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-8411 407
47 always_except LU-14181 64e 64f
50 # skip the grant tests for ARM until they are fixed
51 if [[ $(uname -m) = aarch64 ]]; then
52 always_except LU-11671 45
55 # skip nfs tests on kernels >= 4.12.0 until they are fixed
56 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
57 always_except LU-12661 817
59 # skip cgroup tests on RHEL8.1 kernels until they are fixed
60 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
61 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
62 always_except LU-13063 411
66 [[ "$SLOW" = "no" ]] && EXCEPT_SLOW="27m 60i 64b 68 71 135 136 230d 300o"
68 if [[ "$mds1_FSTYPE" == "zfs" ]]; then
70 [[ "$SLOW" == "no" ]] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
73 if [[ "$ost1_FSTYPE" = "zfs" ]]; then
74 always_except LU-1941 130b 130c 130d 130e 130f 130g
75 always_except LU-9054 312
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 ="
1152 test_mkdir $DIR/R16a
1153 test_mkdir $DIR/R16a/b
1154 test_mkdir $DIR/R16a/b/c
1155 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1156 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1157 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1159 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1161 test_24u() { # bug12192
1162 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1163 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1165 run_test 24u "create stripe file"
1167 simple_cleanup_common() {
1171 [[ -z "$DIR" || -z "$tdir" || ! -d "$DIR/$tdir" ]] && return 0
1173 local start=$SECONDS
1175 [[ -n "$createmany" ]] && unlinkmany $DIR/$tdir/$tfile $createmany
1176 rm -rf $DIR/$tdir || error "cleanup $DIR/$tdir failed"
1178 wait_delete_completed
1179 echo "cleanup time $((SECONDS - start))"
1183 max_pages_per_rpc() {
1184 local mdtname="$(printf "MDT%04x" ${1:-0})"
1185 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1189 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1191 local nrfiles=${COUNT:-100000}
1192 local fname="$DIR/$tdir/$tfile"
1194 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1195 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1197 test_mkdir "$(dirname $fname)"
1198 # assume MDT0000 has the fewest inodes
1199 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1200 local free_inodes=$(($(mdt_free_inodes 0) * ${stripes/#0/1}))
1201 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1203 stack_trap "simple_cleanup_common $nrfiles"
1205 createmany -m "$fname" $nrfiles
1207 cancel_lru_locks mdc
1208 lctl set_param mdc.*.stats clear
1210 # was previously test_24D: LU-6101
1211 # readdir() returns correct number of entries after cursor reload
1212 local num_ls=$(ls $DIR/$tdir | wc -l)
1213 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1214 local num_all=$(ls -a $DIR/$tdir | wc -l)
1215 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1216 [ $num_all -ne $((nrfiles + 2)) ]; then
1217 error "Expected $nrfiles files, got $num_ls " \
1218 "($num_uniq unique $num_all .&..)"
1220 # LU-5 large readdir
1221 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1222 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1223 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1224 # take into account of overhead in lu_dirpage header and end mark in
1225 # each page, plus one in rpc_num calculation.
1226 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1227 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1228 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1229 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1230 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1231 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1232 echo "readpages: $mds_readpage rpc_max: $rpc_max-2/+1"
1233 (( $mds_readpage >= $rpc_max - 2 && $mds_readpage <= $rpc_max + 1)) ||
1234 error "large readdir doesn't take effect: " \
1235 "$mds_readpage should be about $rpc_max"
1237 run_test 24v "list large directory (test hash collision, b=17560)"
1239 test_24w() { # bug21506
1241 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1242 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1243 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1244 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1245 [[ "$SZ1" -eq "$SZ2" ]] ||
1246 error "Error reading at the end of the file $tfile"
1248 run_test 24w "Reading a file larger than 4Gb"
1251 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1252 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1253 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1254 skip "Need MDS version at least 2.7.56"
1257 local remote_dir=$DIR/$tdir/remote_dir
1259 test_mkdir $DIR/$tdir
1260 $LFS mkdir -i $MDTIDX $remote_dir ||
1261 error "create remote directory failed"
1263 test_mkdir $DIR/$tdir/src_dir
1264 touch $DIR/$tdir/src_file
1265 test_mkdir $remote_dir/tgt_dir
1266 touch $remote_dir/tgt_file
1268 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1269 error "rename dir cross MDT failed!"
1271 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1272 error "rename file cross MDT failed!"
1274 touch $DIR/$tdir/ln_file
1275 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1276 error "ln file cross MDT failed"
1278 rm -rf $DIR/$tdir || error "Can not delete directories"
1280 run_test 24x "cross MDT rename/link"
1283 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1284 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1286 local remote_dir=$DIR/$tdir/remote_dir
1289 test_mkdir $DIR/$tdir
1290 $LFS mkdir -i $mdtidx $remote_dir ||
1291 error "create remote directory failed"
1293 test_mkdir $remote_dir/src_dir
1294 touch $remote_dir/src_file
1295 test_mkdir $remote_dir/tgt_dir
1296 touch $remote_dir/tgt_file
1298 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1299 error "rename subdir in the same remote dir failed!"
1301 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1302 error "rename files in the same remote dir failed!"
1304 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1305 error "link files in the same remote dir failed!"
1307 rm -rf $DIR/$tdir || error "Can not delete directories"
1309 run_test 24y "rename/link on the same dir should succeed"
1312 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1313 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1314 skip "Need MDS version at least 2.12.51"
1318 for index in 0 1; do
1319 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1320 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1323 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1325 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1326 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1328 local mdts=$(comma_list $(mdts_nodes))
1330 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1331 stack_trap "do_nodes $mdts $LCTL \
1332 set_param mdt.*.enable_remote_rename=1" EXIT
1334 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1336 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1337 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1339 run_test 24z "cross-MDT rename is done as cp"
1341 test_24A() { # LU-3182
1344 test_mkdir $DIR/$tdir
1345 stack_trap "simple_cleanup_common $NFILES"
1346 createmany -m $DIR/$tdir/$tfile $NFILES
1347 local t=$(ls $DIR/$tdir | wc -l)
1348 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1349 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1351 (( $t == $NFILES && $u == $NFILES && $v == NFILES + 2 )) ||
1352 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1354 run_test 24A "readdir() returns correct number of entries."
1356 test_24B() { # LU-4805
1357 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1361 test_mkdir $DIR/$tdir
1362 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir/ ||
1363 error "create striped dir failed"
1365 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1366 [ $count -eq 2 ] || error "Expected 2, got $count"
1368 touch $DIR/$tdir/striped_dir/a
1370 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1371 [ $count -eq 3 ] || error "Expected 3, got $count"
1373 touch $DIR/$tdir/striped_dir/.f
1375 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1376 [ $count -eq 4 ] || error "Expected 4, got $count"
1378 rm -rf $DIR/$tdir || error "Can not delete directories"
1380 run_test 24B "readdir for striped dir return correct number of entries"
1383 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1389 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1390 error "create striped dir failed"
1392 cd $DIR/$tdir/d0/striped_dir
1394 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1395 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1396 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1398 [ "$d0_ino" = "$parent_ino" ] ||
1399 error ".. wrong, expect $d0_ino, get $parent_ino"
1401 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1402 error "mv striped dir failed"
1404 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1406 [ "$d1_ino" = "$parent_ino" ] ||
1407 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1409 run_test 24C "check .. in striped dir"
1412 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1413 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1416 mkdir $DIR/$tdir/src_dir
1417 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1418 error "create remote source failed"
1420 touch $DIR/$tdir/src_dir/src_child/a
1422 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1423 error "create remote target dir failed"
1425 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1426 error "create remote target child failed"
1428 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1429 error "rename dir cross MDT failed!"
1433 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1434 error "src_child still exists after rename"
1436 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1437 error "missing file(a) after rename"
1439 rm -rf $DIR/$tdir || error "Can not delete directories"
1441 run_test 24E "cross MDT rename/link"
1444 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1447 [ "$SLOW" = "no" ] && repeats=100
1451 echo "$repeats repeats"
1452 for ((i = 0; i < repeats; i++)); do
1453 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1454 touch $DIR/$tdir/test/a || error "touch fails"
1455 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1456 rm -rf $DIR/$tdir/test || error "rmdir fails"
1461 run_test 24F "hash order vs readdir (LU-11330)"
1464 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1469 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1470 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1471 touch $DIR/$tdir-0/f1 || error "touch f1"
1472 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1473 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1474 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1475 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1476 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1478 run_test 24G "migrate symlink in rename"
1481 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1482 [[ $(hostname) != $(facet_active_host mds2) ]] ||
1483 skip "MDT1 should be on another node"
1485 test_mkdir -i 1 -c 1 $DIR/$tdir
1486 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
1487 do_facet mds2 $LCTL set_param fail_loc=0x80001103
1488 touch $DIR/$tdir/$tfile || error "touch failed"
1490 run_test 24H "repeat FLD_QUERY rpc"
1493 echo '== symlink sanity ============================================='
1497 touch $DIR/s25/foo ||
1498 error "File creation in symlinked directory failed"
1500 run_test 25a "create file in symlinked directory ==============="
1503 [ ! -d $DIR/d25 ] && test_25a
1504 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1506 run_test 25b "lookup file in symlinked directory ==============="
1510 test_mkdir $DIR/d26/d26-2
1511 ln -s d26/d26-2 $DIR/s26
1512 touch $DIR/s26/foo || error "File creation failed"
1514 run_test 26a "multiple component symlink ======================="
1517 test_mkdir -p $DIR/$tdir/d26-2
1518 ln -s $tdir/d26-2/foo $DIR/s26-2
1519 touch $DIR/s26-2 || error "File creation failed"
1521 run_test 26b "multiple component symlink at end of lookup ======"
1524 test_mkdir $DIR/d26.2
1525 touch $DIR/d26.2/foo
1526 ln -s d26.2 $DIR/s26.2-1
1527 ln -s s26.2-1 $DIR/s26.2-2
1528 ln -s s26.2-2 $DIR/s26.2-3
1529 chmod 0666 $DIR/s26.2-3/foo
1531 run_test 26c "chain of symlinks"
1533 # recursive symlinks (bug 439)
1535 ln -s d26-3/foo $DIR/d26-3
1537 run_test 26d "create multiple component recursive symlink"
1540 [ ! -h $DIR/d26-3 ] && test_26d
1543 run_test 26e "unlink multiple component recursive symlink"
1545 # recursive symlinks (bug 7022)
1547 test_mkdir $DIR/$tdir
1548 test_mkdir $DIR/$tdir/$tfile
1549 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1550 test_mkdir -p lndir/bar1
1551 test_mkdir $DIR/$tdir/$tfile/$tfile
1552 cd $tfile || error "cd $tfile failed"
1553 ln -s .. dotdot || error "ln dotdot failed"
1554 ln -s dotdot/lndir lndir || error "ln lndir failed"
1555 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1556 output=`ls $tfile/$tfile/lndir/bar1`
1557 [ "$output" = bar1 ] && error "unexpected output"
1558 rm -r $tfile || error "rm $tfile failed"
1559 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1561 run_test 26f "rm -r of a directory which has recursive symlink"
1564 test_mkdir $DIR/$tdir
1565 $LFS getstripe $DIR/$tdir
1566 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1567 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1568 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1570 run_test 27a "one stripe file"
1573 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1575 test_mkdir $DIR/$tdir
1576 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1577 $LFS getstripe -c $DIR/$tdir/$tfile
1578 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1579 error "two-stripe file doesn't have two stripes"
1581 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1583 run_test 27b "create and write to two stripe file"
1585 # 27c family tests specific striping, setstripe -o
1587 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1588 test_mkdir -p $DIR/$tdir
1591 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1592 $LFS getstripe -i $DIR/$tdir/$tfile
1593 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1594 error "stripe not on specified OST"
1596 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1598 run_test 27ca "one stripe on specified OST"
1601 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1602 test_mkdir -p $DIR/$tdir
1604 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1605 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1608 # Strip getstripe output to a space separated list of OSTs
1609 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1610 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1611 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1612 error "stripes not on specified OSTs"
1614 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1616 run_test 27cb "two stripes on specified OSTs"
1619 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1620 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1621 skip "server does not support overstriping"
1623 test_mkdir -p $DIR/$tdir
1625 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1626 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1629 # Strip getstripe output to a space separated list of OSTs
1630 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1631 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1632 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1633 error "stripes not on specified OSTs"
1635 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1637 run_test 27cc "two stripes on the same OST"
1640 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1641 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1642 skip "server does not support overstriping"
1643 test_mkdir -p $DIR/$tdir
1644 local osts="0,1,1,0"
1645 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1646 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1649 # Strip getstripe output to a space separated list of OSTs
1650 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1651 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1652 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1653 error "stripes not on specified OSTs"
1655 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1657 run_test 27cd "four stripes on two OSTs"
1660 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1661 skip_env "too many osts, skipping"
1662 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1663 skip "server does not support overstriping"
1664 # We do one more stripe than we have OSTs
1665 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1666 skip_env "ea_inode feature disabled"
1668 test_mkdir -p $DIR/$tdir
1670 for i in $(seq 0 $OSTCOUNT);
1673 if [ $i -ne $OSTCOUNT ]; then
1677 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1678 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1681 # Strip getstripe output to a space separated list of OSTs
1682 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1683 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1684 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1685 error "stripes not on specified OSTs"
1687 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1689 run_test 27ce "more stripes than OSTs with -o"
1692 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1695 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1696 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1697 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1698 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1699 error "failed to set $osp_proc=0"
1701 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1704 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1705 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1706 error "failed to set $osp_proc=1"
1709 error "should return error due to $osp_proc=0"
1711 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1714 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1715 skip "server does not support overstriping"
1716 [[ $mds1_FSTYPE != "ldiskfs" ]] && skip_env "ldiskfs only test"
1717 large_xattr_enabled || skip_env "ea_inode feature disabled"
1721 for ((i=1;i<1000;i++)); do
1722 osts+=",$((i % OSTCOUNT))"
1725 local mdts=$(comma_list $(mdts_nodes))
1726 local before=$(do_nodes $mdts \
1727 "$LCTL get_param -n osd-ldiskfs.*MDT*.stats" |
1728 awk '/many credits/{print $3}' |
1731 $LFS setstripe -o $osts $DIR/$tfile || error "setstripe failed"
1732 $LFS getstripe $DIR/$tfile | grep stripe
1734 rm -f $DIR/$tfile || error "can't unlink"
1736 after=$(do_nodes $mdts \
1737 "$LCTL get_param -n osd-ldiskfs.*MDT*.stats" |
1738 awk '/many credits/{print $3}' |
1741 (( before == after )) ||
1742 error "too many credits happened: $after > $before"
1744 run_test 27cg "1000 shouldn't cause too many credits"
1747 test_mkdir $DIR/$tdir
1748 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1749 error "setstripe failed"
1750 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1751 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1753 run_test 27d "create file with default settings"
1756 # LU-5839 adds check for existed layout before setting it
1757 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1758 skip "Need MDS version at least 2.7.56"
1760 test_mkdir $DIR/$tdir
1761 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1762 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1763 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1765 run_test 27e "setstripe existing file (should return error)"
1768 test_mkdir $DIR/$tdir
1769 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1770 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1771 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1772 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1773 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1774 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1776 run_test 27f "setstripe with bad stripe size (should return error)"
1779 test_mkdir $DIR/$tdir
1780 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1781 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1782 error "$DIR/$tdir/$tfile has object"
1784 run_test 27g "$LFS getstripe with no objects"
1787 test_mkdir $DIR/$tdir
1788 touch $DIR/$tdir/$tfile || error "touch failed"
1789 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1790 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1792 (( rc == 2 )) || error "getstripe did not return ENOENT"
1794 run_test 27ga "$LFS getstripe with missing file (should return error)"
1797 test_mkdir $DIR/$tdir
1798 touch $DIR/$tdir/$tfile || error "touch failed"
1799 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1800 error "missing objects"
1802 run_test 27i "$LFS getstripe with some objects"
1805 test_mkdir $DIR/$tdir
1806 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1807 error "setstripe failed" || true
1809 run_test 27j "setstripe with bad stripe offset (should return error)"
1811 test_27k() { # bug 2844
1812 test_mkdir $DIR/$tdir
1813 local file=$DIR/$tdir/$tfile
1814 local ll_max_blksize=$((4 * 1024 * 1024))
1815 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1816 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1817 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1818 dd if=/dev/zero of=$file bs=4k count=1
1819 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1820 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1822 run_test 27k "limit i_blksize for broken user apps"
1825 mcreate $DIR/$tfile || error "creating file"
1826 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1827 error "setstripe should have failed" || true
1829 run_test 27l "check setstripe permissions (should return error)"
1832 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1834 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1835 skip_env "multiple clients -- skipping"
1837 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1839 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1840 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1842 stack_trap simple_cleanup_common
1843 test_mkdir $DIR/$tdir
1844 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1845 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1846 error "dd should fill OST0"
1848 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1850 [ $i -gt 256 ] && break
1853 touch $DIR/$tdir/$tfile.$i
1854 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1855 awk '{print $1}'| grep -w "0") ] &&
1856 error "OST0 was full but new created file still use it"
1858 touch $DIR/$tdir/$tfile.$i
1859 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1860 awk '{print $1}'| grep -w "0") ] &&
1861 error "OST0 was full but new created file still use it" || true
1863 run_test 27m "create file while OST0 was full"
1865 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1866 # if the OST isn't full anymore.
1868 local ostidx=${1:-""}
1873 local list=$(comma_list $(osts_nodes))
1874 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1876 do_nodes $list lctl set_param fail_loc=0
1877 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1878 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1879 awk '{print $1 * 2;exit;}')
1880 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1882 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1886 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1887 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1888 remote_mds_nodsh && skip "remote MDS with nodsh"
1889 remote_ost_nodsh && skip "remote OST with nodsh"
1892 rm -f $DIR/$tdir/$tfile
1893 exhaust_precreations 0 0x80000215
1894 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1895 touch $DIR/$tdir/$tfile || error "touch failed"
1896 $LFS getstripe $DIR/$tdir/$tfile
1899 run_test 27n "create file with some full OSTs"
1902 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1904 remote_mds_nodsh && skip "remote MDS with nodsh"
1905 remote_ost_nodsh && skip "remote OST with nodsh"
1908 rm -f $DIR/$tdir/$tfile
1909 exhaust_all_precreations 0x215
1911 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1916 run_test 27o "create file with all full OSTs (should error)"
1918 function create_and_checktime() {
1923 for ((i=0; i < $loops; i++)); do
1924 local start=$SECONDS
1925 multiop $fname-$i Oc
1926 ((SECONDS-start < TIMEOUT)) ||
1927 error "creation took " $((SECONDS-$start)) && return 1
1932 local mdts=$(comma_list $(mdts_nodes))
1934 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1935 skip "Need MDS version at least 2.13.57"
1937 local f0=$DIR/${tfile}-0
1938 local f1=$DIR/${tfile}-1
1940 wait_delete_completed
1942 # refill precreated objects
1943 $LFS setstripe -i0 -c1 $f0
1945 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1946 # force QoS allocation policy
1947 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1948 stack_trap "do_nodes $mdts $LCTL set_param \
1949 lov.*.qos_threshold_rr=$saved" EXIT
1952 # one OST is unavailable, but still have few objects preallocated
1954 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1955 rm -rf $f1 $DIR/$tdir*" EXIT
1957 for ((i=0; i < 7; i++)); do
1958 mkdir $DIR/$tdir$i || error "can't create dir"
1959 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1960 error "can't set striping"
1962 for ((i=0; i < 7; i++)); do
1963 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1967 run_test 27oo "don't let few threads to reserve too many objects"
1970 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1971 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1972 remote_mds_nodsh && skip "remote MDS with nodsh"
1973 remote_ost_nodsh && skip "remote OST with nodsh"
1976 rm -f $DIR/$tdir/$tfile
1977 test_mkdir $DIR/$tdir
1979 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1980 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1981 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1983 exhaust_precreations 0 0x80000215
1984 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1985 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1986 $LFS getstripe $DIR/$tdir/$tfile
1990 run_test 27p "append to a truncated file with some full OSTs"
1993 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1994 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1995 remote_mds_nodsh && skip "remote MDS with nodsh"
1996 remote_ost_nodsh && skip "remote OST with nodsh"
1999 rm -f $DIR/$tdir/$tfile
2001 mkdir_on_mdt0 $DIR/$tdir
2002 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
2003 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
2004 error "truncate $DIR/$tdir/$tfile failed"
2005 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
2007 exhaust_all_precreations 0x215
2009 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
2010 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
2014 run_test 27q "append to truncated file with all OSTs full (should error)"
2017 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2018 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2019 remote_mds_nodsh && skip "remote MDS with nodsh"
2020 remote_ost_nodsh && skip "remote OST with nodsh"
2023 rm -f $DIR/$tdir/$tfile
2024 exhaust_precreations 0 0x80000215
2026 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
2030 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
2032 test_27s() { # bug 10725
2033 test_mkdir $DIR/$tdir
2034 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2035 local stripe_count=0
2036 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2037 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2038 error "stripe width >= 2^32 succeeded" || true
2041 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2043 test_27t() { # bug 10864
2048 $WLFS getstripe $tfile
2051 run_test 27t "check that utils parse path correctly"
2053 test_27u() { # bug 4900
2054 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2055 remote_mds_nodsh && skip "remote MDS with nodsh"
2058 local list=$(comma_list $(mdts_nodes))
2060 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2061 do_nodes $list $LCTL set_param fail_loc=0x139
2062 test_mkdir -p $DIR/$tdir
2063 stack_trap "simple_cleanup_common 1000"
2064 createmany -o $DIR/$tdir/$tfile 1000
2065 do_nodes $list $LCTL set_param fail_loc=0
2067 TLOG=$TMP/$tfile.getstripe
2068 $LFS getstripe $DIR/$tdir > $TLOG
2069 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2070 [[ $OBJS -gt 0 ]] &&
2071 error "$OBJS objects created on OST-0. See $TLOG" ||
2074 run_test 27u "skip object creation on OSC w/o objects"
2076 test_27v() { # bug 4900
2077 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2078 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2079 remote_mds_nodsh && skip "remote MDS with nodsh"
2080 remote_ost_nodsh && skip "remote OST with nodsh"
2082 exhaust_all_precreations 0x215
2085 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2087 touch $DIR/$tdir/$tfile
2088 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2090 for (( i=1; i < OSTCOUNT; i++ )); do
2091 do_facet ost$i lctl set_param fail_loc=0x705
2093 local START=`date +%s`
2094 createmany -o $DIR/$tdir/$tfile 32
2096 local FINISH=`date +%s`
2097 local TIMEOUT=`lctl get_param -n timeout`
2098 local PROCESS=$((FINISH - START))
2099 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2100 error "$FINISH - $START >= $TIMEOUT / 2"
2101 sleep $((TIMEOUT / 2 - PROCESS))
2104 run_test 27v "skip object creation on slow OST"
2106 test_27w() { # bug 10997
2107 test_mkdir $DIR/$tdir
2108 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2109 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2110 error "stripe size $size != 65536" || true
2111 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2112 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2114 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2117 [[ $OSTCOUNT -lt 2 ]] &&
2118 skip_env "skipping multiple stripe count/offset test"
2120 test_mkdir $DIR/$tdir
2121 for i in $(seq 1 $OSTCOUNT); do
2123 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2124 error "setstripe -c $i -i $offset failed"
2125 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2126 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2127 [ $count -ne $i ] && error "stripe count $count != $i" || true
2128 [ $index -ne $offset ] &&
2129 error "stripe offset $index != $offset" || true
2132 run_test 27wa "check $LFS setstripe -c -i options"
2135 remote_ost_nodsh && skip "remote OST with nodsh"
2136 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2139 OFFSET=$(($OSTCOUNT - 1))
2141 local OST=$(ostname_from_index $OSTIDX)
2143 test_mkdir $DIR/$tdir
2144 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2145 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2147 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2148 for i in $(seq 0 $OFFSET); do
2149 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2150 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2151 error "OST0 was degraded but new created file still use it"
2153 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2155 run_test 27x "create files while OST0 is degraded"
2158 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2159 remote_mds_nodsh && skip "remote MDS with nodsh"
2160 remote_ost_nodsh && skip "remote OST with nodsh"
2161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2163 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2164 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2165 osp.$mdtosc.prealloc_last_id)
2166 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2167 osp.$mdtosc.prealloc_next_id)
2168 local fcount=$((last_id - next_id))
2169 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2170 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2172 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2173 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2174 local OST_DEACTIVE_IDX=-1
2179 for OSC in $MDS_OSCS; do
2180 OST=$(osc_to_ost $OSC)
2181 OSTIDX=$(index_from_ostuuid $OST)
2182 if [ $OST_DEACTIVE_IDX == -1 ]; then
2183 OST_DEACTIVE_IDX=$OSTIDX
2185 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2186 echo $OSC "is Deactivated:"
2187 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2191 OSTIDX=$(index_from_ostuuid $OST)
2192 test_mkdir $DIR/$tdir
2193 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2195 for OSC in $MDS_OSCS; do
2196 OST=$(osc_to_ost $OSC)
2197 OSTIDX=$(index_from_ostuuid $OST)
2198 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2199 echo $OST "is degraded:"
2200 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2201 obdfilter.$OST.degraded=1
2206 createmany -o $DIR/$tdir/$tfile $fcount
2208 for OSC in $MDS_OSCS; do
2209 OST=$(osc_to_ost $OSC)
2210 OSTIDX=$(index_from_ostuuid $OST)
2211 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2212 echo $OST "is recovered from degraded:"
2213 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2214 obdfilter.$OST.degraded=0
2216 do_facet $SINGLEMDS lctl --device %$OSC activate
2220 # all osp devices get activated, hence -1 stripe count restored
2221 local stripe_count=0
2223 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2224 # devices get activated.
2226 $LFS setstripe -c -1 $DIR/$tfile
2227 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2229 [ $stripe_count -ne $OSTCOUNT ] &&
2230 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2233 run_test 27y "create files while OST0 is degraded and the rest inactive"
2239 lmm_count=$($LFS getstripe -c $1)
2240 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2241 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2243 local old_ifs="$IFS"
2245 fid=($($LFS path2fid $1))
2248 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2249 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2251 # compare lmm_seq and lu_fid->f_seq
2252 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2253 # compare lmm_object_id and lu_fid->oid
2254 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2256 # check the trusted.fid attribute of the OST objects of the file
2257 local have_obdidx=false
2259 $LFS getstripe $1 | while read obdidx oid hex seq; do
2260 # skip lines up to and including "obdidx"
2261 [ -z "$obdidx" ] && break
2262 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2263 $have_obdidx || continue
2265 local ost=$((obdidx + 1))
2266 local dev=$(ostdevname $ost)
2269 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2271 seq=$(echo $seq | sed -e "s/^0x//g")
2272 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2273 oid_hex=$(echo $oid)
2275 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2277 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2281 # Don't unmount/remount the OSTs if we don't need to do that.
2282 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2283 # update too, until that use mount/ll_decode_filter_fid/mount.
2284 # Re-enable when debugfs will understand new filter_fid.
2286 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2287 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2288 $dev 2>/dev/null" | grep "parent=")
2290 if [ -z "$ff" ]; then
2292 mount_fstype ost$ost
2293 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2294 $(facet_mntpt ost$ost)/$obj_file)
2295 unmount_fstype ost$ost
2296 start ost$ost $dev $OST_MOUNT_OPTS
2300 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2302 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2304 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2305 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2307 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2308 # stripe_size=1048576 component_id=1 component_start=0 \
2309 # component_end=33554432
2310 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2311 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2312 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2314 if grep -q 'stripe=' <<<$ff; then
2315 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2317 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2318 # into f_ver in this case. See comment on ff_parent.
2319 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2322 # compare lmm_seq and filter_fid->ff_parent.f_seq
2323 [ $ff_pseq = $lmm_seq ] ||
2324 error "FF parent SEQ $ff_pseq != $lmm_seq"
2325 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2326 [ $ff_poid = $lmm_oid ] ||
2327 error "FF parent OID $ff_poid != $lmm_oid"
2328 (($ff_pstripe == $stripe_nr)) ||
2329 error "FF stripe $ff_pstripe != $stripe_nr"
2331 stripe_nr=$((stripe_nr + 1))
2332 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2334 if grep -q 'stripe_count=' <<<$ff; then
2335 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2336 -e 's/ .*//' <<<$ff)
2337 [ $lmm_count = $ff_scnt ] ||
2338 error "FF stripe count $lmm_count != $ff_scnt"
2344 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2345 remote_ost_nodsh && skip "remote OST with nodsh"
2347 test_mkdir $DIR/$tdir
2348 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2349 { error "setstripe -c -1 failed"; return 1; }
2350 # We need to send a write to every object to get parent FID info set.
2351 # This _should_ also work for setattr, but does not currently.
2352 # touch $DIR/$tdir/$tfile-1 ||
2353 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2354 { error "dd $tfile-1 failed"; return 2; }
2355 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2356 { error "setstripe -c -1 failed"; return 3; }
2357 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2358 { error "dd $tfile-2 failed"; return 4; }
2360 # make sure write RPCs have been sent to OSTs
2363 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2364 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2366 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2368 test_27A() { # b=19102
2369 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2371 save_layout_restore_at_exit $MOUNT
2372 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2373 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2374 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2375 local default_size=$($LFS getstripe -S $MOUNT)
2376 local default_offset=$($LFS getstripe -i $MOUNT)
2377 local dsize=$(do_facet $SINGLEMDS \
2378 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2379 [ $default_size -eq $dsize ] ||
2380 error "stripe size $default_size != $dsize"
2381 [ $default_offset -eq -1 ] ||
2382 error "stripe offset $default_offset != -1"
2384 run_test 27A "check filesystem-wide default LOV EA values"
2386 test_27B() { # LU-2523
2387 test_mkdir $DIR/$tdir
2388 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2390 # open f1 with O_LOV_DELAY_CREATE
2392 # call setstripe ioctl on open file descriptor for f1
2394 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2398 # open f1 with O_LOV_DELAY_CREATE
2400 # call setstripe ioctl on open file descriptor for f1
2402 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2404 # Allow multiop to fail in imitation of NFS's busted semantics.
2407 run_test 27B "call setstripe on open unlinked file/rename victim"
2409 # 27C family tests full striping and overstriping
2410 test_27Ca() { #LU-2871
2411 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2419 test_mkdir $DIR/$tdir
2421 for i in $(seq 0 $((OSTCOUNT - 1))); do
2422 # set stripe across all OSTs starting from OST$i
2423 $LFS setstripe -i $i -c -1 $tfile$i
2424 # get striping information
2425 ost_idx=($($LFS getstripe $tfile$i |
2426 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2427 echo "OST Index: ${ost_idx[*]}"
2430 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2431 error "${#ost_idx[@]} != $OSTCOUNT"
2433 for index in $(seq 0 $((OSTCOUNT - 1))); do
2435 for j in "${ost_idx[@]}"; do
2436 if [ $index -eq $j ]; then
2442 error "Can not find $index in ${ost_idx[*]}"
2446 run_test 27Ca "check full striping across all OSTs"
2449 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2450 skip "server does not support overstriping"
2451 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2452 skip_env "too many osts, skipping"
2454 test_mkdir -p $DIR/$tdir
2455 local setcount=$(($OSTCOUNT * 2))
2456 [ $setcount -lt 160 ] || large_xattr_enabled ||
2457 skip_env "ea_inode feature disabled"
2459 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2460 error "setstripe failed"
2462 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2463 [ $count -eq $setcount ] ||
2464 error "stripe count $count, should be $setcount"
2466 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2467 error "overstriped should be set in pattern"
2469 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2472 run_test 27Cb "more stripes than OSTs with -C"
2475 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2476 skip "server does not support overstriping"
2477 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2479 test_mkdir -p $DIR/$tdir
2480 local setcount=$(($OSTCOUNT - 1))
2482 [ $setcount -lt 160 ] || large_xattr_enabled ||
2483 skip_env "ea_inode feature disabled"
2485 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2486 error "setstripe failed"
2488 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2489 [ $count -eq $setcount ] ||
2490 error "stripe count $count, should be $setcount"
2492 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2493 error "overstriped should not be set in pattern"
2495 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2498 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2501 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2502 skip "server does not support overstriping"
2503 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2504 large_xattr_enabled || skip_env "ea_inode feature disabled"
2506 test_mkdir -p $DIR/$tdir
2507 local setcount=$LOV_MAX_STRIPE_COUNT
2509 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2510 error "setstripe failed"
2512 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2513 [ $count -eq $setcount ] ||
2514 error "stripe count $count, should be $setcount"
2516 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2517 error "overstriped should be set in pattern"
2519 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2522 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2524 run_test 27Cd "test maximum stripe count"
2527 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2528 skip "server does not support overstriping"
2529 test_mkdir -p $DIR/$tdir
2531 pool_add $TESTNAME || error "Pool creation failed"
2532 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2536 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2537 error "setstripe failed"
2539 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2540 [ $count -eq $setcount ] ||
2541 error "stripe count $count, should be $setcount"
2543 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2544 error "overstriped should be set in pattern"
2546 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2549 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2551 run_test 27Ce "test pool with overstriping"
2554 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2555 skip "server does not support overstriping"
2556 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2557 skip_env "too many osts, skipping"
2559 test_mkdir -p $DIR/$tdir
2561 local setcount=$(($OSTCOUNT * 2))
2562 [ $setcount -lt 160 ] || large_xattr_enabled ||
2563 skip_env "ea_inode feature disabled"
2565 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2566 error "setstripe failed"
2568 echo 1 > $DIR/$tdir/$tfile
2570 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2571 [ $count -eq $setcount ] ||
2572 error "stripe count $count, should be $setcount"
2574 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2575 error "overstriped should be set in pattern"
2577 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2580 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2582 run_test 27Cf "test default inheritance with overstriping"
2585 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2586 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2587 remote_mds_nodsh && skip "remote MDS with nodsh"
2589 local POOL=${POOL:-testpool}
2591 local last_ost=$(($OSTCOUNT - 1))
2593 local ost_list=$(seq $first_ost $ost_step $last_ost)
2594 local ost_range="$first_ost $last_ost $ost_step"
2596 test_mkdir $DIR/$tdir
2597 pool_add $POOL || error "pool_add failed"
2598 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2601 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2603 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2604 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2605 skip27D+=" -s 30,31"
2606 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2607 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2608 skip27D+=" -s 32,33"
2609 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2611 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2612 error "llapi_layout_test failed"
2614 destroy_test_pools || error "destroy test pools failed"
2616 run_test 27D "validate llapi_layout API"
2618 # Verify that default_easize is increased from its initial value after
2619 # accessing a widely striped file.
2621 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2622 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2623 skip "client does not have LU-3338 fix"
2625 # 72 bytes is the minimum space required to store striping
2626 # information for a file striped across one OST:
2627 # (sizeof(struct lov_user_md_v3) +
2628 # sizeof(struct lov_user_ost_data_v1))
2630 $LCTL set_param -n llite.*.default_easize $min_easize ||
2631 error "lctl set_param failed"
2632 local easize=$($LCTL get_param -n llite.*.default_easize)
2634 [ $easize -eq $min_easize ] ||
2635 error "failed to set default_easize"
2637 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2638 error "setstripe failed"
2639 # In order to ensure stat() call actually talks to MDS we need to
2640 # do something drastic to this file to shake off all lock, e.g.
2641 # rename it (kills lookup lock forcing cache cleaning)
2642 mv $DIR/$tfile $DIR/${tfile}-1
2643 ls -l $DIR/${tfile}-1
2646 easize=$($LCTL get_param -n llite.*.default_easize)
2648 [ $easize -gt $min_easize ] ||
2649 error "default_easize not updated"
2651 run_test 27E "check that default extended attribute size properly increases"
2653 test_27F() { # LU-5346/LU-7975
2654 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2655 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2656 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2657 skip "Need MDS version at least 2.8.51"
2658 remote_ost_nodsh && skip "remote OST with nodsh"
2660 test_mkdir $DIR/$tdir
2662 $LFS setstripe -c 2 $DIR/$tdir
2664 # stop all OSTs to reproduce situation for LU-7975 ticket
2665 for num in $(seq $OSTCOUNT); do
2669 # open/create f0 with O_LOV_DELAY_CREATE
2670 # truncate f0 to a non-0 size
2672 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2674 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2675 # open/write it again to force delayed layout creation
2676 cat /etc/hosts > $DIR/$tdir/f0 &
2680 for num in $(seq $OSTCOUNT); do
2681 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2682 error "ost$num failed to start"
2685 wait $catpid || error "cat failed"
2687 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2688 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2689 error "wrong stripecount"
2692 run_test 27F "Client resend delayed layout creation with non-zero size"
2694 test_27G() { #LU-10629
2695 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2696 skip "Need MDS version at least 2.11.51"
2697 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2698 remote_mds_nodsh && skip "remote MDS with nodsh"
2699 local POOL=${POOL:-testpool}
2700 local ostrange="0 0 1"
2702 test_mkdir $DIR/$tdir
2703 touch $DIR/$tdir/$tfile.nopool
2704 pool_add $POOL || error "pool_add failed"
2705 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2706 $LFS setstripe -p $POOL $DIR/$tdir
2708 local pool=$($LFS getstripe -p $DIR/$tdir)
2710 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2711 touch $DIR/$tdir/$tfile.default
2712 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2713 $LFS find $DIR/$tdir -type f --pool $POOL
2714 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2715 [[ "$found" == "2" ]] ||
2716 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2718 $LFS setstripe -d $DIR/$tdir
2720 pool=$($LFS getstripe -p -d $DIR/$tdir)
2722 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2724 run_test 27G "Clear OST pool from stripe"
2727 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2728 skip "Need MDS version newer than 2.11.54"
2729 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2730 test_mkdir $DIR/$tdir
2731 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2732 touch $DIR/$tdir/$tfile
2733 $LFS getstripe -c $DIR/$tdir/$tfile
2734 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2735 error "two-stripe file doesn't have two stripes"
2737 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2738 $LFS getstripe -y $DIR/$tdir/$tfile
2739 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2740 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2741 error "expected l_ost_idx: [02]$ not matched"
2743 # make sure ost list has been cleared
2744 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2745 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2746 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2748 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2750 run_test 27H "Set specific OSTs stripe"
2753 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2754 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2755 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2756 skip "Need MDS version newer than 2.12.52"
2757 local pool=$TESTNAME
2758 local ostrange="1 1 1"
2760 save_layout_restore_at_exit $MOUNT
2761 $LFS setstripe -c 2 -i 0 $MOUNT
2762 pool_add $pool || error "pool_add failed"
2763 pool_add_targets $pool $ostrange ||
2764 error "pool_add_targets failed"
2765 test_mkdir $DIR/$tdir
2766 $LFS setstripe -p $pool $DIR/$tdir
2767 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2768 $LFS getstripe $DIR/$tdir/$tfile
2770 run_test 27I "check that root dir striping does not break parent dir one"
2773 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2774 skip "Need MDS version newer than 2.12.51"
2776 test_mkdir $DIR/$tdir
2777 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2778 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2780 # create foreign file (raw way)
2781 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2782 error "creating $tfile w/ hex flags w/o --foreign should fail"
2784 ! $LFS setstripe --foreign --flags foo \
2785 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2786 error "creating $tfile with '--flags foo' should fail"
2788 ! $LFS setstripe --foreign --flags 0xffffffff \
2789 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2790 error "creating $tfile w/ 0xffffffff flags should fail"
2792 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2793 -t 1 -F 0xda08 || error "create_foreign_file failed"
2795 # verify foreign file (raw way)
2796 parse_foreign_file -f $DIR/$tdir/$tfile |
2797 grep "lov_foreign_magic: 0x0BD70BD0" ||
2798 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2799 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2800 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2801 parse_foreign_file -f $DIR/$tdir/$tfile |
2802 grep "lov_foreign_size: 73" ||
2803 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2804 parse_foreign_file -f $DIR/$tdir/$tfile |
2805 grep "lov_foreign_type: 1" ||
2806 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2807 parse_foreign_file -f $DIR/$tdir/$tfile |
2808 grep "lov_foreign_flags: 0x0000DA08" ||
2809 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2810 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2811 grep "lov_foreign_value: 0x" |
2812 sed -e 's/lov_foreign_value: 0x//')
2813 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2814 [[ $lov = ${lov2// /} ]] ||
2815 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2817 # create foreign file (lfs + API)
2818 $LFS setstripe --foreign=none --flags 0xda08 \
2819 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2820 error "$DIR/$tdir/${tfile}2: create failed"
2822 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2823 grep "lfm_magic:.*0x0BD70BD0" ||
2824 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2825 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2826 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2827 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2828 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2829 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2830 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2831 grep "lfm_flags:.*0x0000DA08" ||
2832 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2833 $LFS getstripe $DIR/$tdir/${tfile}2 |
2834 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2835 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2837 # modify striping should fail
2838 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2839 error "$DIR/$tdir/$tfile: setstripe should fail"
2840 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2841 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2844 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2845 cat $DIR/$tdir/${tfile}2 &&
2846 error "$DIR/$tdir/${tfile}2: read should fail"
2847 cat /etc/passwd > $DIR/$tdir/$tfile &&
2848 error "$DIR/$tdir/$tfile: write should fail"
2849 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2850 error "$DIR/$tdir/${tfile}2: write should fail"
2853 chmod 222 $DIR/$tdir/$tfile ||
2854 error "$DIR/$tdir/$tfile: chmod failed"
2855 chmod 222 $DIR/$tdir/${tfile}2 ||
2856 error "$DIR/$tdir/${tfile}2: chmod failed"
2859 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2860 error "$DIR/$tdir/$tfile: chown failed"
2861 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2862 error "$DIR/$tdir/${tfile}2: chown failed"
2864 # rename should work
2865 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2866 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2867 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2868 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2870 #remove foreign file
2871 rm $DIR/$tdir/${tfile}.new ||
2872 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2873 rm $DIR/$tdir/${tfile}2.new ||
2874 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2876 run_test 27J "basic ops on file with foreign LOV"
2879 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2880 skip "Need MDS version newer than 2.12.49"
2882 test_mkdir $DIR/$tdir
2883 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2884 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2886 # create foreign dir (raw way)
2887 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2888 error "creating $tdir w/ hex flags w/o --foreign should fail"
2890 ! $LFS setdirstripe --foreign --flags foo \
2891 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2892 error "creating $tdir with '--flags foo' should fail"
2894 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2895 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2896 error "creating $tdir w/ 0xffffffff flags should fail"
2898 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2899 error "create_foreign_dir FAILED"
2901 # verify foreign dir (raw way)
2902 parse_foreign_dir -d $DIR/$tdir/$tdir |
2903 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2904 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2905 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2906 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2907 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2908 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2909 parse_foreign_dir -d $DIR/$tdir/$tdir |
2910 grep "lmv_foreign_flags: 55813$" ||
2911 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2912 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2913 grep "lmv_foreign_value: 0x" |
2914 sed 's/lmv_foreign_value: 0x//')
2915 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2917 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2919 # create foreign dir (lfs + API)
2920 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2921 $DIR/$tdir/${tdir}2 ||
2922 error "$DIR/$tdir/${tdir}2: create failed"
2924 $LFS getdirstripe -v $DIR/$tdir/${tdir}2
2926 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2927 grep "lfm_magic:.*0x0CD50CD0" ||
2928 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2929 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2930 # - sizeof(lfm_type) - sizeof(lfm_flags)
2931 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2932 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2933 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2934 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2935 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2936 grep "lfm_flags:.*0x0000DA05" ||
2937 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2938 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2939 grep "lfm_value.*${uuid1}@${uuid2}" ||
2940 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2942 # file create in dir should fail
2943 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
2944 touch $DIR/$tdir/${tdir}2/$tfile &&
2945 error "$DIR/${tdir}2: file create should fail"
2948 chmod 777 $DIR/$tdir/$tdir ||
2949 error "$DIR/$tdir: chmod failed"
2950 chmod 777 $DIR/$tdir/${tdir}2 ||
2951 error "$DIR/${tdir}2: chmod failed"
2954 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2955 error "$DIR/$tdir: chown failed"
2956 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2957 error "$DIR/${tdir}2: chown failed"
2959 # rename should work
2960 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2961 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2962 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2963 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2966 rmdir $DIR/$tdir/${tdir}.new ||
2967 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2968 rmdir $DIR/$tdir/${tdir}2.new ||
2969 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2971 run_test 27K "basic ops on dir with foreign LMV"
2974 remote_mds_nodsh && skip "remote MDS with nodsh"
2976 local POOL=${POOL:-$TESTNAME}
2978 pool_add $POOL || error "pool_add failed"
2980 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2981 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2982 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2984 run_test 27L "lfs pool_list gives correct pool name"
2987 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2988 skip "Need MDS version >= than 2.12.57"
2989 remote_mds_nodsh && skip "remote MDS with nodsh"
2990 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2992 # Set default striping on directory
2995 local mdts=$(comma_list $(mdts_nodes))
2997 # if we run against a 2.12 server which lacks overstring support
2998 # then the connect_flag will not report overstriping, even if client
3000 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
3001 stripe_opt="-C $setcount"
3002 elif (( $OSTCOUNT >= $setcount )); then
3003 stripe_opt="-c $setcount"
3005 skip "server does not support overstriping"
3008 test_mkdir $DIR/$tdir
3010 # Validate existing append_* params and ensure restore
3011 local pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3012 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3013 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3015 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3016 ((orig_count == 1)) || error "expected append_stripe_count == 1, got $orig_count"
3017 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1"
3019 $LFS setstripe $stripe_opt $DIR/$tdir
3021 echo 1 > $DIR/$tdir/${tfile}.1
3022 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
3023 [ $count -eq $setcount ] ||
3024 error "(1) stripe count $count, should be $setcount"
3026 local appendcount=$orig_count
3027 echo 1 >> $DIR/$tdir/${tfile}.2_append
3028 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
3029 [ $count -eq $appendcount ] ||
3030 error "(2)stripe count $count, should be $appendcount for append"
3032 # Disable O_APPEND striping, verify it works
3033 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3035 # Should now get the default striping, which is 4
3037 echo 1 >> $DIR/$tdir/${tfile}.3_append
3038 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3039 [ $count -eq $setcount ] ||
3040 error "(3) stripe count $count, should be $setcount"
3042 # Try changing the stripe count for append files
3043 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3045 # Append striping is now 2 (directory default is still 4)
3047 echo 1 >> $DIR/$tdir/${tfile}.4_append
3048 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3049 [ $count -eq $appendcount ] ||
3050 error "(4) stripe count $count, should be $appendcount for append"
3052 # Test append stripe count of -1
3053 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3054 appendcount=$OSTCOUNT
3055 echo 1 >> $DIR/$tdir/${tfile}.5
3056 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3057 [ $count -eq $appendcount ] ||
3058 error "(5) stripe count $count, should be $appendcount for append"
3060 # Set append striping back to default of 1
3061 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3063 # Try a new default striping, PFL + DOM
3064 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3066 # Create normal DOM file, DOM returns stripe count == 0
3068 touch $DIR/$tdir/${tfile}.6
3069 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3070 [ $count -eq $setcount ] ||
3071 error "(6) stripe count $count, should be $setcount"
3075 echo 1 >> $DIR/$tdir/${tfile}.7_append
3076 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3077 [ $count -eq $appendcount ] ||
3078 error "(7) stripe count $count, should be $appendcount for append"
3080 # Clean up DOM layout
3081 $LFS setstripe -d $DIR/$tdir
3083 save_layout_restore_at_exit $MOUNT
3084 # Now test that append striping works when layout is from root
3085 $LFS setstripe -c 2 $MOUNT
3086 # Make a special directory for this
3087 mkdir $DIR/${tdir}/${tdir}.2
3089 # Verify for normal file
3091 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3092 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3093 [ $count -eq $setcount ] ||
3094 error "(8) stripe count $count, should be $setcount"
3097 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3098 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3099 [ $count -eq $appendcount ] ||
3100 error "(9) stripe count $count, should be $appendcount for append"
3102 # Now test O_APPEND striping with pools
3103 pool_add $TESTNAME || error "pool creation failed"
3104 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3105 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3107 echo 1 >> $DIR/$tdir/${tfile}.10_append
3109 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3110 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3112 # Check that count is still correct
3114 echo 1 >> $DIR/$tdir/${tfile}.11_append
3115 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3116 [ $count -eq $appendcount ] ||
3117 error "(11) stripe count $count, should be $appendcount for append"
3119 # Disable O_APPEND stripe count, verify pool works separately
3120 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3122 echo 1 >> $DIR/$tdir/${tfile}.12_append
3124 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3125 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3127 # Remove pool setting, verify it's not applied
3128 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3130 echo 1 >> $DIR/$tdir/${tfile}.13_append
3132 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3133 [ "$pool" = "" ] || error "(13) pool found: $pool"
3135 run_test 27M "test O_APPEND striping"
3138 combined_mgs_mds && skip "needs separate MGS/MDT"
3140 pool_add $TESTNAME || error "pool_add failed"
3141 do_facet mgs "$LCTL pool_list $FSNAME" |
3142 grep -Fx "${FSNAME}.${TESTNAME}" ||
3143 error "lctl pool_list on MGS failed"
3145 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3147 clean_foreign_symlink() {
3149 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3150 for i in $DIR/$tdir/* ; do
3151 $LFS unlink_foreign $i || true
3156 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3157 skip "Need MDS version newer than 2.12.51"
3159 test_mkdir $DIR/$tdir
3160 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3161 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3163 trap clean_foreign_symlink EXIT
3165 # enable foreign_symlink behaviour
3166 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3168 # foreign symlink LOV format is a partial path by default
3170 # create foreign file (lfs + API)
3171 $LFS setstripe --foreign=symlink --flags 0xda05 \
3172 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3173 error "$DIR/$tdir/${tfile}: create failed"
3175 $LFS getstripe -v $DIR/$tdir/${tfile} |
3176 grep "lfm_magic:.*0x0BD70BD0" ||
3177 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3178 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3179 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3180 $LFS getstripe -v $DIR/$tdir/${tfile} |
3181 grep "lfm_flags:.*0x0000DA05" ||
3182 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3183 $LFS getstripe $DIR/$tdir/${tfile} |
3184 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3185 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3187 # modify striping should fail
3188 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3189 error "$DIR/$tdir/$tfile: setstripe should fail"
3191 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3192 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3193 cat /etc/passwd > $DIR/$tdir/$tfile &&
3194 error "$DIR/$tdir/$tfile: write should fail"
3196 # rename should succeed
3197 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3198 error "$DIR/$tdir/$tfile: rename has failed"
3200 #remove foreign_symlink file should fail
3201 rm $DIR/$tdir/${tfile}.new &&
3202 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3205 mkdir /tmp/${uuid1} ||
3206 error "/tmp/${uuid1}: mkdir has failed"
3207 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3208 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3209 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3210 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3211 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3212 #read should succeed now
3213 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3214 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3215 #write should succeed now
3216 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3217 error "$DIR/$tdir/${tfile}.new: write should succeed"
3218 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3219 error "$DIR/$tdir/${tfile}.new: diff has failed"
3220 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3221 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3223 #check that getstripe still works
3224 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3225 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3227 # chmod should still succeed
3228 chmod 644 $DIR/$tdir/${tfile}.new ||
3229 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3231 # chown should still succeed
3232 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3233 error "$DIR/$tdir/${tfile}.new: chown has failed"
3235 # rename should still succeed
3236 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3237 error "$DIR/$tdir/${tfile}.new: rename has failed"
3239 #remove foreign_symlink file should still fail
3240 rm $DIR/$tdir/${tfile} &&
3241 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3243 #use special ioctl() to unlink foreign_symlink file
3244 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3245 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3248 run_test 27O "basic ops on foreign file of symlink type"
3251 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3252 skip "Need MDS version newer than 2.12.49"
3254 test_mkdir $DIR/$tdir
3255 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3256 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3258 trap clean_foreign_symlink EXIT
3260 # enable foreign_symlink behaviour
3261 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3263 # foreign symlink LMV format is a partial path by default
3265 # create foreign dir (lfs + API)
3266 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3267 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3268 error "$DIR/$tdir/${tdir}: create failed"
3270 $LFS getdirstripe -v $DIR/$tdir/${tdir}
3272 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3273 grep "lfm_magic:.*0x0CD50CD0" ||
3274 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3275 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3276 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3277 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3278 grep "lfm_flags:.*0x0000DA05" ||
3279 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3280 $LFS getdirstripe $DIR/$tdir/${tdir} |
3281 grep "lfm_value.*${uuid1}/${uuid2}" ||
3282 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3284 # file create in dir should fail
3285 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3286 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
3288 # rename should succeed
3289 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3290 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3292 #remove foreign_symlink dir should fail
3293 rmdir $DIR/$tdir/${tdir}.new &&
3294 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3297 mkdir -p /tmp/${uuid1}/${uuid2} ||
3298 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3299 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3300 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3301 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3302 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3303 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3304 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3305 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3307 #check that getstripe fails now that foreign_symlink enabled
3308 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3309 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3311 # file create in dir should work now
3312 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3313 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3314 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3315 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3316 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3317 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3319 # chmod should still succeed
3320 chmod 755 $DIR/$tdir/${tdir}.new ||
3321 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3323 # chown should still succeed
3324 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3325 error "$DIR/$tdir/${tdir}.new: chown has failed"
3327 # rename should still succeed
3328 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3329 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3331 #remove foreign_symlink dir should still fail
3332 rmdir $DIR/$tdir/${tdir} &&
3333 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3335 #use special ioctl() to unlink foreign_symlink file
3336 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3337 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3339 #created file should still exist
3340 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3341 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3342 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3343 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3345 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3348 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3349 stack_trap "rm -f $TMP/$tfile*"
3351 test_mkdir $DIR/$tdir-1
3352 test_mkdir $DIR/$tdir-2
3354 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3355 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3357 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3358 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3360 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3361 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3363 # Create some bad symlinks and ensure that we don't loop
3364 # forever or something. These should return ELOOP (40) and
3365 # ENOENT (2) but I don't want to test for that because there's
3366 # always some weirdo architecture that needs to ruin
3367 # everything by defining these error numbers differently.
3369 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3370 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3372 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3373 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3377 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3380 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
3381 skip "need MDS 2.14.55 or later"
3382 (( $OSTCOUNT >= 2 )) || skip_env "needs at least 2 OSTs"
3384 local testdir="$DIR/$tdir"
3385 test_mkdir -p $testdir
3386 stack_trap "rm -rf $testdir"
3387 $LFS setstripe -c -1 $testdir || error "setstripe failed"
3389 local f1="$testdir/f1"
3390 touch $f1 || error "failed to touch $f1"
3391 local count=$($LFS getstripe -c $f1)
3392 (( $count == $OSTCOUNT )) || error "wrong stripe count"
3394 do_facet $SINGLEMDS $LCTL set_param lod.*.max_stripecount=-1
3395 (( $? == 34 )) || error "setting max_stripecount to -1 should fail and return ERANGE"
3397 local maxcount=$(($OSTCOUNT - 1))
3398 local mdts=$(comma_list $(mdts_nodes))
3399 do_nodes $mdts $LCTL set_param lod.*.max_stripecount=$maxcount
3400 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_stripecount=0"
3402 local f2="$testdir/f2"
3403 touch $f2 || error "failed to touch $f2"
3404 local count=$($LFS getstripe -c $f2)
3405 (( $count == $maxcount )) || error "wrong stripe count"
3407 run_test 27R "test max_stripecount limitation when stripe count is set to -1"
3410 [ $(facet_host client) == $(facet_host ost1) ] &&
3411 skip "need ost1 and client on different nodes"
3413 #define OBD_FAIL_OSC_NO_GRANT 0x411
3414 $LCTL set_param fail_loc=0x20000411 fail_val=1
3415 #define OBD_FAIL_OST_ENOSPC 0x215
3416 do_facet ost1 "$LCTL set_param fail_loc=0x80000215"
3417 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3418 $MULTIOP $DIR/$tfile oO_WRONLY:P$((4 * 1024 * 1024 + 10 * 4096))c ||
3419 error "multiop failed"
3421 run_test 27T "no eio on close on partial write due to enosp"
3424 local dir=$DIR/$tdir
3425 local file=$dir/$tfile
3426 local append_pool=${TESTNAME}-append
3427 local normal_pool=${TESTNAME}-normal
3431 local mdts=$(comma_list $(mdts_nodes))
3434 # (( $MDS1_VERSION >= $(version_code 2.15.42) )) ||
3435 # skip "Need MDS version at least 2.15.42"
3437 # Validate existing append_* params and ensure restore
3438 pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3439 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3440 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3442 stripe_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3443 ((stripe_count == 1)) || error "expected append_stripe_count != 0, got $stripe_count"
3444 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$stripe_count"
3446 pool_add $append_pool || error "pool creation failed"
3447 pool_add_targets $append_pool 0 1 || error "Pool add targets failed"
3449 pool_add $normal_pool || error "pool creation failed"
3450 pool_add_targets $normal_pool 0 1 || error "Pool add targets failed"
3453 $LFS setstripe -E 1M -c 1 -p $normal_pool -E 2M -c 2 -p $normal_pool -E eof -c -1 $dir
3456 $LFS getstripe $file.1
3458 pool=$($LFS getstripe -p $file.1)
3459 [[ "$pool" == "$normal_pool" ]] || error "got pool '$pool', expected '$normal_pool'"
3461 stripe_count2=$($LFS getstripe -c $file.1)
3462 ((stripe_count2 == stripe_count)) ||
3463 error "got stripe_count '$stripe_count2', expected '$stripe_count'"
3465 do_nodes $mdts $LCTL set_param mdd.*.append_pool=$append_pool
3468 $LFS getstripe $file.2
3470 pool=$($LFS getstripe -p $file.2)
3471 [[ "$pool" == "$append_pool" ]] || error "got pool '$pool', expected '$append_pool'"
3473 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3476 $LFS getstripe $file.3
3478 stripe_count2=$($LFS getstripe -c $file.3)
3479 ((stripe_count2 == 2)) || error "got stripe_count '$stripe_count2', expected 2"
3481 run_test 27U "append pool and stripe count work with composite default layout"
3483 # createtest also checks that device nodes are created and
3484 # then visible correctly (#2091)
3485 test_28() { # bug 2091
3487 $CREATETEST $DIR/d28/ct || error "createtest failed"
3489 run_test 28 "create/mknod/mkdir with bad file types ============"
3492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3494 [ $MDS1_VERSION -ge $(version_code 2.14.51) ] && {
3496 stack_trap "restore_opencache"
3499 sync; sleep 1; sync # flush out any dirty pages from previous tests
3506 declare -i LOCKCOUNTORIG=0
3507 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3508 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3510 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3512 declare -i LOCKUNUSEDCOUNTORIG=0
3513 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3514 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3521 declare -i LOCKCOUNTCURRENT=0
3522 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3523 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3526 declare -i LOCKUNUSEDCOUNTCURRENT=0
3527 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3528 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3531 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3532 $LCTL set_param -n ldlm.dump_namespaces ""
3533 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3534 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3535 log "dumped log to $TMP/test_29.dk (bug 5793)"
3538 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3539 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3540 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3541 log "dumped log to $TMP/test_29.dk (bug 5793)"
3545 run_test 29 "IT_GETATTR regression ============================"
3547 test_30a() { # was test_30
3548 cp $(which ls) $DIR || cp /bin/ls $DIR
3549 $DIR/ls / || error "Can't execute binary from lustre"
3552 run_test 30a "execute binary from Lustre (execve) =============="
3555 cp `which ls` $DIR || cp /bin/ls $DIR
3557 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3560 run_test 30b "execute binary from Lustre as non-root ==========="
3562 test_30c() { # b=22376
3563 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3565 cp $(which ls) $DIR || cp /bin/ls $DIR
3567 cancel_lru_locks mdc
3568 cancel_lru_locks osc
3569 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3572 run_test 30c "execute binary from Lustre without read perms ===="
3575 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3577 for i in {1..10}; do
3578 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3581 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3582 wait $PID || error "executing dd from Lustre failed"
3588 run_test 30d "execute binary from Lustre while clear locks"
3591 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3592 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3594 run_test 31a "open-unlink file =================================="
3597 touch $DIR/f31 || error "touch $DIR/f31 failed"
3598 ln $DIR/f31 $DIR/f31b || error "ln failed"
3599 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3600 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3602 run_test 31b "unlink file with multiple links while open ======="
3605 touch $DIR/f31 || error "touch $DIR/f31 failed"
3606 ln $DIR/f31 $DIR/f31c || error "ln failed"
3607 multiop_bg_pause $DIR/f31 O_uc ||
3608 error "multiop_bg_pause for $DIR/f31 failed"
3610 $MULTIOP $DIR/f31c Ouc
3611 kill -USR1 $MULTIPID
3614 run_test 31c "open-unlink file with multiple links ============="
3617 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3618 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3620 run_test 31d "remove of open directory ========================="
3622 test_31e() { # bug 2904
3623 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3625 run_test 31e "remove of open non-empty directory ==============="
3627 test_31f() { # bug 4554
3628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3631 test_mkdir $DIR/d31f
3632 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3633 cp /etc/hosts $DIR/d31f
3635 $LFS getstripe $DIR/d31f/hosts
3636 multiop_bg_pause $DIR/d31f D_c || return 1
3639 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3640 test_mkdir $DIR/d31f
3641 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3642 cp /etc/hosts $DIR/d31f
3644 $LFS getstripe $DIR/d31f/hosts
3645 multiop_bg_pause $DIR/d31f D_c || return 1
3648 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3649 wait $MULTIPID || error "first opendir $MULTIPID failed"
3653 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3654 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3657 run_test 31f "remove of open directory with open-unlink file ==="
3660 echo "-- cross directory link --"
3661 test_mkdir -c1 $DIR/${tdir}ga
3662 test_mkdir -c1 $DIR/${tdir}gb
3663 touch $DIR/${tdir}ga/f
3664 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3665 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3666 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3667 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3668 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3670 run_test 31g "cross directory link==============="
3673 echo "-- cross directory link --"
3674 test_mkdir -c1 $DIR/${tdir}
3675 test_mkdir -c1 $DIR/${tdir}/dir
3676 touch $DIR/${tdir}/f
3677 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3678 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3679 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3680 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3681 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3683 run_test 31h "cross directory link under child==============="
3686 echo "-- cross directory link --"
3687 test_mkdir -c1 $DIR/$tdir
3688 test_mkdir -c1 $DIR/$tdir/dir
3689 touch $DIR/$tdir/dir/f
3690 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3691 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3692 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3693 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3694 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3696 run_test 31i "cross directory link under parent==============="
3699 test_mkdir -c1 -p $DIR/$tdir
3700 test_mkdir -c1 -p $DIR/$tdir/dir1
3701 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3702 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3703 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3704 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3707 run_test 31j "link for directory==============="
3710 test_mkdir -c1 -p $DIR/$tdir
3712 touch $DIR/$tdir/exist
3713 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3714 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3715 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3716 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3717 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3718 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3719 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3722 run_test 31k "link to file: the same, non-existing, dir==============="
3728 touch $DIR/d31m2/exist
3729 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3730 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3731 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3732 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3733 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3734 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3737 run_test 31m "link to file: the same, non-existing, dir==============="
3740 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3741 nlink=$(stat --format=%h $DIR/$tfile)
3742 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3744 local cmd="exec $fd<$DIR/$tfile"
3747 trap "eval $cmd" EXIT
3748 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3749 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3750 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3751 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3752 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3755 run_test 31n "check link count of unlinked file"
3758 local tempfile=$(mktemp $1_XXXXXX)
3759 mlink $tempfile $1 2> /dev/null &&
3760 echo "$BASHPID: link $tempfile to $1 succeeded"
3764 test_31o() { # LU-2901
3765 test_mkdir $DIR/$tdir
3766 for LOOP in $(seq 100); do
3767 rm -f $DIR/$tdir/$tfile*
3768 for THREAD in $(seq 8); do
3769 link_one $DIR/$tdir/$tfile.$LOOP &
3772 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3773 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3774 error "$LINKS duplicate links to $tfile.$LOOP" &&
3778 run_test 31o "duplicate hard links with same filename"
3781 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3783 test_mkdir $DIR/$tdir
3784 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3785 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3787 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3788 error "open unlink test1 failed"
3789 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3790 error "open unlink test2 failed"
3792 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3793 error "test1 still exists"
3794 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3795 error "test2 still exists"
3797 run_test 31p "remove of open striped directory"
3800 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3802 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3803 index=$($LFS getdirstripe -i $DIR/$tdir)
3804 [ $index -eq 3 ] || error "first stripe index $index != 3"
3805 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3806 [ $index -eq 1 ] || error "second stripe index $index != 1"
3808 # when "-c <stripe_count>" is set, the number of MDTs specified after
3809 # "-i" should equal to the stripe count
3810 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3812 run_test 31q "create striped directory on specific MDTs"
3816 touch $DIR/$tfile.target
3817 touch $DIR/$tfile.source
3819 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
3820 $LCTL set_param fail_loc=0x1419 fail_val=3
3821 cat $DIR/$tfile.target &
3824 # Guarantee open is waiting before we get here
3826 mv $DIR/$tfile.source $DIR/$tfile.target
3830 if [[ $RC -ne 0 ]]; then
3831 error "open with cat failed, rc=$RC"
3834 run_test 31r "open-rename(replace) race"
3836 cleanup_test32_mount() {
3839 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3840 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3841 losetup -d $loopdev || true
3847 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3849 echo "== more mountpoints and symlinks ================="
3850 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3851 trap cleanup_test32_mount EXIT
3852 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3853 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3854 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3855 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3856 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3857 cleanup_test32_mount
3859 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3862 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3864 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3865 trap cleanup_test32_mount EXIT
3866 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3867 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3868 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3869 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3870 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3871 cleanup_test32_mount
3873 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3876 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3878 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3879 trap cleanup_test32_mount EXIT
3880 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3881 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3882 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3883 test_mkdir -p $DIR/$tdir/d2/test_dir
3884 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3885 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3886 cleanup_test32_mount
3888 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3893 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3894 trap cleanup_test32_mount EXIT
3895 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3896 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3897 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3898 test_mkdir -p $DIR/$tdir/d2/test_dir
3899 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3900 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3901 cleanup_test32_mount
3903 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3907 test_mkdir -p $DIR/$tdir/tmp
3908 local tmp_dir=$DIR/$tdir/tmp
3909 ln -s $DIR/$tdir $tmp_dir/symlink11
3910 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3911 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3912 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3914 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3918 test_mkdir -p $DIR/$tdir/tmp
3919 local tmp_dir=$DIR/$tdir/tmp
3920 ln -s $DIR/$tdir $tmp_dir/symlink11
3921 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3922 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3923 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3925 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3928 local tmp_dir=$DIR/$tdir/tmp
3929 test_mkdir -p $tmp_dir
3930 test_mkdir $DIR/${tdir}2
3931 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3932 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3933 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3934 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3935 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3936 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3938 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3941 rm -fr $DIR/$tdir $DIR/${tdir}2
3942 tmp_dir=$DIR/$tdir/tmp
3943 test_mkdir -p $tmp_dir
3944 test_mkdir $DIR/${tdir}2
3945 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3946 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3947 ls $tmp_dir/symlink12 || error "listing symlink12"
3948 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3950 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3953 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3955 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3956 trap cleanup_test32_mount EXIT
3957 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3958 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3959 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3960 touch $DIR/$tdir/test_file
3961 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3962 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3963 cleanup_test32_mount
3965 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3968 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3970 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3971 trap cleanup_test32_mount EXIT
3972 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3973 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3974 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3975 touch $DIR/$tdir/test_file
3976 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3977 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3978 cleanup_test32_mount
3980 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3983 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3986 trap cleanup_test32_mount EXIT
3987 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3988 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3989 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3990 test_mkdir -p $DIR/$tdir/d2
3991 touch $DIR/$tdir/d2/test_file || error "touch failed"
3992 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3993 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3994 cleanup_test32_mount
3996 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3999 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4002 trap cleanup_test32_mount EXIT
4003 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4004 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4005 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4006 test_mkdir -p $DIR/$tdir/d2
4007 touch $DIR/$tdir/d2/test_file || error "touch failed"
4008 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
4009 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
4010 cleanup_test32_mount
4012 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
4016 test_mkdir -p $DIR/d32m/tmp
4017 TMP_DIR=$DIR/d32m/tmp
4018 ln -s $DIR $TMP_DIR/symlink11
4019 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
4020 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
4021 error "symlink11 not a link"
4022 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
4023 error "symlink01 not a link"
4025 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
4029 test_mkdir -p $DIR/d32n/tmp
4030 TMP_DIR=$DIR/d32n/tmp
4031 ln -s $DIR $TMP_DIR/symlink11
4032 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
4033 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
4034 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
4036 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
4040 test_mkdir -p $DIR/d32o/tmp
4041 TMP_DIR=$DIR/d32o/tmp
4042 ln -s $DIR/$tfile $TMP_DIR/symlink12
4043 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4044 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
4045 error "symlink12 not a link"
4046 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
4047 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
4048 error "$DIR/d32o/tmp/symlink12 not file type"
4049 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
4050 error "$DIR/d32o/symlink02 not file type"
4052 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
4062 test_mkdir -p $DIR/d32p/tmp
4064 TMP_DIR=$DIR/d32p/tmp
4066 ln -s $DIR/$tfile $TMP_DIR/symlink12
4068 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4070 cat $DIR/d32p/tmp/symlink12 ||
4071 error "Can't open $DIR/d32p/tmp/symlink12"
4073 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
4076 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
4079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4081 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4082 trap cleanup_test32_mount EXIT
4083 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4084 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4085 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4086 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4087 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
4088 cleanup_test32_mount
4090 run_test 32q "stat follows mountpoints in Lustre (should return error)"
4093 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4095 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4096 trap cleanup_test32_mount EXIT
4097 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4098 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4099 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4100 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4101 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
4102 cleanup_test32_mount
4104 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
4109 chmod 444 $DIR/$tfile
4110 chown $RUNAS_ID $DIR/$tfile
4112 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4115 run_test 33aa "write file with mode 444 (should return error)"
4119 test_mkdir $DIR/$tdir
4120 chown $RUNAS_ID $DIR/$tdir
4121 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
4122 error "$RUNAS create $tdir/$tfile failed"
4123 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4124 error "open RDWR" || true
4126 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4130 test_mkdir $DIR/$tdir
4131 chown $RUNAS_ID $DIR/$tdir
4132 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4134 run_test 33b "test open file with malformed flags (No panic)"
4137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4138 remote_ost_nodsh && skip "remote OST with nodsh"
4146 test_mkdir $DIR/$tdir
4147 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4150 for ostnum in $(seq $OSTCOUNT); do
4151 # test-framework's OST numbering is one-based, while Lustre's
4153 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4154 # check if at least some write_bytes stats are counted
4155 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4156 obdfilter.$ostname.stats |
4157 awk '/^write_bytes/ {print $7}' )
4158 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4159 if (( ${write_bytes:-0} > 0 )); then
4165 $all_zeros || return 0
4168 echo foo > $DIR/$tdir/bar
4172 # Total up write_bytes after writing. We'd better find non-zeros.
4173 for ostnum in $(seq $OSTCOUNT); do
4174 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4175 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4176 obdfilter/$ostname/stats |
4177 awk '/^write_bytes/ {print $7}' )
4178 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4179 if (( ${write_bytes:-0} > 0 )); then
4186 for ostnum in $(seq $OSTCOUNT); do
4187 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4188 echo "Check write_bytes is in obdfilter.*.stats:"
4189 do_facet ost$ostnum lctl get_param -n \
4190 obdfilter.$ostname.stats
4192 error "OST not keeping write_bytes stats (b=22312)"
4195 run_test 33c "test write_bytes stats"
4198 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4199 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4202 local remote_dir=$DIR/$tdir/remote_dir
4204 test_mkdir $DIR/$tdir
4205 $LFS mkdir -i $MDTIDX $remote_dir ||
4206 error "create remote directory failed"
4208 touch $remote_dir/$tfile
4209 chmod 444 $remote_dir/$tfile
4210 chown $RUNAS_ID $remote_dir/$tfile
4212 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4214 chown $RUNAS_ID $remote_dir
4215 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4216 error "create" || true
4217 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4218 error "open RDWR" || true
4219 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4221 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4224 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4228 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4229 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4230 mkdir $DIR/$tdir/local_dir
4232 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4233 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4234 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4236 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4237 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4239 rmdir $DIR/$tdir/* || error "rmdir failed"
4242 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4243 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4244 mkdir $DIR/$tdir/local_dir
4246 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4247 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4248 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4250 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4251 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4253 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4256 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4257 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4258 mkdir $DIR/$tdir/local_dir
4260 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4261 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4262 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4264 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4265 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4267 run_test 33e "mkdir and striped directory should have same mode"
4271 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4275 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4276 remote_mds_nodsh && skip "remote MDS with nodsh"
4279 chmod go+rwx $DIR/$tdir
4280 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4281 trap cleanup_33f EXIT
4283 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4284 error "cannot create striped directory"
4286 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4287 error "cannot create files in striped directory"
4289 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4290 error "cannot remove files in striped directory"
4292 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4293 error "cannot remove striped directory"
4297 run_test 33f "nonroot user can create, access, and remove a striped directory"
4300 mkdir -p $DIR/$tdir/dir2
4302 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4304 [[ $err =~ "exists" ]] || error "Not exists error"
4306 run_test 33g "nonroot user create already existing root created file"
4312 test_mkdir -c $MDSCOUNT -H $hash_type $DIR/$tdir ||
4313 error "lfs mkdir -H $hash_type $tdir failed"
4314 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4316 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4320 for fname in $DIR/$tdir/$tfile.bak \
4321 $DIR/$tdir/$tfile.SAV \
4322 $DIR/$tdir/$tfile.orig \
4323 $DIR/$tdir/$tfile~; do
4324 touch $fname || error "touch $fname failed"
4325 index2=$($LFS getstripe -m $fname)
4326 (( $index == $index2 )) ||
4327 error "$fname MDT index mismatch $index != $index2"
4331 local patterns=(".$tfile.XXXXXX" "$tfile.XXXXXXXX")
4334 for pattern in ${patterns[*]}; do
4335 echo "pattern $pattern"
4336 fname=$DIR/$tdir/$pattern
4337 for (( i = 0; i < $count; i++ )); do
4338 fname=$(mktemp $DIR/$tdir/$pattern) ||
4339 error "mktemp $DIR/$tdir/$pattern failed"
4340 index2=$($LFS getstripe -m $fname)
4341 (( $index == $index2 )) && continue
4343 failed=$((failed + 1))
4344 echo "$fname MDT index mismatch $index != $index2"
4348 echo "$failed/$count MDT index mismatches, expect ~2-4"
4349 (( failed < 10 )) || error "MDT index mismatch $failed/$count times"
4354 # verify that "crush" is still broken with all files on same MDT,
4355 # crush2 should have about 1/MDSCOUNT files on each MDT, with margin
4356 [[ "$hash_type" == "crush" ]] && expect=$count ||
4357 expect=$((count / MDSCOUNT))
4359 # crush2 doesn't put all-numeric suffixes on the same MDT,
4360 # filename like $tfile.12345678 should *not* be considered temp
4361 for pattern in ${patterns[*]}; do
4362 local base=${pattern%%X*}
4363 local suff=${pattern#$base}
4365 echo "pattern $pattern"
4366 for (( i = 0; i < $count; i++ )); do
4367 fname=$DIR/$tdir/$base$((${suff//X/1} + i))
4368 touch $fname || error "touch $fname failed"
4369 index2=$($LFS getstripe -m $fname)
4370 (( $index != $index2 )) && continue
4376 # the number of "bad" hashes is random, as it depends on the random
4377 # filenames generated by "mktemp". Allow some margin in the results.
4378 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4379 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4380 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4381 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4384 # crush2 doesn't put suffixes with special characters on the same MDT
4385 # filename like $tfile.txt.1234 should *not* be considered temp
4386 for pattern in ${patterns[*]}; do
4387 local base=${pattern%%X*}
4388 local suff=${pattern#$base}
4390 pattern=$base...${suff/XXX}
4391 echo "pattern=$pattern"
4392 for (( i = 0; i < $count; i++ )); do
4393 fname=$(mktemp $DIR/$tdir/$pattern) ||
4394 error "touch $fname failed"
4395 index2=$($LFS getstripe -m $fname)
4396 (( $index != $index2 )) && continue
4402 # the number of "bad" hashes is random, as it depends on the random
4403 # filenames generated by "mktemp". Allow some margin in the results.
4404 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4405 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4406 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4407 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4411 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4412 (( $MDS1_VERSION >= $(version_code 2.13.50) )) ||
4413 skip "Need MDS version at least 2.13.50"
4417 run_test 33h "temp file is located on the same MDT as target (crush)"
4420 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4421 echo "MDS1_VERSION=$MDS1_VERSION version_code=$(version_code 2.15.0)"
4422 (( $MDS1_VERSION > $(version_code 2.15.0) )) ||
4423 skip "Need MDS version at least 2.15.0 for crush2"
4427 run_test 33hh "temp file is located on the same MDT as target (crush2)"
4431 (( MDSCOUNT < 2 )) && skip "needs >= 2 MDTs"
4433 local FNAME=$(str_repeat 'f' 250)
4435 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
4436 createmany -o $DIR/$tdir/$FNAME 1000 || error "createmany failed"
4441 count=$($LFS getstripe -m $DIR/$tdir/* | grep -cw 1)
4443 local MDC=$(lctl dl | awk '/MDT0001-mdc-[^M]/ { print $4 }')
4445 lctl --device %$MDC deactivate
4446 stack_trap "lctl --device %$MDC activate"
4447 ls $DIR/$tdir > /dev/null && error "ls should return an error"
4448 total=$(\ls -l $DIR/$tdir | wc -l)
4449 # "ls -l" will list total in the first line
4450 total=$((total - 1))
4451 (( total + count == 1000 )) ||
4452 error "ls list $total files, $count files on MDT1"
4454 run_test 33i "striped directory can be accessed when one MDT is down"
4457 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4459 mkdir -p $DIR/$tdir/
4461 $LFS setdirstripe -D -i0,1 $DIR/$tdir/striped_dir_a &&
4462 error "setdirstripe -D -i0,1 incorrectly succeeded"
4464 $LFS setdirstripe -D -i0,1 -c1 $DIR/$tdir/striped_dir_b &&
4465 error "setdirstripe -D -i0,1 -c1 incorrectly succeeded"
4467 $LFS setdirstripe -D -i0,1 -c3 $DIR/$tdir/striped_dir_c &&
4468 error "setdirstripe -D -i0,1 -c3 incorrectly succeeded"
4470 $LFS setdirstripe -i0,1 $DIR/$tdir/striped_dir_e ||
4471 error "-D was not specified, but still failed"
4473 run_test 33j "lfs setdirstripe -D -i x,y,x should fail"
4475 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4478 $MCREATE $DIR/f34 || error "mcreate failed"
4479 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4480 error "getstripe failed"
4481 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4482 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4483 error "getstripe failed"
4484 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4485 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4487 run_test 34a "truncate file that has not been opened ==========="
4490 [ ! -f $DIR/f34 ] && test_34a
4491 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4492 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4493 $OPENFILE -f O_RDONLY $DIR/f34
4494 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4495 error "getstripe failed"
4496 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4497 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4499 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4502 [ ! -f $DIR/f34 ] && test_34a
4503 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4504 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4505 $OPENFILE -f O_RDWR $DIR/f34
4506 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4507 error "$LFS getstripe failed"
4508 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4509 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4511 run_test 34c "O_RDWR opening file-with-size works =============="
4514 [ ! -f $DIR/f34 ] && test_34a
4515 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4517 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4518 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4521 run_test 34d "write to sparse file ============================="
4525 $MCREATE $DIR/f34e || error "mcreate failed"
4526 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4527 $CHECKSTAT -s 1000 $DIR/f34e ||
4528 error "Size of $DIR/f34e not equal to 1000 bytes"
4529 $OPENFILE -f O_RDWR $DIR/f34e
4530 $CHECKSTAT -s 1000 $DIR/f34e ||
4531 error "Size of $DIR/f34e not equal to 1000 bytes"
4533 run_test 34e "create objects, some with size and some without =="
4535 test_34f() { # bug 6242, 6243
4536 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4540 $MCREATE $DIR/f34f || error "mcreate failed"
4541 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4542 dd if=$DIR/f34f of=$TMP/f34f
4543 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4544 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4545 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4546 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4547 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4549 run_test 34f "read from a file with no objects until EOF ======="
4552 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4554 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4556 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4557 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4558 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4559 cancel_lru_locks osc
4560 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4561 error "wrong size after lock cancel"
4563 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4564 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4565 error "expanding truncate failed"
4566 cancel_lru_locks osc
4567 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4568 error "wrong expanded size after lock cancel"
4570 run_test 34g "truncate long file ==============================="
4573 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4578 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4579 sync # Flush the cache so that multiop below does not block on cache
4580 # flush when getting the group lock
4581 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4584 # Since just timed wait is not good enough, let's do a sync write
4585 # that way we are sure enough time for a roundtrip + processing
4586 # passed + 2 seconds of extra margin.
4587 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4591 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4592 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4596 local nsz=`stat -c %s $DIR/$tfile`
4597 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4599 run_test 34h "ftruncate file under grouplock should not block"
4602 cp /bin/sh $DIR/f35a
4604 chown $RUNAS_ID $DIR/f35a
4605 $RUNAS $DIR/f35a && error || true
4608 run_test 35a "exec file with mode 444 (should return and not leak)"
4612 utime $DIR/f36 || error "utime failed for MDS"
4614 run_test 36a "MDS utime check (mknod, utime)"
4618 utime $DIR/f36 || error "utime failed for OST"
4620 run_test 36b "OST utime check (open, utime)"
4625 chown $RUNAS_ID $DIR/d36
4626 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4628 run_test 36c "non-root MDS utime check (mknod, utime)"
4631 [ ! -d $DIR/d36 ] && test_36c
4632 echo "" > $DIR/d36/f36
4633 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4635 run_test 36d "non-root OST utime check (open, utime)"
4638 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4640 test_mkdir $DIR/$tdir
4641 touch $DIR/$tdir/$tfile
4642 $RUNAS utime $DIR/$tdir/$tfile &&
4643 error "utime worked, expected failure" || true
4645 run_test 36e "utime on non-owned file (should return error)"
4649 local LANG_SAVE=$LANG
4650 local LC_LANG_SAVE=$LC_LANG
4651 export LANG=C LC_LANG=C # for date language
4653 DATESTR="Dec 20 2000"
4654 test_mkdir $DIR/$tdir
4655 lctl set_param fail_loc=$fl
4657 cp /etc/hosts $DIR/$tdir/$tfile
4658 sync & # write RPC generated with "current" inode timestamp, but delayed
4660 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4661 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4662 cancel_lru_locks $OSC
4663 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4665 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4666 echo "BEFORE: $LS_BEFORE" && \
4667 echo "AFTER : $LS_AFTER" && \
4668 echo "WANT : $DATESTR" && \
4669 error "$DIR/$tdir/$tfile timestamps changed" || true
4671 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4675 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4677 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4678 subr_36fh "0x80000214"
4680 run_test 36f "utime on file racing with OST BRW write =========="
4683 remote_ost_nodsh && skip "remote OST with nodsh"
4684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4685 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4686 skip "Need MDS version at least 2.12.51"
4691 local tgt="obdfilter"
4693 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4695 test_mkdir $DIR/$tdir
4696 fmd_max_age=$(do_facet $facet \
4697 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4700 echo "FMD max age: ${fmd_max_age}s"
4701 touch $DIR/$tdir/$tfile
4702 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4703 gawk '{cnt=cnt+$1} END{print cnt}')
4704 echo "FMD before: $fmd"
4706 error "FMD wasn't create by touch"
4707 sleep $((fmd_max_age + 12))
4708 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4709 gawk '{cnt=cnt+$1} END{print cnt}')
4710 echo "FMD after: $fmd"
4712 error "FMD wasn't expired by ping"
4714 run_test 36g "FMD cache expiry ====================="
4717 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4719 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4720 subr_36fh "0x80000227"
4722 run_test 36h "utime on file racing with OST BRW write =========="
4725 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4727 test_mkdir $DIR/$tdir
4728 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4730 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4731 local new_mtime=$((mtime + 200))
4733 #change Modify time of striped dir
4734 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4735 error "change mtime failed"
4737 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4739 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4741 run_test 36i "change mtime on striped directory"
4743 # test_37 - duplicate with tests 32q 32r
4746 local file=$DIR/$tfile
4748 openfile -f O_DIRECTORY $file
4751 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4752 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4754 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4756 test_39a() { # was test_39
4758 touch $DIR/${tfile}2
4759 # ls -l $DIR/$tfile $DIR/${tfile}2
4760 # ls -lu $DIR/$tfile $DIR/${tfile}2
4761 # ls -lc $DIR/$tfile $DIR/${tfile}2
4763 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4764 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4766 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4768 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4770 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4771 error "O_TRUNC didn't change timestamps"
4774 run_test 39a "mtime changed on create"
4777 test_mkdir -c1 $DIR/$tdir
4778 cp -p /etc/passwd $DIR/$tdir/fopen
4779 cp -p /etc/passwd $DIR/$tdir/flink
4780 cp -p /etc/passwd $DIR/$tdir/funlink
4781 cp -p /etc/passwd $DIR/$tdir/frename
4782 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4785 echo "aaaaaa" >> $DIR/$tdir/fopen
4786 echo "aaaaaa" >> $DIR/$tdir/flink
4787 echo "aaaaaa" >> $DIR/$tdir/funlink
4788 echo "aaaaaa" >> $DIR/$tdir/frename
4790 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4791 local link_new=`stat -c %Y $DIR/$tdir/flink`
4792 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4793 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4795 cat $DIR/$tdir/fopen > /dev/null
4796 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4797 rm -f $DIR/$tdir/funlink2
4798 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4800 for (( i=0; i < 2; i++ )) ; do
4801 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4802 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4803 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4804 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4806 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4807 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4808 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4809 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4811 cancel_lru_locks $OSC
4812 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4815 run_test 39b "mtime change on open, link, unlink, rename ======"
4817 # this should be set to past
4818 TEST_39_MTIME=`date -d "1 year ago" +%s`
4824 local mtime0=`stat -c %Y $DIR1/$tfile`
4826 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4827 local mtime1=`stat -c %Y $DIR1/$tfile`
4828 [ "$mtime1" = $TEST_39_MTIME ] || \
4829 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4832 echo hello >> $DIR1/$tfile
4834 local mtime2=`stat -c %Y $DIR1/$tfile`
4835 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4836 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4838 mv $DIR1/$tfile $DIR1/$tfile-1
4840 for (( i=0; i < 2; i++ )) ; do
4841 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4842 [ "$mtime2" = "$mtime3" ] || \
4843 error "mtime ($mtime2) changed (to $mtime3) on rename"
4845 cancel_lru_locks $OSC
4846 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4849 run_test 39c "mtime change on rename ==========================="
4853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4856 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4858 for (( i=0; i < 2; i++ )) ; do
4859 local mtime=`stat -c %Y $DIR1/$tfile`
4860 [ $mtime = $TEST_39_MTIME ] || \
4861 error "mtime($mtime) is not set to $TEST_39_MTIME"
4863 cancel_lru_locks $OSC
4864 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4867 run_test 39d "create, utime, stat =============================="
4871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4874 local mtime1=`stat -c %Y $DIR1/$tfile`
4876 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4878 for (( i=0; i < 2; i++ )) ; do
4879 local mtime2=`stat -c %Y $DIR1/$tfile`
4880 [ $mtime2 = $TEST_39_MTIME ] || \
4881 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4883 cancel_lru_locks $OSC
4884 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4887 run_test 39e "create, stat, utime, stat ========================"
4891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4894 mtime1=`stat -c %Y $DIR1/$tfile`
4897 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4899 for (( i=0; i < 2; i++ )) ; do
4900 local mtime2=`stat -c %Y $DIR1/$tfile`
4901 [ $mtime2 = $TEST_39_MTIME ] || \
4902 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4904 cancel_lru_locks $OSC
4905 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4908 run_test 39f "create, stat, sleep, utime, stat ================="
4912 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4914 echo hello >> $DIR1/$tfile
4915 local mtime1=`stat -c %Y $DIR1/$tfile`
4918 chmod o+r $DIR1/$tfile
4920 for (( i=0; i < 2; i++ )) ; do
4921 local mtime2=`stat -c %Y $DIR1/$tfile`
4922 [ "$mtime1" = "$mtime2" ] || \
4923 error "lost mtime: $mtime2, should be $mtime1"
4925 cancel_lru_locks $OSC
4926 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4929 run_test 39g "write, chmod, stat ==============================="
4933 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4939 echo hello >> $DIR1/$tfile
4940 local mtime1=`stat -c %Y $DIR1/$tfile`
4942 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4944 if [ "$d1" != "$d2" ]; then
4945 echo "write and touch not within one second"
4947 for (( i=0; i < 2; i++ )) ; do
4948 local mtime2=`stat -c %Y $DIR1/$tfile`
4949 [ "$mtime2" = $TEST_39_MTIME ] || \
4950 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4952 cancel_lru_locks $OSC
4953 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4957 run_test 39h "write, utime within one second, stat ============="
4960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4965 echo hello >> $DIR1/$tfile
4966 local mtime1=`stat -c %Y $DIR1/$tfile`
4968 mv $DIR1/$tfile $DIR1/$tfile-1
4970 for (( i=0; i < 2; i++ )) ; do
4971 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4973 [ "$mtime1" = "$mtime2" ] || \
4974 error "lost mtime: $mtime2, should be $mtime1"
4976 cancel_lru_locks $OSC
4977 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4980 run_test 39i "write, rename, stat =============================="
4983 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4985 start_full_debug_logging
4989 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4990 lctl set_param fail_loc=0x80000412
4991 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4992 error "multiop failed"
4994 local mtime1=`stat -c %Y $DIR1/$tfile`
4996 mv $DIR1/$tfile $DIR1/$tfile-1
4998 kill -USR1 $multipid
4999 wait $multipid || error "multiop close failed"
5001 for (( i=0; i < 2; i++ )) ; do
5002 local mtime2=`stat -c %Y $DIR1/$tfile-1`
5003 [ "$mtime1" = "$mtime2" ] ||
5004 error "mtime is lost on close: $mtime2, " \
5008 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5010 lctl set_param fail_loc=0
5011 stop_full_debug_logging
5013 run_test 39j "write, rename, close, stat ======================="
5016 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5021 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
5023 local mtime1=`stat -c %Y $DIR1/$tfile`
5025 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
5027 kill -USR1 $multipid
5028 wait $multipid || error "multiop close failed"
5030 for (( i=0; i < 2; i++ )) ; do
5031 local mtime2=`stat -c %Y $DIR1/$tfile`
5033 [ "$mtime2" = $TEST_39_MTIME ] || \
5034 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
5037 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5040 run_test 39k "write, utime, close, stat ========================"
5042 # this should be set to future
5043 TEST_39_ATIME=`date -d "1 year" +%s`
5046 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5047 remote_mds_nodsh && skip "remote MDS with nodsh"
5049 local atime_diff=$(do_facet $SINGLEMDS \
5050 lctl get_param -n mdd.*MDT0000*.atime_diff)
5052 mkdir_on_mdt0 $DIR/$tdir
5054 # test setting directory atime to future
5055 touch -a -d @$TEST_39_ATIME $DIR/$tdir
5056 local atime=$(stat -c %X $DIR/$tdir)
5057 [ "$atime" = $TEST_39_ATIME ] ||
5058 error "atime is not set to future: $atime, $TEST_39_ATIME"
5060 # test setting directory atime from future to now
5061 local now=$(date +%s)
5062 touch -a -d @$now $DIR/$tdir
5064 atime=$(stat -c %X $DIR/$tdir)
5065 [ "$atime" -eq "$now" ] ||
5066 error "atime is not updated from future: $atime, $now"
5068 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
5071 # test setting directory atime when now > dir atime + atime_diff
5072 local d1=$(date +%s)
5074 local d2=$(date +%s)
5075 cancel_lru_locks mdc
5076 atime=$(stat -c %X $DIR/$tdir)
5077 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5078 error "atime is not updated : $atime, should be $d2"
5080 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
5083 # test not setting directory atime when now < dir atime + atime_diff
5085 cancel_lru_locks mdc
5086 atime=$(stat -c %X $DIR/$tdir)
5087 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5088 error "atime is updated to $atime, should remain $d1<atime<$d2"
5090 do_facet $SINGLEMDS \
5091 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5093 run_test 39l "directory atime update ==========================="
5096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5100 local far_past_mtime=$(date -d "May 29 1953" +%s)
5101 local far_past_atime=$(date -d "Dec 17 1903" +%s)
5103 touch -m -d @$far_past_mtime $DIR1/$tfile
5104 touch -a -d @$far_past_atime $DIR1/$tfile
5106 for (( i=0; i < 2; i++ )) ; do
5107 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
5108 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
5109 error "atime or mtime set incorrectly"
5111 cancel_lru_locks $OSC
5112 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5115 run_test 39m "test atime and mtime before 1970"
5117 test_39n() { # LU-3832
5118 remote_mds_nodsh && skip "remote MDS with nodsh"
5120 local atime_diff=$(do_facet $SINGLEMDS \
5121 lctl get_param -n mdd.*MDT0000*.atime_diff)
5126 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
5129 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
5130 atime0=$(stat -c %X $DIR/$tfile)
5133 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5134 atime1=$(stat -c %X $DIR/$tfile)
5137 cancel_lru_locks mdc
5138 cancel_lru_locks osc
5139 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5140 atime2=$(stat -c %X $DIR/$tfile)
5142 do_facet $SINGLEMDS \
5143 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5145 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
5146 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
5148 run_test 39n "check that O_NOATIME is honored"
5151 TESTDIR=$DIR/$tdir/$tfile
5152 [ -e $TESTDIR ] && rm -rf $TESTDIR
5159 links2=$(stat -c %h .)
5160 [ $(($links1 + 2)) != $links2 ] &&
5161 error "wrong links count $(($links1 + 2)) != $links2"
5163 links3=$(stat -c %h .)
5164 [ $(($links1 + 1)) != $links3 ] &&
5165 error "wrong links count $links1 != $links3"
5168 run_test 39o "directory cached attributes updated after create"
5171 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
5174 TESTDIR=$DIR/$tdir/$tdir
5175 [ -e $TESTDIR ] && rm -rf $TESTDIR
5176 test_mkdir -p $TESTDIR
5180 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
5181 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
5183 links2=$(stat -c %h .)
5184 [ $(($links1 + 2)) != $links2 ] &&
5185 error "wrong links count $(($links1 + 2)) != $links2"
5187 links3=$(stat -c %h .)
5188 [ $(($links1 + 1)) != $links3 ] &&
5189 error "wrong links count $links1 != $links3"
5192 run_test 39p "remote directory cached attributes updated after create ========"
5195 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
5196 skip "no atime update on old OST"
5197 if [ "$ost1_FSTYPE" != ldiskfs ]; then
5198 skip_env "ldiskfs only test"
5202 saved_adiff=$(do_facet ost1 \
5203 lctl get_param -n obdfilter.*OST0000.atime_diff)
5204 stack_trap "do_facet ost1 \
5205 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
5207 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
5209 $LFS setstripe -i 0 $DIR/$tfile
5210 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
5211 error "can't write initial file"
5212 cancel_lru_locks osc
5214 # exceed atime_diff and access file
5216 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
5217 error "can't udpate atime"
5219 local atime_cli=$(stat -c %X $DIR/$tfile)
5220 echo "client atime: $atime_cli"
5221 # allow atime update to be written to device
5222 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
5225 local ostdev=$(ostdevname 1)
5226 local fid=($($LFS getstripe $DIR/$tfile | grep 0x))
5227 local seq=${fid[3]#0x}
5231 if [ $seq == 0 ]; then
5234 oid_hex=${fid[2]#0x}
5236 local objpath="O/$seq/d$(($oid % 32))/$oid_hex"
5237 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
5239 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
5240 local atime_ost=$(do_facet ost1 "$cmd" |&
5241 awk -F'[: ]' '/atime:/ { print $4 }')
5242 (( atime_cli == atime_ost )) ||
5243 error "atime on client $atime_cli != ost $atime_ost"
5245 run_test 39r "lazy atime update on OST"
5247 test_39q() { # LU-8041
5248 local testdir=$DIR/$tdir
5250 multiop_bg_pause $testdir D_c || error "multiop failed"
5252 cancel_lru_locks mdc
5253 kill -USR1 $multipid
5254 local atime=$(stat -c %X $testdir)
5255 [ "$atime" -ne 0 ] || error "atime is zero"
5257 run_test 39q "close won't zero out atime"
5266 umount_client $MOUNT
5267 mount_client $MOUNT relatime
5269 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer conv=fsync
5270 atime0=$(stat -c %X $DIR/$tfile)
5272 # First read updates atime
5274 cat $DIR/$tfile >/dev/null
5275 atime1=$(stat -c %X $DIR/$tfile) # (atime = atime0 + 1)
5277 # Next reads do not update atime
5279 cat $DIR/$tfile >/dev/null
5280 atime2=$(stat -c %X $DIR/$tfile) # (atime = atime0 + 1)
5282 # If mtime is greater than atime, atime is updated
5284 touch -m $DIR/$tfile # (mtime = now)
5286 cat $DIR/$tfile >/dev/null # (atime is updated because atime < mtime)
5287 atime3=$(stat -c %X $DIR/$tfile) # (atime = mtime = atime0 + 3)
5289 # Next reads do not update atime
5291 cat $DIR/$tfile >/dev/null
5292 atime4=$(stat -c %X $DIR/$tfile)
5294 # Remount the client to clear 'relatime' option
5295 remount_client $MOUNT
5297 if (( MDS1_VERSION >= $(version_code 2.15.50) )); then
5298 # The full test lasted less than default atime_diff
5299 # Client was remounted to clear 'relatime' option for next tests
5300 # and to confirm atime was written to disk
5301 local atime5=$(stat -c %X $DIR/$tfile)
5302 (( atime3 == atime5 )) ||
5303 error "atime3 $atime3 != atime5 $atime5"
5306 (( atime0 < atime1 )) ||
5307 error "atime $atime0 should be smaller than $atime1"
5308 (( atime1 == atime2 )) ||
5309 error "atime $atime1 was updated to $atime2"
5310 (( atime1 < atime3 )) || error "atime1 $atime1 != atime3 $atime3"
5311 (( atime3 == atime4 )) || error "atime3 $atime3 != atime4 $atime4"
5313 run_test 39s "relatime is supported"
5316 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5317 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5318 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5319 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5320 error "$tfile is not 4096 bytes in size"
5322 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5326 small_write $DIR/f41 18
5328 run_test 41 "test small file write + fstat ====================="
5330 count_ost_writes() {
5331 lctl get_param -n ${OSC}.*.stats |
5332 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5333 END { printf("%0.0f", writes) }'
5340 BG_DIRTY_RATIO_SAVE=10
5341 MAX_BG_DIRTY_RATIO=25
5345 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5346 # dirty_ratio, dirty_background_ratio
5347 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5348 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5349 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5350 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5352 # if file not here, we are a 2.4 kernel
5353 kill -CONT `pidof kupdated`
5358 # setup the trap first, so someone cannot exit the test at the
5359 # exact wrong time and mess up a machine
5360 trap start_writeback EXIT
5361 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5362 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5363 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5364 sysctl -w vm.dirty_writeback_centisecs=0
5365 sysctl -w vm.dirty_writeback_centisecs=0
5366 # save and increase /proc/sys/vm/dirty_ratio
5367 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5368 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5369 # save and increase /proc/sys/vm/dirty_background_ratio
5370 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5371 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5373 # if file not here, we are a 2.4 kernel
5374 kill -STOP `pidof kupdated`
5378 # ensure that all stripes have some grant before we test client-side cache
5380 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5381 dd if=/dev/zero of=$i bs=4k count=1
5386 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5387 # file truncation, and file removal.
5389 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5392 cancel_lru_locks $OSC
5394 sync; sleep 1; sync # just to be safe
5395 BEFOREWRITES=`count_ost_writes`
5396 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5397 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5398 AFTERWRITES=`count_ost_writes`
5399 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5400 error "$BEFOREWRITES < $AFTERWRITES"
5403 run_test 42a "ensure that we don't flush on close"
5406 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5409 cancel_lru_locks $OSC
5412 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5413 BEFOREWRITES=$(count_ost_writes)
5414 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
5415 AFTERWRITES=$(count_ost_writes)
5416 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5417 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5419 BEFOREWRITES=$(count_ost_writes)
5420 sync || error "sync: $?"
5421 AFTERWRITES=$(count_ost_writes)
5422 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5423 error "$BEFOREWRITES < $AFTERWRITES on sync"
5425 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5429 run_test 42b "test destroy of file with cached dirty data ======"
5431 # if these tests just want to test the effect of truncation,
5432 # they have to be very careful. consider:
5433 # - the first open gets a {0,EOF}PR lock
5434 # - the first write conflicts and gets a {0, count-1}PW
5435 # - the rest of the writes are under {count,EOF}PW
5436 # - the open for truncate tries to match a {0,EOF}PR
5437 # for the filesize and cancels the PWs.
5438 # any number of fixes (don't get {0,EOF} on open, match
5439 # composite locks, do smarter file size management) fix
5440 # this, but for now we want these tests to verify that
5441 # the cancellation with truncate intent works, so we
5442 # start the file with a full-file pw lock to match against
5443 # until the truncate.
5448 cancel_lru_locks $OSC
5450 # prime the file with 0,EOF PW to match
5454 # now the real test..
5455 dd if=/dev/zero of=$file bs=1024 count=100
5456 BEFOREWRITES=`count_ost_writes`
5457 $TRUNCATE $file $offset
5458 cancel_lru_locks $OSC
5459 AFTERWRITES=`count_ost_writes`
5464 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5467 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5468 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5471 run_test 42c "test partial truncate of file with cached dirty data"
5474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5476 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
5477 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
5478 $LCTL set_param debug=+cache
5481 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5482 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5485 run_test 42d "test complete truncate of file with cached dirty data"
5487 test_42e() { # bug22074
5488 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5490 local TDIR=$DIR/${tdir}e
5491 local pages=16 # hardcoded 16 pages, don't change it.
5492 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5493 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5497 test_mkdir $DIR/${tdir}e
5498 $LFS setstripe -c 1 $TDIR
5499 createmany -o $TDIR/f $files
5501 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5503 # we assume that with $OSTCOUNT files, at least one of them will
5504 # be allocated on OST0.
5505 warmup_files=$((OSTCOUNT * max_dirty_mb))
5506 createmany -o $TDIR/w $warmup_files
5508 # write a large amount of data into one file and sync, to get good
5509 # avail_grant number from OST.
5510 for ((i=0; i<$warmup_files; i++)); do
5511 idx=$($LFS getstripe -i $TDIR/w$i)
5512 [ $idx -ne 0 ] && continue
5513 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5516 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5518 $LCTL get_param $proc_osc0/cur_dirty_bytes
5519 $LCTL get_param $proc_osc0/cur_grant_bytes
5521 # create as much dirty pages as we can while not to trigger the actual
5522 # RPCs directly. but depends on the env, VFS may trigger flush during this
5523 # period, hopefully we are good.
5524 for ((i=0; i<$warmup_files; i++)); do
5525 idx=$($LFS getstripe -i $TDIR/w$i)
5526 [ $idx -ne 0 ] && continue
5527 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5529 $LCTL get_param $proc_osc0/cur_dirty_bytes
5530 $LCTL get_param $proc_osc0/cur_grant_bytes
5532 # perform the real test
5533 $LCTL set_param $proc_osc0/rpc_stats 0
5534 for ((;i<$files; i++)); do
5535 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5536 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5539 $LCTL get_param $proc_osc0/rpc_stats
5542 local have_ppr=false
5543 $LCTL get_param $proc_osc0/rpc_stats |
5544 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5545 # skip lines until we are at the RPC histogram data
5546 [ "$PPR" == "pages" ] && have_ppr=true && continue
5547 $have_ppr || continue
5549 # we only want the percent stat for < 16 pages
5550 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5552 percent=$((percent + WPCT))
5553 if [[ $percent -gt 15 ]]; then
5554 error "less than 16-pages write RPCs" \
5561 run_test 42e "verify sub-RPC writes are not done synchronously"
5563 test_43A() { # was test_43
5564 test_mkdir $DIR/$tdir
5565 cp -p /bin/ls $DIR/$tdir/$tfile
5566 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5568 # give multiop a chance to open
5571 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5573 # Wait for multiop to exit
5576 run_test 43A "execution of file opened for write should return -ETXTBSY"
5579 test_mkdir $DIR/$tdir
5580 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5581 $DIR/$tdir/sleep 60 &
5583 # Make sure exec of $tdir/sleep wins race with truncate
5585 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5588 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5593 test_mkdir $DIR/$tdir
5594 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5595 $DIR/$tdir/sleep 60 &
5597 # Make sure exec of $tdir/sleep wins race with truncate
5599 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5602 run_test 43b "truncate of file being executed should return -ETXTBSY"
5605 local testdir="$DIR/$tdir"
5608 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5609 ( cd $testdir && md5sum -c )
5611 run_test 43c "md5sum of copy into lustre"
5613 test_44A() { # was test_44
5614 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5616 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5617 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5619 run_test 44A "zero length read from a sparse stripe"
5622 local nstripe=$($LFS getstripe -c -d $DIR)
5623 [ -z "$nstripe" ] && skip "can't get stripe info"
5624 [[ $nstripe -gt $OSTCOUNT ]] &&
5625 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5627 local stride=$($LFS getstripe -S -d $DIR)
5628 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5629 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5632 OFFSETS="0 $((stride/2)) $((stride-1))"
5633 for offset in $OFFSETS; do
5634 for i in $(seq 0 $((nstripe-1))); do
5635 local GLOBALOFFSETS=""
5637 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5638 local myfn=$DIR/d44a-$size
5639 echo "--------writing $myfn at $size"
5640 ll_sparseness_write $myfn $size ||
5641 error "ll_sparseness_write"
5642 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5643 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5644 error "ll_sparseness_verify $GLOBALOFFSETS"
5646 for j in $(seq 0 $((nstripe-1))); do
5648 size=$((((j + $nstripe )*$stride + $offset)))
5649 ll_sparseness_write $myfn $size ||
5650 error "ll_sparseness_write"
5651 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5653 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5654 error "ll_sparseness_verify $GLOBALOFFSETS"
5659 run_test 44a "test sparse pwrite ==============================="
5663 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5669 before=`dirty_osc_total`
5670 echo executing "\"$*\""
5672 after=`dirty_osc_total`
5673 echo before $before, after $after
5676 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5679 # Obtain grants from OST if it supports it
5680 echo blah > ${f}_grant
5683 do_dirty_record "echo blah > $f"
5684 [[ $before -eq $after ]] && error "write wasn't cached"
5685 do_dirty_record "> $f"
5686 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5687 do_dirty_record "echo blah > $f"
5688 [[ $before -eq $after ]] && error "write wasn't cached"
5689 do_dirty_record "sync"
5690 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5691 do_dirty_record "echo blah > $f"
5692 [[ $before -eq $after ]] && error "write wasn't cached"
5693 do_dirty_record "cancel_lru_locks osc"
5694 [[ $before -gt $after ]] ||
5695 error "lock cancellation didn't lower dirty count"
5698 run_test 45 "osc io page accounting ============================"
5700 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5701 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5702 # objects offset and an assert hit when an rpc was built with 1023's mapped
5703 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5705 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5710 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5712 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5713 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5717 run_test 46 "dirtying a previously written page ================"
5719 # test_47 is removed "Device nodes check" is moved to test_28
5721 test_48a() { # bug 2399
5722 [ "$mds1_FSTYPE" = "zfs" ] &&
5723 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5724 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5726 test_mkdir $DIR/$tdir
5728 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5729 test_mkdir $DIR/$tdir
5730 touch foo || error "'touch foo' failed after recreating cwd"
5732 touch .foo || error "'touch .foo' failed after recreating cwd"
5734 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5735 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5736 cd . || error "'cd .' failed after recreating cwd"
5737 mkdir . && error "'mkdir .' worked after recreating cwd"
5738 rmdir . && error "'rmdir .' worked after recreating cwd"
5739 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5740 cd .. || error "'cd ..' failed after recreating cwd"
5742 run_test 48a "Access renamed working dir (should return errors)="
5744 test_48b() { # bug 2399
5746 test_mkdir $DIR/$tdir
5748 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5749 touch foo && error "'touch foo' worked after removing cwd"
5750 mkdir foo && error "'mkdir foo' worked after removing cwd"
5751 touch .foo && error "'touch .foo' worked after removing cwd"
5752 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5753 ls . > /dev/null && error "'ls .' worked after removing cwd"
5754 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5755 mkdir . && error "'mkdir .' worked after removing cwd"
5756 rmdir . && error "'rmdir .' worked after removing cwd"
5757 ln -s . foo && error "'ln -s .' worked after removing cwd"
5758 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5760 run_test 48b "Access removed working dir (should return errors)="
5762 test_48c() { # bug 2350
5763 #lctl set_param debug=-1
5766 test_mkdir -p $DIR/$tdir/dir
5768 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5769 $TRACE touch foo && error "touch foo worked after removing cwd"
5770 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5771 touch .foo && error "touch .foo worked after removing cwd"
5772 mkdir .foo && error "mkdir .foo worked after removing cwd"
5773 $TRACE ls . && error "'ls .' worked after removing cwd"
5774 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5775 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5776 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5777 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5778 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5780 run_test 48c "Access removed working subdir (should return errors)"
5782 test_48d() { # bug 2350
5783 #lctl set_param debug=-1
5786 test_mkdir -p $DIR/$tdir/dir
5788 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5789 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5790 $TRACE touch foo && error "'touch foo' worked after removing parent"
5791 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5792 touch .foo && error "'touch .foo' worked after removing parent"
5793 mkdir .foo && error "mkdir .foo worked after removing parent"
5794 $TRACE ls . && error "'ls .' worked after removing parent"
5795 $TRACE ls .. && error "'ls ..' worked after removing parent"
5796 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5797 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5798 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5801 run_test 48d "Access removed parent subdir (should return errors)"
5803 test_48e() { # bug 4134
5804 #lctl set_param debug=-1
5807 test_mkdir -p $DIR/$tdir/dir
5809 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5810 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5811 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5812 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5813 # On a buggy kernel addition of "touch foo" after cd .. will
5814 # produce kernel oops in lookup_hash_it
5815 touch ../foo && error "'cd ..' worked after recreate parent"
5817 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5819 run_test 48e "Access to recreated parent subdir (should return errors)"
5822 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5823 skip "need MDS >= 2.13.55"
5824 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5825 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5826 skip "needs different host for mdt1 mdt2"
5827 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5829 $LFS mkdir -i0 $DIR/$tdir
5830 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5832 for d in sub1 sub2 sub3; do
5833 #define OBD_FAIL_OSD_REF_DEL 0x19c
5834 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5835 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5838 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5840 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5842 test_49() { # LU-1030
5843 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5844 remote_ost_nodsh && skip "remote OST with nodsh"
5846 # get ost1 size - $FSNAME-OST0000
5847 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5849 # write 800M at maximum
5850 [[ $ost1_size -lt 2 ]] && ost1_size=2
5851 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5853 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5854 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5857 # change max_pages_per_rpc while writing the file
5858 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5859 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5860 # loop until dd process exits
5861 while ps ax -opid | grep -wq $dd_pid; do
5862 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5863 sleep $((RANDOM % 5 + 1))
5865 # restore original max_pages_per_rpc
5866 $LCTL set_param $osc1_mppc=$orig_mppc
5867 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5869 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5873 test_mkdir $DIR/$tdir
5875 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5877 run_test 50 "special situations: /proc symlinks ==============="
5879 test_51a() { # was test_51
5880 # bug 1516 - create an empty entry right after ".." then split dir
5881 test_mkdir -c1 $DIR/$tdir
5882 touch $DIR/$tdir/foo
5883 $MCREATE $DIR/$tdir/bar
5885 createmany -m $DIR/$tdir/longfile 201
5887 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5888 $MCREATE $DIR/$tdir/longfile$FNUM
5893 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5895 run_test 51a "special situations: split htree with empty entry =="
5897 cleanup_print_lfs_df () {
5904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5906 local dir=$DIR/$tdir
5907 local nrdirs=$((65536 + 100))
5909 # cleanup the directory
5912 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5916 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5917 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5918 [[ $numfree -lt $nrdirs ]] &&
5919 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5921 # need to check free space for the directories as well
5922 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5923 numfree=$(( blkfree / $(fs_inode_ksize) ))
5924 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5926 trap cleanup_print_lfs_df EXIT
5929 createmany -d $dir/d $nrdirs || {
5930 unlinkmany $dir/d $nrdirs
5931 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5935 nrdirs=$(ls -U $dir | wc -l)
5937 # unlink all but 100 subdirectories, then check it still works
5939 local delete=$((nrdirs - left))
5944 # for ldiskfs the nlink count should be 1, but this is OSD specific
5945 # and so this is listed for informational purposes only
5946 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5947 unlinkmany -d $dir/d $delete ||
5948 error "unlink of first $delete subdirs failed"
5950 echo "nlink between: $(stat -c %h $dir)"
5951 local found=$(ls -U $dir | wc -l)
5952 [ $found -ne $left ] &&
5953 error "can't find subdirs: found only $found, expected $left"
5955 unlinkmany -d $dir/d $delete $left ||
5956 error "unlink of second $left subdirs failed"
5957 # regardless of whether the backing filesystem tracks nlink accurately
5958 # or not, the nlink count shouldn't be more than "." and ".." here
5959 local after=$(stat -c %h $dir)
5960 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5961 echo "nlink after: $after"
5963 cleanup_print_lfs_df
5965 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5968 local stripecount=$1
5971 log "create files with stripecount=$stripecount"
5972 $LFS setstripe -C $stripecount $DIR/$tdir
5973 createmany -o $DIR/$tdir/t- $nfiles
5974 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5975 for ((n = 0; n < $OSTCOUNT; n++)); do
5976 objs[$n]=$(awk -vobjs=0 '($1 == '$n') { objs += 1 } \
5977 END { printf("%0.0f", objs) }' $TMP/$tfile)
5978 objs0[$n]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5979 '($1 == '$n') { objs += 1 } \
5980 END { printf("%0.0f", objs) }')
5981 log "OST$n has ${objs[$n]} objects, ${objs0[$n]} are index 0"
5983 unlinkmany $DIR/$tdir/t- $nfiles
5988 local max=6 # allow variance of (1 - $min/$max) = 33% by default
5990 # For some combinations of stripecount and OSTCOUNT current code
5991 # is not ideal, and allocates 50% fewer *first* objects to some OSTs
5992 # than others. Rather than skipping this test entirely, check that
5993 # and keep testing to ensure imbalance does not get worse. LU-15282
5994 (( (OSTCOUNT == 6 && stripecount == 4) ||
5995 (OSTCOUNT == 10 && (stripecount == 4 || stripecount == 8)) ||
5996 (OSTCOUNT == 12 && (stripecount == 8 || stripecount == 9)))) && max=9
5997 for ((nlast=0, n = 1; n < $OSTCOUNT; nlast=n,n++)); do
5998 (( ${objs[$n]} > ${objs[$nlast]} * 4 / 5 )) ||
5999 { $LFS df && $LFS df -i &&
6000 error "stripecount=$stripecount: " \
6001 "OST $n has fewer objects vs. OST $nlast " \
6002 "(${objs[$n]} < ${objs[$nlast]} x 4/5)"; }
6003 (( ${objs[$n]} < ${objs[$nlast]} * 5 / 4 )) ||
6004 { $LFS df && $LFS df -i &&
6005 error "stripecount=$stripecount: " \
6006 "OST $n has more objects vs. OST $nlast " \
6007 "(${objs[$n]} > ${objs[$nlast]} x 5/4)"; }
6009 (( ${objs0[$n]} > ${objs0[$nlast]} * $min / $max )) ||
6010 { $LFS df && $LFS df -i &&
6011 error "stripecount=$stripecount: " \
6012 "OST $n has fewer #0 objects vs. OST $nlast " \
6013 "(${objs0[$n]} < ${objs0[$nlast]} x $min/$max)"; }
6014 (( ${objs0[$n]} < ${objs0[$nlast]} * $max / $min )) ||
6015 { $LFS df && $LFS df -i &&
6016 error "stripecount=$stripecount: " \
6017 "OST $n has more #0 objects vs. OST $nlast " \
6018 "(${objs0[$n]} > ${objs0[$nlast]} x $max/$min)"; }
6023 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6024 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
6028 local nfiles=$((per_ost * OSTCOUNT))
6029 local mdts=$(comma_list $(mdts_nodes))
6030 local param="osp.*.create_count"
6031 local qos_old=$(do_facet mds1 \
6032 "$LCTL get_param -n lod.$FSNAME-*.qos_threshold_rr" | head -n 1)
6035 "$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=100"
6036 stack_trap "do_nodes $mdts \
6037 '$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=${qos_old%%%}'"
6039 test_mkdir $DIR/$tdir
6040 local dirstripes=$(lfs getdirstripe -c $DIR/$tdir)
6041 (( dirstripes > 0 )) || dirstripes=1
6043 # Ensure enough OST objects precreated for tests to pass without
6044 # running out of objects. This is an LOV r-r OST algorithm test,
6045 # not an OST object precreation test.
6046 local old=$(do_facet mds1 "$LCTL get_param -n $param" | head -n 1)
6047 (( old >= nfiles )) ||
6049 local create_count=$((nfiles * OSTCOUNT / dirstripes))
6051 do_nodes $mdts "$LCTL set_param $param=$create_count"
6052 stack_trap "do_nodes $mdts $LCTL set_param $param=$old"
6054 # trigger precreation from all MDTs for all OSTs
6055 for ((i = 0; i < $MDSCOUNT * 2; i++ )); do
6056 $LFS setstripe -c -1 $DIR/$tdir/wide.$i
6060 for ((stripecount = 3; stripecount <= $OSTCOUNT; stripecount++)); do
6061 sleep 8 # allow object precreation to catch up
6062 test_51d_sub $stripecount $nfiles
6065 run_test 51d "check LOV round-robin OST object distribution"
6068 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6069 skip_env "ldiskfs only test"
6072 test_mkdir -c1 $DIR/$tdir
6073 test_mkdir -c1 $DIR/$tdir/d0
6075 touch $DIR/$tdir/d0/foo
6076 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
6077 error "file exceed 65000 nlink limit!"
6078 unlinkmany $DIR/$tdir/d0/f- 65001
6081 run_test 51e "check file nlink limit"
6084 test_mkdir $DIR/$tdir
6087 local ulimit_old=$(ulimit -n)
6088 local spare=20 # number of spare fd's for scripts/libraries, etc.
6089 local mdt=$($LFS getstripe -m $DIR/$tdir)
6090 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
6092 echo "MDT$mdt numfree=$numfree, max=$max"
6093 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
6094 if [ $((numfree + spare)) -gt $ulimit_old ]; then
6095 while ! ulimit -n $((numfree + spare)); do
6096 numfree=$((numfree * 3 / 4))
6098 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
6100 echo "left ulimit at $ulimit_old"
6103 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
6104 unlinkmany $DIR/$tdir/f $numfree
6105 error "create+open $numfree files in $DIR/$tdir failed"
6107 ulimit -n $ulimit_old
6109 # if createmany exits at 120s there will be fewer than $numfree files
6110 unlinkmany $DIR/$tdir/f $numfree || true
6112 run_test 51f "check many open files limit"
6115 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
6116 test_mkdir $DIR/$tdir
6117 touch $DIR/$tdir/foo
6118 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
6119 echo bar >> $DIR/$tdir/foo || error "append bar failed"
6120 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6121 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6122 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6124 echo foo >> $DIR/$tdir/foo || error "append foo failed"
6125 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6126 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
6128 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
6129 cp -r $DIR/$tdir $TMP/
6130 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
6132 run_test 52a "append-only flag test (should return errors)"
6135 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
6136 test_mkdir $DIR/$tdir
6137 touch $DIR/$tdir/foo
6138 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
6139 cat test > $DIR/$tdir/foo && error "cat test worked"
6140 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6141 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6142 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6144 echo foo >> $DIR/$tdir/foo && error "echo worked"
6145 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6146 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
6147 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
6148 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
6150 chattr -i $DIR/$tdir/foo || error "chattr failed"
6152 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
6154 run_test 52b "immutable flag test (should return errors) ======="
6157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6158 remote_mds_nodsh && skip "remote MDS with nodsh"
6159 remote_ost_nodsh && skip "remote OST with nodsh"
6172 local support_last_seq=true
6174 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
6175 support_last_seq=false
6178 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
6180 for value in $(do_facet $SINGLEMDS \
6181 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
6182 param=$(echo ${value[0]} | cut -d "=" -f1)
6183 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
6185 if $support_last_seq; then
6186 param_seq=$(echo $param |
6187 sed -e s/prealloc_last_id/prealloc_last_seq/g)
6188 mds_last_seq=$(do_facet $SINGLEMDS \
6189 $LCTL get_param -n $param_seq)
6191 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
6193 ostnum=$(index_from_ostuuid ${ostname}_UUID)
6194 node=$(facet_active_host ost$((ostnum+1)))
6195 param="obdfilter.$ostname.last_id"
6196 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
6197 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
6198 ost_last_id=$ost_last
6200 if $support_last_seq; then
6201 ost_last_id=$(echo $ost_last |
6202 awk -F':' '{print $2}' |
6204 ost_last_seq=$(echo $ost_last |
6205 awk -F':' '{print $1}')
6206 [[ $ost_last_seq = $mds_last_seq ]] || continue
6209 if [[ $ost_last_id != $mds_last ]]; then
6210 error "$ost_last_id != $mds_last"
6217 $found || error "can not match last_seq/last_id for $mdtosc"
6220 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
6223 perl -MSocket -e ';' || skip "no Socket perl module installed"
6225 $SOCKETSERVER $DIR/socket ||
6226 error "$SOCKETSERVER $DIR/socket failed: $?"
6227 $SOCKETCLIENT $DIR/socket ||
6228 error "$SOCKETCLIENT $DIR/socket failed: $?"
6229 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
6231 run_test 54a "unix domain socket test =========================="
6237 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
6239 run_test 54b "char device works in lustre ======================"
6242 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
6243 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
6244 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
6246 for i in $(seq 3 7); do
6247 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
6256 loopdev="$DIR/loop54c"
6259 $UMOUNT $DIR/$tdir || rc=$?
6260 losetup -d $loopdev || true
6261 losetup -d $LOOPDEV || true
6262 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
6267 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6269 loopdev="$DIR/loop54c"
6272 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
6273 trap cleanup_54c EXIT
6274 mknod $loopdev b 7 $LOOPNUM
6275 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
6276 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
6277 losetup $loopdev $DIR/$tfile ||
6278 error "can't set up $loopdev for $DIR/$tfile"
6279 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
6280 test_mkdir $DIR/$tdir
6281 mount -t ext2 $loopdev $DIR/$tdir ||
6282 error "error mounting $loopdev on $DIR/$tdir"
6283 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
6286 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
6290 run_test 54c "block device works in lustre ====================="
6293 local pipe="$DIR/$tfile.pipe"
6294 local string="aaaaaa"
6297 echo -n "$string" > $pipe &
6298 local result=$(cat $pipe)
6299 [[ "$result" == "$string" ]] || error "$result != $string"
6301 run_test 54d "fifo device works in lustre ======================"
6306 cp -aL /dev/console $f
6307 echo $string > $f || error "echo $string to $f failed"
6309 run_test 54e "console/tty device works in lustre ======================"
6314 local dir=$DIR/$tdir
6317 test_mkdir -p $dir/dir
6318 for i in $(seq $numfiles); do
6320 touch $dir/dir/file$i
6323 local numcomp=$($LFS getstripe --component-count $dir)
6325 [[ $numcomp == 0 ]] && numcomp=1
6327 # test lfs getstripe with --recursive
6328 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
6330 [[ $filenum -eq $((numfiles * 2)) ]] ||
6331 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
6332 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
6333 [[ $filenum -eq $numfiles ]] ||
6334 error "$LFS getstripe $dir: found $filenum, not $numfiles"
6335 echo "$LFS getstripe showed obdidx or l_ost_idx"
6337 # test lfs getstripe with file instead of dir
6338 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
6339 [[ $filenum -eq 1 ]] ||
6340 error "$LFS getstripe $dir/file1: found $filenum, not 1"
6341 echo "$LFS getstripe file1 passed"
6343 #test lfs getstripe with --verbose
6344 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
6345 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
6346 error "$LFS getstripe --verbose $dir: "\
6347 "got $filenum want $((numfiles * numcomp)) lmm_magic"
6348 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
6349 error "$LFS getstripe $dir: showed lmm_magic"
6351 #test lfs getstripe with -v prints lmm_fid
6352 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
6353 local countfids=$((numdirs + numfiles * numcomp))
6354 [[ $filenum -eq $countfids ]] ||
6355 error "$LFS getstripe -v $dir: "\
6356 "got $filenum want $countfids lmm_fid"
6357 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
6358 error "$LFS getstripe $dir: showed lmm_fid by default"
6359 echo "$LFS getstripe --verbose passed"
6361 #check for FID information
6362 local fid1=$($LFS getstripe --fid $dir/file1)
6363 local fid2=$($LFS getstripe --verbose $dir/file1 |
6364 awk '/lmm_fid: / { print $2; exit; }')
6365 local fid3=$($LFS path2fid $dir/file1)
6367 [ "$fid1" != "$fid2" ] &&
6368 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
6369 [ "$fid1" != "$fid3" ] &&
6370 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
6371 echo "$LFS getstripe --fid passed"
6373 #test lfs getstripe with --obd
6374 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6375 error "$LFS getstripe --obd wrong_uuid: should return error"
6377 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6380 local obduuid=$(ostuuid_from_index $ostidx)
6381 local found=$($LFS getstripe -r --obd $obduuid $dir |
6382 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6384 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6385 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6387 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6390 [[ $found -eq $filenum ]] ||
6391 error "$LFS getstripe --obd: found $found expect $filenum"
6392 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6393 sed '/^[ ]*'${ostidx}'[ ]/d' |
6394 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6395 error "$LFS getstripe --obd: should not show file on other obd"
6396 echo "$LFS getstripe --obd passed"
6398 run_test 56a "check $LFS getstripe"
6401 local dir=$DIR/$tdir
6405 for i in $(seq $numdirs); do
6406 test_mkdir $dir/dir$i
6409 # test lfs getdirstripe default mode is non-recursion, which is
6410 # different from lfs getstripe
6411 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6413 [[ $dircnt -eq 1 ]] ||
6414 error "$LFS getdirstripe: found $dircnt, not 1"
6415 dircnt=$($LFS getdirstripe --recursive $dir |
6416 grep -c lmv_stripe_count)
6417 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6418 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6420 run_test 56b "check $LFS getdirstripe"
6423 remote_ost_nodsh && skip "remote OST with nodsh"
6426 local ost_name=$(ostname_from_index $ost_idx)
6427 local old_status=$(ost_dev_status $ost_idx)
6428 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6430 [[ -z "$old_status" ]] ||
6431 skip_env "OST $ost_name is in $old_status status"
6433 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6434 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6435 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6436 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6437 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6438 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6441 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6442 error "$LFS df -v showing inactive devices"
6445 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6447 [[ "$new_status" =~ "D" ]] ||
6448 error "$ost_name status is '$new_status', missing 'D'"
6449 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6450 [[ "$new_status" =~ "N" ]] ||
6451 error "$ost_name status is '$new_status', missing 'N'"
6453 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6454 [[ "$new_status" =~ "f" ]] ||
6455 error "$ost_name status is '$new_status', missing 'f'"
6458 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6459 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6460 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6461 [[ -z "$p" ]] && restore_lustre_params < $p || true
6464 new_status=$(ost_dev_status $ost_idx)
6465 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6466 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6467 # can't check 'f' as devices may actually be on flash
6469 run_test 56c "check 'lfs df' showing device status"
6472 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6473 local osts=$($LFS df -v $MOUNT | grep -c OST)
6477 (( mdts == MDSCOUNT )) ||
6478 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6479 (( osts == OSTCOUNT )) ||
6480 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6482 run_test 56d "'lfs df -v' prints only configured devices"
6485 err_enoent=2 # No such file or directory
6486 err_eopnotsupp=95 # Operation not supported
6488 enoent_mnt=/pmt1 # Invalid dentry. Path not present
6489 notsup_mnt=/tmp # Valid dentry, but Not a lustreFS
6491 # Check for handling of path not exists
6492 output=$($LFS df $enoent_mnt 2>&1)
6495 fs=$(echo $output | awk -F: '{print $2}' | awk '{print $3}' | tr -d \')
6496 [[ $fs = $enoent_mnt && $ret -eq $err_enoent ]] ||
6497 error "expect failure $err_enoent, not $ret"
6499 # Check for handling of non-Lustre FS
6500 output=$($LFS df $notsup_mnt)
6503 fs=$(echo $output | awk '{print $1}' | awk -F: '{print $2}')
6504 [[ $fs = $notsup_mnt && $ret -eq $err_eopnotsupp ]] ||
6505 error "expect success $err_eopnotsupp, not $ret"
6507 # Check for multiple LustreFS argument
6508 output=$($LFS df $MOUNT $MOUNT $MOUNT | grep -c "filesystem_summary:")
6511 [[ $output -eq 3 && $ret -eq 0 ]] ||
6512 error "expect success 3, not $output, rc = $ret"
6514 # Check for correct non-Lustre FS handling among multiple
6516 output=$($LFS df $MOUNT $notsup_mnt $MOUNT |
6517 grep -c "filesystem_summary:"; exit ${PIPESTATUS[0]})
6520 [[ $output -eq 2 && $ret -eq $err_eopnotsupp ]] ||
6521 error "expect success 2, not $output, rc = $ret"
6523 run_test 56e "'lfs df' Handle non LustreFS & multiple LustreFS"
6528 local local_tdir="$1"
6529 local local_numfiles="$2"
6530 local local_numdirs="$3"
6531 local dir_params="$4"
6532 local dir_stripe_params="$5"
6534 if [ ! -d "$local_tdir" ] ; then
6535 test_mkdir -p $dir_stripe_params $local_tdir
6536 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6537 for i in $(seq $local_numfiles) ; do
6538 touch $local_tdir/file$i
6540 for i in $(seq $local_numdirs) ; do
6541 test_mkdir $dir_stripe_params $local_tdir/dir$i
6542 for j in $(seq $local_numfiles) ; do
6543 touch $local_tdir/dir$i/file$j
6549 setup_56_special() {
6551 local local_numfiles=$2
6552 local local_numdirs=$3
6554 setup_56 $local_tdir $local_numfiles $local_numdirs
6556 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6557 for i in $(seq $local_numfiles) ; do
6558 mknod $local_tdir/loop${i}b b 7 $i
6559 mknod $local_tdir/null${i}c c 1 3
6560 ln -s $local_tdir/file1 $local_tdir/link${i}
6562 for i in $(seq $local_numdirs) ; do
6563 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6564 mknod $local_tdir/dir$i/null${i}c c 1 3
6565 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6571 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6572 local expected=$(($NUMDIRS + 2))
6574 setup_56 $dir $NUMFILES $NUMDIRS
6576 # test lfs find with -name
6577 for i in $(seq $NUMFILES) ; do
6578 local nums=$($LFS find -name "*$i" $dir | wc -l)
6580 [ $nums -eq $expected ] ||
6581 error "lfs find -name '*$i' $dir wrong: "\
6582 "found $nums, expected $expected"
6585 run_test 56g "check lfs find -name"
6588 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6589 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6591 setup_56 $dir $NUMFILES $NUMDIRS
6593 # test lfs find with ! -name
6594 for i in $(seq $NUMFILES) ; do
6595 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6597 [ $nums -eq $expected ] ||
6598 error "lfs find ! -name '*$i' $dir wrong: "\
6599 "found $nums, expected $expected"
6602 run_test 56h "check lfs find ! -name"
6605 local dir=$DIR/$tdir
6609 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6612 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6614 run_test 56i "check 'lfs find -ost UUID' skips directories"
6617 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6619 setup_56_special $dir $NUMFILES $NUMDIRS
6621 local expected=$((NUMDIRS + 1))
6622 local cmd="$LFS find -type d $dir"
6623 local nums=$($cmd | wc -l)
6625 [ $nums -eq $expected ] ||
6626 error "'$cmd' wrong: found $nums, expected $expected"
6628 run_test 56j "check lfs find -type d"
6631 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6633 setup_56_special $dir $NUMFILES $NUMDIRS
6635 local expected=$(((NUMDIRS + 1) * NUMFILES))
6636 local cmd="$LFS find -type f $dir"
6637 local nums=$($cmd | wc -l)
6639 [ $nums -eq $expected ] ||
6640 error "'$cmd' wrong: found $nums, expected $expected"
6642 run_test 56k "check lfs find -type f"
6645 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6647 setup_56_special $dir $NUMFILES $NUMDIRS
6649 local expected=$((NUMDIRS + NUMFILES))
6650 local cmd="$LFS find -type b $dir"
6651 local nums=$($cmd | wc -l)
6653 [ $nums -eq $expected ] ||
6654 error "'$cmd' wrong: found $nums, expected $expected"
6656 run_test 56l "check lfs find -type b"
6659 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6661 setup_56_special $dir $NUMFILES $NUMDIRS
6663 local expected=$((NUMDIRS + NUMFILES))
6664 local cmd="$LFS find -type c $dir"
6665 local nums=$($cmd | wc -l)
6666 [ $nums -eq $expected ] ||
6667 error "'$cmd' wrong: found $nums, expected $expected"
6669 run_test 56m "check lfs find -type c"
6672 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6673 setup_56_special $dir $NUMFILES $NUMDIRS
6675 local expected=$((NUMDIRS + NUMFILES))
6676 local cmd="$LFS find -type l $dir"
6677 local nums=$($cmd | wc -l)
6679 [ $nums -eq $expected ] ||
6680 error "'$cmd' wrong: found $nums, expected $expected"
6682 run_test 56n "check lfs find -type l"
6685 local dir=$DIR/$tdir
6687 setup_56 $dir $NUMFILES $NUMDIRS
6688 utime $dir/file1 > /dev/null || error "utime (1)"
6689 utime $dir/file2 > /dev/null || error "utime (2)"
6690 utime $dir/dir1 > /dev/null || error "utime (3)"
6691 utime $dir/dir2 > /dev/null || error "utime (4)"
6692 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6693 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6696 local nums=$($LFS find -mtime +0 $dir | wc -l)
6698 [ $nums -eq $expected ] ||
6699 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6702 cmd="$LFS find -mtime 0 $dir"
6703 nums=$($cmd | wc -l)
6704 [ $nums -eq $expected ] ||
6705 error "'$cmd' wrong: found $nums, expected $expected"
6707 run_test 56o "check lfs find -mtime for old files"
6710 local dir=$DIR/$tdir
6714 # just to make sure there is something that won't be found
6716 touch $dir/$tfile.now
6718 for age in year week day hour min; do
6719 count=$((count + 1))
6721 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6722 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6723 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6725 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6726 local nums=$($cmd | wc -l)
6727 [ $nums -eq $expected ] ||
6728 error "'$cmd' wrong: found $nums, expected $expected"
6730 cmd="$LFS find $dir -atime $count${age:0:1}"
6731 nums=$($cmd | wc -l)
6732 [ $nums -eq $expected ] ||
6733 error "'$cmd' wrong: found $nums, expected $expected"
6737 cmd="$LFS find $dir -ctime +1s -type f"
6738 nums=$($cmd | wc -l)
6739 (( $nums == $count * 2 + 1)) ||
6740 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6742 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6744 test_newerXY_base() {
6747 local dir=$DIR/$tdir
6751 if [ $y == "t" ]; then
6752 if [ $x == "b" ]; then
6753 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6755 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6758 ref=$DIR/$tfile.newer.$x$y
6759 touch $ref || error "touch $ref failed"
6762 echo "before = $ref"
6764 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6766 if [ $y == "t" ]; then
6767 if [ $x == "b" ]; then
6768 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6770 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6773 negref=$DIR/$tfile.negnewer.$x$y
6774 touch $negref || error "touch $negref failed"
6777 echo "after = $negref"
6778 local cmd="$LFS find $dir -newer$x$y $ref"
6779 local nums=$(eval $cmd | wc -l)
6780 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6782 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6783 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6785 cmd="$LFS find $dir ! -newer$x$y $negref"
6786 nums=$(eval $cmd | wc -l)
6787 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6788 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6790 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6791 nums=$(eval $cmd | wc -l)
6792 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6793 error "'$cmd' wrong: found $nums between, expected $expected"; }
6799 test_newerXY_base "a" "a"
6800 test_newerXY_base "a" "m"
6801 test_newerXY_base "a" "c"
6802 test_newerXY_base "m" "a"
6803 test_newerXY_base "m" "m"
6804 test_newerXY_base "m" "c"
6805 test_newerXY_base "c" "a"
6806 test_newerXY_base "c" "m"
6807 test_newerXY_base "c" "c"
6809 test_newerXY_base "a" "t"
6810 test_newerXY_base "m" "t"
6811 test_newerXY_base "c" "t"
6813 [[ $MDS1_VERSION -lt $(version_code 2.13.54) ||
6814 $CLIENT_VERSION -lt $(version_code 2.13.54) ]] &&
6815 ! btime_supported && echo "btime unsupported" && return 0
6817 test_newerXY_base "b" "b"
6818 test_newerXY_base "b" "t"
6820 run_test 56oc "check lfs find -newerXY work"
6823 local dir=$DIR/$tdir
6828 $LFS find $dir -btime -1d -type f
6835 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
6836 ! btime_supported && skip "btime unsupported on MDS"
6838 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6839 ! btime_supported && skip "btime unsupported on clients"
6841 local dir=$DIR/$tdir
6842 local ref=$DIR/$tfile.ref
6843 local negref=$DIR/$tfile.negref
6845 mkdir $dir || error "mkdir $dir failed"
6846 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6847 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6848 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6849 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6850 touch $ref || error "touch $ref failed"
6851 # sleep 3 seconds at least
6854 local before=$(do_facet mds1 date +%s)
6855 local skew=$(($(date +%s) - before + 1))
6857 if (( skew < 0 && skew > -5 )); then
6858 sleep $((0 - skew + 1))
6862 # Set the dir stripe params to limit files all on MDT0,
6863 # otherwise we need to calc the max clock skew between
6864 # the client and MDTs.
6865 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6867 touch $negref || error "touch $negref failed"
6869 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6870 local nums=$($cmd | wc -l)
6871 local expected=$(((NUMFILES + 1) * NUMDIRS))
6873 [ $nums -eq $expected ] ||
6874 error "'$cmd' wrong: found $nums, expected $expected"
6876 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6877 nums=$($cmd | wc -l)
6878 expected=$((NUMFILES + 1))
6879 [ $nums -eq $expected ] ||
6880 error "'$cmd' wrong: found $nums, expected $expected"
6882 [ $skew -lt 0 ] && return
6884 local after=$(do_facet mds1 date +%s)
6885 local age=$((after - before + 1 + skew))
6887 cmd="$LFS find $dir -btime -${age}s -type f"
6888 nums=$($cmd | wc -l)
6889 expected=$(((NUMFILES + 1) * NUMDIRS))
6891 echo "Clock skew between client and server: $skew, age:$age"
6892 [ $nums -eq $expected ] ||
6893 error "'$cmd' wrong: found $nums, expected $expected"
6895 expected=$(($NUMDIRS + 1))
6896 cmd="$LFS find $dir -btime -${age}s -type d"
6897 nums=$($cmd | wc -l)
6898 [ $nums -eq $expected ] ||
6899 error "'$cmd' wrong: found $nums, expected $expected"
6900 rm -f $ref $negref || error "Failed to remove $ref $negref"
6902 run_test 56od "check lfs find -btime with units"
6905 [ $RUNAS_ID -eq $UID ] &&
6906 skip_env "RUNAS_ID = UID = $UID -- skipping"
6908 local dir=$DIR/$tdir
6910 setup_56 $dir $NUMFILES $NUMDIRS
6911 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6913 local expected=$NUMFILES
6914 local cmd="$LFS find -uid $RUNAS_ID $dir"
6915 local nums=$($cmd | wc -l)
6917 [ $nums -eq $expected ] ||
6918 error "'$cmd' wrong: found $nums, expected $expected"
6920 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6921 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6922 nums=$($cmd | wc -l)
6923 [ $nums -eq $expected ] ||
6924 error "'$cmd' wrong: found $nums, expected $expected"
6926 run_test 56p "check lfs find -uid and ! -uid"
6929 [ $RUNAS_ID -eq $UID ] &&
6930 skip_env "RUNAS_ID = UID = $UID -- skipping"
6932 local dir=$DIR/$tdir
6934 setup_56 $dir $NUMFILES $NUMDIRS
6935 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6937 local expected=$NUMFILES
6938 local cmd="$LFS find -gid $RUNAS_GID $dir"
6939 local nums=$($cmd | wc -l)
6941 [ $nums -eq $expected ] ||
6942 error "'$cmd' wrong: found $nums, expected $expected"
6944 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6945 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6946 nums=$($cmd | wc -l)
6947 [ $nums -eq $expected ] ||
6948 error "'$cmd' wrong: found $nums, expected $expected"
6950 run_test 56q "check lfs find -gid and ! -gid"
6953 local dir=$DIR/$tdir
6955 setup_56 $dir $NUMFILES $NUMDIRS
6958 local cmd="$LFS find -size 0 -type f -lazy $dir"
6959 local nums=$($cmd | wc -l)
6961 [ $nums -eq $expected ] ||
6962 error "'$cmd' wrong: found $nums, expected $expected"
6963 cmd="$LFS find -size 0 -type f $dir"
6964 nums=$($cmd | wc -l)
6965 [ $nums -eq $expected ] ||
6966 error "'$cmd' wrong: found $nums, expected $expected"
6969 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6970 nums=$($cmd | wc -l)
6971 [ $nums -eq $expected ] ||
6972 error "'$cmd' wrong: found $nums, expected $expected"
6973 cmd="$LFS find ! -size 0 -type f $dir"
6974 nums=$($cmd | wc -l)
6975 [ $nums -eq $expected ] ||
6976 error "'$cmd' wrong: found $nums, expected $expected"
6978 echo "test" > $dir/$tfile
6979 echo "test2" > $dir/$tfile.2 && sync
6981 cmd="$LFS find -size 5 -type f -lazy $dir"
6982 nums=$($cmd | wc -l)
6983 [ $nums -eq $expected ] ||
6984 error "'$cmd' wrong: found $nums, expected $expected"
6985 cmd="$LFS find -size 5 -type f $dir"
6986 nums=$($cmd | wc -l)
6987 [ $nums -eq $expected ] ||
6988 error "'$cmd' wrong: found $nums, expected $expected"
6991 cmd="$LFS find -size +5 -type f -lazy $dir"
6992 nums=$($cmd | wc -l)
6993 [ $nums -eq $expected ] ||
6994 error "'$cmd' wrong: found $nums, expected $expected"
6995 cmd="$LFS find -size +5 -type f $dir"
6996 nums=$($cmd | wc -l)
6997 [ $nums -eq $expected ] ||
6998 error "'$cmd' wrong: found $nums, expected $expected"
7001 cmd="$LFS find -size +0 -type f -lazy $dir"
7002 nums=$($cmd | wc -l)
7003 [ $nums -eq $expected ] ||
7004 error "'$cmd' wrong: found $nums, expected $expected"
7005 cmd="$LFS find -size +0 -type f $dir"
7006 nums=$($cmd | wc -l)
7007 [ $nums -eq $expected ] ||
7008 error "'$cmd' wrong: found $nums, expected $expected"
7011 cmd="$LFS find ! -size -5 -type f -lazy $dir"
7012 nums=$($cmd | wc -l)
7013 [ $nums -eq $expected ] ||
7014 error "'$cmd' wrong: found $nums, expected $expected"
7015 cmd="$LFS find ! -size -5 -type f $dir"
7016 nums=$($cmd | wc -l)
7017 [ $nums -eq $expected ] ||
7018 error "'$cmd' wrong: found $nums, expected $expected"
7021 cmd="$LFS find -size -5 -type f -lazy $dir"
7022 nums=$($cmd | wc -l)
7023 [ $nums -eq $expected ] ||
7024 error "'$cmd' wrong: found $nums, expected $expected"
7025 cmd="$LFS find -size -5 -type f $dir"
7026 nums=$($cmd | wc -l)
7027 [ $nums -eq $expected ] ||
7028 error "'$cmd' wrong: found $nums, expected $expected"
7030 run_test 56r "check lfs find -size works"
7037 cancel_lru_locks $OSC
7039 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
7040 local nums=$($cmd | wc -l)
7042 [ $nums -eq $expected ] ||
7043 error "'$cmd' wrong: found $nums, expected $expected"
7045 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
7047 if (( rpcs_before + glimpses != rpcs_after )); then
7048 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
7049 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
7051 if [[ $glimpses == 0 ]]; then
7052 error "'$cmd' should not send glimpse RPCs to OST"
7054 error "'$cmd' should send $glimpses glimpse RPCs to OST"
7060 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
7061 skip "MDS < 2.12.58 doesn't return LSOM data"
7062 local dir=$DIR/$tdir
7063 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
7065 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
7067 # statahead_agl may cause extra glimpse which confuses results. LU-13017
7068 $LCTL set_param -n llite.*.statahead_agl=0
7069 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
7071 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7072 # open and close all files to ensure LSOM is updated
7073 cancel_lru_locks $OSC
7074 find $dir -type f | xargs cat > /dev/null
7076 # expect_found glimpse_rpcs command_to_run
7077 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
7078 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
7079 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
7080 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
7082 echo "test" > $dir/$tfile
7083 echo "test2" > $dir/$tfile.2 && sync
7084 cancel_lru_locks $OSC
7085 cat $dir/$tfile $dir/$tfile.2 > /dev/null
7087 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
7088 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
7089 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
7090 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
7092 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
7093 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
7094 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
7095 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
7096 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
7097 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
7099 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
7102 local dir=$DIR/$tdir
7103 local tmp=$TMP/$tfile.log
7106 test_mkdir -p $dir || error "failed to mkdir $dir"
7107 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
7108 error "failed to setstripe $dir/$tfile"
7109 mdt_idx=$($LFS getdirstripe -i $dir)
7110 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
7112 stack_trap "rm -f $tmp" EXIT
7113 $LFS find --size +100K --ost 0 $dir |& tee $tmp
7114 ! grep -q obd_uuid $tmp ||
7115 error "failed to find --size +100K --ost 0 $dir"
7116 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
7117 ! grep -q obd_uuid $tmp ||
7118 error "failed to find --size +100K --mdt $mdt_idx $dir"
7120 run_test 56rb "check lfs find --size --ost/--mdt works"
7123 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
7124 local dir=$DIR/$tdir
7127 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
7128 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
7129 (( $MDSCOUNT > 2 )) &&
7130 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
7131 mkdir $dir/$tdir-{1..10}
7132 touch $dir/$tfile-{1..10}
7134 found=$($LFS find $dir --mdt-count 2 | wc -l)
7136 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
7138 found=$($LFS find $dir -T +1 | wc -l)
7139 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
7140 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
7142 found=$($LFS find $dir --mdt-hash all_char | wc -l)
7144 (( $found == $expect )) || error "found $found all_char, expect $expect"
7146 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
7147 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
7148 (( $found == $expect )) || error "found $found all_char, expect $expect"
7150 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
7152 test_56s() { # LU-611 #LU-9369
7153 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
7155 local dir=$DIR/$tdir
7156 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
7158 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7159 for i in $(seq $NUMDIRS); do
7160 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
7163 local expected=$NUMDIRS
7164 local cmd="$LFS find -c $OSTCOUNT $dir"
7165 local nums=$($cmd | wc -l)
7167 [ $nums -eq $expected ] || {
7168 $LFS getstripe -R $dir
7169 error "'$cmd' wrong: found $nums, expected $expected"
7172 expected=$((NUMDIRS + onestripe))
7173 cmd="$LFS find -stripe-count +0 -type f $dir"
7174 nums=$($cmd | wc -l)
7175 [ $nums -eq $expected ] || {
7176 $LFS getstripe -R $dir
7177 error "'$cmd' wrong: found $nums, expected $expected"
7181 cmd="$LFS find -stripe-count 1 -type f $dir"
7182 nums=$($cmd | wc -l)
7183 [ $nums -eq $expected ] || {
7184 $LFS getstripe -R $dir
7185 error "'$cmd' wrong: found $nums, expected $expected"
7188 cmd="$LFS find -stripe-count -2 -type f $dir"
7189 nums=$($cmd | wc -l)
7190 [ $nums -eq $expected ] || {
7191 $LFS getstripe -R $dir
7192 error "'$cmd' wrong: found $nums, expected $expected"
7196 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
7197 nums=$($cmd | wc -l)
7198 [ $nums -eq $expected ] || {
7199 $LFS getstripe -R $dir
7200 error "'$cmd' wrong: found $nums, expected $expected"
7203 run_test 56s "check lfs find -stripe-count works"
7205 test_56t() { # LU-611 #LU-9369
7206 local dir=$DIR/$tdir
7208 setup_56 $dir 0 $NUMDIRS
7209 for i in $(seq $NUMDIRS); do
7210 $LFS setstripe -S 8M $dir/dir$i/$tfile
7213 local expected=$NUMDIRS
7214 local cmd="$LFS find -S 8M $dir"
7215 local nums=$($cmd | wc -l)
7217 [ $nums -eq $expected ] || {
7218 $LFS getstripe -R $dir
7219 error "'$cmd' wrong: found $nums, expected $expected"
7223 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
7225 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
7227 expected=$(((NUMDIRS + 1) * NUMFILES))
7228 cmd="$LFS find -stripe-size 512k -type f $dir"
7229 nums=$($cmd | wc -l)
7230 [ $nums -eq $expected ] ||
7231 error "'$cmd' wrong: found $nums, expected $expected"
7233 cmd="$LFS find -stripe-size +320k -type f $dir"
7234 nums=$($cmd | wc -l)
7235 [ $nums -eq $expected ] ||
7236 error "'$cmd' wrong: found $nums, expected $expected"
7238 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
7239 cmd="$LFS find -stripe-size +200k -type f $dir"
7240 nums=$($cmd | wc -l)
7241 [ $nums -eq $expected ] ||
7242 error "'$cmd' wrong: found $nums, expected $expected"
7244 cmd="$LFS find -stripe-size -640k -type f $dir"
7245 nums=$($cmd | wc -l)
7246 [ $nums -eq $expected ] ||
7247 error "'$cmd' wrong: found $nums, expected $expected"
7250 cmd="$LFS find -stripe-size 256k -type f $dir"
7251 nums=$($cmd | wc -l)
7252 [ $nums -eq $expected ] ||
7253 error "'$cmd' wrong: found $nums, expected $expected"
7255 cmd="$LFS find -stripe-size -320k -type f $dir"
7256 nums=$($cmd | wc -l)
7257 [ $nums -eq $expected ] ||
7258 error "'$cmd' wrong: found $nums, expected $expected"
7261 cmd="$LFS find -stripe-size 1024k -type f $dir"
7262 nums=$($cmd | wc -l)
7263 [ $nums -eq $expected ] ||
7264 error "'$cmd' wrong: found $nums, expected $expected"
7266 run_test 56t "check lfs find -stripe-size works"
7268 test_56u() { # LU-611
7269 local dir=$DIR/$tdir
7271 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
7273 if [[ $OSTCOUNT -gt 1 ]]; then
7274 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
7280 local expected=$(((NUMDIRS + 1) * NUMFILES))
7281 local cmd="$LFS find -stripe-index 0 -type f $dir"
7282 local nums=$($cmd | wc -l)
7284 [ $nums -eq $expected ] ||
7285 error "'$cmd' wrong: found $nums, expected $expected"
7288 cmd="$LFS find -stripe-index 1 -type f $dir"
7289 nums=$($cmd | wc -l)
7290 [ $nums -eq $expected ] ||
7291 error "'$cmd' wrong: found $nums, expected $expected"
7293 cmd="$LFS find ! -stripe-index 0 -type f $dir"
7294 nums=$($cmd | wc -l)
7295 [ $nums -eq $expected ] ||
7296 error "'$cmd' wrong: found $nums, expected $expected"
7299 # This should produce an error and not return any files
7300 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
7301 nums=$($cmd 2>/dev/null | wc -l)
7302 [ $nums -eq $expected ] ||
7303 error "'$cmd' wrong: found $nums, expected $expected"
7305 if [[ $OSTCOUNT -gt 1 ]]; then
7306 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
7307 cmd="$LFS find -stripe-index 0,1 -type f $dir"
7308 nums=$($cmd | wc -l)
7309 [ $nums -eq $expected ] ||
7310 error "'$cmd' wrong: found $nums, expected $expected"
7313 run_test 56u "check lfs find -stripe-index works"
7317 local dir=$DIR/$tdir
7319 setup_56 $dir $NUMFILES $NUMDIRS
7321 UUID=$(mdtuuid_from_index $mdt_idx $dir)
7322 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
7324 for file in $($LFS find -m $UUID $dir); do
7325 file_midx=$($LFS getstripe -m $file)
7326 [ $file_midx -eq $mdt_idx ] ||
7327 error "lfs find -m $UUID != getstripe -m $file_midx"
7330 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
7333 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
7334 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7336 local dir=$DIR/$tdir
7338 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
7340 local stripe_size=$($LFS getstripe -S -d $dir) ||
7341 error "$LFS getstripe -S -d $dir failed"
7342 stripe_size=${stripe_size%% *}
7344 local file_size=$((stripe_size * OSTCOUNT))
7345 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
7346 local required_space=$((file_num * file_size))
7347 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
7349 (( free_space >= required_space / 1024 )) ||
7350 skip_env "need $required_space, have $free_space kbytes"
7353 local dd_count=$((file_size / dd_bs))
7355 # write data into the files
7360 for ((i = 1; i <= NUMFILES; i++ )); do
7362 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7363 error "write data into $file failed"
7365 for ((i = 1; i <= NUMDIRS; i++ )); do
7366 for ((j = 1; j <= NUMFILES; j++ )); do
7367 file=$dir/dir$i/file$j
7368 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7369 error "write data into $file failed"
7373 # $LFS_MIGRATE will fail if hard link migration is unsupported
7374 if (( MDS1_VERSION > $(version_code 2.5.55) )); then
7375 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
7376 error "creating links to $dir/dir1/file1 failed"
7381 (( OSTCOUNT <= 1 )) || expected=$((OSTCOUNT - 1))
7384 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
7387 eval $cmd || error "$cmd failed"
7389 check_stripe_count $dir/file1 $expected
7391 if (( $MDS1_VERSION >= $(version_code 2.6.90) )); then
7392 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
7393 # OST 1 if it is on OST 0. This file is small enough to
7394 # be on only one stripe.
7395 file=$dir/migr_1_ost
7396 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
7397 error "write data into $file failed"
7398 local obdidx=$($LFS getstripe -i $file)
7399 local oldmd5=$(md5sum $file)
7402 (( obdidx != 0 )) || newobdidx=1
7403 cmd="$LFS migrate -i $newobdidx $file"
7405 eval $cmd || error "$cmd failed"
7407 local realobdix=$($LFS getstripe -i $file)
7408 local newmd5=$(md5sum $file)
7410 (( $newobdidx == $realobdix )) ||
7411 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
7412 [[ "$oldmd5" == "$newmd5" ]] ||
7413 error "md5sum differ: $oldmd5, $newmd5"
7417 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7419 eval $cmd || error "$cmd failed"
7421 for (( j = 1; j <= NUMFILES; j++ )); do
7422 check_stripe_count $dir/dir1/file$j $expected
7425 # lfs_migrate works with lfs find
7426 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7427 $LFS_MIGRATE -y -c $expected"
7429 eval $cmd || error "$cmd failed"
7431 for (( i = 2; i <= NUMFILES; i++ )); do
7432 check_stripe_count $dir/file$i $expected
7434 for (( i = 2; i <= NUMDIRS; i++ )); do
7435 for (( j = 1; j <= NUMFILES; j++ )); do
7436 check_stripe_count $dir/dir$i/file$j $expected
7440 run_test 56wa "check lfs_migrate -c stripe_count works"
7443 local file1=$DIR/$tdir/file1
7444 local create_pool=false
7445 local initial_pool=$($LFS getstripe -p $DIR)
7449 echo -n "Creating test dir..."
7450 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7453 echo -n "Creating test file..."
7454 touch $file1 || error "cannot create file"
7457 echo -n "Detecting existing pools..."
7458 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7460 if [ ${#pool_list[@]} -gt 0 ]; then
7461 echo "${pool_list[@]}"
7462 for thispool in "${pool_list[@]}"; do
7463 if [[ -z "$initial_pool" ||
7464 "$initial_pool" != "$thispool" ]]; then
7466 echo "Using existing pool '$pool'"
7471 echo "none detected."
7473 if [ -z "$pool" ]; then
7474 pool=${POOL:-testpool}
7475 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7476 echo -n "Creating pool '$pool'..."
7478 pool_add $pool &> /dev/null ||
7479 error "pool_add failed"
7482 echo -n "Adding target to pool..."
7483 pool_add_targets $pool 0 0 1 &> /dev/null ||
7484 error "pool_add_targets failed"
7488 echo -n "Setting pool using -p option..."
7489 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7490 error "migrate failed rc = $?"
7493 echo -n "Verifying test file is in pool after migrating..."
7494 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7495 error "file was not migrated to pool $pool"
7498 echo -n "Removing test file from pool '$pool'..."
7499 # "lfs migrate $file" won't remove the file from the pool
7500 # until some striping information is changed.
7501 $LFS migrate -c 1 $file1 &> /dev/null ||
7502 error "cannot remove from pool"
7503 [ "$($LFS getstripe -p $file1)" ] &&
7504 error "pool still set"
7507 echo -n "Setting pool using --pool option..."
7508 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7509 error "migrate failed rc = $?"
7514 if $create_pool; then
7515 destroy_test_pools 2> /dev/null ||
7516 error "destroy test pools failed"
7519 run_test 56wb "check lfs_migrate pool support"
7522 local file1="$DIR/$tdir/$tfile"
7532 echo -n "Creating test dir..."
7533 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7534 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7535 error "cannot set stripe by '-S 1M -c 1'"
7538 echo -n "Setting initial stripe for test file..."
7539 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7540 error "cannot set stripe"
7541 cur_ssize=$($LFS getstripe -S "$file1")
7542 (( cur_ssize == 524288 )) || error "setstripe -S $cur_ssize != 524288"
7545 dd if=/dev/urandom of=$file1 bs=1M count=12 || error "dd $file1 failed"
7546 stack_trap "rm -f $file1"
7547 md5="$(md5sum $file1)"
7549 # File currently set to -S 512K -c 1
7551 # Ensure -c and -S options are rejected when -R is set
7552 echo -n "Verifying incompatible options are detected..."
7553 $LFS_MIGRATE -R -c 1 "$file1" &&
7554 error "incompatible -R and -c options not detected"
7555 $LFS_MIGRATE -R -S 1M "$file1" &&
7556 error "incompatible -R and -S options not detected"
7557 $LFS_MIGRATE -R -p pool "$file1" &&
7558 error "incompatible -R and -p options not detected"
7559 $LFS_MIGRATE -R -E eof -c 1 "$file1" &&
7560 error "incompatible -R and -E options not detected"
7561 $LFS_MIGRATE -R -A "$file1" &&
7562 error "incompatible -R and -A options not detected"
7563 $LFS_MIGRATE -A -c 1 "$file1" &&
7564 error "incompatible -A and -c options not detected"
7565 $LFS_MIGRATE -A -S 1M "$file1" &&
7566 error "incompatible -A and -S options not detected"
7567 $LFS_MIGRATE -A -p pool "$file1" &&
7568 error "incompatible -A and -p options not detected"
7569 $LFS_MIGRATE -A -E eof -c 1 "$file1" &&
7570 error "incompatible -A and -E options not detected"
7573 # Ensure unrecognized options are passed through to 'lfs migrate'
7574 echo -n "Verifying -S option is passed through to lfs migrate..."
7575 $LFS_MIGRATE -y -S 1M "$file1" || error "migration failed"
7576 cur_ssize=$($LFS getstripe -S "$file1")
7577 (( cur_ssize == 1048576 )) || error "migrate -S $cur_ssize != 1048576"
7578 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (1)"
7581 # File currently set to -S 1M -c 1
7583 # Ensure long options are supported
7584 echo -n "Verifying long options supported..."
7585 $LFS_MIGRATE --non-block "$file1" ||
7586 error "long option without argument not supported"
7587 $LFS_MIGRATE --stripe-size 512K "$file1" ||
7588 error "long option with argument not supported"
7589 cur_ssize=$($LFS getstripe -S "$file1")
7590 (( cur_ssize == 524288 )) ||
7591 error "migrate --stripe-size $cur_ssize != 524288"
7592 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (2)"
7595 # File currently set to -S 512K -c 1
7597 if (( OSTCOUNT > 1 )); then
7598 echo -n "Verifying explicit stripe count can be set..."
7599 $LFS_MIGRATE -c 2 "$file1" || error "migrate failed"
7600 cur_scount=$($LFS getstripe -c "$file1")
7601 (( cur_scount == 2 )) || error "migrate -c $cur_scount != 2"
7602 [[ "$(md5sum $file1)" == "$md5" ]] ||
7603 error "file data has changed (3)"
7607 # File currently set to -S 512K -c 1 or -S 512K -c 2
7609 # Ensure parent striping is used if -R is set, and no stripe
7610 # count or size is specified
7611 echo -n "Setting stripe for parent directory..."
7612 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7613 error "cannot set stripe '-S 2M -c 1'"
7614 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (4)"
7617 echo -n "Verifying restripe option uses parent stripe settings..."
7618 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7619 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7620 $LFS_MIGRATE -R "$file1" || error "migrate failed"
7621 cur_ssize=$($LFS getstripe -S "$file1")
7622 (( cur_ssize == parent_ssize )) ||
7623 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7624 cur_scount=$($LFS getstripe -c "$file1")
7625 (( cur_scount == parent_scount )) ||
7626 error "migrate -R stripe_count $cur_scount != $parent_scount"
7627 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (5)"
7630 # File currently set to -S 1M -c 1
7632 # Ensure striping is preserved if -R is not set, and no stripe
7633 # count or size is specified
7634 echo -n "Verifying striping size preserved when not specified..."
7635 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7636 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7637 error "cannot set stripe on parent directory"
7638 $LFS_MIGRATE "$file1" || error "migrate failed"
7639 cur_ssize=$($LFS getstripe -S "$file1")
7640 (( cur_ssize == orig_ssize )) ||
7641 error "migrate by default $cur_ssize != $orig_ssize"
7642 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (6)"
7645 # Ensure file name properly detected when final option has no argument
7646 echo -n "Verifying file name properly detected..."
7647 $LFS_MIGRATE "$file1" ||
7648 error "file name interpreted as option argument"
7649 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (7)"
7652 # Ensure PFL arguments are passed through properly
7653 echo -n "Verifying PFL options passed through..."
7654 new_scount=$(((OSTCOUNT + 1) / 2))
7655 $LFS_MIGRATE -E 1M -c 1 -E 16M -c $new_scount -E eof -c -1 "$file1" ||
7656 error "migrate PFL arguments failed"
7657 cur_comp=$($LFS getstripe --comp-count $file1)
7658 (( cur_comp == 3 )) || error "component count '$cur_comp' != 3"
7659 cur_scount=$($LFS getstripe --stripe-count $file1)
7660 (( cur_scount == new_scount)) ||
7661 error "PFL stripe count $cur_scount != $new_scount"
7662 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (8)"
7665 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7668 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
7670 local file1=$DIR/$tdir/$tfile
7672 echo -n "Creating test dir..."
7673 test_mkdir $DIR/$tdir || error "cannot create dir"
7676 echo -n "Creating test file..."
7677 echo "$tfile" > $file1
7680 # Ensure 'lfs migrate' will fail by using a non-existent option,
7681 # and make sure rsync is not called to recover
7682 echo -n "Make sure --no-rsync option works..."
7683 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7684 grep -q 'refusing to fall back to rsync' ||
7685 error "rsync was called with --no-rsync set"
7688 # Ensure rsync is called without trying 'lfs migrate' first
7689 echo -n "Make sure --rsync option works..."
7690 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7691 grep -q 'falling back to rsync' &&
7692 error "lfs migrate was called with --rsync set"
7695 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7701 test_mkdir $td || error "cannot create $td"
7702 touch $tf || error "cannot touch $tf"
7704 echo -n "Make sure --non-direct|-D works..."
7705 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7706 grep -q "lfs migrate --non-direct" ||
7707 error "--non-direct option cannot work correctly"
7708 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7709 grep -q "lfs migrate -D" ||
7710 error "-D option cannot work correctly"
7713 run_test 56we "check lfs_migrate --non-direct|-D support"
7716 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7717 check_swap_layouts_support
7719 local dir=$DIR/$tdir
7720 local ref1=/etc/passwd
7721 local file1=$dir/file1
7723 test_mkdir $dir || error "creating dir $dir"
7724 $LFS setstripe -c 2 $file1
7726 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7727 stripe=$($LFS getstripe -c $file1)
7728 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7729 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7734 run_test 56x "lfs migration support"
7737 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7738 check_swap_layouts_support
7740 local dir=$DIR/$tdir/$testnum
7744 local ref1=/etc/passwd
7745 local file1=$dir/file1
7747 $LFS setstripe -c 2 $file1
7749 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7751 local stripe=$($LFS getstripe -c $file1)
7753 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7754 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7759 run_test 56xa "lfs migration --block support"
7761 check_migrate_links() {
7762 [[ "$1" == "--rsync" ]] && local opts="--rsync -y" && shift
7764 local file1="$dir/file1"
7768 local total_count=$(($begin + $count - 1))
7769 local symlink_count=10
7772 if [ ! -f "$file1" ]; then
7773 echo -n "creating initial file..."
7774 $LFS setstripe -c 1 -S "512k" "$file1" ||
7775 error "cannot setstripe initial file"
7778 echo -n "creating symlinks..."
7779 for s in $(seq 1 $symlink_count); do
7780 ln -s "$file1" "$dir/slink$s" ||
7781 error "cannot create symlinks"
7785 echo -n "creating nonlinked files..."
7786 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7787 error "cannot create nonlinked files"
7792 if [ ! -f "$dir/file$total_count" ]; then
7793 echo -n "creating hard links $begin:$total_count..."
7794 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7795 /dev/null || error "cannot create hard links"
7799 echo -n "checking number of hard links listed in xattrs..."
7800 local fid=$($LFS getstripe -F "$file1")
7801 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7804 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7805 skip "hard link list has unexpected size, skipping test"
7807 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7808 error "link names should exceed xattrs size"
7811 echo -n "migrating files..."
7812 local migrate_out=$($runas $LFS_MIGRATE $opts -S '1m' $dir)
7814 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7817 # make sure all links have been properly migrated
7818 echo -n "verifying files..."
7819 fid=$($LFS getstripe -F "$file1") ||
7820 error "cannot get fid for file $file1"
7821 for i in $(seq 2 $total_count); do
7822 local fid2=$($LFS getstripe -F $dir/file$i)
7824 [ "$fid2" == "$fid" ] ||
7825 error "migrated hard link has mismatched FID"
7828 # make sure hard links were properly detected, and migration was
7829 # performed only once for the entire link set; nonlinked files should
7831 local actual=$(grep -c 'done' <<< "$migrate_out")
7832 local expected=$(($uniq_count + 1))
7834 [ "$actual" -eq "$expected" ] ||
7835 error "hard links individually migrated ($actual != $expected)"
7837 # make sure the correct number of hard links are present
7838 local hardlinks=$(stat -c '%h' "$file1")
7840 [ $hardlinks -eq $total_count ] ||
7841 error "num hard links $hardlinks != $total_count"
7848 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7849 skip "Need MDS version at least 2.10.55"
7851 local dir="$DIR/$tdir"
7853 test_mkdir "$dir" || error "cannot create dir $dir"
7855 echo "testing lfs migrate mode when all links fit within xattrs"
7856 check_migrate_links "$dir" 2 99
7858 echo "testing rsync mode when all links fit within xattrs"
7859 check_migrate_links --rsync "$dir" 2 99
7861 echo "testing lfs migrate mode when all links do not fit within xattrs"
7862 check_migrate_links "$dir" 101 100
7864 echo "testing rsync mode when all links do not fit within xattrs"
7865 check_migrate_links --rsync "$dir" 101 100
7867 chown -R $RUNAS_ID $dir
7868 echo "testing non-root lfs migrate mode when not all links are in xattr"
7869 check_migrate_links "$dir" 101 100 "$RUNAS"
7874 run_test 56xb "lfs migration hard link support"
7877 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7879 local dir="$DIR/$tdir"
7881 test_mkdir "$dir" || error "cannot create dir $dir"
7883 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7884 echo -n "Setting initial stripe for 20MB test file..."
7885 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7886 error "cannot setstripe 20MB file"
7888 echo -n "Sizing 20MB test file..."
7889 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
7891 echo -n "Verifying small file autostripe count is 1..."
7892 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
7893 error "cannot migrate 20MB file"
7894 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7895 error "cannot get stripe for $dir/20mb"
7896 [ $stripe_count -eq 1 ] ||
7897 error "unexpected stripe count $stripe_count for 20MB file"
7901 # Test 2: File is small enough to fit within the available space on
7902 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7903 # have at least an additional 1KB for each desired stripe for test 3
7904 echo -n "Setting stripe for 1GB test file..."
7905 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7907 echo -n "Sizing 1GB test file..."
7908 # File size is 1GB + 3KB
7909 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7912 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7913 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7914 if (( avail > 524288 * OSTCOUNT )); then
7915 echo -n "Migrating 1GB file..."
7916 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7917 error "cannot migrate 1GB file"
7919 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7920 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7921 error "cannot getstripe for 1GB file"
7922 [ $stripe_count -eq 2 ] ||
7923 error "unexpected stripe count $stripe_count != 2"
7927 # Test 3: File is too large to fit within the available space on
7928 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7929 if [ $OSTCOUNT -ge 3 ]; then
7930 # The required available space is calculated as
7931 # file size (1GB + 3KB) / OST count (3).
7932 local kb_per_ost=349526
7934 echo -n "Migrating 1GB file with limit..."
7935 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7936 error "cannot migrate 1GB file with limit"
7939 stripe_count=$($LFS getstripe -c "$dir/1gb")
7940 echo -n "Verifying 1GB autostripe count with limited space..."
7941 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7942 error "unexpected stripe count $stripe_count (min 3)"
7949 run_test 56xc "lfs migration autostripe"
7952 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7954 local dir=$DIR/$tdir
7955 local f_mgrt=$dir/$tfile.mgrt
7956 local f_yaml=$dir/$tfile.yaml
7957 local f_copy=$dir/$tfile.copy
7958 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7959 local layout_copy="-c 2 -S 2M -i 1"
7960 local yamlfile=$dir/yamlfile
7961 local layout_before;
7964 test_mkdir "$dir" || error "cannot create dir $dir"
7965 $LFS setstripe $layout_yaml $f_yaml ||
7966 error "cannot setstripe $f_yaml with layout $layout_yaml"
7967 $LFS getstripe --yaml $f_yaml > $yamlfile
7968 $LFS setstripe $layout_copy $f_copy ||
7969 error "cannot setstripe $f_copy with layout $layout_copy"
7971 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7973 # 1. test option --yaml
7974 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7975 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7976 layout_before=$(get_layout_param $f_yaml)
7977 layout_after=$(get_layout_param $f_mgrt)
7978 [ "$layout_after" == "$layout_before" ] ||
7979 error "lfs_migrate --yaml: $layout_after != $layout_before"
7981 # 2. test option --copy
7982 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7983 error "cannot migrate $f_mgrt with --copy $f_copy"
7984 layout_before=$(SKIP_INDEX=yes get_layout_param $f_copy)
7985 layout_after=$(SKIP_INDEX=yes get_layout_param $f_mgrt)
7986 [ "$layout_after" == "$layout_before" ] ||
7987 error "lfs_migrate --copy: $layout_after != $layout_before"
7989 run_test 56xd "check lfs_migrate --yaml and --copy support"
7992 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7994 local dir=$DIR/$tdir
7995 local f_comp=$dir/$tfile
7996 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7997 local layout_before=""
7998 local layout_after=""
8000 test_mkdir "$dir" || error "cannot create dir $dir"
8001 $LFS setstripe $layout $f_comp ||
8002 error "cannot setstripe $f_comp with layout $layout"
8003 layout_before=$(SKIP_INDEX=yes get_layout_param $f_comp)
8004 dd if=/dev/zero of=$f_comp bs=1M count=4
8006 # 1. migrate a comp layout file by lfs_migrate
8007 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
8008 layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
8009 [ "$layout_before" == "$layout_after" ] ||
8010 error "lfs_migrate: $layout_before != $layout_after"
8012 # 2. migrate a comp layout file by lfs migrate
8013 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
8014 layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
8015 [ "$layout_before" == "$layout_after" ] ||
8016 error "lfs migrate: $layout_before != $layout_after"
8018 run_test 56xe "migrate a composite layout file"
8021 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
8023 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
8024 skip "Need server version at least 2.13.53"
8026 local dir=$DIR/$tdir
8027 local f_comp=$dir/$tfile
8028 local layout="-E 1M -c1 -E -1 -c2"
8032 test_mkdir "$dir" || error "cannot create dir $dir"
8033 $LFS setstripe $layout $f_comp ||
8034 error "cannot setstripe $f_comp with layout $layout"
8035 fid_before=$($LFS getstripe --fid $f_comp)
8036 dd if=/dev/zero of=$f_comp bs=1M count=4
8038 # 1. migrate a comp layout file to a comp layout
8039 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
8040 fid_after=$($LFS getstripe --fid $f_comp)
8041 [ "$fid_before" == "$fid_after" ] ||
8042 error "comp-to-comp migrate: $fid_before != $fid_after"
8044 # 2. migrate a comp layout file to a plain layout
8045 $LFS migrate -c2 $f_comp ||
8046 error "cannot migrate $f_comp by lfs migrate"
8047 fid_after=$($LFS getstripe --fid $f_comp)
8048 [ "$fid_before" == "$fid_after" ] ||
8049 error "comp-to-plain migrate: $fid_before != $fid_after"
8051 # 3. migrate a plain layout file to a comp layout
8052 $LFS migrate $layout $f_comp ||
8053 error "cannot migrate $f_comp by lfs migrate"
8054 fid_after=$($LFS getstripe --fid $f_comp)
8055 [ "$fid_before" == "$fid_after" ] ||
8056 error "plain-to-comp migrate: $fid_before != $fid_after"
8058 run_test 56xf "FID is not lost during migration of a composite layout file"
8060 check_file_ost_range() {
8067 file_range=($($LFS getstripe -y "$file" |
8068 awk '/l_ost_idx:/ { print $NF }'))
8070 if [[ "${#file_range[@]}" = 0 ]]; then
8071 echo "No osts found for $file"
8075 for idx in "${file_range[@]}"; do
8076 [[ " $range " =~ " $idx " ]] ||
8084 local stripe_opt="$1"
8087 local pool_ostidx="$(seq $* | tr '\n' ' ')"
8089 $LFS migrate $stripe_opt -p $pool $DIR/$tfile ||
8090 error "Fail to migrate $tfile on $pool"
8091 [[ "$($LFS getstripe -p $DIR/$tfile)" = "$pool" ]] ||
8092 error "$tfile is not in pool $pool"
8093 check_file_ost_range "$DIR/$tfile" $pool_ostidx ||
8094 error "$tfile osts mismatch with pool $pool (osts $pool_ostidx)"
8098 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
8099 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
8100 [[ $MDS1_VERSION -gt $(version_code 2.14.52) ]] ||
8101 skip "Need MDS version newer than 2.14.52"
8103 local -a pool_names=("${TESTNAME}_0" "${TESTNAME}_1" "${TESTNAME}_2")
8104 local -a pool_ranges=("0 0" "1 1" "0 1")
8107 for i in "${!pool_names[@]}"; do
8108 pool_add ${pool_names[$i]} ||
8109 error "pool_add failed (pool: ${pool_names[$i]})"
8110 pool_add_targets ${pool_names[$i]} ${pool_ranges[$i]} ||
8111 error "pool_add_targets failed (pool: ${pool_names[$i]})"
8114 # init the file to migrate
8115 $LFS setstripe -c1 -i1 $DIR/$tfile ||
8116 error "Unable to create $tfile on OST1"
8117 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=4 status=none ||
8118 error "Unable to write on $tfile"
8120 echo "1. migrate $tfile on pool ${pool_names[0]}"
8121 sub_test_56xg "-c-1" "${pool_names[0]}" ${pool_ranges[0]}
8123 echo "2. migrate $tfile on pool ${pool_names[2]}"
8124 sub_test_56xg "-c-1 -S2M" "${pool_names[2]}" ${pool_ranges[2]}
8126 echo "3. migrate $tfile on pool ${pool_names[1]}"
8127 sub_test_56xg "-n -c-1" "${pool_names[1]}" ${pool_ranges[1]}
8129 echo "4. migrate $tfile on pool ${pool_names[2]} with default stripe parameters"
8130 sub_test_56xg "" "${pool_names[2]}" ${pool_ranges[2]}
8134 destroy_test_pools ||
8135 error "pool_destroy failed"
8137 run_test 56xg "lfs migrate pool support"
8140 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8143 local file1=$DIR/$tfile
8144 local tmp1=$TMP/$tfile.tmp
8146 $LFS setstripe -c 2 $file1
8148 stack_trap "rm -f $file1 $tmp1"
8149 dd if=/dev/urandom of=$tmp1 bs=1M count=$size_mb ||
8150 error "error creating $tmp1"
8154 local start=$SECONDS
8156 $LFS migrate --stats --stats-interval=1 -W 1M -c 1 $file1 ||
8157 error "migrate failed rc = $?"
8159 local elapsed=$((SECONDS - start))
8161 # with 1MB/s, elapsed should equal size_mb
8162 (( elapsed >= size_mb * 95 / 100 )) ||
8163 error "'lfs migrate -W' too fast ($elapsed < 0.95 * $size_mb)?"
8165 (( elapsed <= size_mb * 120 / 100 )) ||
8166 error_not_in_vm "'lfs migrate -W' slow ($elapsed > 1.2 * $size_mb)"
8168 (( elapsed <= size_mb * 150 / 100 )) ||
8169 error "'lfs migrate -W' too slow in VM ($elapsed > 2 * $size_mb 2)"
8171 stripe=$($LFS getstripe -c $file1)
8172 (( $stripe == 1 )) || error "stripe of $file1 is $stripe != 1"
8173 cmp $file1 $tmp1 || error "content mismatch $file1 differs from $tmp1"
8175 # Clean up file (since it is multiple MB)
8178 run_test 56xh "lfs migrate bandwidth limitation support"
8181 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8182 verify_yaml_available || skip_env "YAML verification not installed"
8185 local file1=$DIR/$tfile.1
8186 local file2=$DIR/$tfile.2
8187 local file3=$DIR/$tfile.3
8188 local output_file=$DIR/$tfile.out
8189 local tmp1=$TMP/$tfile.tmp
8191 $LFS setstripe -c 2 $file1
8192 $LFS setstripe -c 2 $file2
8193 $LFS setstripe -c 2 $file3
8195 stack_trap "rm -f $file1 $file2 $file3 $tmp1 $output_file"
8196 dd if=/dev/urandom of=$tmp1 bs=1M count=$size_mb ||
8197 error "error creating $tmp1"
8203 $LFS migrate --stats --stats-interval=1 \
8204 -c 1 $file1 $file2 $file3 1> $output_file ||
8205 error "migrate failed rc = $?"
8208 cat $output_file | verify_yaml || error "rename_stats is not valid YAML"
8210 # Clean up file (since it is multiple MB)
8211 rm -f $file1 $file2 $file3 $tmp1 $output_file
8213 run_test 56xi "lfs migrate stats support"
8216 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
8217 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
8220 local dir=$DIR/$tdir
8224 test_mkdir -p $dir || error "creating dir $dir"
8225 touch $f1 || error "creating std file $f1"
8226 $MULTIOP $f2 H2c || error "creating released file $f2"
8228 # a directory can be raid0, so ask only for files
8229 res=$($LFS find $dir -L raid0 -type f | wc -l)
8230 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
8232 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
8233 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
8235 # only files can be released, so no need to force file search
8236 res=$($LFS find $dir -L released)
8237 [[ $res == $f2 ]] || error "search released: found $res != $f2"
8239 res=$($LFS find $dir -type f \! -L released)
8240 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
8242 run_test 56y "lfs find -L raid0|released"
8244 test_56z() { # LU-4824
8245 # This checks to make sure 'lfs find' continues after errors
8246 # There are two classes of errors that should be caught:
8247 # - If multiple paths are provided, all should be searched even if one
8249 # - If errors are encountered during the search, it should not terminate
8251 local dir=$DIR/$tdir
8255 for i in d{0..9}; do
8257 touch $dir/$i/$tfile
8259 $LFS find $DIR/non_existent_dir $dir &&
8260 error "$LFS find did not return an error"
8261 # Make a directory unsearchable. This should NOT be the last entry in
8262 # directory order. Arbitrarily pick the 6th entry
8263 chmod 700 $($LFS find $dir -type d | sed '6!d')
8265 $RUNAS $LFS find $DIR/non_existent $dir
8266 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
8268 # The user should be able to see 10 directories and 9 files
8269 (( count == 19 )) ||
8270 error "$LFS find found $count != 19 entries after error"
8272 run_test 56z "lfs find should continue after an error"
8274 test_56aa() { # LU-5937
8275 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
8277 local dir=$DIR/$tdir
8280 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
8282 createmany -o $dir/striped_dir/${tfile}- 1024
8283 local dirs=$($LFS find --size +8k $dir/)
8285 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
8287 run_test 56aa "lfs find --size under striped dir"
8289 test_56ab() { # LU-10705
8290 test_mkdir $DIR/$tdir
8291 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
8292 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
8293 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
8294 # Flush writes to ensure valid blocks. Need to be more thorough for
8295 # ZFS, since blocks are not allocated/returned to client immediately.
8297 wait_zfs_commit ost1 2
8298 cancel_lru_locks osc
8301 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
8303 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
8305 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
8306 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
8308 rm -f $DIR/$tdir/$tfile.[123]
8310 run_test 56ab "lfs find --blocks"
8314 local dir="$DIR/$tdir"
8315 local perms=(001 002 003 004 005 006 007
8316 010 020 030 040 050 060 070
8317 100 200 300 400 500 600 700
8318 111 222 333 444 555 666 777)
8319 local perm_minus=(8 8 4 8 4 4 2
8323 local perm_slash=(8 8 12 8 12 12 14
8326 16 16 24 16 24 24 28)
8329 for perm in ${perms[*]}; do
8330 touch "$dir/$tfile.$perm"
8331 chmod $perm "$dir/$tfile.$perm"
8334 for ((i = 0; i < ${#perms[*]}; i++)); do
8335 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
8337 error "lfs find -perm ${perms[i]}:"\
8340 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
8341 (( $num == ${perm_minus[i]} )) ||
8342 error "lfs find -perm -${perms[i]}:"\
8343 "$num != ${perm_minus[i]}"
8345 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
8346 (( $num == ${perm_slash[i]} )) ||
8347 error "lfs find -perm /${perms[i]}:"\
8348 "$num != ${perm_slash[i]}"
8351 run_test 56aca "check lfs find -perm with octal representation"
8354 local dir=$DIR/$tdir
8355 # p is the permission of write and execute for user, group and other
8356 # without the umask. It is used to test +wx.
8357 local p=$(printf "%o" "$((0333 & ~$(umask)))")
8358 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
8359 local symbolic=(+t a+t u+t g+t o+t
8365 o=r,ug+o,u+w u=r,a+u,u+w
8366 g=r,ugo=g,u+w u+x,+X +X
8367 u+x,u+X u+X u+x,g+X o+r,+X
8371 for perm in ${perms[*]}; do
8372 touch "$dir/$tfile.$perm"
8373 chmod $perm "$dir/$tfile.$perm"
8376 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
8377 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
8380 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
8383 run_test 56acb "check lfs find -perm with symbolic representation"
8386 local dir=$DIR/$tdir
8387 local tests="17777 787 789 abcd
8388 ug=uu ug=a ug=gu uo=ou urw
8392 for err in $tests; do
8393 if $LFS find $dir -perm $err 2>/dev/null; then
8394 error "lfs find -perm $err: parsing should have failed"
8398 run_test 56acc "check parsing error for lfs find -perm"
8401 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
8402 skip "Need MDS version at least 2.10.50"
8404 # Create composite files with one component
8405 local dir=$DIR/$tdir
8407 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
8408 # Create composite files with three components
8409 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
8410 # Create non-composite files
8411 createmany -o $dir/${tfile}- 10
8413 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
8415 [[ $nfiles == 10 ]] ||
8416 error "lfs find -E 1M found $nfiles != 10 files"
8418 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
8419 [[ $nfiles == 25 ]] ||
8420 error "lfs find ! -E 1M found $nfiles != 25 files"
8422 # All files have a component that starts at 0
8423 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
8424 [[ $nfiles == 35 ]] ||
8425 error "lfs find --component-start 0 - $nfiles != 35 files"
8427 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
8428 [[ $nfiles == 15 ]] ||
8429 error "lfs find --component-start 2M - $nfiles != 15 files"
8431 # All files created here have a componenet that does not starts at 2M
8432 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
8433 [[ $nfiles == 35 ]] ||
8434 error "lfs find ! --component-start 2M - $nfiles != 35 files"
8436 # Find files with a specified number of components
8437 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
8438 [[ $nfiles == 15 ]] ||
8439 error "lfs find --component-count 3 - $nfiles != 15 files"
8441 # Remember non-composite files have a component count of zero
8442 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
8443 [[ $nfiles == 10 ]] ||
8444 error "lfs find --component-count 0 - $nfiles != 10 files"
8446 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
8447 [[ $nfiles == 20 ]] ||
8448 error "lfs find ! --component-count 3 - $nfiles != 20 files"
8450 # All files have a flag called "init"
8451 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
8452 [[ $nfiles == 35 ]] ||
8453 error "lfs find --component-flags init - $nfiles != 35 files"
8455 # Multi-component files will have a component not initialized
8456 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
8457 [[ $nfiles == 15 ]] ||
8458 error "lfs find !--component-flags init - $nfiles != 15 files"
8463 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
8466 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
8467 skip "Need MDS version at least 2.10.57"
8477 # create mirrored directories and mirrored files
8478 mkdir $td || error "mkdir $td failed"
8479 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
8480 createmany -o $tf- 10 || error "create $tf- failed"
8482 for i in $(seq 2); do
8484 mkdir $dir || error "mkdir $dir failed"
8485 $LFS mirror create -N$((3 + i)) $dir ||
8486 error "create mirrored dir $dir failed"
8487 createmany -o $dir/$tfile- 10 ||
8488 error "create $dir/$tfile- failed"
8491 # change the states of some mirrored files
8493 for i in $(seq 2); do
8495 for j in $(seq 4 9); do
8496 echo foo > $dir/$tfile-$j
8500 # find mirrored files with specific mirror count
8501 cmd="$LFS find --mirror-count 3 --type f $td"
8502 nfiles=$($cmd | wc -l)
8503 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
8505 cmd="$LFS find ! --mirror-count 3 --type f $td"
8506 nfiles=$($cmd | wc -l)
8507 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
8509 cmd="$LFS find --mirror-count +2 --type f $td"
8510 nfiles=$($cmd | wc -l)
8511 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8513 cmd="$LFS find --mirror-count -6 --type f $td"
8514 nfiles=$($cmd | wc -l)
8515 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8517 # find mirrored files with specific file state
8518 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
8519 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
8521 cmd="$LFS find --mirror-state=ro --type f $td"
8522 nfiles=$($cmd | wc -l)
8523 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
8525 cmd="$LFS find ! --mirror-state=ro --type f $td"
8526 nfiles=$($cmd | wc -l)
8527 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8529 cmd="$LFS find --mirror-state=wp --type f $td"
8530 nfiles=$($cmd | wc -l)
8531 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8533 cmd="$LFS find ! --mirror-state=sp --type f $td"
8534 nfiles=$($cmd | wc -l)
8535 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8537 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
8539 test_56da() { # LU-14179
8540 local path=$DIR/$tdir
8545 local longdir=$(str_repeat 'a' 255)
8547 for i in {1..15}; do
8554 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
8559 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
8562 touch $(str_repeat 'f' 255)
8564 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
8565 error "lfs find reported an error"
8569 run_test 56da "test lfs find with long paths"
8571 test_56ea() { #LU-10378
8572 local path=$DIR/$tdir
8573 local pool=$TESTNAME
8576 pool_add $pool || error "pool_add $pool failed"
8577 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8578 error "adding targets to $pool failed"
8580 # Set default pool on directory before creating file
8581 mkdir $path || error "mkdir $path failed"
8582 $LFS setstripe -p $pool $path ||
8583 error "set OST pool on $pool failed"
8584 touch $path/$tfile || error "touch $path/$tfile failed"
8586 # Compare basic file attributes from -printf and stat
8587 local attr_printf=$($LFS find $path/$tfile -printf "%A@ %T@ %C@ %U %G")
8588 local attr_stat=$(stat -c "%X %Y %Z %u %g" $path/$tfile)
8590 [[ "${attr_printf}" == "${attr_stat}" ]] ||
8591 error "Attrs from lfs find and stat don't match"
8593 # Compare Lustre attributes from lfs find and lfs getstripe
8594 local lattr_printf=$($LFS find $path/$tfile -printf "%Lc %LS %Li %Lp")
8595 local str_cnt=$($LFS getstripe --stripe-count $path/$tfile)
8596 local str_size=$($LFS getstripe --stripe-size $path/$tfile)
8597 local str_idx=$($LFS getstripe --stripe-index $path/$tfile)
8598 local fpool=$($LFS getstripe --pool $path/$tfile)
8599 local lattr_getstr="${str_cnt} ${str_size} ${str_idx} ${fpool}"
8601 [[ "${lattr_printf}" == "${lattr_getstr}" ]] ||
8602 error "Attrs from lfs find and lfs getstripe don't match"
8604 # Verify behavior for unknown escape/format sequences
8605 local esc_printf=$($LFS find $path/$tfile -printf '\\ %% \Q %Q')
8607 [[ "${esc_printf}" == '\ % \Q %Q' ]] ||
8608 error "Escape/format codes don't match"
8610 run_test 56ea "test lfs find -printf option"
8613 local dir=$DIR/$tdir
8614 local subdir_1=$dir/subdir_1
8616 test_mkdir -p $subdir_1
8617 ln -s subdir_1 $dir/link_1
8619 $LFS getstripe $dir | grep "^$dir/link_1$" -A1 ||
8620 error "symlink is not followed"
8622 $LFS getstripe --no-follow $dir |
8623 grep "^$dir/link_1 has no stripe info$" ||
8624 error "symlink should not have stripe info"
8627 ln -s testfile $dir/file_link_2
8629 $LFS getstripe $dir | grep "^$dir/file_link_2$" -A1 ||
8630 error "symlink is not followed"
8632 $LFS getstripe --no-follow $dir |
8633 grep "^$dir/file_link_2 has no stripe info$" ||
8634 error "symlink should not have stripe info"
8636 run_test 56eb "check lfs getstripe on symlink"
8639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8640 # note test will not do anything if MDS is not local
8641 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8642 skip_env "ldiskfs only test"
8644 remote_mds_nodsh && skip "remote MDS with nodsh"
8646 local MNTDEV="osd*.*MDT*.mntdev"
8647 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
8648 [ -z "$DEV" ] && error "can't access $MNTDEV"
8649 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
8650 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
8651 error "can't access $DEV"
8652 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
8653 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
8657 run_test 57a "verify MDS filesystem created with large inodes =="
8660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8661 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8662 skip_env "ldiskfs only test"
8664 remote_mds_nodsh && skip "remote MDS with nodsh"
8666 local dir=$DIR/$tdir
8669 local fileN=$dir/f$filecount
8671 rm -rf $dir || error "removing $dir"
8673 local mdtidx=$($LFS getstripe -m $dir)
8674 local mdtname=MDT$(printf %04x $mdtidx)
8675 local facet=mds$((mdtidx + 1))
8677 echo "mcreating $filecount files"
8678 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
8680 # verify that files do not have EAs yet
8681 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
8682 error "$file1 has an EA"
8683 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
8684 error "$fileN has an EA"
8688 df $dir #make sure we get new statfs data
8689 local mdsfree=$(do_facet $facet \
8690 lctl get_param -n osd*.*$mdtname.kbytesfree)
8691 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8694 echo "opening files to create objects/EAs"
8695 for file in $(seq -f $dir/f%g 1 $filecount); do
8696 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
8697 error "opening $file"
8700 # verify that files have EAs now
8701 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
8702 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
8704 sleep 1 #make sure we get new statfs data
8706 local mdsfree2=$(do_facet $facet \
8707 lctl get_param -n osd*.*$mdtname.kbytesfree)
8708 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8710 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
8711 if [ "$mdsfree" != "$mdsfree2" ]; then
8712 error "MDC before $mdcfree != after $mdcfree2"
8714 echo "MDC before $mdcfree != after $mdcfree2"
8715 echo "unable to confirm if MDS has large inodes"
8720 run_test 57b "default LOV EAs are stored inside large inodes ==="
8723 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8724 [ -z "$(which wiretest 2>/dev/null)" ] &&
8725 skip_env "could not find wiretest"
8729 run_test 58 "verify cross-platform wire constants =============="
8732 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8734 echo "touch 130 files"
8735 createmany -o $DIR/f59- 130
8737 unlinkmany $DIR/f59- 130
8739 # wait for commitment of removal
8740 wait_delete_completed
8742 run_test 59 "verify cancellation of llog records async ========="
8744 TEST60_HEAD="test_60 run $RANDOM"
8746 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8747 remote_mgs_nodsh && skip "remote MGS with nodsh"
8748 do_facet mgs "! which run-llog.sh &> /dev/null" &&
8749 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
8750 skip_env "missing subtest run-llog.sh"
8752 log "$TEST60_HEAD - from kernel mode"
8753 do_facet mgs "$LCTL dk > /dev/null"
8754 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
8755 do_facet mgs $LCTL dk > $TMP/$tfile
8757 # LU-6388: test llog_reader
8758 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
8759 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
8760 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
8761 skip_env "missing llog_reader"
8762 local fstype=$(facet_fstype mgs)
8763 [ $fstype != ldiskfs -a $fstype != zfs ] &&
8764 skip_env "Only for ldiskfs or zfs type mgs"
8766 local mntpt=$(facet_mntpt mgs)
8767 local mgsdev=$(mgsdevname 1)
8779 #get fid and record list
8780 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
8782 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
8784 #remount mgs as ldiskfs or zfs type
8785 stop mgs || error "stop mgs failed"
8786 mount_fstype mgs || error "remount mgs failed"
8787 for ((i = 0; i < ${#fid_list[@]}; i++)); do
8790 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
8791 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
8796 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
8798 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
8800 echo "obj_file is $obj_file"
8801 do_facet mgs $llog_reader $obj_file
8803 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
8804 awk '{ print $3 }' | sed -e "s/^type=//g")
8805 if [ $rec_type != $rec ]; then
8806 echo "FAILED test_60a wrong record type $rec_type," \
8812 #check obj path if record type is LLOG_LOGID_MAGIC
8813 if [ "$rec" == "1064553b" ]; then
8814 path=$(do_facet mgs $llog_reader $obj_file |
8815 grep "path=" | awk '{ print $NF }' |
8816 sed -e "s/^path=//g")
8817 if [ $obj_file != $mntpt/$path ]; then
8818 echo "FAILED test_60a wrong obj path" \
8819 "$montpt/$path, should be $obj_file"
8826 #restart mgs before "error", otherwise it will block the next test
8827 stop mgs || error "stop mgs failed"
8828 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
8829 $pass || error "test failed, see FAILED test_60a messages for specifics"
8831 run_test 60a "llog_test run from kernel module and test llog_reader"
8833 test_60b() { # bug 6411
8834 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8837 LLOG_COUNT=$(do_facet mgs dmesg |
8838 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
8839 /llog_[a-z]*.c:[0-9]/ {
8851 [[ $LLOG_COUNT -gt 120 ]] &&
8852 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
8854 run_test 60b "limit repeated messages from CERROR/CWARN"
8857 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8859 echo "create 5000 files"
8860 createmany -o $DIR/f60c- 5000
8861 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
8862 lctl set_param fail_loc=0x80000137
8863 unlinkmany $DIR/f60c- 5000
8864 lctl set_param fail_loc=0
8866 run_test 60c "unlink file when mds full"
8869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8871 SAVEPRINTK=$(lctl get_param -n printk)
8872 # verify "lctl mark" is even working"
8873 MESSAGE="test message ID $RANDOM $$"
8874 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8875 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
8877 lctl set_param printk=0 || error "set lnet.printk failed"
8878 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
8879 MESSAGE="new test message ID $RANDOM $$"
8880 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
8881 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8882 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
8884 lctl set_param -n printk="$SAVEPRINTK"
8886 run_test 60d "test printk console message masking"
8889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8890 remote_mds_nodsh && skip "remote MDS with nodsh"
8893 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
8894 do_facet mds1 lctl set_param fail_loc=0x15b
8897 run_test 60e "no space while new llog is being created"
8900 local old_path=$($LCTL get_param -n debug_path)
8902 stack_trap "$LCTL set_param debug_path=$old_path"
8903 stack_trap "rm -f $TMP/$tfile*"
8904 rm -f $TMP/$tfile* 2> /dev/null
8905 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8906 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
8907 test_mkdir $DIR/$tdir
8908 # retry in case the open is cached and not released
8909 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
8910 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
8914 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
8916 run_test 60f "change debug_path works"
8922 test_mkdir -c $MDSCOUNT $DIR/$tdir
8927 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
8928 -c $MDSCOUNT $DIR/$tdir/subdir$index \
8930 mkdir $DIR/$tdir/subdir$index 2>/dev/null
8931 rmdir $DIR/$tdir/subdir$index 2>/dev/null
8932 index=$((index + 1))
8938 for i in {0..100}; do
8939 # define OBD_FAIL_OSD_TXN_START 0x19a
8940 local index=$((i % MDSCOUNT + 1))
8942 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
8949 for i in $(seq $MDSCOUNT); do
8950 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
8953 mkdir $DIR/$tdir/new || error "mkdir failed"
8954 rmdir $DIR/$tdir/new || error "rmdir failed"
8956 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
8958 for i in $(seq $MDSCOUNT); do
8959 wait_update_facet mds$i "$LCTL get_param -n \
8960 mdd.$(facet_svc mds$i).lfsck_namespace |
8961 awk '/^status/ { print \\\$2 }'" "completed"
8965 rm -rf $DIR/$tdir || error "rmdir failed"
8967 run_test 60g "transaction abort won't cause MDT hung"
8970 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
8971 skip "Need MDS version at least 2.12.52"
8972 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
8976 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
8977 #define OBD_FAIL_MDS_STRIPE_FID 0x189
8978 for fail_loc in 0x80000188 0x80000189; do
8979 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
8980 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
8981 error "mkdir $dir-$fail_loc failed"
8982 for i in {0..10}; do
8983 # create may fail on missing stripe
8984 echo $i > $DIR/$tdir-$fail_loc/$i
8986 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8987 error "getdirstripe $tdir-$fail_loc failed"
8988 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
8989 error "migrate $tdir-$fail_loc failed"
8990 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8991 error "getdirstripe $tdir-$fail_loc failed"
8992 pushd $DIR/$tdir-$fail_loc
8994 echo $f | cmp $f - || error "$f data mismatch"
8997 rm -rf $DIR/$tdir-$fail_loc
9000 run_test 60h "striped directory with missing stripes can be accessed"
9002 function t60i_load() {
9004 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
9005 $LCTL set_param fail_loc=0x131c fail_val=1
9006 for ((i=0; i<5000; i++)); do
9007 touch $DIR/$tdir/f$i
9012 changelog_register || error "changelog_register failed"
9013 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
9014 changelog_users $SINGLEMDS | grep -q $cl_user ||
9015 error "User $cl_user not found in changelog_users"
9016 changelog_chmask "ALL"
9019 for((i=0; i<100; i++)); do
9020 changelog_dump >/dev/null ||
9021 error "can't read changelog"
9025 changelog_deregister || error "changelog_deregister failed"
9026 $LCTL set_param fail_loc=0
9028 run_test 60i "llog: new record vs reader race"
9031 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
9032 skip "need MDS version at least 2.15.50"
9033 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9034 remote_mds_nodsh && skip "remote MDS with nodsh"
9035 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
9037 changelog_users $SINGLEMDS | grep "^cl" &&
9038 skip "active changelog user"
9040 local llog_reader=$(do_facet $SINGLEMDS "which llog_reader 2> /dev/null")
9042 [[ -z $(do_facet $SINGLEMDS ls -d $llog_reader 2> /dev/null) ]] &&
9043 skip_env "missing llog_reader"
9045 mkdir_on_mdt0 $DIR/$tdir
9047 local f=$DIR/$tdir/$tfile
9052 changelog_register || error "cannot register changelog user"
9054 # set changelog_mask to ALL
9055 changelog_chmask "ALL"
9058 createmany -o ${f}- 100 || error "createmany failed as $RUNAS_ID"
9059 unlinkmany ${f}- 100 || error "unlinkmany failed"
9061 tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
9062 mdt_dev=$(facet_device $SINGLEMDS)
9064 do_facet $SINGLEMDS sync
9065 plain=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'dump changelog_catalog \
9066 $tmpfile' $mdt_dev; $llog_reader $tmpfile" |
9067 awk '{match($0,"path=([^ ]+)",a)}END{print a[1]}')
9069 stack_trap "do_facet $SINGLEMDS rm -f $tmpfile"
9071 # if $tmpfile is not on EXT3 filesystem for some reason
9072 [[ ${plain:0:1} == 'O' ]] ||
9073 skip "path $plain is not in 'O/1/d<n>/<n>' format"
9075 size=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'dump $plain $tmpfile' \
9076 $mdt_dev; stat -c %s $tmpfile")
9077 echo "Truncate llog from $size to $((size - size % 8192))"
9078 size=$((size - size % 8192))
9079 do_facet $SINGLEMDS $TRUNCATE $tmpfile $size
9080 errs=$(do_facet $SINGLEMDS "$llog_reader $tmpfile" |
9081 grep -c 'in bitmap only')
9082 (( $errs > 0 )) || error "llog_reader didn't find lost records"
9084 size=$((size - 9000))
9085 echo "Corrupt llog in the middle at $size"
9086 do_facet $SINGLEMDS dd if=/dev/urandom of=$tmpfile bs=1 seek=$size \
9087 count=333 conv=notrunc
9088 errs=$(do_facet $SINGLEMDS "$llog_reader $tmpfile" |
9089 grep -c 'next chunk')
9090 (( $errs > 0 )) || error "llog_reader didn't skip bad chunk"
9092 run_test 60j "llog_reader reports corruptions"
9095 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9098 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
9099 cancel_lru_locks osc
9100 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
9103 run_test 61a "mmap() writes don't make sync hang ================"
9106 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
9108 run_test 61b "mmap() of unstriped file is successful"
9110 # bug 2330 - insufficient obd_match error checking causes LBUG
9112 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9116 cancel_lru_locks osc
9117 lctl set_param fail_loc=0x405
9118 cat $f && error "cat succeeded, expect -EIO"
9119 lctl set_param fail_loc=0
9121 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
9122 # match every page all of the time.
9123 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
9125 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
9126 # Though this test is irrelevant anymore, it helped to reveal some
9127 # other grant bugs (LU-4482), let's keep it.
9128 test_63a() { # was test_63
9129 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9131 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
9133 for i in `seq 10` ; do
9134 dd if=/dev/zero of=$DIR/f63 bs=8k &
9140 rm -f $DIR/f63 || true
9142 run_test 63a "Verify oig_wait interruption does not crash ======="
9144 # bug 2248 - async write errors didn't return to application on sync
9145 # bug 3677 - async write errors left page locked
9147 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9150 lctl set_param debug=-1
9152 # ensure we have a grant to do async writes
9153 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
9156 sync # sync lest earlier test intercept the fail_loc
9158 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9159 lctl set_param fail_loc=0x80000406
9160 $MULTIOP $DIR/$tfile Owy && \
9161 error "sync didn't return ENOMEM"
9162 sync; sleep 2; sync # do a real sync this time to flush page
9163 lctl get_param -n llite.*.dump_page_cache | grep locked && \
9164 error "locked page left in cache after async error" || true
9167 run_test 63b "async write errors should be returned to fsync ==="
9170 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9173 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
9175 run_test 64a "verify filter grant calculations (in kernel) ====="
9178 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9180 bash oos.sh $MOUNT || error "oos.sh failed: $?"
9182 run_test 64b "check out-of-space detection on client"
9185 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
9187 run_test 64c "verify grant shrink"
9193 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
9196 # this does exactly what osc_request.c:osc_announce_cached() does in
9197 # order to calculate max amount of grants to ask from server
9201 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
9202 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
9204 ((rpc_in_flight++));
9205 nrpages=$((nrpages * rpc_in_flight))
9207 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
9209 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
9211 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
9212 local undirty=$((nrpages * PAGE_SIZE))
9214 local max_extent_pages
9215 max_extent_pages=$(import_param $tgt grant_max_extent_size)
9216 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
9217 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
9218 local grant_extent_tax
9219 grant_extent_tax=$(import_param $tgt grant_extent_tax)
9221 undirty=$((undirty + nrextents * grant_extent_tax))
9226 # this is size of unit for grant allocation. It should be equal to
9227 # what tgt_grant.c:tgt_grant_chunk() calculates
9231 local grant_extent_tax
9233 max_brw_size=$(import_param $tgt max_brw_size)
9235 grant_extent_tax=$(import_param $tgt grant_extent_tax)
9237 echo $(((max_brw_size + grant_extent_tax) * 2))
9241 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
9242 skip "OST < 2.10.55 doesn't limit grants enough"
9244 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
9246 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
9247 skip "no grant_param connect flag"
9249 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9251 $LCTL set_param -n -n debug="$OLDDEBUG" || true
9252 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9255 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
9256 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
9258 $LFS setstripe $DIR/$tfile -i 0 -c 1
9259 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
9262 while kill -0 $ddpid; do
9263 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
9265 if [[ $cur_grant -gt $max_cur_granted ]]; then
9267 error "cur_grant $cur_grant > $max_cur_granted"
9273 run_test 64d "check grant limit exceed"
9279 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
9281 ((cur_grants == expected)) ||
9282 error "$msg: grants mismatch: $cur_grants, expected $expected"
9286 echo $((($1 + $2 - 1) & ~($2 - 1)))
9290 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9291 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
9292 skip "Need OSS version at least 2.11.56"
9294 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9295 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9296 $LCTL set_param debug=+cache
9298 # Remount client to reset grant
9299 remount_client $MOUNT || error "failed to remount client"
9300 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9302 local init_grants=$(import_param $osc_tgt initial_grant)
9304 check_grants $osc_tgt $init_grants "init grants"
9306 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9307 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9308 local gbs=$(import_param $osc_tgt grant_block_size)
9310 # write random number of bytes from max_brw_size / 4 to max_brw_size
9311 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9312 # align for direct io
9313 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9314 # round to grant consumption unit
9315 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9317 local grants=$((wb_round_up + extent_tax))
9319 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9321 # define OBD_FAIL_TGT_NO_GRANT 0x725
9322 # make the server not grant more back
9323 do_facet ost1 $LCTL set_param fail_loc=0x725
9324 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
9326 do_facet ost1 $LCTL set_param fail_loc=0
9328 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
9330 rm -f $DIR/$tfile || error "rm failed"
9332 # Remount client to reset grant
9333 remount_client $MOUNT || error "failed to remount client"
9334 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9336 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9338 # define OBD_FAIL_TGT_NO_GRANT 0x725
9339 # make the server not grant more back
9340 do_facet ost1 $LCTL set_param fail_loc=0x725
9341 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
9342 do_facet ost1 $LCTL set_param fail_loc=0
9344 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
9346 run_test 64e "check grant consumption (no grant allocation)"
9349 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9351 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9352 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9353 $LCTL set_param debug=+cache
9355 # Remount client to reset grant
9356 remount_client $MOUNT || error "failed to remount client"
9357 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9359 local init_grants=$(import_param $osc_tgt initial_grant)
9360 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9361 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9362 local gbs=$(import_param $osc_tgt grant_block_size)
9363 local chunk=$(grant_chunk $osc_tgt)
9365 # write random number of bytes from max_brw_size / 4 to max_brw_size
9366 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9367 # align for direct io
9368 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9369 # round to grant consumption unit
9370 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9372 local grants=$((wb_round_up + extent_tax))
9374 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9375 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
9376 error "error writing to $DIR/$tfile"
9378 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9379 "direct io with grant allocation"
9381 rm -f $DIR/$tfile || error "rm failed"
9383 # Remount client to reset grant
9384 remount_client $MOUNT || error "failed to remount client"
9385 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9387 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9389 local cmd="oO_WRONLY:w${write_bytes}_yc"
9391 $MULTIOP $DIR/$tfile $cmd &
9395 check_grants $osc_tgt $((init_grants - grants)) \
9396 "buffered io, not write rpc"
9398 kill -USR1 $MULTIPID
9401 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9402 "buffered io, one RPC"
9404 run_test 64f "check grant consumption (with grant allocation)"
9407 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
9408 skip "Need MDS version at least 2.14.56"
9410 local mdts=$(comma_list $(mdts_nodes))
9412 local old=$($LCTL get_param mdc.$FSNAME-*.grant_shrink_interval |
9414 stack_trap "$LCTL set_param $old"
9416 # generate dirty pages and increase dirty granted on MDT
9417 stack_trap "rm -f $DIR/$tfile-*"
9418 for (( i = 0; i < 10; i++)); do
9419 $LFS setstripe -E 1M -L mdt $DIR/$tfile-$i ||
9420 error "can't set stripe"
9421 dd if=/dev/zero of=$DIR/$tfile-$i bs=128k count=1 ||
9423 $LFS getstripe $DIR/$tfile-$i | grep -q pattern.*mdt || {
9424 $LFS getstripe $DIR/$tfile-$i
9425 error "not DoM file"
9432 # wait until grant shrink reset grant dirty on MDTs
9433 for ((i = 0; i < 120; i++)); do
9434 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9435 awk '{sum=sum+$1} END {print sum}')
9436 vm_dirty=$(awk '/Dirty:/{print $2}' /proc/meminfo)
9437 echo "$grant_dirty grants, $vm_dirty pages"
9438 (( grant_dirty + vm_dirty == 0 )) && break
9439 (( i == 3 )) && sync &&
9440 $LCTL set_param mdc.$FSNAME-*.grant_shrink_interval=5
9444 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9445 awk '{sum=sum+$1} END {print sum}')
9446 (( grant_dirty == 0 )) || error "$grant_dirty on MDT"
9448 run_test 64g "grant shrink on MDT"
9451 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9452 skip "need OST at least 2.14.56 to avoid grant shrink on read"
9454 local instance=$($LFS getname -i $DIR)
9455 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9456 local num_exps=$(do_facet ost1 \
9457 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
9458 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9459 local avail=$($LCTL get_param -n osc.*OST0000-osc-$instance.kbytesavail)
9460 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9462 # 10MiB is for file to be written, max_brw_size * 16 *
9463 # num_exps is space reserve so that tgt_grant_shrink() decided
9465 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
9466 (( avail * 1024 < expect )) &&
9467 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
9469 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
9470 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
9471 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
9472 $LCTL set_param osc.*OST0000*.grant_shrink=1
9473 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
9475 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9476 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
9478 # drop cache so that coming read would do rpc
9479 cancel_lru_locks osc
9481 # shrink interval is set to 10, pause for 7 seconds so that
9482 # grant thread did not wake up yet but coming read entered
9483 # shrink mode for rpc (osc_should_shrink_grant())
9486 declare -a cur_grant_bytes
9487 declare -a tot_granted
9488 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9489 tot_granted[0]=$(do_facet ost1 \
9490 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9492 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
9494 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9495 tot_granted[1]=$(do_facet ost1 \
9496 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9498 # grant change should be equal on both sides
9499 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
9500 tot_granted[0] - tot_granted[1])) ||
9501 error "grant change mismatch, " \
9502 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
9503 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
9505 run_test 64h "grant shrink on read"
9508 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9509 skip "need OST at least 2.14.56 to avoid grant shrink on replay"
9511 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9512 remote_ost_nodsh && skip "remote OSTs with nodsh"
9514 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9516 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
9518 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
9519 local instance=$($LFS getname -i $DIR)
9521 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9522 local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
9524 # shrink grants and simulate rpc loss
9525 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
9526 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
9527 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
9531 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
9533 local testid=$(echo $TESTNAME | tr '_' ' ')
9535 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
9536 grep "GRANT, real grant" &&
9537 error "client has more grants then it owns" || true
9539 run_test 64i "shrink on reconnect"
9541 # bug 1414 - set/get directories' stripe info
9543 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9545 test_mkdir $DIR/$tdir
9547 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
9549 run_test 65a "directory with no stripe info"
9552 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9554 test_mkdir $DIR/$tdir
9555 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9557 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9560 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
9562 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
9565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9566 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
9568 test_mkdir $DIR/$tdir
9569 local stripesize=$($LFS getstripe -S $DIR/$tdir)
9571 $LFS setstripe -S $((stripesize * 4)) -i 1 \
9572 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
9574 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
9576 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
9579 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9581 test_mkdir $DIR/$tdir
9582 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
9583 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9585 if [[ $STRIPECOUNT -le 0 ]]; then
9587 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
9588 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
9589 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
9591 sc=$(($STRIPECOUNT - 1))
9593 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
9594 touch $DIR/$tdir/f4 $DIR/$tdir/f5
9595 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
9596 error "lverify failed"
9598 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
9601 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9603 test_mkdir $DIR/$tdir
9605 $LFS setstripe $DIR/$tdir || error "setstripe"
9606 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9607 error "no stripe info failed"
9609 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
9611 run_test 65e "directory setstripe defaults"
9614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9616 test_mkdir $DIR/${tdir}f
9617 $RUNAS $LFS setstripe $DIR/${tdir}f &&
9618 error "setstripe succeeded" || true
9620 run_test 65f "dir setstripe permission (should return error) ==="
9623 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9625 test_mkdir $DIR/$tdir
9626 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9628 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9629 error "setstripe -S failed"
9630 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
9631 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9632 error "delete default stripe failed"
9634 run_test 65g "directory setstripe -d"
9637 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9639 test_mkdir $DIR/$tdir
9640 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9642 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9643 error "setstripe -S failed"
9644 test_mkdir $DIR/$tdir/dd1
9645 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
9646 error "stripe info inherit failed"
9648 run_test 65h "directory stripe info inherit ===================="
9651 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9653 save_layout_restore_at_exit $MOUNT
9655 # bug6367: set non-default striping on root directory
9656 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
9658 # bug12836: getstripe on -1 default directory striping
9659 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
9661 # bug12836: getstripe -v on -1 default directory striping
9662 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
9664 # bug12836: new find on -1 default directory striping
9665 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
9667 run_test 65i "various tests to set root directory striping"
9669 test_65j() { # bug6367
9670 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9674 # if we aren't already remounting for each test, do so for this test
9675 if [ "$I_MOUNTED" = "yes" ]; then
9676 cleanup || error "failed to unmount"
9680 save_layout_restore_at_exit $MOUNT
9682 $LFS setstripe -d $MOUNT || error "setstripe failed"
9684 run_test 65j "set default striping on root directory (bug 6367)="
9688 wait_delete_completed
9689 do_facet $SINGLEMDS "lctl set_param -n \
9690 osp.$ost*MDT0000.max_create_count=$max_count"
9691 do_facet $SINGLEMDS "lctl set_param -n \
9692 osp.$ost*MDT0000.create_count=$count"
9693 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9694 echo $INACTIVE_OSC "is Activate"
9696 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9699 test_65k() { # bug11679
9700 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9701 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9702 remote_mds_nodsh && skip "remote MDS with nodsh"
9704 local disable_precreate=true
9705 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
9706 disable_precreate=false
9708 echo "Check OST status: "
9709 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
9710 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
9712 for OSC in $MDS_OSCS; do
9713 echo $OSC "is active"
9714 do_facet $SINGLEMDS lctl --device %$OSC activate
9717 for INACTIVE_OSC in $MDS_OSCS; do
9718 local ost=$(osc_to_ost $INACTIVE_OSC)
9719 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
9720 lov.*md*.target_obd |
9721 awk -F: /$ost/'{ print $1 }' | head -n 1)
9724 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
9725 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
9727 echo "Deactivate: " $INACTIVE_OSC
9728 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
9730 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
9731 osp.$ost*MDT0000.create_count")
9732 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
9733 osp.$ost*MDT0000.max_create_count")
9734 $disable_precreate &&
9735 do_facet $SINGLEMDS "lctl set_param -n \
9736 osp.$ost*MDT0000.max_create_count=0"
9738 for idx in $(seq 0 $((OSTCOUNT - 1))); do
9739 [ -f $DIR/$tdir/$idx ] && continue
9740 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
9741 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
9743 error "setstripe $idx should succeed"; }
9744 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
9746 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
9749 do_facet $SINGLEMDS "lctl set_param -n \
9750 osp.$ost*MDT0000.max_create_count=$max_count"
9751 do_facet $SINGLEMDS "lctl set_param -n \
9752 osp.$ost*MDT0000.create_count=$count"
9753 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9754 echo $INACTIVE_OSC "is Activate"
9756 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9759 run_test 65k "validate manual striping works properly with deactivated OSCs"
9761 test_65l() { # bug 12836
9762 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9764 test_mkdir -p $DIR/$tdir/test_dir
9765 $LFS setstripe -c -1 $DIR/$tdir/test_dir
9766 $LFS find -mtime -1 $DIR/$tdir >/dev/null
9768 run_test 65l "lfs find on -1 stripe dir ========================"
9771 local layout=$(save_layout $MOUNT)
9772 $RUNAS $LFS setstripe -c 2 $MOUNT && {
9773 restore_layout $MOUNT $layout
9774 error "setstripe should fail by non-root users"
9778 run_test 65m "normal user can't set filesystem default stripe"
9781 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
9782 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
9783 skip "Need MDS version at least 2.12.50"
9784 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9786 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
9787 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
9788 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
9790 save_layout_restore_at_exit $MOUNT
9792 # new subdirectory under root directory should not inherit
9793 # the default layout from root
9794 local dir1=$MOUNT/$tdir-1
9795 mkdir $dir1 || error "mkdir $dir1 failed"
9796 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
9797 error "$dir1 shouldn't have LOV EA"
9799 # delete the default layout on root directory
9800 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
9802 local dir2=$MOUNT/$tdir-2
9803 mkdir $dir2 || error "mkdir $dir2 failed"
9804 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
9805 error "$dir2 shouldn't have LOV EA"
9807 # set a new striping pattern on root directory
9808 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9809 local new_def_stripe_size=$((def_stripe_size * 2))
9810 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
9811 error "set stripe size on $MOUNT failed"
9813 # new file created in $dir2 should inherit the new stripe size from
9814 # the filesystem default
9815 local file2=$dir2/$tfile-2
9816 touch $file2 || error "touch $file2 failed"
9818 local file2_stripe_size=$($LFS getstripe -S $file2)
9819 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
9821 echo "file2_stripe_size: '$file2_stripe_size'"
9822 echo "new_def_stripe_size: '$new_def_stripe_size'"
9823 error "$file2 didn't inherit stripe size $new_def_stripe_size"
9826 local dir3=$MOUNT/$tdir-3
9827 mkdir $dir3 || error "mkdir $dir3 failed"
9828 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
9829 # the root layout, which is the actual default layout that will be used
9830 # when new files are created in $dir3.
9831 local dir3_layout=$(get_layout_param $dir3)
9832 local root_dir_layout=$(get_layout_param $MOUNT)
9833 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
9835 echo "dir3_layout: '$dir3_layout'"
9836 echo "root_dir_layout: '$root_dir_layout'"
9837 error "$dir3 should show the default layout from $MOUNT"
9840 # set OST pool on root directory
9841 local pool=$TESTNAME
9842 pool_add $pool || error "add $pool failed"
9843 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9844 error "add targets to $pool failed"
9846 $LFS setstripe -p $pool $MOUNT ||
9847 error "set OST pool on $MOUNT failed"
9849 # new file created in $dir3 should inherit the pool from
9850 # the filesystem default
9851 local file3=$dir3/$tfile-3
9852 touch $file3 || error "touch $file3 failed"
9854 local file3_pool=$($LFS getstripe -p $file3)
9855 [[ "$file3_pool" = "$pool" ]] ||
9856 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
9858 local dir4=$MOUNT/$tdir-4
9859 mkdir $dir4 || error "mkdir $dir4 failed"
9860 local dir4_layout=$(get_layout_param $dir4)
9861 root_dir_layout=$(get_layout_param $MOUNT)
9862 echo "$LFS getstripe -d $dir4"
9863 $LFS getstripe -d $dir4
9864 echo "$LFS getstripe -d $MOUNT"
9865 $LFS getstripe -d $MOUNT
9866 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
9868 echo "dir4_layout: '$dir4_layout'"
9869 echo "root_dir_layout: '$root_dir_layout'"
9870 error "$dir4 should show the default layout from $MOUNT"
9873 # new file created in $dir4 should inherit the pool from
9874 # the filesystem default
9875 local file4=$dir4/$tfile-4
9876 touch $file4 || error "touch $file4 failed"
9878 local file4_pool=$($LFS getstripe -p $file4)
9879 [[ "$file4_pool" = "$pool" ]] ||
9880 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
9882 # new subdirectory under non-root directory should inherit
9883 # the default layout from its parent directory
9884 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
9885 error "set directory layout on $dir4 failed"
9887 local dir5=$dir4/$tdir-5
9888 mkdir $dir5 || error "mkdir $dir5 failed"
9890 dir4_layout=$(get_layout_param $dir4)
9891 local dir5_layout=$(get_layout_param $dir5)
9892 [[ "$dir4_layout" = "$dir5_layout" ]] ||
9894 echo "dir4_layout: '$dir4_layout'"
9895 echo "dir5_layout: '$dir5_layout'"
9896 error "$dir5 should inherit the default layout from $dir4"
9899 # though subdir under ROOT doesn't inherit default layout, but
9900 # its sub dir/file should be created with default layout.
9901 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
9902 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
9903 skip "Need MDS version at least 2.12.59"
9905 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
9906 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
9907 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
9909 if [ $default_lmv_hash == "none" ]; then
9910 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
9912 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
9913 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
9916 $LFS setdirstripe -D -c 2 $MOUNT ||
9917 error "setdirstripe -D -c 2 failed"
9918 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
9919 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
9920 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
9922 # $dir4 layout includes pool
9923 $LFS setstripe -S $((new_def_stripe_size * 2)) $dir4
9924 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9925 error "pool lost on setstripe"
9926 $LFS setstripe -E -1 -S $new_def_stripe_size $dir4
9927 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9928 error "pool lost on compound layout setstripe"
9930 run_test 65n "don't inherit default layout from root for new subdirectories"
9933 (( $MDS1_VERSION >= $(version_code 2.14.57) )) ||
9934 skip "need MDS version at least 2.14.57"
9936 # set OST pool on root directory
9937 local pool=$TESTNAME
9939 pool_add $pool || error "add $pool failed"
9940 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9941 error "add targets to $pool failed"
9943 local dir1=$MOUNT/$tdir
9945 mkdir $dir1 || error "mkdir $dir1 failed"
9947 # set a new striping pattern on root directory
9948 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9950 $LFS setstripe -p $pool $dir1 ||
9951 error "set directory layout on $dir1 failed"
9953 # $dir1 layout includes pool
9954 $LFS setstripe -S $((def_stripe_size * 2)) $dir1
9955 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9956 error "pool lost on setstripe"
9957 $LFS setstripe -E 1M -L mdt -E -1 -c 1 $dir1
9958 $LFS getstripe $dir1
9959 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9960 error "pool lost on compound layout setstripe"
9962 $LFS setdirstripe -i 0 -c 2 $dir1/dir2 ||
9963 error "setdirstripe failed on sub-dir with inherited pool"
9964 $LFS getstripe $dir1/dir2
9965 [[ "$pool" = $($LFS getstripe -p -d $dir1/dir2) ]] ||
9966 error "pool lost on compound layout setdirstripe"
9968 $LFS setstripe -E -1 -c 1 $dir1
9969 $LFS getstripe -d $dir1
9970 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9971 error "pool lost on setstripe"
9973 run_test 65o "pool inheritance for mdt component"
9975 test_65p () { # LU-16152
9976 local src_dir=$DIR/$tdir/src_dir
9977 local dst_dir=$DIR/$tdir/dst_dir
9978 local yaml_file=$DIR/$tdir/layout.yaml
9981 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
9982 skip "Need at least version 2.15.51"
9984 test_mkdir -p $src_dir
9985 $LFS setstripe -E 2048M -c 4 -E EOF -c 8 $src_dir ||
9986 error "failed to setstripe"
9987 $LFS getstripe --yaml -d $src_dir > $yaml_file ||
9988 error "failed to getstripe"
9990 test_mkdir -p $dst_dir
9991 $LFS setstripe --yaml $yaml_file $dst_dir ||
9992 error "failed to setstripe with yaml file"
9993 border=$($LFS getstripe -d $dst_dir |
9994 awk '/lcme_extent.e_end:/ { print $2; exit; }') ||
9995 error "failed to getstripe"
9997 # 2048M is 0x80000000, or 2147483648
9998 (( $border == 2147483648 )) ||
9999 error "failed to handle huge number in yaml layout"
10001 run_test 65p "setstripe with yaml file and huge number"
10003 # bug 2543 - update blocks count on client
10005 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10007 local COUNT=${COUNT:-8}
10008 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
10009 sync; sync_all_data; sync; sync_all_data
10010 cancel_lru_locks osc
10011 local BLOCKS=$(ls -s --block-size=1k $DIR/f66 | awk '{ print $1 }')
10012 (( BLOCKS >= COUNT )) || error "$DIR/f66 blocks $BLOCKS < $COUNT"
10014 run_test 66 "update inode blocks count on client ==============="
10017 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
10021 swapon -s | awk '($1 == "'$1'") { print $4 }'
10024 # bug5265, obdfilter oa2dentry return -ENOENT
10025 # #define OBD_FAIL_SRV_ENOENT 0x217
10027 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10028 remote_ost_nodsh && skip "remote OST with nodsh"
10031 $LFS setstripe -c 1 -i 0 $f
10033 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
10035 do_facet ost1 lctl set_param fail_loc=0x217
10036 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
10037 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
10039 do_facet ost1 lctl set_param fail_loc=0
10040 $DIRECTIO write $f 0 2 || error "write error"
10042 cancel_lru_locks osc
10043 $DIRECTIO read $f 0 1 || error "read error"
10045 do_facet ost1 lctl set_param fail_loc=0x217
10046 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
10048 do_facet ost1 lctl set_param fail_loc=0
10051 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
10054 test_mkdir $DIR/$tdir
10055 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
10056 bash rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
10058 run_test 71 "Running dbench on lustre (don't segment fault) ===="
10060 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
10061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10062 [ "$RUNAS_ID" = "$UID" ] &&
10063 skip_env "RUNAS_ID = UID = $UID -- skipping"
10064 # Check that testing environment is properly set up. Skip if not
10065 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
10066 skip_env "User $RUNAS_ID does not exist - skipping"
10069 chmod 777 $DIR/$tfile
10070 chmod ug+s $DIR/$tfile
10071 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
10072 error "$RUNAS dd $DIR/$tfile failed"
10073 # See if we are still setuid/sgid
10074 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
10075 error "S/gid is not dropped on write"
10076 # Now test that MDS is updated too
10077 cancel_lru_locks mdc
10078 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
10079 error "S/gid is not dropped on MDS"
10082 run_test 72a "Test that remove suid works properly (bug5695) ===="
10084 test_72b() { # bug 24226 -- keep mode setting when size is not changing
10087 [ "$RUNAS_ID" = "$UID" ] &&
10088 skip_env "RUNAS_ID = UID = $UID -- skipping"
10089 [ "$RUNAS_ID" -eq 0 ] &&
10090 skip_env "RUNAS_ID = 0 -- skipping"
10091 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10092 # Check that testing environment is properly set up. Skip if not
10093 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
10094 skip_env "User $RUNAS_ID does not exist - skipping"
10096 touch $DIR/${tfile}-f{g,u}
10097 test_mkdir $DIR/${tfile}-dg
10098 test_mkdir $DIR/${tfile}-du
10099 chmod 770 $DIR/${tfile}-{f,d}{g,u}
10100 chmod g+s $DIR/${tfile}-{f,d}g
10101 chmod u+s $DIR/${tfile}-{f,d}u
10102 for perm in 777 2777 4777; do
10103 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
10104 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
10105 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
10106 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
10110 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
10112 # bug 3462 - multiple simultaneous MDC requests
10114 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10116 test_mkdir $DIR/d73-1
10117 test_mkdir $DIR/d73-2
10118 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
10121 lctl set_param fail_loc=0x80000129
10122 $MULTIOP $DIR/d73-1/f73-2 Oc &
10124 lctl set_param fail_loc=0
10126 $MULTIOP $DIR/d73-2/f73-3 Oc &
10130 wait $pid1 || return 1
10134 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
10135 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
10136 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
10140 run_test 73 "multiple MDC requests (should not deadlock)"
10142 test_74a() { # bug 6149, 6184
10143 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10146 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
10148 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
10149 # will spin in a tight reconnection loop
10150 $LCTL set_param fail_loc=0x8000030e
10151 # get any lock that won't be difficult - lookup works.
10153 $LCTL set_param fail_loc=0
10157 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
10159 test_74b() { # bug 13310
10160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10162 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
10164 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
10165 # will spin in a tight reconnection loop
10166 $LCTL set_param fail_loc=0x8000030e
10167 # get a "difficult" lock
10169 $LCTL set_param fail_loc=0
10173 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
10176 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10178 #define OBD_FAIL_LDLM_NEW_LOCK
10179 $LCTL set_param fail_loc=0x319
10180 touch $DIR/$tfile && error "touch successful"
10181 $LCTL set_param fail_loc=0
10184 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
10186 slab_lic=/sys/kernel/slab/lustre_inode_cache
10188 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
10189 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
10190 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
10193 test_76a() { # Now for b=20433, added originally in b=1443
10194 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10196 cancel_lru_locks osc
10197 # there may be some slab objects cached per core
10198 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
10199 local before=$(num_objects)
10200 local count=$((512 * cpus))
10201 [ "$SLOW" = "no" ] && count=$((128 * cpus))
10202 local margin=$((count / 10))
10203 if [[ -f $slab_lic/aliases ]]; then
10204 local aliases=$(cat $slab_lic/aliases)
10205 (( aliases > 0 )) && margin=$((margin * aliases))
10208 echo "before slab objects: $before"
10209 for i in $(seq $count); do
10213 cancel_lru_locks osc
10214 local after=$(num_objects)
10215 echo "created: $count, after slab objects: $after"
10216 # shared slab counts are not very accurate, allow significant margin
10217 # the main goal is that the cache growth is not permanently > $count
10218 while (( after > before + margin )); do
10220 after=$(num_objects)
10222 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
10223 if (( wait > 60 )); then
10224 error "inode slab grew from $before+$margin to $after"
10228 run_test 76a "confirm clients recycle inodes properly ===="
10231 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10232 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
10235 local before=$(num_objects)
10237 for i in $(seq $count); do
10242 local after=$(num_objects)
10245 while (( after > before )); do
10247 after=$(num_objects)
10249 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
10250 if (( wait > 60 )); then
10251 error "inode slab grew from $before to $after"
10255 echo "slab objects before: $before, after: $after"
10257 run_test 76b "confirm clients recycle directory inodes properly ===="
10259 export ORIG_CSUM=""
10262 # Note: in sptlrpc modes which enable its own bulk checksum, the
10263 # original crc32_le bulk checksum will be automatically disabled,
10264 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
10265 # will be checked by sptlrpc code against sptlrpc bulk checksum.
10266 # In this case set_checksums() will not be no-op, because sptlrpc
10267 # bulk checksum will be enabled all through the test.
10269 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
10270 lctl set_param -n osc.*.checksums $1
10274 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
10275 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
10276 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
10277 tr -d [] | head -n1)}
10278 set_checksum_type()
10280 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
10282 log "set checksum type to $1, rc = $rc"
10286 get_osc_checksum_type()
10288 # arugment 1: OST name, like OST0000
10290 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
10291 sed 's/.*\[\(.*\)\].*/\1/g')
10293 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
10294 echo $checksum_type
10297 F77_TMP=$TMP/f77-temp
10300 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
10301 error "error writing to $F77_TMP"
10304 test_77a() { # bug 10889
10305 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10306 $GSS && skip_env "could not run with gss"
10308 [ ! -f $F77_TMP ] && setup_f77
10310 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
10314 run_test 77a "normal checksum read/write operation"
10316 test_77b() { # bug 10889
10317 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10318 $GSS && skip_env "could not run with gss"
10320 [ ! -f $F77_TMP ] && setup_f77
10321 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10322 $LCTL set_param fail_loc=0x80000409
10325 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10326 error "dd error: $?"
10327 $LCTL set_param fail_loc=0
10329 for algo in $CKSUM_TYPES; do
10330 cancel_lru_locks osc
10331 set_checksum_type $algo
10332 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10333 $LCTL set_param fail_loc=0x80000408
10334 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
10335 $LCTL set_param fail_loc=0
10338 set_checksum_type $ORIG_CSUM_TYPE
10341 run_test 77b "checksum error on client write, read"
10346 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
10348 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
10349 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
10350 $check_ost && [ -n "$ost_file_prefix" ] &&
10351 do_facet ost1 rm -f ${ost_file_prefix}\*
10355 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10356 $GSS && skip_env "could not run with gss"
10357 remote_ost_nodsh && skip "remote OST with nodsh"
10360 local osc_file_prefix
10362 local check_ost=false
10363 local ost_file_prefix
10369 # ensure corruption will occur on first OSS/OST
10370 $LFS setstripe -i 0 $DIR/$tfile
10372 [ ! -f $F77_TMP ] && setup_f77
10373 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10374 error "dd write error: $?"
10375 fid=$($LFS path2fid $DIR/$tfile)
10377 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
10380 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
10381 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
10383 echo "OSS do not support bulk pages dump upon error"
10386 osc_file_prefix=$($LCTL get_param -n debug_path)
10387 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
10389 trap cleanup_77c EXIT
10392 # enable bulk pages dump upon error on Client
10393 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
10394 # enable bulk pages dump upon error on OSS
10396 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
10398 # flush Client cache to allow next read to reach OSS
10399 cancel_lru_locks osc
10401 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10402 $LCTL set_param fail_loc=0x80000408
10403 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
10404 $LCTL set_param fail_loc=0
10408 # check cksum dump on Client
10409 osc_file=$(ls ${osc_file_prefix}*)
10410 [ -n "$osc_file" ] || error "no checksum dump file on Client"
10411 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
10412 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
10413 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
10414 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
10416 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
10417 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10418 error "dump content does not match on Client"
10420 $check_ost || skip "No need to check cksum dump on OSS"
10422 # check cksum dump on OSS
10423 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
10424 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
10425 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
10426 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
10427 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10428 error "dump content does not match on OSS"
10432 run_test 77c "checksum error on client read with debug"
10434 test_77d() { # bug 10889
10435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10436 $GSS && skip_env "could not run with gss"
10438 stack_trap "rm -f $DIR/$tfile"
10439 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10440 $LCTL set_param fail_loc=0x80000409
10442 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10443 error "direct write: rc=$?"
10444 $LCTL set_param fail_loc=0
10447 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10448 $LCTL set_param fail_loc=0x80000408
10450 cancel_lru_locks osc
10451 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10452 error "direct read: rc=$?"
10453 $LCTL set_param fail_loc=0
10456 run_test 77d "checksum error on OST direct write, read"
10458 test_77f() { # bug 10889
10459 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10460 $GSS && skip_env "could not run with gss"
10463 stack_trap "rm -f $DIR/$tfile"
10464 for algo in $CKSUM_TYPES; do
10465 cancel_lru_locks osc
10466 set_checksum_type $algo
10467 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10468 $LCTL set_param fail_loc=0x409
10469 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
10470 error "direct write succeeded"
10471 $LCTL set_param fail_loc=0
10473 set_checksum_type $ORIG_CSUM_TYPE
10476 run_test 77f "repeat checksum error on write (expect error)"
10478 test_77g() { # bug 10889
10479 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10480 $GSS && skip_env "could not run with gss"
10481 remote_ost_nodsh && skip "remote OST with nodsh"
10483 [ ! -f $F77_TMP ] && setup_f77
10485 local file=$DIR/$tfile
10486 stack_trap "rm -f $file" EXIT
10488 $LFS setstripe -c 1 -i 0 $file
10489 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
10490 do_facet ost1 lctl set_param fail_loc=0x8000021a
10492 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
10493 error "write error: rc=$?"
10494 do_facet ost1 lctl set_param fail_loc=0
10497 cancel_lru_locks osc
10498 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
10499 do_facet ost1 lctl set_param fail_loc=0x8000021b
10501 cmp $F77_TMP $file || error "file compare failed"
10502 do_facet ost1 lctl set_param fail_loc=0
10505 run_test 77g "checksum error on OST write, read"
10507 test_77k() { # LU-10906
10508 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10509 $GSS && skip_env "could not run with gss"
10511 local cksum_param="osc.$FSNAME*.checksums"
10512 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
10516 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
10517 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
10518 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
10521 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
10522 error "failed to set checksum=$i on MGS"
10523 wait_update $HOSTNAME "$get_checksum" $i
10525 echo "remount client, checksum should be $i"
10526 remount_client $MOUNT || error "failed to remount client"
10527 checksum=$(eval $get_checksum)
10528 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10530 # remove persistent param to avoid races with checksum mountopt below
10531 do_facet mgs $LCTL set_param -P -d $cksum_param ||
10532 error "failed to delete checksum on MGS"
10534 for opt in "checksum" "nochecksum"; do
10535 #remount with mount option
10536 echo "remount client with option $opt, checksum should be $i"
10537 umount_client $MOUNT || error "failed to umount client"
10538 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
10539 error "failed to mount client with option '$opt'"
10540 checksum=$(eval $get_checksum)
10541 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10545 remount_client $MOUNT || error "failed to remount client"
10547 run_test 77k "enable/disable checksum correctly"
10550 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10551 $GSS && skip_env "could not run with gss"
10554 stack_trap "set_checksums $ORIG_CSUM" EXIT
10555 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10557 set_checksum_type invalid && error "unexpected success of invalid checksum type"
10559 $LFS setstripe -c 1 -i 0 $DIR/$tfile
10560 for algo in $CKSUM_TYPES; do
10561 set_checksum_type $algo || error "fail to set checksum type $algo"
10562 osc_algo=$(get_osc_checksum_type OST0000)
10563 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
10565 # no locks, no reqs to let the connection idle
10566 cancel_lru_locks osc
10567 lru_resize_disable osc
10568 wait_osc_import_state client ost1 IDLE
10570 # ensure ost1 is connected
10571 stat $DIR/$tfile >/dev/null || error "can't stat"
10572 wait_osc_import_state client ost1 FULL
10574 osc_algo=$(get_osc_checksum_type OST0000)
10575 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
10579 run_test 77l "preferred checksum type is remembered after reconnected"
10581 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
10586 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
10587 skip "Need at least version 2.14.52"
10588 local param=checksum_speed
10590 $LCTL get_param $param || error "reading $param failed"
10592 csum_speeds=$($LCTL get_param -n $param)
10594 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
10595 error "known checksum types are missing"
10597 run_test 77m "Verify checksum_speed is correctly read"
10599 check_filefrag_77n() {
10604 while read extidx a b start end rest; do
10605 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
10606 nr_ext=$(( $nr_ext + 1 ))
10607 starts+=( ${start%..} )
10610 done < <( filefrag -sv $1 )
10612 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
10617 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
10620 $TRUNCATE $DIR/$tfile 0
10621 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
10622 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
10623 check_filefrag_77n $DIR/$tfile ||
10624 skip "$tfile blocks not contiguous around hole"
10627 stack_trap "set_checksums $ORIG_CSUM" EXIT
10628 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10629 stack_trap "rm -f $DIR/$tfile"
10631 for algo in $CKSUM_TYPES; do
10632 if [[ "$algo" =~ ^t10 ]]; then
10633 set_checksum_type $algo ||
10634 error "fail to set checksum type $algo"
10635 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
10636 error "fail to read $tfile with $algo"
10642 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
10645 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
10646 skip "Need MDS version at least 2.14.55"
10647 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
10648 skip "Need OST version at least 2.14.55"
10649 local ofd=obdfilter
10652 # print OST checksum_type
10653 echo "$ofd.$FSNAME-*.checksum_type:"
10654 do_nodes $(comma_list $(osts_nodes)) \
10655 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type
10657 # print MDT checksum_type
10658 echo "$mdt.$FSNAME-*.checksum_type:"
10659 do_nodes $(comma_list $(mdts_nodes)) \
10660 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type
10662 local o_count=$(do_nodes $(comma_list $(osts_nodes)) \
10663 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l)
10665 (( $o_count == $OSTCOUNT )) ||
10666 error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT"
10668 local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \
10669 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l)
10671 (( $m_count == $MDSCOUNT )) ||
10672 error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT"
10674 run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))"
10676 cleanup_test_78() {
10681 test_78() { # bug 10901
10682 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10683 remote_ost || skip_env "local OST"
10686 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
10687 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
10688 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
10689 echo "MemTotal: $MEMTOTAL"
10691 # reserve 256MB of memory for the kernel and other running processes,
10692 # and then take 1/2 of the remaining memory for the read/write buffers.
10693 if [ $MEMTOTAL -gt 512 ] ;then
10694 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
10696 # for those poor memory-starved high-end clusters...
10697 MEMTOTAL=$((MEMTOTAL / 2))
10699 echo "Mem to use for directio: $MEMTOTAL"
10701 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
10702 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
10703 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
10704 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
10706 echo "Smallest OST: $SMALLESTOST"
10707 [[ $SMALLESTOST -lt 10240 ]] &&
10708 skip "too small OSTSIZE, useless to run large O_DIRECT test"
10710 trap cleanup_test_78 EXIT
10712 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
10713 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
10715 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
10716 echo "File size: $F78SIZE"
10717 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
10718 for i in $(seq 1 $NSEQ); do
10719 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
10720 echo directIO rdwr round $i of $NSEQ
10721 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
10726 run_test 78 "handle large O_DIRECT writes correctly ============"
10728 test_79() { # bug 12743
10729 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10731 wait_delete_completed
10733 BKTOTAL=$(calc_osc_kbytes kbytestotal)
10734 BKFREE=$(calc_osc_kbytes kbytesfree)
10735 BKAVAIL=$(calc_osc_kbytes kbytesavail)
10737 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
10738 DFTOTAL=`echo $STRING | cut -d, -f1`
10739 DFUSED=`echo $STRING | cut -d, -f2`
10740 DFAVAIL=`echo $STRING | cut -d, -f3`
10741 DFFREE=$(($DFTOTAL - $DFUSED))
10743 ALLOWANCE=$((64 * $OSTCOUNT))
10745 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
10746 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
10747 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
10749 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
10750 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
10751 error "df free($DFFREE) mismatch OST free($BKFREE)"
10753 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
10754 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
10755 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
10758 run_test 79 "df report consistency check ======================="
10760 test_80() { # bug 10718
10761 remote_ost_nodsh && skip "remote OST with nodsh"
10762 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10764 # relax strong synchronous semantics for slow backends like ZFS
10765 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
10766 local soc="obdfilter.*.sync_lock_cancel"
10767 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10769 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
10770 if [ -z "$save" ]; then
10771 soc="obdfilter.*.sync_on_lock_cancel"
10772 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10775 if [ "$save" != "never" ]; then
10776 local hosts=$(comma_list $(osts_nodes))
10778 do_nodes $hosts $LCTL set_param $soc=never
10779 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
10783 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
10784 sync; sleep 1; sync
10785 local before=$(date +%s)
10786 cancel_lru_locks osc
10787 local after=$(date +%s)
10788 local diff=$((after - before))
10789 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
10793 run_test 80 "Page eviction is equally fast at high offsets too"
10795 test_81a() { # LU-456
10796 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10797 remote_ost_nodsh && skip "remote OST with nodsh"
10799 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10800 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
10801 do_facet ost1 lctl set_param fail_loc=0x80000228
10803 # write should trigger a retry and success
10804 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10805 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10807 if [ $RC -ne 0 ] ; then
10808 error "write should success, but failed for $RC"
10811 run_test 81a "OST should retry write when get -ENOSPC ==============="
10813 test_81b() { # LU-456
10814 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10815 remote_ost_nodsh && skip "remote OST with nodsh"
10817 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10818 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
10819 do_facet ost1 lctl set_param fail_loc=0x228
10821 # write should retry several times and return -ENOSPC finally
10822 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10823 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10826 if [ $RC -ne $ENOSPC ] ; then
10827 error "dd should fail for -ENOSPC, but succeed."
10830 run_test 81b "OST should return -ENOSPC when retry still fails ======="
10833 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
10835 test_mkdir $DIR/$tdir.cvsroot
10836 chown $RUNAS_ID $DIR/$tdir.cvsroot
10839 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
10842 # some versions of cvs import exit(1) when asked to import links or
10843 # files they can't read. ignore those files.
10844 local toignore=$(find . -type l -printf '-I %f\n' -o \
10845 ! -perm /4 -printf '-I %f\n')
10846 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
10847 $tdir.reposname vtag rtag
10850 test_mkdir $DIR/$tdir.reposname
10851 chown $RUNAS_ID $DIR/$tdir.reposname
10852 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
10854 cd $DIR/$tdir.reposname
10856 $RUNAS cvs add -m 'addmsg' foo99
10858 $RUNAS cvs commit -m 'nomsg' foo99
10859 rm -fr $DIR/$tdir.cvsroot
10861 run_test 99 "cvs strange file/directory operations"
10864 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10865 [[ "$NETTYPE" =~ tcp ]] ||
10866 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
10867 remote_ost_nodsh && skip "remote OST with nodsh"
10868 remote_mds_nodsh && skip "remote MDS with nodsh"
10870 skip "useless for local single node setup"
10872 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
10873 [ "$PROT" != "tcp" ] && continue
10874 RPORT=$(echo $REMOTE | cut -d: -f2)
10875 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
10878 LPORT=`echo $LOCAL | cut -d: -f2`
10879 if [ $LPORT -ge 1024 ]; then
10880 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
10882 error_exit "local: $LPORT > 1024, remote: $RPORT"
10885 [ "$rc" = 0 ] || error_exit "privileged port not found" )
10887 run_test 100 "check local port using privileged port ==========="
10889 function get_named_value()
10893 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
10896 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
10897 awk '/^max_cached_mb/ { print $2 }')
10900 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
10905 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10910 local cache_limit=32
10912 $LCTL set_param -n osc.*-osc*.rpc_stats=0
10913 trap cleanup_101a EXIT
10914 $LCTL set_param -n llite.*.read_ahead_stats=0
10915 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
10918 # randomly read 10000 of 64K chunks from file 3x 32MB in size
10920 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
10921 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
10924 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
10925 get_named_value 'read.but.discarded'); do
10926 discard=$(($discard + $s))
10930 $LCTL get_param osc.*-osc*.rpc_stats
10931 $LCTL get_param llite.*.read_ahead_stats
10933 # Discard is generally zero, but sometimes a few random reads line up
10934 # and trigger larger readahead, which is wasted & leads to discards.
10935 if [[ $(($discard)) -gt $nreads ]]; then
10936 error "too many ($discard) discarded pages"
10938 rm -f $DIR/$tfile || true
10940 run_test 101a "check read-ahead for random reads"
10942 setup_test101bc() {
10943 test_mkdir $DIR/$tdir
10945 local FILE_LENGTH=$2
10948 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
10950 local list=$(comma_list $(osts_nodes))
10951 set_osd_param $list '' read_cache_enable 0
10952 set_osd_param $list '' writethrough_cache_enable 0
10954 trap cleanup_test101bc EXIT
10955 # prepare the read-ahead file
10956 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
10958 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
10959 count=$FILE_SIZE_MB 2> /dev/null
10963 cleanup_test101bc() {
10968 local list=$(comma_list $(osts_nodes))
10969 set_osd_param $list '' read_cache_enable 1
10970 set_osd_param $list '' writethrough_cache_enable 1
10974 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
10979 local stripe_size=$2
10980 local stride_length=$((stripe_size / read_size))
10981 local stride_width=$((stride_length * OSTCOUNT))
10982 local discard_limit=$(( ((stride_length - 1) * 3 / stride_width) *
10983 (stride_width - stride_length) ))
10984 local discard=$($LCTL get_param -n llite.*.read_ahead_stats |
10985 get_named_value 'read.but.discarded' | calc_total)
10987 if [[ $discard -gt $discard_limit ]]; then
10988 $LCTL get_param llite.*.read_ahead_stats
10989 error "($discard limit ${discard_limit}) discarded pages with size (${read_size})"
10991 echo "Read-ahead success for size ${read_size}"
10996 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10997 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10999 local STRIPE_SIZE=1048576
11000 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
11002 if [ $SLOW == "yes" ]; then
11003 local FILE_LENGTH=$((STRIDE_SIZE * 64))
11005 local FILE_LENGTH=$((STRIDE_SIZE * 8))
11008 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
11010 # prepare the read-ahead file
11011 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
11012 cancel_lru_locks osc
11013 for BIDX in 2 4 8 16 32 64 128 256
11015 local BSIZE=$((BIDX*4096))
11016 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
11017 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
11018 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
11019 $LCTL set_param -n llite.*.read_ahead_stats=0
11020 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
11021 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
11022 cancel_lru_locks osc
11023 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
11028 run_test 101b "check stride-io mode read-ahead ================="
11031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11033 local STRIPE_SIZE=1048576
11034 local FILE_LENGTH=$((STRIPE_SIZE*100))
11037 local osc_rpc_stats
11039 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
11041 cancel_lru_locks osc
11042 $LCTL set_param osc.*.rpc_stats=0
11043 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
11044 $LCTL get_param osc.*.rpc_stats
11045 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
11046 local stats=$($LCTL get_param -n $osc_rpc_stats)
11047 local lines=$(echo "$stats" | awk 'END {print NR;}')
11050 if [ $lines -le 20 ]; then
11051 echo "continue debug"
11054 for size in 1 2 4 8; do
11055 local rpc=$(echo "$stats" |
11056 awk '($1 == "'$size':") {print $2; exit; }')
11057 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
11058 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
11060 echo "$osc_rpc_stats check passed!"
11065 run_test 101c "check stripe_size aligned read-ahead"
11068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11070 local file=$DIR/$tfile
11071 local sz_MB=${FILESIZE_101d:-80}
11072 local ra_MB=${READAHEAD_MB:-40}
11074 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
11075 [ $free_MB -lt $sz_MB ] &&
11076 skip "Need free space ${sz_MB}M, have ${free_MB}M"
11078 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
11079 $LFS setstripe -c -1 $file || error "setstripe failed"
11081 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
11082 echo Cancel LRU locks on lustre client to flush the client cache
11083 cancel_lru_locks osc
11085 echo Disable read-ahead
11086 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
11087 $LCTL set_param -n llite.*.max_read_ahead_mb=0
11088 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
11089 $LCTL get_param -n llite.*.max_read_ahead_mb
11091 echo "Reading the test file $file with read-ahead disabled"
11092 local sz_KB=$((sz_MB * 1024 / 4))
11093 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
11094 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
11095 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
11096 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
11098 echo "Cancel LRU locks on lustre client to flush the client cache"
11099 cancel_lru_locks osc
11100 echo Enable read-ahead with ${ra_MB}MB
11101 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
11103 echo "Reading the test file $file with read-ahead enabled"
11104 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
11105 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
11107 echo "read-ahead disabled time read $raOFF"
11108 echo "read-ahead enabled time read $raON"
11111 wait_delete_completed
11113 # use awk for this check instead of bash because it handles decimals
11114 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
11115 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
11117 run_test 101d "file read with and without read-ahead enabled"
11120 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11122 local file=$DIR/$tfile
11123 local size_KB=500 #KB
11127 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
11128 local need_KB=$((count * size_KB))
11129 [[ $free_KB -le $need_KB ]] &&
11130 skip_env "Need free space $need_KB, have $free_KB"
11132 echo "Creating $count ${size_KB}K test files"
11133 for ((i = 0; i < $count; i++)); do
11134 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
11137 echo "Cancel LRU locks on lustre client to flush the client cache"
11138 cancel_lru_locks $OSC
11140 echo "Reset readahead stats"
11141 $LCTL set_param -n llite.*.read_ahead_stats=0
11143 for ((i = 0; i < $count; i++)); do
11144 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
11147 $LCTL get_param llite.*.max_cached_mb
11148 $LCTL get_param llite.*.read_ahead_stats
11149 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11150 get_named_value 'misses' | calc_total)
11152 for ((i = 0; i < $count; i++)); do
11153 rm -rf $file.$i 2>/dev/null
11156 #10000 means 20% reads are missing in readahead
11157 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
11159 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
11162 which iozone || skip_env "no iozone installed"
11164 local old_debug=$($LCTL get_param debug)
11165 old_debug=${old_debug#*=}
11166 $LCTL set_param debug="reada mmap"
11168 # create a test file
11169 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
11171 echo Cancel LRU locks on lustre client to flush the client cache
11172 cancel_lru_locks osc
11174 echo Reset readahead stats
11175 $LCTL set_param -n llite.*.read_ahead_stats=0
11177 echo mmap read the file with small block size
11178 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
11181 echo checking missing pages
11182 $LCTL get_param llite.*.read_ahead_stats
11183 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11184 get_named_value 'misses' | calc_total)
11186 $LCTL set_param debug="$old_debug"
11187 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
11190 run_test 101f "check mmap read performance"
11192 test_101g_brw_size_test() {
11194 local pages=$((mb * 1048576 / PAGE_SIZE))
11195 local file=$DIR/$tfile
11197 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
11198 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
11199 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
11200 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
11204 stack_trap "rm -f $file" EXIT
11205 $LCTL set_param -n osc.*.rpc_stats=0
11207 # 10 RPCs should be enough for the test
11209 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
11210 { error "dd write ${mb} MB blocks failed"; return 3; }
11211 cancel_lru_locks osc
11212 dd of=/dev/null if=$file bs=${mb}M count=$count ||
11213 { error "dd write ${mb} MB blocks failed"; return 4; }
11215 # calculate number of full-sized read and write RPCs
11216 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
11217 sed -n '/pages per rpc/,/^$/p' |
11218 awk '/'$pages':/ { reads += $2; writes += $6 }; \
11219 END { print reads,writes }'))
11220 # allow one extra full-sized read RPC for async readahead
11221 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
11222 { error "${rpcs[0]} != $count read RPCs"; return 5; }
11223 [[ ${rpcs[1]} == $count ]] ||
11224 { error "${rpcs[1]} != $count write RPCs"; return 6; }
11228 remote_ost_nodsh && skip "remote OST with nodsh"
11231 local osts=$(get_facets OST)
11232 local list=$(comma_list $(osts_nodes))
11233 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11234 local brw_size="obdfilter.*.brw_size"
11236 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11238 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
11240 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
11241 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
11242 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
11243 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
11244 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
11245 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
11247 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
11250 if [[ $orig_mb -lt 16 ]]; then
11251 save_lustre_params $osts "$brw_size" > $p
11252 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
11253 error "set 16MB RPC size failed"
11255 echo "remount client to enable new RPC size"
11256 remount_client $MOUNT || error "remount_client failed"
11259 test_101g_brw_size_test 16 || error "16MB RPC test failed"
11260 # should be able to set brw_size=12, but no rpc_stats for that
11261 test_101g_brw_size_test 8 || error "8MB RPC test failed"
11264 test_101g_brw_size_test 4 || error "4MB RPC test failed"
11266 if [[ $orig_mb -lt 16 ]]; then
11267 restore_lustre_params < $p
11268 remount_client $MOUNT || error "remount_client restore failed"
11271 rm -f $p $DIR/$tfile
11273 run_test 101g "Big bulk(4/16 MiB) readahead"
11276 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11278 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
11279 error "dd 70M file failed"
11280 echo Cancel LRU locks on lustre client to flush the client cache
11281 cancel_lru_locks osc
11283 echo "Reset readahead stats"
11284 $LCTL set_param -n llite.*.read_ahead_stats 0
11286 echo "Read 10M of data but cross 64M bundary"
11287 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
11288 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11289 get_named_value 'misses' | calc_total)
11290 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
11291 rm -f $p $DIR/$tfile
11293 run_test 101h "Readahead should cover current read window"
11296 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
11297 error "dd 10M file failed"
11299 local max_per_file_mb=$($LCTL get_param -n \
11300 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
11301 cancel_lru_locks osc
11302 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
11303 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
11304 error "set max_read_ahead_per_file_mb to 1 failed"
11306 echo "Reset readahead stats"
11307 $LCTL set_param llite.*.read_ahead_stats=0
11309 dd if=$DIR/$tfile of=/dev/null bs=2M
11311 $LCTL get_param llite.*.read_ahead_stats
11312 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11313 awk '/misses/ { print $2 }')
11314 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
11317 run_test 101i "allow current readahead to exceed reservation"
11320 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
11321 error "setstripe $DIR/$tfile failed"
11322 local file_size=$((1048576 * 16))
11323 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
11324 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
11326 echo Disable read-ahead
11327 $LCTL set_param -n llite.*.max_read_ahead_mb=0
11329 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
11330 for blk in $PAGE_SIZE 1048576 $file_size; do
11331 cancel_lru_locks osc
11332 echo "Reset readahead stats"
11333 $LCTL set_param -n llite.*.read_ahead_stats=0
11334 local count=$(($file_size / $blk))
11335 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
11336 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11337 get_named_value 'failed.to.fast.read' | calc_total)
11338 $LCTL get_param -n llite.*.read_ahead_stats
11339 [ $miss -eq $count ] || error "expected $count got $miss"
11342 rm -f $p $DIR/$tfile
11344 run_test 101j "A complete read block should be submitted when no RA"
11348 local file=$DIR/$tfile
11350 check_set_fallocate_or_skip
11352 $LCTL set_param -n llite.*.read_ahead_stats=0
11353 fallocate -l 16K $file || error "failed to fallocate $file"
11354 cancel_lru_locks osc
11355 $MULTIOP $file or1048576c
11356 $LCTL get_param llite.*.read_ahead_stats
11358 run_test 101k "read ahead for small file"
11361 test_mkdir $DIR/$tdir
11362 chown $RUNAS_ID $DIR/$tdir
11365 STRIPE_COUNT=$OSTCOUNT
11366 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
11368 trap cleanup_test102 EXIT
11370 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
11372 for num in 1 2 3 4; do
11373 for count in $(seq 1 $STRIPE_COUNT); do
11374 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
11375 local size=`expr $STRIPE_SIZE \* $num`
11376 local file=file"$num-$idx-$count"
11377 $1 $LFS setstripe -S $size -i $idx -c $count $file
11383 $1 tar cf $TMP/f102.tar $tdir --xattrs
11386 cleanup_test102() {
11388 rm -f $TMP/f102.tar
11389 rm -rf $DIR/d0.sanity/d102
11393 [ "$UID" != 0 ] && skip "must run as root"
11394 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
11395 skip_env "must have user_xattr"
11397 [ -z "$(which setfattr 2>/dev/null)" ] &&
11398 skip_env "could not find setfattr"
11400 local testfile=$DIR/$tfile
11403 echo "set/get xattr..."
11404 setfattr -n trusted.name1 -v value1 $testfile ||
11405 error "setfattr -n trusted.name1=value1 $testfile failed"
11406 getfattr -n trusted.name1 $testfile 2> /dev/null |
11407 grep "trusted.name1=.value1" ||
11408 error "$testfile missing trusted.name1=value1"
11410 setfattr -n user.author1 -v author1 $testfile ||
11411 error "setfattr -n user.author1=author1 $testfile failed"
11412 getfattr -n user.author1 $testfile 2> /dev/null |
11413 grep "user.author1=.author1" ||
11414 error "$testfile missing trusted.author1=author1"
11416 echo "listxattr..."
11417 setfattr -n trusted.name2 -v value2 $testfile ||
11418 error "$testfile unable to set trusted.name2"
11419 setfattr -n trusted.name3 -v value3 $testfile ||
11420 error "$testfile unable to set trusted.name3"
11421 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
11422 grep "trusted.name" | wc -l) -eq 3 ] ||
11423 error "$testfile missing 3 trusted.name xattrs"
11425 setfattr -n user.author2 -v author2 $testfile ||
11426 error "$testfile unable to set user.author2"
11427 setfattr -n user.author3 -v author3 $testfile ||
11428 error "$testfile unable to set user.author3"
11429 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
11430 grep "user.author" | wc -l) -eq 3 ] ||
11431 error "$testfile missing 3 user.author xattrs"
11433 echo "remove xattr..."
11434 setfattr -x trusted.name1 $testfile ||
11435 error "$testfile error deleting trusted.name1"
11436 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
11437 error "$testfile did not delete trusted.name1 xattr"
11439 setfattr -x user.author1 $testfile ||
11440 error "$testfile error deleting user.author1"
11441 echo "set lustre special xattr ..."
11442 $LFS setstripe -c1 $testfile
11443 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
11444 awk -F "=" '/trusted.lov/ { print $2 }' )
11445 setfattr -n "trusted.lov" -v $lovea $testfile ||
11446 error "$testfile doesn't ignore setting trusted.lov again"
11447 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
11448 error "$testfile allow setting invalid trusted.lov"
11451 run_test 102a "user xattr test =================================="
11453 check_102b_layout() {
11455 local testfile=$DIR/$tfile
11457 echo "test layout '$layout'"
11458 $LFS setstripe $layout $testfile || error "setstripe failed"
11459 $LFS getstripe -y $testfile
11461 echo "get/set/list trusted.lov xattr ..." # b=10930
11462 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
11463 [[ "$value" =~ "trusted.lov" ]] ||
11464 error "can't get trusted.lov from $testfile"
11465 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
11466 error "getstripe failed"
11468 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
11470 value=$(cut -d= -f2 <<<$value)
11471 # LU-13168: truncated xattr should fail if short lov_user_md header
11472 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
11473 lens="${#value}" || lens="$(seq 4 2 ${#value})"
11474 for len in $lens; do
11475 echo "setfattr $len $testfile.2"
11476 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
11477 [ $len -lt 66 ] && error "short xattr len=$len worked"
11479 local stripe_size=$($LFS getstripe -S $testfile.2)
11480 local stripe_count=$($LFS getstripe -c $testfile.2)
11481 [[ $stripe_size -eq 65536 ]] ||
11482 error "stripe size $stripe_size != 65536"
11483 [[ $stripe_count -eq $stripe_count_orig ]] ||
11484 error "stripe count $stripe_count != $stripe_count_orig"
11485 rm $testfile $testfile.2
11489 [ -z "$(which setfattr 2>/dev/null)" ] &&
11490 skip_env "could not find setfattr"
11491 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11493 # check plain layout
11494 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
11496 # and also check composite layout
11497 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
11500 run_test 102b "getfattr/setfattr for trusted.lov EAs"
11503 [ -z "$(which setfattr 2>/dev/null)" ] &&
11504 skip_env "could not find setfattr"
11505 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11507 # b10930: get/set/list lustre.lov xattr
11508 echo "get/set/list lustre.lov xattr ..."
11509 test_mkdir $DIR/$tdir
11510 chown $RUNAS_ID $DIR/$tdir
11511 local testfile=$DIR/$tdir/$tfile
11512 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
11513 error "setstripe failed"
11514 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
11515 error "getstripe failed"
11516 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
11517 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
11519 local testfile2=${testfile}2
11520 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
11521 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
11523 $RUNAS $MCREATE $testfile2
11524 $RUNAS setfattr -n lustre.lov -v $value $testfile2
11525 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
11526 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
11527 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
11528 [ $stripe_count -eq $STRIPECOUNT ] ||
11529 error "stripe count $stripe_count != $STRIPECOUNT"
11531 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
11533 compare_stripe_info1() {
11534 local stripe_index_all_zero=true
11536 for num in 1 2 3 4; do
11537 for count in $(seq 1 $STRIPE_COUNT); do
11538 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
11539 local size=$((STRIPE_SIZE * num))
11540 local file=file"$num-$offset-$count"
11541 stripe_size=$($LFS getstripe -S $PWD/$file)
11542 [[ $stripe_size -ne $size ]] &&
11543 error "$file: size $stripe_size != $size"
11544 stripe_count=$($LFS getstripe -c $PWD/$file)
11545 # allow fewer stripes to be created, ORI-601
11546 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
11547 error "$file: count $stripe_count != $count"
11548 stripe_index=$($LFS getstripe -i $PWD/$file)
11549 [[ $stripe_index -ne 0 ]] &&
11550 stripe_index_all_zero=false
11554 $stripe_index_all_zero &&
11555 error "all files are being extracted starting from OST index 0"
11559 have_xattrs_include() {
11560 tar --help | grep -q xattrs-include &&
11561 echo --xattrs-include="lustre.*"
11565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11566 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11568 XINC=$(have_xattrs_include)
11570 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11571 cd $DIR/$tdir/$tdir
11572 compare_stripe_info1
11574 run_test 102d "tar restore stripe info from tarfile,not keep osts"
11577 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11578 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11580 XINC=$(have_xattrs_include)
11582 test_mkdir $DIR/$tdir.restore
11584 tar cf - --xattrs $tdir | tar xf - \
11585 -C $DIR/$tdir.restore --xattrs $XINC
11586 cd $DIR/$tdir.restore/$tdir
11587 compare_stripe_info1
11589 run_test 102f "tar copy files, not keep osts"
11592 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
11593 skip "must have user_xattr"
11594 [ -z "$(which setfattr 2>/dev/null)" ] &&
11595 skip_env "could not find setfattr"
11596 [ -z "$(which getfattr 2>/dev/null)" ] &&
11597 skip_env "could not find getfattr"
11599 local xsize=${1:-1024} # in bytes
11600 local file=$DIR/$tfile
11601 local value="$(generate_string $xsize)"
11602 local xbig=trusted.big
11606 log "save $xbig on $file"
11607 if [ -z "$toobig" ]
11609 setfattr -n $xbig -v $value $file ||
11610 error "saving $xbig on $file failed"
11612 setfattr -n $xbig -v $value $file &&
11613 error "saving $xbig on $file succeeded"
11617 local orig=$(get_xattr_value $xbig $file)
11618 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
11620 local xsml=trusted.sml
11621 log "save $xsml on $file"
11622 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
11624 local new=$(get_xattr_value $xbig $file)
11625 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
11627 log "grow $xsml on $file"
11628 setfattr -n $xsml -v "$value" $file ||
11629 error "growing $xsml on $file failed"
11631 new=$(get_xattr_value $xbig $file)
11632 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
11633 log "$xbig still valid after growing $xsml"
11638 test_102h() { # bug 15777
11641 run_test 102h "grow xattr from inside inode to external block"
11644 large_xattr_enabled || skip_env "ea_inode feature disabled"
11646 echo "setting xattr of max xattr size: $(max_xattr_size)"
11647 grow_xattr $(max_xattr_size)
11649 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
11650 echo "This should fail:"
11651 grow_xattr $(($(max_xattr_size) + 10)) 1
11653 run_test 102ha "grow xattr from inside inode to external inode"
11655 test_102i() { # bug 17038
11656 [ -z "$(which getfattr 2>/dev/null)" ] &&
11657 skip "could not find getfattr"
11660 ln -s $DIR/$tfile $DIR/${tfile}link
11661 getfattr -n trusted.lov $DIR/$tfile ||
11662 error "lgetxattr on $DIR/$tfile failed"
11663 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
11664 grep -i "no such attr" ||
11665 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
11666 rm -f $DIR/$tfile $DIR/${tfile}link
11668 run_test 102i "lgetxattr test on symbolic link ============"
11671 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11672 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11674 XINC=$(have_xattrs_include)
11675 setup_test102 "$RUNAS"
11676 chown $RUNAS_ID $DIR/$tdir
11677 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11678 cd $DIR/$tdir/$tdir
11679 compare_stripe_info1 "$RUNAS"
11681 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
11684 [ -z "$(which setfattr 2>/dev/null)" ] &&
11685 skip "could not find setfattr"
11688 # b22187 just check that does not crash for regular file.
11689 setfattr -n trusted.lov $DIR/$tfile
11690 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
11691 local test_kdir=$DIR/$tdir
11692 test_mkdir $test_kdir
11693 local default_size=$($LFS getstripe -S $test_kdir)
11694 local default_count=$($LFS getstripe -c $test_kdir)
11695 local default_offset=$($LFS getstripe -i $test_kdir)
11696 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
11697 error 'dir setstripe failed'
11698 setfattr -n trusted.lov $test_kdir
11699 local stripe_size=$($LFS getstripe -S $test_kdir)
11700 local stripe_count=$($LFS getstripe -c $test_kdir)
11701 local stripe_offset=$($LFS getstripe -i $test_kdir)
11702 [ $stripe_size -eq $default_size ] ||
11703 error "stripe size $stripe_size != $default_size"
11704 [ $stripe_count -eq $default_count ] ||
11705 error "stripe count $stripe_count != $default_count"
11706 [ $stripe_offset -eq $default_offset ] ||
11707 error "stripe offset $stripe_offset != $default_offset"
11708 rm -rf $DIR/$tfile $test_kdir
11710 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
11713 [ -z "$(which getfattr 2>/dev/null)" ] &&
11714 skip "could not find getfattr"
11716 # LU-532 trusted. xattr is invisible to non-root
11717 local testfile=$DIR/$tfile
11721 echo "listxattr as user..."
11722 chown $RUNAS_ID $testfile
11723 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
11724 grep -q "trusted" &&
11725 error "$testfile trusted xattrs are user visible"
11729 run_test 102l "listxattr size test =================================="
11731 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
11732 local path=$DIR/$tfile
11735 listxattr_size_check $path || error "listattr_size_check $path failed"
11737 run_test 102m "Ensure listxattr fails on small bufffer ========"
11741 getxattr() { # getxattr path name
11742 # Return the base64 encoding of the value of xattr name on path.
11746 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
11748 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11750 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11752 getfattr --absolute-names --encoding=base64 --name=$name $path |
11753 awk -F= -v name=$name '$1 == name {
11754 print substr($0, index($0, "=") + 1);
11758 test_102n() { # LU-4101 mdt: protect internal xattrs
11759 [ -z "$(which setfattr 2>/dev/null)" ] &&
11760 skip "could not find setfattr"
11761 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
11763 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
11766 local file0=$DIR/$tfile.0
11767 local file1=$DIR/$tfile.1
11768 local xattr0=$TMP/$tfile.0
11769 local xattr1=$TMP/$tfile.1
11770 local namelist="lov lma lmv link fid version som hsm"
11774 rm -rf $file0 $file1 $xattr0 $xattr1
11775 touch $file0 $file1
11777 # Get 'before' xattrs of $file1.
11778 getfattr --absolute-names --dump --match=- $file1 > $xattr0
11780 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
11781 namelist+=" lfsck_namespace"
11782 for name in $namelist; do
11783 # Try to copy xattr from $file0 to $file1.
11784 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11786 setfattr --name=trusted.$name --value="$value" $file1 ||
11787 error "setxattr 'trusted.$name' failed"
11789 # Try to set a garbage xattr.
11790 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11792 if [[ x$name == "xlov" ]]; then
11793 setfattr --name=trusted.lov --value="$value" $file1 &&
11794 error "setxattr invalid 'trusted.lov' success"
11796 setfattr --name=trusted.$name --value="$value" $file1 ||
11797 error "setxattr invalid 'trusted.$name' failed"
11800 # Try to remove the xattr from $file1. We don't care if this
11801 # appears to succeed or fail, we just don't want there to be
11802 # any changes or crashes.
11803 setfattr --remove=$trusted.$name $file1 2> /dev/null
11806 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
11809 # Try to copy xattr from $file0 to $file1.
11810 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11812 setfattr --name=trusted.$name --value="$value" $file1 ||
11813 error "setxattr 'trusted.$name' failed"
11815 # Try to set a garbage xattr.
11816 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11818 setfattr --name=trusted.$name --value="$value" $file1 ||
11819 error "setxattr 'trusted.$name' failed"
11821 # Try to remove the xattr from $file1. We don't care if this
11822 # appears to succeed or fail, we just don't want there to be
11823 # any changes or crashes.
11824 setfattr --remove=$trusted.$name $file1 2> /dev/null
11827 # Get 'after' xattrs of file1.
11828 getfattr --absolute-names --dump --match=- $file1 > $xattr1
11830 if ! diff $xattr0 $xattr1; then
11831 error "before and after xattrs of '$file1' differ"
11834 rm -rf $file0 $file1 $xattr0 $xattr1
11838 run_test 102n "silently ignore setxattr on internal trusted xattrs"
11840 test_102p() { # LU-4703 setxattr did not check ownership
11841 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
11842 skip "MDS needs to be at least 2.5.56"
11844 local testfile=$DIR/$tfile
11848 echo "setfacl as user..."
11849 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
11850 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
11852 echo "setfattr as user..."
11853 setfacl -m "u:$RUNAS_ID:---" $testfile
11854 $RUNAS setfattr -x system.posix_acl_access $testfile
11855 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
11857 run_test 102p "check setxattr(2) correctly fails without permission"
11860 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
11861 skip "MDS needs to be at least 2.6.92"
11863 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
11865 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
11868 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
11869 skip "MDS needs to be at least 2.6.93"
11871 touch $DIR/$tfile || error "touch"
11872 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
11873 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
11874 rm $DIR/$tfile || error "rm"
11877 mkdir -p $DIR/$tdir || error "mkdir"
11878 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11879 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11880 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11881 error "$testfile error deleting user.author1"
11882 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11883 grep "user.$(basename $tdir)" &&
11884 error "$tdir did not delete user.$(basename $tdir)"
11885 rmdir $DIR/$tdir || error "rmdir"
11888 test_mkdir $DIR/$tdir
11889 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11890 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11891 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11892 error "$testfile error deleting user.author1"
11893 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11894 grep "user.$(basename $tdir)" &&
11895 error "$tdir did not delete user.$(basename $tdir)"
11896 rmdir $DIR/$tdir || error "rm striped dir"
11898 run_test 102r "set EAs with empty values"
11901 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11902 skip "MDS needs to be at least 2.11.52"
11904 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11906 save_lustre_params client "llite.*.xattr_cache" > $save
11908 for cache in 0 1; do
11909 lctl set_param llite.*.xattr_cache=$cache
11912 touch $DIR/$tfile || error "touch"
11913 for prefix in lustre security system trusted user; do
11914 # Note getxattr() may fail with 'Operation not
11915 # supported' or 'No such attribute' depending
11916 # on prefix and cache.
11917 getfattr -n $prefix.n102s $DIR/$tfile &&
11918 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
11922 restore_lustre_params < $save
11924 run_test 102s "getting nonexistent xattrs should fail"
11927 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11928 skip "MDS needs to be at least 2.11.52"
11930 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11932 save_lustre_params client "llite.*.xattr_cache" > $save
11934 for cache in 0 1; do
11935 lctl set_param llite.*.xattr_cache=$cache
11937 for buf_size in 0 256; do
11939 touch $DIR/$tfile || error "touch"
11940 setfattr -n user.multiop $DIR/$tfile
11941 $MULTIOP $DIR/$tfile oa$buf_size ||
11942 error "cannot get zero length xattr value (buf_size = $buf_size)"
11946 restore_lustre_params < $save
11948 run_test 102t "zero length xattr values handled correctly"
11952 local test=$LUSTRE/tests/acl/$1.test
11953 local tmp=$(mktemp -t $1-XXXXXX).test
11961 local sedusers="-e s/bin/$bin/g -e s/daemon/$dmn/g"
11962 local sedgroups="-e s/:users/:$grp/g"
11963 [[ -z "$nbd" ]] || sedusers+=" -e s/nobody/$nbd/g"
11965 sed $sedusers $sedgroups < $test > $tmp
11966 stack_trap "rm -f $tmp"
11967 [[ -s $tmp ]] || error "sed failed to create test script"
11969 echo "performing $1 with bin='$bin' daemon='$dmn' users='$grp'..."
11970 $LUSTRE/tests/acl/run $tmp || error "run_acl_subtest '$1' failed"
11974 [ "$UID" != 0 ] && skip "must run as root"
11975 $GSS && skip_env "could not run under gss"
11976 [[ "$(lctl get_param -n mdc.*-mdc-*.connect_flags)" =~ "acl" ]] ||
11977 skip_env "must have acl enabled"
11978 which setfacl || skip_env "could not find setfacl"
11979 remote_mds_nodsh && skip "remote MDS with nodsh"
11981 ACLBIN=${ACLBIN:-"bin"}
11982 ACLDMN=${ACLDMN:-"daemon"}
11983 ACLGRP=${ACLGRP:-"users"}
11984 ACLNBD=${ACLNBD:-"nobody"}
11987 [[ "$(id -u $ACLBIN)" != "$(do_facet mds1 id -u $ACLBIN)" ]]; then
11988 echo "bad 'bin' user '$ACLBIN', using '$USER0'"
11990 if ! id $ACLBIN ; then
11992 skip_env "can't find suitable ACL 'bin' $ACLBIN"
11995 if ! id $ACLDMN || (( $(id -u $ACLDMN) < $(id -u $ACLBIN) )) ||
11996 [[ "$(id -u $ACLDMN)" != "$(do_facet mds1 id -u $ACLDMN)" ]]; then
11997 echo "bad 'daemon' user '$ACLDMN', using '$USER1'"
11999 if ! id $ACLDMN ; then
12001 skip_env "can't find suitable ACL 'daemon' $ACLDMN"
12004 if ! getent group $ACLGRP; then
12005 echo "missing 'users' group '$ACLGRP', using '$TSTUSR'"
12007 if ! getent group $ACLGRP; then
12008 echo "cannot find group '$ACLGRP', adding it"
12010 add_group 60000 $ACLGRP
12014 local bingid=$(getent group $ACLBIN | cut -d: -f 3)
12015 local dmngid=$(getent group $ACLDMN | cut -d: -f 3)
12016 local grpgid=$(getent group $ACLGRP | cut -d: -f 3)
12018 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
12019 echo "group '$ACLGRP' has low gid=$grpgid, use '$TSTUSR'"
12021 if ! getent group $ACLGRP; then
12022 echo "cannot find group '$ACLGRP', adding it"
12024 add_group 60000 $ACLGRP
12026 grpgid=$(getent group $ACLGRP | cut -d: -f 3)
12027 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
12029 skip_env "$ACLGRP gid=$grpgid less than $bingid|$dmngid"
12033 gpasswd -a $ACLDMN $ACLBIN ||
12034 error "setting client group failed" # LU-5641
12035 do_facet mds1 gpasswd -a $ACLDMN $ACLBIN ||
12036 error "setting MDS group failed" # LU-5641
12038 declare -a identity_old
12040 for num in $(seq $MDSCOUNT); do
12041 switch_identity $num true || identity_old[$num]=$?
12044 SAVE_UMASK=$(umask)
12046 mkdir -p $DIR/$tdir
12049 run_acl_subtest cp $ACLBIN $ACLDMN $ACLGRP
12050 run_acl_subtest getfacl-noacl $ACLBIN $ACLDMN $ACLGRP
12051 run_acl_subtest misc $ACLBIN $ACLDMN $ACLGRP
12052 run_acl_subtest permissions $ACLBIN $ACLDMN $ACLGRP
12053 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
12054 # CentOS7- uses nobody=99, while newer distros use nobody=65534
12055 if ! id -u $ACLNBD ||
12056 (( $(id -u nobody) != $(do_facet mds1 id -u nobody) )); then
12058 if ! id -u $ACLNBD; then
12062 if [[ -n "$ACLNBD" ]] && ! getent group $ACLNBD; then
12063 add_group $(id -u $ACLNBD) $ACLNBD
12064 if ! getent group $ACLNBD; then
12068 if (( $MDS1_VERSION > $(version_code 2.8.55) )) &&
12069 [[ -n "$ACLNBD" ]] && which setfattr; then
12070 run_acl_subtest permissions_xattr \
12071 $ACLBIN $ACLDMN $ACLGRP $ACLNBD
12072 elif [[ -z "$ACLNBD" ]]; then
12073 echo "skip 'permission_xattr' test - missing 'nobody' user/grp"
12075 echo "skip 'permission_xattr' test - missing setfattr command"
12077 run_acl_subtest setfacl $ACLBIN $ACLDMN $ACLGRP
12079 # inheritance test got from HP
12080 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
12081 chmod +x make-tree || error "chmod +x failed"
12082 run_acl_subtest inheritance $ACLBIN $ACLDMN $ACLGRP
12085 echo "LU-974 ignore umask when acl is enabled..."
12086 run_acl_subtest 974 $ACLBIN $ACLDMN $ACLGRP
12087 if [ $MDSCOUNT -ge 2 ]; then
12088 run_acl_subtest 974_remote $ACLBIN $ACLDMN $ACLGRP
12091 echo "LU-2561 newly created file is same size as directory..."
12092 if [ "$mds1_FSTYPE" != "zfs" ]; then
12093 run_acl_subtest 2561 $ACLBIN $ACLDMN $ACLGRP
12095 run_acl_subtest 2561_zfs $ACLBIN $ACLDMN $ACLGRP
12098 run_acl_subtest 4924 $ACLBIN $ACLDMN $ACLGRP
12103 for num in $(seq $MDSCOUNT); do
12104 if [ "${identity_old[$num]}" = 1 ]; then
12105 switch_identity $num false || identity_old[$num]=$?
12109 run_test 103a "acl test"
12115 for U in {0..511}; do
12117 local O=$(printf "%04o" $U)
12119 umask $(printf "%04o" $((511 ^ $O)))
12120 $LFS setstripe -c 1 $DIR/$tfile.s$O
12121 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
12123 (( $S == ($O & 0666) )) ||
12124 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
12126 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
12127 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
12128 (( $S == ($O & 0666) )) ||
12129 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
12131 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
12132 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
12133 (( $S == ($O & 0666) )) ||
12134 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
12135 rm -f $DIR/$tfile.[smp]$0
12139 # limit the concurrently running threads to 64. LU-11878
12140 local idx=$((U % 64))
12141 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
12146 run_test 103b "umask lfs setstripe"
12149 mkdir -p $DIR/$tdir
12150 cp -rp $DIR/$tdir $DIR/$tdir.bak
12152 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
12153 error "$DIR/$tdir shouldn't contain default ACL"
12154 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
12155 error "$DIR/$tdir.bak shouldn't contain default ACL"
12158 run_test 103c "'cp -rp' won't set empty acl"
12163 local saved_debug=$($LCTL get_param -n debug)
12165 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
12166 skip "MDS needs to be at least 2.14.52"
12168 large_xattr_enabled || skip_env "ea_inode feature disabled"
12170 mkdir -p $DIR/$tdir
12171 # add big LOV EA to cause reply buffer overflow earlier
12172 $LFS setstripe -C 1000 $DIR/$tdir
12173 lctl set_param mdc.*-mdc*.stats=clear
12175 $LCTL set_param debug=0
12176 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
12177 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
12179 # add a large number of default ACLs (expect 8000+ for 2.13+)
12180 for U in {2..7000}; do
12181 setfacl -d -m user:$U:rwx $DIR/$tdir ||
12182 error "Able to add just $U default ACLs"
12184 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
12185 echo "$numacl default ACLs created"
12187 stat $DIR/$tdir || error "Cannot stat directory"
12188 # check file creation
12189 touch $DIR/$tdir/$tfile ||
12190 error "failed to create $tfile with $numacl default ACLs"
12191 stat $DIR/$tdir/$tfile || error "Cannot stat file"
12192 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12193 echo "$fileacl ACLs were inherited"
12194 (( $fileacl == $numacl )) ||
12195 error "Not all default ACLs were inherited: $numacl != $fileacl"
12196 # check that new ACLs creation adds new ACLs to inherited ACLs
12197 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
12198 error "Cannot set new ACL"
12199 numacl=$((numacl + 1))
12200 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12201 (( $fileacl == $numacl )) ||
12202 error "failed to add new ACL: $fileacl != $numacl as expected"
12203 # adds more ACLs to a file to reach their maximum at 8000+
12205 for U in {20000..25000}; do
12206 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
12207 numacl=$((numacl + 1))
12209 echo "Added $numacl more ACLs to the file"
12210 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12211 echo "Total $fileacl ACLs in file"
12212 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
12213 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
12214 rmdir $DIR/$tdir || error "Cannot remove directory"
12216 run_test 103e "inheritance of big amount of default ACLs"
12219 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
12220 skip "MDS needs to be at least 2.14.51"
12222 large_xattr_enabled || skip_env "ea_inode feature disabled"
12224 # enable changelog to consume more internal MDD buffers
12227 mkdir -p $DIR/$tdir
12229 $LFS setstripe -C 1000 $DIR/$tdir
12230 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
12231 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
12232 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
12233 rmdir $DIR/$tdir || error "Cannot remove directory"
12235 run_test 103f "changelog doesn't interfere with default ACLs buffers"
12238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12241 lfs df || error "lfs df failed"
12242 lfs df -ih || error "lfs df -ih failed"
12243 lfs df -h $DIR || error "lfs df -h $DIR failed"
12244 lfs df -i $DIR || error "lfs df -i $DIR failed"
12245 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
12246 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
12248 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
12249 lctl --device %$OSC deactivate
12250 lfs df || error "lfs df with deactivated OSC failed"
12251 lctl --device %$OSC activate
12252 # wait the osc back to normal
12253 wait_osc_import_ready client ost
12255 lfs df || error "lfs df with reactivated OSC failed"
12258 run_test 104a "lfs df [-ih] [path] test ========================="
12261 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12262 [ $RUNAS_ID -eq $UID ] &&
12263 skip_env "RUNAS_ID = UID = $UID -- skipping"
12265 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
12266 grep "Permission denied" | wc -l)))
12267 if [ $denied_cnt -ne 0 ]; then
12268 error "lfs check servers test failed"
12271 run_test 104b "$RUNAS lfs check servers test ===================="
12274 # Verify $1 is within range of $2.
12275 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
12276 # $1 is <= 2% of $2. Else Fail.
12279 # Strip all units (M, G, T)
12280 actual=$(echo $1 | tr -d A-Z)
12281 expect=$(echo $2 | tr -d A-Z)
12283 expect_lo=$(($expect * 98 / 100)) # 2% below
12284 expect_hi=$(($expect * 102 / 100)) # 2% above
12286 # permit 2% drift above and below
12287 (( $actual >= $expect_lo && $actual <= $expect_hi ))
12291 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12292 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
12294 local ost_param="osd-zfs.$FSNAME-OST0000."
12295 local mdt_param="osd-zfs.$FSNAME-MDT0000."
12296 local ofacets=$(get_facets OST)
12297 local mfacets=$(get_facets MDS)
12298 local saved_ost_blocks=
12299 local saved_mdt_blocks=
12301 echo "Before recordsize change"
12302 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
12303 df=($(df -h | grep "$MOUNT"$))
12306 echo "lfs output : ${lfs_df[*]}"
12307 echo "df output : ${df[*]}"
12309 for facet in ${ofacets//,/ }; do
12310 if [ -z $saved_ost_blocks ]; then
12311 saved_ost_blocks=$(do_facet $facet \
12312 lctl get_param -n $ost_param.blocksize)
12313 echo "OST Blocksize: $saved_ost_blocks"
12315 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12316 do_facet $facet zfs set recordsize=32768 $ost
12319 # BS too small. Sufficient for functional testing.
12320 for facet in ${mfacets//,/ }; do
12321 if [ -z $saved_mdt_blocks ]; then
12322 saved_mdt_blocks=$(do_facet $facet \
12323 lctl get_param -n $mdt_param.blocksize)
12324 echo "MDT Blocksize: $saved_mdt_blocks"
12326 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12327 do_facet $facet zfs set recordsize=32768 $mdt
12330 # Give new values chance to reflect change
12333 echo "After recordsize change"
12334 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
12335 df_after=($(df -h | grep "$MOUNT"$))
12338 echo "lfs output : ${lfs_df_after[*]}"
12339 echo "df output : ${df_after[*]}"
12342 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
12343 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
12344 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
12345 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
12346 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
12347 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
12350 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
12351 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
12352 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
12353 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
12354 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
12355 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
12357 # Restore MDT recordize back to original
12358 for facet in ${mfacets//,/ }; do
12359 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12360 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
12363 # Restore OST recordize back to original
12364 for facet in ${ofacets//,/ }; do
12365 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12366 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
12371 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
12374 (( $RUNAS_ID != $UID )) ||
12375 skip_env "RUNAS_ID = UID = $UID -- skipping"
12377 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
12378 skip "lustre version doesn't support lctl dl with non-root"
12380 # debugfs only allows root users to access files, so the
12381 # previous move of the "devices" file to debugfs broke
12382 # "lctl dl" for non-root users. The LU-9680 Netlink
12383 # interface again allows non-root users to list devices.
12384 [ "$($RUNAS $LCTL dl | wc -l)" -ge 3 ] ||
12385 error "lctl dl doesn't work for non root"
12387 ost_count="$($RUNAS $LCTL dl | grep $FSNAME-OST* | wc -l)"
12388 [ "$ost_count" -eq $OSTCOUNT ] ||
12389 error "lctl dl reports wrong number of OST devices"
12391 mdt_count="$($RUNAS $LCTL dl | grep $FSNAME-MDT* | wc -l)"
12392 [ "$mdt_count" -eq $MDSCOUNT ] ||
12393 error "lctl dl reports wrong number of MDT devices"
12395 run_test 104d "$RUNAS lctl dl test"
12398 # doesn't work on 2.4 kernels
12400 if $(flock_is_enabled); then
12401 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
12403 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
12407 run_test 105a "flock when mounted without -o flock test ========"
12411 if $(flock_is_enabled); then
12412 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
12414 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
12418 run_test 105b "fcntl when mounted without -o flock test ========"
12422 if $(flock_is_enabled); then
12423 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
12425 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
12429 run_test 105c "lockf when mounted without -o flock test"
12431 test_105d() { # bug 15924
12432 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12434 test_mkdir $DIR/$tdir
12435 flock_is_enabled || skip_env "mount w/o flock enabled"
12436 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
12437 $LCTL set_param fail_loc=0x80000315
12438 flocks_test 2 $DIR/$tdir
12440 run_test 105d "flock race (should not freeze) ========"
12442 test_105e() { # bug 22660 && 22040
12443 flock_is_enabled || skip_env "mount w/o flock enabled"
12446 flocks_test 3 $DIR/$tfile
12448 run_test 105e "Two conflicting flocks from same process"
12450 test_106() { #bug 10921
12451 test_mkdir $DIR/$tdir
12452 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
12453 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
12455 run_test 106 "attempt exec of dir followed by chown of that dir"
12458 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12466 local save_pattern=$(sysctl -n kernel.core_pattern)
12467 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
12468 sysctl -w kernel.core_pattern=$file
12469 sysctl -w kernel.core_uses_pid=0
12471 ulimit -c unlimited
12477 kill -s 11 $SLEEPPID
12479 if [ -e $file ]; then
12480 size=`stat -c%s $file`
12481 [ $size -eq 0 ] && error "Fail to create core file $file"
12483 error "Fail to create core file $file"
12486 sysctl -w kernel.core_pattern=$save_pattern
12487 sysctl -w kernel.core_uses_pid=$save_uses_pid
12490 run_test 107 "Coredump on SIG"
12493 test_mkdir $DIR/$tdir
12494 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
12495 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
12496 error "mkdir with 256 char should fail, but did not"
12497 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
12498 error "create with 255 char failed"
12499 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
12500 error "create with 256 char should fail, but did not"
12505 run_test 110 "filename length checking"
12507 test_116a() { # was previously test_116()
12508 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12509 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12510 remote_mds_nodsh && skip "remote MDS with nodsh"
12512 echo -n "Free space priority "
12513 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
12518 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
12519 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
12520 stack_trap simple_cleanup_common
12522 # Check if we need to generate uneven OSTs
12523 test_mkdir -p $DIR/$tdir/OST${MINI}
12524 local FILL=$((MINV / 4))
12525 local DIFF=$((MAXV - MINV))
12526 local DIFF2=$((DIFF * 100 / MINV))
12528 local threshold=$(do_facet $SINGLEMDS \
12529 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
12530 threshold=${threshold%%%}
12531 echo -n "Check for uneven OSTs: "
12532 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
12534 if [[ $DIFF2 -gt $threshold ]]; then
12536 echo "Don't need to fill OST$MINI"
12538 # generate uneven OSTs. Write 2% over the QOS threshold value
12540 DIFF=$((threshold - DIFF2 + 2))
12541 DIFF2=$((MINV * DIFF / 100))
12542 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
12543 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
12544 error "setstripe failed"
12545 DIFF=$((DIFF2 / 2048))
12547 while [ $i -lt $DIFF ]; do
12549 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
12550 bs=2M count=1 2>/dev/null
12559 DIFF=$((MAXV - MINV))
12560 DIFF2=$((DIFF * 100 / MINV))
12561 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
12562 if [ $DIFF2 -gt $threshold ]; then
12565 skip "QOS imbalance criteria not met"
12573 # now fill using QOS
12574 $LFS setstripe -c 1 $DIR/$tdir
12575 FILL=$((FILL / 200))
12576 if [ $FILL -gt 600 ]; then
12579 echo "writing $FILL files to QOS-assigned OSTs"
12581 while [ $i -lt $FILL ]; do
12583 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
12584 count=1 2>/dev/null
12587 echo "wrote $i 200k files"
12591 echo "Note: free space may not be updated, so measurements might be off"
12593 DIFF2=$((MAXV - MINV))
12594 echo "free space delta: orig $DIFF final $DIFF2"
12595 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
12596 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
12597 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
12598 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
12599 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
12600 if [[ $DIFF -gt 0 ]]; then
12601 FILL=$((DIFF2 * 100 / DIFF - 100))
12602 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
12605 # Figure out which files were written where
12606 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12607 awk '/'$MINI1': / {print $2; exit}')
12609 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12610 echo "$MINC files created on smaller OST $MINI1"
12611 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12612 awk '/'$MAXI1': / {print $2; exit}')
12614 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12615 echo "$MAXC files created on larger OST $MAXI1"
12616 if [[ $MINC -gt 0 ]]; then
12617 FILL=$((MAXC * 100 / MINC - 100))
12618 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
12620 [[ $MAXC -gt $MINC ]] ||
12621 error_ignore LU-9 "stripe QOS didn't balance free space"
12623 run_test 116a "stripe QOS: free space balance ==================="
12625 test_116b() { # LU-2093
12626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12627 remote_mds_nodsh && skip "remote MDS with nodsh"
12629 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
12630 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
12631 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
12632 [ -z "$old_rr" ] && skip "no QOS"
12633 do_facet $SINGLEMDS lctl set_param \
12634 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
12635 mkdir -p $DIR/$tdir
12636 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
12637 createmany -o $DIR/$tdir/f- 20 || error "can't create"
12638 do_facet $SINGLEMDS lctl set_param fail_loc=0
12640 do_facet $SINGLEMDS lctl set_param \
12641 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
12643 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
12645 test_117() # bug 10891
12647 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12649 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
12650 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
12651 lctl set_param fail_loc=0x21e
12652 > $DIR/$tfile || error "truncate failed"
12653 lctl set_param fail_loc=0
12654 echo "Truncate succeeded."
12657 run_test 117 "verify osd extend =========="
12659 NO_SLOW_RESENDCOUNT=4
12660 export OLD_RESENDCOUNT=""
12661 set_resend_count () {
12662 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
12663 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
12664 lctl set_param -n $PROC_RESENDCOUNT $1
12665 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
12668 # for reduce test_118* time (b=14842)
12669 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12671 # Reset async IO behavior after error case
12673 FILE=$DIR/reset_async
12675 # Ensure all OSCs are cleared
12676 $LFS setstripe -c -1 $FILE
12677 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
12682 test_118a() #bug 11710
12684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12688 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12689 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12690 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12692 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12693 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12698 run_test 118a "verify O_SYNC works =========="
12702 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12703 remote_ost_nodsh && skip "remote OST with nodsh"
12707 #define OBD_FAIL_SRV_ENOENT 0x217
12708 set_nodes_failloc "$(osts_nodes)" 0x217
12709 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12711 set_nodes_failloc "$(osts_nodes)" 0
12712 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12713 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12716 if [[ $RC -eq 0 ]]; then
12717 error "Must return error due to dropped pages, rc=$RC"
12721 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12722 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12726 echo "Dirty pages not leaked on ENOENT"
12728 # Due to the above error the OSC will issue all RPCs syncronously
12729 # until a subsequent RPC completes successfully without error.
12730 $MULTIOP $DIR/$tfile Ow4096yc
12735 run_test 118b "Reclaim dirty pages on fatal error =========="
12739 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12741 # for 118c, restore the original resend count, LU-1940
12742 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
12743 set_resend_count $OLD_RESENDCOUNT
12744 remote_ost_nodsh && skip "remote OST with nodsh"
12748 #define OBD_FAIL_OST_EROFS 0x216
12749 set_nodes_failloc "$(osts_nodes)" 0x216
12751 # multiop should block due to fsync until pages are written
12752 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12756 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12757 error "Multiop failed to block on fsync, pid=$MULTIPID"
12760 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12762 if [[ $WRITEBACK -eq 0 ]]; then
12763 error "No page in writeback, writeback=$WRITEBACK"
12766 set_nodes_failloc "$(osts_nodes)" 0
12769 if [[ $RC -ne 0 ]]; then
12770 error "Multiop fsync failed, rc=$RC"
12773 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12774 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12776 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12777 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12781 echo "Dirty pages flushed via fsync on EROFS"
12784 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
12786 # continue to use small resend count to reduce test_118* time (b=14842)
12787 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12792 remote_ost_nodsh && skip "remote OST with nodsh"
12796 #define OBD_FAIL_OST_BRW_PAUSE_BULK
12797 set_nodes_failloc "$(osts_nodes)" 0x214
12798 # multiop should block due to fsync until pages are written
12799 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12803 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12804 error "Multiop failed to block on fsync, pid=$MULTIPID"
12807 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12809 if [[ $WRITEBACK -eq 0 ]]; then
12810 error "No page in writeback, writeback=$WRITEBACK"
12813 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
12814 set_nodes_failloc "$(osts_nodes)" 0
12816 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12817 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12819 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12820 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12824 echo "Dirty pages gaurenteed flushed via fsync"
12827 run_test 118d "Fsync validation inject a delay of the bulk =========="
12830 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12834 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
12835 lctl set_param fail_loc=0x8000040a
12837 # Should simulate EINVAL error which is fatal
12838 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12840 if [[ $RC -eq 0 ]]; then
12841 error "Must return error due to dropped pages, rc=$RC"
12844 lctl set_param fail_loc=0x0
12846 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12847 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12848 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12850 if [[ $LOCKED -ne 0 ]]; then
12851 error "Locked pages remain in cache, locked=$LOCKED"
12854 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12855 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12859 echo "No pages locked after fsync"
12864 run_test 118f "Simulate unrecoverable OSC side error =========="
12867 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12871 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
12872 lctl set_param fail_loc=0x406
12874 # simulate local -ENOMEM
12875 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12878 lctl set_param fail_loc=0
12879 if [[ $RC -eq 0 ]]; then
12880 error "Must return error due to dropped pages, rc=$RC"
12883 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12884 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12885 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12887 if [[ $LOCKED -ne 0 ]]; then
12888 error "Locked pages remain in cache, locked=$LOCKED"
12891 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12892 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12896 echo "No pages locked after fsync"
12901 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
12904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12905 remote_ost_nodsh && skip "remote OST with nodsh"
12909 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12910 set_nodes_failloc "$(osts_nodes)" 0x20e
12911 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12912 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12915 set_nodes_failloc "$(osts_nodes)" 0
12916 if [[ $RC -eq 0 ]]; then
12917 error "Must return error due to dropped pages, rc=$RC"
12920 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12921 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12922 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12924 if [[ $LOCKED -ne 0 ]]; then
12925 error "Locked pages remain in cache, locked=$LOCKED"
12928 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12929 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12933 echo "No pages locked after fsync"
12937 run_test 118h "Verify timeout in handling recoverables errors =========="
12939 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12942 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12943 remote_ost_nodsh && skip "remote OST with nodsh"
12947 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12948 set_nodes_failloc "$(osts_nodes)" 0x20e
12950 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12951 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12954 set_nodes_failloc "$(osts_nodes)" 0
12958 if [[ $RC -ne 0 ]]; then
12959 error "got error, but should be not, rc=$RC"
12962 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12963 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12964 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12965 if [[ $LOCKED -ne 0 ]]; then
12966 error "Locked pages remain in cache, locked=$LOCKED"
12969 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12970 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12974 echo "No pages locked after fsync"
12978 run_test 118i "Fix error before timeout in recoverable error =========="
12980 [ "$SLOW" = "no" ] && set_resend_count 4
12983 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12984 remote_ost_nodsh && skip "remote OST with nodsh"
12988 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
12989 set_nodes_failloc "$(osts_nodes)" 0x220
12991 # return -EIO from OST
12992 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12994 set_nodes_failloc "$(osts_nodes)" 0x0
12995 if [[ $RC -eq 0 ]]; then
12996 error "Must return error due to dropped pages, rc=$RC"
12999 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13000 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13001 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
13002 if [[ $LOCKED -ne 0 ]]; then
13003 error "Locked pages remain in cache, locked=$LOCKED"
13006 # in recoverable error on OST we want resend and stay until it finished
13007 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13008 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13012 echo "No pages locked after fsync"
13016 run_test 118j "Simulate unrecoverable OST side error =========="
13020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13021 remote_ost_nodsh && skip "remote OSTs with nodsh"
13023 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
13024 set_nodes_failloc "$(osts_nodes)" 0x20e
13025 test_mkdir $DIR/$tdir
13027 for ((i=0;i<10;i++)); do
13028 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
13029 error "dd to $DIR/$tdir/$tfile-$i failed" )&
13036 set_nodes_failloc "$(osts_nodes)" 0
13039 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
13041 test_118l() # LU-646
13043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13045 test_mkdir $DIR/$tdir
13046 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
13049 run_test 118l "fsync dir"
13051 test_118m() # LU-3066
13053 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13055 test_mkdir $DIR/$tdir
13056 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
13059 run_test 118m "fdatasync dir ========="
13061 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
13068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13069 remote_ost_nodsh && skip "remote OSTs with nodsh"
13071 # Sleep to avoid a cached response.
13072 #define OBD_STATFS_CACHE_SECONDS 1
13075 # Inject a 10 second delay in the OST_STATFS handler.
13076 #define OBD_FAIL_OST_STATFS_DELAY 0x242
13077 set_nodes_failloc "$(osts_nodes)" 0x242
13080 stat --file-system $MOUNT > /dev/null
13083 set_nodes_failloc "$(osts_nodes)" 0
13085 if ((end - begin > 20)); then
13086 error "statfs took $((end - begin)) seconds, expected 10"
13089 run_test 118n "statfs() sends OST_STATFS requests in parallel"
13091 test_119a() # bug 11737
13093 BSIZE=$((512 * 1024))
13094 directio write $DIR/$tfile 0 1 $BSIZE
13095 # We ask to read two blocks, which is more than a file size.
13096 # directio will indicate an error when requested and actual
13097 # sizes aren't equeal (a normal situation in this case) and
13098 # print actual read amount.
13099 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
13100 if [ "$NOB" != "$BSIZE" ]; then
13101 error "read $NOB bytes instead of $BSIZE"
13105 run_test 119a "Short directIO read must return actual read amount"
13107 test_119b() # bug 11737
13109 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13111 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
13112 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
13114 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
13115 error "direct read failed"
13118 run_test 119b "Sparse directIO read must return actual read amount"
13120 test_119c() # bug 13099
13123 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
13124 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
13127 run_test 119c "Testing for direct read hitting hole"
13129 test_119d() # bug 15950
13131 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13133 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
13134 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
13136 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
13137 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
13138 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
13139 lctl set_param fail_loc=0x40d
13140 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
13143 cat $DIR/$tfile > /dev/null &
13144 lctl set_param fail_loc=0
13147 log "the DIO writes have completed, now wait for the reads (should not block very long)"
13149 [ -n "`ps h -p $pid_reads -o comm`" ] && \
13150 error "the read rpcs have not completed in 2s"
13152 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
13154 run_test 119d "The DIO path should try to send a new rpc once one is completed"
13157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13158 remote_mds_nodsh && skip "remote MDS with nodsh"
13159 test_mkdir -i0 -c1 $DIR/$tdir
13160 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13161 skip_env "no early lock cancel on server"
13163 lru_resize_disable mdc
13164 lru_resize_disable osc
13165 cancel_lru_locks mdc
13166 # asynchronous object destroy at MDT could cause bl ast to client
13167 cancel_lru_locks osc
13169 stat $DIR/$tdir > /dev/null
13170 can1=$(do_facet mds1 \
13171 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13172 awk '/ldlm_cancel/ {print $2}')
13173 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13174 awk '/ldlm_bl_callback/ {print $2}')
13175 test_mkdir -i0 -c1 $DIR/$tdir/d1
13176 can2=$(do_facet mds1 \
13177 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13178 awk '/ldlm_cancel/ {print $2}')
13179 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13180 awk '/ldlm_bl_callback/ {print $2}')
13181 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13182 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13183 lru_resize_enable mdc
13184 lru_resize_enable osc
13186 run_test 120a "Early Lock Cancel: mkdir test"
13189 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13190 remote_mds_nodsh && skip "remote MDS with nodsh"
13191 test_mkdir $DIR/$tdir
13192 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13193 skip_env "no early lock cancel on server"
13195 lru_resize_disable mdc
13196 lru_resize_disable osc
13197 cancel_lru_locks mdc
13198 stat $DIR/$tdir > /dev/null
13199 can1=$(do_facet $SINGLEMDS \
13200 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13201 awk '/ldlm_cancel/ {print $2}')
13202 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13203 awk '/ldlm_bl_callback/ {print $2}')
13204 touch $DIR/$tdir/f1
13205 can2=$(do_facet $SINGLEMDS \
13206 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13207 awk '/ldlm_cancel/ {print $2}')
13208 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13209 awk '/ldlm_bl_callback/ {print $2}')
13210 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13211 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13212 lru_resize_enable mdc
13213 lru_resize_enable osc
13215 run_test 120b "Early Lock Cancel: create test"
13218 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13219 remote_mds_nodsh && skip "remote MDS with nodsh"
13220 test_mkdir -i0 -c1 $DIR/$tdir
13221 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13222 skip "no early lock cancel on server"
13224 lru_resize_disable mdc
13225 lru_resize_disable osc
13226 test_mkdir -i0 -c1 $DIR/$tdir/d1
13227 test_mkdir -i0 -c1 $DIR/$tdir/d2
13228 touch $DIR/$tdir/d1/f1
13229 cancel_lru_locks mdc
13230 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
13231 can1=$(do_facet mds1 \
13232 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13233 awk '/ldlm_cancel/ {print $2}')
13234 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13235 awk '/ldlm_bl_callback/ {print $2}')
13236 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13237 can2=$(do_facet mds1 \
13238 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13239 awk '/ldlm_cancel/ {print $2}')
13240 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13241 awk '/ldlm_bl_callback/ {print $2}')
13242 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13243 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13244 lru_resize_enable mdc
13245 lru_resize_enable osc
13247 run_test 120c "Early Lock Cancel: link test"
13250 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13251 remote_mds_nodsh && skip "remote MDS with nodsh"
13252 test_mkdir -i0 -c1 $DIR/$tdir
13253 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13254 skip_env "no early lock cancel on server"
13256 lru_resize_disable mdc
13257 lru_resize_disable osc
13259 cancel_lru_locks mdc
13260 stat $DIR/$tdir > /dev/null
13261 can1=$(do_facet mds1 \
13262 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13263 awk '/ldlm_cancel/ {print $2}')
13264 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13265 awk '/ldlm_bl_callback/ {print $2}')
13266 chmod a+x $DIR/$tdir
13267 can2=$(do_facet mds1 \
13268 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13269 awk '/ldlm_cancel/ {print $2}')
13270 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13271 awk '/ldlm_bl_callback/ {print $2}')
13272 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13273 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13274 lru_resize_enable mdc
13275 lru_resize_enable osc
13277 run_test 120d "Early Lock Cancel: setattr test"
13280 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13281 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13282 skip_env "no early lock cancel on server"
13283 remote_mds_nodsh && skip "remote MDS with nodsh"
13285 local dlmtrace_set=false
13287 test_mkdir -i0 -c1 $DIR/$tdir
13288 lru_resize_disable mdc
13289 lru_resize_disable osc
13290 ! $LCTL get_param debug | grep -q dlmtrace &&
13291 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
13292 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
13293 cancel_lru_locks mdc
13294 cancel_lru_locks osc
13295 dd if=$DIR/$tdir/f1 of=/dev/null
13296 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
13297 # XXX client can not do early lock cancel of OST lock
13298 # during unlink (LU-4206), so cancel osc lock now.
13300 cancel_lru_locks osc
13301 can1=$(do_facet mds1 \
13302 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13303 awk '/ldlm_cancel/ {print $2}')
13304 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13305 awk '/ldlm_bl_callback/ {print $2}')
13306 unlink $DIR/$tdir/f1
13308 can2=$(do_facet mds1 \
13309 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13310 awk '/ldlm_cancel/ {print $2}')
13311 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13312 awk '/ldlm_bl_callback/ {print $2}')
13313 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
13314 $LCTL dk $TMP/cancel.debug.txt
13315 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
13316 $LCTL dk $TMP/blocking.debug.txt
13317 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
13318 lru_resize_enable mdc
13319 lru_resize_enable osc
13321 run_test 120e "Early Lock Cancel: unlink test"
13324 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13325 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13326 skip_env "no early lock cancel on server"
13327 remote_mds_nodsh && skip "remote MDS with nodsh"
13329 test_mkdir -i0 -c1 $DIR/$tdir
13330 lru_resize_disable mdc
13331 lru_resize_disable osc
13332 test_mkdir -i0 -c1 $DIR/$tdir/d1
13333 test_mkdir -i0 -c1 $DIR/$tdir/d2
13334 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
13335 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
13336 cancel_lru_locks mdc
13337 cancel_lru_locks osc
13338 dd if=$DIR/$tdir/d1/f1 of=/dev/null
13339 dd if=$DIR/$tdir/d2/f2 of=/dev/null
13340 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
13341 # XXX client can not do early lock cancel of OST lock
13342 # during rename (LU-4206), so cancel osc lock now.
13344 cancel_lru_locks osc
13345 can1=$(do_facet mds1 \
13346 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13347 awk '/ldlm_cancel/ {print $2}')
13348 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13349 awk '/ldlm_bl_callback/ {print $2}')
13350 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13352 can2=$(do_facet mds1 \
13353 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13354 awk '/ldlm_cancel/ {print $2}')
13355 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13356 awk '/ldlm_bl_callback/ {print $2}')
13357 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13358 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13359 lru_resize_enable mdc
13360 lru_resize_enable osc
13362 run_test 120f "Early Lock Cancel: rename test"
13365 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13366 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13367 skip_env "no early lock cancel on server"
13368 remote_mds_nodsh && skip "remote MDS with nodsh"
13370 lru_resize_disable mdc
13371 lru_resize_disable osc
13373 echo create $count files
13374 test_mkdir $DIR/$tdir
13375 cancel_lru_locks mdc
13376 cancel_lru_locks osc
13379 can0=$(do_facet $SINGLEMDS \
13380 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13381 awk '/ldlm_cancel/ {print $2}')
13382 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13383 awk '/ldlm_bl_callback/ {print $2}')
13384 createmany -o $DIR/$tdir/f $count
13386 can1=$(do_facet $SINGLEMDS \
13387 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13388 awk '/ldlm_cancel/ {print $2}')
13389 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13390 awk '/ldlm_bl_callback/ {print $2}')
13392 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
13393 echo rm $count files
13396 can2=$(do_facet $SINGLEMDS \
13397 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13398 awk '/ldlm_cancel/ {print $2}')
13399 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13400 awk '/ldlm_bl_callback/ {print $2}')
13402 echo total: $count removes in $((t2-t1))
13403 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
13405 # wait for commitment of removal
13406 lru_resize_enable mdc
13407 lru_resize_enable osc
13409 run_test 120g "Early Lock Cancel: performance test"
13411 test_121() { #bug #10589
13412 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13415 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
13416 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
13417 lctl set_param fail_loc=0x310
13418 cancel_lru_locks osc > /dev/null
13419 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
13420 lctl set_param fail_loc=0
13421 [[ $reads -eq $writes ]] ||
13422 error "read $reads blocks, must be $writes blocks"
13424 run_test 121 "read cancel race ========="
13426 test_123a_base() { # was test 123, statahead(bug 11401)
13430 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
13431 log "testing UP system. Performance may be lower than expected."
13434 running_in_vm && SLOWOK=1
13437 test_mkdir $DIR/$tdir
13438 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
13439 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
13441 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
13442 createmany -o $DIR/$tdir/$tfile $j $((i - j))
13444 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
13445 lctl set_param -n llite.*.statahead_max 0
13446 lctl get_param llite.*.statahead_max
13447 cancel_lru_locks mdc
13448 cancel_lru_locks osc
13450 time $lsx $DIR/$tdir | wc -l
13452 delta=$((etime - stime))
13453 log "$lsx $i files without statahead: $delta sec"
13454 lctl set_param llite.*.statahead_max=$max
13456 swrong=$(lctl get_param -n llite.*.statahead_stats |
13457 awk '/statahead.wrong:/ { print $NF }')
13458 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
13459 cancel_lru_locks mdc
13460 cancel_lru_locks osc
13462 time $lsx $DIR/$tdir | wc -l
13464 delta_sa=$((etime - stime))
13465 log "$lsx $i files with statahead: $delta_sa sec"
13466 lctl get_param -n llite.*.statahead_stats
13467 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13468 awk '/statahead.wrong:/ { print $NF }')
13470 [[ $swrong -lt $ewrong ]] &&
13471 log "statahead was stopped, maybe too many locks held!"
13472 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
13474 if (( $delta_sa*100 > $delta*105 && $delta_sa > $delta+2)); then
13475 max=$(lctl get_param -n llite.*.statahead_max |
13477 lctl set_param -n llite.*.statahead_max 0
13478 lctl get_param llite.*.statahead_max
13479 cancel_lru_locks mdc
13480 cancel_lru_locks osc
13482 time $lsx $DIR/$tdir | wc -l
13484 delta=$((etime - stime))
13485 log "$lsx $i files again without statahead: $delta sec"
13486 lctl set_param llite.*.statahead_max=$max
13487 if (( $delta_sa*100 > delta*105 && delta_sa > delta+2 )); then
13488 if [ $SLOWOK -eq 0 ]; then
13489 error "$lsx $i files is slower with statahead!"
13491 log "$lsx $i files is slower with statahead!"
13497 [ $delta -gt 20 ] && break
13498 [ $delta -gt 8 ] && MULT=$((50 / delta))
13499 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
13507 delta=$((etime - stime))
13508 log "rm -r $DIR/$tdir/: $delta seconds"
13510 lctl get_param -n llite.*.statahead_stats
13514 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13516 test_123a_base "ls -l"
13518 run_test 123aa "verify statahead work"
13521 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13523 statx_supported || skip_env "Test must be statx() syscall supported"
13525 test_123a_base "$STATX -l"
13527 run_test 123ab "verify statahead work by using statx"
13530 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13532 statx_supported || skip_env "Test must be statx() syscall supported"
13539 cancel_lru_locks $OSC
13540 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13541 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
13542 awk '/agl.total:/ { print $NF }')
13543 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
13544 test_123a_base "$STATX --cached=always -D"
13545 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
13546 awk '/agl.total:/ { print $NF }')
13547 [ $agl_before -eq $agl_after ] ||
13548 error "Should not trigger AGL thread - $agl_before:$agl_after"
13549 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13550 [ $rpcs_after -eq $rpcs_before ] ||
13551 error "$STATX should not send glimpse RPCs to $OSC"
13553 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
13555 test_123b () { # statahead(bug 15027)
13556 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13558 test_mkdir $DIR/$tdir
13559 createmany -o $DIR/$tdir/$tfile-%d 1000
13561 cancel_lru_locks mdc
13562 cancel_lru_locks osc
13564 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
13565 lctl set_param fail_loc=0x80000803
13566 ls -lR $DIR/$tdir > /dev/null
13568 lctl set_param fail_loc=0x0
13569 lctl get_param -n llite.*.statahead_stats
13574 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
13577 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
13579 test_mkdir -i 0 -c 1 $DIR/$tdir.0
13580 test_mkdir -i 1 -c 1 $DIR/$tdir.1
13581 touch $DIR/$tdir.1/{1..3}
13582 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
13584 remount_client $MOUNT
13586 $MULTIOP $DIR/$tdir.0 Q
13588 # let statahead to complete
13589 ls -l $DIR/$tdir.0 > /dev/null
13591 testid=$(echo $TESTNAME | tr '_' ' ')
13592 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
13593 error "statahead warning" || true
13595 run_test 123c "Can not initialize inode warning on DNE statahead"
13602 test_mkdir -c -1 $DIR/$tdir || error "test_mkdir $DIR/$tdir failed"
13603 $LFS setdirstripe -D -c $MDSCOUNT $DIR/$tdir ||
13604 error "setdirstripe $DIR/$tdir failed"
13605 createmany -d $DIR/$tdir/$tfile $num || error "createmany $num failed"
13606 remount_client $MOUNT
13607 $LCTL get_param llite.*.statahead_max
13608 $LCTL set_param llite.*.statahead_stats=0 ||
13609 error "clear statahead_stats failed"
13610 swrong=$(lctl get_param -n llite.*.statahead_stats |
13611 awk '/statahead.wrong:/ { print $NF }')
13612 ls -l $DIR/$tdir || error "ls -l $DIR/$tdir failed"
13613 # wait for statahead thread finished to update hit/miss stats.
13615 $LCTL get_param -n llite.*.statahead_stats
13616 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13617 awk '/statahead.wrong:/ { print $NF }')
13618 (( $swrong == $ewrong )) ||
13619 log "statahead was stopped, maybe too many locks held!"
13621 run_test 123d "Statahead on striped directories works correctly"
13624 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13625 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13626 skip_env "no lru resize on server"
13630 test_mkdir $DIR/$tdir
13632 log "create $NR files at $DIR/$tdir"
13633 createmany -o $DIR/$tdir/f $NR ||
13634 error "failed to create $NR files in $DIR/$tdir"
13636 cancel_lru_locks mdc
13637 ls -l $DIR/$tdir > /dev/null
13641 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
13642 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
13643 LRU_SIZE=$($LCTL get_param -n $PARAM)
13644 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
13645 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
13647 log "NS=$(basename $NSDIR)"
13652 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
13653 skip "Not enough cached locks created!"
13655 log "LRU=$LRU_SIZE"
13659 # We know that lru resize allows one client to hold $LIMIT locks
13660 # for 10h. After that locks begin to be killed by client.
13662 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
13664 if [ $LIMIT -lt $LRU_SIZE ]; then
13665 skip "Limit is too small $LIMIT"
13668 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
13669 # killing locks. Some time was spent for creating locks. This means
13670 # that up to the moment of sleep finish we must have killed some of
13671 # them (10-100 locks). This depends on how fast ther were created.
13672 # Many of them were touched in almost the same moment and thus will
13673 # be killed in groups.
13674 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
13676 # Use $LRU_SIZE_B here to take into account real number of locks
13677 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
13678 local LRU_SIZE_B=$LRU_SIZE
13680 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
13681 log "OLD_LVF=$OLD_LVF"
13682 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
13684 # Let's make sure that we really have some margin. Client checks
13685 # cached locks every 10 sec.
13686 SLEEP=$((SLEEP+20))
13687 log "Sleep ${SLEEP} sec"
13689 while ((SEC<$SLEEP)); do
13693 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
13694 echo -n "$LRU_SIZE"
13697 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
13698 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
13700 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
13701 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
13702 unlinkmany $DIR/$tdir/f $NR
13706 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
13707 log "unlink $NR files at $DIR/$tdir"
13708 unlinkmany $DIR/$tdir/f $NR
13710 run_test 124a "lru resize ======================================="
13712 get_max_pool_limit()
13714 local limit=$($LCTL get_param \
13715 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
13717 for l in $limit; do
13718 if [[ $l -gt $max ]]; then
13726 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13727 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13728 skip_env "no lru resize on server"
13730 LIMIT=$(get_max_pool_limit)
13732 NR=$(($(default_lru_size)*20))
13733 if [[ $NR -gt $LIMIT ]]; then
13734 log "Limit lock number by $LIMIT locks"
13738 IFree=$(mdsrate_inodes_available)
13739 if [ $IFree -lt $NR ]; then
13740 log "Limit lock number by $IFree inodes"
13744 lru_resize_disable mdc
13745 test_mkdir -p $DIR/$tdir/disable_lru_resize
13747 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
13748 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
13749 cancel_lru_locks mdc
13752 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13755 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13758 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13762 nolruresize_delta=$((etime-stime))
13763 log "ls -la time: $nolruresize_delta seconds"
13764 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13765 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
13767 lru_resize_enable mdc
13768 test_mkdir -p $DIR/$tdir/enable_lru_resize
13770 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
13771 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
13772 cancel_lru_locks mdc
13775 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13778 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13781 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13785 lruresize_delta=$((etime-stime))
13786 log "ls -la time: $lruresize_delta seconds"
13787 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13789 if [ $lruresize_delta -gt $nolruresize_delta ]; then
13790 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
13791 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
13792 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
13794 log "lru resize performs the same with no lru resize"
13796 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
13798 run_test 124b "lru resize (performance test) ======================="
13801 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13802 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13803 skip_env "no lru resize on server"
13805 # cache ununsed locks on client
13807 cancel_lru_locks mdc
13808 test_mkdir $DIR/$tdir
13809 createmany -o $DIR/$tdir/f $nr ||
13810 error "failed to create $nr files in $DIR/$tdir"
13811 ls -l $DIR/$tdir > /dev/null
13813 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13814 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13815 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13816 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13817 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13819 # set lru_max_age to 1 sec
13820 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13821 echo "sleep $((recalc_p * 2)) seconds..."
13822 sleep $((recalc_p * 2))
13824 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13825 # restore lru_max_age
13826 $LCTL set_param -n $nsdir.lru_max_age $max_age
13827 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13828 unlinkmany $DIR/$tdir/f $nr
13830 run_test 124c "LRUR cancel very aged locks"
13833 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13834 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13835 skip_env "no lru resize on server"
13837 # cache ununsed locks on client
13840 lru_resize_disable mdc
13841 stack_trap "lru_resize_enable mdc" EXIT
13843 cancel_lru_locks mdc
13845 # asynchronous object destroy at MDT could cause bl ast to client
13846 test_mkdir $DIR/$tdir
13847 createmany -o $DIR/$tdir/f $nr ||
13848 error "failed to create $nr files in $DIR/$tdir"
13849 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
13851 ls -l $DIR/$tdir > /dev/null
13853 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13854 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13855 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13856 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13858 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13860 # set lru_max_age to 1 sec
13861 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13862 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
13864 echo "sleep $((recalc_p * 2)) seconds..."
13865 sleep $((recalc_p * 2))
13867 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13869 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13871 run_test 124d "cancel very aged locks if lru-resize diasbaled"
13873 test_125() { # 13358
13874 $LCTL get_param -n llite.*.client_type | grep -q local ||
13875 skip "must run as local client"
13876 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
13877 skip_env "must have acl enabled"
13878 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13880 test_mkdir $DIR/$tdir
13881 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
13882 setfacl -R -m u:$USER0:rwx $DIR/$tdir ||
13883 error "setfacl $DIR/$tdir failed"
13884 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
13886 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
13888 test_126() { # bug 12829/13455
13889 $GSS && skip_env "must run as gss disabled"
13890 $LCTL get_param -n llite.*.client_type | grep -q local ||
13891 skip "must run as local client"
13892 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
13894 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
13895 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
13897 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
13899 run_test 126 "check that the fsgid provided by the client is taken into account"
13901 test_127a() { # bug 15521
13902 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13903 local name count samp unit min max sum sumsq
13904 local tmpfile=$TMP/$tfile.tmp
13906 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
13907 echo "stats before reset"
13908 stack_trap "rm -f $tmpfile"
13909 local now=$(date +%s)
13911 $LCTL get_param osc.*.stats | tee $tmpfile
13913 local snapshot_time=$(awk '/snapshot_time/ { print $2; exit }' $tmpfile)
13914 local start_time=$(awk '/start_time/ { print $2; exit }' $tmpfile)
13915 local elapsed=$(awk '/elapsed_time/ { print $2; exit }' $tmpfile)
13916 local uptime=$(awk '{ print $1 }' /proc/uptime)
13918 # snapshot_time should match POSIX epoch time, allow some delta for VMs
13919 (( ${snapshot_time%\.*} >= $now - 5 &&
13920 ${snapshot_time%\.*} <= $now + 5 )) ||
13921 error "snapshot_time=$snapshot_time != now=$now"
13922 # elapsed _should_ be from mount, but at least less than uptime
13923 (( ${elapsed%\.*} < ${uptime%\.*} )) ||
13924 error "elapsed=$elapsed > uptime=$uptime"
13925 (( ${snapshot_time%\.*} - ${start_time%\.*} >= ${elapsed%\.*} - 2 &&
13926 ${snapshot_time%\.*} - ${start_time%\.*} <= ${elapsed%\.*} + 2 )) ||
13927 error "elapsed=$elapsed != $snapshot_time - $start_time"
13929 $LCTL set_param osc.*.stats=0
13930 local reset=$(date +%s)
13931 local fsize=$((2048 * 1024))
13933 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
13934 cancel_lru_locks osc
13935 dd if=$DIR/$tfile of=/dev/null bs=$fsize
13938 $LCTL get_param osc.*0000-osc-*.stats > $tmpfile
13939 while read name count samp unit min max sum sumsq; do
13940 [[ "$samp" == "samples" ]] || continue
13942 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13943 [ ! $min ] && error "Missing min value for $name proc entry"
13944 eval $name=$count || error "Wrong proc format"
13947 read_bytes|write_bytes)
13948 [[ "$unit" =~ "bytes" ]] ||
13949 error "unit is not 'bytes': $unit"
13950 (( $min >= 4096 )) || error "min is too small: $min"
13951 (( $min <= $fsize )) || error "min is too big: $min"
13952 (( $max >= 4096 )) || error "max is too small: $max"
13953 (( $max <= $fsize )) || error "max is too big: $max"
13954 (( $sum == $fsize )) || error "sum is wrong: $sum"
13955 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
13956 error "sumsquare is too small: $sumsq"
13957 (( $sumsq <= $fsize * $fsize )) ||
13958 error "sumsquare is too big: $sumsq"
13960 ost_read|ost_write)
13961 [[ "$unit" =~ "usec" ]] ||
13962 error "unit is not 'usec': $unit"
13968 #check that we actually got some stats
13969 [ "$read_bytes" ] || error "Missing read_bytes stats"
13970 [ "$write_bytes" ] || error "Missing write_bytes stats"
13971 [ "$read_bytes" != 0 ] || error "no read done"
13972 [ "$write_bytes" != 0 ] || error "no write done"
13974 snapshot_time=$(awk '/snapshot_time/ { print $2; exit }' $tmpfile)
13975 start_time=$(awk '/start_time/ { print $2; exit }' $tmpfile)
13976 elapsed=$(awk '/elapsed_time/ { print $2; exit }' $tmpfile)
13978 # snapshot_time should match POSIX epoch time, allow some delta for VMs
13979 (( ${snapshot_time%\.*} >= $now - 5 &&
13980 ${snapshot_time%\.*} <= $now + 5 )) ||
13981 error "reset snapshot_time=$snapshot_time != now=$now"
13982 # elapsed should be from time of stats reset
13983 (( ${elapsed%\.*} >= $now - $reset - 2 &&
13984 ${elapsed%\.*} <= $now - $reset + 2 )) ||
13985 error "reset elapsed=$elapsed > $now - $reset"
13986 (( ${snapshot_time%\.*} - ${start_time%\.*} >= ${elapsed%\.*} - 2 &&
13987 ${snapshot_time%\.*} - ${start_time%\.*} <= ${elapsed%\.*} + 2 )) ||
13988 error "reset elapsed=$elapsed != $snapshot_time - $start_time"
13990 run_test 127a "verify the client stats are sane"
13992 test_127b() { # bug LU-333
13993 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13994 local name count samp unit min max sum sumsq
13996 echo "stats before reset"
13997 $LCTL get_param llite.*.stats
13998 $LCTL set_param llite.*.stats=0
14000 # perform 2 reads and writes so MAX is different from SUM.
14001 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
14002 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
14003 cancel_lru_locks osc
14004 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
14005 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
14007 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
14008 stack_trap "rm -f $TMP/$tfile.tmp"
14009 while read name count samp unit min max sum sumsq; do
14010 echo "got name=$name count=$count unit=$unit min=$min max=$max"
14011 eval $name=$count || error "Wrong proc format"
14014 read_bytes|write_bytes)
14015 [[ "$unit" =~ "bytes" ]] ||
14016 error "unit is not 'bytes': $unit"
14017 (( $count == 2 )) || error "count is not 2: $count"
14018 (( $min == $PAGE_SIZE )) ||
14019 error "min is not $PAGE_SIZE: $min"
14020 (( $max == $PAGE_SIZE )) ||
14021 error "max is not $PAGE_SIZE: $max"
14022 (( $sum == $PAGE_SIZE * 2 )) ||
14023 error "sum is not $((PAGE_SIZE * 2)): $sum"
14026 [[ "$unit" =~ "usec" ]] ||
14027 error "unit is not 'usec': $unit"
14031 done < $TMP/$tfile.tmp
14033 #check that we actually got some stats
14034 [ "$read_bytes" ] || error "Missing read_bytes stats"
14035 [ "$write_bytes" ] || error "Missing write_bytes stats"
14036 [ "$read_bytes" != 0 ] || error "no read done"
14037 [ "$write_bytes" != 0 ] || error "no write done"
14039 run_test 127b "verify the llite client stats are sane"
14041 test_127c() { # LU-12394
14042 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
14049 $LCTL set_param llite.*.extents_stats=1
14050 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
14052 # Use two stripes so there is enough space in default config
14053 $LFS setstripe -c 2 $DIR/$tfile
14055 # Extent stats start at 0-4K and go in power of two buckets
14056 # LL_HIST_START = 12 --> 2^12 = 4K
14057 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
14058 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
14060 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
14062 # Write and read, 2x each, second time at a non-zero offset
14063 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
14064 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
14065 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
14066 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
14070 $LCTL get_param llite.*.extents_stats
14073 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
14075 local bucket=$($LCTL get_param -n llite.*.extents_stats |
14077 reads=$(echo $bucket | awk '{print $5}')
14078 writes=$(echo $bucket | awk '{print $9}')
14079 [ "$reads" -eq $count ] ||
14080 error "$reads reads in < $bsize bucket, expect $count"
14081 [ "$writes" -eq $count ] ||
14082 error "$writes writes in < $bsize bucket, expect $count"
14085 # Test mmap write and read
14086 $LCTL set_param llite.*.extents_stats=c
14088 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
14089 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
14090 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
14092 $LCTL get_param llite.*.extents_stats
14094 count=$(((size*1024) / PAGE_SIZE))
14096 bsize=$((2 * PAGE_SIZE / 1024))K
14098 bucket=$($LCTL get_param -n llite.*.extents_stats |
14100 reads=$(echo $bucket | awk '{print $5}')
14101 writes=$(echo $bucket | awk '{print $9}')
14102 # mmap writes fault in the page first, creating an additonal read
14103 [ "$reads" -eq $((2 * count)) ] ||
14104 error "$reads reads in < $bsize bucket, expect $count"
14105 [ "$writes" -eq $count ] ||
14106 error "$writes writes in < $bsize bucket, expect $count"
14108 run_test 127c "test llite extent stats with regular & mmap i/o"
14110 test_128() { # bug 15212
14112 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
14117 result=$(grep error $TMP/$tfile.log)
14118 rm -f $DIR/$tfile $TMP/$tfile.log
14119 [ -z "$result" ] ||
14120 error "consecutive find's under interactive lfs failed"
14122 run_test 128 "interactive lfs for 2 consecutive find's"
14124 set_dir_limits () {
14129 local ldproc=/proc/fs/ldiskfs
14130 local facets=$(get_facets MDS)
14132 for facet in ${facets//,/ }; do
14133 canondev=$(ldiskfs_canon \
14134 *.$(convert_facet2label $facet).mntdev $facet)
14135 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
14136 ldproc=/sys/fs/ldiskfs
14137 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
14138 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
14142 check_mds_dmesg() {
14143 local facets=$(get_facets MDS)
14144 for facet in ${facets//,/ }; do
14145 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
14151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14152 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
14153 skip "Need MDS version with at least 2.5.56"
14154 if [ "$mds1_FSTYPE" != ldiskfs ]; then
14155 skip_env "ldiskfs only test"
14157 remote_mds_nodsh && skip "remote MDS with nodsh"
14160 local has_warning=false
14163 mkdir -p $DIR/$tdir
14165 # block size of mds1
14166 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
14167 set_dir_limits $maxsize $((maxsize * 6 / 8))
14168 stack_trap "set_dir_limits 0 0"
14169 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
14170 local dirsize=$(stat -c%s "$DIR/$tdir")
14172 while (( $dirsize <= $maxsize )); do
14173 $MCREATE $DIR/$tdir/file_base_$nfiles
14175 # check two errors:
14176 # ENOSPC for ext4 max_dir_size, which has been used since
14177 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
14178 if (( rc == ENOSPC )); then
14180 echo "rc=$rc returned as expected after $nfiles files"
14182 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
14183 error "create failed w/o dir size limit"
14185 # messages may be rate limited if test is run repeatedly
14186 check_mds_dmesg '"is approaching max"' ||
14187 echo "warning message should be output"
14188 check_mds_dmesg '"has reached max"' ||
14189 echo "reached message should be output"
14191 dirsize=$(stat -c%s "$DIR/$tdir")
14193 [[ $dirsize -ge $maxsize ]] && return 0
14194 error "dirsize $dirsize < $maxsize after $nfiles files"
14195 elif (( rc != 0 )); then
14198 nfiles=$((nfiles + 1))
14199 dirsize=$(stat -c%s "$DIR/$tdir")
14202 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
14204 run_test 129 "test directory size limit ========================"
14213 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
14214 [[ -z "$filefrag_op" ]] || skip_env "filefrag does not support FIEMAP"
14216 trap cleanup_130 EXIT RETURN
14218 local fm_file=$DIR/$tfile
14219 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
14220 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
14221 error "dd failed for $fm_file"
14223 # LU-1795: test filefrag/FIEMAP once, even if unsupported on ZFS
14224 filefrag -ves $fm_file
14226 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14227 skip "LU-1941: FIEMAP unimplemented on ZFS"
14228 (( $rc == 0 )) || error "filefrag $fm_file failed"
14230 filefrag_op=$(filefrag -ve -k $fm_file |
14231 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14232 local lun=$($LFS getstripe -i $fm_file)
14234 local start_blk=$(echo $filefrag_op | cut -d: -f2 | cut -d. -f1)
14237 for line in $filefrag_op; do
14238 local frag_lun=$(echo $line | cut -d: -f5)
14239 local ext_len=$(echo $line | cut -d: -f4)
14241 if (( $frag_lun != $lun )); then
14242 error "FIEMAP on 1-stripe file($fm_file) failed"
14245 (( tot_len += ext_len ))
14248 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
14249 error "FIEMAP on 1-stripe file($fm_file) failed"
14253 echo "FIEMAP on single striped file succeeded"
14255 run_test 130a "FIEMAP (1-stripe file)"
14258 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14260 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14261 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14262 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14263 skip "LU-1941: FIEMAP unimplemented on ZFS"
14265 trap cleanup_130 EXIT RETURN
14267 local fm_file=$DIR/$tfile
14268 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
14269 error "setstripe on $fm_file"
14271 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
14272 error "dd failed on $fm_file"
14274 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14275 filefrag_op=$(filefrag -ve -k $fm_file |
14276 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14278 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14279 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14285 for line in $filefrag_op; do
14286 local frag_lun=$(echo $line | cut -d: -f5 |
14287 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14288 local ext_len=$(echo $line | cut -d: -f4)
14289 if (( $frag_lun != $last_lun )); then
14290 if (( tot_len != 1024 )); then
14291 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14294 (( num_luns += 1 ))
14298 (( tot_len += ext_len ))
14301 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
14302 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14306 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
14308 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
14311 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14313 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14314 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14315 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14316 skip "LU-1941: FIEMAP unimplemented on ZFS"
14318 trap cleanup_130 EXIT RETURN
14320 local fm_file=$DIR/$tfile
14321 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
14323 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
14324 error "dd failed on $fm_file"
14326 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14327 filefrag_op=$(filefrag -ve -k $fm_file |
14328 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14330 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14331 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14336 for line in $filefrag_op; do
14337 local frag_lun=$(echo $line | cut -d: -f5 |
14338 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14339 local ext_len=$(echo $line | cut -d: -f4)
14340 if (( $frag_lun != $last_lun )); then
14341 local logical=$(echo $line | cut -d: -f2 | cut -d. -f1)
14342 if (( logical != 512 )); then
14343 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
14346 if (( tot_len != 512 )); then
14347 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14350 (( num_luns += 1 ))
14354 (( tot_len += ext_len ))
14357 if (( num_luns != 2 || tot_len != 512 )); then
14358 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14362 echo "FIEMAP on 2-stripe file with hole succeeded"
14364 run_test 130c "FIEMAP (2-stripe file with hole)"
14367 (( $OSTCOUNT >= 3 )) || skip "needs >= 3 OSTs"
14369 filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14370 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14371 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14372 skip "LU-1941: FIEMAP unimplemented on ZFS"
14374 trap cleanup_130 EXIT RETURN
14376 local fm_file=$DIR/$tfile
14377 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
14378 error "setstripe on $fm_file"
14380 local actual_stripe_count=$($LFS getstripe -c $fm_file)
14381 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
14382 error "dd failed on $fm_file"
14384 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14385 filefrag_op=$(filefrag -ve -k $fm_file |
14386 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14388 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14389 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14394 for line in $filefrag_op; do
14395 local frag_lun=$(echo $line | cut -d: -f5 |
14396 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14397 local ext_len=$(echo $line | cut -d: -f4)
14398 if (( $frag_lun != $last_lun )); then
14399 if (( tot_len != 1024 )); then
14400 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14403 (( num_luns += 1 ))
14407 (( tot_len += ext_len ))
14410 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
14411 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14415 echo "FIEMAP on N-stripe file succeeded"
14417 run_test 130d "FIEMAP (N-stripe file)"
14420 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14422 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14423 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14424 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14425 skip "LU-1941: FIEMAP unimplemented on ZFS"
14427 trap cleanup_130 EXIT RETURN
14429 local fm_file=$DIR/$tfile
14430 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
14433 local expected_len=$(( (num_blks / 2) * 64 ))
14434 for ((i = 0; i < $num_blks; i++)); do
14435 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
14436 conv=notrunc > /dev/null 2>&1
14439 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14440 filefrag_op=$(filefrag -ve -k $fm_file |
14441 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14443 local last_lun=$(echo $filefrag_op | cut -d: -f5)
14448 for line in $filefrag_op; do
14449 local frag_lun=$(echo $line | cut -d: -f5)
14450 local ext_len=$(echo $line | cut -d: -f4)
14451 if (( $frag_lun != $last_lun )); then
14452 if (( tot_len != $expected_len )); then
14453 error "OST$last_lun $tot_len != $expected_len"
14455 (( num_luns += 1 ))
14459 (( tot_len += ext_len ))
14462 if (( num_luns != 2 || tot_len != $expected_len )); then
14463 error "OST$last_lun $num_luns != 2, $tot_len != $expected_len"
14466 echo "FIEMAP with continuation calls succeeded"
14468 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
14471 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14472 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14473 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14474 skip "LU-1941: FIEMAP unimplemented on ZFS"
14476 local fm_file=$DIR/$tfile
14477 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
14478 error "multiop create with lov_delay_create on $fm_file"
14480 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14481 filefrag_extents=$(filefrag -vek $fm_file |
14482 awk '/extents? found/ { print $2 }')
14483 if (( $filefrag_extents != 0 )); then
14484 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
14489 run_test 130f "FIEMAP (unstriped file)"
14492 (( $MDS1_VERSION >= $(version_code 2.12.53) )) ||
14493 skip "Need MDS version with at least 2.12.53 for overstriping"
14494 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14495 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14496 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14497 skip "LU-1941: FIEMAP unimplemented on ZFS"
14499 local file=$DIR/$tfile
14500 local nr=$((OSTCOUNT * 100))
14502 $LFS setstripe -C $nr $file || error "failed to setstripe -C $nr $file"
14504 stack_trap "rm -f $file"
14505 dd if=/dev/zero of=$file count=$nr bs=1M
14507 nr=$($LFS getstripe -c $file)
14509 local extents=$(filefrag -v $file |
14510 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
14512 echo "filefrag list $extents extents in file with stripecount $nr"
14513 if (( extents < nr )); then
14514 $LFS getstripe $file
14516 error "filefrag printed $extents < $nr extents"
14519 run_test 130g "FIEMAP (overstripe file)"
14521 # Test for writev/readv
14523 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
14524 error "writev test failed"
14525 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
14526 error "readv failed"
14529 run_test 131a "test iov's crossing stripe boundary for writev/readv"
14532 local fsize=$((524288 + 1048576 + 1572864))
14533 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
14534 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14535 error "append writev test failed"
14537 ((fsize += 1572864 + 1048576))
14538 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
14539 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14540 error "append writev test failed"
14543 run_test 131b "test append writev"
14546 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
14549 run_test 131c "test read/write on file w/o objects"
14552 rwv -f $DIR/$tfile -w -n 1 1572864
14553 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
14554 if [ "$NOB" != 1572864 ]; then
14555 error "Short read filed: read $NOB bytes instead of 1572864"
14559 run_test 131d "test short read"
14562 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
14563 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
14564 error "read hitting hole failed"
14567 run_test 131e "test read hitting hole"
14575 # open 11 samples [usecs] 468 4793 13658 35791898
14577 mds*) res=($(do_facet $facet \
14578 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op"))
14580 ost*) res=($(do_facet $facet \
14581 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op"))
14583 *) error "Wrong facet '$facet'" ;;
14585 [[ -n "$res" ]] || error "counter for $op on $facet not incremented"
14586 # if $want is zero, it means any stat increment is ok.
14587 if (( $want > 0 )); then
14588 local count=${res[1]}
14590 if (( $count != $want )); then
14591 if [[ $facet =~ "mds" ]]; then
14592 do_nodes $(comma_list $(mdts_nodes)) \
14593 $LCTL get_param mdt.*.md_stats
14595 do_nodes $(comma_list $(osts-nodes)) \
14596 $LCTL get_param obdfilter.*.stats
14598 error "The $op counter on $facet is $count, not $want"
14604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14605 remote_ost_nodsh && skip "remote OST with nodsh"
14606 remote_mds_nodsh && skip "remote MDS with nodsh"
14607 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14608 skip_env "MDS doesn't support rename stats"
14610 local testdir=$DIR/${tdir}/stats_testdir
14612 mkdir -p $DIR/${tdir}
14615 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14616 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14618 # verify mdt stats first.
14619 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
14620 check_stats $SINGLEMDS "mkdir" 1
14622 # clear "open" from "lfs mkdir" above
14623 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14624 touch ${testdir}/${tfile} || error "touch failed"
14625 check_stats $SINGLEMDS "open" 1
14626 check_stats $SINGLEMDS "close" 1
14627 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
14628 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
14629 check_stats $SINGLEMDS "mknod" 2
14631 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
14632 check_stats $SINGLEMDS "unlink" 1
14633 rm -f ${testdir}/${tfile} || error "file remove failed"
14634 check_stats $SINGLEMDS "unlink" 2
14636 # remove working dir and check mdt stats again.
14637 rmdir ${testdir} || error "rmdir failed"
14638 check_stats $SINGLEMDS "rmdir" 1
14640 local testdir1=$DIR/${tdir}/stats_testdir1
14641 mkdir_on_mdt0 -p ${testdir}
14642 mkdir_on_mdt0 -p ${testdir1}
14643 touch ${testdir1}/test1
14644 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
14645 check_stats $SINGLEMDS "crossdir_rename" 1
14647 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
14648 check_stats $SINGLEMDS "samedir_rename" 1
14650 rm -rf $DIR/${tdir}
14652 run_test 133a "Verifying MDT stats ========================================"
14657 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14658 remote_ost_nodsh && skip "remote OST with nodsh"
14659 remote_mds_nodsh && skip "remote MDS with nodsh"
14661 local testdir=$DIR/${tdir}/stats_testdir
14663 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
14664 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
14665 touch ${testdir}/${tfile} || error "touch failed"
14666 cancel_lru_locks mdc
14669 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14670 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14672 # extra mdt stats verification.
14673 chmod 444 ${testdir}/${tfile} || error "chmod failed"
14674 check_stats $SINGLEMDS "setattr" 1
14675 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14676 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
14678 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
14679 check_stats $SINGLEMDS "getattr" 1
14681 rm -rf $DIR/${tdir}
14683 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
14684 # so the check below is not reliable
14685 [ $MDSCOUNT -eq 1 ] || return 0
14687 # Sleep to avoid a cached response.
14688 #define OBD_STATFS_CACHE_SECONDS 1
14690 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14691 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14692 $LFS df || error "lfs failed"
14693 check_stats $SINGLEMDS "statfs" 1
14695 # check aggregated statfs (LU-10018)
14696 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
14698 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
14701 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14702 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14704 check_stats $SINGLEMDS "statfs" 1
14706 # We want to check that the client didn't send OST_STATFS to
14707 # ost1 but the MDT also uses OST_STATFS for precreate. So some
14708 # extra care is needed here.
14709 if remote_mds; then
14710 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
14711 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
14713 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
14714 [ "$res" ] && error "OST got STATFS"
14719 run_test 133b "Verifying extra MDT stats =================================="
14722 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14723 remote_ost_nodsh && skip "remote OST with nodsh"
14724 remote_mds_nodsh && skip "remote MDS with nodsh"
14726 local testdir=$DIR/$tdir/stats_testdir
14728 test_mkdir -p $testdir
14730 # verify obdfilter stats.
14731 $LFS setstripe -c 1 -i 0 $testdir/$tfile
14733 cancel_lru_locks osc
14734 wait_delete_completed
14737 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14738 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14740 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
14743 cancel_lru_locks osc
14744 check_stats ost1 "write" 1
14746 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
14747 check_stats ost1 "read" 1
14749 > $testdir/$tfile || error "truncate failed"
14750 check_stats ost1 "punch" 1
14752 rm -f $testdir/$tfile || error "file remove failed"
14753 wait_delete_completed
14754 check_stats ost1 "destroy" 1
14758 run_test 133c "Verifying OST stats ========================================"
14765 while [ $value -ge 2 ]; do
14770 if [ $orig -gt $order ]; then
14778 local size=('K' 'M' 'G' 'T');
14780 local size_string=$value
14782 while [ $value -ge 1024 ]; do
14783 if [ $i -gt 3 ]; then
14784 #T is the biggest unit we get here, if that is bigger,
14786 size_string=${value}T
14789 value=$((value >> 10))
14790 if [ $value -lt 1024 ]; then
14791 size_string=${value}${size[$i]}
14800 get_rename_size() {
14802 local context=${2:-.}
14803 local sample=$(do_facet $SINGLEMDS $LCTL \
14804 get_param mdt.$FSNAME-MDT0000.rename_stats |
14805 grep -A1 $context |
14806 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
14811 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14812 remote_ost_nodsh && skip "remote OST with nodsh"
14813 remote_mds_nodsh && skip "remote MDS with nodsh"
14814 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14815 skip_env "MDS doesn't support rename stats"
14817 local testdir1=$DIR/${tdir}/stats_testdir1
14818 local testdir2=$DIR/${tdir}/stats_testdir2
14819 mkdir -p $DIR/${tdir} || error "mkdir $tdir failed"
14821 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14823 mkdir_on_mdt0 ${testdir1} || error "mkdir $testdir1 failed"
14824 mkdir_on_mdt0 ${testdir2} || error "mkdir $testdir2 failed"
14826 createmany -o $testdir1/test 512 || error "createmany failed"
14828 # check samedir rename size
14829 mv ${testdir1}/test0 ${testdir1}/test_0
14831 local testdir1_size=$(ls -l $DIR/${tdir} |
14832 awk '/stats_testdir1/ {print $5}')
14833 local testdir2_size=$(ls -l $DIR/${tdir} |
14834 awk '/stats_testdir2/ {print $5}')
14836 testdir1_size=$(order_2 $testdir1_size)
14837 testdir2_size=$(order_2 $testdir2_size)
14839 testdir1_size=$(size_in_KMGT $testdir1_size)
14840 testdir2_size=$(size_in_KMGT $testdir2_size)
14842 echo "source rename dir size: ${testdir1_size}"
14843 echo "target rename dir size: ${testdir2_size}"
14845 local cmd="do_facet $SINGLEMDS $LCTL "
14846 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
14848 eval $cmd || error "$cmd failed"
14849 local samedir=$($cmd | grep 'same_dir')
14850 local same_sample=$(get_rename_size $testdir1_size)
14851 [ -z "$samedir" ] && error "samedir_rename_size count error"
14852 [[ $same_sample -eq 1 ]] ||
14853 error "samedir_rename_size error $same_sample"
14854 echo "Check same dir rename stats success"
14856 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14858 # check crossdir rename size
14859 mv ${testdir1}/test_0 ${testdir2}/test_0
14861 testdir1_size=$(ls -l $DIR/${tdir} |
14862 awk '/stats_testdir1/ {print $5}')
14863 testdir2_size=$(ls -l $DIR/${tdir} |
14864 awk '/stats_testdir2/ {print $5}')
14866 testdir1_size=$(order_2 $testdir1_size)
14867 testdir2_size=$(order_2 $testdir2_size)
14869 testdir1_size=$(size_in_KMGT $testdir1_size)
14870 testdir2_size=$(size_in_KMGT $testdir2_size)
14872 echo "source rename dir size: ${testdir1_size}"
14873 echo "target rename dir size: ${testdir2_size}"
14875 eval $cmd || error "$cmd failed"
14876 local crossdir=$($cmd | grep 'crossdir')
14877 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
14878 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
14879 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
14880 [[ $src_sample -eq 1 ]] ||
14881 error "crossdir_rename_size error $src_sample"
14882 [[ $tgt_sample -eq 1 ]] ||
14883 error "crossdir_rename_size error $tgt_sample"
14884 echo "Check cross dir rename stats success"
14885 rm -rf $DIR/${tdir}
14887 run_test 133d "Verifying rename_stats ========================================"
14890 remote_mds_nodsh && skip "remote MDS with nodsh"
14891 remote_ost_nodsh && skip "remote OST with nodsh"
14892 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14894 local testdir=$DIR/${tdir}/stats_testdir
14895 local ctr f0 f1 bs=32768 count=42 sum
14897 mkdir -p ${testdir} || error "mkdir failed"
14899 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
14901 for ctr in {write,read}_bytes; do
14903 cancel_lru_locks osc
14905 do_facet ost1 $LCTL set_param -n \
14906 "obdfilter.*.exports.clear=clear"
14908 if [ $ctr = write_bytes ]; then
14910 f1=${testdir}/${tfile}
14912 f0=${testdir}/${tfile}
14916 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
14919 cancel_lru_locks osc
14921 sum=$(do_facet ost1 $LCTL get_param \
14922 "obdfilter.*.exports.*.stats" |
14923 awk -v ctr=$ctr 'BEGIN { sum = 0 }
14924 $1 == ctr { sum += $7 }
14925 END { printf("%0.0f", sum) }')
14927 if ((sum != bs * count)); then
14928 error "Bad $ctr sum, expected $((bs * count)), got $sum"
14932 rm -rf $DIR/${tdir}
14934 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
14937 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
14938 skip "too old lustre for get_param -R ($facet_ver)"
14940 # verifying readability.
14941 $LCTL get_param -R '*' &> /dev/null
14943 # Verifing writability with badarea_io.
14944 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14945 local skipped_params='force_lbug|changelog_mask|daemon_file'
14946 $LCTL list_param -FR '*' | grep '=' | tr -d = |
14947 egrep -v "$skipped_params" |
14948 xargs -n 1 find $proc_dirs -name |
14949 xargs -n 1 badarea_io ||
14950 error "client badarea_io failed"
14952 # remount the FS in case writes/reads /proc break the FS
14953 cleanup || error "failed to unmount"
14954 setup || error "failed to setup"
14956 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
14959 remote_mds_nodsh && skip "remote MDS with nodsh"
14960 remote_ost_nodsh && skip "remote OST with nodsh"
14962 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14963 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
14965 for facet in mds1 ost1; do
14966 local facet_ver=$(lustre_version_code $facet)
14967 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
14968 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
14970 log "$facet: too old lustre for get_param -R"
14972 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
14973 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
14974 tr -d = | egrep -v $skipped_params |
14975 xargs -n 1 find $proc_dirs -name |
14976 xargs -n 1 badarea_io" ||
14977 error "$facet badarea_io failed"
14979 skip_noexit "$facet: too old lustre for get_param -R"
14983 # remount the FS in case writes/reads /proc break the FS
14984 cleanup || error "failed to unmount"
14985 setup || error "failed to setup"
14987 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
14990 remote_mds_nodsh && skip "remote MDS with nodsh"
14991 remote_ost_nodsh && skip "remote OST with nodsh"
14992 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
14993 skip "Need MDS version at least 2.9.54"
14996 for facet in client mds1 ost1; do
14997 # Get the list of files that are missing the terminating newline
14998 local plist=$(do_facet $facet
14999 $LCTL list_param -FR '*' | grep '=' | tr -d =)
15001 for ent in $plist; do
15002 local missing=$(do_facet $facet $LCTL get_param $ent \|\
15003 awk -v FS='\v' -v RS='\v\v' \
15004 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
15005 print FILENAME}'" 2>/dev/null)
15006 [ -z $missing ] || {
15007 do_facet $facet $LCTL get_param $ent | od -An -tx1
15008 error "file does not end with newline: $facet-$ent"
15013 run_test 133h "Proc files should end with newlines"
15016 remote_mds_nodsh && skip "remote MDS with nodsh"
15017 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
15018 skip "Need MDS version at least 2.7.54"
15020 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
15021 cancel_lru_locks mdc
15023 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
15024 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
15025 [ $unused -eq 0 ] || error "$unused locks are not cleared"
15028 createmany -o $DIR/$tdir/f $nr ||
15029 error "failed to create $nr files in $DIR/$tdir"
15030 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
15032 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
15033 do_facet mds1 $LCTL set_param fail_loc=0x327
15034 do_facet mds1 $LCTL set_param fail_val=500
15037 echo "sleep 10 seconds ..."
15039 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
15041 do_facet mds1 $LCTL set_param fail_loc=0
15042 do_facet mds1 $LCTL set_param fail_val=0
15043 [ $lck_cnt -lt $unused ] ||
15044 error "No locks reclaimed, before:$unused, after:$lck_cnt"
15047 unlinkmany $DIR/$tdir/f $nr
15049 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
15052 remote_mds_nodsh && skip "remote MDS with nodsh"
15053 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
15054 skip "Need MDS version at least 2.7.54"
15056 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
15057 cancel_lru_locks mdc
15059 local low_wm=$(do_facet mds1 $LCTL get_param -n \
15060 ldlm.lock_reclaim_threshold_mb)
15061 # disable reclaim temporarily
15062 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
15064 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
15065 do_facet mds1 $LCTL set_param fail_loc=0x328
15066 do_facet mds1 $LCTL set_param fail_val=500
15068 $LCTL set_param debug=+trace
15071 createmany -o $DIR/$tdir/f $nr &
15072 local create_pid=$!
15074 echo "Sleep $TIMEOUT seconds ..."
15076 if ! ps -p $create_pid > /dev/null 2>&1; then
15077 do_facet mds1 $LCTL set_param fail_loc=0
15078 do_facet mds1 $LCTL set_param fail_val=0
15079 do_facet mds1 $LCTL set_param \
15080 ldlm.lock_reclaim_threshold_mb=${low_wm}m
15081 error "createmany finished incorrectly!"
15083 do_facet mds1 $LCTL set_param fail_loc=0
15084 do_facet mds1 $LCTL set_param fail_val=0
15085 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
15086 wait $create_pid || return 1
15088 unlinkmany $DIR/$tdir/f $nr
15090 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
15093 remote_mds_nodsh && skip "remote MDS with nodsh"
15094 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
15095 skip "Need MDS version at least 2.13.50"
15098 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
15100 #define OBD_FAIL_PLAIN_RECORDS 0x1319
15101 #set only one record at plain llog
15102 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
15104 #fill already existed plain llog each 64767
15105 #wrapping whole catalog
15106 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
15108 createmany -o $DIR/$tdir/$tfile_ 64700
15109 for (( i = 0; i < 64700; i = i + 2 ))
15111 rm $DIR/$tdir/$tfile_$i &
15112 rm $DIR/$tdir/$tfile_$((i + 1)) &
15117 #waiting osp synchronization
15118 wait_delete_completed
15120 run_test 135 "Race catalog processing"
15123 remote_mds_nodsh && skip "remote MDS with nodsh"
15124 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
15125 skip "Need MDS version at least 2.13.50"
15128 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
15129 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
15130 #set only one record at plain llog
15131 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
15132 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
15134 #fill already existed 2 plain llogs each 64767
15135 #wrapping whole catalog
15136 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
15137 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
15138 wait_delete_completed
15140 createmany -o $DIR/$tdir/$tfile_ 10
15143 do_facet $SINGLEMDS $LCTL set_param fail_val=3
15144 for (( i = 0; i < 10; i = i + 3 ))
15146 rm $DIR/$tdir/$tfile_$i &
15147 rm $DIR/$tdir/$tfile_$((i + 1)) &
15151 rm $DIR/$tdir/$tfile_$((i + 2)) &
15154 #waiting osp synchronization
15155 wait_delete_completed
15157 run_test 136 "Race catalog processing 2"
15159 test_140() { #bug-17379
15160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15162 test_mkdir $DIR/$tdir
15163 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
15164 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
15166 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
15167 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
15169 while i=$((i + 1)); do
15171 cd $i || error "Changing to $i"
15172 ln -s ../stat stat || error "Creating stat symlink"
15173 # Read the symlink until ELOOP present,
15174 # not LBUGing the system is considered success,
15175 # we didn't overrun the stack.
15176 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
15177 if [ $ret -ne 0 ]; then
15178 if [ $ret -eq 40 ]; then
15181 error "Open stat symlink"
15187 echo "The symlink depth = $i"
15188 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
15189 error "Invalid symlink depth"
15191 # Test recursive symlink
15192 ln -s symlink_self symlink_self
15193 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
15194 echo "open symlink_self returns $ret"
15195 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
15197 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
15200 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15202 local TF="$TMP/$tfile"
15204 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15205 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
15207 cancel_lru_locks $OSC
15208 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
15209 remount_client $MOUNT
15211 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
15214 $TRUNCATE $DIR/$tfile 6000
15215 cancel_lru_locks $OSC
15216 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
15219 echo "12345" >>$DIR/$tfile
15220 cancel_lru_locks $OSC
15221 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
15224 echo "12345" >>$DIR/$tfile
15225 cancel_lru_locks $OSC
15226 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
15228 run_test 150a "truncate/append tests"
15231 check_set_fallocate_or_skip
15235 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15236 out=$(check_fallocate $DIR/$tfile 2>&1) ||
15237 skip_eopnotsupp "$out|check_fallocate failed"
15239 run_test 150b "Verify fallocate (prealloc) functionality"
15242 check_set_fallocate_or_skip
15245 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15246 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
15248 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
15249 # precomputed md5sum for 20MB of zeroes
15250 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
15251 local sum=($(md5sum $DIR/$tfile))
15253 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
15255 check_set_fallocate 1
15258 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
15259 sum=($(md5sum $DIR/$tfile))
15261 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
15263 run_test 150bb "Verify fallocate modes both zero space"
15266 check_set_fallocate_or_skip
15267 local striping="-c2"
15269 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15270 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
15271 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
15272 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
15273 local want=$((OSTCOUNT * 1048576))
15275 # Must allocate all requested space, not more than 5% extra
15276 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15277 error "bytes $bytes is not $want"
15281 echo "verify fallocate on PFL file"
15283 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
15285 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
15286 error "Create $DIR/$tfile failed"
15287 fallocate -l $((1048576 * 512)) $DIR/$tfile || error "fallocate failed"
15288 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
15289 want=$((512 * 1048576))
15291 # Must allocate all requested space, not more than 5% extra
15292 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15293 error "bytes $bytes is not $want"
15295 run_test 150c "Verify fallocate Size and Blocks"
15298 check_set_fallocate_or_skip
15299 local striping="-c2"
15301 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
15303 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15304 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
15305 error "setstripe failed"
15306 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
15307 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
15308 local want=$((OSTCOUNT * 1048576))
15310 # Must allocate all requested space, not more than 5% extra
15311 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15312 error "bytes $bytes is not $want"
15314 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
15317 check_set_fallocate_or_skip
15321 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15322 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15323 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15325 # Find OST with Minimum Size
15326 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15327 sort -un | head -1)
15329 # Get 100MB per OST of the available space to reduce run time
15330 # else 60% of the available space if we are running SLOW tests
15331 if [ $SLOW == "no" ]; then
15332 local space=$((1024 * 100 * OSTCOUNT))
15334 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
15337 fallocate -l${space}k $DIR/$tfile ||
15338 error "fallocate ${space}k $DIR/$tfile failed"
15339 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
15341 # get size immediately after fallocate. This should be correctly
15343 local size=$(stat -c '%s' $DIR/$tfile)
15344 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
15346 # Sleep for a while for statfs to get updated. And not pull from cache.
15349 echo "df after fallocate:"
15352 (( size / 1024 == space )) || error "size $size != requested $space"
15353 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
15354 error "used $used < space $space"
15356 rm $DIR/$tfile || error "rm failed"
15358 wait_delete_completed
15360 echo "df after unlink:"
15363 run_test 150e "Verify 60% of available OST space consumed by fallocate"
15368 local want_size_before=20480 # in bytes
15369 local want_blocks_before=40 # 512 sized blocks
15370 local want_blocks_after=24 # 512 sized blocks
15371 local length=$(((want_blocks_before - want_blocks_after) * 512))
15373 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
15374 skip "need at least 2.14.0 for fallocate punch"
15376 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
15377 skip "LU-14160: punch mode is not implemented on OSD ZFS"
15380 check_set_fallocate_or_skip
15381 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15383 [[ "x$DOM" == "xyes" ]] &&
15384 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
15386 echo "Verify fallocate punch: Range within the file range"
15387 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
15388 error "dd failed for bs 4096 and count 5"
15390 # Call fallocate with punch range which is within the file range
15391 out=$(fallocate -p --offset 4096 -l $length $DIR/$tfile 2>&1) ||
15392 skip_eopnotsupp "$out|fallocate: offset 4096 and length $length"
15393 # client must see changes immediately after fallocate
15394 size=$(stat -c '%s' $DIR/$tfile)
15395 blocks=$(stat -c '%b' $DIR/$tfile)
15397 # Verify punch worked.
15398 (( blocks == want_blocks_after )) ||
15399 error "punch failed: blocks $blocks != $want_blocks_after"
15401 (( size == want_size_before )) ||
15402 error "punch failed: size $size != $want_size_before"
15404 # Verify there is hole in file
15405 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
15406 # precomputed md5sum
15407 local expect="4a9a834a2db02452929c0a348273b4aa"
15409 cksum=($(md5sum $DIR/$tfile))
15410 [[ "${cksum[0]}" == "$expect" ]] ||
15411 error "unexpected MD5SUM after punch: ${cksum[0]}"
15413 # Start second sub-case for fallocate punch.
15414 echo "Verify fallocate punch: Range overlapping and less than blocksize"
15415 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
15416 error "dd failed for bs 4096 and count 5"
15418 # Punch range less than block size will have no change in block count
15419 want_blocks_after=40 # 512 sized blocks
15421 # Punch overlaps two blocks and less than blocksize
15422 out=$(fallocate -p --offset 4000 -l 3000 $DIR/$tfile 2>&1) ||
15423 skip_eopnotsupp "$out|fallocate: offset 4000 length 3000"
15424 size=$(stat -c '%s' $DIR/$tfile)
15425 blocks=$(stat -c '%b' $DIR/$tfile)
15427 # Verify punch worked.
15428 (( blocks == want_blocks_after )) ||
15429 error "punch failed: blocks $blocks != $want_blocks_after"
15431 (( size == want_size_before )) ||
15432 error "punch failed: size $size != $want_size_before"
15434 # Verify if range is really zero'ed out. We expect Zeros.
15435 # precomputed md5sum
15436 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
15437 cksum=($(md5sum $DIR/$tfile))
15438 [[ "${cksum[0]}" == "$expect" ]] ||
15439 error "unexpected MD5SUM after punch: ${cksum[0]}"
15441 run_test 150f "Verify fallocate punch functionality"
15449 local BS=4096 # Block size in bytes
15451 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
15452 skip "need at least 2.14.0 for fallocate punch"
15454 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
15455 skip "LU-14160: punch mode is not implemented on OSD ZFS"
15458 check_set_fallocate_or_skip
15459 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15461 if [[ "x$DOM" == "xyes" ]]; then
15462 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
15463 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
15465 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15466 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15469 # Get 100MB per OST of the available space to reduce run time
15470 # else 60% of the available space if we are running SLOW tests
15471 if [ $SLOW == "no" ]; then
15472 space=$((1024 * 100 * OSTCOUNT))
15474 # Find OST with Minimum Size
15475 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15476 sort -un | head -1)
15477 echo "min size OST: $space"
15478 space=$(((space * 60)/100 * OSTCOUNT))
15480 # space in 1k units, round to 4k blocks
15481 local blkcount=$((space * 1024 / $BS))
15483 echo "Verify fallocate punch: Very large Range"
15484 fallocate -l${space}k $DIR/$tfile ||
15485 error "fallocate ${space}k $DIR/$tfile failed"
15486 # write 1M at the end, start and in the middle
15487 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
15488 error "dd failed: bs $BS count 256"
15489 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
15490 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
15491 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
15492 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
15495 size=$(stat -c '%s' $DIR/$tfile)
15497 # gather punch length.
15498 local punch_size=$((size - (BS * 2)))
15500 echo "punch_size = $punch_size"
15501 echo "size - punch_size: $((size - punch_size))"
15502 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
15504 # Call fallocate to punch all except 2 blocks. We leave the
15505 # first and the last block
15506 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
15507 out=$(fallocate -p --offset $BS -l $punch_size $DIR/$tfile 2>&1) ||
15508 skip_eopnotsupp "$out|fallocate: offset $BS length $punch_size"
15510 size_after=$(stat -c '%s' $DIR/$tfile)
15511 blocks_after=$(stat -c '%b' $DIR/$tfile)
15513 # Verify punch worked.
15514 # Size should be kept
15515 (( size == size_after )) ||
15516 error "punch failed: size $size != $size_after"
15518 # two 4k data blocks to remain plus possible 1 extra extent block
15519 (( blocks_after <= ((BS / 512) * 3) )) ||
15520 error "too many blocks remains: $blocks_after"
15522 # Verify that file has hole between the first and the last blocks
15523 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
15524 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
15526 echo "Hole at [$hole_start, $hole_end)"
15527 (( hole_start == BS )) ||
15528 error "no hole at offset $BS after punch"
15530 (( hole_end == BS + punch_size )) ||
15531 error "data at offset $hole_end < $((BS + punch_size))"
15533 run_test 150g "Verify fallocate punch on large range"
15536 local file=$DIR/$tfile
15539 check_set_fallocate_or_skip
15540 statx_supported || skip_env "Test must be statx() syscall supported"
15542 # fallocate() does not update the size information on the MDT
15543 fallocate -l 16K $file || error "failed to fallocate $file"
15544 cancel_lru_locks $OSC
15545 # STATX with cached-always mode will not send glimpse RPCs to OST,
15546 # it uses the caching attrs on the client side as much as possible.
15547 size=$($STATX --cached=always -c %s $file)
15548 [ $size == 16384 ] ||
15549 error "size after fallocate() is $size, expected 16384"
15551 run_test 150h "Verify extend fallocate updates the file size"
15553 #LU-2902 roc_hit was not able to read all values from lproc
15554 function roc_hit_init() {
15555 local list=$(comma_list $(osts_nodes))
15556 local dir=$DIR/$tdir-check
15557 local file=$dir/$tfile
15563 #use setstripe to do a write to every ost
15564 for i in $(seq 0 $((OSTCOUNT-1))); do
15565 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
15566 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
15567 idx=$(printf %04x $i)
15568 BEFORE=$(get_osd_param $list *OST*$idx stats |
15569 awk '$1 == "cache_access" {sum += $7}
15570 END { printf("%0.0f", sum) }')
15572 cancel_lru_locks osc
15573 cat $file >/dev/null
15575 AFTER=$(get_osd_param $list *OST*$idx stats |
15576 awk '$1 == "cache_access" {sum += $7}
15577 END { printf("%0.0f", sum) }')
15579 echo BEFORE:$BEFORE AFTER:$AFTER
15580 if ! let "AFTER - BEFORE == 4"; then
15582 error "roc_hit is not safe to use"
15590 function roc_hit() {
15591 local list=$(comma_list $(osts_nodes))
15592 echo $(get_osd_param $list '' stats |
15593 awk '$1 == "cache_hit" {sum += $7}
15594 END { printf("%0.0f", sum) }')
15597 function set_cache() {
15600 if [ "$2" == "off" ]; then
15603 local list=$(comma_list $(osts_nodes))
15604 set_osd_param $list '' $1_cache_enable $on
15606 cancel_lru_locks osc
15610 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15611 remote_ost_nodsh && skip "remote OST with nodsh"
15614 local list=$(comma_list $(osts_nodes))
15616 # check whether obdfilter is cache capable at all
15617 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
15618 skip "not cache-capable obdfilter"
15621 # check cache is enabled on all obdfilters
15622 if get_osd_param $list '' read_cache_enable | grep 0; then
15623 skip "oss cache is disabled"
15626 set_osd_param $list '' writethrough_cache_enable 1
15628 # check write cache is enabled on all obdfilters
15629 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
15630 skip "oss write cache is NOT enabled"
15635 #define OBD_FAIL_OBD_NO_LRU 0x609
15636 do_nodes $list $LCTL set_param fail_loc=0x609
15638 # pages should be in the case right after write
15639 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
15642 local BEFORE=$(roc_hit)
15643 cancel_lru_locks osc
15644 cat $DIR/$tfile >/dev/null
15645 local AFTER=$(roc_hit)
15647 do_nodes $list $LCTL set_param fail_loc=0
15649 if ! let "AFTER - BEFORE == CPAGES"; then
15650 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
15653 cancel_lru_locks osc
15654 # invalidates OST cache
15655 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
15656 set_osd_param $list '' read_cache_enable 0
15657 cat $DIR/$tfile >/dev/null
15659 # now data shouldn't be found in the cache
15661 cancel_lru_locks osc
15662 cat $DIR/$tfile >/dev/null
15664 if let "AFTER - BEFORE != 0"; then
15665 error "IN CACHE: before: $BEFORE, after: $AFTER"
15668 set_osd_param $list '' read_cache_enable 1
15671 run_test 151 "test cache on oss and controls ==============================="
15674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15676 local TF="$TMP/$tfile"
15678 # simulate ENOMEM during write
15679 #define OBD_FAIL_OST_NOMEM 0x226
15680 lctl set_param fail_loc=0x80000226
15681 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
15683 sync || error "sync failed"
15684 lctl set_param fail_loc=0
15686 # discard client's cache
15687 cancel_lru_locks osc
15689 # simulate ENOMEM during read
15690 lctl set_param fail_loc=0x80000226
15691 cmp $TF $DIR/$tfile || error "cmp failed"
15692 lctl set_param fail_loc=0
15696 run_test 152 "test read/write with enomem ============================"
15699 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
15701 run_test 153 "test if fdatasync does not crash ======================="
15703 dot_lustre_fid_permission_check() {
15705 local ffid=$MOUNT/.lustre/fid/$fid
15708 echo "stat fid $fid"
15709 stat $ffid || error "stat $ffid failed."
15710 echo "touch fid $fid"
15711 touch $ffid || error "touch $ffid failed."
15712 echo "write to fid $fid"
15713 cat /etc/hosts > $ffid || error "write $ffid failed."
15714 echo "read fid $fid"
15715 diff /etc/hosts $ffid || error "read $ffid failed."
15716 echo "append write to fid $fid"
15717 cat /etc/hosts >> $ffid || error "append write $ffid failed."
15718 echo "rename fid $fid"
15719 mv $ffid $test_dir/$tfile.1 &&
15720 error "rename $ffid to $tfile.1 should fail."
15721 touch $test_dir/$tfile.1
15722 mv $test_dir/$tfile.1 $ffid &&
15723 error "rename $tfile.1 to $ffid should fail."
15724 rm -f $test_dir/$tfile.1
15725 echo "truncate fid $fid"
15726 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
15727 echo "link fid $fid"
15728 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
15729 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
15730 echo "setfacl fid $fid"
15731 setfacl -R -m u:$USER0:rwx $ffid ||
15732 error "setfacl $ffid failed"
15733 echo "getfacl fid $fid"
15734 getfacl $ffid || error "getfacl $ffid failed."
15736 echo "unlink fid $fid"
15737 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
15738 echo "mknod fid $fid"
15739 mknod $ffid c 1 3 && error "mknod $ffid should fail."
15741 fid=[0xf00000400:0x1:0x0]
15742 ffid=$MOUNT/.lustre/fid/$fid
15744 echo "stat non-exist fid $fid"
15745 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
15746 echo "write to non-exist fid $fid"
15747 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
15748 echo "link new fid $fid"
15749 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
15751 mkdir -p $test_dir/$tdir
15752 touch $test_dir/$tdir/$tfile
15753 fid=$($LFS path2fid $test_dir/$tdir)
15756 error "error: could not get fid for $test_dir/$dir/$tfile."
15758 ffid=$MOUNT/.lustre/fid/$fid
15761 ls $ffid || error "ls $ffid failed."
15762 echo "touch $fid/$tfile.1"
15763 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
15765 echo "touch $MOUNT/.lustre/fid/$tfile"
15766 touch $MOUNT/.lustre/fid/$tfile && \
15767 error "touch $MOUNT/.lustre/fid/$tfile should fail."
15769 echo "setxattr to $MOUNT/.lustre/fid"
15770 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
15772 echo "listxattr for $MOUNT/.lustre/fid"
15773 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
15775 echo "delxattr from $MOUNT/.lustre/fid"
15776 setfattr -x trusted.name1 $MOUNT/.lustre/fid
15778 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
15779 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
15780 error "touch invalid fid should fail."
15782 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
15783 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
15784 error "touch non-normal fid should fail."
15786 echo "rename $tdir to $MOUNT/.lustre/fid"
15787 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
15788 error "rename to $MOUNT/.lustre/fid should fail."
15790 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
15792 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
15793 local new_obf_mode=777
15795 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
15796 chmod $new_obf_mode $DIR/.lustre/fid ||
15797 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
15799 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
15800 [ $obf_mode -eq $new_obf_mode ] ||
15801 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
15803 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
15804 chmod $old_obf_mode $DIR/.lustre/fid ||
15805 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
15808 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
15809 fid=$($LFS path2fid $test_dir/$tfile-2)
15811 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
15813 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
15814 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
15815 error "create lov data thru .lustre failed"
15817 echo "cp /etc/passwd $test_dir/$tfile-2"
15818 cp /etc/passwd $test_dir/$tfile-2 ||
15819 error "copy to $test_dir/$tfile-2 failed."
15820 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
15821 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
15822 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
15824 rm -rf $test_dir/tfile.lnk
15825 rm -rf $test_dir/$tfile-2
15829 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15830 skip "Need MDS version at least 2.4.1"
15832 local tf=$DIR/$tfile
15835 local fid=$($LFS path2fid $tf)
15836 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
15838 # check that we get the same pathname back
15841 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
15842 echo "$rootpath $fid"
15843 found=$($LFS fid2path $rootpath "$fid")
15844 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
15845 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
15848 # check wrong root path format
15849 rootpath=$MOUNT"_wrong"
15850 found=$($LFS fid2path $rootpath "$fid")
15851 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
15853 run_test 154A "lfs path2fid and fid2path basic checks"
15856 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15857 skip "Need MDS version at least 2.4.1"
15859 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
15860 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
15861 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
15862 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
15864 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
15865 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
15867 # check that we get the same pathname
15868 echo "PFID: $PFID, name: $name"
15869 local FOUND=$($LFS fid2path $MOUNT "$PFID")
15870 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
15871 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
15872 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
15874 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
15876 run_test 154B "verify the ll_decode_linkea tool"
15879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15880 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15881 (( $MDS1_VERSION >= $(version_code 2.2.51) )) ||
15882 skip "Need MDS version at least 2.2.51"
15883 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
15885 cp /etc/hosts $DIR/$tfile
15887 fid=$($LFS path2fid $DIR/$tfile)
15889 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
15891 dot_lustre_fid_permission_check "$fid" $DIR ||
15892 error "dot lustre permission check $fid failed"
15894 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
15896 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
15898 touch $MOUNT/.lustre/file &&
15899 error "creation is not allowed under .lustre"
15901 mkdir $MOUNT/.lustre/dir &&
15902 error "mkdir is not allowed under .lustre"
15906 run_test 154a "Open-by-FID"
15909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15910 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15911 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15912 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
15913 skip "Need MDS version at least 2.2.51"
15915 local remote_dir=$DIR/$tdir/remote_dir
15919 mkdir -p $DIR/$tdir
15920 $LFS mkdir -i $MDTIDX $remote_dir ||
15921 error "create remote directory failed"
15923 cp /etc/hosts $remote_dir/$tfile
15925 fid=$($LFS path2fid $remote_dir/$tfile)
15927 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
15929 dot_lustre_fid_permission_check "$fid" $remote_dir ||
15930 error "dot lustre permission check $fid failed"
15933 run_test 154b "Open-by-FID for remote directory"
15936 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15937 skip "Need MDS version at least 2.4.1"
15939 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
15940 local FID1=$($LFS path2fid $DIR/$tfile.1)
15941 local FID2=$($LFS path2fid $DIR/$tfile.2)
15942 local FID3=$($LFS path2fid $DIR/$tfile.3)
15945 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
15946 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
15947 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
15949 [ "$FID" = "${!want}" ] ||
15950 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
15954 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
15956 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
15957 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
15961 run_test 154c "lfs path2fid and fid2path multiple arguments"
15964 remote_mds_nodsh && skip "remote MDS with nodsh"
15965 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
15966 skip "Need MDS version at least 2.5.53"
15968 if remote_mds; then
15969 nid=$($LCTL list_nids | sed "s/\./\\\./g")
15973 local proc_ofile="mdt.*.exports.'$nid'.open_files"
15980 local fid=$($LFS path2fid $DIR/$tfile)
15983 cmd="exec $fd<$DIR/$tfile"
15985 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
15986 echo "$fid_list" | grep "$fid"
15989 cmd="exec $fd>/dev/null"
15991 if [ $rc -ne 0 ]; then
15992 error "FID $fid not found in open files list $fid_list"
15995 run_test 154d "Verify open file fid"
15999 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
16000 skip "Need MDS version at least 2.6.50"
16002 if ls -a $MOUNT | grep -q '^\.lustre$'; then
16003 error ".lustre returned by readdir"
16006 run_test 154e ".lustre is not returned by readdir"
16009 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16011 # create parent directory on a single MDT to avoid cross-MDT hardlinks
16012 mkdir_on_mdt0 $DIR/$tdir
16013 # test dirs inherit from its stripe
16014 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
16015 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
16016 cp /etc/hosts $DIR/$tdir/foo1/$tfile
16017 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
16020 # get fid of parents
16021 local FID0=$($LFS path2fid $DIR/$tdir)
16022 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
16023 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
16024 local FID3=$($LFS path2fid $DIR)
16026 # check that path2fid --parents returns expected <parent_fid>/name
16027 # 1) test for a directory (single parent)
16028 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
16029 [ "$parent" == "$FID0/foo1" ] ||
16030 error "expected parent: $FID0/foo1, got: $parent"
16032 # 2) test for a file with nlink > 1 (multiple parents)
16033 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
16034 echo "$parent" | grep -F "$FID1/$tfile" ||
16035 error "$FID1/$tfile not returned in parent list"
16036 echo "$parent" | grep -F "$FID2/link" ||
16037 error "$FID2/link not returned in parent list"
16039 # 3) get parent by fid
16040 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
16041 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16042 echo "$parent" | grep -F "$FID1/$tfile" ||
16043 error "$FID1/$tfile not returned in parent list (by fid)"
16044 echo "$parent" | grep -F "$FID2/link" ||
16045 error "$FID2/link not returned in parent list (by fid)"
16047 # 4) test for entry in root directory
16048 parent=$($LFS path2fid --parents $DIR/f)
16049 echo "$parent" | grep -F "$FID3/f" ||
16050 error "$FID3/f not returned in parent list"
16052 # 5) test it on root directory
16053 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
16054 error "$MOUNT should not have parents"
16056 # enable xattr caching and check that linkea is correctly updated
16057 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
16058 save_lustre_params client "llite.*.xattr_cache" > $save
16059 lctl set_param llite.*.xattr_cache 1
16061 # 6.1) linkea update on rename
16062 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
16064 # get parents by fid
16065 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16066 # foo1 should no longer be returned in parent list
16067 echo "$parent" | grep -F "$FID1" &&
16068 error "$FID1 should no longer be in parent list"
16069 # the new path should appear
16070 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
16071 error "$FID2/$tfile.moved is not in parent list"
16073 # 6.2) linkea update on unlink
16074 rm -f $DIR/$tdir/foo2/link
16075 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16076 # foo2/link should no longer be returned in parent list
16077 echo "$parent" | grep -F "$FID2/link" &&
16078 error "$FID2/link should no longer be in parent list"
16082 restore_lustre_params < $save
16085 run_test 154f "get parent fids by reading link ea"
16089 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
16090 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
16091 skip "Need MDS version at least 2.6.92"
16093 mkdir_on_mdt0 $DIR/$tdir
16094 llapi_fid_test -d $DIR/$tdir
16096 run_test 154g "various llapi FID tests"
16098 test_155_small_load() {
16099 local temp=$TMP/$tfile
16100 local file=$DIR/$tfile
16102 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
16103 error "dd of=$temp bs=6096 count=1 failed"
16105 cancel_lru_locks $OSC
16106 cmp $temp $file || error "$temp $file differ"
16108 $TRUNCATE $temp 6000
16109 $TRUNCATE $file 6000
16110 cmp $temp $file || error "$temp $file differ (truncate1)"
16112 echo "12345" >>$temp
16113 echo "12345" >>$file
16114 cmp $temp $file || error "$temp $file differ (append1)"
16116 echo "12345" >>$temp
16117 echo "12345" >>$file
16118 cmp $temp $file || error "$temp $file differ (append2)"
16124 test_155_big_load() {
16125 remote_ost_nodsh && skip "remote OST with nodsh"
16127 local temp=$TMP/$tfile
16128 local file=$DIR/$tfile
16131 local cache_size=$(do_facet ost$((MAXI+1)) \
16132 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
16134 # LU-16042: can not get the cache size on Arm64 VM here, fallback to a
16136 if [ -z "$cache_size" ]; then
16139 local large_file_size=$((cache_size * 2))
16141 echo "OSS cache size: $cache_size KB"
16142 echo "Large file size: $large_file_size KB"
16144 [ $MAXV -le $large_file_size ] &&
16145 skip_env "max available OST size needs > $large_file_size KB"
16147 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
16149 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
16150 error "dd of=$temp bs=$large_file_size count=1k failed"
16153 cancel_lru_locks osc
16154 cmp $temp $file || error "$temp $file differ"
16160 save_writethrough() {
16161 local facets=$(get_facets OST)
16163 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
16167 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16169 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16171 save_writethrough $p
16174 set_cache writethrough on
16175 test_155_small_load
16176 restore_lustre_params < $p
16179 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
16182 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16184 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16186 save_writethrough $p
16189 set_cache writethrough off
16190 test_155_small_load
16191 restore_lustre_params < $p
16194 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
16197 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16199 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16201 save_writethrough $p
16204 set_cache writethrough on
16205 test_155_small_load
16206 restore_lustre_params < $p
16209 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
16212 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16214 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16216 save_writethrough $p
16219 set_cache writethrough off
16220 test_155_small_load
16221 restore_lustre_params < $p
16224 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
16227 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16229 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16231 save_writethrough $p
16234 set_cache writethrough on
16236 restore_lustre_params < $p
16239 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
16242 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16244 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16246 save_writethrough $p
16249 set_cache writethrough off
16251 restore_lustre_params < $p
16254 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
16257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16259 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16261 save_writethrough $p
16264 set_cache writethrough on
16266 restore_lustre_params < $p
16269 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
16272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16274 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16276 save_writethrough $p
16279 set_cache writethrough off
16281 restore_lustre_params < $p
16284 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
16287 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16288 remote_ost_nodsh && skip "remote OST with nodsh"
16289 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
16290 skip "stats not implemented on old servers"
16291 [ "$ost1_FSTYPE" = "zfs" ] &&
16292 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
16297 local file="$DIR/$tfile"
16298 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16300 save_writethrough $p
16303 log "Turn on read and write cache"
16305 set_cache writethrough on
16307 log "Write data and read it back."
16308 log "Read should be satisfied from the cache."
16309 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16311 cancel_lru_locks osc
16312 cat $file >/dev/null
16314 if ! let "AFTER - BEFORE == CPAGES"; then
16315 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
16317 log "cache hits: before: $BEFORE, after: $AFTER"
16320 log "Read again; it should be satisfied from the cache."
16322 cancel_lru_locks osc
16323 cat $file >/dev/null
16325 if ! let "AFTER - BEFORE == CPAGES"; then
16326 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
16328 log "cache hits:: before: $BEFORE, after: $AFTER"
16331 log "Turn off the read cache and turn on the write cache"
16333 set_cache writethrough on
16335 log "Read again; it should be satisfied from the cache."
16337 cancel_lru_locks osc
16338 cat $file >/dev/null
16340 if ! let "AFTER - BEFORE == CPAGES"; then
16341 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
16343 log "cache hits:: before: $BEFORE, after: $AFTER"
16346 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
16347 # > 2.12.56 uses pagecache if cached
16348 log "Read again; it should not be satisfied from the cache."
16350 cancel_lru_locks osc
16351 cat $file >/dev/null
16353 if ! let "AFTER - BEFORE == 0"; then
16354 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
16356 log "cache hits:: before: $BEFORE, after: $AFTER"
16360 log "Write data and read it back."
16361 log "Read should be satisfied from the cache."
16362 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16364 cancel_lru_locks osc
16365 cat $file >/dev/null
16367 if ! let "AFTER - BEFORE == CPAGES"; then
16368 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
16370 log "cache hits:: before: $BEFORE, after: $AFTER"
16373 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
16374 # > 2.12.56 uses pagecache if cached
16375 log "Read again; it should not be satisfied from the cache."
16377 cancel_lru_locks osc
16378 cat $file >/dev/null
16380 if ! let "AFTER - BEFORE == 0"; then
16381 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
16383 log "cache hits:: before: $BEFORE, after: $AFTER"
16387 log "Turn off read and write cache"
16389 set_cache writethrough off
16391 log "Write data and read it back"
16392 log "It should not be satisfied from the cache."
16394 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16395 cancel_lru_locks osc
16397 cat $file >/dev/null
16399 if ! let "AFTER - BEFORE == 0"; then
16400 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
16402 log "cache hits:: before: $BEFORE, after: $AFTER"
16405 log "Turn on the read cache and turn off the write cache"
16407 set_cache writethrough off
16409 log "Write data and read it back"
16410 log "It should not be satisfied from the cache."
16412 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16414 cancel_lru_locks osc
16415 cat $file >/dev/null
16417 if ! let "AFTER - BEFORE == 0"; then
16418 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
16420 log "cache hits:: before: $BEFORE, after: $AFTER"
16423 log "Read again; it should be satisfied from the cache."
16425 cancel_lru_locks osc
16426 cat $file >/dev/null
16428 if ! let "AFTER - BEFORE == CPAGES"; then
16429 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
16431 log "cache hits:: before: $BEFORE, after: $AFTER"
16434 restore_lustre_params < $p
16437 run_test 156 "Verification of tunables"
16440 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16441 remote_mds_nodsh && skip "remote MDS with nodsh"
16442 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
16443 skip "Need MDS version at least 2.2.0"
16445 changelog_register || error "changelog_register failed"
16446 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16447 changelog_users $SINGLEMDS | grep -q $cl_user ||
16448 error "User $cl_user not found in changelog_users"
16450 mkdir_on_mdt0 $DIR/$tdir
16453 test_mkdir -p $DIR/$tdir/pics/2008/zachy
16454 changelog_clear 0 || error "changelog_clear failed"
16455 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
16456 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
16457 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
16458 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
16459 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
16460 rm $DIR/$tdir/pics/desktop.jpg
16462 echo "verifying changelog mask"
16463 changelog_chmask "-MKDIR"
16464 changelog_chmask "-CLOSE"
16466 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
16467 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
16469 changelog_chmask "+MKDIR"
16470 changelog_chmask "+CLOSE"
16472 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
16473 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
16475 MKDIRS=$(changelog_dump | grep -c "MKDIR")
16476 CLOSES=$(changelog_dump | grep -c "CLOSE")
16477 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
16478 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
16481 echo "verifying target fid"
16482 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
16483 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
16484 [ "$fidc" == "$fidf" ] ||
16485 error "changelog '$tfile' fid $fidc != file fid $fidf"
16486 echo "verifying parent fid"
16487 # The FID returned from the Changelog may be the directory shard on
16488 # a different MDT, and not the FID returned by path2fid on the parent.
16489 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
16490 # since this is what will matter when recreating this file in the tree.
16491 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
16492 local pathp=$($LFS fid2path $MOUNT "$fidp")
16493 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
16494 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
16496 echo "getting records for $cl_user"
16497 changelog_users $SINGLEMDS
16498 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
16500 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
16501 error "changelog_clear failed"
16502 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
16503 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
16504 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
16505 error "user index expect $user_rec1 + $nclr != $user_rec2"
16507 local min0_rec=$(changelog_users $SINGLEMDS |
16508 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
16509 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
16510 awk '{ print $1; exit; }')
16512 changelog_dump | tail -n 5
16513 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
16514 [ $first_rec == $((min0_rec + 1)) ] ||
16515 error "first index should be $min0_rec + 1 not $first_rec"
16517 # LU-3446 changelog index reset on MDT restart
16518 local cur_rec1=$(changelog_users $SINGLEMDS |
16519 awk '/^current.index:/ { print $NF }')
16520 changelog_clear 0 ||
16521 error "clear all changelog records for $cl_user failed"
16522 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
16523 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
16524 error "Fail to start $SINGLEMDS"
16525 local cur_rec2=$(changelog_users $SINGLEMDS |
16526 awk '/^current.index:/ { print $NF }')
16527 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
16528 [ $cur_rec1 == $cur_rec2 ] ||
16529 error "current index should be $cur_rec1 not $cur_rec2"
16531 echo "verifying users from this test are deregistered"
16532 changelog_deregister || error "changelog_deregister failed"
16533 changelog_users $SINGLEMDS | grep -q $cl_user &&
16534 error "User '$cl_user' still in changelog_users"
16536 # lctl get_param -n mdd.*.changelog_users
16537 # current_index: 144
16538 # ID index (idle seconds)
16539 # cl3 144 (2) mask=<list>
16540 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
16541 # this is the normal case where all users were deregistered
16542 # make sure no new records are added when no users are present
16543 local last_rec1=$(changelog_users $SINGLEMDS |
16544 awk '/^current.index:/ { print $NF }')
16545 touch $DIR/$tdir/chloe
16546 local last_rec2=$(changelog_users $SINGLEMDS |
16547 awk '/^current.index:/ { print $NF }')
16548 echo "verify changelogs are off: $last_rec1 == $last_rec2"
16549 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
16551 # any changelog users must be leftovers from a previous test
16552 changelog_users $SINGLEMDS
16553 echo "other changelog users; can't verify off"
16556 run_test 160a "changelog sanity"
16558 test_160b() { # LU-3587
16559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16560 remote_mds_nodsh && skip "remote MDS with nodsh"
16561 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
16562 skip "Need MDS version at least 2.2.0"
16564 changelog_register || error "changelog_register failed"
16565 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16566 changelog_users $SINGLEMDS | grep -q $cl_user ||
16567 error "User '$cl_user' not found in changelog_users"
16569 local longname1=$(str_repeat a 255)
16570 local longname2=$(str_repeat b 255)
16573 echo "creating very long named file"
16574 touch $longname1 || error "create of '$longname1' failed"
16575 echo "renaming very long named file"
16576 mv $longname1 $longname2
16578 changelog_dump | grep RENME | tail -n 5
16581 run_test 160b "Verify that very long rename doesn't crash in changelog"
16584 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16585 remote_mds_nodsh && skip "remote MDS with nodsh"
16587 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
16588 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
16589 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
16590 skip "Need MDS version at least 2.5.58 or 2.5.2+"
16594 # Registration step
16595 changelog_register || error "changelog_register failed"
16598 mkdir -p $DIR/$tdir
16599 $MCREATE $DIR/$tdir/foo_160c
16600 changelog_chmask "-TRUNC"
16601 $TRUNCATE $DIR/$tdir/foo_160c 200
16602 changelog_chmask "+TRUNC"
16603 $TRUNCATE $DIR/$tdir/foo_160c 199
16604 changelog_dump | tail -n 5
16605 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
16606 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
16608 run_test 160c "verify that changelog log catch the truncate event"
16611 remote_mds_nodsh && skip "remote MDS with nodsh"
16612 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16613 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16614 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
16615 skip "Need MDS version at least 2.7.60"
16617 # Registration step
16618 changelog_register || error "changelog_register failed"
16620 mkdir -p $DIR/$tdir/migrate_dir
16621 changelog_clear 0 || error "changelog_clear failed"
16623 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
16624 changelog_dump | tail -n 5
16625 local migrates=$(changelog_dump | grep -c "MIGRT")
16626 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
16628 run_test 160d "verify that changelog log catch the migrate event"
16631 remote_mds_nodsh && skip "remote MDS with nodsh"
16634 changelog_register || error "changelog_register failed"
16636 local MDT0=$(facet_svc $SINGLEMDS)
16639 # No user (expect fail)
16640 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
16642 if [ $rc -eq 0 ]; then
16643 error "Should fail without user"
16644 elif [ $rc -ne 4 ]; then
16645 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
16648 # Delete a future user (expect fail)
16649 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
16651 if [ $rc -eq 0 ]; then
16652 error "Deleted non-existant user cl77"
16653 elif [ $rc -ne 2 ]; then
16654 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
16657 # Clear to a bad index (1 billion should be safe)
16658 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
16661 if [ $rc -eq 0 ]; then
16662 error "Successfully cleared to invalid CL index"
16663 elif [ $rc -ne 22 ]; then
16664 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
16667 run_test 160e "changelog negative testing (should return errors)"
16670 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16671 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16672 skip "Need MDS version at least 2.10.56"
16674 local mdts=$(comma_list $(mdts_nodes))
16677 changelog_register || error "first changelog_register failed"
16678 changelog_register || error "second changelog_register failed"
16680 declare -A cl_user1
16681 declare -A cl_user2
16686 # generate some changelog records to accumulate on each MDT
16687 # use all_char because created files should be evenly distributed
16688 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16689 error "test_mkdir $tdir failed"
16690 log "$(date +%s): creating first files"
16691 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16692 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
16693 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
16696 # check changelogs have been generated
16697 local start=$SECONDS
16698 local idle_time=$((MDSCOUNT * 5 + 5))
16699 local nbcl=$(changelog_dump | wc -l)
16700 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16702 for param in "changelog_max_idle_time=$idle_time" \
16704 "changelog_min_gc_interval=2" \
16705 "changelog_min_free_cat_entries=3"; do
16706 local MDT0=$(facet_svc $SINGLEMDS)
16707 local var="${param%=*}"
16708 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16710 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16711 do_nodes $mdts $LCTL set_param mdd.*.$param
16714 # force cl_user2 to be idle (1st part), but also cancel the
16715 # cl_user1 records so that it is not evicted later in the test.
16716 local sleep1=$((idle_time / 2))
16717 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
16720 # simulate changelog catalog almost full
16721 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
16722 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
16724 for i in $(seq $MDSCOUNT); do
16725 cl_users=(${CL_USERS[mds$i]})
16726 cl_user1[mds$i]="${cl_users[0]}"
16727 cl_user2[mds$i]="${cl_users[1]}"
16729 [ -n "${cl_user1[mds$i]}" ] ||
16730 error "mds$i: no user registered"
16731 [ -n "${cl_user2[mds$i]}" ] ||
16732 error "mds$i: only ${cl_user2[mds$i]} is registered"
16734 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16735 [ -n "$user_rec1" ] ||
16736 error "mds$i: User ${cl_user1[mds$i]} not registered"
16737 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16738 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16739 [ -n "$user_rec2" ] ||
16740 error "mds$i: User ${cl_user1[mds$i]} not registered"
16741 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16742 "$user_rec1 + 2 == $user_rec2"
16743 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16744 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16745 "$user_rec1 + 2, but is $user_rec2"
16746 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16747 [ -n "$user_rec2" ] ||
16748 error "mds$i: User ${cl_user2[mds$i]} not registered"
16749 [ $user_rec1 == $user_rec2 ] ||
16750 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16751 "$user_rec1, but is $user_rec2"
16754 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
16755 local sleep2=$((idle_time - (SECONDS - start) + 1))
16756 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
16759 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16760 # cl_user1 should be OK because it recently processed records.
16761 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
16762 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16763 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
16764 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
16767 # ensure gc thread is done
16768 for i in $(mdts_nodes); do
16769 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16770 error "$i: GC-thread not done"
16774 for (( i = 1; i <= MDSCOUNT; i++ )); do
16775 # check cl_user1 still registered
16776 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16777 error "mds$i: User ${cl_user1[mds$i]} not registered"
16778 # check cl_user2 unregistered
16779 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16780 error "mds$i: User ${cl_user2[mds$i]} still registered"
16782 # check changelogs are present and starting at $user_rec1 + 1
16783 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16784 [ -n "$user_rec1" ] ||
16785 error "mds$i: User ${cl_user1[mds$i]} not registered"
16786 first_rec=$($LFS changelog $(facet_svc mds$i) |
16787 awk '{ print $1; exit; }')
16789 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16790 [ $((user_rec1 + 1)) == $first_rec ] ||
16791 error "mds$i: rec $first_rec != $user_rec1 + 1"
16794 run_test 160f "changelog garbage collect (timestamped users)"
16797 remote_mds_nodsh && skip "remote MDS with nodsh"
16798 [[ $MDS1_VERSION -ge $(version_code 2.14.55) ]] ||
16799 skip "Need MDS version at least 2.14.55"
16801 local mdts=$(comma_list $(mdts_nodes))
16804 changelog_register || error "first changelog_register failed"
16805 changelog_register || error "second changelog_register failed"
16807 declare -A cl_user1
16808 declare -A cl_user2
16813 # generate some changelog records to accumulate on each MDT
16814 # use all_char because created files should be evenly distributed
16815 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16816 error "test_mkdir $tdir failed"
16817 for ((i = 0; i < MDSCOUNT; i++)); do
16818 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16819 error "create $DIR/$tdir/d$i.1 failed"
16822 # check changelogs have been generated
16823 local nbcl=$(changelog_dump | wc -l)
16824 (( $nbcl > 0 )) || error "no changelogs found"
16826 # reduce the max_idle_indexes value to make sure we exceed it
16827 for param in "changelog_max_idle_indexes=2" \
16829 "changelog_min_gc_interval=2"; do
16830 local MDT0=$(facet_svc $SINGLEMDS)
16831 local var="${param%=*}"
16832 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16834 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16835 do_nodes $mdts $LCTL set_param mdd.*.$param ||
16836 error "unable to set mdd.*.$param"
16839 local start=$SECONDS
16840 for i in $(seq $MDSCOUNT); do
16841 cl_users=(${CL_USERS[mds$i]})
16842 cl_user1[mds$i]="${cl_users[0]}"
16843 cl_user2[mds$i]="${cl_users[1]}"
16845 [ -n "${cl_user1[mds$i]}" ] ||
16846 error "mds$i: user1 is not registered"
16847 [ -n "${cl_user2[mds$i]}" ] ||
16848 error "mds$i: only ${cl_user1[mds$i]} is registered"
16850 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16851 [ -n "$user_rec1" ] ||
16852 error "mds$i: user1 ${cl_user1[mds$i]} not found"
16853 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16854 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16855 [ -n "$user_rec2" ] ||
16856 error "mds$i: user1 ${cl_user1[mds$i]} not found (2)"
16857 echo "mds$i: verifying user1 ${cl_user1[mds$i]} clear: " \
16858 "$user_rec1 + 2 == $user_rec2"
16859 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16860 error "mds$i: user1 ${cl_user1[mds$i]} index " \
16861 "expected $user_rec1 + 2, but is $user_rec2"
16862 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16863 [ -n "$user_rec2" ] ||
16864 error "mds$i: user2 ${cl_user2[mds$i]} not found"
16865 [ $user_rec1 == $user_rec2 ] ||
16866 error "mds$i: user2 ${cl_user2[mds$i]} index " \
16867 "expected $user_rec1, but is $user_rec2"
16870 # ensure we are past the previous changelog_min_gc_interval set above
16871 local sleep2=$((start + 2 - SECONDS))
16872 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
16873 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16874 # cl_user1 should be OK because it recently processed records.
16875 for ((i = 0; i < MDSCOUNT; i++)); do
16876 $LFS mkdir -i $i $DIR/$tdir/d$i.3 ||
16877 error "create $DIR/$tdir/d$i.3 failed"
16880 # ensure gc thread is done
16881 for i in $(mdts_nodes); do
16882 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16883 error "$i: GC-thread not done"
16887 for (( i = 1; i <= MDSCOUNT; i++ )); do
16888 # check cl_user1 still registered
16889 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16890 error "mds$i: user1 ${cl_user1[mds$i]} not found (3)"
16891 # check cl_user2 unregistered
16892 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16893 error "mds$i: user2 ${cl_user2[mds$i]} is registered"
16895 # check changelogs are present and starting at $user_rec1 + 1
16896 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16897 [ -n "$user_rec1" ] ||
16898 error "mds$i: user1 ${cl_user1[mds$i]} not found (4)"
16899 first_rec=$($LFS changelog $(facet_svc mds$i) |
16900 awk '{ print $1; exit; }')
16902 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16903 [ $((user_rec1 + 1)) == $first_rec ] ||
16904 error "mds$i: rec $first_rec != $user_rec1 + 1"
16907 run_test 160g "changelog garbage collect on idle records"
16910 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16911 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16912 skip "Need MDS version at least 2.10.56"
16914 local mdts=$(comma_list $(mdts_nodes))
16917 changelog_register || error "first changelog_register failed"
16918 changelog_register || error "second changelog_register failed"
16920 declare -A cl_user1
16921 declare -A cl_user2
16926 # generate some changelog records to accumulate on each MDT
16927 # use all_char because created files should be evenly distributed
16928 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16929 error "test_mkdir $tdir failed"
16930 for ((i = 0; i < MDSCOUNT; i++)); do
16931 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16932 error "create $DIR/$tdir/d$i.1 failed"
16935 # check changelogs have been generated
16936 local nbcl=$(changelog_dump | wc -l)
16937 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16939 for param in "changelog_max_idle_time=10" \
16941 "changelog_min_gc_interval=2"; do
16942 local MDT0=$(facet_svc $SINGLEMDS)
16943 local var="${param%=*}"
16944 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16946 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16947 do_nodes $mdts $LCTL set_param mdd.*.$param
16950 # force cl_user2 to be idle (1st part)
16953 for i in $(seq $MDSCOUNT); do
16954 cl_users=(${CL_USERS[mds$i]})
16955 cl_user1[mds$i]="${cl_users[0]}"
16956 cl_user2[mds$i]="${cl_users[1]}"
16958 [ -n "${cl_user1[mds$i]}" ] ||
16959 error "mds$i: no user registered"
16960 [ -n "${cl_user2[mds$i]}" ] ||
16961 error "mds$i: only ${cl_user2[mds$i]} is registered"
16963 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16964 [ -n "$user_rec1" ] ||
16965 error "mds$i: User ${cl_user1[mds$i]} not registered"
16966 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16967 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16968 [ -n "$user_rec2" ] ||
16969 error "mds$i: User ${cl_user1[mds$i]} not registered"
16970 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16971 "$user_rec1 + 2 == $user_rec2"
16972 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16973 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16974 "$user_rec1 + 2, but is $user_rec2"
16975 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16976 [ -n "$user_rec2" ] ||
16977 error "mds$i: User ${cl_user2[mds$i]} not registered"
16978 [ $user_rec1 == $user_rec2 ] ||
16979 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16980 "$user_rec1, but is $user_rec2"
16983 # force cl_user2 to be idle (2nd part) and to reach
16984 # changelog_max_idle_time
16987 # force each GC-thread start and block then
16988 # one per MDT/MDD, set fail_val accordingly
16989 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
16990 do_nodes $mdts $LCTL set_param fail_loc=0x1316
16992 # generate more changelogs to trigger fail_loc
16993 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16994 error "create $DIR/$tdir/${tfile}bis failed"
16996 # stop MDT to stop GC-thread, should be done in back-ground as it will
16997 # block waiting for the thread to be released and exit
16998 declare -A stop_pids
16999 for i in $(seq $MDSCOUNT); do
17001 stop_pids[mds$i]=$!
17004 for i in $(mdts_nodes); do
17007 local facets=$(facets_up_on_host $i)
17009 for facet in ${facets//,/ }; do
17010 if [[ $facet == mds* ]]; then
17014 # ensure each MDS's gc threads are still present and all in "R"
17015 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
17016 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
17017 error "$i: expected $nb GC-thread"
17019 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
17021 error "$i: GC-thread not found in R-state"
17022 # check umounts of each MDT on MDS have reached kthread_stop()
17023 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
17024 error "$i: expected $nb umount"
17026 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
17027 error "$i: umount not found in D-state"
17030 # release all GC-threads
17031 do_nodes $mdts $LCTL set_param fail_loc=0
17033 # wait for MDT stop to complete
17034 for i in $(seq $MDSCOUNT); do
17035 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
17039 # may try to check if any orphan changelog records are present
17040 # via ldiskfs/zfs and llog_reader...
17042 # re-start/mount MDTs
17043 for i in $(seq $MDSCOUNT); do
17044 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
17045 error "Fail to start mds$i"
17049 for i in $(seq $MDSCOUNT); do
17050 # check cl_user1 still registered
17051 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
17052 error "mds$i: User ${cl_user1[mds$i]} not registered"
17053 # check cl_user2 unregistered
17054 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
17055 error "mds$i: User ${cl_user2[mds$i]} still registered"
17057 # check changelogs are present and starting at $user_rec1 + 1
17058 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17059 [ -n "$user_rec1" ] ||
17060 error "mds$i: User ${cl_user1[mds$i]} not registered"
17061 first_rec=$($LFS changelog $(facet_svc mds$i) |
17062 awk '{ print $1; exit; }')
17064 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
17065 [ $((user_rec1 + 1)) == $first_rec ] ||
17066 error "mds$i: first index should be $user_rec1 + 1, " \
17067 "but is $first_rec"
17070 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
17075 local mdts=$(comma_list $(mdts_nodes))
17077 changelog_register || error "first changelog_register failed"
17079 # generate some changelog records to accumulate on each MDT
17080 # use all_char because created files should be evenly distributed
17081 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17082 error "test_mkdir $tdir failed"
17083 for ((i = 0; i < MDSCOUNT; i++)); do
17084 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17085 error "create $DIR/$tdir/d$i.1 failed"
17088 # check changelogs have been generated
17089 local nbcl=$(changelog_dump | wc -l)
17090 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17092 # simulate race between register and unregister
17093 # XXX as fail_loc is set per-MDS, with DNE configs the race
17094 # simulation will only occur for one MDT per MDS and for the
17095 # others the normal race scenario will take place
17096 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
17097 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
17098 do_nodes $mdts $LCTL set_param fail_val=1
17100 # unregister 1st user
17101 changelog_deregister &
17103 # wait some time for deregister work to reach race rdv
17105 # register 2nd user
17106 changelog_register || error "2nd user register failed"
17108 wait $pid1 || error "1st user deregister failed"
17112 declare -A LAST_REC
17113 for i in $(seq $MDSCOUNT); do
17114 if changelog_users mds$i | grep "^cl"; then
17115 # make sure new records are added with one user present
17116 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
17117 awk '/^current.index:/ { print $NF }')
17119 error "mds$i has no user registered"
17123 # generate more changelog records to accumulate on each MDT
17124 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
17125 error "create $DIR/$tdir/${tfile}bis failed"
17127 for i in $(seq $MDSCOUNT); do
17128 last_rec=$(changelog_users $SINGLEMDS |
17129 awk '/^current.index:/ { print $NF }')
17130 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
17131 [ $last_rec != ${LAST_REC[mds$i]} ] ||
17132 error "changelogs are off on mds$i"
17135 run_test 160i "changelog user register/unregister race"
17138 remote_mds_nodsh && skip "remote MDS with nodsh"
17139 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
17140 skip "Need MDS version at least 2.12.56"
17142 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
17143 stack_trap "umount $MOUNT2" EXIT
17145 changelog_register || error "first changelog_register failed"
17146 stack_trap "changelog_deregister" EXIT
17148 # generate some changelog
17149 # use all_char because created files should be evenly distributed
17150 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17151 error "mkdir $tdir failed"
17152 for ((i = 0; i < MDSCOUNT; i++)); do
17153 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17154 error "create $DIR/$tdir/d$i.1 failed"
17157 # open the changelog device
17158 exec 3>/dev/changelog-$FSNAME-MDT0000
17159 stack_trap "exec 3>&-" EXIT
17160 exec 4</dev/changelog-$FSNAME-MDT0000
17161 stack_trap "exec 4<&-" EXIT
17163 # umount the first lustre mount
17165 stack_trap "mount_client $MOUNT" EXIT
17167 # read changelog, which may or may not fail, but should not crash
17171 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17172 changelog_users $SINGLEMDS | grep -q $cl_user ||
17173 error "User $cl_user not found in changelog_users"
17175 printf 'clear:'$cl_user':0' >&3
17177 run_test 160j "client can be umounted while its chanangelog is being used"
17180 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17181 remote_mds_nodsh && skip "remote MDS with nodsh"
17183 mkdir -p $DIR/$tdir/1/1
17185 changelog_register || error "changelog_register failed"
17186 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17188 changelog_users $SINGLEMDS | grep -q $cl_user ||
17189 error "User '$cl_user' not found in changelog_users"
17190 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
17191 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
17192 rmdir $DIR/$tdir/1/1 & sleep 1
17194 touch $DIR/$tdir/2/2
17195 rm -rf $DIR/$tdir/2
17200 changelog_dump | grep rmdir || error "rmdir not recorded"
17202 run_test 160k "Verify that changelog records are not lost"
17204 # Verifies that a file passed as a parameter has recently had an operation
17205 # performed on it that has generated an MTIME changelog which contains the
17206 # correct parent FID. As files might reside on a different MDT from the
17207 # parent directory in DNE configurations, the FIDs are translated to paths
17208 # before being compared, which should be identical
17209 compare_mtime_changelog() {
17217 mdtidx=$($LFS getstripe --mdt-index $file)
17218 mdtidx=$(printf "%04x" $mdtidx)
17220 # Obtain the parent FID from the MTIME changelog
17221 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
17222 [ -z "$mtime" ] && error "MTIME changelog not recorded"
17224 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
17225 [ -z "$cl_fid" ] && error "parent FID not present"
17227 # Verify that the path for the parent FID is the same as the path for
17228 # the test directory
17229 pdir=$($LFS fid2path $MOUNT "$cl_fid")
17233 [[ "${pdir%/}" == "$dir" ]] ||
17234 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
17238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17240 remote_mds_nodsh && skip "remote MDS with nodsh"
17241 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
17242 skip "Need MDS version at least 2.13.55"
17246 changelog_register || error "changelog_register failed"
17247 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17249 changelog_users $SINGLEMDS | grep -q $cl_user ||
17250 error "User '$cl_user' not found in changelog_users"
17252 # Clear some types so that MTIME changelogs are generated
17253 changelog_chmask "-CREAT"
17254 changelog_chmask "-CLOSE"
17256 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
17258 # Test CL_MTIME during setattr
17259 touch $DIR/$tdir/$tfile
17260 compare_mtime_changelog $DIR/$tdir/$tfile
17262 # Test CL_MTIME during close
17263 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
17264 compare_mtime_changelog $DIR/$tdir/${tfile}_2
17266 run_test 160l "Verify that MTIME changelog records contain the parent FID"
17269 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17270 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17271 skip "Need MDS version at least 2.14.51"
17278 changelog_register || error "first changelog_register failed"
17279 changelog_register || error "second changelog_register failed"
17281 cl_users=(${CL_USERS[mds1]})
17282 cl_user1="${cl_users[0]}"
17283 cl_user2="${cl_users[1]}"
17284 # generate some changelog records to accumulate on MDT0
17285 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17286 createmany -m $DIR/$tdir/$tfile 50 ||
17287 error "create $DIR/$tdir/$tfile failed"
17288 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
17291 # check changelogs have been generated
17292 local nbcl=$(changelog_dump | wc -l)
17293 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17295 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
17296 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
17298 __changelog_clear mds1 $cl_user1 +10
17299 __changelog_clear mds1 $cl_user2 0 &
17302 __changelog_clear mds1 $cl_user1 0 ||
17303 error "fail to cancel record for $cl_user1"
17305 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
17307 run_test 160m "Changelog clear race"
17310 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17311 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17312 skip "Need MDS version at least 2.14.51"
17321 changelog_register || error "first changelog_register failed"
17323 cl_users=(${CL_USERS[mds1]})
17324 cl_user1="${cl_users[0]}"
17326 # generate some changelog records to accumulate on MDT0
17327 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17328 first_rec=$(changelog_users $SINGLEMDS |
17329 awk '/^current.index:/ { print $NF }')
17330 while (( last_rec < (( first_rec + 65000)) )); do
17331 createmany -m $DIR/$tdir/$tfile 10000 ||
17332 error "create $DIR/$tdir/$tfile failed"
17334 for i in $(seq 0 10000); do
17335 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
17339 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
17340 error "unlinkmany failed unlink"
17341 last_rec=$(changelog_users $SINGLEMDS |
17342 awk '/^current.index:/ { print $NF }')
17343 echo last record $last_rec
17344 (( last_rec == 0 )) && error "no changelog found"
17347 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
17348 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
17350 __changelog_clear mds1 $cl_user1 0 &
17353 __changelog_clear mds1 $cl_user1 0 ||
17354 error "fail to cancel record for $cl_user1"
17356 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
17358 run_test 160n "Changelog destroy race"
17361 local mdt="$(facet_svc $SINGLEMDS)"
17363 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
17364 remote_mds_nodsh && skip "remote MDS with nodsh"
17365 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
17366 skip "Need MDS version at least 2.14.52"
17368 changelog_register --user test_160o -m unlnk+close+open ||
17369 error "changelog_register failed"
17371 do_facet $SINGLEMDS $LCTL --device $mdt \
17372 changelog_register -u "Tt3_-#" &&
17373 error "bad symbols in name should fail"
17375 do_facet $SINGLEMDS $LCTL --device $mdt \
17376 changelog_register -u test_160o &&
17377 error "the same name registration should fail"
17379 do_facet $SINGLEMDS $LCTL --device $mdt \
17380 changelog_register -u test_160toolongname &&
17381 error "too long name registration should fail"
17383 changelog_chmask "MARK+HSM"
17384 lctl get_param mdd.*.changelog*mask
17385 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17386 changelog_users $SINGLEMDS | grep -q $cl_user ||
17387 error "User $cl_user not found in changelog_users"
17389 echo $cl_user | grep -q test_160o ||
17390 error "User $cl_user has no specific name 'test160o'"
17393 changelog_clear 0 || error "changelog_clear failed"
17394 # generate some changelog records to accumulate on MDT0
17395 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17396 touch $DIR/$tdir/$tfile # open 1
17398 OPENS=$(changelog_dump | grep -c "OPEN")
17399 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
17401 # must be no MKDIR it wasn't set as user mask
17402 MKDIR=$(changelog_dump | grep -c "MKDIR")
17403 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
17405 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
17406 mdd.$mdt.changelog_current_mask -n)
17407 # register maskless user
17408 changelog_register || error "changelog_register failed"
17409 # effective mask should be not changed because it is not minimal
17410 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17411 mdd.$mdt.changelog_current_mask -n)
17412 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
17413 # set server mask to minimal value
17414 changelog_chmask "MARK"
17415 # check effective mask again, should be treated as DEFMASK now
17416 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17417 mdd.$mdt.changelog_current_mask -n)
17418 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
17420 if (( $MDS1_VERSION >= $(version_code 2.15.52) )) ; then
17421 # set server mask back to some value
17422 changelog_chmask "CLOSE,UNLNK"
17423 # check effective mask again, should not remain as DEFMASK
17424 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17425 mdd.$mdt.changelog_current_mask -n)
17426 [[ $mask != *"HLINK"* ]] || error "mask is still DEFMASK"
17429 do_facet $SINGLEMDS $LCTL --device $mdt \
17430 changelog_deregister -u test_160o ||
17431 error "cannot deregister by name"
17433 run_test 160o "changelog user name and mask"
17436 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17437 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17438 skip "Need MDS version at least 2.14.51"
17439 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
17445 changelog_register || error "first changelog_register failed"
17447 cl_users=(${CL_USERS[mds1]})
17448 cl_user1="${cl_users[0]}"
17450 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17451 createmany -m $DIR/$tdir/$tfile 50 ||
17452 error "create $DIR/$tdir/$tfile failed"
17453 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
17456 # check changelogs have been generated
17457 entry_count=$(changelog_dump | wc -l)
17458 ((entry_count != 0)) || error "no changelog entries found"
17460 # remove changelog_users and check that orphan entries are removed
17462 local dev=$(mdsdevname 1)
17463 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $dev"
17464 start mds1 $dev $MDS_MOUNT_OPTS || error "cannot start mds1"
17465 entry_count=$(changelog_dump | wc -l)
17466 ((entry_count == 0)) ||
17467 error "found $entry_count changelog entries, expected none"
17469 run_test 160p "Changelog orphan cleanup with no users"
17472 local mdt="$(facet_svc $SINGLEMDS)"
17475 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
17476 remote_mds_nodsh && skip "remote MDS with nodsh"
17477 [ $MDS1_VERSION -ge $(version_code 2.14.54) ] ||
17478 skip "Need MDS version at least 2.14.54"
17480 # set server mask to minimal value like server init does
17481 changelog_chmask "MARK"
17482 clu=$(do_facet $SINGLEMDS $LCTL --device $mdt changelog_register -n) ||
17483 error "changelog_register failed"
17484 # check effective mask again, should be treated as DEFMASK now
17485 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17486 mdd.$mdt.changelog_current_mask -n)
17487 do_facet $SINGLEMDS $LCTL --device $mdt changelog_deregister $clu ||
17488 error "changelog_deregister failed"
17489 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
17491 run_test 160q "changelog effective mask is DEFMASK if not set"
17494 remote_mds_nodsh && skip "remote MDS with nodsh"
17495 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
17496 skip "Need MDS version at least 2.14.55"
17498 local mdts=$(comma_list $(mdts_nodes))
17500 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
17501 do_nodes $mdts $LCTL set_param fail_loc=0x1314 \
17502 fail_val=$((24 * 3600 * 10))
17504 # Create a user which is 10 days old
17505 changelog_register || error "first changelog_register failed"
17507 declare -A cl_user1
17510 # generate some changelog records to accumulate on each MDT
17511 # use all_char because created files should be evenly distributed
17512 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17513 error "test_mkdir $tdir failed"
17514 for ((i = 0; i < MDSCOUNT; i++)); do
17515 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17516 error "create $DIR/$tdir/d$i.1 failed"
17519 # check changelogs have been generated
17520 local nbcl=$(changelog_dump | wc -l)
17521 (( nbcl > 0 )) || error "no changelogs found"
17523 # reduce the max_idle_indexes value to make sure we exceed it
17524 for param in "changelog_max_idle_indexes=2097446912" \
17525 "changelog_max_idle_time=2592000" \
17527 "changelog_min_gc_interval=2"; do
17528 local MDT0=$(facet_svc $SINGLEMDS)
17529 local var="${param%=*}"
17530 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17532 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17533 do_nodes $mdts $LCTL set_param mdd.*.$param ||
17534 error "unable to set mdd.*.$param"
17537 local start=$SECONDS
17538 for i in $(seq $MDSCOUNT); do
17539 cl_users=(${CL_USERS[mds$i]})
17540 cl_user1[mds$i]="${cl_users[0]}"
17542 [[ -n "${cl_user1[mds$i]}" ]] ||
17543 error "mds$i: no user registered"
17546 #define OBD_FAIL_MDS_CHANGELOG_IDX_PUMP 0x16d
17547 do_nodes $mdts $LCTL set_param fail_loc=0x16d fail_val=500000000
17549 # ensure we are past the previous changelog_min_gc_interval set above
17550 local sleep2=$((start + 2 - SECONDS))
17551 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17553 # Generate one more changelog to trigger GC
17554 for ((i = 0; i < MDSCOUNT; i++)); do
17555 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
17556 error "create $DIR/$tdir/d$i.3 failed"
17559 # ensure gc thread is done
17560 for node in $(mdts_nodes); do
17561 wait_update $node "pgrep chlg_gc_thread" "" 20 ||
17562 error "$node: GC-thread not done"
17565 do_nodes $mdts $LCTL set_param fail_loc=0
17567 for (( i = 1; i <= MDSCOUNT; i++ )); do
17568 # check cl_user1 is purged
17569 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" &&
17570 error "mds$i: User ${cl_user1[mds$i]} is registered"
17574 run_test 160s "changelog garbage collect on idle records * time"
17577 remote_mds_nodsh && skip "remote MDS with nodsh"
17578 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
17579 skip "Need MDS version at least 2.15.50"
17581 local MDT0=$(facet_svc $SINGLEMDS)
17587 changelog_register --user user1 -m all ||
17588 error "user1 failed to register"
17590 mkdir_on_mdt0 $DIR/$tdir
17591 # create default overstripe to maximize changelog size
17592 $LFS setstripe -C 8 $DIR/$tdir || error "setstripe failed"
17593 createmany -o $DIR/$tdir/u1_ 2000 || error "createmany for user1 failed"
17594 llog_size1=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
17596 # user2 consumes less records so less space
17597 changelog_register --user user2 || error "user2 failed to register"
17598 createmany -o $DIR/$tdir/u2_ 500 || error "createmany for user2 failed"
17599 llog_size2=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
17601 # check changelogs have been generated
17602 local nbcl=$(changelog_dump | wc -l)
17603 (( nbcl > 0 )) || error "no changelogs found"
17605 # reduce the changelog_min_gc_interval to force check
17606 for param in "changelog_gc=1" "changelog_min_gc_interval=2"; do
17607 local var="${param%=*}"
17608 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17610 stack_trap "do_facet mds1 $LCTL set_param mdd.$MDT0.$var=$old"
17611 do_facet mds1 $LCTL set_param mdd.$MDT0.$param ||
17612 error "unable to set mdd.*.$param"
17616 cl_users=(${CL_USERS[mds1]})
17617 cl_user1="${cl_users[0]}"
17618 cl_user2="${cl_users[1]}"
17620 [[ -n $cl_user1 ]] ||
17621 error "mds1: user #1 isn't registered"
17622 [[ -n $cl_user2 ]] ||
17623 error "mds1: user #2 isn't registered"
17625 # ensure we are past the previous changelog_min_gc_interval set above
17626 local sleep2=$((start + 2 - SECONDS))
17627 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17629 #define OBD_FAIL_MDS_CHANGELOG_ENOSPC 0x018c
17630 do_facet mds1 $LCTL set_param fail_loc=0x018c \
17631 fail_val=$(((llog_size1 + llog_size2) / 2))
17633 # Generate more changelog to trigger GC
17634 createmany -o $DIR/$tdir/u3_ 4 ||
17635 error "create failed for more files"
17637 # ensure gc thread is done
17638 wait_update_facet mds1 "pgrep chlg_gc_thread" "" 20 ||
17639 error "mds1: GC-thread not done"
17641 do_facet mds1 $LCTL set_param fail_loc=0
17643 # check cl_user1 is purged
17644 changelog_users mds1 | grep -q "$cl_user1" &&
17645 error "User $cl_user1 is registered"
17646 # check cl_user2 is not purged
17647 changelog_users mds1 | grep -q "$cl_user2" ||
17648 error "User $cl_user2 is not registered"
17650 run_test 160t "changelog garbage collect on lack of space"
17653 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17655 test_mkdir -c1 $DIR/$tdir
17656 cp /etc/hosts $DIR/$tdir/$tfile
17657 test_mkdir -c1 $DIR/$tdir/foo1
17658 test_mkdir -c1 $DIR/$tdir/foo2
17659 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
17660 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
17661 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
17662 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
17663 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
17664 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17665 $LFS fid2path $DIR $FID
17666 error "bad link ea"
17669 rm $DIR/$tdir/foo2/zachary
17671 rm $DIR/$tdir/foo2/thor
17673 rm $DIR/$tdir/$tfile
17675 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
17676 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
17677 { $LFS fid2path $DIR $FID; error "bad link rename"; }
17678 rm $DIR/$tdir/foo2/maggie
17681 local longname=$tfile.avg_len_is_thirty_two_
17682 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
17683 error_noexit 'failed to unlink many hardlinks'" EXIT
17684 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
17685 error "failed to hardlink many files"
17686 links=$($LFS fid2path $DIR $FID | wc -l)
17687 echo -n "${links}/1000 links in link EA"
17688 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
17690 run_test 161a "link ea sanity"
17693 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17694 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
17697 local remote_dir=$DIR/$tdir/remote_dir
17699 mkdir -p $DIR/$tdir
17700 $LFS mkdir -i $MDTIDX $remote_dir ||
17701 error "create remote directory failed"
17703 cp /etc/hosts $remote_dir/$tfile
17704 mkdir -p $remote_dir/foo1
17705 mkdir -p $remote_dir/foo2
17706 ln $remote_dir/$tfile $remote_dir/foo1/sofia
17707 ln $remote_dir/$tfile $remote_dir/foo2/zachary
17708 ln $remote_dir/$tfile $remote_dir/foo1/luna
17709 ln $remote_dir/$tfile $remote_dir/foo2/thor
17711 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
17713 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17714 $LFS fid2path $DIR $FID
17715 error "bad link ea"
17718 rm $remote_dir/foo2/zachary
17720 rm $remote_dir/foo2/thor
17722 rm $remote_dir/$tfile
17724 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
17725 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
17726 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
17727 $LFS fid2path $DIR $FID
17728 error "bad link rename"
17730 rm $remote_dir/foo2/maggie
17733 local longname=filename_avg_len_is_thirty_two_
17734 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
17735 error "failed to hardlink many files"
17736 links=$($LFS fid2path $DIR $FID | wc -l)
17737 echo -n "${links}/1000 links in link EA"
17738 [[ ${links} -gt 60 ]] ||
17739 error "expected at least 60 links in link EA"
17740 unlinkmany $remote_dir/foo2/$longname 1000 ||
17741 error "failed to unlink many hardlinks"
17743 run_test 161b "link ea sanity under remote directory"
17746 remote_mds_nodsh && skip "remote MDS with nodsh"
17747 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17748 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
17749 skip "Need MDS version at least 2.1.5"
17751 # define CLF_RENAME_LAST 0x0001
17752 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
17753 changelog_register || error "changelog_register failed"
17756 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
17757 touch $DIR/$tdir/foo_161c
17758 touch $DIR/$tdir/bar_161c
17759 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17760 changelog_dump | grep RENME | tail -n 5
17761 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17762 changelog_clear 0 || error "changelog_clear failed"
17763 if [ x$flags != "x0x1" ]; then
17764 error "flag $flags is not 0x1"
17767 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
17768 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
17769 touch $DIR/$tdir/foo_161c
17770 touch $DIR/$tdir/bar_161c
17771 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17772 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17773 changelog_dump | grep RENME | tail -n 5
17774 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17775 changelog_clear 0 || error "changelog_clear failed"
17776 if [ x$flags != "x0x0" ]; then
17777 error "flag $flags is not 0x0"
17779 echo "rename overwrite a target having nlink > 1," \
17780 "changelog record has flags of $flags"
17782 # rename doesn't overwrite a target (changelog flag 0x0)
17783 touch $DIR/$tdir/foo_161c
17784 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
17785 changelog_dump | grep RENME | tail -n 5
17786 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
17787 changelog_clear 0 || error "changelog_clear failed"
17788 if [ x$flags != "x0x0" ]; then
17789 error "flag $flags is not 0x0"
17791 echo "rename doesn't overwrite a target," \
17792 "changelog record has flags of $flags"
17794 # define CLF_UNLINK_LAST 0x0001
17795 # unlink a file having nlink = 1 (changelog flag 0x1)
17796 rm -f $DIR/$tdir/foo2_161c
17797 changelog_dump | grep UNLNK | tail -n 5
17798 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17799 changelog_clear 0 || error "changelog_clear failed"
17800 if [ x$flags != "x0x1" ]; then
17801 error "flag $flags is not 0x1"
17803 echo "unlink a file having nlink = 1," \
17804 "changelog record has flags of $flags"
17806 # unlink a file having nlink > 1 (changelog flag 0x0)
17807 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17808 rm -f $DIR/$tdir/foobar_161c
17809 changelog_dump | grep UNLNK | tail -n 5
17810 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17811 changelog_clear 0 || error "changelog_clear failed"
17812 if [ x$flags != "x0x0" ]; then
17813 error "flag $flags is not 0x0"
17815 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
17817 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
17820 remote_mds_nodsh && skip "remote MDS with nodsh"
17821 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
17826 changelog_register || error "changelog_register failed"
17828 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
17829 # interfer with $MOUNT/.lustre/fid/ access
17831 [[ $? -eq 0 ]] || error "mkdir failed"
17833 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
17834 $LCTL set_param fail_loc=0x8000140c
17836 $LCTL set_param fail_val=5
17839 echo foofoo > $DIR/$tdir/$tfile &
17842 # wait for create to be delayed
17846 [[ $? -eq 0 ]] || error "create should be blocked"
17848 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
17849 stack_trap "rm -f $tempfile"
17850 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
17851 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
17852 # some delay may occur during ChangeLog publishing and file read just
17853 # above, that could allow file write to happen finally
17854 [[ -s $tempfile ]] && echo "file should be empty"
17856 $LCTL set_param fail_loc=0
17859 [[ $? -eq 0 ]] || error "create failed"
17861 run_test 161d "create with concurrent .lustre/fid access"
17864 local expected="$1"
17869 path=$($LFS fid2path "$@")
17872 if [ $rc -ne 0 ]; then
17873 error "path looked up of '$expected' failed: rc=$rc"
17874 elif [ "$path" != "$expected" ]; then
17875 error "path looked up '$path' instead of '$expected'"
17877 echo "FID '$fid' resolves to path '$path' as expected"
17881 test_162a() { # was test_162
17882 test_mkdir -p -c1 $DIR/$tdir/d2
17883 touch $DIR/$tdir/d2/$tfile
17884 touch $DIR/$tdir/d2/x1
17885 touch $DIR/$tdir/d2/x2
17886 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
17887 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
17889 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
17890 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
17893 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
17894 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
17895 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
17897 # softlink to wrong file
17898 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
17899 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
17900 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
17903 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
17904 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
17905 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
17906 # fid2path dir/fsname should both work
17907 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
17908 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
17910 # hardlink count: check that there are 2 links
17911 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
17912 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
17914 # hardlink indexing: remove the first link
17915 rm $DIR/$tdir/d2/p/q/r/hlink
17916 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
17918 run_test 162a "path lookup sanity"
17921 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17922 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17925 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17926 error "create striped dir failed"
17928 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
17929 tail -n 1 | awk '{print $2}')
17930 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
17932 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
17933 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
17936 for ((i=0;i<5;i++)); do
17937 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
17938 error "get fid for f$i failed"
17939 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
17941 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
17942 error "get fid for d$i failed"
17943 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
17948 run_test 162b "striped directory path lookup sanity"
17950 # LU-4239: Verify fid2path works with paths 100 or more directories deep
17952 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
17953 skip "Need MDS version at least 2.7.51"
17955 local lpath=$tdir.local
17956 local rpath=$tdir.remote
17958 test_mkdir $DIR/$lpath
17959 test_mkdir $DIR/$rpath
17961 for ((i = 0; i <= 101; i++)); do
17964 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
17965 error "get fid for local directory $DIR/$lpath failed"
17966 check_path "$DIR/$lpath" $MOUNT $FID --link 0
17969 test_mkdir $DIR/$rpath
17970 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
17971 error "get fid for remote directory $DIR/$rpath failed"
17972 check_path "$DIR/$rpath" $MOUNT $FID --link 0
17977 run_test 162c "fid2path works with paths 100 or more directories deep"
17979 oalr_event_count() {
17983 awk -v name="${FSNAME}-OST0000" \
17984 -v event="${event}" \
17985 '$1 == "TRACE" && $2 == event && $3 == name' \
17990 oalr_expect_event_count() {
17993 local expect="${3}"
17996 count=$(oalr_event_count "${event}" "${trace}")
17997 if ((count == expect)); then
18001 error_noexit "${event} event count was '${count}', expected ${expect}"
18007 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
18009 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
18013 sync # Flush previous IOs so we can count log entries.
18014 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
18015 stack_trap cleanup_165 EXIT
18019 local trace="/tmp/${tfile}.trace"
18023 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18024 skip "OFD access log unsupported"
18027 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18030 do_facet ost1 ofd_access_log_reader --list
18033 do_facet ost1 killall -TERM ofd_access_log_reader
18037 if ((rc != 0)); then
18038 error "ofd_access_log_reader exited with rc = '${rc}'"
18041 # Parse trace file for discovery events:
18042 oalr_expect_event_count alr_log_add "${trace}" 1
18043 oalr_expect_event_count alr_log_eof "${trace}" 1
18044 oalr_expect_event_count alr_log_free "${trace}" 1
18046 run_test 165a "ofd access log discovery"
18049 local trace="/tmp/${tfile}.trace"
18050 local file="${DIR}/${tfile}"
18059 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18060 skip "OFD access log unsupported"
18063 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18066 do_facet ost1 ofd_access_log_reader --list
18068 lfs setstripe -c 1 -i 0 "${file}"
18069 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18070 error "cannot create '${file}'"
18073 do_facet ost1 killall -TERM ofd_access_log_reader
18077 if ((rc != 0)); then
18078 error "ofd_access_log_reader exited with rc = '${rc}'"
18081 oalr_expect_event_count alr_log_entry "${trace}" 1
18083 pfid1=$($LFS path2fid "${file}")
18085 # 1 2 3 4 5 6 7 8 9 10
18086 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
18087 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
18089 echo "entry = '${entry[*]}'" >&2
18092 if [[ "${pfid1}" != "${pfid2}" ]]; then
18093 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
18097 if ((size != 1048576)); then
18098 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
18102 if [[ "${flags}" != "w" ]]; then
18103 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
18106 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18109 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
18110 error "cannot read '${file}'"
18113 do_facet ost1 killall -TERM ofd_access_log_reader
18117 if ((rc != 0)); then
18118 error "ofd_access_log_reader exited with rc = '${rc}'"
18121 oalr_expect_event_count alr_log_entry "${trace}" 1
18123 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
18124 echo "entry = '${entry[*]}'" >&2
18127 if [[ "${pfid1}" != "${pfid2}" ]]; then
18128 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
18132 if ((size != 524288)); then
18133 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
18137 if [[ "${flags}" != "r" ]]; then
18138 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
18141 run_test 165b "ofd access log entries are produced and consumed"
18144 local trace="/tmp/${tfile}.trace"
18145 local file="${DIR}/${tdir}/${tfile}"
18147 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18148 skip "OFD access log unsupported"
18150 test_mkdir "${DIR}/${tdir}"
18153 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18156 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
18158 # 4096 / 64 = 64. Create twice as many entries.
18159 for ((i = 0; i < 128; i++)); do
18160 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
18161 error "cannot create file"
18166 do_facet ost1 killall -TERM ofd_access_log_reader
18169 if ((rc != 0)); then
18170 error "ofd_access_log_reader exited with rc = '${rc}'"
18173 unlinkmany "${file}-%d" 128
18175 run_test 165c "full ofd access logs do not block IOs"
18177 oal_get_read_count() {
18180 # STATS lustre-OST0001 alr_read_count 1
18182 do_facet ost1 cat "${stats}" |
18183 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
18184 END { print count; }'
18187 oal_expect_read_count() {
18192 # Ask ofd_access_log_reader to write stats.
18193 do_facet ost1 killall -USR1 ofd_access_log_reader
18195 # Allow some time for things to happen.
18198 count=$(oal_get_read_count "${stats}")
18199 if ((count == expect)); then
18203 error_noexit "bad read count, got ${count}, expected ${expect}"
18204 do_facet ost1 cat "${stats}" >&2
18209 local stats="/tmp/${tfile}.stats"
18210 local file="${DIR}/${tdir}/${tfile}"
18211 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
18213 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18214 skip "OFD access log unsupported"
18216 test_mkdir "${DIR}/${tdir}"
18219 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
18222 lfs setstripe -c 1 -i 0 "${file}"
18224 do_facet ost1 lctl set_param "${param}=rw"
18225 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18226 error "cannot create '${file}'"
18227 oal_expect_read_count "${stats}" 1
18229 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18230 error "cannot read '${file}'"
18231 oal_expect_read_count "${stats}" 2
18233 do_facet ost1 lctl set_param "${param}=r"
18234 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18235 error "cannot create '${file}'"
18236 oal_expect_read_count "${stats}" 2
18238 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18239 error "cannot read '${file}'"
18240 oal_expect_read_count "${stats}" 3
18242 do_facet ost1 lctl set_param "${param}=w"
18243 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18244 error "cannot create '${file}'"
18245 oal_expect_read_count "${stats}" 4
18247 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18248 error "cannot read '${file}'"
18249 oal_expect_read_count "${stats}" 4
18251 do_facet ost1 lctl set_param "${param}=0"
18252 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18253 error "cannot create '${file}'"
18254 oal_expect_read_count "${stats}" 4
18256 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18257 error "cannot read '${file}'"
18258 oal_expect_read_count "${stats}" 4
18260 do_facet ost1 killall -TERM ofd_access_log_reader
18263 if ((rc != 0)); then
18264 error "ofd_access_log_reader exited with rc = '${rc}'"
18267 run_test 165d "ofd_access_log mask works"
18270 local stats="/tmp/${tfile}.stats"
18271 local file0="${DIR}/${tdir}-0/${tfile}"
18272 local file1="${DIR}/${tdir}-1/${tfile}"
18274 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18275 skip "OFD access log unsupported"
18277 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
18279 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
18280 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
18282 lfs setstripe -c 1 -i 0 "${file0}"
18283 lfs setstripe -c 1 -i 0 "${file1}"
18286 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
18289 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
18290 error "cannot create '${file0}'"
18292 oal_expect_read_count "${stats}" 0
18294 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
18295 error "cannot create '${file1}'"
18297 oal_expect_read_count "${stats}" 1
18299 do_facet ost1 killall -TERM ofd_access_log_reader
18302 if ((rc != 0)); then
18303 error "ofd_access_log_reader exited with rc = '${rc}'"
18306 run_test 165e "ofd_access_log MDT index filter works"
18309 local trace="/tmp/${tfile}.trace"
18314 do_facet ost1 timeout 60 ofd_access_log_reader \
18315 --exit-on-close --debug=- --trace=- > "${trace}" &
18322 if ((rc != 0)); then
18323 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
18328 run_test 165f "ofd_access_log_reader --exit-on-close works"
18331 # do directio so as not to populate the page cache
18332 log "creating a 10 Mb file"
18333 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
18334 error "multiop failed while creating a file"
18335 log "starting reads"
18336 dd if=$DIR/$tfile of=/dev/null bs=4096 &
18337 log "truncating the file"
18338 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
18339 error "multiop failed while truncating the file"
18341 kill %+ || true # reads might have finished
18342 echo "wait until dd is finished"
18344 log "removing the temporary file"
18345 rm -rf $DIR/$tfile || error "tmp file removal failed"
18347 run_test 169 "parallel read and truncate should not deadlock"
18350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18352 $LCTL clear # bug 18514
18353 $LCTL debug_daemon start $TMP/${tfile}_log_good
18355 $LCTL debug_daemon stop
18356 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
18357 error "sed failed to read log_good"
18359 $LCTL debug_daemon start $TMP/${tfile}_log_good
18361 $LCTL debug_daemon stop
18363 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
18364 error "lctl df log_bad failed"
18366 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
18367 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
18369 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
18370 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
18372 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
18373 error "bad_line good_line1 good_line2 are empty"
18375 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
18376 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
18377 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
18379 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
18380 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
18381 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
18383 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
18384 error "bad_line_new good_line_new are empty"
18386 local expected_good=$((good_line1 + good_line2*2))
18388 rm -f $TMP/${tfile}*
18389 # LU-231, short malformed line may not be counted into bad lines
18390 if [ $bad_line -ne $bad_line_new ] &&
18391 [ $bad_line -ne $((bad_line_new - 1)) ]; then
18392 error "expected $bad_line bad lines, but got $bad_line_new"
18396 if [ $expected_good -ne $good_line_new ]; then
18397 error "expected $expected_good good lines, but got $good_line_new"
18402 run_test 170 "test lctl df to handle corrupted log ====================="
18404 test_171() { # bug20592
18405 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18407 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
18408 $LCTL set_param fail_loc=0x50e
18409 $LCTL set_param fail_val=3000
18410 multiop_bg_pause $DIR/$tfile O_s || true
18412 kill -USR1 $MULTIPID
18416 if dmesg | grep "recursive fault"; then
18417 error "caught a recursive fault"
18419 $LCTL set_param fail_loc=0
18422 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
18426 #define OBD_FAIL_OBD_CLEANUP 0x60e
18427 $LCTL set_param fail_loc=0x60e
18428 umount $MOUNT || error "umount $MOUNT failed"
18429 stack_trap "mount_client $MOUNT"
18431 (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )) ||
18432 error "no client OBDs are remained"
18434 $LCTL dl | while read devno state type name foo; do
18437 $LCTL --device $name cleanup
18438 $LCTL --device $name detach
18441 # skip server devices
18446 if (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )); then
18447 $LCTL dl | egrep " osc | lov | lmv | mdc "
18448 error "some client OBDs are still remained"
18452 run_test 172 "manual device removal with lctl cleanup/detach ======"
18454 # it would be good to share it with obdfilter-survey/iokit-libecho code
18455 setup_obdecho_osc () {
18458 local obdfilter_name=$2
18459 echo "Creating new osc for $obdfilter_name on $ost_nid"
18460 # make sure we can find loopback nid
18461 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
18463 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
18464 ${obdfilter_name}_osc_UUID || rc=2; }
18465 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
18466 ${obdfilter_name}_UUID $ost_nid || rc=3; }
18470 cleanup_obdecho_osc () {
18471 local obdfilter_name=$1
18472 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
18473 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
18480 local pages=${3:-64}
18485 local obd_size=$(get_obd_size $node $OBD)
18486 local page_size=$(get_page_size $node)
18487 if [[ -n "$obd_size" ]]; then
18488 local new_count=$((obd_size / (pages * page_size / 1024)))
18489 [[ $new_count -ge $count ]] || count=$new_count
18492 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
18493 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
18495 if [ $rc -eq 0 ]; then
18496 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
18497 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
18499 echo "New object id is $id"
18500 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
18502 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
18503 "test_brw $count w v $pages $id" || rc=4; }
18504 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
18506 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
18507 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
18508 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
18509 { do_facet $node "$LCTL --device ec detach" || rc=6; }
18510 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
18515 skip "obdecho on osc is no longer supported"
18517 run_test 180a "test obdecho on osc"
18520 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18521 remote_ost_nodsh && skip "remote OST with nodsh"
18523 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
18524 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
18525 error "failed to load module obdecho"
18527 local target=$(do_facet ost1 $LCTL dl |
18528 awk '/obdfilter/ { print $4; exit; }')
18530 if [ -n "$target" ]; then
18531 obdecho_test $target ost1 || error "obdecho_test failed with $?"
18533 do_facet ost1 $LCTL dl
18534 error "there is no obdfilter target on ost1"
18537 run_test 180b "test obdecho directly on obdfilter"
18539 test_180c() { # LU-2598
18540 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18541 remote_ost_nodsh && skip "remote OST with nodsh"
18542 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
18543 skip "Need MDS version at least 2.4.0"
18545 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
18546 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
18547 error "failed to load module obdecho"
18549 local target=$(do_facet ost1 $LCTL dl |
18550 awk '/obdfilter/ { print $4; exit; }')
18552 if [ -n "$target" ]; then
18553 local pages=16384 # 64MB bulk I/O RPC size
18555 obdecho_test "$target" ost1 "$pages" ||
18556 error "obdecho_test with pages=$pages failed with $?"
18558 do_facet ost1 $LCTL dl
18559 error "there is no obdfilter target on ost1"
18562 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
18564 test_181() { # bug 22177
18565 test_mkdir $DIR/$tdir
18566 # create enough files to index the directory
18567 createmany -o $DIR/$tdir/foobar 4000
18568 # print attributes for debug purpose
18571 multiop_bg_pause $DIR/$tdir D_Sc || return 1
18573 # remove the files & current working dir
18574 unlinkmany $DIR/$tdir/foobar 4000
18576 kill -USR1 $MULTIPID
18578 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
18581 run_test 181 "Test open-unlinked dir ========================"
18587 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18589 $LCTL set_param mdc.*.rpc_stats=clear
18591 for (( i = 0; i < $tcount; i++ )) ; do
18592 mkdir $DIR/$tdir/$i
18595 for (( i = 0; i < $tcount; i++ )) ; do
18596 createmany -o $DIR/$tdir/$i/f- $fcount &
18600 for (( i = 0; i < $tcount; i++ )) ; do
18601 unlinkmany $DIR/$tdir/$i/f- $fcount &
18605 $LCTL get_param mdc.*.rpc_stats
18609 run_test 182a "Test parallel modify metadata operations from mdc"
18612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18613 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
18620 do_facet mds1 $LCTL list_param \
18621 osp.$FSNAME-MDT*-osp-MDT*.rpc_stats ||
18622 skip "MDS lacks parallel RPC handling"
18624 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18626 rpc_count=$(do_facet mds1 $LCTL get_param -n \
18627 osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight)
18630 createmany -i 0 -d $DIR/$tdir/t- $tcount
18632 for (( i = 0; i < $tcount; i++ )) ; do
18633 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18637 delta=$((etime - stime))
18638 echo "Time for file creation $delta sec for $rpc_count parallel RPCs"
18641 for (( i = 0; i < $tcount; i++ )) ; do
18642 unlinkmany -d $DIR/$tdir/$i/d- $dcount &
18646 delta=$((etime - stime))
18647 echo "Time for file removal $delta sec for $rpc_count parallel RPCs"
18651 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18653 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=1
18656 createmany -i 0 -d $DIR/$tdir/t- $tcount
18658 for (( i = 0; i < $tcount; i++ )) ; do
18659 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18663 delta=$((etime - stime))
18664 echo "Time for file creation $delta sec for 1 RPC sent at a time"
18667 for (( i = 0; i < $tcount; i++ )) ; do
18668 unlinkmany -d $DIR/$tdir/t-$i/d- $dcount &
18672 delta=$((etime - stime))
18673 echo "Time for file removal $delta sec for 1 RPC sent at a time"
18675 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=$rpc_count
18677 run_test 182b "Test parallel modify metadata operations from osp"
18679 test_183() { # LU-2275
18680 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18681 remote_mds_nodsh && skip "remote MDS with nodsh"
18682 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
18683 skip "Need MDS version at least 2.3.56"
18685 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18686 echo aaa > $DIR/$tdir/$tfile
18688 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
18689 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
18691 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
18692 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
18694 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
18696 # Flush negative dentry cache
18697 touch $DIR/$tdir/$tfile
18699 # We are not checking for any leaked references here, they'll
18700 # become evident next time we do cleanup with module unload.
18703 run_test 183 "No crash or request leak in case of strange dispositions ========"
18705 # test suite 184 is for LU-2016, LU-2017
18707 check_swap_layouts_support
18709 dir0=$DIR/$tdir/$testnum
18710 test_mkdir -p -c1 $dir0
18715 $LFS setstripe -c1 $file1
18717 $LFS setstripe -c2 $file2
18719 gen1=$($LFS getstripe -g $file1)
18720 gen2=$($LFS getstripe -g $file2)
18722 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
18723 gen=$($LFS getstripe -g $file1)
18724 [[ $gen1 != $gen ]] ||
18725 error "Layout generation on $file1 does not change"
18726 gen=$($LFS getstripe -g $file2)
18727 [[ $gen2 != $gen ]] ||
18728 error "Layout generation on $file2 does not change"
18730 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
18731 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
18733 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
18735 run_test 184a "Basic layout swap"
18738 check_swap_layouts_support
18740 dir0=$DIR/$tdir/$testnum
18741 mkdir -p $dir0 || error "creating dir $dir0"
18748 $LFS setstripe -c1 $file1
18749 $LFS setstripe -c2 $file2
18750 $LFS setstripe -c1 $file3
18751 chown $RUNAS_ID $file3
18752 gen1=$($LFS getstripe -g $file1)
18753 gen2=$($LFS getstripe -g $file2)
18755 $LFS swap_layouts $dir1 $dir2 &&
18756 error "swap of directories layouts should fail"
18757 $LFS swap_layouts $dir1 $file1 &&
18758 error "swap of directory and file layouts should fail"
18759 $RUNAS $LFS swap_layouts $file1 $file2 &&
18760 error "swap of file we cannot write should fail"
18761 $LFS swap_layouts $file1 $file3 &&
18762 error "swap of file with different owner should fail"
18763 /bin/true # to clear error code
18765 run_test 184b "Forbidden layout swap (will generate errors)"
18768 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
18769 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
18770 check_swap_layouts_support
18771 check_swap_layout_no_dom $DIR
18773 local dir0=$DIR/$tdir/$testnum
18774 mkdir -p $dir0 || error "creating dir $dir0"
18776 local ref1=$dir0/ref1
18777 local ref2=$dir0/ref2
18778 local file1=$dir0/file1
18779 local file2=$dir0/file2
18780 # create a file large enough for the concurrent test
18781 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
18782 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
18783 echo "ref file size: ref1($(stat -c %s $ref1))," \
18784 "ref2($(stat -c %s $ref2))"
18787 dd if=$ref1 of=$file1 bs=16k &
18790 # Make sure dd starts to copy file, but wait at most 5 seconds
18792 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
18794 $LFS swap_layouts $file1 $file2
18797 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
18798 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
18800 # how many bytes copied before swapping layout
18801 local copied=$(stat -c %s $file2)
18802 local remaining=$(stat -c %s $ref1)
18803 remaining=$((remaining - copied))
18804 echo "Copied $copied bytes before swapping layout..."
18806 cmp -n $copied $file1 $ref2 | grep differ &&
18807 error "Content mismatch [0, $copied) of ref2 and file1"
18808 cmp -n $copied $file2 $ref1 ||
18809 error "Content mismatch [0, $copied) of ref1 and file2"
18810 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
18811 error "Content mismatch [$copied, EOF) of ref1 and file1"
18814 rm -f $ref1 $ref2 $file1 $file2
18816 run_test 184c "Concurrent write and layout swap"
18819 check_swap_layouts_support
18820 check_swap_layout_no_dom $DIR
18821 [ -z "$(which getfattr 2>/dev/null)" ] &&
18822 skip_env "no getfattr command"
18824 local file1=$DIR/$tdir/$tfile-1
18825 local file2=$DIR/$tdir/$tfile-2
18826 local file3=$DIR/$tdir/$tfile-3
18830 mkdir -p $DIR/$tdir
18831 touch $file1 || error "create $file1 failed"
18832 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18833 error "create $file2 failed"
18834 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18835 error "create $file3 failed"
18836 lovea1=$(get_layout_param $file1)
18838 $LFS swap_layouts $file2 $file3 ||
18839 error "swap $file2 $file3 layouts failed"
18840 $LFS swap_layouts $file1 $file2 ||
18841 error "swap $file1 $file2 layouts failed"
18843 lovea2=$(get_layout_param $file2)
18846 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
18848 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18849 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
18851 run_test 184d "allow stripeless layouts swap"
18854 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
18855 skip "Need MDS version at least 2.6.94"
18856 check_swap_layouts_support
18857 check_swap_layout_no_dom $DIR
18858 [ -z "$(which getfattr 2>/dev/null)" ] &&
18859 skip_env "no getfattr command"
18861 local file1=$DIR/$tdir/$tfile-1
18862 local file2=$DIR/$tdir/$tfile-2
18863 local file3=$DIR/$tdir/$tfile-3
18866 mkdir -p $DIR/$tdir
18867 touch $file1 || error "create $file1 failed"
18868 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18869 error "create $file2 failed"
18870 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18871 error "create $file3 failed"
18873 $LFS swap_layouts $file1 $file2 ||
18874 error "swap $file1 $file2 layouts failed"
18876 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18877 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
18879 echo 123 > $file1 || error "Should be able to write into $file1"
18881 $LFS swap_layouts $file1 $file3 ||
18882 error "swap $file1 $file3 layouts failed"
18884 echo 123 > $file1 || error "Should be able to write into $file1"
18886 rm -rf $file1 $file2 $file3
18888 run_test 184e "Recreate layout after stripeless layout swaps"
18891 # Create a file with name longer than sizeof(struct stat) ==
18892 # 144 to see if we can get chars from the file name to appear
18893 # in the returned striping. Note that 'f' == 0x66.
18894 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
18896 mkdir -p $DIR/$tdir
18897 mcreate $DIR/$tdir/$file
18898 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
18899 error "IOC_MDC_GETFILEINFO returned garbage striping"
18902 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
18904 test_185() { # LU-2441
18905 # LU-3553 - no volatile file support in old servers
18906 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
18907 skip "Need MDS version at least 2.3.60"
18909 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18910 touch $DIR/$tdir/spoo
18911 local mtime1=$(stat -c "%Y" $DIR/$tdir)
18912 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
18913 error "cannot create/write a volatile file"
18914 [ "$FILESET" == "" ] &&
18915 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
18916 error "FID is still valid after close"
18918 multiop_bg_pause $DIR/$tdir vVw4096_c
18925 # assume that the next FID for this client is sequential, since stdout
18926 # is unfortunately eaten by multiop_bg_pause
18927 local n=$((${fidv[1]} + 1))
18928 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
18929 if [ "$FILESET" == "" ]; then
18930 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
18931 error "FID is missing before close"
18933 kill -USR1 $multi_pid
18934 # 1 second delay, so if mtime change we will see it
18936 local mtime2=$(stat -c "%Y" $DIR/$tdir)
18937 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
18939 run_test 185 "Volatile file support"
18941 function create_check_volatile() {
18945 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
18948 local FID=$(cat /tmp/${tfile}.fid)
18949 [ "$FID" == "" ] && error "can't get FID for volatile"
18950 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
18951 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
18952 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
18956 cancel_lru_locks mdc # flush opencache
18957 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
18962 # LU-12516 - volatile creation via .lustre
18963 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
18964 skip "Need MDS version at least 2.3.55"
18966 create_check_volatile 0
18967 [ $MDSCOUNT -lt 2 ] && return 0
18970 create_check_volatile 1
18974 run_test 185a "Volatile file creation in .lustre/fid/"
18977 remote_mds_nodsh && skip "remote MDS with nodsh"
18978 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18979 skip "Need MDS version at least 2.3.0"
18981 local dir0=$DIR/$tdir/$testnum
18982 mkdir -p $dir0 || error "creating dir $dir0"
18984 local file=$dir0/file1
18985 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
18986 local dv1=$($LFS data_version $file)
18987 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
18988 local dv2=$($LFS data_version $file)
18989 [[ $dv1 != $dv2 ]] ||
18990 error "data version did not change on write $dv1 == $dv2"
18995 run_test 187a "Test data version change"
18998 remote_mds_nodsh && skip "remote MDS with nodsh"
18999 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
19000 skip "Need MDS version at least 2.3.0"
19002 local dir0=$DIR/$tdir/$testnum
19003 mkdir -p $dir0 || error "creating dir $dir0"
19005 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
19006 [[ ${DV[0]} != ${DV[1]} ]] ||
19007 error "data version did not change on write"\
19008 " ${DV[0]} == ${DV[1]}"
19013 run_test 187b "Test data version change on volatile file"
19016 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19017 remote_mgs_nodsh && skip "remote MGS with nodsh"
19018 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
19020 local POOL=${POOL:-cea1}
19021 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
19022 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
19025 local last_ost=$(($OSTCOUNT - 1))
19027 local ost_list=$(seq $first_ost $ost_step $last_ost)
19028 local ost_range="$first_ost $last_ost $ost_step"
19029 local test_path=$POOL_ROOT/$POOL_DIR_NAME
19030 local file_dir=$POOL_ROOT/file_tst
19031 local subdir=$test_path/subdir
19035 # former test_200a test_200b
19036 pool_add $POOL || { rc=$? ; break; }
19037 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
19038 # former test_200c test_200d
19039 mkdir -p $test_path
19040 pool_set_dir $POOL $test_path || { rc=$? ; break; }
19041 pool_check_dir $POOL $test_path || { rc=$? ; break; }
19043 pool_check_dir $POOL $subdir || { rc=$? ; break; }
19044 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
19045 || { rc=$? ; break; }
19046 # former test_200e test_200f
19047 local files=$((OSTCOUNT*3))
19048 pool_alloc_files $POOL $test_path $files "$ost_list" \
19049 || { rc=$? ; break; }
19050 pool_create_files $POOL $file_dir $files "$ost_list" \
19051 || { rc=$? ; break; }
19052 # former test_200g test_200h
19053 pool_lfs_df $POOL || { rc=$? ; break; }
19054 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
19056 # former test_201a test_201b test_201c
19057 pool_remove_first_target $POOL || { rc=$? ; break; }
19059 local f=$test_path/$tfile
19060 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
19061 pool_remove $POOL $f || { rc=$? ; break; }
19069 run_test 200 "OST pools"
19071 # usage: default_attr <count | size | offset>
19073 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
19076 # usage: check_default_stripe_attr
19077 check_default_stripe_attr() {
19078 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
19081 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
19083 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
19087 error "unknown getstripe attr '$1'"
19090 [ $ACTUAL == $EXPECTED ] ||
19091 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
19095 test_mkdir $DIR/$tdir
19096 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
19098 check_default_stripe_attr --stripe-count
19099 check_default_stripe_attr --stripe-size
19100 check_default_stripe_attr --stripe-index
19102 run_test 204a "Print default stripe attributes"
19105 test_mkdir $DIR/$tdir
19106 $LFS setstripe --stripe-count 1 $DIR/$tdir
19108 check_default_stripe_attr --stripe-size
19109 check_default_stripe_attr --stripe-index
19111 run_test 204b "Print default stripe size and offset"
19114 test_mkdir $DIR/$tdir
19115 $LFS setstripe --stripe-size 65536 $DIR/$tdir
19117 check_default_stripe_attr --stripe-count
19118 check_default_stripe_attr --stripe-index
19120 run_test 204c "Print default stripe count and offset"
19123 test_mkdir $DIR/$tdir
19124 $LFS setstripe --stripe-index 0 $DIR/$tdir
19126 check_default_stripe_attr --stripe-count
19127 check_default_stripe_attr --stripe-size
19129 run_test 204d "Print default stripe count and size"
19132 test_mkdir $DIR/$tdir
19133 $LFS setstripe -d $DIR/$tdir
19135 check_default_stripe_attr --stripe-count --raw
19136 check_default_stripe_attr --stripe-size --raw
19137 check_default_stripe_attr --stripe-index --raw
19139 run_test 204e "Print raw stripe attributes"
19142 test_mkdir $DIR/$tdir
19143 $LFS setstripe --stripe-count 1 $DIR/$tdir
19145 check_default_stripe_attr --stripe-size --raw
19146 check_default_stripe_attr --stripe-index --raw
19148 run_test 204f "Print raw stripe size and offset"
19151 test_mkdir $DIR/$tdir
19152 $LFS setstripe --stripe-size 65536 $DIR/$tdir
19154 check_default_stripe_attr --stripe-count --raw
19155 check_default_stripe_attr --stripe-index --raw
19157 run_test 204g "Print raw stripe count and offset"
19160 test_mkdir $DIR/$tdir
19161 $LFS setstripe --stripe-index 0 $DIR/$tdir
19163 check_default_stripe_attr --stripe-count --raw
19164 check_default_stripe_attr --stripe-size --raw
19166 run_test 204h "Print raw stripe count and size"
19168 # Figure out which job scheduler is being used, if any,
19169 # or use a fake one
19170 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
19171 JOBENV=SLURM_JOB_ID
19172 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
19174 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
19176 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
19177 JOBENV=LOADL_STEP_ID
19178 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
19181 $LCTL list_param jobid_name > /dev/null 2>&1
19182 if [ $? -eq 0 ]; then
19188 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
19190 verify_jobstats() {
19195 # we don't really need to clear the stats for this test to work, since each
19196 # command has a unique jobid, but it makes debugging easier if needed.
19197 # for facet in $facets; do
19198 # local dev=$(convert_facet2label $facet)
19199 # # clear old jobstats
19200 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
19203 # use a new JobID for each test, or we might see an old one
19204 [ "$JOBENV" = "FAKE_JOBID" ] &&
19205 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
19207 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
19209 [ "$JOBENV" = "nodelocal" ] && {
19210 FAKE_JOBID=id.$testnum.%e.$RANDOM
19211 $LCTL set_param jobid_name=$FAKE_JOBID
19212 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
19215 log "Test: ${cmd[*]}"
19216 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
19218 if [ $JOBENV = "FAKE_JOBID" ]; then
19219 FAKE_JOBID=$JOBVAL ${cmd[*]}
19224 # all files are created on OST0000
19225 for facet in $facets; do
19226 local stats="*.$(convert_facet2label $facet).job_stats"
19228 # strip out libtool wrappers for in-tree executables
19229 if (( $(do_facet $facet lctl get_param $stats |
19230 sed -e 's/\.lt-/./' | grep -cw $JOBVAL) != 1 )); then
19231 do_facet $facet lctl get_param $stats
19232 error "No jobstats for $JOBVAL found on $facet::$stats"
19238 local new_jobenv=$1
19240 set_persistent_param_and_check client "jobid_var" \
19241 "$FSNAME.sys.jobid_var" $new_jobenv
19244 test_205a() { # Job stats
19245 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19246 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
19247 skip "Need MDS version with at least 2.7.1"
19248 remote_mgs_nodsh && skip "remote MGS with nodsh"
19249 remote_mds_nodsh && skip "remote MDS with nodsh"
19250 remote_ost_nodsh && skip "remote OST with nodsh"
19251 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
19252 skip "Server doesn't support jobstats"
19253 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
19255 local old_jobenv=$($LCTL get_param -n jobid_var)
19256 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
19258 if [[ $PERM_CMD == *"set_param -P"* ]]; then
19259 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
19261 stack_trap "do_facet mgs $PERM_CMD \
19262 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
19266 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
19267 mdt.*.job_cleanup_interval | head -n 1)
19268 local new_interval=5
19269 do_facet $SINGLEMDS \
19270 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
19271 stack_trap "do_facet $SINGLEMDS \
19272 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
19273 local start=$SECONDS
19277 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
19278 verify_jobstats "$cmd" "$SINGLEMDS"
19280 cmd="rmdir $DIR/$tdir"
19281 verify_jobstats "$cmd" "$SINGLEMDS"
19282 # mkdir on secondary MDT
19283 if [ $MDSCOUNT -gt 1 ]; then
19284 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
19285 verify_jobstats "$cmd" "mds2"
19288 cmd="mknod $DIR/$tfile c 1 3"
19289 verify_jobstats "$cmd" "$SINGLEMDS"
19291 cmd="rm -f $DIR/$tfile"
19292 verify_jobstats "$cmd" "$SINGLEMDS"
19293 # create all files on OST0000 so verify_jobstats can find OST stats
19295 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
19296 verify_jobstats "$cmd" "$SINGLEMDS"
19298 cmd="touch $DIR/$tfile"
19299 verify_jobstats "$cmd" "$SINGLEMDS ost1"
19301 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
19302 verify_jobstats "$cmd" "ost1"
19304 cancel_lru_locks osc
19305 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
19306 verify_jobstats "$cmd" "ost1"
19308 cmd="$TRUNCATE $DIR/$tfile 0"
19309 verify_jobstats "$cmd" "$SINGLEMDS ost1"
19311 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
19312 verify_jobstats "$cmd" "$SINGLEMDS"
19313 # jobstats expiry - sleep until old stats should be expired
19314 local left=$((new_interval + 5 - (SECONDS - start)))
19315 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
19316 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
19318 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
19319 verify_jobstats "$cmd" "$SINGLEMDS"
19320 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
19321 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
19323 # Ensure that jobid are present in changelog (if supported by MDS)
19324 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
19325 changelog_dump | tail -10
19326 jobids=$(changelog_dump | tail -9 | grep -c "j=")
19327 [ $jobids -eq 9 ] ||
19328 error "Wrong changelog jobid count $jobids != 9"
19332 jobstats_set $JOBENV
19334 changelog_dump | grep $tfile
19335 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
19336 [ $jobids -eq 0 ] ||
19337 error "Unexpected jobids when jobid_var=$JOBENV"
19340 # test '%j' access to environment variable - if supported
19341 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
19342 JOBENV="JOBCOMPLEX"
19343 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
19345 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19348 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
19349 JOBENV="JOBCOMPLEX"
19350 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
19352 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19355 # test '%j' access to per-session jobid - if supported
19356 if lctl list_param jobid_this_session > /dev/null 2>&1
19358 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
19359 lctl set_param jobid_this_session=$USER
19361 JOBENV="JOBCOMPLEX"
19362 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
19364 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19367 run_test 205a "Verify job stats"
19369 # LU-13117, LU-13597
19371 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
19372 skip "Need MDS version at least 2.13.54.91"
19374 local job_stats="mdt.*.job_stats"
19375 local old_jobid=$(do_facet mds1 $LCTL get_param jobid_var)
19377 do_facet mds1 $LCTL set_param $job_stats=clear
19379 # Setting jobid_var to USER might not be supported
19380 [[ -n "$old_jobid" ]] && stack_trap "$LCTL set_param $old_jobid"
19381 $LCTL set_param jobid_var=USER || true
19382 stack_trap "$LCTL set_param $($LCTL get_param jobid_name)"
19383 $LCTL set_param jobid_name="%j.%e.%u"
19385 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
19386 do_facet mds1 $LCTL get_param $job_stats | grep "job_id:.*foolish" &&
19387 { do_facet mds1 $LCTL get_param $job_stats;
19388 error "Unexpected jobid found"; }
19389 do_facet mds1 $LCTL get_param $job_stats | grep "open:.*min.*max.*sum"||
19390 { do_facet mds1 $LCTL get_param $job_stats;
19391 error "wrong job_stats format found"; }
19393 (( $MDS1_VERSION <= $(version_code 2.15.0) )) &&
19394 echo "MDS does not yet escape jobid" && return 0
19395 $LCTL set_param jobid_var=TEST205b
19396 env -i TEST205b="has sp" touch $DIR/$tfile.2
19397 do_facet mds1 $LCTL get_param $job_stats | grep "has.*x20sp" ||
19398 { do_facet mds1 $LCTL get_param $job_stats;
19399 error "jobid not escaped"; }
19401 run_test 205b "Verify job stats jobid and output format"
19405 $LCTL set_param llite.*.stats=0
19406 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
19407 $LCTL get_param llite.*.stats
19408 $LCTL get_param llite.*.stats | grep \
19409 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
19410 error "wrong client stats format found"
19412 run_test 205c "Verify client stats format"
19415 local file=$DIR/$tdir/$tfile
19417 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
19418 skip "need lustre >= 2.15.53 for lljobstat"
19419 (( $OST1_VERSION >= $(version_code 2.15.53) )) ||
19420 skip "need lustre >= 2.15.53 for lljobstat"
19421 verify_yaml_available || skip_env "YAML verification not installed"
19423 test_mkdir -i 0 $DIR/$tdir
19424 $LFS setstripe -E 1M -L mdt -E -1 $file || error "create file failed"
19426 dd if=/dev/zero of=$file bs=1M count=10 conv=sync ||
19427 error "failed to write data to $file"
19430 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats"
19431 echo -n 'verify rename_stats...'
19432 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats" |
19433 verify_yaml || error "rename_stats is not valid YAML"
19436 echo -n 'verify mdt job_stats...'
19437 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.job_stats" |
19438 verify_yaml || error "job_stats on mds1 is not valid YAML"
19441 echo -n 'verify ost job_stats...'
19442 do_facet ost1 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.job_stats" |
19443 verify_yaml || error "job_stats on ost1 is not valid YAML"
19446 run_test 205d "verify the format of some stats files"
19450 local file=$DIR/$tdir/$tfile
19452 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
19453 skip "need lustre >= 2.15.53 for lljobstat"
19454 (( $OST1_VERSION >= $(version_code 2.15.53) )) ||
19455 skip "need lustre >= 2.15.53 for lljobstat"
19456 verify_yaml_available || skip_env "YAML verification not installed"
19458 mkdir_on_mdt0 $DIR/$tdir || error "failed to create dir"
19460 $LFS setstripe -E EOF -i 0 -c 1 $file ||
19461 error "failed to create $file on ost1"
19462 dd if=/dev/zero of=$file bs=1M count=10 oflag=sync ||
19463 error "failed to write data to $file"
19465 do_facet mds1 "$LCTL get_param *.*.job_stats"
19466 do_facet ost1 "$LCTL get_param *.*.job_stats"
19468 do_facet ost1 "lljobstat -n 1 -i 0 -c 1000"
19469 do_facet ost1 "lljobstat -n 1 -i 0 -c 1000" | verify_yaml ||
19470 error "The output of lljobstat is not an valid YAML"
19472 # verify that job dd.0 does exist and has some ops on ost1
19473 # typically this line is like:
19474 # - dd.0: {ops: 20, ...}
19475 ops_comma=$(do_facet ost1 "lljobstat -n 1 -i 0 -c 1000" |
19476 awk '$2=="dd.0:" {print $4}')
19478 (( ${ops_comma%,} >= 10 )) ||
19479 error "cannot find job dd.0 with ops >= 10"
19481 run_test 205e "verify the output of lljobstat"
19483 # LU-1480, LU-1773 and LU-1657
19485 mkdir -p $DIR/$tdir
19486 $LFS setstripe -c -1 $DIR/$tdir
19487 #define OBD_FAIL_LOV_INIT 0x1403
19488 $LCTL set_param fail_loc=0xa0001403
19489 $LCTL set_param fail_val=1
19490 touch $DIR/$tdir/$tfile || true
19492 run_test 206 "fail lov_init_raid0() doesn't lbug"
19495 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
19496 local fsz=`stat -c %s $DIR/$tfile`
19497 cancel_lru_locks mdc
19499 # do not return layout in getattr intent
19500 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
19501 $LCTL set_param fail_loc=0x170
19502 local sz=`stat -c %s $DIR/$tfile`
19504 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
19508 run_test 207a "can refresh layout at glimpse"
19511 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
19512 local cksum=`md5sum $DIR/$tfile`
19513 local fsz=`stat -c %s $DIR/$tfile`
19514 cancel_lru_locks mdc
19515 cancel_lru_locks osc
19517 # do not return layout in getattr intent
19518 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
19519 $LCTL set_param fail_loc=0x171
19521 # it will refresh layout after the file is opened but before read issues
19522 echo checksum is "$cksum"
19523 echo "$cksum" |md5sum -c --quiet || error "file differs"
19527 run_test 207b "can refresh layout at open"
19530 # FIXME: in this test suite, only RD lease is used. This is okay
19531 # for now as only exclusive open is supported. After generic lease
19532 # is done, this test suite should be revised. - Jinshan
19534 remote_mds_nodsh && skip "remote MDS with nodsh"
19535 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
19536 skip "Need MDS version at least 2.4.52"
19538 echo "==== test 1: verify get lease work"
19539 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
19541 echo "==== test 2: verify lease can be broken by upcoming open"
19542 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
19546 $MULTIOP $DIR/$tfile oO_RDWR:c
19547 kill -USR1 $PID && wait $PID || error "break lease error"
19549 echo "==== test 3: verify lease can't be granted if an open already exists"
19550 $MULTIOP $DIR/$tfile oO_RDWR:_c &
19554 $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
19555 kill -USR1 $PID && wait $PID || error "open file error"
19557 echo "==== test 4: lease can sustain over recovery"
19558 $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
19564 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
19566 echo "==== test 5: lease broken can't be regained by replay"
19567 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
19571 # open file to break lease and then recovery
19572 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
19575 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
19579 run_test 208 "Exclusive open"
19582 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
19583 skip_env "must have disp_stripe"
19586 sync; sleep 5; sync;
19588 echo 3 > /proc/sys/vm/drop_caches
19589 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
19590 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
19591 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
19593 # open/close 500 times
19594 for i in $(seq 500); do
19598 echo 3 > /proc/sys/vm/drop_caches
19599 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
19600 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
19601 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
19603 echo "before: $req_before, after: $req_after"
19604 [ $((req_after - req_before)) -ge 300 ] &&
19605 error "open/close requests are not freed"
19608 run_test 209 "read-only open/close requests should be freed promptly"
19613 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
19617 $LFS getstripe $DIR/$tfile
19619 wait $pid || error "multiop failed"
19621 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
19625 $LFS getstripe $DIR/$tfile
19627 wait $pid || error "multiop failed"
19629 run_test 210 "lfs getstripe does not break leases"
19633 size=$((size % 8192 + 1))
19634 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
19635 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
19636 rm -f $DIR/f212 $DIR/f212.xyz
19638 run_test 212 "Sendfile test ============================================"
19641 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
19642 cancel_lru_locks osc
19643 lctl set_param fail_loc=0x8000040f
19644 # generate a read lock
19645 cat $DIR/$tfile > /dev/null
19646 # write to the file, it will try to cancel the above read lock.
19647 cat /etc/hosts >> $DIR/$tfile
19649 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
19651 test_214() { # for bug 20133
19652 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
19653 for (( i=0; i < 340; i++ )) ; do
19654 touch $DIR/$tdir/d214c/a$i
19657 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
19658 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
19659 ls $DIR/d214c || error "ls $DIR/d214c failed"
19660 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
19661 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
19663 run_test 214 "hash-indexed directory test - bug 20133"
19665 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
19666 create_lnet_proc_files() {
19667 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
19670 # counterpart of create_lnet_proc_files
19671 remove_lnet_proc_files() {
19672 rm -f $TMP/lnet_$1.sys
19675 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19676 # 3rd arg as regexp for body
19677 check_lnet_proc_stats() {
19678 local l=$(cat "$TMP/lnet_$1" |wc -l)
19679 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
19681 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
19684 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19685 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
19686 # optional and can be regexp for 2nd line (lnet.routes case)
19687 check_lnet_proc_entry() {
19688 local blp=2 # blp stands for 'position of 1st line of body'
19689 [ -z "$5" ] || blp=3 # lnet.routes case
19691 local l=$(cat "$TMP/lnet_$1" |wc -l)
19692 # subtracting one from $blp because the body can be empty
19693 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
19695 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
19696 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
19698 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
19699 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
19701 # bail out if any unexpected line happened
19702 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
19703 [ "$?" != 0 ] || error "$2 misformatted"
19706 test_215() { # for bugs 18102, 21079, 21517
19707 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19709 local N='(0|[1-9][0-9]*)' # non-negative numeric
19710 local P='[1-9][0-9]*' # positive numeric
19711 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
19712 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
19713 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
19714 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
19716 local L1 # regexp for 1st line
19717 local L2 # regexp for 2nd line (optional)
19718 local BR # regexp for the rest (body)
19720 # lnet.stats should look as 11 space-separated non-negative numerics
19721 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
19722 create_lnet_proc_files "stats"
19723 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
19724 remove_lnet_proc_files "stats"
19726 # lnet.routes should look like this:
19727 # Routing disabled/enabled
19728 # net hops priority state router
19729 # where net is a string like tcp0, hops > 0, priority >= 0,
19730 # state is up/down,
19731 # router is a string like 192.168.1.1@tcp2
19732 L1="^Routing (disabled|enabled)$"
19733 L2="^net +hops +priority +state +router$"
19734 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
19735 create_lnet_proc_files "routes"
19736 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
19737 remove_lnet_proc_files "routes"
19739 # lnet.routers should look like this:
19740 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
19741 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
19742 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
19743 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
19744 L1="^ref +rtr_ref +alive +router$"
19745 BR="^$P +$P +(up|down) +$NID$"
19746 create_lnet_proc_files "routers"
19747 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
19748 remove_lnet_proc_files "routers"
19750 # lnet.peers should look like this:
19751 # nid refs state last max rtr min tx min queue
19752 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
19753 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
19754 # numeric (0 or >0 or <0), queue >= 0.
19755 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
19756 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
19757 create_lnet_proc_files "peers"
19758 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
19759 remove_lnet_proc_files "peers"
19761 # lnet.buffers should look like this:
19762 # pages count credits min
19763 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
19764 L1="^pages +count +credits +min$"
19765 BR="^ +$N +$N +$I +$I$"
19766 create_lnet_proc_files "buffers"
19767 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
19768 remove_lnet_proc_files "buffers"
19770 # lnet.nis should look like this:
19771 # nid status alive refs peer rtr max tx min
19772 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
19773 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
19774 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
19775 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
19776 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
19777 create_lnet_proc_files "nis"
19778 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
19779 remove_lnet_proc_files "nis"
19781 # can we successfully write to lnet.stats?
19782 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
19784 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
19786 test_216() { # bug 20317
19787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19788 remote_ost_nodsh && skip "remote OST with nodsh"
19791 local facets=$(get_facets OST)
19792 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19794 save_lustre_params client "osc.*.contention_seconds" > $p
19795 save_lustre_params $facets \
19796 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
19797 save_lustre_params $facets \
19798 "ldlm.namespaces.filter-*.contended_locks" >> $p
19799 save_lustre_params $facets \
19800 "ldlm.namespaces.filter-*.contention_seconds" >> $p
19801 clear_stats osc.*.osc_stats
19803 # agressive lockless i/o settings
19804 do_nodes $(comma_list $(osts_nodes)) \
19805 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
19806 ldlm.namespaces.filter-*.contended_locks=0 \
19807 ldlm.namespaces.filter-*.contention_seconds=60"
19808 lctl set_param -n osc.*.contention_seconds=60
19810 $DIRECTIO write $DIR/$tfile 0 10 4096
19811 $CHECKSTAT -s 40960 $DIR/$tfile
19813 # disable lockless i/o
19814 do_nodes $(comma_list $(osts_nodes)) \
19815 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
19816 ldlm.namespaces.filter-*.contended_locks=32 \
19817 ldlm.namespaces.filter-*.contention_seconds=0"
19818 lctl set_param -n osc.*.contention_seconds=0
19819 clear_stats osc.*.osc_stats
19821 dd if=/dev/zero of=$DIR/$tfile count=0
19822 $CHECKSTAT -s 0 $DIR/$tfile
19824 restore_lustre_params <$p
19828 run_test 216 "check lockless direct write updates file size and kms correctly"
19830 test_217() { # bug 22430
19831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19836 for node in $(nodes_list); do
19837 nid=$(host_nids_address $node $NETTYPE)
19838 if [[ $nid = *-* ]] ; then
19839 echo "lctl ping $(h2nettype $nid)"
19840 lctl ping $(h2nettype $nid)
19842 echo "skipping $node (no hyphen detected)"
19846 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
19849 # do directio so as not to populate the page cache
19850 log "creating a 10 Mb file"
19851 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
19852 log "starting reads"
19853 dd if=$DIR/$tfile of=/dev/null bs=4096 &
19854 log "truncating the file"
19855 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
19857 kill %+ || true # reads might have finished
19858 echo "wait until dd is finished"
19860 log "removing the temporary file"
19861 rm -rf $DIR/$tfile || error "tmp file removal failed"
19863 run_test 218 "parallel read and truncate should not deadlock"
19866 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19868 # write one partial page
19869 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
19870 # set no grant so vvp_io_commit_write will do sync write
19871 $LCTL set_param fail_loc=0x411
19872 # write a full page at the end of file
19873 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
19875 $LCTL set_param fail_loc=0
19876 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
19877 $LCTL set_param fail_loc=0x411
19878 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
19881 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
19882 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
19884 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
19886 test_220() { #LU-325
19887 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19888 remote_ost_nodsh && skip "remote OST with nodsh"
19889 remote_mds_nodsh && skip "remote MDS with nodsh"
19890 remote_mgs_nodsh && skip "remote MGS with nodsh"
19894 # create on MDT0000 so the last_id and next_id are correct
19895 mkdir_on_mdt0 $DIR/$tdir
19896 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
19900 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
19901 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
19902 osp.$mdtosc_proc1.prealloc_last_id)
19903 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
19904 osp.$mdtosc_proc1.prealloc_next_id)
19908 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
19909 #define OBD_FAIL_OST_ENOINO 0x229
19910 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
19911 create_pool $FSNAME.$TESTNAME || return 1
19912 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
19914 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
19916 MDSOBJS=$((last_id - next_id))
19917 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
19919 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
19920 echo "OST still has $count kbytes free"
19922 echo "create $MDSOBJS files @next_id..."
19923 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
19925 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19926 osp.$mdtosc_proc1.prealloc_last_id)
19927 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19928 osp.$mdtosc_proc1.prealloc_next_id)
19930 echo "after creation, last_id=$last_id2, next_id=$next_id2"
19935 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
19936 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
19938 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
19939 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
19940 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
19941 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
19942 echo "unlink $MDSOBJS files @$next_id..."
19943 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
19945 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
19948 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19950 dd if=`which date` of=$MOUNT/date oflag=sync
19951 chmod +x $MOUNT/date
19953 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
19954 $LCTL set_param fail_loc=0x80001401
19956 $MOUNT/date > /dev/null
19959 run_test 221 "make sure fault and truncate race to not cause OOM"
19962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19965 test_mkdir $DIR/$tdir
19966 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19967 createmany -o $DIR/$tdir/$tfile 10
19968 cancel_lru_locks mdc
19969 cancel_lru_locks osc
19970 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19971 $LCTL set_param fail_loc=0x31a
19972 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
19973 $LCTL set_param fail_loc=0
19976 run_test 222a "AGL for ls should not trigger CLIO lock failure"
19979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19982 test_mkdir $DIR/$tdir
19983 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19984 createmany -o $DIR/$tdir/$tfile 10
19985 cancel_lru_locks mdc
19986 cancel_lru_locks osc
19987 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19988 $LCTL set_param fail_loc=0x31a
19989 rm -r $DIR/$tdir || error "AGL for rmdir failed"
19990 $LCTL set_param fail_loc=0
19992 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
19995 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19998 test_mkdir $DIR/$tdir
19999 $LFS setstripe -c 1 -i 0 $DIR/$tdir
20000 createmany -o $DIR/$tdir/$tfile 10
20001 cancel_lru_locks mdc
20002 cancel_lru_locks osc
20003 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
20004 $LCTL set_param fail_loc=0x31b
20005 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
20006 $LCTL set_param fail_loc=0
20009 run_test 223 "osc reenqueue if without AGL lock granted ======================="
20011 test_224a() { # LU-1039, MRP-303
20012 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20013 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
20014 $LCTL set_param fail_loc=0x508
20015 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fsync
20016 $LCTL set_param fail_loc=0
20019 run_test 224a "Don't panic on bulk IO failure"
20021 test_224bd_sub() { # LU-1039, MRP-303
20022 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20026 dd if=/dev/urandom of=$TMP/$tfile bs=1M count=1
20028 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20030 dd if=$TMP/$tfile of=$DIR/$tfile bs=1M count=1
20031 cancel_lru_locks osc
20033 stack_trap "set_checksums $ORIG_CSUM" EXIT
20034 local at_max_saved=0
20036 # adaptive timeouts may prevent seeing the issue
20037 if at_is_enabled; then
20038 at_max_saved=$(at_max_get mds)
20039 at_max_set 0 mds client
20040 stack_trap "at_max_set $at_max_saved mds client" EXIT
20043 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
20044 do_facet ost1 $LCTL set_param fail_val=$timeout fail_loc=0x80000515
20045 dd of=$TMP/$tfile.new if=$DIR/$tfile bs=1M count=1 || "$@"
20047 do_facet ost1 $LCTL set_param fail_loc=0
20048 cmp $TMP/$tfile $TMP/$tfile.new || error "file contents wrong"
20053 test_224bd_sub 3 error "dd failed"
20055 run_test 224b "Don't panic on bulk IO failure"
20057 test_224c() { # LU-6441
20058 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20059 remote_mds_nodsh && skip "remote MDS with nodsh"
20061 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
20062 save_writethrough $p
20063 set_cache writethrough on
20065 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
20066 local at_max=$($LCTL get_param -n at_max)
20067 local timeout=$($LCTL get_param -n timeout)
20068 local test_at="at_max"
20069 local param_at="$FSNAME.sys.at_max"
20070 local test_timeout="timeout"
20071 local param_timeout="$FSNAME.sys.timeout"
20073 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
20075 set_persistent_param_and_check client "$test_at" "$param_at" 0
20076 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
20078 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
20079 do_facet ost1 "$LCTL set_param fail_loc=0x520"
20080 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20081 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
20083 do_facet ost1 "$LCTL set_param fail_loc=0"
20085 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
20086 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
20089 $LCTL set_param -n $pages_per_rpc
20090 restore_lustre_params < $p
20093 run_test 224c "Don't hang if one of md lost during large bulk RPC"
20095 test_224d() { # LU-11169
20096 test_224bd_sub $((TIMEOUT + 2)) error "dd failed"
20098 run_test 224d "Don't corrupt data on bulk IO timeout"
20100 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
20102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20103 if [ -z ${MDSSURVEY} ]; then
20104 skip_env "mds-survey not found"
20106 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
20107 skip "Need MDS version at least 2.2.51"
20109 local mds=$(facet_host $SINGLEMDS)
20110 local target=$(do_nodes $mds 'lctl dl' |
20111 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
20113 local cmd1="file_count=1000 thrhi=4"
20114 local cmd2="dir_count=2 layer=mdd stripe_count=0"
20115 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
20116 local cmd="$cmd1 $cmd2 $cmd3"
20118 rm -f ${TMP}/mds_survey*
20120 eval $cmd || error "mds-survey with zero-stripe failed"
20121 cat ${TMP}/mds_survey*
20122 rm -f ${TMP}/mds_survey*
20124 run_test 225a "Metadata survey sanity with zero-stripe"
20127 if [ -z ${MDSSURVEY} ]; then
20128 skip_env "mds-survey not found"
20130 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
20131 skip "Need MDS version at least 2.2.51"
20132 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20133 remote_mds_nodsh && skip "remote MDS with nodsh"
20134 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
20135 skip_env "Need to mount OST to test"
20138 local mds=$(facet_host $SINGLEMDS)
20139 local target=$(do_nodes $mds 'lctl dl' |
20140 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
20142 local cmd1="file_count=1000 thrhi=4"
20143 local cmd2="dir_count=2 layer=mdd stripe_count=1"
20144 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
20145 local cmd="$cmd1 $cmd2 $cmd3"
20147 rm -f ${TMP}/mds_survey*
20149 eval $cmd || error "mds-survey with stripe_count failed"
20150 cat ${TMP}/mds_survey*
20151 rm -f ${TMP}/mds_survey*
20153 run_test 225b "Metadata survey sanity with stripe_count = 1"
20155 mcreate_path2fid () {
20161 local path=$DIR/$tdir/$name
20166 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
20167 error "cannot create $desc"
20169 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
20171 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
20173 fid_path=$($LFS fid2path $MOUNT $fid)
20175 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
20177 [ "$path" == "$fid_path" ] ||
20178 error "fid2path returned $fid_path, expected $path"
20180 echo "pass with $path and $fid"
20185 mkdir -p $DIR/$tdir
20187 mcreate_path2fid 0010666 0 0 fifo "FIFO"
20188 mcreate_path2fid 0020666 1 3 null "character special file (null)"
20189 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
20190 mcreate_path2fid 0040666 0 0 dir "directory"
20191 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
20192 mcreate_path2fid 0100666 0 0 file "regular file"
20193 mcreate_path2fid 0120666 0 0 link "symbolic link"
20194 mcreate_path2fid 0140666 0 0 sock "socket"
20196 run_test 226a "call path2fid and fid2path on files of all type"
20199 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20204 mkdir -p $DIR/$tdir
20205 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
20206 error "create remote directory failed"
20207 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
20208 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
20209 "character special file (null)"
20210 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
20211 "character special file (no device)"
20212 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
20213 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
20214 "block special file (loop)"
20215 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
20216 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
20217 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
20219 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
20222 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20223 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
20224 skip "Need MDS version at least 2.13.55"
20226 local submnt=/mnt/submnt
20227 local srcfile=/etc/passwd
20228 local dstfile=$submnt/passwd
20234 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
20235 error "create remote directory failed"
20236 mkdir -p $submnt || error "create $submnt failed"
20237 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
20238 error "mount $submnt failed"
20239 stack_trap "umount $submnt" EXIT
20241 cp $srcfile $dstfile
20242 fid=$($LFS path2fid $dstfile)
20243 path=$($LFS fid2path $submnt "$fid")
20244 [ "$path" = "$dstfile" ] ||
20245 error "fid2path $submnt $fid failed ($path != $dstfile)"
20247 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
20249 # LU-1299 Executing or running ldd on a truncated executable does not
20250 # cause an out-of-memory condition.
20252 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20253 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
20255 dd if=$(which date) of=$MOUNT/date bs=1k count=1
20256 chmod +x $MOUNT/date
20258 $MOUNT/date > /dev/null
20259 ldd $MOUNT/date > /dev/null
20262 run_test 227 "running truncated executable does not cause OOM"
20264 # LU-1512 try to reuse idle OI blocks
20266 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20267 remote_mds_nodsh && skip "remote MDS with nodsh"
20268 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
20270 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
20271 local myDIR=$DIR/$tdir
20274 #define OBD_FAIL_SEQ_EXHAUST 0x1002
20275 $LCTL set_param fail_loc=0x80001002
20276 createmany -o $myDIR/t- 10000
20277 $LCTL set_param fail_loc=0
20278 # The guard is current the largest FID holder
20280 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
20282 local IDX=$(($SEQ % 64))
20284 do_facet $SINGLEMDS sync
20285 # Make sure journal flushed.
20287 local blk1=$(do_facet $SINGLEMDS \
20288 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20289 grep Blockcount | awk '{print $4}')
20291 # Remove old files, some OI blocks will become idle.
20292 unlinkmany $myDIR/t- 10000
20293 # Create new files, idle OI blocks should be reused.
20294 createmany -o $myDIR/t- 2000
20295 do_facet $SINGLEMDS sync
20296 # Make sure journal flushed.
20298 local blk2=$(do_facet $SINGLEMDS \
20299 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20300 grep Blockcount | awk '{print $4}')
20302 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
20304 run_test 228a "try to reuse idle OI blocks"
20307 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20308 remote_mds_nodsh && skip "remote MDS with nodsh"
20309 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
20311 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
20312 local myDIR=$DIR/$tdir
20315 #define OBD_FAIL_SEQ_EXHAUST 0x1002
20316 $LCTL set_param fail_loc=0x80001002
20317 createmany -o $myDIR/t- 10000
20318 $LCTL set_param fail_loc=0
20319 # The guard is current the largest FID holder
20321 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
20323 local IDX=$(($SEQ % 64))
20325 do_facet $SINGLEMDS sync
20326 # Make sure journal flushed.
20328 local blk1=$(do_facet $SINGLEMDS \
20329 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20330 grep Blockcount | awk '{print $4}')
20332 # Remove old files, some OI blocks will become idle.
20333 unlinkmany $myDIR/t- 10000
20336 stop $SINGLEMDS || error "Fail to stop MDT."
20338 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
20339 error "Fail to start MDT."
20341 client_up || error "Fail to df."
20342 # Create new files, idle OI blocks should be reused.
20343 createmany -o $myDIR/t- 2000
20344 do_facet $SINGLEMDS sync
20345 # Make sure journal flushed.
20347 local blk2=$(do_facet $SINGLEMDS \
20348 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20349 grep Blockcount | awk '{print $4}')
20351 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
20353 run_test 228b "idle OI blocks can be reused after MDT restart"
20357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20358 remote_mds_nodsh && skip "remote MDS with nodsh"
20359 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
20361 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
20362 local myDIR=$DIR/$tdir
20365 #define OBD_FAIL_SEQ_EXHAUST 0x1002
20366 $LCTL set_param fail_loc=0x80001002
20367 # 20000 files can guarantee there are index nodes in the OI file
20368 createmany -o $myDIR/t- 20000
20369 $LCTL set_param fail_loc=0
20370 # The guard is current the largest FID holder
20372 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
20374 local IDX=$(($SEQ % 64))
20376 do_facet $SINGLEMDS sync
20377 # Make sure journal flushed.
20379 local blk1=$(do_facet $SINGLEMDS \
20380 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20381 grep Blockcount | awk '{print $4}')
20383 # Remove old files, some OI blocks will become idle.
20384 unlinkmany $myDIR/t- 20000
20386 # The OI file should become empty now
20388 # Create new files, idle OI blocks should be reused.
20389 createmany -o $myDIR/t- 2000
20390 do_facet $SINGLEMDS sync
20391 # Make sure journal flushed.
20393 local blk2=$(do_facet $SINGLEMDS \
20394 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20395 grep Blockcount | awk '{print $4}')
20397 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
20399 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
20401 test_229() { # LU-2482, LU-3448
20402 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20403 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
20404 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
20405 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
20409 # Create a file with a released layout and stripe count 2.
20410 $MULTIOP $DIR/$tfile H2c ||
20411 error "failed to create file with released layout"
20413 $LFS getstripe -v $DIR/$tfile
20415 local pattern=$($LFS getstripe -L $DIR/$tfile)
20416 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
20418 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
20420 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
20421 stat $DIR/$tfile || error "failed to stat released file"
20423 chown $RUNAS_ID $DIR/$tfile ||
20424 error "chown $RUNAS_ID $DIR/$tfile failed"
20426 chgrp $RUNAS_ID $DIR/$tfile ||
20427 error "chgrp $RUNAS_ID $DIR/$tfile failed"
20429 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
20430 rm $DIR/$tfile || error "failed to remove released file"
20432 run_test 229 "getstripe/stat/rm/attr changes work on released files"
20435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20436 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20437 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20438 skip "Need MDS version at least 2.11.52"
20442 test_mkdir $DIR/$tdir
20443 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
20444 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
20445 [ $mdt_idx -ne 0 ] &&
20446 error "create local directory on wrong MDT $mdt_idx"
20448 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
20449 error "create remote directory failed"
20450 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
20451 [ $mdt_idx -ne $MDTIDX ] &&
20452 error "create remote directory on wrong MDT $mdt_idx"
20454 createmany -o $DIR/$tdir/test_230/t- 10 ||
20455 error "create files on remote directory failed"
20456 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
20457 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
20458 rm -r $DIR/$tdir || error "unlink remote directory failed"
20460 run_test 230a "Create remote directory and files under the remote directory"
20463 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20464 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20465 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20466 skip "Need MDS version at least 2.11.52"
20474 local migrate_dir=$DIR/$tdir/migrate_dir
20475 local other_dir=$DIR/$tdir/other_dir
20477 test_mkdir $DIR/$tdir
20478 test_mkdir -i0 -c1 $migrate_dir
20479 test_mkdir -i0 -c1 $other_dir
20480 for ((i=0; i<10; i++)); do
20481 mkdir -p $migrate_dir/dir_${i}
20482 createmany -o $migrate_dir/dir_${i}/f 10 ||
20483 error "create files under remote dir failed $i"
20486 cp /etc/passwd $migrate_dir/$tfile
20487 cp /etc/passwd $other_dir/$tfile
20488 chattr +SAD $migrate_dir
20489 chattr +SAD $migrate_dir/$tfile
20491 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20492 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20493 local old_dir_mode=$(stat -c%f $migrate_dir)
20494 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
20496 mkdir -p $migrate_dir/dir_default_stripe2
20497 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
20498 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
20500 mkdir -p $other_dir
20501 ln $migrate_dir/$tfile $other_dir/luna
20502 ln $migrate_dir/$tfile $migrate_dir/sofia
20503 ln $other_dir/$tfile $migrate_dir/david
20504 ln -s $migrate_dir/$tfile $other_dir/zachary
20505 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
20506 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
20512 for len in 58 59 60; do
20513 lnktgt=$(str_repeat 'l' $len)
20514 touch $migrate_dir/$lnktgt
20515 ln -s $lnktgt $migrate_dir/${len}char_ln
20519 for len in 4094 4095; do
20520 lnktgt=$(str_repeat 'l' $len)
20521 ln -s $lnktgt $migrate_dir/${len}char_ln
20525 for len in 254 255; do
20526 touch $migrate_dir/$(str_repeat 'l' $len)
20529 $LFS migrate -m $MDTIDX $migrate_dir ||
20530 error "fails on migrating remote dir to MDT1"
20532 echo "migratate to MDT1, then checking.."
20533 for ((i = 0; i < 10; i++)); do
20534 for file in $(find $migrate_dir/dir_${i}); do
20535 mdt_index=$($LFS getstripe -m $file)
20536 # broken symlink getstripe will fail
20537 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
20538 error "$file is not on MDT${MDTIDX}"
20542 # the multiple link file should still in MDT0
20543 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
20544 [ $mdt_index == 0 ] ||
20545 error "$file is not on MDT${MDTIDX}"
20547 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20548 [ "$old_dir_flag" = "$new_dir_flag" ] ||
20549 error " expect $old_dir_flag get $new_dir_flag"
20551 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20552 [ "$old_file_flag" = "$new_file_flag" ] ||
20553 error " expect $old_file_flag get $new_file_flag"
20555 local new_dir_mode=$(stat -c%f $migrate_dir)
20556 [ "$old_dir_mode" = "$new_dir_mode" ] ||
20557 error "expect mode $old_dir_mode get $new_dir_mode"
20559 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
20560 [ "$old_file_mode" = "$new_file_mode" ] ||
20561 error "expect mode $old_file_mode get $new_file_mode"
20563 diff /etc/passwd $migrate_dir/$tfile ||
20564 error "$tfile different after migration"
20566 diff /etc/passwd $other_dir/luna ||
20567 error "luna different after migration"
20569 diff /etc/passwd $migrate_dir/sofia ||
20570 error "sofia different after migration"
20572 diff /etc/passwd $migrate_dir/david ||
20573 error "david different after migration"
20575 diff /etc/passwd $other_dir/zachary ||
20576 error "zachary different after migration"
20578 diff /etc/passwd $migrate_dir/${tfile}_ln ||
20579 error "${tfile}_ln different after migration"
20581 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
20582 error "${tfile}_ln_other different after migration"
20584 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
20585 [ $stripe_count = 2 ] ||
20586 error "dir strpe_count $d != 2 after migration."
20588 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
20589 [ $stripe_count = 2 ] ||
20590 error "file strpe_count $d != 2 after migration."
20592 #migrate back to MDT0
20595 $LFS migrate -m $MDTIDX $migrate_dir ||
20596 error "fails on migrating remote dir to MDT0"
20598 echo "migrate back to MDT0, checking.."
20599 for file in $(find $migrate_dir); do
20600 mdt_index=$($LFS getstripe -m $file)
20601 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
20602 error "$file is not on MDT${MDTIDX}"
20605 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20606 [ "$old_dir_flag" = "$new_dir_flag" ] ||
20607 error " expect $old_dir_flag get $new_dir_flag"
20609 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20610 [ "$old_file_flag" = "$new_file_flag" ] ||
20611 error " expect $old_file_flag get $new_file_flag"
20613 local new_dir_mode=$(stat -c%f $migrate_dir)
20614 [ "$old_dir_mode" = "$new_dir_mode" ] ||
20615 error "expect mode $old_dir_mode get $new_dir_mode"
20617 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
20618 [ "$old_file_mode" = "$new_file_mode" ] ||
20619 error "expect mode $old_file_mode get $new_file_mode"
20621 diff /etc/passwd ${migrate_dir}/$tfile ||
20622 error "$tfile different after migration"
20624 diff /etc/passwd ${other_dir}/luna ||
20625 error "luna different after migration"
20627 diff /etc/passwd ${migrate_dir}/sofia ||
20628 error "sofia different after migration"
20630 diff /etc/passwd ${other_dir}/zachary ||
20631 error "zachary different after migration"
20633 diff /etc/passwd $migrate_dir/${tfile}_ln ||
20634 error "${tfile}_ln different after migration"
20636 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
20637 error "${tfile}_ln_other different after migration"
20639 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
20640 [ $stripe_count = 2 ] ||
20641 error "dir strpe_count $d != 2 after migration."
20643 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
20644 [ $stripe_count = 2 ] ||
20645 error "file strpe_count $d != 2 after migration."
20647 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20649 run_test 230b "migrate directory"
20652 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20653 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20654 remote_mds_nodsh && skip "remote MDS with nodsh"
20655 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20656 skip "Need MDS version at least 2.11.52"
20662 local migrate_dir=$DIR/$tdir/migrate_dir
20664 #If migrating directory fails in the middle, all entries of
20665 #the directory is still accessiable.
20666 test_mkdir $DIR/$tdir
20667 test_mkdir -i0 -c1 $migrate_dir
20668 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
20670 createmany -o $migrate_dir/f $total ||
20671 error "create files under ${migrate_dir} failed"
20673 # fail after migrating top dir, and this will fail only once, so the
20674 # first sub file migration will fail (currently f3), others succeed.
20675 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
20676 do_facet mds1 lctl set_param fail_loc=0x1801
20677 local t=$(ls $migrate_dir | wc -l)
20678 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
20679 error "migrate should fail"
20680 local u=$(ls $migrate_dir | wc -l)
20681 [ "$u" == "$t" ] || error "$u != $t during migration"
20683 # add new dir/file should succeed
20684 mkdir $migrate_dir/dir ||
20685 error "mkdir failed under migrating directory"
20686 touch $migrate_dir/file ||
20687 error "create file failed under migrating directory"
20689 # add file with existing name should fail
20690 for file in $migrate_dir/f*; do
20691 stat $file > /dev/null || error "stat $file failed"
20692 $OPENFILE -f O_CREAT:O_EXCL $file &&
20693 error "open(O_CREAT|O_EXCL) $file should fail"
20694 $MULTIOP $file m && error "create $file should fail"
20695 touch $DIR/$tdir/remote_dir/$tfile ||
20696 error "touch $tfile failed"
20697 ln $DIR/$tdir/remote_dir/$tfile $file &&
20698 error "link $file should fail"
20699 mdt_index=$($LFS getstripe -m $file)
20700 if [ $mdt_index == 0 ]; then
20701 # file failed to migrate is not allowed to rename to
20702 mv $DIR/$tdir/remote_dir/$tfile $file &&
20703 error "rename to $file should fail"
20705 mv $DIR/$tdir/remote_dir/$tfile $file ||
20706 error "rename to $file failed"
20708 echo hello >> $file || error "write $file failed"
20711 # resume migration with different options should fail
20712 $LFS migrate -m 0 $migrate_dir &&
20713 error "migrate -m 0 $migrate_dir should fail"
20715 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
20716 error "migrate -c 2 $migrate_dir should fail"
20718 # resume migration should succeed
20719 $LFS migrate -m $MDTIDX $migrate_dir ||
20720 error "migrate $migrate_dir failed"
20722 echo "Finish migration, then checking.."
20723 for file in $(find $migrate_dir); do
20724 mdt_index=$($LFS getstripe -m $file)
20725 [ $mdt_index == $MDTIDX ] ||
20726 error "$file is not on MDT${MDTIDX}"
20729 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20731 run_test 230c "check directory accessiblity if migration failed"
20734 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20735 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20736 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20737 skip "Need MDS version at least 2.11.52"
20739 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
20741 local migrate_dir=$DIR/$tdir/migrate_dir
20751 old_index=$((RANDOM % MDSCOUNT))
20752 old_count=$((MDSCOUNT - old_index))
20753 new_index=$((RANDOM % MDSCOUNT))
20754 new_count=$((MDSCOUNT - new_index))
20755 new_hash=1 # for all_char
20757 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
20758 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
20760 test_mkdir $DIR/$tdir
20761 test_mkdir -i $old_index -c $old_count $migrate_dir
20763 for ((i=0; i<100; i++)); do
20764 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
20765 createmany -o $migrate_dir/dir_${i}/f 100 ||
20766 error "create files under remote dir failed $i"
20769 echo -n "Migrate from MDT$old_index "
20770 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
20771 echo -n "to MDT$new_index"
20772 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
20775 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
20776 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
20777 error "migrate remote dir error"
20779 echo "Finish migration, then checking.."
20780 for file in $(find $migrate_dir -maxdepth 1); do
20781 mdt_index=$($LFS getstripe -m $file)
20782 if [ $mdt_index -lt $new_index ] ||
20783 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
20784 error "$file is on MDT$mdt_index"
20788 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20790 run_test 230d "check migrate big directory"
20793 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20794 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20795 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20796 skip "Need MDS version at least 2.11.52"
20803 mkdir_on_mdt0 $DIR/$tdir
20804 mkdir $DIR/$tdir/migrate_dir
20805 mkdir $DIR/$tdir/other_dir
20806 touch $DIR/$tdir/migrate_dir/a
20807 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
20808 ls $DIR/$tdir/other_dir
20810 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20811 error "migrate dir fails"
20813 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20814 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20816 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20817 [ $mdt_index == 0 ] || error "a is not on MDT0"
20819 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
20820 error "migrate dir fails"
20822 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
20823 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
20825 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20826 [ $mdt_index == 1 ] || error "a is not on MDT1"
20828 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
20829 [ $mdt_index == 1 ] || error "b is not on MDT1"
20831 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20832 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
20834 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
20836 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20838 run_test 230e "migrate mulitple local link files"
20841 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20842 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20843 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20844 skip "Need MDS version at least 2.11.52"
20849 mkdir -p $DIR/$tdir
20850 mkdir $DIR/$tdir/migrate_dir
20851 $LFS mkdir -i1 $DIR/$tdir/other_dir
20852 touch $DIR/$tdir/migrate_dir/a
20853 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
20854 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
20855 ls $DIR/$tdir/other_dir
20857 # a should be migrated to MDT1, since no other links on MDT0
20858 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20859 error "#1 migrate dir fails"
20860 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20861 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20862 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20863 [ $mdt_index == 1 ] || error "a is not on MDT1"
20865 # a should stay on MDT1, because it is a mulitple link file
20866 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20867 error "#2 migrate dir fails"
20868 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20869 [ $mdt_index == 1 ] || error "a is not on MDT1"
20871 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20872 error "#3 migrate dir fails"
20874 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20875 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
20876 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
20878 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
20879 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
20881 # a should be migrated to MDT0, since no other links on MDT1
20882 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20883 error "#4 migrate dir fails"
20884 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20885 [ $mdt_index == 0 ] || error "a is not on MDT0"
20887 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20889 run_test 230f "migrate mulitple remote link files"
20892 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20893 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20894 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20895 skip "Need MDS version at least 2.11.52"
20897 mkdir -p $DIR/$tdir/migrate_dir
20899 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
20900 error "migrating dir to non-exist MDT succeeds"
20903 run_test 230g "migrate dir to non-exist MDT"
20906 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20907 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20908 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20909 skip "Need MDS version at least 2.11.52"
20913 mkdir -p $DIR/$tdir/migrate_dir
20915 $LFS migrate -m1 $DIR &&
20916 error "migrating mountpoint1 should fail"
20918 $LFS migrate -m1 $DIR/$tdir/.. &&
20919 error "migrating mountpoint2 should fail"
20922 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
20923 error "migrating $tdir/migrate_dir/.. should fail"
20927 run_test 230h "migrate .. and root"
20930 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20931 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20932 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20933 skip "Need MDS version at least 2.11.52"
20935 mkdir -p $DIR/$tdir/migrate_dir
20937 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
20938 error "migration fails with a tailing slash"
20940 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
20941 error "migration fails with two tailing slashes"
20943 run_test 230i "lfs migrate -m tolerates trailing slashes"
20946 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20947 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
20948 skip "Need MDS version at least 2.11.52"
20950 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20951 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
20952 error "create $tfile failed"
20953 cat /etc/passwd > $DIR/$tdir/$tfile
20955 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20957 cmp /etc/passwd $DIR/$tdir/$tfile ||
20958 error "DoM file mismatch after migration"
20960 run_test 230j "DoM file data not changed after dir migration"
20963 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
20964 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20965 skip "Need MDS version at least 2.11.56"
20968 local files_on_starting_mdt=0
20970 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
20971 $LFS getdirstripe $DIR/$tdir
20972 for i in $(seq $total); do
20973 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
20974 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20975 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20978 echo "$files_on_starting_mdt files on MDT0"
20980 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
20981 $LFS getdirstripe $DIR/$tdir
20983 files_on_starting_mdt=0
20984 for i in $(seq $total); do
20985 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20986 error "file $tfile.$i mismatch after migration"
20987 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
20988 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20991 echo "$files_on_starting_mdt files on MDT1 after migration"
20992 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
20994 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
20995 $LFS getdirstripe $DIR/$tdir
20997 files_on_starting_mdt=0
20998 for i in $(seq $total); do
20999 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
21000 error "file $tfile.$i mismatch after 2nd migration"
21001 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
21002 files_on_starting_mdt=$((files_on_starting_mdt + 1))
21005 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
21006 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
21010 run_test 230k "file data not changed after dir migration"
21013 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21014 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
21015 skip "Need MDS version at least 2.11.56"
21017 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
21018 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
21019 error "create files under remote dir failed $i"
21020 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
21022 run_test 230l "readdir between MDTs won't crash"
21025 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21026 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
21027 skip "Need MDS version at least 2.11.56"
21030 local mig_dir=$DIR/$tdir/migrate_dir
21031 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
21035 echo "Creating files and dirs with xattrs"
21036 test_mkdir $DIR/$tdir
21037 test_mkdir -i0 -c1 $mig_dir
21039 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
21040 error "cannot set xattr attr1 on dir"
21041 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
21042 error "cannot set xattr attr2 on dir"
21043 touch $mig_dir/dir/f0
21044 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
21045 error "cannot set xattr attr1 on file"
21046 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
21047 error "cannot set xattr attr2 on file"
21048 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
21049 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
21050 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
21051 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
21052 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
21053 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
21054 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
21055 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
21056 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
21058 echo "Migrating to MDT1"
21059 $LFS migrate -m $MDTIDX $mig_dir ||
21060 error "fails on migrating dir to MDT1"
21062 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
21063 echo "Checking xattrs"
21064 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
21065 [ "$val" = $longstr ] ||
21066 error "expecting xattr1 $longstr on dir, found $val"
21067 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
21068 [ "$val" = $shortstr ] ||
21069 error "expecting xattr2 $shortstr on dir, found $val"
21070 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
21071 [ "$val" = $longstr ] ||
21072 error "expecting xattr1 $longstr on file, found $val"
21073 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
21074 [ "$val" = $shortstr ] ||
21075 error "expecting xattr2 $shortstr on file, found $val"
21077 run_test 230m "xattrs not changed after dir migration"
21080 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21081 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
21082 skip "Need MDS version at least 2.13.53"
21084 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
21085 cat /etc/hosts > $DIR/$tdir/$tfile
21086 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
21087 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
21089 cmp /etc/hosts $DIR/$tdir/$tfile ||
21090 error "File data mismatch after migration"
21092 run_test 230n "Dir migration with mirrored file"
21095 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
21096 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
21097 skip "Need MDS version at least 2.13.52"
21099 local mdts=$(comma_list $(mdts_nodes))
21101 local restripe_status
21105 [[ $mds1_FSTYPE == zfs ]] && timeout=300
21107 # in case "crush" hash type is not set
21108 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
21110 restripe_status=$(do_facet mds1 $LCTL get_param -n \
21111 mdt.*MDT0000.enable_dir_restripe)
21112 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
21113 stack_trap "do_nodes $mdts $LCTL set_param \
21114 mdt.*.enable_dir_restripe=$restripe_status"
21117 createmany -m $DIR/$tdir/f 100 ||
21118 error "create files under remote dir failed $i"
21119 createmany -d $DIR/$tdir/d 100 ||
21120 error "create dirs under remote dir failed $i"
21122 for i in $(seq 2 $MDSCOUNT); do
21123 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
21124 $LFS setdirstripe -c $i $DIR/$tdir ||
21125 error "split -c $i $tdir failed"
21126 wait_update $HOSTNAME \
21127 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
21128 error "dir split not finished"
21129 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
21130 awk '/migrate/ {sum += $2} END { print sum }')
21131 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
21132 # delta is around total_files/stripe_count
21133 (( $delta < 200 / (i - 1) + 4 )) ||
21134 error "$delta files migrated >= $((200 / (i - 1) + 4))"
21137 run_test 230o "dir split"
21140 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
21141 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
21142 skip "Need MDS version at least 2.13.52"
21144 local mdts=$(comma_list $(mdts_nodes))
21146 local restripe_status
21150 [[ $mds1_FSTYPE == zfs ]] && timeout=300
21152 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
21154 restripe_status=$(do_facet mds1 $LCTL get_param -n \
21155 mdt.*MDT0000.enable_dir_restripe)
21156 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
21157 stack_trap "do_nodes $mdts $LCTL set_param \
21158 mdt.*.enable_dir_restripe=$restripe_status"
21160 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
21161 createmany -m $DIR/$tdir/f 100 ||
21162 error "create files under remote dir failed"
21163 createmany -d $DIR/$tdir/d 100 ||
21164 error "create dirs under remote dir failed"
21166 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
21167 local mdt_hash="crush"
21169 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
21170 $LFS setdirstripe -c $c $DIR/$tdir ||
21171 error "split -c $c $tdir failed"
21172 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
21173 mdt_hash="$mdt_hash,fixed"
21174 elif [ $c -eq 1 ]; then
21177 wait_update $HOSTNAME \
21178 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
21179 error "dir merge not finished"
21180 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
21181 awk '/migrate/ {sum += $2} END { print sum }')
21182 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
21183 # delta is around total_files/stripe_count
21184 (( delta < 200 / c + 4 )) ||
21185 error "$delta files migrated >= $((200 / c + 4))"
21188 run_test 230p "dir merge"
21191 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
21192 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
21193 skip "Need MDS version at least 2.13.52"
21195 local mdts=$(comma_list $(mdts_nodes))
21196 local saved_threshold=$(do_facet mds1 \
21197 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
21198 local saved_delta=$(do_facet mds1 \
21199 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
21200 local threshold=100
21203 local stripe_count=0
21208 # test with fewer files on ZFS
21209 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
21211 stack_trap "do_nodes $mdts $LCTL set_param \
21212 mdt.*.dir_split_count=$saved_threshold"
21213 stack_trap "do_nodes $mdts $LCTL set_param \
21214 mdt.*.dir_split_delta=$saved_delta"
21215 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
21216 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
21217 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
21218 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
21219 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
21220 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
21222 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
21223 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
21225 create=$((threshold * 3 / 2))
21226 while [ $stripe_count -lt $MDSCOUNT ]; do
21227 createmany -m $DIR/$tdir/f $total $create ||
21228 error "create sub files failed"
21229 stat $DIR/$tdir > /dev/null
21230 total=$((total + create))
21231 stripe_count=$((stripe_count + delta))
21232 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
21234 wait_update $HOSTNAME \
21235 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
21236 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
21238 wait_update $HOSTNAME \
21239 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
21240 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
21242 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
21243 echo "$nr_files/$total files on MDT$stripe_index after split"
21244 # allow 10% margin of imbalance with crush hash
21245 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
21246 error "$nr_files files on MDT$stripe_index after split"
21248 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
21249 [ $nr_files -eq $total ] ||
21250 error "total sub files $nr_files != $total"
21253 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
21255 echo "fixed layout directory won't auto split"
21256 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
21257 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
21258 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
21259 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
21260 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
21262 run_test 230q "dir auto split"
21265 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
21266 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
21267 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
21268 skip "Need MDS version at least 2.13.54"
21270 # maximum amount of local locks:
21271 # parent striped dir - 2 locks
21272 # new stripe in parent to migrate to - 1 lock
21273 # source and target - 2 locks
21274 # Total 5 locks for regular file
21275 mkdir -p $DIR/$tdir
21276 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
21277 touch $DIR/$tdir/dir1/eee
21279 # create 4 hardlink for 4 more locks
21280 # Total: 9 locks > RS_MAX_LOCKS (8)
21281 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
21282 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
21283 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
21284 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
21285 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
21286 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
21287 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
21288 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
21290 cancel_lru_locks mdc
21292 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
21293 error "migrate dir fails"
21295 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21297 run_test 230r "migrate with too many local locks"
21300 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
21301 skip "Need MDS version at least 2.14.52"
21303 local mdts=$(comma_list $(mdts_nodes))
21304 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
21305 mdt.*MDT0000.enable_dir_restripe)
21307 stack_trap "do_nodes $mdts $LCTL set_param \
21308 mdt.*.enable_dir_restripe=$restripe_status"
21312 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
21313 test_mkdir $DIR/$tdir
21314 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
21315 error "$LFS mkdir should return EEXIST if target exists"
21319 run_test 230s "lfs mkdir should return -EEXIST if target exists"
21323 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
21324 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
21325 skip "Need MDS version at least 2.14.50"
21327 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
21328 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
21329 $LFS project -p 1 -s $DIR/$tdir ||
21330 error "set $tdir project id failed"
21331 $LFS project -p 2 -s $DIR/$tdir/subdir ||
21332 error "set subdir project id failed"
21333 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
21335 run_test 230t "migrate directory with project ID set"
21339 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
21340 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
21341 skip "Need MDS version at least 2.14.53"
21345 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
21346 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
21347 $LFS migrate -m -1 $DIR/$tdir/sub{0..99} || error "migrate sub failed"
21348 for i in $(seq 0 $((MDSCOUNT - 1))); do
21349 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
21350 echo "$count dirs migrated to MDT$i"
21352 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
21353 (( count >= MDSCOUNT - 1 )) || error "dirs migrated to $count MDTs"
21355 run_test 230u "migrate directory by QOS"
21359 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
21360 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
21361 skip "Need MDS version at least 2.14.53"
21365 mkdir $DIR/$tdir || error "mkdir $tdir failed"
21366 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
21367 $LFS migrate -m 0,2,1 $DIR/$tdir || error "migrate $tdir failed"
21368 for i in $(seq 0 $((MDSCOUNT - 1))); do
21369 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
21370 echo "$count subdirs migrated to MDT$i"
21371 (( i == 3 )) && (( count > 0 )) &&
21372 error "subdir shouldn't be migrated to MDT3"
21374 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
21375 (( count == 3 )) || error "dirs migrated to $count MDTs"
21377 run_test 230v "subdir migrated to the MDT where its parent is located"
21380 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
21381 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
21382 skip "Need MDS version at least 2.15.0"
21384 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
21385 createmany -o $DIR/$tdir/f 10 || error "create files failed"
21386 createmany -d $DIR/$tdir/d 10 || error "create dirs failed"
21388 $LFS migrate -m 1 -c $MDSCOUNT -d $DIR/$tdir ||
21389 error "migrate failed"
21391 (( $($LFS getdirstripe -c $DIR/$tdir) == MDSCOUNT )) ||
21392 error "$tdir stripe count mismatch"
21394 for i in $(seq 0 9); do
21395 (( $($LFS getdirstripe -c $DIR/$tdir/d$i) == 0 )) ||
21396 error "d$i is striped"
21399 run_test 230w "non-recursive mode dir migration"
21402 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
21403 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
21404 skip "Need MDS version at least 2.15.0"
21406 mkdir -p $DIR/$tdir || error "mkdir failed"
21407 createmany -d $DIR/$tdir/sub 100 || error "createmany failed"
21409 local mdt_name=$(mdtname_from_index 0)
21410 local low=$(do_facet mds2 $LCTL get_param -n \
21411 osp.*$mdt_name-osp-MDT0001.reserved_ino_low)
21412 local high=$(do_facet mds2 $LCTL get_param -n \
21413 osp.*$mdt_name-osp-MDT0001.reserved_ino_high)
21414 local ffree=$($LFS df -i $MOUNT | awk "/$mdt_name/ { print \$4 }")
21415 local maxage=$(do_facet mds2 $LCTL get_param -n \
21416 osp.*$mdt_name-osp-MDT0001.maxage)
21418 stack_trap "do_facet mds2 $LCTL set_param -n \
21419 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low \
21420 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high" EXIT
21421 stack_trap "do_facet mds2 $LCTL set_param -n \
21422 osp.*$mdt_name-osp-MDT0001.maxage=$maxage" EXIT
21424 do_facet mds2 $LCTL set_param -n \
21425 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$((ffree + 1))
21426 do_facet mds2 $LCTL set_param -n osp.*$mdt_name-osp-MDT0001.maxage=1
21428 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir &&
21429 error "migrate $tdir should fail"
21431 do_facet mds2 $LCTL set_param -n \
21432 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low
21433 do_facet mds2 $LCTL set_param -n \
21434 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high
21436 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir ||
21437 error "migrate failed"
21438 (( $($LFS getdirstripe -c $DIR/$tdir) == $MDSCOUNT )) ||
21439 error "$tdir stripe count mismatch"
21441 run_test 230x "dir migration check space"
21445 # For simplicity this test assumes that max_pages_per_rpc
21446 # is the same across all OSCs
21447 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
21448 local bulk_size=$((max_pages * PAGE_SIZE))
21449 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
21452 mkdir -p $DIR/$tdir
21453 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
21454 error "failed to set stripe with -S ${brw_size}M option"
21456 # clear the OSC stats
21457 $LCTL set_param osc.*.stats=0 &>/dev/null
21460 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
21461 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
21462 oflag=direct &>/dev/null || error "dd failed"
21464 sync; sleep 1; sync # just to be safe
21465 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
21466 if [ x$nrpcs != "x1" ]; then
21467 $LCTL get_param osc.*.stats
21468 error "found $nrpcs ost_write RPCs, not 1 as expected"
21472 # Drop the OSC cache, otherwise we will read from it
21473 cancel_lru_locks osc
21475 # clear the OSC stats
21476 $LCTL set_param osc.*.stats=0 &>/dev/null
21478 # Client reads $bulk_size.
21479 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
21480 iflag=direct &>/dev/null || error "dd failed"
21482 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
21483 if [ x$nrpcs != "x1" ]; then
21484 $LCTL get_param osc.*.stats
21485 error "found $nrpcs ost_read RPCs, not 1 as expected"
21488 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
21491 mkdir -p $DIR/$tdir
21493 for i in {0..1023}; do
21494 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
21495 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
21496 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
21500 run_test 231b "must not assert on fully utilized OST request buffer"
21503 mkdir -p $DIR/$tdir
21504 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
21506 #define OBD_FAIL_LDLM_OST_LVB 0x31c
21507 do_facet ost1 $LCTL set_param fail_loc=0x31c
21509 # ignore dd failure
21510 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
21512 do_facet ost1 $LCTL set_param fail_loc=0
21513 umount_client $MOUNT || error "umount failed"
21514 mount_client $MOUNT || error "mount failed"
21515 stop ost1 || error "cannot stop ost1"
21516 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21518 run_test 232a "failed lock should not block umount"
21521 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
21522 skip "Need MDS version at least 2.10.58"
21524 mkdir -p $DIR/$tdir
21525 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
21526 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
21528 cancel_lru_locks osc
21530 #define OBD_FAIL_LDLM_OST_LVB 0x31c
21531 do_facet ost1 $LCTL set_param fail_loc=0x31c
21534 $LFS data_version $DIR/$tdir/$tfile || true
21536 do_facet ost1 $LCTL set_param fail_loc=0
21537 umount_client $MOUNT || error "umount failed"
21538 mount_client $MOUNT || error "mount failed"
21539 stop ost1 || error "cannot stop ost1"
21540 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21542 run_test 232b "failed data version lock should not block umount"
21545 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
21546 skip "Need MDS version at least 2.3.64"
21547 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
21549 local fid=$($LFS path2fid $MOUNT)
21551 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21552 error "cannot access $MOUNT using its FID '$fid'"
21554 run_test 233a "checking that OBF of the FS root succeeds"
21557 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
21558 skip "Need MDS version at least 2.5.90"
21559 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
21561 local fid=$($LFS path2fid $MOUNT/.lustre)
21563 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21564 error "cannot access $MOUNT/.lustre using its FID '$fid'"
21566 fid=$($LFS path2fid $MOUNT/.lustre/fid)
21567 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21568 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
21570 run_test 233b "checking that OBF of the FS .lustre succeeds"
21573 local p="$TMP/sanityN-$TESTNAME.parameters"
21574 save_lustre_params client "llite.*.xattr_cache" > $p
21575 lctl set_param llite.*.xattr_cache 1 ||
21576 skip_env "xattr cache is not supported"
21578 mkdir -p $DIR/$tdir || error "mkdir failed"
21579 touch $DIR/$tdir/$tfile || error "touch failed"
21580 # OBD_FAIL_LLITE_XATTR_ENOMEM
21581 $LCTL set_param fail_loc=0x1405
21582 getfattr -n user.attr $DIR/$tdir/$tfile &&
21583 error "getfattr should have failed with ENOMEM"
21584 $LCTL set_param fail_loc=0x0
21587 restore_lustre_params < $p
21590 run_test 234 "xattr cache should not crash on ENOMEM"
21593 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
21594 skip "Need MDS version at least 2.4.52"
21596 flock_deadlock $DIR/$tfile
21601 124) error "process hangs on a deadlock"
21603 *) error "error executing flock_deadlock $DIR/$tfile"
21607 run_test 235 "LU-1715: flock deadlock detection does not work properly"
21611 check_swap_layouts_support
21613 local ref1=/etc/passwd
21614 local ref2=/etc/group
21615 local file1=$DIR/$tdir/f1
21616 local file2=$DIR/$tdir/f2
21618 test_mkdir -c1 $DIR/$tdir
21619 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
21620 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
21621 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
21622 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
21623 local fd=$(free_fd)
21624 local cmd="exec $fd<>$file2"
21627 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
21628 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
21631 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
21636 run_test 236 "Layout swap on open unlinked file"
21638 # LU-4659 linkea consistency
21640 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
21641 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
21642 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
21643 skip "Need MDS version at least 2.5.58 or 2.5.2+"
21646 ln $DIR/$tfile $DIR/$tfile.lnk
21647 touch $DIR/$tfile.new
21648 mv $DIR/$tfile.new $DIR/$tfile
21649 local fid1=$($LFS path2fid $DIR/$tfile)
21650 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
21651 local path1=$($LFS fid2path $FSNAME "$fid1")
21652 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
21653 local path2=$($LFS fid2path $FSNAME "$fid2")
21654 [ $tfile.lnk == $path2 ] ||
21655 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
21658 run_test 238 "Verify linkea consistency"
21660 test_239A() { # was test_239
21661 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
21662 skip "Need MDS version at least 2.5.60"
21664 local list=$(comma_list $(mdts_nodes))
21666 mkdir -p $DIR/$tdir
21667 createmany -o $DIR/$tdir/f- 5000
21668 unlinkmany $DIR/$tdir/f- 5000
21669 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
21670 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
21671 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
21672 osp.*MDT*.sync_in_flight" | calc_sum)
21673 [ "$changes" -eq 0 ] || error "$changes not synced"
21675 run_test 239A "osp_sync test"
21677 test_239a() { #LU-5297
21678 remote_mds_nodsh && skip "remote MDS with nodsh"
21681 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
21682 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
21683 chgrp $RUNAS_GID $DIR/$tfile
21684 wait_delete_completed
21686 run_test 239a "process invalid osp sync record correctly"
21688 test_239b() { #LU-5297
21689 remote_mds_nodsh && skip "remote MDS with nodsh"
21692 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
21693 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
21694 chgrp $RUNAS_GID $DIR/$tfile1
21695 wait_delete_completed
21696 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
21698 chgrp $RUNAS_GID $DIR/$tfile2
21699 wait_delete_completed
21701 run_test 239b "process osp sync record with ENOMEM error correctly"
21704 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21705 remote_mds_nodsh && skip "remote MDS with nodsh"
21707 mkdir -p $DIR/$tdir
21709 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
21710 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
21711 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
21712 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
21714 umount_client $MOUNT || error "umount failed"
21715 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
21716 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
21717 mount_client $MOUNT || error "failed to mount client"
21719 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
21720 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
21722 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
21728 for LOOP in $(seq $count); do
21729 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
21730 cancel_lru_locks $OSC || true
21738 for LOOP in $(seq $1); do
21739 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
21744 test_241a() { # was test_241
21745 local bsize=$PAGE_SIZE
21747 (( bsize < 40960 )) && bsize=40960
21748 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21750 cancel_lru_locks $OSC
21751 test_241_bio 1000 $bsize &
21753 test_241_dio 1000 $bsize
21756 run_test 241a "bio vs dio"
21759 local bsize=$PAGE_SIZE
21761 (( bsize < 40960 )) && bsize=40960
21762 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21764 test_241_dio 1000 $bsize &
21766 test_241_dio 1000 $bsize
21769 run_test 241b "dio vs dio"
21772 remote_mds_nodsh && skip "remote MDS with nodsh"
21774 mkdir_on_mdt0 $DIR/$tdir
21775 touch $DIR/$tdir/$tfile
21777 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
21778 do_facet mds1 lctl set_param fail_loc=0x105
21779 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
21781 do_facet mds1 lctl set_param fail_loc=0
21782 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
21784 run_test 242 "mdt_readpage failure should not cause directory unreadable"
21788 test_mkdir $DIR/$tdir
21789 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
21791 run_test 243 "various group lock tests"
21795 test_mkdir $DIR/$tdir
21796 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
21797 sendfile_grouplock $DIR/$tdir/$tfile || \
21798 error "sendfile+grouplock failed"
21801 run_test 244a "sendfile with group lock tests"
21805 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
21808 local size=$((1024*1024))
21810 test_mkdir $DIR/$tdir
21811 for i in $(seq 1 $threads); do
21812 local file=$DIR/$tdir/file_$((i / 10))
21813 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
21816 for i in $(seq 1 $threads); do
21820 run_test 244b "multi-threaded write with group lock"
21823 local flagname="multi_mod_rpcs"
21824 local connect_data_name="max_mod_rpcs"
21827 # check if multiple modify RPCs flag is set
21828 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
21829 grep "connect_flags:")
21832 echo "$out" | grep -qw $flagname
21833 if [ $? -ne 0 ]; then
21834 echo "connect flag $flagname is not set"
21838 # check if multiple modify RPCs data is set
21839 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
21842 echo "$out" | grep -qw $connect_data_name ||
21843 error "import should have connect data $connect_data_name"
21845 run_test 245a "check mdc connection flag/data: multiple modify RPCs"
21848 local flagname="multi_mod_rpcs"
21849 local connect_data_name="max_mod_rpcs"
21852 remote_mds_nodsh && skip "remote MDS with nodsh"
21853 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
21855 # check if multiple modify RPCs flag is set
21856 out=$(do_facet mds1 \
21857 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import |
21858 grep "connect_flags:")
21861 [[ "$out" =~ $flagname ]] || skip "connect flag $flagname is not set"
21863 # check if multiple modify RPCs data is set
21864 out=$(do_facet mds1 \
21865 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import)
21867 [[ "$out" =~ $connect_data_name ]] ||
21870 error "missing connect data $connect_data_name"
21873 run_test 245b "check osp connection flag/data: multiple modify RPCs"
21879 umount_client $submount
21884 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21886 skip_env "Fileset feature is not supported"
21888 local submount=${MOUNT}_$tdir
21891 mkdir -p $submount || error "mkdir $submount failed"
21892 FILESET="$FILESET/$tdir" mount_client $submount ||
21893 error "mount $submount failed"
21894 trap "cleanup_247 $submount" EXIT
21895 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
21896 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
21897 error "read $MOUNT/$tdir/$tfile failed"
21898 cleanup_247 $submount
21900 run_test 247a "mount subdir as fileset"
21903 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21904 skip_env "Fileset feature is not supported"
21906 local submount=${MOUNT}_$tdir
21908 rm -rf $MOUNT/$tdir
21909 mkdir -p $submount || error "mkdir $submount failed"
21911 FILESET="$FILESET/$tdir" mount_client $submount &&
21912 error "mount $submount should fail"
21915 run_test 247b "mount subdir that dose not exist"
21918 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21919 skip_env "Fileset feature is not supported"
21921 local submount=${MOUNT}_$tdir
21923 mkdir -p $MOUNT/$tdir/dir1
21924 mkdir -p $submount || error "mkdir $submount failed"
21925 trap "cleanup_247 $submount" EXIT
21926 FILESET="$FILESET/$tdir" mount_client $submount ||
21927 error "mount $submount failed"
21928 local fid=$($LFS path2fid $MOUNT/)
21929 $LFS fid2path $submount $fid && error "fid2path should fail"
21930 cleanup_247 $submount
21932 run_test 247c "running fid2path outside subdirectory root"
21935 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21936 skip "Fileset feature is not supported"
21938 local submount=${MOUNT}_$tdir
21940 mkdir -p $MOUNT/$tdir/dir1
21941 mkdir -p $submount || error "mkdir $submount failed"
21942 FILESET="$FILESET/$tdir" mount_client $submount ||
21943 error "mount $submount failed"
21944 trap "cleanup_247 $submount" EXIT
21946 local td=$submount/dir1
21947 local fid=$($LFS path2fid $td)
21948 [ -z "$fid" ] && error "path2fid unable to get $td FID"
21950 # check that we get the same pathname back
21953 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
21954 echo "$rootpath $fid"
21955 found=$($LFS fid2path $rootpath "$fid")
21956 [ -n "$found" ] || error "fid2path should succeed"
21957 [ "$found" == "$td" ] || error "fid2path $found != $td"
21959 # check wrong root path format
21960 rootpath=$submount"_wrong"
21961 found=$($LFS fid2path $rootpath "$fid")
21962 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
21964 cleanup_247 $submount
21966 run_test 247d "running fid2path inside subdirectory root"
21970 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21972 skip "Fileset feature is not supported"
21974 local submount=${MOUNT}_$tdir
21977 mkdir -p $submount || error "mkdir $submount failed"
21978 FILESET="$FILESET/.." mount_client $submount &&
21979 error "mount $submount should fail"
21982 run_test 247e "mount .. as fileset"
21985 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
21986 (( $MDS1_VERSION >= $(version_code 2.14.50.162) )) ||
21987 skip "Need at least version 2.14.50.162"
21988 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21989 skip "Fileset feature is not supported"
21991 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
21992 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
21993 error "mkdir remote failed"
21994 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
21995 error "mkdir remote/subdir failed"
21996 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
21997 error "mkdir striped failed"
21998 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
22000 local submount=${MOUNT}_$tdir
22002 mkdir -p $submount || error "mkdir $submount failed"
22003 stack_trap "rmdir $submount"
22006 local fileset=$FILESET
22007 local mdts=$(comma_list $(mdts_nodes))
22009 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
22010 for dir in $tdir/remote $tdir/remote/subdir $tdir/striped \
22011 $tdir/striped/subdir $tdir/striped/.; do
22012 FILESET="$fileset/$dir" mount_client $submount ||
22013 error "mount $dir failed"
22014 umount_client $submount
22017 run_test 247f "mount striped or remote directory as fileset"
22019 test_subdir_mount_lock()
22022 local submount=${MOUNT}_$(basename $testdir)
22024 touch $DIR/$testdir/$tfile || error "touch $tfile failed"
22026 mkdir -p $submount || error "mkdir $submount failed"
22027 stack_trap "rmdir $submount"
22029 FILESET="$fileset/$testdir" mount_client $submount ||
22030 error "mount $FILESET failed"
22031 stack_trap "umount $submount"
22033 local mdts=$(comma_list $(mdts_nodes))
22037 stat $submount > /dev/null || error "stat $submount failed"
22038 cancel_lru_locks $MDC
22039 stat $submount > /dev/null || error "stat $submount failed"
22040 stat $submount/$tfile > /dev/null || error "stat $tfile failed"
22041 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
22042 stat $submount/$tfile > /dev/null || error "stat $tfile failed"
22043 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
22044 awk '/getattr/ {sum += $2} END {print sum}')
22046 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
22050 (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
22052 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
22053 error "mkdir $tdir failed"
22054 test_subdir_mount_lock $tdir
22056 run_test 247g "striped directory submount revalidate ROOT from cache"
22059 (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
22060 (( $MDS1_VERSION >= $(version_code 2.15.51) )) ||
22061 skip "Need MDS version at least 2.15.51"
22063 $LFS mkdir -i 1 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
22064 test_subdir_mount_lock $tdir
22065 mkdir_on_mdt -i 0 $DIR/$tdir/$tdir.0 || error "mkdir $tdir.0 failed"
22066 mkdir_on_mdt -i 1 $DIR/$tdir/$tdir.0/$tdir.1 ||
22067 error "mkdir $tdir.1 failed"
22068 test_subdir_mount_lock $tdir/$tdir.0/$tdir.1
22070 run_test 247h "remote directory submount revalidate ROOT from cache"
22073 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
22074 [ -z "$fast_read_sav" ] && skip "no fast read support"
22076 # create a large file for fast read verification
22077 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
22079 # make sure the file is created correctly
22080 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
22081 { rm -f $DIR/$tfile; skip "file creation error"; }
22083 echo "Test 1: verify that fast read is 4 times faster on cache read"
22085 # small read with fast read enabled
22086 $LCTL set_param -n llite.*.fast_read=1
22087 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
22088 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
22089 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
22090 # small read with fast read disabled
22091 $LCTL set_param -n llite.*.fast_read=0
22092 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
22093 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
22094 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
22096 # verify that fast read is 4 times faster for cache read
22097 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
22098 error_not_in_vm "fast read was not 4 times faster: " \
22099 "$t_fast vs $t_slow"
22101 echo "Test 2: verify the performance between big and small read"
22102 $LCTL set_param -n llite.*.fast_read=1
22104 # 1k non-cache read
22105 cancel_lru_locks osc
22106 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
22107 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
22108 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
22110 # 1M non-cache read
22111 cancel_lru_locks osc
22112 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
22113 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
22114 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
22116 # verify that big IO is not 4 times faster than small IO
22117 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
22118 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
22120 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
22123 run_test 248a "fast read verification"
22126 # Default short_io_bytes=16384, try both smaller and larger sizes.
22127 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
22128 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
22129 echo "bs=53248 count=113 normal buffered write"
22130 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
22131 error "dd of initial data file failed"
22132 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
22134 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
22135 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
22136 error "dd with sync normal writes failed"
22137 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
22139 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
22140 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
22141 error "dd with sync small writes failed"
22142 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
22144 cancel_lru_locks osc
22146 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
22147 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
22148 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
22149 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
22150 iflag=direct || error "dd with O_DIRECT small read failed"
22151 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
22152 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
22153 error "compare $TMP/$tfile.1 failed"
22155 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
22156 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
22158 # just to see what the maximum tunable value is, and test parsing
22159 echo "test invalid parameter 2MB"
22160 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
22161 error "too-large short_io_bytes allowed"
22162 echo "test maximum parameter 512KB"
22163 # if we can set a larger short_io_bytes, run test regardless of version
22164 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
22165 # older clients may not allow setting it this large, that's OK
22166 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
22167 skip "Need at least client version 2.13.50"
22168 error "medium short_io_bytes failed"
22170 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
22171 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
22173 echo "test large parameter 64KB"
22174 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
22175 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
22177 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
22178 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
22179 error "dd with sync large writes failed"
22180 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
22182 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
22183 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
22184 num=$((113 * 4096 / PAGE_SIZE))
22185 echo "bs=$size count=$num oflag=direct large write $tfile.3"
22186 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
22187 error "dd with O_DIRECT large writes failed"
22188 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
22189 error "compare $DIR/$tfile.3 failed"
22191 cancel_lru_locks osc
22193 echo "bs=$size count=$num iflag=direct large read $tfile.2"
22194 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
22195 error "dd with O_DIRECT large read failed"
22196 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
22197 error "compare $TMP/$tfile.2 failed"
22199 echo "bs=$size count=$num iflag=direct large read $tfile.3"
22200 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
22201 error "dd with O_DIRECT large read failed"
22202 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
22203 error "compare $TMP/$tfile.3 failed"
22205 run_test 248b "test short_io read and write for both small and large sizes"
22207 test_249() { # LU-7890
22208 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
22209 skip "Need at least version 2.8.54"
22212 $LFS setstripe -c 1 $DIR/$tfile
22213 # Offset 2T == 4k * 512M
22214 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
22215 error "dd to 2T offset failed"
22217 run_test 249 "Write above 2T file size"
22220 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
22221 && skip "no 16TB file size limit on ZFS"
22223 $LFS setstripe -c 1 $DIR/$tfile
22224 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
22225 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
22226 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
22227 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
22228 conv=notrunc,fsync && error "append succeeded"
22231 run_test 250 "Write above 16T limit"
22234 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
22236 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
22237 #Skip once - writing the first stripe will succeed
22238 $LCTL set_param fail_loc=0xa0001407 fail_val=1
22239 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
22240 error "short write happened"
22242 $LCTL set_param fail_loc=0xa0001407 fail_val=1
22243 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
22244 error "short read happened"
22248 run_test 251 "Handling short read and write correctly"
22251 remote_mds_nodsh && skip "remote MDS with nodsh"
22252 remote_ost_nodsh && skip "remote OST with nodsh"
22253 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
22254 skip_env "ldiskfs only test"
22264 # check lr_reader on OST0000
22266 dev=$(facet_device $tgt)
22267 out=$(do_facet $tgt $LR_READER $dev)
22268 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
22270 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
22271 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
22272 error "Invalid uuid returned by $LR_READER on target $tgt"
22273 echo -e "uuid returned by $LR_READER is '$uuid'\n"
22275 # check lr_reader -c on MDT0000
22277 dev=$(facet_device $tgt)
22278 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
22279 skip "$LR_READER does not support additional options"
22281 out=$(do_facet $tgt $LR_READER -c $dev)
22282 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
22284 num=$(echo "$out" | grep -c "mdtlov")
22285 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
22286 error "Invalid number of mdtlov clients returned by $LR_READER"
22287 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
22289 # check lr_reader -cr on MDT0000
22290 out=$(do_facet $tgt $LR_READER -cr $dev)
22291 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
22293 echo "$out" | grep -q "^reply_data:$" ||
22294 error "$LR_READER should have returned 'reply_data' section"
22295 num=$(echo "$out" | grep -c "client_generation")
22296 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
22298 run_test 252 "check lr_reader tool"
22301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22302 remote_mds_nodsh && skip "remote MDS with nodsh"
22303 remote_mgs_nodsh && skip "remote MGS with nodsh"
22307 local ost_name=$(ostname_from_index $ostidx)
22310 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
22311 do_facet $SINGLEMDS $LCTL get_param -n \
22312 osp.$mdtosc_proc1.reserved_mb_high ||
22313 skip "remote MDS does not support reserved_mb_high"
22317 wait_delete_completed
22320 pool_add $TESTNAME || error "Pool creation failed"
22321 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
22323 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
22324 error "Setstripe failed"
22326 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
22328 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
22330 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
22332 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
22333 osp.$mdtosc_proc1.prealloc_status)
22334 echo "prealloc_status $oa_status"
22336 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
22337 error "File creation should fail"
22339 #object allocation was stopped, but we still able to append files
22340 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
22341 oflag=append || error "Append failed"
22343 rm -f $DIR/$tdir/$tfile.0
22345 # For this test, we want to delete the files we created to go out of
22346 # space but leave the watermark, so we remain nearly out of space
22347 ost_watermarks_enospc_delete_files $tfile $ostidx
22349 wait_delete_completed
22353 for i in $(seq 10 12); do
22354 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
22355 2>/dev/null || error "File creation failed after rm"
22358 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
22359 osp.$mdtosc_proc1.prealloc_status)
22360 echo "prealloc_status $oa_status"
22362 if (( oa_status != 0 )); then
22363 error "Object allocation still disable after rm"
22366 run_test 253 "Check object allocation limit"
22369 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22370 remote_mds_nodsh && skip "remote MDS with nodsh"
22372 local mdt=$(facet_svc $SINGLEMDS)
22374 do_facet $SINGLEMDS $LCTL get_param -n mdd.$mdt.changelog_size ||
22375 skip "MDS does not support changelog_size"
22379 changelog_register || error "changelog_register failed"
22381 changelog_clear 0 || error "changelog_clear failed"
22383 local size1=$(do_facet $SINGLEMDS \
22384 $LCTL get_param -n mdd.$mdt.changelog_size)
22385 echo "Changelog size $size1"
22388 $LFS mkdir -i 0 $DIR/$tdir
22390 mkdir -p $DIR/$tdir/pics/2008/zachy
22391 touch $DIR/$tdir/pics/2008/zachy/timestamp
22392 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
22393 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
22394 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
22395 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
22396 rm $DIR/$tdir/pics/desktop.jpg
22398 local size2=$(do_facet $SINGLEMDS \
22399 $LCTL get_param -n mdd.$mdt.changelog_size)
22400 echo "Changelog size after work $size2"
22402 (( $size2 > $size1 )) ||
22403 error "new Changelog size=$size2 less than old size=$size1"
22405 run_test 254 "Check changelog size"
22412 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
22413 awk -F: '{print $2}' | grep $type > /dev/null
22414 if [ $? -ne 0 ]; then
22424 lfs ladvise -a willread $file > /dev/null 2>&1
22425 if [ $? -eq 0 ]; then
22429 lfs ladvise -a willread $file 2>&1 |
22430 grep "Inappropriate ioctl for device" > /dev/null
22431 if [ $? -eq 0 ]; then
22438 bc <<<"scale=2; ($1 - $2) * 100 / $2"
22441 # run a random read IO workload
22442 # usage: random_read_iops <filename> <filesize> <iosize>
22443 random_read_iops() {
22446 local iosize=${3:-4096}
22448 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
22449 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
22452 drop_file_oss_cache() {
22456 $LFS ladvise -a dontneed $file 2>/dev/null ||
22457 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
22460 ladvise_willread_performance()
22463 local average_origin=0
22464 local average_cache=0
22465 local average_ladvise=0
22467 for ((i = 1; i <= $repeat; i++)); do
22468 echo "Iter $i/$repeat: reading without willread hint"
22469 cancel_lru_locks osc
22470 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
22471 local speed_origin=$(random_read_iops $DIR/$tfile $size)
22472 echo "Iter $i/$repeat: uncached speed: $speed_origin"
22473 average_origin=$(bc <<<"$average_origin + $speed_origin")
22475 cancel_lru_locks osc
22476 local speed_cache=$(random_read_iops $DIR/$tfile $size)
22477 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
22478 average_cache=$(bc <<<"$average_cache + $speed_cache")
22480 cancel_lru_locks osc
22481 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
22482 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
22483 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
22484 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
22485 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
22487 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
22488 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
22489 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
22491 speedup_cache=$(percent $average_cache $average_origin)
22492 speedup_ladvise=$(percent $average_ladvise $average_origin)
22494 echo "Average uncached read: $average_origin"
22495 echo "Average speedup with OSS cached read: " \
22496 "$average_cache = +$speedup_cache%"
22497 echo "Average speedup with ladvise willread: " \
22498 "$average_ladvise = +$speedup_ladvise%"
22500 local lowest_speedup=20
22501 if (( ${average_cache%.*} < $lowest_speedup )); then
22502 echo "Speedup with OSS cached read less than $lowest_speedup%,"\
22503 " got $average_cache%. Skipping ladvise willread check."
22507 # the test won't work on ZFS until it supports 'ladvise dontneed', but
22508 # it is still good to run until then to exercise 'ladvise willread'
22509 ! $LFS ladvise -a dontneed $DIR/$tfile &&
22510 [ "$ost1_FSTYPE" = "zfs" ] &&
22511 echo "osd-zfs does not support dontneed or drop_caches" &&
22514 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
22515 (( ${average_ladvise%.*} > ${lowest_speedup%.*} )) ||
22516 error_not_in_vm "Speedup with willread is less than " \
22517 "$lowest_speedup%, got $average_ladvise%"
22521 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
22522 skip "lustre < 2.8.54 does not support ladvise "
22523 remote_ost_nodsh && skip "remote OST with nodsh"
22525 stack_trap "rm -f $DIR/$tfile"
22526 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
22528 ladvise_no_type willread $DIR/$tfile &&
22529 skip "willread ladvise is not supported"
22531 ladvise_no_ioctl $DIR/$tfile &&
22532 skip "ladvise ioctl is not supported"
22535 local size=$((size_mb * 1048576))
22536 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
22537 error "dd to $DIR/$tfile failed"
22539 lfs ladvise -a willread $DIR/$tfile ||
22540 error "Ladvise failed with no range argument"
22542 lfs ladvise -a willread -s 0 $DIR/$tfile ||
22543 error "Ladvise failed with no -l or -e argument"
22545 lfs ladvise -a willread -e 1 $DIR/$tfile ||
22546 error "Ladvise failed with only -e argument"
22548 lfs ladvise -a willread -l 1 $DIR/$tfile ||
22549 error "Ladvise failed with only -l argument"
22551 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
22552 error "End offset should not be smaller than start offset"
22554 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
22555 error "End offset should not be equal to start offset"
22557 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
22558 error "Ladvise failed with overflowing -s argument"
22560 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
22561 error "Ladvise failed with overflowing -e argument"
22563 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
22564 error "Ladvise failed with overflowing -l argument"
22566 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
22567 error "Ladvise succeeded with conflicting -l and -e arguments"
22569 echo "Synchronous ladvise should wait"
22571 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
22572 do_nodes $(comma_list $(osts_nodes)) \
22573 $LCTL set_param fail_val=$delay fail_loc=0x237
22575 local start_ts=$SECONDS
22576 lfs ladvise -a willread $DIR/$tfile ||
22577 error "Ladvise failed with no range argument"
22578 local end_ts=$SECONDS
22579 local inteval_ts=$((end_ts - start_ts))
22581 if [ $inteval_ts -lt $(($delay - 1)) ]; then
22582 error "Synchronous advice didn't wait reply"
22585 echo "Asynchronous ladvise shouldn't wait"
22586 local start_ts=$SECONDS
22587 lfs ladvise -a willread -b $DIR/$tfile ||
22588 error "Ladvise failed with no range argument"
22589 local end_ts=$SECONDS
22590 local inteval_ts=$((end_ts - start_ts))
22592 if [ $inteval_ts -gt $(($delay / 2)) ]; then
22593 error "Asynchronous advice blocked"
22596 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
22597 ladvise_willread_performance
22599 run_test 255a "check 'lfs ladvise -a willread'"
22605 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
22609 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
22610 skip "lustre < 2.8.54 does not support ladvise "
22611 remote_ost_nodsh && skip "remote OST with nodsh"
22613 stack_trap "rm -f $DIR/$tfile"
22614 lfs setstripe -c 1 -i 0 $DIR/$tfile
22616 ladvise_no_type dontneed $DIR/$tfile &&
22617 skip "dontneed ladvise is not supported"
22619 ladvise_no_ioctl $DIR/$tfile &&
22620 skip "ladvise ioctl is not supported"
22622 ! $LFS ladvise -a dontneed $DIR/$tfile &&
22623 [ "$ost1_FSTYPE" = "zfs" ] &&
22624 skip "zfs-osd does not support 'ladvise dontneed'"
22627 local size=$((size_mb * 1048576))
22628 # In order to prevent disturbance of other processes, only check 3/4
22629 # of the memory usage
22630 local kibibytes=$((size_mb * 1024 * 3 / 4))
22632 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
22633 error "dd to $DIR/$tfile failed"
22635 #force write to complete before dropping OST cache & checking memory
22638 local total=$(facet_meminfo ost1 MemTotal)
22639 echo "Total memory: $total KiB"
22641 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
22642 local before_read=$(facet_meminfo ost1 Cached)
22643 echo "Cache used before read: $before_read KiB"
22645 lfs ladvise -a willread $DIR/$tfile ||
22646 error "Ladvise willread failed"
22647 local after_read=$(facet_meminfo ost1 Cached)
22648 echo "Cache used after read: $after_read KiB"
22650 lfs ladvise -a dontneed $DIR/$tfile ||
22651 error "Ladvise dontneed again failed"
22652 local no_read=$(facet_meminfo ost1 Cached)
22653 echo "Cache used after dontneed ladvise: $no_read KiB"
22655 if [ $total -lt $((before_read + kibibytes)) ]; then
22656 echo "Memory is too small, abort checking"
22660 if [ $((before_read + kibibytes)) -gt $after_read ]; then
22661 error "Ladvise willread should use more memory" \
22662 "than $kibibytes KiB"
22665 if [ $((no_read + kibibytes)) -gt $after_read ]; then
22666 error "Ladvise dontneed should release more memory" \
22667 "than $kibibytes KiB"
22670 run_test 255b "check 'lfs ladvise -a dontneed'"
22673 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
22674 skip "lustre < 2.10.50 does not support lockahead"
22676 local ost1_imp=$(get_osc_import_name client ost1)
22677 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
22685 test_mkdir -p $DIR/$tdir
22686 $LFS setstripe -i 0 -c 1 $DIR/$tdir
22688 #test 10 returns only success/failure
22690 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22692 if [ $rc -eq 255 ]; then
22693 error "Ladvise test${i} failed, ${rc}"
22696 #test 11 counts lock enqueue requests, all others count new locks
22698 count=$(do_facet ost1 \
22699 $LCTL get_param -n ost.OSS.ost.stats)
22700 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
22702 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22704 if [ $rc -eq 255 ]; then
22705 error "Ladvise test${i} failed, ${rc}"
22708 new_count=$(do_facet ost1 \
22709 $LCTL get_param -n ost.OSS.ost.stats)
22710 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
22711 awk '{ print $2 }')
22713 difference="$((new_count - count))"
22714 if [ $difference -ne $rc ]; then
22715 error "Ladvise test${i}, bad enqueue count, returned " \
22716 "${rc}, actual ${difference}"
22719 for i in $(seq 12 21); do
22720 # If we do not do this, we run the risk of having too many
22721 # locks and starting lock cancellation while we are checking
22723 cancel_lru_locks osc
22725 count=$($LCTL get_param -n \
22726 ldlm.namespaces.$imp_name.lock_unused_count)
22728 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22730 if [ $rc -eq 255 ]; then
22731 error "Ladvise test ${i} failed, ${rc}"
22734 new_count=$($LCTL get_param -n \
22735 ldlm.namespaces.$imp_name.lock_unused_count)
22736 difference="$((new_count - count))"
22738 # Test 15 output is divided by 100 to map down to valid return
22739 if [ $i -eq 15 ]; then
22743 if [ $difference -ne $rc ]; then
22744 error "Ladvise test ${i}, bad lock count, returned " \
22745 "${rc}, actual ${difference}"
22749 #test 22 returns only success/failure
22751 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22753 if [ $rc -eq 255 ]; then
22754 error "Ladvise test${i} failed, ${rc}"
22757 run_test 255c "suite of ladvise lockahead tests"
22760 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22761 remote_mds_nodsh && skip "remote MDS with nodsh"
22762 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22763 changelog_users $SINGLEMDS | grep "^cl" &&
22764 skip "active changelog user"
22770 mdt_dev=$(facet_device $SINGLEMDS)
22773 changelog_register || error "changelog_register failed"
22776 mkdir_on_mdt -i$(($(facet_number $SINGLEMDS) - 1)) $DIR/$tdir
22778 changelog_clear 0 || error "changelog_clear failed"
22781 touch $DIR/$tdir/{1..10}
22784 stop $SINGLEMDS || error "Fail to stop MDT"
22787 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
22788 error "Fail to start MDT"
22790 #after mount new plainllog is used
22791 touch $DIR/$tdir/{11..19}
22792 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
22793 stack_trap "rm -f $tmpfile"
22794 cat_sl=$(do_facet $SINGLEMDS "sync; \
22795 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22796 llog_reader $tmpfile | grep -c type=1064553b")
22797 do_facet $SINGLEMDS llog_reader $tmpfile
22799 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
22801 changelog_clear 0 || error "changelog_clear failed"
22803 cat_sl=$(do_facet $SINGLEMDS "sync; \
22804 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22805 llog_reader $tmpfile | grep -c type=1064553b")
22807 if (( cat_sl == 2 )); then
22808 error "Empty plain llog was not deleted from changelog catalog"
22809 elif (( cat_sl != 1 )); then
22810 error "Active plain llog shouldn't be deleted from catalog"
22813 run_test 256 "Check llog delete for empty and not full state"
22816 remote_mds_nodsh && skip "remote MDS with nodsh"
22817 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
22818 skip "Need MDS version at least 2.8.55"
22820 test_mkdir $DIR/$tdir
22822 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
22823 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
22826 #define OBD_FAIL_MDS_XATTR_REP 0x161
22827 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
22828 local facet=mds$((mdtidx + 1))
22829 set_nodes_failloc $(facet_active_host $facet) 0x80000161
22830 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
22832 stop $facet || error "stop MDS failed"
22833 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
22834 error "start MDS fail"
22835 wait_recovery_complete $facet
22837 run_test 257 "xattr locks are not lost"
22839 # Verify we take the i_mutex when security requires it
22841 #define OBD_FAIL_IMUTEX_SEC 0x141c
22842 $LCTL set_param fail_loc=0x141c
22844 chmod u+s $DIR/$tfile
22845 chmod a+rwx $DIR/$tfile
22846 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22848 if [ $RC -ne 0 ]; then
22849 error "error, failed to take i_mutex, rc=$?"
22853 run_test 258a "verify i_mutex security behavior when suid attributes is set"
22855 # Verify we do NOT take the i_mutex in the normal case
22857 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
22858 $LCTL set_param fail_loc=0x141d
22861 chmod a+rw $DIR/$tfile
22862 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22864 if [ $RC -ne 0 ]; then
22865 error "error, took i_mutex unnecessarily, rc=$?"
22870 run_test 258b "verify i_mutex security behavior"
22873 local file=$DIR/$tfile
22877 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22879 stack_trap "rm -f $file" EXIT
22881 wait_delete_completed
22882 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22883 echo "before: $before"
22885 $LFS setstripe -i 0 -c 1 $file
22886 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
22888 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22889 echo "after write: $after"
22891 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
22892 do_facet ost1 $LCTL set_param fail_loc=0x2301
22894 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22895 echo "after truncate: $after"
22898 do_facet ost1 $LCTL set_param fail_loc=0
22899 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22901 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22902 echo "after restart: $after"
22903 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
22904 error "missing truncate?"
22908 run_test 259 "crash at delayed truncate"
22911 #define OBD_FAIL_MDC_CLOSE 0x806
22912 $LCTL set_param fail_loc=0x80000806
22916 run_test 260 "Check mdc_close fail"
22918 ### Data-on-MDT sanity tests ###
22920 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22921 skip "Need MDS version at least 2.10.55 for DoM"
22924 local dom=$DIR/$tdir/dom_file
22925 local tmp=$DIR/$tdir/tmp_file
22927 mkdir_on_mdt0 $DIR/$tdir
22929 # basic checks for DoM component creation
22930 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
22931 error "Can set MDT layout to non-first entry"
22933 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
22934 error "Can define multiple entries as MDT layout"
22936 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
22938 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
22939 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
22940 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
22942 local mdtidx=$($LFS getstripe -m $dom)
22943 local mdtname=MDT$(printf %04x $mdtidx)
22944 local facet=mds$((mdtidx + 1))
22945 local space_check=1
22947 # Skip free space checks with ZFS
22948 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
22952 local size_tmp=$((65536 * 3))
22953 local mdtfree1=$(do_facet $facet \
22954 lctl get_param -n osd*.*$mdtname.kbytesfree)
22956 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22957 # check also direct IO along write
22958 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
22959 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22961 cmp $tmp $dom || error "file data is different"
22962 [ $(stat -c%s $dom) == $size_tmp ] ||
22963 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22964 if [ $space_check == 1 ]; then
22965 local mdtfree2=$(do_facet $facet \
22966 lctl get_param -n osd*.*$mdtname.kbytesfree)
22968 # increase in usage from by $size_tmp
22969 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22970 error "MDT free space wrong after write: " \
22971 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22975 local size_dom=10000
22977 $TRUNCATE $dom $size_dom
22978 [ $(stat -c%s $dom) == $size_dom ] ||
22979 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
22980 if [ $space_check == 1 ]; then
22981 mdtfree1=$(do_facet $facet \
22982 lctl get_param -n osd*.*$mdtname.kbytesfree)
22983 # decrease in usage from $size_tmp to new $size_dom
22984 [ $(($mdtfree1 - $mdtfree2)) -ge \
22985 $(((size_tmp - size_dom) / 1024)) ] ||
22986 error "MDT free space is wrong after truncate: " \
22987 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
22993 size_dom=$((size_dom + size_tmp))
22994 [ $(stat -c%s $dom) == $size_dom ] ||
22995 error "bad size after append: $(stat -c%s $dom) != $size_dom"
22996 if [ $space_check == 1 ]; then
22997 mdtfree2=$(do_facet $facet \
22998 lctl get_param -n osd*.*$mdtname.kbytesfree)
22999 # increase in usage by $size_tmp from previous
23000 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
23001 error "MDT free space is wrong after append: " \
23002 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
23007 if [ $space_check == 1 ]; then
23008 mdtfree1=$(do_facet $facet \
23009 lctl get_param -n osd*.*$mdtname.kbytesfree)
23010 # decrease in usage by $size_dom from previous
23011 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
23012 error "MDT free space is wrong after removal: " \
23013 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
23016 # combined striping
23017 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
23018 error "Can't create DoM + OST striping"
23020 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
23021 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
23022 # check also direct IO along write
23023 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
23025 cmp $tmp $dom || error "file data is different"
23026 [ $(stat -c%s $dom) == $size_tmp ] ||
23027 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
23032 run_test 270a "DoM: basic functionality tests"
23035 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23036 skip "Need MDS version at least 2.10.55"
23038 local dom=$DIR/$tdir/dom_file
23039 local max_size=1048576
23041 mkdir -p $DIR/$tdir
23042 $LFS setstripe -E $max_size -L mdt $dom
23044 # truncate over the limit
23045 $TRUNCATE $dom $(($max_size + 1)) &&
23046 error "successful truncate over the maximum size"
23047 # write over the limit
23048 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
23049 error "successful write over the maximum size"
23050 # append over the limit
23051 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
23052 echo "12345" >> $dom && error "successful append over the maximum size"
23057 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
23060 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23061 skip "Need MDS version at least 2.10.55"
23063 mkdir -p $DIR/$tdir
23064 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23066 # check files inherit DoM EA
23067 touch $DIR/$tdir/first
23068 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
23069 error "bad pattern"
23070 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
23071 error "bad stripe count"
23072 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
23073 error "bad stripe size"
23075 # check directory inherits DoM EA and uses it as default
23076 mkdir $DIR/$tdir/subdir
23077 touch $DIR/$tdir/subdir/second
23078 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
23079 error "bad pattern in sub-directory"
23080 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
23081 error "bad stripe count in sub-directory"
23082 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
23083 error "bad stripe size in sub-directory"
23086 run_test 270c "DoM: DoM EA inheritance tests"
23089 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23090 skip "Need MDS version at least 2.10.55"
23092 mkdir -p $DIR/$tdir
23093 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23095 # inherit default DoM striping
23096 mkdir $DIR/$tdir/subdir
23097 touch $DIR/$tdir/subdir/f1
23099 # change default directory striping
23100 $LFS setstripe -c 1 $DIR/$tdir/subdir
23101 touch $DIR/$tdir/subdir/f2
23102 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
23103 error "wrong default striping in file 2"
23104 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
23105 error "bad pattern in file 2"
23108 run_test 270d "DoM: change striping from DoM to RAID0"
23111 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23112 skip "Need MDS version at least 2.10.55"
23114 mkdir -p $DIR/$tdir/dom
23115 mkdir -p $DIR/$tdir/norm
23118 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
23119 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
23121 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
23122 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
23124 # find DoM files by layout
23125 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
23126 [ $NUM -eq $DOMFILES ] ||
23127 error "lfs find -L: found $NUM, expected $DOMFILES"
23128 echo "Test 1: lfs find 20 DOM files by layout: OK"
23130 # there should be 1 dir with default DOM striping
23131 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
23133 error "lfs find -L: found $NUM, expected 1 dir"
23134 echo "Test 2: lfs find 1 DOM dir by layout: OK"
23136 # find DoM files by stripe size
23137 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
23138 [ $NUM -eq $DOMFILES ] ||
23139 error "lfs find -S: found $NUM, expected $DOMFILES"
23140 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
23142 # find files by stripe offset except DoM files
23143 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
23144 [ $NUM -eq $NORMFILES ] ||
23145 error "lfs find -i: found $NUM, expected $NORMFILES"
23146 echo "Test 5: lfs find no DOM files by stripe index: OK"
23149 run_test 270e "DoM: lfs find with DoM files test"
23152 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23153 skip "Need MDS version at least 2.10.55"
23155 local mdtname=${FSNAME}-MDT0000-mdtlov
23156 local dom=$DIR/$tdir/dom_file
23157 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
23158 lod.$mdtname.dom_stripesize)
23159 local dom_limit=131072
23161 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
23162 local dom_current=$(do_facet mds1 $LCTL get_param -n \
23163 lod.$mdtname.dom_stripesize)
23164 [ ${dom_limit} -eq ${dom_current} ] ||
23165 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
23167 $LFS mkdir -i 0 -c 1 $DIR/$tdir
23168 $LFS setstripe -d $DIR/$tdir
23169 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
23170 error "Can't set directory default striping"
23172 # exceed maximum stripe size
23173 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
23174 error "Can't create file with $((dom_limit * 2)) DoM stripe"
23175 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
23176 error "Able to create DoM component size more than LOD limit"
23178 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
23179 dom_current=$(do_facet mds1 $LCTL get_param -n \
23180 lod.$mdtname.dom_stripesize)
23181 [ 0 -eq ${dom_current} ] ||
23182 error "Can't set zero DoM stripe limit"
23185 # attempt to create DoM file on server with disabled DoM should
23186 # remove DoM entry from layout and be succeed
23187 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
23188 error "Can't create DoM file (DoM is disabled)"
23189 [ $($LFS getstripe -L $dom) == "mdt" ] &&
23190 error "File has DoM component while DoM is disabled"
23193 # attempt to create DoM file with only DoM stripe should return error
23194 $LFS setstripe -E $dom_limit -L mdt $dom &&
23195 error "Able to create DoM-only file while DoM is disabled"
23197 # too low values to be aligned with smallest stripe size 64K
23198 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
23199 dom_current=$(do_facet mds1 $LCTL get_param -n \
23200 lod.$mdtname.dom_stripesize)
23201 [ 30000 -eq ${dom_current} ] &&
23202 error "Can set too small DoM stripe limit"
23204 # 64K is a minimal stripe size in Lustre, expect limit of that size
23205 [ 65536 -eq ${dom_current} ] ||
23206 error "Limit is not set to 64K but ${dom_current}"
23208 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
23209 dom_current=$(do_facet mds1 $LCTL get_param -n \
23210 lod.$mdtname.dom_stripesize)
23212 [ 2147483648 -eq ${dom_current} ] &&
23213 error "Can set too large DoM stripe limit"
23215 do_facet mds1 $LCTL set_param -n \
23216 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
23217 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
23218 error "Can't create DoM component size after limit change"
23219 do_facet mds1 $LCTL set_param -n \
23220 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
23221 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
23222 error "Can't create DoM file after limit decrease"
23223 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
23224 error "Can create big DoM component after limit decrease"
23225 touch ${dom}_def ||
23226 error "Can't create file with old default layout"
23228 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
23231 run_test 270f "DoM: maximum DoM stripe size checks"
23234 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
23235 skip "Need MDS version at least 2.13.52"
23236 local dom=$DIR/$tdir/$tfile
23238 $LFS mkdir -i 0 -c 1 $DIR/$tdir
23239 local lodname=${FSNAME}-MDT0000-mdtlov
23241 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
23242 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
23243 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
23244 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
23246 local dom_limit=1024
23247 local dom_threshold="50%"
23249 $LFS setstripe -d $DIR/$tdir
23250 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
23251 error "Can't set directory default striping"
23253 do_facet mds1 $LCTL set_param -n \
23254 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
23255 # set 0 threshold and create DOM file to change tunable stripesize
23256 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
23257 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
23258 error "Failed to create $dom file"
23259 # now tunable dom_cur_stripesize should reach maximum
23260 local dom_current=$(do_facet mds1 $LCTL get_param -n \
23261 lod.${lodname}.dom_stripesize_cur_kb)
23262 [[ $dom_current == $dom_limit ]] ||
23263 error "Current DOM stripesize is not maximum"
23266 # set threshold for further tests
23267 do_facet mds1 $LCTL set_param -n \
23268 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
23269 echo "DOM threshold is $dom_threshold free space"
23272 # Spoof bfree to exceed threshold
23273 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
23274 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
23275 for spfree in 40 20 0 15 30 55; do
23276 do_facet mds1 $LCTL set_param -n fail_val=$spfree
23277 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
23278 error "Failed to create $dom file"
23279 dom_def=$(do_facet mds1 $LCTL get_param -n \
23280 lod.${lodname}.dom_stripesize_cur_kb)
23281 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
23282 [[ $dom_def != $dom_current ]] ||
23283 error "Default stripe size was not changed"
23284 if (( spfree > 0 )) ; then
23285 dom_set=$($LFS getstripe -S $dom)
23286 (( dom_set == dom_def * 1024 )) ||
23287 error "DOM component size is still old"
23289 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
23290 error "DoM component is set with no free space"
23293 dom_current=$dom_def
23296 run_test 270g "DoM: default DoM stripe size depends on free space"
23299 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
23300 skip "Need MDS version at least 2.13.53"
23302 local mdtname=${FSNAME}-MDT0000-mdtlov
23303 local dom=$DIR/$tdir/$tfile
23304 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
23306 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
23307 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
23309 $LFS mkdir -i 0 -c 1 $DIR/$tdir
23310 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
23311 error "can't create OST file"
23312 # mirrored file with DOM entry in the second mirror
23313 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
23314 error "can't create mirror with DoM component"
23316 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
23318 # DOM component in the middle and has other enries in the same mirror,
23319 # should succeed but lost DoM component
23320 $LFS setstripe --copy=${dom}_1 $dom ||
23321 error "Can't create file from OST|DOM mirror layout"
23322 # check new file has no DoM layout after all
23323 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
23324 error "File has DoM component while DoM is disabled"
23326 run_test 270h "DoM: DoM stripe removal when disabled on server"
23329 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
23330 skip "Need MDS version at least 2.14.54"
23333 # DoM with plain layout
23334 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir &&
23335 error "default plain layout with DoM must fail"
23336 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir/$tfile &&
23337 error "setstripe plain file layout with DoM must fail"
23338 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir &&
23339 error "default DoM layout with bad striping must fail"
23340 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir/$tfile &&
23341 error "setstripe to DoM layout with bad striping must fail"
23344 run_test 270i "DoM: setting invalid DoM striping should fail"
23347 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23348 skip "Need MDS version at least 2.10.55"
23350 local dom=$DIR/$tdir/dom
23352 mkdir -p $DIR/$tdir
23354 $LFS setstripe -E 1024K -L mdt $dom
23356 lctl set_param -n mdc.*.stats=clear
23357 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
23358 cat $dom > /dev/null
23359 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
23360 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
23364 run_test 271a "DoM: data is cached for read after write"
23367 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23368 skip "Need MDS version at least 2.10.55"
23370 local dom=$DIR/$tdir/dom
23372 mkdir -p $DIR/$tdir
23374 $LFS setstripe -E 1024K -L mdt -E EOF $dom
23376 lctl set_param -n mdc.*.stats=clear
23377 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
23378 cancel_lru_locks mdc
23379 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
23380 # second stat to check size is cached on client
23381 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
23382 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
23383 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
23386 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
23389 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23390 skip "Need MDS version at least 2.10.55"
23392 local dom=$DIR/$tdir/dom
23394 mkdir -p $DIR/$tdir
23396 $LFS setstripe -E 1024K -L mdt -E EOF $dom
23398 lctl set_param -n mdc.*.stats=clear
23399 lctl set_param -n osc.*.stats=clear
23400 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
23401 cancel_lru_locks mdc
23402 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
23403 # second stat to check size is cached on client
23404 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
23405 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
23406 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
23407 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
23408 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
23411 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
23417 local mdt=MDT$(printf %04x $mdtidx)
23419 if [ -z $param ]; then
23420 lctl get_param -n mdc.*$mdt*.stats
23422 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
23427 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23428 skip "Need MDS version at least 2.10.55"
23430 local dom=$DIR/$tdir/dom
23432 mkdir -p $DIR/$tdir
23434 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23436 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
23437 local facet=mds$((mdtidx + 1))
23439 cancel_lru_locks mdc
23440 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
23441 createmany -o $dom 1000
23442 lctl set_param -n mdc.*.stats=clear
23443 smalliomany -w $dom 1000 200
23444 get_mdc_stats $mdtidx
23445 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
23446 # Each file has 1 open, 1 IO enqueues, total 2000
23447 # but now we have also +1 getxattr for security.capability, total 3000
23448 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
23449 unlinkmany $dom 1000
23451 cancel_lru_locks mdc
23452 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
23453 createmany -o $dom 1000
23454 lctl set_param -n mdc.*.stats=clear
23455 smalliomany -w $dom 1000 200
23456 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
23457 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
23458 # for OPEN and IO lock.
23459 [ $((enq - enq_2)) -ge 1000 ] ||
23460 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
23461 unlinkmany $dom 1000
23464 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
23466 cleanup_271def_tests() {
23472 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
23473 skip "Need MDS version at least 2.10.57"
23475 local dom=$DIR/$tdir/dom
23476 local tmp=$TMP/$tfile
23477 trap "cleanup_271def_tests $tmp" EXIT
23479 mkdir -p $DIR/$tdir
23481 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23483 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
23485 cancel_lru_locks mdc
23486 dd if=/dev/urandom of=$tmp bs=1000 count=1
23487 dd if=$tmp of=$dom bs=1000 count=1
23488 cancel_lru_locks mdc
23490 cat /etc/hosts >> $tmp
23491 lctl set_param -n mdc.*.stats=clear
23493 # append data to the same file it should update local page
23494 echo "Append to the same page"
23495 cat /etc/hosts >> $dom
23496 local num=$(get_mdc_stats $mdtidx ost_read)
23497 local ra=$(get_mdc_stats $mdtidx req_active)
23498 local rw=$(get_mdc_stats $mdtidx req_waittime)
23500 [ -z $num ] || error "$num READ RPC occured"
23501 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23505 cmp $tmp $dom || error "file miscompare"
23507 cancel_lru_locks mdc
23508 lctl set_param -n mdc.*.stats=clear
23510 echo "Open and read file"
23511 cat $dom > /dev/null
23512 local num=$(get_mdc_stats $mdtidx ost_read)
23513 local ra=$(get_mdc_stats $mdtidx req_active)
23514 local rw=$(get_mdc_stats $mdtidx req_waittime)
23516 [ -z $num ] || error "$num READ RPC occured"
23517 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23521 cmp $tmp $dom || error "file miscompare"
23525 run_test 271d "DoM: read on open (1K file in reply buffer)"
23528 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
23529 skip "Need MDS version at least 2.10.57"
23531 local dom=$DIR/$tdir/dom
23532 local tmp=$TMP/$tfile
23533 trap "cleanup_271def_tests $tmp" EXIT
23535 mkdir -p $DIR/$tdir
23537 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23539 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
23541 cancel_lru_locks mdc
23542 dd if=/dev/urandom of=$tmp bs=265000 count=1
23543 dd if=$tmp of=$dom bs=265000 count=1
23544 cancel_lru_locks mdc
23545 cat /etc/hosts >> $tmp
23546 lctl set_param -n mdc.*.stats=clear
23548 echo "Append to the same page"
23549 cat /etc/hosts >> $dom
23550 local num=$(get_mdc_stats $mdtidx ost_read)
23551 local ra=$(get_mdc_stats $mdtidx req_active)
23552 local rw=$(get_mdc_stats $mdtidx req_waittime)
23554 [ -z $num ] || error "$num READ RPC occured"
23555 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23559 cmp $tmp $dom || error "file miscompare"
23561 cancel_lru_locks mdc
23562 lctl set_param -n mdc.*.stats=clear
23564 echo "Open and read file"
23565 cat $dom > /dev/null
23566 local num=$(get_mdc_stats $mdtidx ost_read)
23567 local ra=$(get_mdc_stats $mdtidx req_active)
23568 local rw=$(get_mdc_stats $mdtidx req_waittime)
23570 [ -z $num ] && num=0
23571 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
23572 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23576 cmp $tmp $dom || error "file miscompare"
23580 run_test 271f "DoM: read on open (200K file and read tail)"
23583 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
23584 skip "Skipping due to old client or server version"
23586 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
23588 $CHECKSTAT -t file $DIR1/$tfile
23590 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
23593 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
23594 $LCTL set_param fail_loc=0x80000314
23595 rm $DIR1/$tfile || error "Unlink fails"
23597 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
23598 [ $RC -eq 0 ] || error "Failed write to stale object"
23600 run_test 271g "Discard DoM data vs client flush race"
23603 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23604 skip "Need MDS version at least 2.11.50"
23606 local dom=$DIR/$tdir/dom
23607 mkdir -p $DIR/$tdir
23609 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
23610 dd if=/dev/urandom of=$dom bs=512K count=1 ||
23611 error "failed to write data into $dom"
23612 local old_md5=$(md5sum $dom)
23614 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
23615 error "failed to migrate to the same DoM component"
23617 local new_md5=$(md5sum $dom)
23619 [ "$old_md5" == "$new_md5" ] ||
23620 error "md5sum differ: $old_md5, $new_md5"
23622 [ $($LFS getstripe -c $dom) -eq 2 ] ||
23623 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
23625 run_test 272a "DoM migration: new layout with the same DOM component"
23628 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23629 skip "Need MDS version at least 2.11.50"
23631 local dom=$DIR/$tdir/dom
23632 mkdir -p $DIR/$tdir
23633 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23635 local mdtidx=$($LFS getstripe -m $dom)
23636 local mdtname=MDT$(printf %04x $mdtidx)
23637 local facet=mds$((mdtidx + 1))
23639 local mdtfree1=$(do_facet $facet \
23640 lctl get_param -n osd*.*$mdtname.kbytesfree)
23641 dd if=/dev/urandom of=$dom bs=2M count=1 ||
23642 error "failed to write data into $dom"
23643 local old_md5=$(md5sum $dom)
23644 cancel_lru_locks mdc
23645 local mdtfree1=$(do_facet $facet \
23646 lctl get_param -n osd*.*$mdtname.kbytesfree)
23648 $LFS migrate -c2 $dom ||
23649 error "failed to migrate to the new composite layout"
23650 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
23651 error "MDT stripe was not removed"
23653 cancel_lru_locks mdc
23654 local new_md5=$(md5sum $dom)
23655 [ "$old_md5" == "$new_md5" ] ||
23656 error "$old_md5 != $new_md5"
23658 # Skip free space checks with ZFS
23659 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23660 local mdtfree2=$(do_facet $facet \
23661 lctl get_param -n osd*.*$mdtname.kbytesfree)
23662 [ $mdtfree2 -gt $mdtfree1 ] ||
23663 error "MDT space is not freed after migration"
23667 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
23670 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23671 skip "Need MDS version at least 2.11.50"
23673 local dom=$DIR/$tdir/$tfile
23674 mkdir -p $DIR/$tdir
23675 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23677 local mdtidx=$($LFS getstripe -m $dom)
23678 local mdtname=MDT$(printf %04x $mdtidx)
23679 local facet=mds$((mdtidx + 1))
23681 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23682 error "failed to write data into $dom"
23683 local old_md5=$(md5sum $dom)
23684 cancel_lru_locks mdc
23685 local mdtfree1=$(do_facet $facet \
23686 lctl get_param -n osd*.*$mdtname.kbytesfree)
23688 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
23689 error "failed to migrate to the new composite layout"
23690 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
23691 error "MDT stripe was not removed"
23693 cancel_lru_locks mdc
23694 local new_md5=$(md5sum $dom)
23695 [ "$old_md5" == "$new_md5" ] ||
23696 error "$old_md5 != $new_md5"
23698 # Skip free space checks with ZFS
23699 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23700 local mdtfree2=$(do_facet $facet \
23701 lctl get_param -n osd*.*$mdtname.kbytesfree)
23702 [ $mdtfree2 -gt $mdtfree1 ] ||
23703 error "MDS space is not freed after migration"
23707 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
23710 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23711 skip "Need MDS version at least 2.12.55"
23713 local dom=$DIR/$tdir/$tfile
23714 mkdir -p $DIR/$tdir
23715 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23717 local mdtidx=$($LFS getstripe -m $dom)
23718 local mdtname=MDT$(printf %04x $mdtidx)
23719 local facet=mds$((mdtidx + 1))
23721 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23722 error "failed to write data into $dom"
23723 local old_md5=$(md5sum $dom)
23724 cancel_lru_locks mdc
23725 local mdtfree1=$(do_facet $facet \
23726 lctl get_param -n osd*.*$mdtname.kbytesfree)
23728 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
23729 error "failed mirroring to the new composite layout"
23730 $LFS mirror resync $dom ||
23731 error "failed mirror resync"
23732 $LFS mirror split --mirror-id 1 -d $dom ||
23733 error "failed mirror split"
23735 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
23736 error "MDT stripe was not removed"
23738 cancel_lru_locks mdc
23739 local new_md5=$(md5sum $dom)
23740 [ "$old_md5" == "$new_md5" ] ||
23741 error "$old_md5 != $new_md5"
23743 # Skip free space checks with ZFS
23744 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23745 local mdtfree2=$(do_facet $facet \
23746 lctl get_param -n osd*.*$mdtname.kbytesfree)
23747 [ $mdtfree2 -gt $mdtfree1 ] ||
23748 error "MDS space is not freed after DOM mirror deletion"
23752 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
23755 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23756 skip "Need MDS version at least 2.12.55"
23758 local dom=$DIR/$tdir/$tfile
23759 mkdir -p $DIR/$tdir
23760 $LFS setstripe -c 2 $dom
23762 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23763 error "failed to write data into $dom"
23764 local old_md5=$(md5sum $dom)
23767 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
23768 error "failed mirroring to the DOM layout"
23769 $LFS mirror resync $dom ||
23770 error "failed mirror resync"
23771 $LFS mirror split --mirror-id 1 -d $dom ||
23772 error "failed mirror split"
23774 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23775 error "MDT stripe wasn't set"
23778 local new_md5=$(md5sum $dom)
23779 [ "$old_md5" == "$new_md5" ] ||
23780 error "$old_md5 != $new_md5"
23784 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
23787 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23788 skip "Need MDS version at least 2.12.55"
23790 local dom=$DIR/$tdir/$tfile
23791 mkdir -p $DIR/$tdir
23792 $LFS setstripe -c 2 $dom
23794 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23795 error "failed to write data into $dom"
23796 local old_md5=$(md5sum $dom)
23799 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
23800 error "failed migrating to the DOM file"
23802 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23803 error "MDT stripe wasn't set"
23806 local new_md5=$(md5sum $dom)
23807 [ "$old_md5" != "$new_md5" ] &&
23808 error "$old_md5 != $new_md5"
23812 run_test 272f "DoM migration: OST-striped file to DOM file"
23815 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23816 skip "Need MDS version at least 2.11.50"
23818 # Layout swap cannot be done if either file has DOM component,
23819 # this will never be supported, migration should be used instead
23821 local dom=$DIR/$tdir/$tfile
23822 mkdir -p $DIR/$tdir
23824 $LFS setstripe -c2 ${dom}_plain
23825 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
23826 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
23827 error "can swap layout with DoM component"
23828 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
23829 error "can swap layout with DoM component"
23831 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
23832 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
23833 error "can swap layout with DoM component"
23834 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
23835 error "can swap layout with DoM component"
23838 run_test 273a "DoM: layout swapping should fail with DOM"
23841 mkdir -p $DIR/$tdir
23842 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
23844 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
23845 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
23847 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
23849 run_test 273b "DoM: race writeback and object destroy"
23852 remote_ost_nodsh && skip "remote OST with nodsh"
23853 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
23854 skip "Need OST version >= 2.10.57"
23856 local file=$DIR/$tfile
23859 oss=$(comma_list $(osts_nodes))
23861 dd if=/dev/urandom of=$file bs=1M count=2 ||
23862 error "failed to create a file"
23863 cancel_lru_locks osc
23866 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23867 error "failed to read a file"
23869 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
23870 $LCTL set_param fail_loc=0x8000031f
23872 cancel_lru_locks osc &
23875 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
23876 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
23877 #IO takes another lock, but matches the PENDING one
23878 #and places it to the IO RPC
23879 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23880 error "failed to read a file with PENDING lock"
23882 run_test 275 "Read on a canceled duplicate lock"
23885 remote_ost_nodsh && skip "remote OST with nodsh"
23888 do_facet ost1 "(while true; do \
23889 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
23890 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
23893 for LOOP in $(seq 20); do
23895 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
23898 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
23899 rm $TMP/sanity_276_pid"
23901 run_test 276 "Race between mount and obd_statfs"
23904 $LCTL set_param ldlm.namespaces.*.lru_size=0
23905 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23906 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23907 grep ^used_mb | awk '{print $2}')
23908 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
23909 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
23910 oflag=direct conv=notrunc
23911 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23912 grep ^used_mb | awk '{print $2}')
23913 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
23915 run_test 277 "Direct IO shall drop page cache"
23918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
23919 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23920 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
23921 skip "needs the same host for mdt1 mdt2" && return
23926 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
23927 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
23933 echo "Starting MDTs"
23934 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
23936 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
23938 do_facet mds2 $LCTL set_param fail_loc=0
23940 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
23941 wait_recovery_complete mds2
23943 run_test 278 "Race starting MDS between MDTs stop/start"
23946 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
23947 skip "Need MGS version at least 2.13.52"
23948 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23949 combined_mgs_mds || skip "needs combined MGS/MDT"
23951 umount_client $MOUNT
23952 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
23953 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
23955 mount_client $MOUNT &
23957 stop mgs || error "stop mgs failed"
23958 #for a race mgs would crash
23959 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
23960 # make sure we unmount client before remounting
23962 umount_client $MOUNT
23963 mount_client $MOUNT || error "mount client failed"
23965 run_test 280 "Race between MGS umount and client llog processing"
23967 cleanup_test_300() {
23971 test_striped_dir() {
23976 mkdir -p $DIR/$tdir
23978 SAVE_UMASK=$(umask)
23979 trap cleanup_test_300 RETURN EXIT
23981 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
23982 $DIR/$tdir/striped_dir ||
23983 error "set striped dir error"
23985 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
23986 [ "$mode" = "755" ] || error "expect 755 got $mode"
23988 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
23989 error "getdirstripe failed"
23990 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
23991 if [ "$stripe_count" != "2" ]; then
23992 error "1:stripe_count is $stripe_count, expect 2"
23994 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
23995 if [ "$stripe_count" != "2" ]; then
23996 error "2:stripe_count is $stripe_count, expect 2"
23999 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
24000 if [ "$stripe_index" != "$mdt_index" ]; then
24001 error "stripe_index is $stripe_index, expect $mdt_index"
24004 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
24005 error "nlink error after create striped dir"
24007 mkdir $DIR/$tdir/striped_dir/a
24008 mkdir $DIR/$tdir/striped_dir/b
24010 stat $DIR/$tdir/striped_dir/a ||
24011 error "create dir under striped dir failed"
24012 stat $DIR/$tdir/striped_dir/b ||
24013 error "create dir under striped dir failed"
24015 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
24016 error "nlink error after mkdir"
24018 rmdir $DIR/$tdir/striped_dir/a
24019 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
24020 error "nlink error after rmdir"
24022 rmdir $DIR/$tdir/striped_dir/b
24023 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
24024 error "nlink error after rmdir"
24026 chattr +i $DIR/$tdir/striped_dir
24027 createmany -o $DIR/$tdir/striped_dir/f 10 &&
24028 error "immutable flags not working under striped dir!"
24029 chattr -i $DIR/$tdir/striped_dir
24031 rmdir $DIR/$tdir/striped_dir ||
24032 error "rmdir striped dir error"
24040 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
24041 skip "skipped for lustre < 2.7.0"
24042 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24043 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24045 test_striped_dir 0 || error "failed on striped dir on MDT0"
24046 test_striped_dir 1 || error "failed on striped dir on MDT0"
24048 run_test 300a "basic striped dir sanity test"
24051 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
24052 skip "skipped for lustre < 2.7.0"
24053 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24054 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24061 test_mkdir $DIR/$tdir || error "mkdir fail"
24062 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
24063 error "set striped dir error"
24064 for i in {0..9}; do
24065 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
24067 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
24068 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
24069 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
24071 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
24072 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
24073 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
24077 run_test 300b "check ctime/mtime for striped dir"
24080 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
24081 skip "skipped for lustre < 2.7.0"
24082 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24083 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24087 mkdir_on_mdt0 $DIR/$tdir
24088 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
24089 error "set striped dir error"
24091 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
24092 error "chown striped dir failed"
24094 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
24095 error "create 5k files failed"
24097 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
24099 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
24103 run_test 300c "chown && check ls under striped directory"
24106 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
24107 skip "skipped for lustre < 2.7.0"
24108 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24109 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24114 mkdir -p $DIR/$tdir
24115 $LFS setstripe -c 2 $DIR/$tdir
24117 #local striped directory
24118 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
24119 error "set striped dir error"
24120 #look at the directories for debug purposes
24122 $LFS getdirstripe $DIR/$tdir
24123 ls -l $DIR/$tdir/striped_dir
24124 $LFS getdirstripe $DIR/$tdir/striped_dir
24125 createmany -o $DIR/$tdir/striped_dir/f 10 ||
24126 error "create 10 files failed"
24128 #remote striped directory
24129 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
24130 error "set striped dir error"
24131 #look at the directories for debug purposes
24133 $LFS getdirstripe $DIR/$tdir
24134 ls -l $DIR/$tdir/remote_striped_dir
24135 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
24136 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
24137 error "create 10 files failed"
24139 for file in $(find $DIR/$tdir); do
24140 stripe_count=$($LFS getstripe -c $file)
24141 [ $stripe_count -eq 2 ] ||
24142 error "wrong stripe $stripe_count for $file"
24147 run_test 300d "check default stripe under striped directory"
24150 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24151 skip "Need MDS version at least 2.7.55"
24152 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24153 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24158 mkdir -p $DIR/$tdir
24160 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
24161 error "set striped dir error"
24163 touch $DIR/$tdir/striped_dir/a
24164 touch $DIR/$tdir/striped_dir/b
24165 touch $DIR/$tdir/striped_dir/c
24167 mkdir $DIR/$tdir/striped_dir/dir_a
24168 mkdir $DIR/$tdir/striped_dir/dir_b
24169 mkdir $DIR/$tdir/striped_dir/dir_c
24171 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
24172 error "set striped adir under striped dir error"
24174 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
24175 error "set striped bdir under striped dir error"
24177 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
24178 error "set striped cdir under striped dir error"
24180 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
24181 error "rename dir under striped dir fails"
24183 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
24184 error "rename dir under different stripes fails"
24186 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
24187 error "rename file under striped dir should succeed"
24189 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
24190 error "rename dir under striped dir should succeed"
24194 run_test 300e "check rename under striped directory"
24197 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24198 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24199 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24200 skip "Need MDS version at least 2.7.55"
24206 mkdir -p $DIR/$tdir
24208 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
24209 error "set striped dir error"
24211 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
24212 error "set striped dir error"
24214 touch $DIR/$tdir/striped_dir/a
24215 mkdir $DIR/$tdir/striped_dir/dir_a
24216 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
24217 error "create striped dir under striped dir fails"
24219 touch $DIR/$tdir/striped_dir1/b
24220 mkdir $DIR/$tdir/striped_dir1/dir_b
24221 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
24222 error "create striped dir under striped dir fails"
24224 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
24225 error "rename dir under different striped dir should fail"
24227 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
24228 error "rename striped dir under diff striped dir should fail"
24230 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
24231 error "rename file under diff striped dirs fails"
24235 run_test 300f "check rename cross striped directory"
24237 test_300_check_default_striped_dir()
24240 local default_count=$2
24241 local default_index=$3
24244 local dir_stripe_index
24247 echo "checking $dirname $default_count $default_index"
24248 $LFS setdirstripe -D -c $default_count -i $default_index \
24249 -H all_char $DIR/$tdir/$dirname ||
24250 error "set default stripe on striped dir error"
24251 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
24252 [ $stripe_count -eq $default_count ] ||
24253 error "expect $default_count get $stripe_count for $dirname"
24255 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
24256 [ $stripe_index -eq $default_index ] ||
24257 error "expect $default_index get $stripe_index for $dirname"
24259 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
24260 error "create dirs failed"
24262 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
24263 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
24264 for dir in $(find $DIR/$tdir/$dirname/*); do
24265 stripe_count=$($LFS getdirstripe -c $dir)
24266 (( $stripe_count == $default_count )) ||
24267 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
24268 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
24269 error "stripe count $default_count != $stripe_count for $dir"
24271 stripe_index=$($LFS getdirstripe -i $dir)
24272 [ $default_index -eq -1 ] ||
24273 [ $stripe_index -eq $default_index ] ||
24274 error "$stripe_index != $default_index for $dir"
24276 #check default stripe
24277 stripe_count=$($LFS getdirstripe -D -c $dir)
24278 [ $stripe_count -eq $default_count ] ||
24279 error "default count $default_count != $stripe_count for $dir"
24281 stripe_index=$($LFS getdirstripe -D -i $dir)
24282 [ $stripe_index -eq $default_index ] ||
24283 error "default index $default_index != $stripe_index for $dir"
24285 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
24289 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24290 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24291 skip "Need MDS version at least 2.7.55"
24297 mkdir_on_mdt0 $DIR/$tdir
24298 mkdir $DIR/$tdir/normal_dir
24300 #Checking when client cache stripe index
24301 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
24302 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
24303 error "create striped_dir failed"
24305 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
24306 error "create dir0 fails"
24307 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
24308 [ $stripe_index -eq 0 ] ||
24309 error "dir0 expect index 0 got $stripe_index"
24311 mkdir $DIR/$tdir/striped_dir/dir1 ||
24312 error "create dir1 fails"
24313 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
24314 [ $stripe_index -eq 1 ] ||
24315 error "dir1 expect index 1 got $stripe_index"
24317 #check default stripe count/stripe index
24318 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
24319 test_300_check_default_striped_dir normal_dir 1 0
24320 test_300_check_default_striped_dir normal_dir -1 1
24321 test_300_check_default_striped_dir normal_dir 2 -1
24323 #delete default stripe information
24324 echo "delete default stripeEA"
24325 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
24326 error "set default stripe on striped dir error"
24328 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
24329 for dir in $(find $DIR/$tdir/normal_dir/*); do
24330 stripe_count=$($LFS getdirstripe -c $dir)
24331 [ $stripe_count -eq 0 ] ||
24332 error "expect 1 get $stripe_count for $dir"
24335 run_test 300g "check default striped directory for normal directory"
24338 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24339 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24340 skip "Need MDS version at least 2.7.55"
24346 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
24347 error "set striped dir error"
24349 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
24350 test_300_check_default_striped_dir striped_dir 1 0
24351 test_300_check_default_striped_dir striped_dir -1 1
24352 test_300_check_default_striped_dir striped_dir 2 -1
24354 #delete default stripe information
24355 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
24356 error "set default stripe on striped dir error"
24358 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
24359 for dir in $(find $DIR/$tdir/striped_dir/*); do
24360 stripe_count=$($LFS getdirstripe -c $dir)
24361 [ $stripe_count -eq 0 ] ||
24362 error "expect 1 get $stripe_count for $dir"
24365 run_test 300h "check default striped directory for striped directory"
24368 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
24369 (( $MDSCOUNT >= 2 )) || skip_env "needs >= 2 MDTs"
24370 (( $MDS1_VERSION >= $(version_code 2.7.55) )) ||
24371 skip "Need MDS version at least 2.7.55"
24378 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
24379 error "set striped dir error"
24381 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
24382 error "create files under striped dir failed"
24384 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
24385 error "set striped hashdir error"
24387 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
24388 error "create dir0 under hash dir failed"
24389 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
24390 error "create dir1 under hash dir failed"
24391 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
24392 error "create dir2 under hash dir failed"
24394 # unfortunately, we need to umount to clear dir layout cache for now
24395 # once we fully implement dir layout, we can drop this
24396 umount_client $MOUNT || error "umount failed"
24397 mount_client $MOUNT || error "mount failed"
24399 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
24400 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
24401 (( $dircnt == 2 )) || error "lfs find striped dir got $dircnt != 2"
24403 if (( $MDS1_VERSION > $(version_code 2.15.0) )); then
24404 $LFS mkdir -i0 -c$MDSCOUNT -H crush2 $DIR/$tdir/hashdir/d3 ||
24405 error "create crush2 dir $tdir/hashdir/d3 failed"
24406 $LFS find -H crush2 $DIR/$tdir/hashdir
24407 dircnt=$($LFS find -H crush2 $DIR/$tdir/hashdir | wc -l)
24408 (( $dircnt == 1 )) || error "find crush2 dir got $dircnt != 1"
24410 # mkdir with an invalid hash type (hash=fail_val) from client
24411 # should be replaced on MDS with a valid (default) hash type
24412 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
24413 $LCTL set_param fail_loc=0x1901 fail_val=99
24414 $LFS mkdir -c2 $DIR/$tdir/hashdir/d99
24416 local hash=$($LFS getdirstripe -H $DIR/$tdir/hashdir/d99)
24417 local expect=$(do_facet mds1 \
24418 $LCTL get_param -n lod.$FSNAME-MDT0000-mdtlov.mdt_hash)
24419 [[ $hash == $expect ]] ||
24420 error "d99 hash '$hash' != expected hash '$expect'"
24423 #set the stripe to be unknown hash type on read
24424 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
24425 $LCTL set_param fail_loc=0x1901 fail_val=99
24426 for ((i = 0; i < 10; i++)); do
24427 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
24428 error "stat f-$i failed"
24429 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
24432 touch $DIR/$tdir/striped_dir/f0 &&
24433 error "create under striped dir with unknown hash should fail"
24435 $LCTL set_param fail_loc=0
24437 umount_client $MOUNT || error "umount failed"
24438 mount_client $MOUNT || error "mount failed"
24442 run_test 300i "client handle unknown hash type striped directory"
24445 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24446 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24447 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24448 skip "Need MDS version at least 2.7.55"
24455 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
24456 $LCTL set_param fail_loc=0x1702
24457 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
24458 error "set striped dir error"
24460 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
24461 error "create files under striped dir failed"
24463 $LCTL set_param fail_loc=0
24465 rm -rf $DIR/$tdir || error "unlink striped dir fails"
24469 run_test 300j "test large update record"
24472 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24473 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24474 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24475 skip "Need MDS version at least 2.7.55"
24477 # this test needs a huge transaction
24479 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24480 osd*.$FSNAME-MDT0000.kbytestotal")
24481 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
24488 #define OBD_FAIL_LARGE_STRIPE 0x1703
24489 $LCTL set_param fail_loc=0x1703
24490 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
24491 error "set striped dir error"
24492 $LCTL set_param fail_loc=0
24494 $LFS getdirstripe $DIR/$tdir/striped_dir ||
24495 error "getstripeddir fails"
24496 rm -rf $DIR/$tdir/striped_dir ||
24497 error "unlink striped dir fails"
24501 run_test 300k "test large striped directory"
24504 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24505 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24506 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24507 skip "Need MDS version at least 2.7.55"
24511 test_mkdir -p $DIR/$tdir/striped_dir
24512 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
24513 error "chown $RUNAS_ID failed"
24514 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
24515 error "set default striped dir failed"
24517 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
24518 $LCTL set_param fail_loc=0x80000158
24519 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
24521 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
24522 [ $stripe_index -eq 1 ] ||
24523 error "expect 1 get $stripe_index for $dir"
24525 run_test 300l "non-root user to create dir under striped dir with stale layout"
24528 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24529 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
24530 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24531 skip "Need MDS version at least 2.7.55"
24533 mkdir -p $DIR/$tdir/striped_dir
24534 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
24535 error "set default stripes dir error"
24537 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
24539 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
24540 [ $stripe_count -eq 0 ] ||
24541 error "expect 0 get $stripe_count for a"
24543 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
24544 error "set default stripes dir error"
24546 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
24548 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
24549 [ $stripe_count -eq 0 ] ||
24550 error "expect 0 get $stripe_count for b"
24552 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
24553 error "set default stripes dir error"
24555 mkdir $DIR/$tdir/striped_dir/c &&
24556 error "default stripe_index is invalid, mkdir c should fails"
24558 rm -rf $DIR/$tdir || error "rmdir fails"
24560 run_test 300m "setstriped directory on single MDT FS"
24563 local list=$(comma_list $(mdts_nodes))
24566 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24570 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24571 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24572 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24573 skip "Need MDS version at least 2.7.55"
24574 remote_mds_nodsh && skip "remote MDS with nodsh"
24577 local list=$(comma_list $(mdts_nodes))
24579 trap cleanup_300n RETURN EXIT
24580 mkdir -p $DIR/$tdir
24581 chmod 777 $DIR/$tdir
24582 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
24583 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
24584 error "create striped dir succeeds with gid=0"
24586 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
24587 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
24588 error "create striped dir fails with gid=-1"
24590 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24591 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
24592 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
24593 error "set default striped dir succeeds with gid=0"
24596 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
24597 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
24598 error "set default striped dir fails with gid=-1"
24601 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24602 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
24603 error "create test_dir fails"
24604 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
24605 error "create test_dir1 fails"
24606 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
24607 error "create test_dir2 fails"
24610 run_test 300n "non-root user to create dir under striped dir with default EA"
24613 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24614 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24615 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24616 skip "Need MDS version at least 2.7.55"
24621 mkdir -p $DIR/$tdir
24623 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
24624 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
24625 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
24626 skip "not enough free inodes $numfree1 $numfree2"
24629 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
24630 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
24631 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
24632 skip "not enough free space $numfree1 $numfree2"
24635 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
24636 error "setdirstripe fails"
24638 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
24639 error "create dirs fails"
24641 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
24642 ls $DIR/$tdir/striped_dir > /dev/null ||
24643 error "ls striped dir fails"
24644 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
24645 error "unlink big striped dir fails"
24647 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
24650 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24651 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24652 remote_mds_nodsh && skip "remote MDS with nodsh"
24654 mkdir_on_mdt0 $DIR/$tdir
24656 #define OBD_FAIL_OUT_ENOSPC 0x1704
24657 do_facet mds2 lctl set_param fail_loc=0x80001704
24658 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
24659 && error "create striped directory should fail"
24661 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
24663 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
24666 run_test 300p "create striped directory without space"
24669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24670 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24672 local fd=$(free_fd)
24673 local cmd="exec $fd<$tdir"
24675 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
24678 trap "eval $cmd" EXIT
24679 cd $tdir || error "cd $tdir fails"
24680 rmdir ../$tdir || error "rmdir $tdir fails"
24681 mkdir local_dir && error "create dir succeeds"
24682 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
24686 run_test 300q "create remote directory under orphan directory"
24689 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24690 skip "Need MDS version at least 2.7.55" && return
24691 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24695 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
24696 error "set striped dir error"
24698 $LFS getdirstripe $DIR/$tdir/striped_dir ||
24699 error "getstripeddir fails"
24702 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
24703 awk '/lmv_stripe_count:/ { print $2 }')
24705 [ $MDSCOUNT -ne $stripe_count ] &&
24706 error "wrong stripe count $stripe_count expected $MDSCOUNT"
24708 rm -rf $DIR/$tdir/striped_dir ||
24709 error "unlink striped dir fails"
24711 run_test 300r "test -1 striped directory"
24713 test_300s_helper() {
24716 local stripe_dir=$DIR/$tdir/striped_dir.$count
24718 $LFS mkdir -c $count $stripe_dir ||
24719 error "lfs mkdir -c error"
24721 $LFS getdirstripe $stripe_dir ||
24722 error "lfs getdirstripe fails"
24725 stripe_count=$($LFS getdirstripe $stripe_dir |
24726 awk '/lmv_stripe_count:/ { print $2 }')
24728 [ $count -ne $stripe_count ] &&
24729 error_noexit "bad stripe count $stripe_count expected $count"
24732 dupe_stripes=$($LFS getdirstripe $stripe_dir |
24733 awk '/0x/ {count[$1] += 1}; END {
24734 for (idx in count) {
24735 if (count[idx]>1) {
24736 print "index " idx " count " count[idx]
24741 if [[ -n "$dupe_stripes" ]] ; then
24742 lfs getdirstripe $stripe_dir
24743 error_noexit "Dupe MDT above: $dupe_stripes "
24746 rm -rf $stripe_dir ||
24747 error_noexit "unlink $stripe_dir fails"
24751 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24752 skip "Need MDS version at least 2.7.55" && return
24753 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24756 for count in $(seq 2 $MDSCOUNT); do
24757 test_300s_helper $count
24760 run_test 300s "test lfs mkdir -c without -i"
24763 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
24764 skip "need MDS 2.14.55 or later"
24765 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
24767 local testdir="$DIR/$tdir/striped_dir"
24768 local dir1=$testdir/dir1
24769 local dir2=$testdir/dir2
24773 $LFS setdirstripe -D -c -1 --max-inherit=3 $testdir ||
24774 error "failed to set default stripe count for $testdir"
24777 local stripe_count=$($LFS getdirstripe -c $dir1)
24779 (( $stripe_count == $MDSCOUNT )) || error "wrong stripe count"
24781 local max_count=$((MDSCOUNT - 1))
24782 local mdts=$(comma_list $(mdts_nodes))
24784 do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=$max_count
24785 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=0"
24788 stripe_count=$($LFS getdirstripe -c $dir2)
24790 (( $stripe_count == $max_count )) || error "wrong stripe count"
24792 run_test 300t "test max_mdt_stripecount"
24794 prepare_remote_file() {
24795 mkdir $DIR/$tdir/src_dir ||
24796 error "create remote source failed"
24798 cp /etc/hosts $DIR/$tdir/src_dir/a ||
24799 error "cp to remote source failed"
24800 touch $DIR/$tdir/src_dir/a
24802 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
24803 error "create remote target dir failed"
24805 touch $DIR/$tdir/tgt_dir/b
24807 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
24808 error "rename dir cross MDT failed!"
24810 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
24811 error "src_child still exists after rename"
24813 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
24814 error "missing file(a) after rename"
24816 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
24817 error "diff after rename"
24821 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24822 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24824 local remote_file=$DIR/$tdir/tgt_dir/b
24826 mkdir -p $DIR/$tdir
24828 prepare_remote_file || error "prepare remote file failed"
24831 $OPENUNLINK $remote_file $remote_file ||
24832 error "openunlink $remote_file failed"
24833 $CHECKSTAT -a $remote_file || error "$remote_file exists"
24835 run_test 310a "open unlink remote file"
24838 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24839 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24841 local remote_file=$DIR/$tdir/tgt_dir/b
24843 mkdir -p $DIR/$tdir
24845 prepare_remote_file || error "prepare remote file failed"
24847 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24848 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
24849 $CHECKSTAT -t file $remote_file || error "check file failed"
24851 run_test 310b "unlink remote file with multiple links while open"
24854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24855 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
24857 local remote_file=$DIR/$tdir/tgt_dir/b
24859 mkdir -p $DIR/$tdir
24861 prepare_remote_file || error "prepare remote file failed"
24863 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24864 multiop_bg_pause $remote_file O_uc ||
24865 error "mulitop failed for remote file"
24867 $MULTIOP $DIR/$tfile Ouc
24868 kill -USR1 $MULTIPID
24871 run_test 310c "open-unlink remote file with multiple links"
24875 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24876 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
24877 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
24878 skip "lustre < 2.8.54 does not contain LU-4825 fix"
24879 remote_mds_nodsh && skip "remote MDS with nodsh"
24881 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24882 local mdts=$(comma_list $(mdts_nodes))
24884 mkdir -p $DIR/$tdir
24885 $LFS setstripe -i 0 -c 1 $DIR/$tdir
24886 createmany -o $DIR/$tdir/$tfile. 1000
24888 # statfs data is not real time, let's just calculate it
24889 old_iused=$((old_iused + 1000))
24891 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24892 osp.*OST0000*MDT0000.create_count")
24893 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24894 osp.*OST0000*MDT0000.max_create_count")
24895 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
24897 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
24898 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
24899 [ $index -ne 0 ] || error "$tfile stripe index is 0"
24901 unlinkmany $DIR/$tdir/$tfile. 1000
24903 do_nodes $mdts "$LCTL set_param -n \
24904 osp.*OST0000*.max_create_count=$max_count"
24905 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
24906 do_nodes $mdts "$LCTL set_param -n \
24907 osp.*OST0000*.create_count=$count"
24908 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
24909 grep "=0" && error "create_count is zero"
24912 for i in $(seq 120); do
24913 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24914 # system may be too busy to destroy all objs in time, use
24915 # a somewhat small value to not fail autotest
24916 [ $((old_iused - new_iused)) -gt 400 ] && break
24920 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
24921 [ $((old_iused - new_iused)) -gt 400 ] ||
24922 error "objs not destroyed after unlink"
24924 run_test 311 "disable OSP precreate, and unlink should destroy objs"
24930 local fid=($($LFS getstripe $tf | grep 0x))
24931 local seq=${fid[3]#0x}
24932 local objid=${fid[1]}
24934 local vdevdir=$(dirname $(facet_vdevice $ost))
24935 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
24936 local zfs_zapid=$(do_facet $ost $cmd |
24937 grep -w "/O/$seq/d$((objid%32))" -C 5 |
24938 awk '/Object/{getline; print $1}')
24939 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
24940 awk "/$objid = /"'{printf $3}')
24945 zfs_object_blksz() {
24949 local vdevdir=$(dirname $(facet_vdevice $ost))
24950 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
24951 local blksz=$(do_facet $ost $cmd $objid |
24952 awk '/dblk/{getline; printf $4}')
24954 case "${blksz: -1}" in
24955 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
24956 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
24963 test_312() { # LU-4856
24964 remote_ost_nodsh && skip "remote OST with nodsh"
24965 [[ "$ost1_FSTYPE" == "zfs" ]] || skip "the test only applies to zfs"
24967 local max_blksz=$(do_facet ost1 \
24968 $ZFS get -p recordsize $(facet_device ost1) |
24969 awk '!/VALUE/{print $3}')
24970 local tf=$DIR/$tfile
24972 $LFS setstripe -c1 $tf
24973 local facet="ost$(($($LFS getstripe -i $tf) + 1))"
24975 # Get ZFS object id
24976 local zfs_objid=$(zfs_get_objid $facet $tf)
24977 # block size change by sequential overwrite
24980 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
24981 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
24983 local blksz=$(zfs_object_blksz $facet $zfs_objid)
24984 [[ $blksz -eq $bs ]] || error "blksz error: $blksz, expected: $bs"
24988 $LFS setstripe -c1 $tf
24989 facet="ost$(($($LFS getstripe -i $tf) + 1))"
24991 # block size change by sequential append write
24992 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
24993 zfs_objid=$(zfs_get_objid $facet $tf)
24996 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
24997 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
24998 oflag=sync conv=notrunc
25000 blksz=$(zfs_object_blksz $facet $zfs_objid)
25001 (( $blksz == 2 * count * PAGE_SIZE )) ||
25002 error "blksz error, actual $blksz, " \
25003 "expected: 2 * $count * $PAGE_SIZE"
25008 $LFS setstripe -c1 $tf
25009 facet="ost$(($($LFS getstripe -i $tf) + 1))"
25010 zfs_objid=$(zfs_get_objid $facet $tf)
25012 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
25013 blksz=$(zfs_object_blksz $facet $zfs_objid)
25014 (( blksz == PAGE_SIZE )) ||
25015 error "blksz error: $blksz, expected: $PAGE_SIZE"
25017 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
25018 blksz=$(zfs_object_blksz $facet $zfs_objid)
25019 (( blksz == 65536 )) || error "blksz error: $blksz, expected: 64k"
25021 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
25022 blksz=$(zfs_object_blksz $facet $zfs_objid)
25023 (( blksz == 65536 )) || error "rewrite error: $blksz, expected: 64k"
25025 run_test 312 "make sure ZFS adjusts its block size by write pattern"
25028 remote_ost_nodsh && skip "remote OST with nodsh"
25030 local file=$DIR/$tfile
25033 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
25035 # define OBD_FAIL_TGT_RCVD_EIO 0x720
25036 do_facet ost1 "$LCTL set_param fail_loc=0x720"
25037 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
25038 error "write should failed"
25039 do_facet ost1 "$LCTL set_param fail_loc=0"
25042 run_test 313 "io should fail after last_rcvd update fail"
25045 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
25047 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
25048 do_facet ost1 "$LCTL set_param fail_loc=0x720"
25050 wait_delete_completed
25051 do_facet ost1 "$LCTL set_param fail_loc=0"
25053 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
25055 test_315() { # LU-618
25056 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
25058 local file=$DIR/$tfile
25061 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
25062 error "multiop file write failed"
25063 $MULTIOP $file oO_RDONLY:r4063232_c &
25068 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
25071 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
25074 run_test 315 "read should be accounted"
25077 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
25078 large_xattr_enabled || skip "ea_inode feature disabled"
25080 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
25081 mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
25082 chown nobody $DIR/$tdir/d || error "chown $tdir/d failed"
25083 touch $DIR/$tdir/d/$tfile || error "touch $tdir/d/$tfile failed"
25085 $LFS migrate -m1 $DIR/$tdir/d || error "lfs migrate -m1 failed"
25087 run_test 316 "lfs migrate of file with large_xattr enabled"
25090 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
25091 skip "Need MDS version at least 2.11.53"
25092 if [ "$ost1_FSTYPE" == "zfs" ]; then
25093 skip "LU-10370: no implementation for ZFS"
25097 local grant_blk_size
25099 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
25100 awk '/grant_block_size:/ { print $2; exit; }')
25102 # Create File of size 5M. Truncate it to below size's and verify
25105 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
25106 error "Create file $DIR/$tfile failed"
25107 stack_trap "rm -f $DIR/$tfile" EXIT
25109 for trunc_sz in 2097152 4097 4000 509 0; do
25110 $TRUNCATE $DIR/$tfile $trunc_sz ||
25111 error "truncate $tfile to $trunc_sz failed"
25112 local sz=$(stat --format=%s $DIR/$tfile)
25113 local blk=$(stat --format=%b $DIR/$tfile)
25114 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
25115 grant_blk_size) * 8))
25117 if [[ $blk -ne $trunc_blk ]]; then
25118 $(which stat) $DIR/$tfile
25119 error "Expected Block $trunc_blk got $blk for $tfile"
25122 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
25123 error "Expected Size $trunc_sz got $sz for $tfile"
25128 # Create file with a hole and write actual 65536 bytes which aligned
25129 # with 4K and 64K PAGE_SIZE. Block count must be 128.
25132 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 seek=5 conv=fsync ||
25133 error "Create file : $DIR/$tfile"
25136 # Truncate to size $trunc_sz bytes. Strip tail blocks and leave only 8
25137 # blocks. The block count must drop to 8.
25139 trunc_sz=$(($(stat --format=%s $DIR/$tfile) -
25140 ((bs - grant_blk_size) + 1)))
25141 $TRUNCATE $DIR/$tfile $trunc_sz ||
25142 error "truncate $tfile to $trunc_sz failed"
25144 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
25145 sz=$(stat --format=%s $DIR/$tfile)
25146 blk=$(stat --format=%b $DIR/$tfile)
25148 if [[ $blk -ne $trunc_bsz ]]; then
25149 $(which stat) $DIR/$tfile
25150 error "Expected Block $trunc_bsz got $blk for $tfile"
25153 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
25154 error "Expected Size $trunc_sz got $sz for $tfile"
25156 run_test 317 "Verify blocks get correctly update after truncate"
25159 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
25160 local old_max_active=$($LCTL get_param -n \
25161 ${llite_name}.max_read_ahead_async_active \
25164 $LCTL set_param llite.*.max_read_ahead_async_active=256
25165 local max_active=$($LCTL get_param -n \
25166 ${llite_name}.max_read_ahead_async_active \
25168 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
25170 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
25171 error "set max_read_ahead_async_active should succeed"
25173 $LCTL set_param llite.*.max_read_ahead_async_active=512
25174 max_active=$($LCTL get_param -n \
25175 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
25176 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
25178 # restore @max_active
25179 [ $old_max_active -ne 0 ] && $LCTL set_param \
25180 llite.*.max_read_ahead_async_active=$old_max_active
25182 local old_threshold=$($LCTL get_param -n \
25183 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
25184 local max_per_file_mb=$($LCTL get_param -n \
25185 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
25187 local invalid=$(($max_per_file_mb + 1))
25189 llite.*.read_ahead_async_file_threshold_mb=$invalid\
25190 && error "set $invalid should fail"
25192 local valid=$(($invalid - 1))
25194 llite.*.read_ahead_async_file_threshold_mb=$valid ||
25195 error "set $valid should succeed"
25196 local threshold=$($LCTL get_param -n \
25197 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
25198 [ $threshold -eq $valid ] || error \
25199 "expect threshold $valid got $threshold"
25201 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
25203 run_test 318 "Verify async readahead tunables"
25206 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
25208 local before=$(date +%s)
25210 local mdir=$DIR/$tdir
25211 local file=$mdir/xxx
25213 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
25216 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
25217 $LCTL set_param fail_val=5 fail_loc=0x8000032c
25218 $LFS migrate -m1 $mdir &
25221 dd if=$file of=/dev/null
25223 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
25224 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
25226 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
25228 run_test 319 "lost lease lock on migrate error"
25230 test_398a() { # LU-4198
25231 local ost1_imp=$(get_osc_import_name client ost1)
25232 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
25235 $LFS setstripe -c 1 -i 0 $DIR/$tfile
25236 $LCTL set_param ldlm.namespaces.*.lru_size=clear
25238 # Disabled: DIO does not push out buffered I/O pages, see LU-12587
25239 # request a new lock on client
25240 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
25242 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
25243 #local lock_count=$($LCTL get_param -n \
25244 # ldlm.namespaces.$imp_name.lru_size)
25245 #[[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
25247 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
25249 # no lock cached, should use lockless DIO and not enqueue new lock
25250 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct \
25252 error "dio write failed"
25253 lock_count=$($LCTL get_param -n \
25254 ldlm.namespaces.$imp_name.lru_size)
25255 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
25257 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
25259 # no lock cached, should use locked DIO append
25260 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct oflag=append \
25261 conv=notrunc || error "DIO append failed"
25262 lock_count=$($LCTL get_param -n \
25263 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
25264 [[ $lock_count -ne 0 ]] || error "lock still must be held by DIO append"
25266 run_test 398a "direct IO should cancel lock otherwise lockless"
25268 test_398b() { # LU-4198
25269 local before=$(date +%s)
25273 which fio || skip_env "no fio installed"
25274 $LFS setstripe -c -1 -S 1M $DIR/$tfile
25275 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
25277 # Single page, multiple pages, stripe size, 4*stripe size
25278 for bsize in $(( $PAGE_SIZE )) $(( 4*$PAGE_SIZE )) 1048576 4194304; do
25279 echo "mix direct rw ${bsize} by fio with $njobs jobs..."
25280 fio --name=rand-rw --rw=randrw --bs=$bsize --direct=1 \
25281 --numjobs=$njobs --fallocate=none \
25282 --iodepth=16 --allow_file_create=0 \
25283 --size=$((size/njobs))M \
25284 --filename=$DIR/$tfile &
25287 echo "mix buffer rw ${bsize} by fio with $njobs jobs..."
25288 fio --name=rand-rw --rw=randrw --bs=$bsize \
25289 --numjobs=$njobs --fallocate=none \
25290 --iodepth=16 --allow_file_create=0 \
25291 --size=$((size/njobs))M \
25292 --filename=$DIR/$tfile || true
25296 evict=$(do_facet client $LCTL get_param \
25297 osc.$FSNAME-OST*-osc-*/state |
25298 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
25300 [ -z "$evict" ] || [[ $evict -le $before ]] ||
25301 (do_facet client $LCTL get_param \
25302 osc.$FSNAME-OST*-osc-*/state;
25303 error "eviction happened: $evict before:$before")
25307 run_test 398b "DIO and buffer IO race"
25309 test_398c() { # LU-4198
25310 local ost1_imp=$(get_osc_import_name client ost1)
25311 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
25314 which fio || skip_env "no fio installed"
25316 saved_debug=$($LCTL get_param -n debug)
25317 $LCTL set_param debug=0
25319 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
25320 ((size /= 1024)) # by megabytes
25321 ((size /= 2)) # write half of the OST at most
25322 [ $size -gt 40 ] && size=40 #reduce test time anyway
25324 $LFS setstripe -c 1 $DIR/$tfile
25326 # it seems like ldiskfs reserves more space than necessary if the
25327 # writing blocks are not mapped, so it extends the file firstly
25328 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
25329 cancel_lru_locks osc
25331 # clear and verify rpc_stats later
25332 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
25335 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
25336 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
25337 --numjobs=$njobs --fallocate=none --ioengine=libaio \
25338 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
25339 --filename=$DIR/$tfile
25340 [ $? -eq 0 ] || error "fio write error"
25342 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
25343 error "Locks were requested while doing AIO"
25345 # get the percentage of 1-page I/O
25346 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
25347 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
25349 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
25351 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
25352 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
25353 --numjobs=$njobs --fallocate=none --ioengine=libaio \
25354 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
25355 --filename=$DIR/$tfile
25356 [ $? -eq 0 ] || error "fio mixed read write error"
25358 echo "AIO with large block size ${size}M"
25359 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
25360 --numjobs=1 --fallocate=none --ioengine=libaio \
25361 --iodepth=16 --allow_file_create=0 --size=${size}M \
25362 --filename=$DIR/$tfile
25363 [ $? -eq 0 ] || error "fio large block size failed"
25366 $LCTL set_param debug="$saved_debug"
25368 run_test 398c "run fio to test AIO"
25370 test_398d() { # LU-13846
25371 which aiocp || skip_env "no aiocp installed"
25372 local aio_file=$DIR/$tfile.aio
25374 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
25376 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
25377 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
25378 stack_trap "rm -f $DIR/$tfile $aio_file"
25380 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
25382 # make sure we don't crash and fail properly
25383 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
25384 error "aio not aligned with PAGE SIZE should fail"
25386 rm -f $DIR/$tfile $aio_file
25388 run_test 398d "run aiocp to verify block size > stripe size"
25391 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
25392 touch $DIR/$tfile.new
25393 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
25395 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
25397 test_398f() { # LU-14687
25398 which aiocp || skip_env "no aiocp installed"
25399 local aio_file=$DIR/$tfile.aio
25401 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
25403 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
25404 stack_trap "rm -f $DIR/$tfile $aio_file"
25406 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
25407 $LCTL set_param fail_loc=0x1418
25408 # make sure we don't crash and fail properly
25409 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
25410 error "aio with page allocation failure succeeded"
25411 $LCTL set_param fail_loc=0
25412 diff $DIR/$tfile $aio_file
25413 [[ $? != 0 ]] || error "no diff after failed aiocp"
25415 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
25417 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
25418 # stripe and i/o size must be > stripe size
25419 # Old style synchronous DIO waits after submitting each chunk, resulting in a
25420 # single RPC in flight. This test shows async DIO submission is working by
25421 # showing multiple RPCs in flight.
25422 test_398g() { # LU-13798
25423 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
25425 # We need to do some i/o first to acquire enough grant to put our RPCs
25426 # in flight; otherwise a new connection may not have enough grant
25428 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25429 error "parallel dio failed"
25430 stack_trap "rm -f $DIR/$tfile"
25432 # Reduce RPC size to 1M to avoid combination in to larger RPCs
25433 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
25434 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
25435 stack_trap "$LCTL set_param -n $pages_per_rpc"
25437 # Recreate file so it's empty
25439 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
25440 #Pause rpc completion to guarantee we see multiple rpcs in flight
25441 #define OBD_FAIL_OST_BRW_PAUSE_BULK
25442 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
25443 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25446 $LCTL set_param osc.*.rpc_stats=c
25448 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25449 error "parallel dio failed"
25450 stack_trap "rm -f $DIR/$tfile"
25452 $LCTL get_param osc.*-OST0000-*.rpc_stats
25453 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
25454 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
25455 grep "8:" | awk '{print $8}')
25456 # We look at the "8 rpcs in flight" field, and verify A) it is present
25457 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
25458 # as expected for an 8M DIO to a file with 1M stripes.
25459 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
25461 # Verify turning off parallel dio works as expected
25463 $LCTL set_param osc.*.rpc_stats=c
25464 $LCTL set_param llite.*.parallel_dio=0
25465 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
25467 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25468 error "dio with parallel dio disabled failed"
25470 # Ideally, we would see only one RPC in flight here, but there is an
25471 # unavoidable race between i/o completion and RPC in flight counting,
25472 # so while only 1 i/o is in flight at a time, the RPC in flight counter
25473 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
25474 # So instead we just verify it's always < 8.
25475 $LCTL get_param osc.*-OST0000-*.rpc_stats
25476 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
25477 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
25478 grep '^$' -B1 | grep . | awk '{print $1}')
25479 [ $ret != "8:" ] ||
25480 error "we should see fewer than 8 RPCs in flight (saw $ret)"
25482 run_test 398g "verify parallel dio async RPC submission"
25484 test_398h() { # LU-13798
25485 local dio_file=$DIR/$tfile.dio
25487 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
25489 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25490 stack_trap "rm -f $DIR/$tfile $dio_file"
25492 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
25493 error "parallel dio failed"
25494 diff $DIR/$tfile $dio_file
25495 [[ $? == 0 ]] || error "file diff after aiocp"
25497 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
25499 test_398i() { # LU-13798
25500 local dio_file=$DIR/$tfile.dio
25502 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
25504 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25505 stack_trap "rm -f $DIR/$tfile $dio_file"
25507 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
25508 $LCTL set_param fail_loc=0x1418
25509 # make sure we don't crash and fail properly
25510 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
25511 error "parallel dio page allocation failure succeeded"
25512 diff $DIR/$tfile $dio_file
25513 [[ $? != 0 ]] || error "no diff after failed aiocp"
25515 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
25517 test_398j() { # LU-13798
25518 # Stripe size > RPC size but less than i/o size tests split across
25519 # stripes and RPCs for individual i/o op
25520 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
25522 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
25523 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
25524 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
25525 stack_trap "$LCTL set_param -n $pages_per_rpc"
25527 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25528 error "parallel dio write failed"
25529 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
25531 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
25532 error "parallel dio read failed"
25533 diff $DIR/$tfile $DIR/$tfile.2
25534 [[ $? == 0 ]] || error "file diff after parallel dio read"
25536 run_test 398j "test parallel dio where stripe size > rpc_size"
25538 test_398k() { # LU-13798
25539 wait_delete_completed
25542 # 4 stripe file; we will cause out of space on OST0
25543 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
25545 # Fill OST0 (if it's not too large)
25546 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
25548 if [[ $ORIGFREE -gt $MAXFREE ]]; then
25549 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
25551 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
25552 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
25553 error "dd should fill OST0"
25554 stack_trap "rm -f $DIR/$tfile.1"
25556 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25560 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
25561 error "file is not 0 bytes in size"
25563 # dd above should not succeed, but don't error until here so we can
25564 # get debug info above
25566 error "parallel dio write with enospc succeeded"
25567 stack_trap "rm -f $DIR/$tfile"
25569 run_test 398k "test enospc on first stripe"
25571 test_398l() { # LU-13798
25572 wait_delete_completed
25575 # 4 stripe file; we will cause out of space on OST0
25576 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
25577 # happens on the second i/o chunk we issue
25578 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
25580 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
25581 stack_trap "rm -f $DIR/$tfile"
25583 # Fill OST0 (if it's not too large)
25584 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
25586 if [[ $ORIGFREE -gt $MAXFREE ]]; then
25587 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
25589 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
25590 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
25591 error "dd should fill OST0"
25592 stack_trap "rm -f $DIR/$tfile.1"
25594 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
25596 stack_trap "rm -f $DIR/$tfile.2"
25598 # Check that short write completed as expected
25599 ls -la $DIR/$tfile.2
25600 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
25601 error "file is not 1M in size"
25603 # dd above should not succeed, but don't error until here so we can
25604 # get debug info above
25606 error "parallel dio write with enospc succeeded"
25608 # Truncate source file to same length as output file and diff them
25609 $TRUNCATE $DIR/$tfile 1048576
25610 diff $DIR/$tfile $DIR/$tfile.2
25611 [[ $? == 0 ]] || error "data incorrect after short write"
25613 run_test 398l "test enospc on intermediate stripe/RPC"
25615 test_398m() { # LU-13798
25616 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
25618 # Set up failure on OST0, the first stripe:
25619 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
25620 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
25621 # OST0 is on ost1, OST1 is on ost2.
25622 # So this fail_val specifies OST0
25623 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
25624 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25626 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
25627 error "parallel dio write with failure on first stripe succeeded"
25628 stack_trap "rm -f $DIR/$tfile"
25629 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25631 # Place data in file for read
25632 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25633 error "parallel dio write failed"
25635 # Fail read on OST0, first stripe
25636 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
25637 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
25638 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
25639 error "parallel dio read with error on first stripe succeeded"
25640 rm -f $DIR/$tfile.2
25641 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25643 # Switch to testing on OST1, second stripe
25644 # Clear file contents, maintain striping
25646 # Set up failure on OST1, second stripe:
25647 do_facet ost2 $LCTL set_param fail_loc=0x20e fail_val=2
25648 stack_trap "do_facet ost2 $LCTL set_param fail_loc=0"
25650 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
25651 error "parallel dio write with failure on second stripe succeeded"
25652 stack_trap "rm -f $DIR/$tfile"
25653 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
25655 # Place data in file for read
25656 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25657 error "parallel dio write failed"
25659 # Fail read on OST1, second stripe
25660 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
25661 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
25662 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
25663 error "parallel dio read with error on second stripe succeeded"
25664 rm -f $DIR/$tfile.2
25665 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
25667 run_test 398m "test RPC failures with parallel dio"
25669 # Parallel submission of DIO should not cause problems for append, but it's
25670 # important to verify.
25671 test_398n() { # LU-13798
25672 $LFS setstripe -C 2 -S 1M $DIR/$tfile
25674 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
25675 error "dd to create source file failed"
25676 stack_trap "rm -f $DIR/$tfile"
25678 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
25679 error "parallel dio write with failure on second stripe succeeded"
25680 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
25681 diff $DIR/$tfile $DIR/$tfile.1
25682 [[ $? == 0 ]] || error "data incorrect after append"
25685 run_test 398n "test append with parallel DIO"
25688 directio rdwr $DIR/$tfile 0 1 1 || error "bad KMS"
25690 run_test 398o "right kms with DIO"
25693 local read_write=$1
25694 if [ "$read_write" = "write" ]; then
25695 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
25696 elif [ "$read_write" = "read" ]; then
25697 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
25699 error "argument error"
25702 # turn off debug for performance testing
25703 local saved_debug=$($LCTL get_param -n debug)
25704 $LCTL set_param debug=0
25706 $LFS setstripe -c 1 -i 0 $DIR/$tfile
25708 # get ost1 size - $FSNAME-OST0000
25709 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
25710 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
25711 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
25713 if [ "$read_write" = "read" ]; then
25714 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
25717 local start_time=$(date +%s.%N)
25718 $dd_cmd bs=1M count=$blocks oflag=sync ||
25719 error "real dd $read_write error"
25720 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
25722 if [ "$read_write" = "write" ]; then
25726 # define OBD_FAIL_OST_FAKE_RW 0x238
25727 do_facet ost1 $LCTL set_param fail_loc=0x238
25729 local start_time=$(date +%s.%N)
25730 $dd_cmd bs=1M count=$blocks oflag=sync ||
25731 error "fake dd $read_write error"
25732 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
25734 if [ "$read_write" = "write" ]; then
25736 cancel_lru_locks osc
25737 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
25738 error "$tfile size not $blocks MB"
25740 do_facet ost1 $LCTL set_param fail_loc=0
25742 echo "fake $read_write $duration_fake vs. normal $read_write" \
25743 "$duration in seconds"
25744 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
25745 error_not_in_vm "fake write is slower"
25747 $LCTL set_param -n debug="$saved_debug"
25750 test_399a() { # LU-7655 for OST fake write
25751 remote_ost_nodsh && skip "remote OST with nodsh"
25755 run_test 399a "fake write should not be slower than normal write"
25757 test_399b() { # LU-8726 for OST fake read
25758 remote_ost_nodsh && skip "remote OST with nodsh"
25759 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
25760 skip_env "ldiskfs only test"
25765 run_test 399b "fake read should not be slower than normal read"
25767 test_400a() { # LU-1606, was conf-sanity test_74
25768 if ! which $CC > /dev/null 2>&1; then
25769 skip_env "$CC is not installed"
25772 local extra_flags=''
25773 local out=$TMP/$tfile
25774 local prefix=/usr/include/lustre
25777 # Oleg removes .c files in his test rig so test if any c files exist
25778 [[ -n "$(ls -A $LUSTRE_TESTS_API_DIR)" ]] ||
25779 skip_env "Needed .c test files are missing"
25781 if ! [[ -d $prefix ]]; then
25782 # Assume we're running in tree and fixup the include path.
25783 extra_flags+=" -I$LUSTRE/../lnet/include/uapi"
25784 extra_flags+=" -I$LUSTRE/include/uapi -I$LUSTRE/include"
25785 extra_flags+=" -L$LUSTRE/utils/.libs"
25788 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
25789 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
25790 error "client api broken"
25794 run_test 400a "Lustre client api program can compile and link"
25796 test_400b() { # LU-1606, LU-5011
25798 local out=$TMP/$tfile
25799 local prefix=/usr/include/linux/lustre
25801 # We use a hard coded prefix so that this test will not fail
25802 # when run in tree. There are headers in lustre/include/lustre/
25803 # that are not packaged (like lustre_idl.h) and have more
25804 # complicated include dependencies (like config.h and lnet/types.h).
25805 # Since this test about correct packaging we just skip them when
25806 # they don't exist (see below) rather than try to fixup cppflags.
25808 if ! which $CC > /dev/null 2>&1; then
25809 skip_env "$CC is not installed"
25812 for header in $prefix/*.h; do
25813 if ! [[ -f "$header" ]]; then
25817 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
25818 continue # lustre_ioctl.h is internal header
25821 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
25822 error "cannot compile '$header'"
25826 run_test 400b "packaged headers can be compiled"
25828 test_401a() { #LU-7437
25829 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
25830 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
25832 #count the number of parameters by "list_param -R"
25833 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
25834 #count the number of parameters by listing proc files
25835 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
25836 echo "proc_dirs='$proc_dirs'"
25837 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
25838 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
25841 [ $params -eq $procs ] ||
25842 error "found $params parameters vs. $procs proc files"
25844 # test the list_param -D option only returns directories
25845 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
25846 #count the number of parameters by listing proc directories
25847 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
25850 [ $params -eq $procs ] ||
25851 error "found $params parameters vs. $procs proc files"
25853 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
25856 # jobid_var may not allow arbitrary values, so use jobid_name
25858 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25859 local testname=jobid_name tmp='testing%p'
25861 local testname=jobid_var tmp=testing
25864 local save=$($LCTL get_param -n $testname)
25866 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
25867 error "no error returned when setting bad parameters"
25869 local jobid_new=$($LCTL get_param -n foe $testname baz)
25870 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
25872 $LCTL set_param -n fog=bam $testname=$save bat=fog
25873 local jobid_old=$($LCTL get_param -n foe $testname bag)
25874 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
25876 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
25879 # jobid_var may not allow arbitrary values, so use jobid_name
25881 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25882 local testname=jobid_name
25884 local testname=jobid_var
25887 local jobid_var_old=$($LCTL get_param -n $testname)
25888 local jobid_var_new
25890 $LCTL set_param $testname= &&
25891 error "no error returned for 'set_param a='"
25893 jobid_var_new=$($LCTL get_param -n $testname)
25894 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25895 error "$testname was changed by setting without value"
25897 $LCTL set_param $testname &&
25898 error "no error returned for 'set_param a'"
25900 jobid_var_new=$($LCTL get_param -n $testname)
25901 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25902 error "$testname was changed by setting without value"
25904 run_test 401c "Verify 'lctl set_param' without value fails in either format."
25907 # jobid_var may not allow arbitrary values, so use jobid_name
25909 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25910 local testname=jobid_name new_value='foo=bar%p'
25912 local testname=jobid_var new_valuie=foo=bar
25915 local jobid_var_old=$($LCTL get_param -n $testname)
25916 local jobid_var_new
25918 $LCTL set_param $testname=$new_value ||
25919 error "'set_param a=b' did not accept a value containing '='"
25921 jobid_var_new=$($LCTL get_param -n $testname)
25922 [[ "$jobid_var_new" == "$new_value" ]] ||
25923 error "'set_param a=b' failed on a value containing '='"
25925 # Reset the $testname to test the other format
25926 $LCTL set_param $testname=$jobid_var_old
25927 jobid_var_new=$($LCTL get_param -n $testname)
25928 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25929 error "failed to reset $testname"
25931 $LCTL set_param $testname $new_value ||
25932 error "'set_param a b' did not accept a value containing '='"
25934 jobid_var_new=$($LCTL get_param -n $testname)
25935 [[ "$jobid_var_new" == "$new_value" ]] ||
25936 error "'set_param a b' failed on a value containing '='"
25938 $LCTL set_param $testname $jobid_var_old
25939 jobid_var_new=$($LCTL get_param -n $testname)
25940 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25941 error "failed to reset $testname"
25943 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
25945 test_401e() { # LU-14779
25946 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
25947 error "lctl list_param MGC* failed"
25948 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
25949 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
25950 error "lctl get_param lru_size failed"
25952 run_test 401e "verify 'lctl get_param' works with NID in parameter"
25955 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
25956 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
25957 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
25958 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
25959 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
25960 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
25961 remote_mds_nodsh && skip "remote MDS with nodsh"
25963 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
25964 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
25965 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
25966 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
25967 echo "Touch failed - OK"
25969 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
25972 local file1=$DIR/$tfile.1
25973 local file2=$DIR/$tfile.2
25974 local tfile=$TMP/$tfile
25976 rm -f $file1 $file2 $tfile
25981 # 30 sec OBD_TIMEOUT in ll_getattr()
25982 # right before populating st_nlink
25983 $LCTL set_param fail_loc=0x80001409
25984 stat -c %h $file1 > $tfile &
25986 # create an alias, drop all locks and reclaim the dentry
25988 cancel_lru_locks mdc
25989 cancel_lru_locks osc
25990 sysctl -w vm.drop_caches=2
25994 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
25996 rm -f $tfile $file1 $file2
25998 run_test 403 "i_nlink should not drop to zero due to aliasing"
26000 test_404() { # LU-6601
26001 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
26002 skip "Need server version newer than 2.8.52"
26003 remote_mds_nodsh && skip "remote MDS with nodsh"
26005 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
26006 awk '/osp .*-osc-MDT/ { print $4}')
26009 for osp in $mosps; do
26010 echo "Deactivate: " $osp
26011 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
26012 local stat=$(do_facet $SINGLEMDS $LCTL dl |
26013 awk -vp=$osp '$4 == p { print $2 }')
26014 [ $stat = IN ] || {
26015 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
26016 error "deactivate error"
26018 echo "Activate: " $osp
26019 do_facet $SINGLEMDS $LCTL --device %$osp activate
26020 local stat=$(do_facet $SINGLEMDS $LCTL dl |
26021 awk -vp=$osp '$4 == p { print $2 }')
26022 [ $stat = UP ] || {
26023 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
26024 error "activate error"
26028 run_test 404 "validate manual {de}activated works properly for OSPs"
26031 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
26032 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
26033 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
26034 skip "Layout swap lock is not supported"
26036 check_swap_layouts_support
26037 check_swap_layout_no_dom $DIR
26039 test_mkdir $DIR/$tdir
26040 swap_lock_test -d $DIR/$tdir ||
26041 error "One layout swap locked test failed"
26043 run_test 405 "Various layout swap lock tests"
26046 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
26047 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
26048 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
26049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26050 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
26051 skip "Need MDS version at least 2.8.50"
26053 local def_stripe_size=$($LFS getstripe -S $MOUNT)
26054 local test_pool=$TESTNAME
26056 pool_add $test_pool || error "pool_add failed"
26057 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
26058 error "pool_add_targets failed"
26060 save_layout_restore_at_exit $MOUNT
26062 # parent set default stripe count only, child will stripe from both
26063 # parent and fs default
26064 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
26065 error "setstripe $MOUNT failed"
26066 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
26067 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
26068 for i in $(seq 10); do
26069 local f=$DIR/$tdir/$tfile.$i
26070 touch $f || error "touch failed"
26071 local count=$($LFS getstripe -c $f)
26072 [ $count -eq $OSTCOUNT ] ||
26073 error "$f stripe count $count != $OSTCOUNT"
26074 local offset=$($LFS getstripe -i $f)
26075 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
26076 local size=$($LFS getstripe -S $f)
26077 [ $size -eq $((def_stripe_size * 2)) ] ||
26078 error "$f stripe size $size != $((def_stripe_size * 2))"
26079 local pool=$($LFS getstripe -p $f)
26080 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
26083 # change fs default striping, delete parent default striping, now child
26084 # will stripe from new fs default striping only
26085 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
26086 error "change $MOUNT default stripe failed"
26087 $LFS setstripe -c 0 $DIR/$tdir ||
26088 error "delete $tdir default stripe failed"
26089 for i in $(seq 11 20); do
26090 local f=$DIR/$tdir/$tfile.$i
26091 touch $f || error "touch $f failed"
26092 local count=$($LFS getstripe -c $f)
26093 [ $count -eq 1 ] || error "$f stripe count $count != 1"
26094 local offset=$($LFS getstripe -i $f)
26095 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
26096 local size=$($LFS getstripe -S $f)
26097 [ $size -eq $def_stripe_size ] ||
26098 error "$f stripe size $size != $def_stripe_size"
26099 local pool=$($LFS getstripe -p $f)
26100 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
26103 unlinkmany $DIR/$tdir/$tfile. 1 20
26105 local f=$DIR/$tdir/$tfile
26106 pool_remove_all_targets $test_pool $f
26107 pool_remove $test_pool $f
26109 run_test 406 "DNE support fs default striping"
26112 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
26113 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
26114 skip "Need MDS version at least 2.8.55"
26115 remote_mds_nodsh && skip "remote MDS with nodsh"
26117 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
26118 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
26119 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
26120 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
26121 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
26123 #define OBD_FAIL_DT_TXN_STOP 0x2019
26124 for idx in $(seq $MDSCOUNT); do
26125 do_facet mds$idx "lctl set_param fail_loc=0x2019"
26127 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
26128 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
26129 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
26132 run_test 407 "transaction fail should cause operation fail"
26135 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
26137 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
26138 lctl set_param fail_loc=0x8000040a
26139 # let ll_prepare_partial_page() fail
26140 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
26144 # create at least 100 unused inodes so that
26145 # shrink_icache_memory(0) should not return 0
26146 touch $DIR/$tfile-{0..100}
26147 rm -f $DIR/$tfile-{0..100}
26150 echo 2 > /proc/sys/vm/drop_caches
26152 run_test 408 "drop_caches should not hang due to page leaks"
26156 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26158 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
26159 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
26160 touch $DIR/$tdir/guard || error "(2) Fail to create"
26162 local PREFIX=$(str_repeat 'A' 128)
26163 echo "Create 1K hard links start at $(date)"
26164 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
26165 error "(3) Fail to hard link"
26167 echo "Links count should be right although linkEA overflow"
26168 stat $DIR/$tdir/guard || error "(4) Fail to stat"
26169 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
26170 [ $linkcount -eq 1001 ] ||
26171 error "(5) Unexpected hard links count: $linkcount"
26173 echo "List all links start at $(date)"
26174 ls -l $DIR/$tdir/foo > /dev/null ||
26175 error "(6) Fail to list $DIR/$tdir/foo"
26177 echo "Unlink hard links start at $(date)"
26178 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
26179 error "(7) Fail to unlink"
26180 echo "Unlink hard links finished at $(date)"
26182 run_test 409 "Large amount of cross-MDTs hard links on the same file"
26186 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
26187 skip "Need client version at least 2.9.59"
26188 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
26189 skip "Need MODULES build"
26191 # Create a file, and stat it from the kernel
26192 local testfile=$DIR/$tfile
26195 local run_id=$RANDOM
26196 local my_ino=$(stat --format "%i" $testfile)
26198 # Try to insert the module. This will always fail as the
26199 # module is designed to not be inserted.
26200 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
26203 # Anything but success is a test failure
26205 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
26206 error "no inode match"
26208 run_test 410 "Test inode number returned from kernel thread"
26210 cleanup_test411_cgroup() {
26216 local cg_basedir=/sys/fs/cgroup/memory
26218 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
26219 skip "no setup for cgroup"
26221 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
26222 error "test file creation failed"
26223 cancel_lru_locks osc
26225 # Create a very small memory cgroup to force a slab allocation error
26226 local cgdir=$cg_basedir/osc_slab_alloc
26227 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
26228 trap "cleanup_test411_cgroup $cgdir" EXIT
26229 echo 2M > $cgdir/memory.kmem.limit_in_bytes
26230 echo 1M > $cgdir/memory.limit_in_bytes
26232 # Should not LBUG, just be killed by oom-killer
26233 # dd will return 0 even allocation failure in some environment.
26234 # So don't check return value
26235 bash -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
26236 cleanup_test411_cgroup $cgdir
26240 run_test 411 "Slab allocation error with cgroup does not LBUG"
26243 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
26244 (( $MDS1_VERSION >= $(version_code 2.10.55) )) ||
26245 skip "Need server version at least 2.10.55"
26247 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
26248 error "mkdir failed"
26249 $LFS getdirstripe $DIR/$tdir
26250 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
26251 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
26252 error "expect $((MDSCOUT - 1)) get $stripe_index"
26253 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
26254 [ $stripe_count -eq 2 ] ||
26255 error "expect 2 get $stripe_count"
26257 (( $MDS1_VERSION >= $(version_code 2.14.55) )) || return 0
26262 # subdirs should be on the same MDT as parent
26263 for i in $(seq 0 $((MDSCOUNT - 1))); do
26264 $LFS mkdir -i $i $DIR/$tdir/mdt$i || error "mkdir mdt$i failed"
26265 mkdir $DIR/$tdir/mdt$i/sub || error "mkdir sub failed"
26266 index=$($LFS getstripe -m $DIR/$tdir/mdt$i/sub)
26267 (( index == i )) || error "mdt$i/sub on MDT$index"
26270 # stripe offset -1, ditto
26271 for i in {1..10}; do
26272 $LFS mkdir -i -1 $DIR/$tdir/qos$i || error "mkdir qos$i failed"
26273 index=$($LFS getstripe -m $DIR/$tdir/qos$i)
26274 mkdir $DIR/$tdir/qos$i/sub || error "mkdir sub failed"
26275 index2=$($LFS getstripe -m $DIR/$tdir/qos$i/sub)
26276 (( index == index2 )) ||
26277 error "qos$i on MDT$index, sub on MDT$index2"
26280 local testdir=$DIR/$tdir/inherit
26282 $LFS mkdir -i 1 --max-inherit=3 $testdir || error "mkdir inherit failed"
26285 testdir=$testdir/s$i
26286 mkdir $testdir || error "mkdir $testdir failed"
26287 index=$($LFS getstripe -m $testdir)
26288 (( index == 1 )) ||
26289 error "$testdir on MDT$index"
26292 # not inherit any more
26293 testdir=$testdir/s3
26294 mkdir $testdir || error "mkdir $testdir failed"
26295 getfattr -d -m dmv $testdir | grep dmv &&
26296 error "default LMV set on $testdir" || true
26298 run_test 412 "mkdir on specific MDTs"
26300 TEST413_COUNT=${TEST413_COUNT:-200}
26301 generate_uneven_mdts() {
26303 local lmv_qos_maxage
26304 local lod_qos_maxage
26314 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
26315 $LCTL set_param lmv.*.qos_maxage=1
26316 stack_trap "$LCTL set_param \
26317 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
26318 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
26319 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
26320 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
26321 lod.*.mdt_qos_maxage=1
26322 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
26323 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
26326 echo "Check for uneven MDTs: "
26328 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26329 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26330 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26332 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26333 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26336 for ((i = 1; i < ${#ffree[@]}; i++)); do
26337 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26338 if [ $tmp -gt $max ]; then
26342 if [ $tmp -lt $min ]; then
26348 (( ${ffree[min_index]} > 0 )) ||
26349 skip "no free files in MDT$min_index"
26350 (( ${ffree[min_index]} < 10000000 )) ||
26351 skip "too many free files in MDT$min_index"
26353 # Check if we need to generate uneven MDTs
26354 local diff=$(((max - min) * 100 / min))
26355 local testdir=$DIR/$tdir-fillmdt
26359 while (( diff < threshold )); do
26361 # generate uneven MDTs, create till $threshold% diff
26362 echo -n "weight diff=$diff% must be > $threshold% ..."
26363 echo "Fill MDT$min_index with $TEST413_COUNT files: loop $i"
26364 testdir=$DIR/$tdir-fillmdt/$i
26365 [ -d $testdir ] && continue
26366 $LFS mkdir -i $min_index $testdir ||
26367 error "mkdir $testdir failed"
26368 $LFS setstripe -E 1M -L mdt $testdir ||
26369 error "setstripe $testdir failed"
26371 for ((F=0; F < TEST413_COUNT; F++)); do
26372 dd if=/dev/zero of=$testdir/f.$F bs=128K count=1 > \
26373 /dev/null 2>&1 || error "dd $F failed"
26375 sync; sleep 1; sync
26377 # wait for QOS to update
26378 (( SECONDS < start + 1 )) && sleep $((start + 1 - SECONDS))
26380 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
26381 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
26382 max=$(((${ffree[max_index]} >> 8) *
26383 (${bavail[max_index]} * bsize >> 16)))
26384 min=$(((${ffree[min_index]} >> 8) *
26385 (${bavail[min_index]} * bsize >> 16)))
26386 diff=$(((max - min) * 100 / min))
26390 echo "MDT filesfree available: ${ffree[*]}"
26391 echo "MDT blocks available: ${bavail[*]}"
26392 echo "weight diff=$diff%"
26397 local stripe_count=$2
26398 local mdts=$(comma_list $(mdts_nodes))
26401 local lmv_qos_prio_free
26402 local lmv_qos_threshold_rr
26403 local lmv_qos_maxage
26404 local lod_qos_prio_free
26405 local lod_qos_threshold_rr
26406 local lod_qos_maxage
26410 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
26411 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
26412 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
26414 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
26415 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
26416 stack_trap "$LCTL set_param \
26417 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
26418 stack_trap "$LCTL set_param \
26419 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
26420 stack_trap "$LCTL set_param \
26421 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
26423 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
26424 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
26425 lod_qos_prio_free=${lod_qos_prio_free%%%}
26426 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
26427 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
26428 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
26429 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
26430 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
26431 stack_trap "do_nodes $mdts $LCTL set_param \
26432 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
26433 stack_trap "do_nodes $mdts $LCTL set_param \
26434 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
26435 stack_trap "do_nodes $mdts $LCTL set_param \
26436 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
26438 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
26439 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
26441 testdir=$DIR/$tdir-s$stripe_count/rr
26443 local stripe_index=$($LFS getstripe -m $testdir)
26444 local test_mkdir_rr=true
26446 getfattr -d -m dmv -e hex $testdir | grep dmv
26447 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
26448 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
26449 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
26450 test_mkdir_rr=false
26455 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
26456 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
26458 stack_trap "unlinkmany -d $testdir/subdir $((100 * MDSCOUNT))"
26459 for (( i = 0; i < 100 * MDSCOUNT; i++ )); do
26460 eval $mkdir_cmd $testdir/subdir$i ||
26461 error "$mkdir_cmd subdir$i failed"
26464 for (( i = 0; i < $MDSCOUNT; i++ )); do
26465 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
26466 echo "$count directories created on MDT$i"
26467 if $test_mkdir_rr; then
26468 (( $count == 100 )) ||
26469 error "subdirs are not evenly distributed"
26470 elif (( $i == $stripe_index )); then
26471 (( $count == 100 * MDSCOUNT )) ||
26472 error "$count subdirs created on MDT$i"
26474 (( $count == 0 )) ||
26475 error "$count subdirs created on MDT$i"
26478 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
26479 count=$($LFS getdirstripe $testdir/* |
26480 grep -c -P "^\s+$i\t")
26481 echo "$count stripes created on MDT$i"
26482 # deviation should < 5% of average
26483 (( $count >= 95 * stripe_count &&
26484 $count <= 105 * stripe_count)) ||
26485 error "stripes are not evenly distributed"
26490 echo "Check for uneven MDTs: "
26500 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26501 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26502 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26504 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26505 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26508 for ((i = 1; i < ${#ffree[@]}; i++)); do
26509 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26510 if [ $tmp -gt $max ]; then
26514 if [ $tmp -lt $min ]; then
26520 (( ${ffree[min_index]} > 0 )) ||
26521 skip "no free files in MDT$min_index"
26522 (( ${ffree[min_index]} < 10000000 )) ||
26523 skip "too many free files in MDT$min_index"
26525 echo "MDT filesfree available: ${ffree[*]}"
26526 echo "MDT blocks available: ${bavail[*]}"
26527 echo "weight diff=$(((max - min) * 100 / min))%"
26529 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
26531 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
26532 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
26533 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
26534 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
26535 # decrease statfs age, so that it can be updated in time
26536 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
26537 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
26541 testdir=$DIR/$tdir-s$stripe_count/qos
26544 stack_trap "unlinkmany -d $testdir/subdir $((num * MDSCOUNT))"
26545 for (( i = 0; i < num * MDSCOUNT; i++ )); do
26546 eval $mkdir_cmd $testdir/subdir$i ||
26547 error "$mkdir_cmd subdir$i failed"
26551 for (( i = 0; i < $MDSCOUNT; i++ )); do
26552 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
26553 (( count > max )) && max=$count
26554 echo "$count directories created on MDT$i"
26557 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
26559 # D-value should > 10% of averge
26560 (( max - min > num / 10 )) ||
26561 error "subdirs shouldn't be evenly distributed: $max - $min < $((num / 10))"
26563 # ditto for stripes
26564 if (( stripe_count > 1 )); then
26566 for (( i = 0; i < $MDSCOUNT; i++ )); do
26567 count=$($LFS getdirstripe $testdir/* |
26568 grep -c -P "^\s+$i\t")
26569 (( count > max )) && max=$count
26570 echo "$count stripes created on MDT$i"
26573 min=$($LFS getdirstripe $testdir/* |
26574 grep -c -P "^\s+$min_index\t")
26575 (( max - min > num * stripe_count / 10 )) ||
26576 error "stripes shouldn't be evenly distributed: $max - $min < $((num / 10)) * $stripe_count"
26588 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26589 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26590 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26592 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26594 for ((i = 1; i < ${#ffree[@]}; i++)); do
26595 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26596 (( tmp < min )) && min=$tmp && min_index=$i
26603 [ $MDSCOUNT -lt 2 ] &&
26604 skip "We need at least 2 MDTs for this test"
26606 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
26607 skip "Need server version at least 2.12.52"
26611 generate_uneven_mdts 100
26612 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
26613 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
26614 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
26615 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
26616 error "mkdir failed"
26617 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
26620 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
26623 [ $MDSCOUNT -lt 2 ] &&
26624 skip "We need at least 2 MDTs for this test"
26626 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
26627 skip "Need server version at least 2.12.52"
26632 generate_uneven_mdts 100
26633 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
26634 testdir=$DIR/$tdir-s$stripe_count
26635 mkdir $testdir || error "mkdir $testdir failed"
26636 mkdir $testdir/rr || error "mkdir rr failed"
26637 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
26638 error "mkdir qos failed"
26639 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
26640 $testdir/rr || error "setdirstripe rr failed"
26641 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
26642 error "setdirstripe failed"
26643 test_qos_mkdir "mkdir" $stripe_count
26646 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
26649 (( $MDSCOUNT >= 2 )) ||
26650 skip "We need at least 2 MDTs for this test"
26652 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
26653 skip "Need server version at least 2.14.51"
26659 testdir=$DIR/${tdir}-s1
26660 mkdir $testdir || error "mkdir $testdir failed"
26661 mkdir $testdir/rr || error "mkdir rr failed"
26662 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
26663 # default max_inherit is -1, default max_inherit_rr is 0
26664 $LFS setdirstripe -D -c 1 $testdir/rr ||
26665 error "setdirstripe rr failed"
26666 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
26667 error "setdirstripe qos failed"
26668 test_qos_mkdir "mkdir" 1
26670 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
26671 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
26672 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
26673 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
26674 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
26676 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
26677 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
26678 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
26679 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
26680 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
26681 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
26682 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
26683 error "level2 shouldn't have default LMV" || true
26685 run_test 413c "mkdir with default LMV max inherit rr"
26688 (( MDSCOUNT >= 2 )) ||
26689 skip "We need at least 2 MDTs for this test"
26691 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
26692 skip "Need server version at least 2.14.51"
26694 local lmv_qos_threshold_rr
26696 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
26698 stack_trap "$LCTL set_param \
26699 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
26701 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
26702 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
26703 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
26704 error "$tdir shouldn't have default LMV"
26705 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
26706 error "mkdir sub failed"
26708 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
26710 (( count == 100 )) || error "$count subdirs on MDT0"
26712 run_test 413d "inherit ROOT default LMV"
26715 (( MDSCOUNT >= 2 )) ||
26716 skip "We need at least 2 MDTs for this test"
26717 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26718 skip "Need server version at least 2.14.55"
26720 local testdir=$DIR/$tdir
26721 local tmpfile=$TMP/temp.setdirstripe.stderr.$$
26723 local sub_max_inherit
26725 mkdir -p $testdir || error "failed to create $testdir"
26727 # set default max-inherit to -1 if stripe count is 0 or 1
26728 $LFS setdirstripe -D -c 1 $testdir ||
26729 error "failed to set default LMV"
26730 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26731 (( max_inherit == -1 )) ||
26732 error "wrong max_inherit value $max_inherit"
26734 # set default max_inherit to a fixed value if stripe count is not 0 or 1
26735 $LFS setdirstripe -D -c -1 $testdir ||
26736 error "failed to set default LMV"
26737 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26738 (( max_inherit > 0 )) ||
26739 error "wrong max_inherit value $max_inherit"
26741 # and the subdir will decrease the max_inherit by 1
26742 mkdir -p $testdir/subdir-1 || error "failed to make subdir"
26743 sub_max_inherit=$($LFS getdirstripe -D --max-inherit $testdir/subdir-1)
26744 (( sub_max_inherit == max_inherit - 1)) ||
26745 error "wrong max-inherit of subdir $sub_max_inherit"
26747 # check specified --max-inherit and warning message
26748 stack_trap "rm -f $tmpfile"
26749 $LFS setdirstripe -D -c 2 --max-inherit=-1 $testdir 2> $tmpfile ||
26750 error "failed to set default LMV"
26751 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26752 (( max_inherit == -1 )) ||
26753 error "wrong max_inherit value $max_inherit"
26755 # check the warning messages
26756 if ! [[ $(cat $tmpfile) =~ "max-inherit=" ]]; then
26757 error "failed to detect warning string"
26760 run_test 413e "check default max-inherit value"
26762 test_fs_dmv_inherit()
26764 local testdir=$DIR/$tdir
26771 mkdir $testdir || error "mkdir $testdir failed"
26772 count=$($LFS getdirstripe -D -c $testdir)
26773 (( count == 1 )) ||
26774 error "$testdir default LMV count mismatch $count != 1"
26775 inherit=$($LFS getdirstripe -D -X $testdir)
26776 (( inherit == 3 - i )) ||
26777 error "$testdir default LMV max-inherit $inherit != $((3 - i))"
26778 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir)
26779 (( inherit_rr == 3 - i )) ||
26780 error "$testdir default LMV max-inherit-rr $inherit_rr != $((3 - i))"
26781 testdir=$testdir/sub
26784 mkdir $testdir || error "mkdir $testdir failed"
26785 count=$($LFS getdirstripe -D -c $testdir)
26786 (( count == 0 )) ||
26787 error "$testdir default LMV count not zero: $count"
26791 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26793 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26794 skip "Need server version at least 2.14.55"
26796 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26797 error "dump $DIR default LMV failed"
26798 stack_trap "setfattr --restore=$TMP/dmv.ea"
26800 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26801 error "set $DIR default LMV failed"
26803 test_fs_dmv_inherit
26805 run_test 413f "lfs getdirstripe -D list ROOT default LMV if it's not set on dir"
26808 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26810 mkdir -p $DIR/$tdir/l2/l3/l4 || error "mkdir $tdir/l1/l2/l3 failed"
26811 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26812 error "dump $DIR default LMV failed"
26813 stack_trap "setfattr --restore=$TMP/dmv.ea"
26815 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26816 error "set $DIR default LMV failed"
26818 FILESET="$FILESET/$tdir/l2/l3/l4" mount_client $MOUNT2 ||
26819 error "mount $MOUNT2 failed"
26820 stack_trap "umount_client $MOUNT2"
26822 local saved_DIR=$DIR
26826 stack_trap "export DIR=$saved_DIR"
26828 # first check filesystem-wide default LMV inheritance
26829 test_fs_dmv_inherit || error "incorrect fs default LMV inheritance"
26831 # then check subdirs are spread to all MDTs
26832 createmany -d $DIR/s $((MDSCOUNT * 100)) || error "createmany failed"
26834 local count=$($LFS getstripe -m $DIR/s* | sort -u | wc -l)
26836 (( $count == $MDSCOUNT )) || error "dirs are spread to $count MDTs"
26838 run_test 413g "enforce ROOT default LMV on subdir mount"
26841 (( MDSCOUNT >= 2 )) ||
26842 skip "We need at least 2 MDTs for this test"
26844 (( MDS1_VERSION >= $(version_code 2.15.50.6) )) ||
26845 skip "Need server version at least 2.15.50.6"
26847 local lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
26849 stack_trap "$LCTL set_param \
26850 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
26851 $LCTL set_param lmv.*.qos_maxage=1
26855 local dir=$DIR/$tdir/l1/l2/l3/l4/l5
26856 local count=$((MDSCOUNT * 20))
26858 generate_uneven_mdts 50
26860 mkdir -p $dir || error "mkdir $dir failed"
26861 stack_trap "rm -rf $dir"
26862 $LFS setdirstripe -D -c 1 -i -1 --max-inherit=$depth \
26863 --max-inherit-rr=$rr_depth $dir
26865 for ((d=0; d < depth + 2; d++)); do
26867 for ((sub=0; sub < count; sub++)); do
26870 $LFS getdirstripe -i $dir/d* | sort | uniq -c | sort -nr
26871 local num=($($LFS getdirstripe -i $dir/d* | sort | uniq -c))
26872 # subdirs within $rr_depth should be created round-robin
26873 if (( d < rr_depth )); then
26874 (( ${num[0]} != count )) ||
26875 error "all objects created on MDT ${num[1]}"
26881 run_test 413h "don't stick to parent for round-robin dirs"
26888 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
26889 unlinkmany $subdir/f. $TEST413_COUNT &
26893 for pid in $pids; do
26897 run_test 413z "413 test cleanup"
26900 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
26901 $LCTL set_param fail_loc=0x80000521
26902 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
26905 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
26908 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
26909 (( $MDS1_VERSION >= $(version_code 2.11.52) )) ||
26910 skip "Need server version at least 2.11.52"
26916 # this test may be slow on ZFS
26917 [[ "$mds1_FSTYPE" == "zfs" ]] && total=50
26919 # though this test is designed for striped directory, let's test normal
26920 # directory too since lock is always saved as CoS lock.
26921 test_mkdir $DIR/$tdir || error "mkdir $tdir"
26922 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
26923 stack_trap "unlinkmany $DIR/$tdir/$tfile. $total || true"
26924 # if looping with ONLY_REPEAT, wait for previous deletions to finish
26925 wait_delete_completed_mds
26927 # run a loop without concurrent touch to measure rename duration.
26928 # only for test debug/robustness, NOT part of COS functional test.
26929 local start_time=$SECONDS
26930 for ((i = 0; i < total; i++)); do
26931 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
26934 local baseline=$((SECONDS - start_time))
26935 echo "rename $total files without 'touch' took $baseline sec"
26942 local setattr_pid=$!
26944 # rename files back to original name so unlinkmany works
26945 start_time=$SECONDS
26946 for ((i = 0; i < total; i++)); do
26947 mrename $DIR/$tdir/$tfile-new.$i $DIR/$tdir/$tfile.$i\
26950 local duration=$((SECONDS - start_time))
26952 kill -9 $setattr_pid
26954 echo "rename $total files with 'touch' took $duration sec"
26955 (( max > 2 * baseline )) || max=$((2 * baseline + 5))
26956 (( duration <= max )) || error "rename took $duration > $max sec"
26958 run_test 415 "lock revoke is not missing"
26961 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
26962 skip "Need server version at least 2.11.55"
26964 # define OBD_FAIL_OSD_TXN_START 0x19a
26965 do_facet mds1 lctl set_param fail_loc=0x19a
26967 lfs mkdir -c $MDSCOUNT $DIR/$tdir
26971 run_test 416 "transaction start failure won't cause system hung"
26975 do_nodes $(comma_list $(mdts_nodes)) \
26976 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
26977 do_nodes $(comma_list $(mdts_nodes)) \
26978 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
26979 do_nodes $(comma_list $(mdts_nodes)) \
26980 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
26984 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26985 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
26986 skip "Need MDS version at least 2.11.56"
26988 trap cleanup_417 RETURN EXIT
26990 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
26991 do_nodes $(comma_list $(mdts_nodes)) \
26992 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
26993 $LFS migrate -m 0 $DIR/$tdir.1 &&
26994 error "migrate dir $tdir.1 should fail"
26996 do_nodes $(comma_list $(mdts_nodes)) \
26997 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
26998 $LFS mkdir -i 1 $DIR/$tdir.2 &&
26999 error "create remote dir $tdir.2 should fail"
27001 do_nodes $(comma_list $(mdts_nodes)) \
27002 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
27003 $LFS mkdir -c 2 $DIR/$tdir.3 &&
27004 error "create striped dir $tdir.3 should fail"
27007 run_test 417 "disable remote dir, striped dir and dir migration"
27009 # Checks that the outputs of df [-i] and lfs df [-i] match
27011 # usage: check_lfs_df <blocks | inodes> <mountpoint>
27021 [ "$1" == "blocks" ] && inodes= || inodes="-i"
27023 for count in {1..100}; do
27024 do_nodes "$CLIENTS" \
27025 $LCTL set_param ldlm.namespaces.*.lru_size=clear
27028 # read the lines of interest
27029 df_out=($(df -P $inodes $dir | tail -n +2)) ||
27030 error "df $inodes $dir | tail -n +2 failed"
27031 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
27032 error "lfs df $inodes $dir | grep summary: failed"
27034 # skip first substrings of each output as they are different
27035 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
27036 # compare the two outputs
27038 # skip "available" on MDT until LU-13997 is fixed.
27039 #for i in {1..5}; do
27040 for i in 1 2 4 5; do
27041 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
27049 lfs df $inodes $dir
27050 error "df and lfs df $1 output mismatch: " \
27051 "df ${inodes}: ${df_out[*]}, " \
27052 "lfs df ${inodes}: ${lfs_df_out[*]}"
27057 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27059 local dir=$DIR/$tdir
27060 local numfiles=$((RANDOM % 4096 + 2))
27061 local numblocks=$((RANDOM % 256 + 1))
27063 wait_delete_completed
27066 # check block output
27067 check_lfs_df blocks $dir
27068 # check inode output
27069 check_lfs_df inodes $dir
27071 # create a single file and retest
27072 echo "Creating a single file and testing"
27073 createmany -o $dir/$tfile- 1 &>/dev/null ||
27074 error "creating 1 file in $dir failed"
27075 check_lfs_df blocks $dir
27076 check_lfs_df inodes $dir
27078 # create a random number of files
27079 echo "Creating $((numfiles - 1)) files and testing"
27080 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
27081 error "creating $((numfiles - 1)) files in $dir failed"
27083 # write a random number of blocks to the first test file
27084 echo "Writing $numblocks 4K blocks and testing"
27085 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
27086 count=$numblocks &>/dev/null ||
27087 error "dd to $dir/${tfile}-0 failed"
27090 check_lfs_df blocks $dir
27091 check_lfs_df inodes $dir
27093 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
27094 error "unlinking $numfiles files in $dir failed"
27096 run_test 418 "df and lfs df outputs match"
27100 local dir=$DIR/$tdir
27105 cancel_lru_locks mdc
27107 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
27108 $LCTL set_param fail_loc=0x1410
27110 $LCTL set_param fail_loc=0
27113 run_test 419 "Verify open file by name doesn't crash kernel"
27117 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
27118 skip "Need MDS version at least 2.12.53"
27120 local SAVE_UMASK=$(umask)
27121 local dir=$DIR/$tdir
27122 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
27126 mkdir -m03777 $dir/testdir
27127 ls -dn $dir/testdir
27128 # Need to remove trailing '.' when SELinux is enabled
27129 local dirperms=$(ls -dn $dir/testdir |
27130 awk '{ sub(/\.$/, "", $1); print $1}')
27131 [ $dirperms == "drwxrwsrwt" ] ||
27132 error "incorrect perms on $dir/testdir"
27134 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
27135 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
27136 ls -n $dir/testdir/testfile
27137 local fileperms=$(ls -n $dir/testdir/testfile |
27138 awk '{ sub(/\.$/, "", $1); print $1}')
27139 [ $fileperms == "-rwxr-xr-x" ] ||
27140 error "incorrect perms on $dir/testdir/testfile"
27144 run_test 420 "clear SGID bit on non-directories for non-members"
27151 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27152 skip "Need MDS version at least 2.12.54"
27154 test_mkdir $DIR/$tdir
27155 createmany -o $DIR/$tdir/f 3
27156 cnt=$(ls -1 $DIR/$tdir | wc -l)
27157 [ $cnt != 3 ] && error "unexpected #files: $cnt"
27159 fid1=$(lfs path2fid $DIR/$tdir/f1)
27160 fid2=$(lfs path2fid $DIR/$tdir/f2)
27161 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
27163 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
27164 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
27166 cnt=$(ls -1 $DIR/$tdir | wc -l)
27167 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
27169 rm -f $DIR/$tdir/f3 || error "can't remove f3"
27170 createmany -o $DIR/$tdir/f 3
27171 cnt=$(ls -1 $DIR/$tdir | wc -l)
27172 [ $cnt != 3 ] && error "unexpected #files: $cnt"
27174 fid1=$(lfs path2fid $DIR/$tdir/f1)
27175 fid2=$(lfs path2fid $DIR/$tdir/f2)
27176 echo "remove using fsname $FSNAME"
27177 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
27179 cnt=$(ls -1 $DIR/$tdir | wc -l)
27180 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
27182 run_test 421a "simple rm by fid"
27189 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27190 skip "Need MDS version at least 2.12.54"
27192 test_mkdir $DIR/$tdir
27193 createmany -o $DIR/$tdir/f 3
27194 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
27197 FID1=$(lfs path2fid $DIR/$tdir/f1)
27198 FID2=$(lfs path2fid $DIR/$tdir/f2)
27199 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
27201 kill -USR1 $MULTIPID
27204 cnt=$(ls $DIR/$tdir | wc -l)
27205 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
27207 run_test 421b "rm by fid on open file"
27213 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27214 skip "Need MDS version at least 2.12.54"
27216 test_mkdir $DIR/$tdir
27217 createmany -o $DIR/$tdir/f 3
27218 touch $DIR/$tdir/$tfile
27219 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
27220 cnt=$(ls -1 $DIR/$tdir | wc -l)
27221 [ $cnt != 184 ] && error "unexpected #files: $cnt"
27223 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
27224 $LFS rmfid $DIR $FID1 || error "rmfid failed"
27226 cnt=$(ls $DIR/$tdir | wc -l)
27227 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
27229 run_test 421c "rm by fid against hardlinked files"
27235 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27236 skip "Need MDS version at least 2.12.54"
27238 test_mkdir $DIR/$tdir
27239 createmany -o $DIR/$tdir/f 4097
27240 cnt=$(ls -1 $DIR/$tdir | wc -l)
27241 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
27243 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
27244 $LFS rmfid $DIR $FIDS || error "rmfid failed"
27246 cnt=$(ls $DIR/$tdir | wc -l)
27248 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
27250 run_test 421d "rmfid en masse"
27256 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
27257 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27258 skip "Need MDS version at least 2.12.54"
27260 mkdir -p $DIR/$tdir
27261 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
27262 createmany -o $DIR/$tdir/striped_dir/f 512
27263 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
27264 [ $cnt != 512 ] && error "unexpected #files: $cnt"
27266 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
27267 sed "s/[/][^:]*://g")
27268 $LFS rmfid $DIR $FIDS || error "rmfid failed"
27270 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
27272 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
27274 run_test 421e "rmfid in DNE"
27280 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27281 skip "Need MDS version at least 2.12.54"
27283 test_mkdir $DIR/$tdir
27285 cnt=$(ls -1 $DIR/$tdir | wc -l)
27286 [ $cnt != 1 ] && error "unexpected #files: $cnt"
27288 FID=$(lfs path2fid $DIR/$tdir/f)
27289 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
27290 # rmfid should fail
27291 cnt=$(ls -1 $DIR/$tdir | wc -l)
27292 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
27294 chmod a+rw $DIR/$tdir
27296 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
27297 # rmfid should fail
27298 cnt=$(ls -1 $DIR/$tdir | wc -l)
27299 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
27302 $RUNAS touch $DIR/$tdir/f
27303 FID=$(lfs path2fid $DIR/$tdir/f)
27304 echo "rmfid as root"
27305 $LFS rmfid $DIR $FID || error "rmfid as root failed"
27306 cnt=$(ls -1 $DIR/$tdir | wc -l)
27307 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
27310 $RUNAS touch $DIR/$tdir/f
27311 cnt=$(ls -1 $DIR/$tdir | wc -l)
27312 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
27313 FID=$(lfs path2fid $DIR/$tdir/f)
27314 # rmfid w/o user_fid2path mount option should fail
27315 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
27316 cnt=$(ls -1 $DIR/$tdir | wc -l)
27317 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
27319 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
27320 stack_trap "rmdir $tmpdir"
27321 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
27322 error "failed to mount client'"
27323 stack_trap "umount_client $tmpdir"
27325 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
27326 # rmfid should succeed
27327 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
27328 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
27330 # rmfid shouldn't allow to remove files due to dir's permission
27331 chmod a+rwx $tmpdir/$tdir
27332 touch $tmpdir/$tdir/f
27333 ls -la $tmpdir/$tdir
27334 FID=$(lfs path2fid $tmpdir/$tdir/f)
27335 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
27338 run_test 421f "rmfid checks permissions"
27344 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
27345 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27346 skip "Need MDS version at least 2.12.54"
27348 mkdir -p $DIR/$tdir
27349 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
27350 createmany -o $DIR/$tdir/striped_dir/f 512
27351 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
27352 [ $cnt != 512 ] && error "unexpected #files: $cnt"
27354 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
27355 sed "s/[/][^:]*://g")
27357 rm -f $DIR/$tdir/striped_dir/f1*
27358 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
27359 removed=$((512 - cnt))
27361 # few files have been just removed, so we expect
27362 # rmfid to fail on their fids
27363 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
27364 [ $removed != $errors ] && error "$errors != $removed"
27366 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
27368 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
27370 run_test 421g "rmfid to return errors properly"
27373 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
27374 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
27375 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
27376 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
27377 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
27379 local amc=$(at_max_get client)
27380 local amo=$(at_max_get mds1)
27381 local timeout=`lctl get_param -n timeout`
27383 at_max_set 0 client
27386 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
27387 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
27388 fail_val=$(((2*timeout + 10)*1000))
27389 touch $DIR/$tdir/d3/file &
27391 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
27392 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
27393 fail_val=$((2*timeout + 5))
27394 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
27398 sleep $((2 * timeout))
27402 touch $DIR/$tdir/d2/file3
27403 touch $DIR/$tdir/d2/file4
27404 touch $DIR/$tdir/d2/file5
27407 at_max_set $amc client
27408 at_max_set $amo mds1
27410 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
27411 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
27412 error "Watchdog is always throttled"
27414 run_test 422 "kill a process with RPC in progress"
27427 # ensure statfs cache is expired
27430 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
27431 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
27435 run_test 423 "statfs should return a right data"
27438 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
27439 $LCTL set_param fail_loc=0x80000522
27440 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
27443 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
27446 test_mkdir -c -1 $DIR/$tdir
27447 $LFS setstripe -c -1 $DIR/$tdir
27449 lru_resize_disable "" 100
27450 stack_trap "lru_resize_enable" EXIT
27454 for i in $(seq $((MDSCOUNT * 125))); do
27455 local t=$DIR/$tdir/$tfile_$i
27457 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
27458 error_noexit "Create file $t"
27460 stack_trap "rm -rf $DIR/$tdir" EXIT
27462 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
27463 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
27464 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
27466 [ $lock_count -le $lru_size ] ||
27467 error "osc lock count $lock_count > lru size $lru_size"
27470 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
27471 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
27472 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
27474 [ $lock_count -le $lru_size ] ||
27475 error "mdc lock count $lock_count > lru size $lru_size"
27478 run_test 425 "lock count should not exceed lru size"
27481 splice-test -r $DIR/$tfile
27482 splice-test -rd $DIR/$tfile
27483 splice-test $DIR/$tfile
27484 splice-test -d $DIR/$tfile
27486 run_test 426 "splice test on Lustre"
27489 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
27490 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
27491 skip "Need MDS version at least 2.12.4"
27497 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
27498 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
27500 $LFS getdirstripe $DIR/$tdir/1/dir
27502 #first setfattr for creating updatelog
27503 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
27505 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
27506 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
27507 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
27508 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
27512 wait_recovery_complete mds2 $((2*TIMEOUT))
27514 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
27515 echo $log | grep "get update log failed" &&
27516 error "update log corruption is detected" || true
27518 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
27521 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27522 local cache_limit=$CACHE_MAX
27524 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$cache_limit"
27525 $LCTL set_param -n llite.*.max_cached_mb=64
27528 $LFS setstripe -c 1 $DIR/$tdir
27529 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
27530 stack_trap "rm -f $DIR/$tdir/$tfile.*"
27532 for f in $(seq 4); do
27533 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
27537 cancel_lru_locks osc
27539 for f in $(seq 4); do
27540 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
27544 run_test 428 "large block size IO should not hang"
27546 test_429() { # LU-7915 / LU-10948
27547 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
27548 local testfile=$DIR/$tfile
27549 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
27555 $LCTL get_param $ll_opencache_threshold_count ||
27556 skip "client does not have opencache parameter"
27558 set_opencache $new_flag
27559 stack_trap "restore_opencache"
27560 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
27561 error "enable opencache failed"
27563 # drop MDC DLM locks
27564 cancel_lru_locks mdc
27565 # clear MDC RPC stats counters
27566 $LCTL set_param $mdc_rpcstats=clear
27568 # According to the current implementation, we need to run 3 times
27569 # open & close file to verify if opencache is enabled correctly.
27570 # 1st, RPCs are sent for lookup/open and open handle is released on
27572 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
27573 # so open handle won't be released thereafter.
27574 # 3rd, No RPC is sent out.
27575 $MULTIOP $testfile oc || error "multiop failed"
27576 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27577 echo "1st: $first_rpc RPCs in flight"
27579 $MULTIOP $testfile oc || error "multiop failed"
27580 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27581 echo "2nd: $second_rpc RPCs in flight"
27583 $MULTIOP $testfile oc || error "multiop failed"
27584 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27585 echo "3rd: $third_rpc RPCs in flight"
27587 #verify no MDC RPC is sent
27588 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
27590 run_test 429 "verify if opencache flag on client side does work"
27596 # data at [200K, 400K)
27597 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
27598 error "256K->512K dd fails"
27600 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
27601 error "2M->3M dd fails"
27603 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
27604 error "4M->5M dd fails"
27605 echo "Data at 256K...512K, 2M...3M and 4M...5M"
27606 # start at first component hole #1
27607 printf "Seeking hole from 1000 ... "
27608 offset=$(lseek_test -l 1000 $file)
27610 [[ $offset == 1000 ]] || error "offset $offset != 1000"
27611 printf "Seeking data from 1000 ... "
27612 offset=$(lseek_test -d 1000 $file)
27614 [[ $offset == 262144 ]] || error "offset $offset != 262144"
27616 # start at first component data block
27617 printf "Seeking hole from 300000 ... "
27618 offset=$(lseek_test -l 300000 $file)
27620 [[ $offset == 524288 ]] || error "offset $offset != 524288"
27621 printf "Seeking data from 300000 ... "
27622 offset=$(lseek_test -d 300000 $file)
27624 [[ $offset == 300000 ]] || error "offset $offset != 300000"
27626 # start at the first component but beyond end of object size
27627 printf "Seeking hole from 1000000 ... "
27628 offset=$(lseek_test -l 1000000 $file)
27630 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27631 printf "Seeking data from 1000000 ... "
27632 offset=$(lseek_test -d 1000000 $file)
27634 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
27636 # start at second component stripe 2 (empty file)
27637 printf "Seeking hole from 1500000 ... "
27638 offset=$(lseek_test -l 1500000 $file)
27640 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
27641 printf "Seeking data from 1500000 ... "
27642 offset=$(lseek_test -d 1500000 $file)
27644 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
27646 # start at second component stripe 1 (all data)
27647 printf "Seeking hole from 3000000 ... "
27648 offset=$(lseek_test -l 3000000 $file)
27650 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
27651 printf "Seeking data from 3000000 ... "
27652 offset=$(lseek_test -d 3000000 $file)
27654 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
27656 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
27657 error "2nd dd fails"
27658 echo "Add data block at 640K...1280K"
27660 # start at before new data block, in hole
27661 printf "Seeking hole from 600000 ... "
27662 offset=$(lseek_test -l 600000 $file)
27664 [[ $offset == 600000 ]] || error "offset $offset != 600000"
27665 printf "Seeking data from 600000 ... "
27666 offset=$(lseek_test -d 600000 $file)
27668 [[ $offset == 655360 ]] || error "offset $offset != 655360"
27670 # start at the first component new data block
27671 printf "Seeking hole from 1000000 ... "
27672 offset=$(lseek_test -l 1000000 $file)
27674 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
27675 printf "Seeking data from 1000000 ... "
27676 offset=$(lseek_test -d 1000000 $file)
27678 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27680 # start at second component stripe 2, new data
27681 printf "Seeking hole from 1200000 ... "
27682 offset=$(lseek_test -l 1200000 $file)
27684 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
27685 printf "Seeking data from 1200000 ... "
27686 offset=$(lseek_test -d 1200000 $file)
27688 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
27690 # start beyond file end
27691 printf "Using offset > filesize ... "
27692 lseek_test -l 4000000 $file && error "lseek should fail"
27693 printf "Using offset > filesize ... "
27694 lseek_test -d 4000000 $file && error "lseek should fail"
27700 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
27701 skip "MDT does not support SEEK_HOLE"
27703 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27704 skip "OST does not support SEEK_HOLE"
27706 local file=$DIR/$tdir/$tfile
27708 mkdir -p $DIR/$tdir
27710 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
27711 # OST stripe #1 will have continuous data at [1M, 3M)
27712 # OST stripe #2 is empty
27713 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
27714 lseek_test_430 $file
27716 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
27717 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
27718 lseek_test_430 $file
27720 $LFS setstripe -c2 -S 512K $file
27721 echo "Two stripes, stripe size 512K"
27722 lseek_test_430 $file
27724 # FLR with stale mirror
27725 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
27727 echo "Mirrored file:"
27728 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
27729 echo "Plain 2 stripes 1M"
27730 lseek_test_430 $file
27733 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
27736 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27737 skip "OST does not support SEEK_HOLE"
27740 local file=$DIR/$tdir/$tfile
27742 mkdir -p $DIR/$tdir
27743 # Empty layout lseek should fail
27746 printf "Seeking hole from 0 ... "
27747 lseek_test -l 0 $file && error "lseek should fail"
27748 printf "Seeking data from 0 ... "
27749 lseek_test -d 0 $file && error "lseek should fail"
27753 $LFS setstripe -E 1M -c2 -E eof $file
27754 $TRUNCATE $file 1048576
27755 printf "Seeking hole from 1000000 ... "
27756 offset=$(lseek_test -l 1000000 $file)
27758 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27759 printf "Seeking data from 1000000 ... "
27760 lseek_test -d 1000000 $file && error "lseek should fail"
27763 # full component followed by non-inited one
27764 $LFS setstripe -E 1M -c2 -E eof $file
27765 dd if=/dev/urandom of=$file bs=1M count=1
27766 printf "Seeking hole from 1000000 ... "
27767 offset=$(lseek_test -l 1000000 $file)
27769 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27770 printf "Seeking hole from 1048576 ... "
27771 lseek_test -l 1048576 $file && error "lseek should fail"
27772 # init second component and truncate back
27773 echo "123" >> $file
27774 $TRUNCATE $file 1048576
27775 printf "Seeking hole from 1000000 ... "
27776 offset=$(lseek_test -l 1000000 $file)
27778 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27779 printf "Seeking hole from 1048576 ... "
27780 lseek_test -l 1048576 $file && error "lseek should fail"
27781 # boundary checks for big values
27782 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
27783 offset=$(lseek_test -d 0 $file.10g)
27784 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
27785 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
27786 offset=$(lseek_test -d 0 $file.100g)
27787 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
27790 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
27793 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27794 skip "OST does not support SEEK_HOLE"
27796 local file=$DIR/$tdir/$tfile
27799 mkdir -p $DIR/$tdir
27800 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M
27802 # cp version 8.33+ prefers lseek over fiemap
27803 if [[ $(cp --version | head -n1 | sed "s/[^0-9]//g") -ge 833 ]]; then
27805 time cp $file /dev/null
27806 (( SECONDS - start < 5 )) ||
27807 error "cp: too long runtime $((SECONDS - start))"
27810 # tar version 1.29+ supports SEEK_HOLE/DATA
27811 if [[ $(tar --version | head -n1 | sed "s/[^0-9]//g") -ge 129 ]]; then
27813 time tar cS $file - | cat > /dev/null
27814 (( SECONDS - start < 5 )) ||
27815 error "tar: too long runtime $((SECONDS - start))"
27818 run_test 430c "lseek: external tools check"
27820 test_431() { # LU-14187
27821 local file=$DIR/$tdir/$tfile
27823 mkdir -p $DIR/$tdir
27824 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
27825 dd if=/dev/urandom of=$file bs=4k count=1
27826 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
27827 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
27828 #define OBD_FAIL_OST_RESTART_IO 0x251
27829 do_facet ost1 "$LCTL set_param fail_loc=0x251"
27830 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
27834 echo 3 > /proc/sys/vm/drop_caches
27835 diff $file $file.0 || error "data diff"
27837 run_test 431 "Restart transaction for IO"
27839 cleanup_test_432() {
27840 do_facet mgs $LCTL nodemap_activate 0
27841 wait_nm_sync active
27845 local tmpdir=$TMP/dir432
27847 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
27848 skip "Need MDS version at least 2.14.52"
27850 stack_trap cleanup_test_432 EXIT
27854 do_facet mgs $LCTL nodemap_activate 1
27855 wait_nm_sync active
27856 do_facet mgs $LCTL nodemap_modify --name default \
27857 --property admin --value 1
27858 do_facet mgs $LCTL nodemap_modify --name default \
27859 --property trusted --value 1
27860 cancel_lru_locks mdc
27861 wait_nm_sync default admin_nodemap
27862 wait_nm_sync default trusted_nodemap
27864 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
27865 grep -ci "Operation not permitted") -ne 0 ]; then
27866 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
27869 run_test 432 "mv dir from outside Lustre"
27872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27874 [[ -n "$($LCTL list_param llite.*.inode_cache 2>/dev/null)" ]] ||
27875 skip "inode cache not supported"
27877 $LCTL set_param llite.*.inode_cache=0
27878 stack_trap "$LCTL set_param llite.*.inode_cache=1"
27884 cancel_lru_locks mdc
27885 test_mkdir $DIR/$tdir || error "mkdir $tdir"
27886 createmany -m $DIR/$tdir/f $count
27887 createmany -d $DIR/$tdir/d $count
27888 ls -l $DIR/$tdir > /dev/null
27889 stack_trap "rm -rf $DIR/$tdir"
27891 before=$(num_objects)
27892 cancel_lru_locks mdc
27893 after=$(num_objects)
27895 # sometimes even @before is less than 2 * count
27896 while (( before - after < count )); do
27898 after=$(num_objects)
27900 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
27901 if (( wait > 60 )); then
27902 error "inode slab grew from $before to $after"
27906 echo "lustre_inode_cache $before objs before lock cancel, $after after"
27908 run_test 433 "ldlm lock cancel releases dentries and inodes"
27912 local getxattr_count
27913 local mdc_stat_param="mdc.$FSNAME-MDT0000*.md_stats"
27914 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
27916 [[ $(getenforce) == "Disabled" ]] ||
27917 skip "lsm selinux module have to be disabled for this test"
27919 test_mkdir -i 0 -c1 $DIR/$tdir/ ||
27920 error "fail to create $DIR/$tdir/ on MDT0000"
27922 touch $DIR/$tdir/$tfile-{001..100}
27924 # disable the xattr cache
27925 save_lustre_params client "llite.*.xattr_cache" > $p
27926 lctl set_param llite.*.xattr_cache=0
27927 stack_trap "restore_lustre_params < $p; rm -f $p" EXIT
27929 # clear clients mdc stats
27930 clear_stats $mdc_stat_param ||
27931 error "fail to clear stats on mdc MDT0000"
27933 for file in $DIR/$tdir/$tfile-{001..100}; do
27934 getfattr -n security.selinux $file |&
27935 grep -q "Operation not supported" ||
27936 error "getxattr on security.selinux should return EOPNOTSUPP"
27939 getxattr_count=$(calc_stats $mdc_stat_param "getxattr")
27940 (( getxattr_count < 100 )) ||
27941 error "client sent $getxattr_count getxattr RPCs to the MDS"
27943 run_test 434 "Client should not send RPCs for security.selinux with SElinux disabled"
27946 if [[ -f $LUSTRE/scripts/bash-completion/lustre ]]; then
27947 source $LUSTRE/scripts/bash-completion/lustre
27948 elif [[ -f /usr/share/bash-completion/completions/lustre ]]; then
27949 source /usr/share/bash-completion/completions/lustre
27951 skip "bash completion scripts not found"
27954 local lctl_completions
27955 local lfs_completions
27957 lctl_completions=$(_lustre_cmds lctl)
27958 if [[ ! $lctl_completions =~ "get_param" ]]; then
27959 error "lctl bash completion failed"
27962 lfs_completions=$(_lustre_cmds lfs)
27963 if [[ ! $lfs_completions =~ "setstripe" ]]; then
27964 error "lfs bash completion failed"
27967 run_test 440 "bash completion for lfs, lctl"
27970 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
27971 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
27972 skip "Need server version at least 2.9.55"
27974 start_full_debug_logging
27978 stop_full_debug_logging
27982 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27983 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27984 awk '/The barrier for/ { print $7 }')
27987 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
27992 barrier_expired() {
27995 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27996 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27997 awk '/will be expired/ { print $7 }')
27999 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
28008 echo "Start barrier_freeze at: $(date)"
28009 #define OBD_FAIL_BARRIER_DELAY 0x2202
28010 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
28011 # Do not reduce barrier time - See LU-11873
28012 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
28015 local b_status=$(barrier_stat)
28016 echo "Got barrier status at: $(date)"
28017 [ "$b_status" = "'freezing_p1'" ] ||
28018 error "(1) unexpected barrier status $b_status"
28020 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
28022 b_status=$(barrier_stat)
28023 [ "$b_status" = "'frozen'" ] ||
28024 error "(2) unexpected barrier status $b_status"
28026 local expired=$(barrier_expired)
28027 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
28028 sleep $((expired + 3))
28030 b_status=$(barrier_stat)
28031 [ "$b_status" = "'expired'" ] ||
28032 error "(3) unexpected barrier status $b_status"
28034 # Do not reduce barrier time - See LU-11873
28035 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
28036 error "(4) fail to freeze barrier"
28038 b_status=$(barrier_stat)
28039 [ "$b_status" = "'frozen'" ] ||
28040 error "(5) unexpected barrier status $b_status"
28042 echo "Start barrier_thaw at: $(date)"
28043 #define OBD_FAIL_BARRIER_DELAY 0x2202
28044 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
28045 do_facet mgs $LCTL barrier_thaw $FSNAME &
28048 b_status=$(barrier_stat)
28049 echo "Got barrier status at: $(date)"
28050 [ "$b_status" = "'thawing'" ] ||
28051 error "(6) unexpected barrier status $b_status"
28053 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
28055 b_status=$(barrier_stat)
28056 [ "$b_status" = "'thawed'" ] ||
28057 error "(7) unexpected barrier status $b_status"
28059 #define OBD_FAIL_BARRIER_FAILURE 0x2203
28060 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
28061 do_facet mgs $LCTL barrier_freeze $FSNAME
28063 b_status=$(barrier_stat)
28064 [ "$b_status" = "'failed'" ] ||
28065 error "(8) unexpected barrier status $b_status"
28067 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
28068 do_facet mgs $LCTL barrier_thaw $FSNAME
28072 run_test 801a "write barrier user interfaces and stat machine"
28077 mkdir $DIR/$tdir || error "(1) fail to mkdir"
28078 createmany -d $DIR/$tdir/d 6 || error "(2) fail to mkdir"
28079 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
28080 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
28081 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
28083 cancel_lru_locks mdc
28085 # 180 seconds should be long enough
28086 do_facet mgs $LCTL barrier_freeze $FSNAME 180
28088 local b_status=$(barrier_stat)
28089 [ "$b_status" = "'frozen'" ] ||
28090 error "(6) unexpected barrier status $b_status"
28092 mkdir $DIR/$tdir/d0/d10 &
28095 touch $DIR/$tdir/d1/f13 &
28098 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
28101 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
28104 rm -f $DIR/$tdir/d4/f12 &
28107 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
28109 # To guarantee taht the 'stat' is not blocked
28110 b_status=$(barrier_stat)
28111 [ "$b_status" = "'frozen'" ] ||
28112 error "(8) unexpected barrier status $b_status"
28114 # let above commands to run at background
28117 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
28118 ps -p $touch_pid || error "(10) touch should be blocked"
28119 ps -p $ln_pid || error "(11) link should be blocked"
28120 ps -p $mv_pid || error "(12) rename should be blocked"
28121 ps -p $rm_pid || error "(13) unlink should be blocked"
28123 b_status=$(barrier_stat)
28124 [ "$b_status" = "'frozen'" ] ||
28125 error "(14) unexpected barrier status $b_status"
28127 do_facet mgs $LCTL barrier_thaw $FSNAME
28128 b_status=$(barrier_stat)
28129 [ "$b_status" = "'thawed'" ] ||
28130 error "(15) unexpected barrier status $b_status"
28132 wait $mkdir_pid || error "(16) mkdir should succeed"
28133 wait $touch_pid || error "(17) touch should succeed"
28134 wait $ln_pid || error "(18) link should succeed"
28135 wait $mv_pid || error "(19) rename should succeed"
28136 wait $rm_pid || error "(20) unlink should succeed"
28140 run_test 801b "modification will be blocked by write barrier"
28143 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28147 stop mds2 || error "(1) Fail to stop mds2"
28149 do_facet mgs $LCTL barrier_freeze $FSNAME 30
28151 local b_status=$(barrier_stat)
28152 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
28153 do_facet mgs $LCTL barrier_thaw $FSNAME
28154 error "(2) unexpected barrier status $b_status"
28157 do_facet mgs $LCTL barrier_rescan $FSNAME ||
28158 error "(3) Fail to rescan barrier bitmap"
28160 # Do not reduce barrier time - See LU-11873
28161 do_facet mgs $LCTL barrier_freeze $FSNAME 20
28163 b_status=$(barrier_stat)
28164 [ "$b_status" = "'frozen'" ] ||
28165 error "(4) unexpected barrier status $b_status"
28167 do_facet mgs $LCTL barrier_thaw $FSNAME
28168 b_status=$(barrier_stat)
28169 [ "$b_status" = "'thawed'" ] ||
28170 error "(5) unexpected barrier status $b_status"
28172 local devname=$(mdsdevname 2)
28174 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
28176 do_facet mgs $LCTL barrier_rescan $FSNAME ||
28177 error "(7) Fail to rescan barrier bitmap"
28181 run_test 801c "rescan barrier bitmap"
28184 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28185 remote_mds_nodsh && skip "remote MDS with nodsh"
28187 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
28188 skip "readonly option not available"
28190 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
28192 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
28193 error "(2) Fail to copy"
28195 # write back all cached data before setting MDT to readonly
28199 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
28200 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
28202 echo "Modify should be refused"
28203 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
28205 echo "Read should be allowed"
28206 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
28207 error "(7) Read should succeed under ro mode"
28210 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
28212 run_test 802b "be able to set MDTs to readonly"
28215 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28216 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
28217 skip "MDS needs to be newer than 2.10.54"
28219 mkdir_on_mdt0 $DIR/$tdir
28220 # Create some objects on all MDTs to trigger related logs objects
28221 for idx in $(seq $MDSCOUNT); do
28222 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
28223 $DIR/$tdir/dir${idx} ||
28224 error "Fail to create $DIR/$tdir/dir${idx}"
28227 wait_delete_completed # ensure old test cleanups are finished
28229 echo "before create:"
28231 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
28233 for i in {1..10}; do
28234 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
28235 error "Fail to create $DIR/$tdir/foo$i"
28238 # sync ZFS-on-MDS to refresh statfs data
28239 wait_zfs_commit mds1
28241 echo "after create:"
28243 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
28245 # allow for an llog to be cleaned up during the test
28246 [ $after_used -ge $((before_used + 10 - 1)) ] ||
28247 error "before ($before_used) + 10 > after ($after_used)"
28249 for i in {1..10}; do
28250 rm -rf $DIR/$tdir/foo$i ||
28251 error "Fail to remove $DIR/$tdir/foo$i"
28254 # sync ZFS-on-MDS to refresh statfs data
28255 wait_zfs_commit mds1
28256 wait_delete_completed
28257 sleep 3 # avoid MDT return cached statfs
28258 echo "after unlink:"
28260 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
28262 # allow for an llog to be created during the test
28263 [ $after_used -le $((before_used + 1)) ] ||
28264 error "after ($after_used) > before ($before_used) + 1"
28266 run_test 803a "verify agent object for remote object"
28269 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28270 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
28271 skip "MDS needs to be newer than 2.13.56"
28272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28274 for i in $(seq 0 $((MDSCOUNT - 1))); do
28275 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
28283 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
28284 for i in $(seq 0 $((MDSCOUNT - 1))); do
28285 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
28286 awk '/getattr/ { print $2 }')
28287 before=$((before + tmp))
28289 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
28290 for i in $(seq 0 $((MDSCOUNT - 1))); do
28291 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
28292 awk '/getattr/ { print $2 }')
28293 after=$((after + tmp))
28296 [ $before -eq $after ] || error "getattr count $before != $after"
28298 run_test 803b "remote object can getattr from cache"
28301 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28302 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
28303 skip "MDS needs to be newer than 2.10.54"
28304 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
28306 mkdir -p $DIR/$tdir
28307 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
28308 error "Fail to create $DIR/$tdir/dir0"
28310 local fid=$($LFS path2fid $DIR/$tdir/dir0)
28311 local dev=$(mdsdevname 2)
28313 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
28314 grep ${fid} || error "NOT found agent entry for dir0"
28316 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
28317 error "Fail to create $DIR/$tdir/dir1"
28319 touch $DIR/$tdir/dir1/foo0 ||
28320 error "Fail to create $DIR/$tdir/dir1/foo0"
28321 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
28324 for idx in $(seq $MDSCOUNT); do
28325 dev=$(mdsdevname $idx)
28326 do_facet mds${idx} \
28327 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
28328 grep ${fid} && rc=$idx
28331 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
28332 error "Fail to rename foo0 to foo1"
28333 if [ $rc -eq 0 ]; then
28334 for idx in $(seq $MDSCOUNT); do
28335 dev=$(mdsdevname $idx)
28336 do_facet mds${idx} \
28337 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
28338 grep ${fid} && rc=$idx
28342 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
28343 error "Fail to rename foo1 to foo2"
28344 if [ $rc -eq 0 ]; then
28345 for idx in $(seq $MDSCOUNT); do
28346 dev=$(mdsdevname $idx)
28347 do_facet mds${idx} \
28348 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
28349 grep ${fid} && rc=$idx
28353 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
28355 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
28356 error "Fail to link to $DIR/$tdir/dir1/foo2"
28357 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
28358 error "Fail to rename foo2 to foo0"
28359 unlink $DIR/$tdir/dir1/foo0 ||
28360 error "Fail to unlink $DIR/$tdir/dir1/foo0"
28361 rm -rf $DIR/$tdir/dir0 ||
28362 error "Fail to rm $DIR/$tdir/dir0"
28364 for idx in $(seq $MDSCOUNT); do
28368 dev=$(mdsdevname $idx)
28369 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
28371 start mds${idx} $dev $MDS_MOUNT_OPTS ||
28372 error "mount mds$idx failed"
28373 df $MOUNT > /dev/null 2>&1
28375 # e2fsck should not return error
28377 error "e2fsck detected error on MDT${idx}: rc=$rc"
28380 run_test 804 "verify agent entry for remote entry"
28383 do_facet $SINGLEMDS zfs set quota=$old $fsset
28384 unlinkmany $DIR/$tdir/f- 1000000
28389 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
28390 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
28391 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
28392 skip "netfree not implemented before 0.7"
28393 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
28394 skip "Need MDS version at least 2.10.57"
28401 local pref="osd-zfs.$FSNAME-MDT0000."
28403 # limit available space on MDS dataset to meet nospace issue
28404 # quickly. then ZFS 0.7.2 can use reserved space if asked
28405 # properly (using netfree flag in osd_declare_destroy()
28406 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
28407 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
28409 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
28410 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
28411 let "usedkb=usedkb-freekb"
28412 let "freekb=freekb/2"
28413 if let "freekb > 5000"; then
28416 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
28417 trap cleanup_805 EXIT
28418 mkdir_on_mdt0 $DIR/$tdir
28419 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
28420 error "Can't set PFL layout"
28421 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
28422 rm -rf $DIR/$tdir || error "not able to remove"
28423 do_facet $SINGLEMDS zfs set quota=$old $fsset
28426 run_test 805 "ZFS can remove from full fs"
28432 local expect=$(stat -c %s $file)
28434 check_lsom_size $1 $expect
28436 local blocks=$($LFS getsom -b $file)
28437 expect=$(stat -c %b $file)
28438 [[ $blocks == $expect ]] ||
28439 error "$file expected blocks: $expect, got: $blocks"
28447 cancel_lru_locks mdc
28449 size=$($LFS getsom -s $1)
28450 [[ $size == $expect ]] ||
28451 error "$file expected size: $expect, got: $size"
28455 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
28456 skip "Need MDS version at least 2.11.52"
28460 touch $DIR/$tfile || error "touch $tfile failed"
28462 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
28463 save_lustre_params client "llite.*.xattr_cache" > $save
28464 lctl set_param llite.*.xattr_cache=0
28465 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
28467 # single-threaded write
28468 echo "Test SOM for single-threaded write"
28469 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
28470 error "write $tfile failed"
28471 check_lsom_size $DIR/$tfile $bs
28474 local size=$(($num * $bs))
28478 echo "Test SOM for single client multi-threaded($num) write"
28479 $TRUNCATE $DIR/$tfile 0
28480 for ((i = 0; i < $num; i++)); do
28481 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28483 offset=$((offset + $bs))
28485 for (( i=0; i < $num; i++ )); do
28488 check_lsom_size $DIR/$tfile $size
28490 $TRUNCATE $DIR/$tfile 0
28491 for ((i = 0; i < $num; i++)); do
28492 offset=$((offset - $bs))
28493 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28496 for (( i=0; i < $num; i++ )); do
28499 check_lsom_size $DIR/$tfile $size
28501 # multi-client writes
28502 num=$(get_node_count ${CLIENTS//,/ })
28503 size=$(($num * $bs))
28507 echo "Test SOM for multi-client ($num) writes"
28508 $TRUNCATE $DIR/$tfile 0
28509 for client in ${CLIENTS//,/ }; do
28510 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28513 offset=$((offset + $bs))
28515 for (( i=0; i < $num; i++ )); do
28518 check_lsom_size $DIR/$tfile $offset
28521 $TRUNCATE $DIR/$tfile 0
28522 for client in ${CLIENTS//,/ }; do
28523 offset=$((offset - $bs))
28524 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28528 for (( i=0; i < $num; i++ )); do
28531 check_lsom_size $DIR/$tfile $size
28534 echo "Test SOM for truncate"
28535 $TRUNCATE $DIR/$tfile 1048576
28536 check_lsom_size $DIR/$tfile 1048576
28537 $TRUNCATE $DIR/$tfile 1234
28538 check_lsom_size $DIR/$tfile 1234
28540 # verify SOM blocks count
28541 echo "Verify SOM block count"
28542 $TRUNCATE $DIR/$tfile 0
28543 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
28544 error "failed to write file $tfile"
28545 check_lsom_data $DIR/$tfile
28547 run_test 806 "Verify Lazy Size on MDS"
28550 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
28551 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
28552 skip "Need MDS version at least 2.11.52"
28554 # Registration step
28555 changelog_register || error "changelog_register failed"
28556 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
28557 changelog_users $SINGLEMDS | grep -q $cl_user ||
28558 error "User $cl_user not found in changelog_users"
28560 rm -rf $DIR/$tdir || error "rm $tdir failed"
28561 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
28562 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
28563 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
28564 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
28565 error "truncate $tdir/trunc failed"
28568 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
28569 error "write $tfile failed"
28571 # multi-client wirtes
28572 local num=$(get_node_count ${CLIENTS//,/ })
28576 echo "Test SOM for multi-client ($num) writes"
28577 touch $DIR/$tfile || error "touch $tfile failed"
28578 $TRUNCATE $DIR/$tfile 0
28579 for client in ${CLIENTS//,/ }; do
28580 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28583 offset=$((offset + $bs))
28585 for (( i=0; i < $num; i++ )); do
28589 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
28590 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
28591 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
28592 check_lsom_data $DIR/$tdir/trunc
28593 check_lsom_data $DIR/$tdir/single_dd
28594 check_lsom_data $DIR/$tfile
28597 # Deregistration step
28598 changelog_deregister || error "changelog_deregister failed"
28600 run_test 807 "verify LSOM syncing tool"
28602 check_som_nologged()
28604 local lines=$($LFS changelog $FSNAME-MDT0000 |
28605 grep 'x=trusted.som' | wc -l)
28606 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
28610 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
28611 skip "Need MDS version at least 2.11.55"
28613 # Registration step
28614 changelog_register || error "changelog_register failed"
28616 touch $DIR/$tfile || error "touch $tfile failed"
28619 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
28620 error "write $tfile failed"
28623 $TRUNCATE $DIR/$tfile 1234
28626 $TRUNCATE $DIR/$tfile 1048576
28629 # Deregistration step
28630 changelog_deregister || error "changelog_deregister failed"
28632 run_test 808 "Check trusted.som xattr not logged in Changelogs"
28637 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
28641 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
28642 skip "Need MDS version at least 2.11.56"
28644 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
28645 error "failed to create DoM-only file $DIR/$tfile"
28646 touch $DIR/$tfile || error "touch $tfile failed"
28647 check_som_nodata $DIR/$tfile
28649 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
28650 error "write $tfile failed"
28651 check_som_nodata $DIR/$tfile
28653 $TRUNCATE $DIR/$tfile 1234
28654 check_som_nodata $DIR/$tfile
28656 $TRUNCATE $DIR/$tfile 4097
28657 check_som_nodata $DIR/$file
28659 run_test 809 "Verify no SOM xattr store for DoM-only files"
28662 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28663 $GSS && skip_env "could not run with gss"
28664 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
28665 skip "OST < 2.12.58 doesn't align checksum"
28668 stack_trap "set_checksums $ORIG_CSUM" EXIT
28669 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
28674 for csum in $CKSUM_TYPES; do
28675 #define OBD_FAIL_OSC_NO_GRANT 0x411
28676 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
28677 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
28679 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
28680 before=$(md5sum $DIR/$tfile)
28681 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
28682 after=$(md5sum $DIR/$tfile)
28683 [ "$before" == "$after" ] ||
28684 error "$csum: $before != $after bs=$1 seek=$2"
28688 run_test 810 "partial page writes on ZFS (LU-11663)"
28691 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
28692 skip "OST < 2.12.51 doesn't support this fail_loc"
28694 $LFS setstripe -c 1 -i 0 $DIR/$tfile
28695 # ensure ost1 is connected
28696 stat $DIR/$tfile >/dev/null || error "can't stat"
28697 wait_osc_import_state client ost1 FULL
28698 # no locks, no reqs to let the connection idle
28699 cancel_lru_locks osc
28701 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
28702 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
28703 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
28704 wait_osc_import_state client ost1 CONNECTING
28705 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
28707 stat $DIR/$tfile >/dev/null || error "can't stat file"
28709 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
28711 test_812b() { # LU-12378
28712 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
28713 skip "OST < 2.12.51 doesn't support this fail_loc"
28715 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
28716 # ensure ost1 is connected
28717 stat $DIR/$tfile >/dev/null || error "can't stat"
28718 wait_osc_import_state client ost1 FULL
28719 # no locks, no reqs to let the connection idle
28720 cancel_lru_locks osc
28722 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
28723 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
28724 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
28725 wait_osc_import_state client ost1 CONNECTING
28726 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
28728 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
28729 wait_osc_import_state client ost1 IDLE
28731 run_test 812b "do not drop no resend request for idle connect"
28736 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
28738 $LFS setstripe -c 1 -o 0 $DIR/$tfile
28739 $LFS getstripe $DIR/$tfile
28740 $LCTL set_param osc.*.idle_timeout=10
28741 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
28742 # ensure ost1 is connected
28743 stat $DIR/$tfile >/dev/null || error "can't stat"
28744 wait_osc_import_state client ost1 FULL
28745 # no locks, no reqs to let the connection idle
28746 cancel_lru_locks osc
28748 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
28749 $LCTL set_param fail_loc=0x80000533
28751 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
28753 run_test 812c "idle import vs lock enqueue race"
28756 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
28757 [ -z "$file_heat_sav" ] && skip "no file heat support"
28768 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
28769 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
28771 $LCTL set_param -n llite.*.file_heat=1
28772 echo "Turn on file heat"
28773 echo "Period second: $period_second, Decay percentage: $decay_pct"
28775 echo "QQQQ" > $DIR/$tfile
28776 echo "QQQQ" > $DIR/$tfile
28777 echo "QQQQ" > $DIR/$tfile
28778 cat $DIR/$tfile > /dev/null
28779 cat $DIR/$tfile > /dev/null
28780 cat $DIR/$tfile > /dev/null
28781 cat $DIR/$tfile > /dev/null
28783 local out=$($LFS heat_get $DIR/$tfile)
28785 $LFS heat_get $DIR/$tfile
28786 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28787 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28788 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28789 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28791 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
28792 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
28793 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
28794 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
28796 sleep $((period_second + 3))
28797 echo "Sleep $((period_second + 3)) seconds..."
28798 # The recursion formula to calculate the heat of the file f is as
28800 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
28801 # Where Hi is the heat value in the period between time points i*I and
28802 # (i+1)*I; Ci is the access count in the period; the symbol P refers
28803 # to the weight of Ci.
28804 out=$($LFS heat_get $DIR/$tfile)
28805 $LFS heat_get $DIR/$tfile
28806 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28807 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28808 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28809 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28811 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
28812 error "read sample ($readsample) is wrong"
28813 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
28814 error "write sample ($writesample) is wrong"
28815 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
28816 error "read bytes ($readbyte) is wrong"
28817 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
28818 error "write bytes ($writebyte) is wrong"
28820 echo "QQQQ" > $DIR/$tfile
28821 echo "QQQQ" > $DIR/$tfile
28822 echo "QQQQ" > $DIR/$tfile
28823 cat $DIR/$tfile > /dev/null
28824 cat $DIR/$tfile > /dev/null
28825 cat $DIR/$tfile > /dev/null
28826 cat $DIR/$tfile > /dev/null
28828 sleep $((period_second + 3))
28829 echo "Sleep $((period_second + 3)) seconds..."
28831 out=$($LFS heat_get $DIR/$tfile)
28832 $LFS heat_get $DIR/$tfile
28833 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28834 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28835 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28836 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28838 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
28839 4 * $decay_pct) / 100") -eq 1 ] ||
28840 error "read sample ($readsample1) is wrong"
28841 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
28842 3 * $decay_pct) / 100") -eq 1 ] ||
28843 error "write sample ($writesample1) is wrong"
28844 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
28845 20 * $decay_pct) / 100") -eq 1 ] ||
28846 error "read bytes ($readbyte1) is wrong"
28847 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
28848 15 * $decay_pct) / 100") -eq 1 ] ||
28849 error "write bytes ($writebyte1) is wrong"
28851 echo "Turn off file heat for the file $DIR/$tfile"
28852 $LFS heat_set -o $DIR/$tfile
28854 echo "QQQQ" > $DIR/$tfile
28855 echo "QQQQ" > $DIR/$tfile
28856 echo "QQQQ" > $DIR/$tfile
28857 cat $DIR/$tfile > /dev/null
28858 cat $DIR/$tfile > /dev/null
28859 cat $DIR/$tfile > /dev/null
28860 cat $DIR/$tfile > /dev/null
28862 out=$($LFS heat_get $DIR/$tfile)
28863 $LFS heat_get $DIR/$tfile
28864 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28865 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28866 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28867 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28869 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28870 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28871 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28872 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28874 echo "Trun on file heat for the file $DIR/$tfile"
28875 $LFS heat_set -O $DIR/$tfile
28877 echo "QQQQ" > $DIR/$tfile
28878 echo "QQQQ" > $DIR/$tfile
28879 echo "QQQQ" > $DIR/$tfile
28880 cat $DIR/$tfile > /dev/null
28881 cat $DIR/$tfile > /dev/null
28882 cat $DIR/$tfile > /dev/null
28883 cat $DIR/$tfile > /dev/null
28885 out=$($LFS heat_get $DIR/$tfile)
28886 $LFS heat_get $DIR/$tfile
28887 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28888 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28889 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28890 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28892 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
28893 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
28894 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
28895 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
28897 $LFS heat_set -c $DIR/$tfile
28898 $LCTL set_param -n llite.*.file_heat=0
28899 echo "Turn off file heat support for the Lustre filesystem"
28901 echo "QQQQ" > $DIR/$tfile
28902 echo "QQQQ" > $DIR/$tfile
28903 echo "QQQQ" > $DIR/$tfile
28904 cat $DIR/$tfile > /dev/null
28905 cat $DIR/$tfile > /dev/null
28906 cat $DIR/$tfile > /dev/null
28907 cat $DIR/$tfile > /dev/null
28909 out=$($LFS heat_get $DIR/$tfile)
28910 $LFS heat_get $DIR/$tfile
28911 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28912 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28913 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28914 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28916 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28917 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28918 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28919 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28921 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
28924 run_test 813 "File heat verfication"
28928 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
28929 echo -n y >> $DIR/$tfile
28930 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
28931 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
28933 run_test 814 "sparse cp works as expected (LU-12361)"
28937 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
28938 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
28940 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
28943 local ost1_imp=$(get_osc_import_name client ost1)
28944 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
28947 $LFS setstripe -c 1 -i 0 $DIR/$tfile
28948 # ensure ost1 is connected
28950 stat $DIR/$tfile >/dev/null || error "can't stat"
28951 wait_osc_import_state client ost1 FULL
28952 # no locks, no reqs to let the connection idle
28953 cancel_lru_locks osc
28954 lru_resize_disable osc
28957 before=$($LCTL get_param -n \
28958 ldlm.namespaces.$imp_name.lru_size)
28960 wait_osc_import_state client ost1 IDLE
28961 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
28962 now=$($LCTL get_param -n \
28963 ldlm.namespaces.$imp_name.lru_size)
28964 [ $before == $now ] || error "lru_size changed $before != $now"
28966 run_test 816 "do not reset lru_resize on idle reconnect"
28970 exportfs -u localhost:$DIR/nfsexp
28975 systemctl restart nfs-server.service || skip "failed to restart nfsd"
28977 mkdir -p $DIR/nfsexp
28978 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
28979 error "failed to export nfs"
28981 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
28982 stack_trap cleanup_817 EXIT
28984 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
28985 error "failed to mount nfs to $tmpdir"
28987 cp /bin/true $tmpdir
28988 $DIR/nfsexp/true || error "failed to execute 'true' command"
28990 run_test 817 "nfsd won't cache write lock for exec file"
28993 test_mkdir -i0 -c1 $DIR/$tdir
28994 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
28995 $LFS setstripe -c1 -i1 $DIR/$tdir/$tfile
28998 # restore osp-syn threads
28999 stack_trap "fail $SINGLEMDS"
29001 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
29002 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
29003 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
29004 error "start $SINGLEMDS failed"
29007 local testid=$(echo $TESTNAME | tr '_' ' ')
29009 do_facet mds1 dmesg | tac | sed "/$testid/,$ d" |
29010 grep "run LFSCK" || error "run LFSCK is not suggested"
29012 run_test 818 "unlink with failed llog"
29015 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
29016 cancel_lru_locks osc
29017 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
29018 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
29019 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
29022 run_test 819a "too big niobuf in read"
29025 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
29026 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
29027 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
29028 cancel_lru_locks osc
29032 run_test 819b "too big niobuf in write"
29035 function test_820_start_ost() {
29038 for num in $(seq $OSTCOUNT); do
29039 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
29044 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
29047 umount_client $MOUNT || error "umount failed"
29048 for num in $(seq $OSTCOUNT); do
29052 # mount client with no active OSTs
29053 # so that the client can't initialize max LOV EA size
29054 # from OSC notifications
29055 mount_client $MOUNT || error "mount failed"
29056 # delay OST starting to keep this 0 max EA size for a while
29057 test_820_start_ost &
29059 # create a directory on MDS2
29060 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
29061 error "Failed to create directory"
29062 # open intent should update default EA size
29063 # see mdc_update_max_ea_from_body()
29064 # notice this is the very first RPC to MDS2
29065 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
29068 # With SSK, this situation can lead to -EPERM being returned.
29069 # In that case, simply retry.
29070 if [ $ret -ne 0 ] && $SHARED_KEY; then
29071 if echo "$out" | grep -q "not permitted"; then
29072 cp /etc/services $DIR/$tdir/mds2
29076 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
29078 run_test 820 "update max EA from open intent"
29081 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
29082 local OST_MAX_PRECREATE=20000
29084 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
29085 skip "Need MDS version at least 2.14.56"
29087 save_lustre_params mds1 \
29088 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
29089 do_facet $SINGLEMDS "$LCTL set_param -n \
29090 osp.$FSNAME-OST*MDT0000.max_create_count=0"
29091 do_facet $SINGLEMDS "$LCTL set_param -n \
29092 osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE"
29094 stack_trap "restore_lustre_params < $p; rm $p"
29096 do_facet $SINGLEMDS "$LCTL set_param -n \
29097 osp.$FSNAME-OST*-osc-MDT*.create_count=100200"
29099 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
29100 osp.$FSNAME-OST0000*MDT0000.create_count")
29101 local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \
29102 osp.$FSNAME-OST0000*MDT0000.max_create_count")
29103 local expect_count=$(((($max/2)/256) * 256))
29105 log "setting create_count to 100200:"
29106 log " -result- count: $count with max: $max, expecting: $expect_count"
29108 [[ $count -eq expect_count ]] ||
29109 error "Create count not set to max precreate."
29111 run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum"
29114 [[ $MDS1_VERSION -lt $(version_code 2.14.56) ]] &&
29115 skip "Need MDS version 2.14.56"
29117 local sync_changes=$(do_facet $SINGLEMDS \
29118 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
29120 [ "$sync_changes" -gt 100 ] &&
29121 skip "Sync changes $sync_changes > 100 already"
29123 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
29125 $LFS mkdir -i 0 $DIR/$tdir
29126 $LFS setstripe -c 1 -i 0 $DIR/$tdir
29128 save_lustre_params mds1 \
29129 "osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes" > $p
29130 save_lustre_params mds1 \
29131 "osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress" >> $p
29133 do_facet mds1 "$LCTL set_param -n \
29134 osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes=100 \
29135 osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress=128"
29136 stack_trap "restore_lustre_params < $p" EXIT
29138 createmany -o $DIR/$tdir/f- 1000
29139 unlinkmany $DIR/$tdir/f- 1000 &
29140 local UNLINK_PID=$!
29143 sync_changes=$(do_facet mds1 \
29144 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
29145 # the check in the code is racy, fail the test
29146 # if the value above the limit by 10.
29147 [ $sync_changes -gt 110 ] && {
29148 kill -2 $UNLINK_PID
29150 error "osp changes throttling failed, $sync_changes>110"
29152 kill -0 $UNLINK_PID 2> /dev/null || break
29156 run_test 831 "throttling unlink/setattr queuing on OSP"
29159 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
29160 (( $MDS1_VERSION >= $(version_code 2.15.52) )) ||
29161 skip "Need MDS version 2.15.52+"
29162 is_rmentry_supported || skip "rm_entry not supported"
29164 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
29165 mkdir $DIR/$tdir/local_dir || error "mkdir local_dir failed"
29166 mkdir_on_mdt -i 1 $DIR/$tdir/remote_dir ||
29167 error "mkdir remote_dir failed"
29168 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/striped_dir ||
29169 error "mkdir striped_dir failed"
29170 touch $DIR/$tdir/file || error "touch file failed"
29171 $LFS rm_entry $DIR/$tdir/* || error "lfs rm_entry $tdir/* failed"
29172 [ -z "$(ls -A $DIR/$tdir)" ] || error "$tdir not empty"
29174 run_test 832 "lfs rm_entry"
29177 # tests that do cleanup/setup should be run at the end
29181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29184 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
29185 $LCTL set_param fail_loc=0x903
29187 cancel_lru_locks MGC
29189 FAIL_ON_ERROR=true cleanup
29190 FAIL_ON_ERROR=true setup
29192 run_test 900 "umount should not race with any mgc requeue thread"
29194 # LUS-6253/LU-11185
29202 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29204 # some get_param have a bug to handle dot in param name
29205 cancel_lru_locks MGC
29206 old=$(mount -t lustre | wc -l)
29214 while [ $old -ne $oldc ]; do
29215 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
29218 if [ $count -ge $TIMEOUT ]; then
29219 error "too large timeout"
29222 umount_client $MOUNT || error "umount failed"
29223 mount_client $MOUNT || error "mount failed"
29224 cancel_lru_locks MGC
29225 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
29227 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
29231 run_test 901 "don't leak a mgc lock on client umount"
29235 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
29236 skip "client does not have LU-13377 fix"
29237 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
29238 $LCTL set_param fail_loc=0x1415
29239 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
29240 cancel_lru_locks osc
29243 run_test 902 "test short write doesn't hang lustre"
29247 $LFS setstripe -i 0 -c 1 $DIR/$tfile $DIR/${tfile}-2
29248 echo "blah" > $DIR/${tfile}-2
29249 dd if=/dev/zero of=$DIR/$tfile bs=1M count=6 conv=fsync
29250 #define OBD_FAIL_OSC_SLOW_PAGE_EVICT 0x417
29251 $LCTL set_param fail_loc=0x417 fail_val=20
29253 mv $DIR/${tfile}-2 $DIR/$tfile # Destroys the big object
29254 sleep 1 # To start the destroy
29255 wait_destroy_complete 150 || error "Destroy taking too long"
29256 cat $DIR/$tfile > /dev/null || error "Evicted"
29258 run_test 903 "Test long page discard does not cause evictions"
29261 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
29262 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
29263 grep -q project || skip "skip project quota not supported"
29265 local testfile="$DIR/$tdir/$tfile"
29266 local xattr="trusted.projid"
29268 local mdts=$(comma_list $(mdts_nodes))
29269 local saved=$(do_facet mds1 $LCTL get_param -n \
29270 osd-ldiskfs.*MDT0000.enable_projid_xattr)
29272 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=0
29273 stack_trap "do_nodes $mdts $LCTL set_param \
29274 osd-ldiskfs.*MDT*.enable_projid_xattr=$saved"
29276 mkdir -p $DIR/$tdir
29278 #hide projid xattr on server
29279 $LFS project -p 1 $testfile ||
29280 error "set $testfile project id failed"
29281 getfattr -m - $testfile | grep $xattr &&
29282 error "do not show trusted.projid when disabled on server"
29283 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=1
29284 #should be hidden when projid is 0
29285 $LFS project -p 0 $testfile ||
29286 error "set $testfile project id failed"
29287 getfattr -m - $testfile | grep $xattr &&
29288 error "do not show trusted.projid with project ID 0"
29290 #still can getxattr explicitly
29291 projid=$(getfattr -n $xattr $testfile |
29292 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
29293 [ $projid == "0" ] ||
29294 error "projid expected 0 not $projid"
29296 #set the projid via setxattr
29297 setfattr -n $xattr -v "1000" $testfile ||
29298 error "setattr failed with $?"
29299 projid=($($LFS project $testfile))
29300 [ ${projid[0]} == "1000" ] ||
29301 error "projid expected 1000 not $projid"
29303 #check the new projid via getxattr
29304 $LFS project -p 1001 $testfile ||
29305 error "set $testfile project id failed"
29306 getfattr -m - $testfile | grep $xattr ||
29307 error "should show trusted.projid when project ID != 0"
29308 projid=$(getfattr -n $xattr $testfile |
29309 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
29310 [ $projid == "1001" ] ||
29311 error "projid expected 1001 not $projid"
29313 #try to set invalid projid
29314 setfattr -n $xattr -v "4294967295" $testfile &&
29315 error "set invalid projid should fail"
29317 #remove the xattr means setting projid to 0
29318 setfattr -x $xattr $testfile ||
29319 error "setfattr failed with $?"
29320 projid=($($LFS project $testfile))
29321 [ ${projid[0]} == "0" ] ||
29322 error "projid expected 0 not $projid"
29324 #should be hidden when parent has inherit flag and same projid
29325 $LFS project -srp 1002 $DIR/$tdir ||
29326 error "set $tdir project id failed"
29327 getfattr -m - $testfile | grep $xattr &&
29328 error "do not show trusted.projid with inherit flag"
29330 #still can getxattr explicitly
29331 projid=$(getfattr -n $xattr $testfile |
29332 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
29333 [ $projid == "1002" ] ||
29334 error "projid expected 1002 not $projid"
29336 run_test 904 "virtual project ID xattr"
29340 (( $OST1_VERSION >= $(version_code 2.8.54) )) ||
29341 skip "lustre < 2.8.54 does not support ladvise"
29343 remote_ost_nodsh && skip "remote OST with nodsh"
29344 $LFS setstripe -c -1 -i 0 $DIR/$tfile || error "setstripe failed"
29346 $LFS ladvise -a willread $DIR/$tfile || error "ladvise does not work"
29348 #define OBD_FAIL_OST_OPCODE 0x253
29350 do_facet ost1 "$LCTL set_param fail_val=21 fail_loc=0x0253"
29351 $LFS ladvise -a willread $DIR/$tfile &&
29352 error "unexpected success of ladvise with fault injection"
29353 $LFS ladvise -a willread $DIR/$tfile |&
29354 grep -q "Operation not supported"
29355 (( $? == 0 )) || error "unexpected stderr of ladvise with fault injection"
29357 run_test 905 "bad or new opcode should not stuck client"
29360 grep -q io_uring_setup /proc/kallsyms ||
29361 skip "Client OS does not support io_uring I/O engine"
29362 io_uring_probe || skip "kernel does not support io_uring fully"
29363 which fio || skip_env "no fio installed"
29364 fio --enghelp | grep -q io_uring ||
29365 skip_env "fio does not support io_uring I/O engine"
29367 local file=$DIR/$tfile
29368 local ioengine="io_uring"
29372 fio --name=seqwrite --ioengine=$ioengine \
29373 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
29374 --iodepth=64 --size=$size --filename=$file --rw=write ||
29375 error "fio seqwrite $file failed"
29377 fio --name=seqread --ioengine=$ioengine \
29378 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
29379 --iodepth=64 --size=$size --filename=$file --rw=read ||
29380 error "fio seqread $file failed"
29382 rm -f $file || error "rm -f $file failed"
29384 run_test 906 "Simple test for io_uring I/O engine via fio"
29388 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
29389 check_and_cleanup_lustre
29390 if [ "$I_MOUNTED" != "yes" ]; then
29391 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true