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 test_mkdir $DIR/$tdir
1715 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1716 error "setstripe failed"
1717 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1718 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1720 run_test 27d "create file with default settings"
1723 # LU-5839 adds check for existed layout before setting it
1724 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1725 skip "Need MDS version at least 2.7.56"
1727 test_mkdir $DIR/$tdir
1728 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1729 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1730 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1732 run_test 27e "setstripe existing file (should return error)"
1735 test_mkdir $DIR/$tdir
1736 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1737 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1738 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1739 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1740 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1741 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1743 run_test 27f "setstripe with bad stripe size (should return error)"
1746 test_mkdir $DIR/$tdir
1747 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1748 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1749 error "$DIR/$tdir/$tfile has object"
1751 run_test 27g "$LFS getstripe with no objects"
1754 test_mkdir $DIR/$tdir
1755 touch $DIR/$tdir/$tfile || error "touch failed"
1756 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1757 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1759 (( rc == 2 )) || error "getstripe did not return ENOENT"
1761 run_test 27ga "$LFS getstripe with missing file (should return error)"
1764 test_mkdir $DIR/$tdir
1765 touch $DIR/$tdir/$tfile || error "touch failed"
1766 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1767 error "missing objects"
1769 run_test 27i "$LFS getstripe with some objects"
1772 test_mkdir $DIR/$tdir
1773 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1774 error "setstripe failed" || true
1776 run_test 27j "setstripe with bad stripe offset (should return error)"
1778 test_27k() { # bug 2844
1779 test_mkdir $DIR/$tdir
1780 local file=$DIR/$tdir/$tfile
1781 local ll_max_blksize=$((4 * 1024 * 1024))
1782 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1783 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1784 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1785 dd if=/dev/zero of=$file bs=4k count=1
1786 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1787 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1789 run_test 27k "limit i_blksize for broken user apps"
1792 mcreate $DIR/$tfile || error "creating file"
1793 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1794 error "setstripe should have failed" || true
1796 run_test 27l "check setstripe permissions (should return error)"
1799 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1801 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1802 skip_env "multiple clients -- skipping"
1804 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1806 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1807 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1809 stack_trap simple_cleanup_common
1810 test_mkdir $DIR/$tdir
1811 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1812 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1813 error "dd should fill OST0"
1815 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1817 [ $i -gt 256 ] && break
1820 touch $DIR/$tdir/$tfile.$i
1821 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1822 awk '{print $1}'| grep -w "0") ] &&
1823 error "OST0 was full but new created file still use it"
1825 touch $DIR/$tdir/$tfile.$i
1826 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1827 awk '{print $1}'| grep -w "0") ] &&
1828 error "OST0 was full but new created file still use it" || true
1830 run_test 27m "create file while OST0 was full"
1832 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1833 # if the OST isn't full anymore.
1835 local ostidx=${1:-""}
1840 local list=$(comma_list $(osts_nodes))
1841 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1843 do_nodes $list lctl set_param fail_loc=0
1844 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1845 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1846 awk '{print $1 * 2;exit;}')
1847 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1849 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1853 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1855 remote_mds_nodsh && skip "remote MDS with nodsh"
1856 remote_ost_nodsh && skip "remote OST with nodsh"
1859 rm -f $DIR/$tdir/$tfile
1860 exhaust_precreations 0 0x80000215
1861 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1862 touch $DIR/$tdir/$tfile || error "touch failed"
1863 $LFS getstripe $DIR/$tdir/$tfile
1866 run_test 27n "create file with some full OSTs"
1869 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1870 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1871 remote_mds_nodsh && skip "remote MDS with nodsh"
1872 remote_ost_nodsh && skip "remote OST with nodsh"
1875 rm -f $DIR/$tdir/$tfile
1876 exhaust_all_precreations 0x215
1878 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1883 run_test 27o "create file with all full OSTs (should error)"
1885 function create_and_checktime() {
1890 for ((i=0; i < $loops; i++)); do
1891 local start=$SECONDS
1892 multiop $fname-$i Oc
1893 ((SECONDS-start < TIMEOUT)) ||
1894 error "creation took " $((SECONDS-$start)) && return 1
1899 local mdts=$(comma_list $(mdts_nodes))
1901 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1902 skip "Need MDS version at least 2.13.57"
1904 local f0=$DIR/${tfile}-0
1905 local f1=$DIR/${tfile}-1
1907 wait_delete_completed
1909 # refill precreated objects
1910 $LFS setstripe -i0 -c1 $f0
1912 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1913 # force QoS allocation policy
1914 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1915 stack_trap "do_nodes $mdts $LCTL set_param \
1916 lov.*.qos_threshold_rr=$saved" EXIT
1919 # one OST is unavailable, but still have few objects preallocated
1921 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1922 rm -rf $f1 $DIR/$tdir*" EXIT
1924 for ((i=0; i < 7; i++)); do
1925 mkdir $DIR/$tdir$i || error "can't create dir"
1926 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1927 error "can't set striping"
1929 for ((i=0; i < 7; i++)); do
1930 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1934 run_test 27oo "don't let few threads to reserve too many objects"
1937 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1938 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1939 remote_mds_nodsh && skip "remote MDS with nodsh"
1940 remote_ost_nodsh && skip "remote OST with nodsh"
1943 rm -f $DIR/$tdir/$tfile
1944 test_mkdir $DIR/$tdir
1946 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1947 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1948 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1950 exhaust_precreations 0 0x80000215
1951 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1952 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1953 $LFS getstripe $DIR/$tdir/$tfile
1957 run_test 27p "append to a truncated file with some full OSTs"
1960 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1961 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1962 remote_mds_nodsh && skip "remote MDS with nodsh"
1963 remote_ost_nodsh && skip "remote OST with nodsh"
1966 rm -f $DIR/$tdir/$tfile
1968 mkdir_on_mdt0 $DIR/$tdir
1969 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1970 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1971 error "truncate $DIR/$tdir/$tfile failed"
1972 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1974 exhaust_all_precreations 0x215
1976 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1977 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1981 run_test 27q "append to truncated file with all OSTs full (should error)"
1984 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1986 remote_mds_nodsh && skip "remote MDS with nodsh"
1987 remote_ost_nodsh && skip "remote OST with nodsh"
1990 rm -f $DIR/$tdir/$tfile
1991 exhaust_precreations 0 0x80000215
1993 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1997 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1999 test_27s() { # bug 10725
2000 test_mkdir $DIR/$tdir
2001 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2002 local stripe_count=0
2003 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2004 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2005 error "stripe width >= 2^32 succeeded" || true
2008 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2010 test_27t() { # bug 10864
2015 $WLFS getstripe $tfile
2018 run_test 27t "check that utils parse path correctly"
2020 test_27u() { # bug 4900
2021 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2022 remote_mds_nodsh && skip "remote MDS with nodsh"
2025 local list=$(comma_list $(mdts_nodes))
2027 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2028 do_nodes $list $LCTL set_param fail_loc=0x139
2029 test_mkdir -p $DIR/$tdir
2030 stack_trap "simple_cleanup_common 1000"
2031 createmany -o $DIR/$tdir/$tfile 1000
2032 do_nodes $list $LCTL set_param fail_loc=0
2034 TLOG=$TMP/$tfile.getstripe
2035 $LFS getstripe $DIR/$tdir > $TLOG
2036 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2037 [[ $OBJS -gt 0 ]] &&
2038 error "$OBJS objects created on OST-0. See $TLOG" ||
2041 run_test 27u "skip object creation on OSC w/o objects"
2043 test_27v() { # bug 4900
2044 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2045 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2046 remote_mds_nodsh && skip "remote MDS with nodsh"
2047 remote_ost_nodsh && skip "remote OST with nodsh"
2049 exhaust_all_precreations 0x215
2052 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2054 touch $DIR/$tdir/$tfile
2055 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2057 for (( i=1; i < OSTCOUNT; i++ )); do
2058 do_facet ost$i lctl set_param fail_loc=0x705
2060 local START=`date +%s`
2061 createmany -o $DIR/$tdir/$tfile 32
2063 local FINISH=`date +%s`
2064 local TIMEOUT=`lctl get_param -n timeout`
2065 local PROCESS=$((FINISH - START))
2066 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2067 error "$FINISH - $START >= $TIMEOUT / 2"
2068 sleep $((TIMEOUT / 2 - PROCESS))
2071 run_test 27v "skip object creation on slow OST"
2073 test_27w() { # bug 10997
2074 test_mkdir $DIR/$tdir
2075 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2076 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2077 error "stripe size $size != 65536" || true
2078 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2079 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2081 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2084 [[ $OSTCOUNT -lt 2 ]] &&
2085 skip_env "skipping multiple stripe count/offset test"
2087 test_mkdir $DIR/$tdir
2088 for i in $(seq 1 $OSTCOUNT); do
2090 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2091 error "setstripe -c $i -i $offset failed"
2092 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2093 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2094 [ $count -ne $i ] && error "stripe count $count != $i" || true
2095 [ $index -ne $offset ] &&
2096 error "stripe offset $index != $offset" || true
2099 run_test 27wa "check $LFS setstripe -c -i options"
2102 remote_ost_nodsh && skip "remote OST with nodsh"
2103 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2104 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2106 OFFSET=$(($OSTCOUNT - 1))
2108 local OST=$(ostname_from_index $OSTIDX)
2110 test_mkdir $DIR/$tdir
2111 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2112 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2114 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2115 for i in $(seq 0 $OFFSET); do
2116 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2117 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2118 error "OST0 was degraded but new created file still use it"
2120 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2122 run_test 27x "create files while OST0 is degraded"
2125 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2126 remote_mds_nodsh && skip "remote MDS with nodsh"
2127 remote_ost_nodsh && skip "remote OST with nodsh"
2128 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2130 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2131 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2132 osp.$mdtosc.prealloc_last_id)
2133 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2134 osp.$mdtosc.prealloc_next_id)
2135 local fcount=$((last_id - next_id))
2136 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2137 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2139 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2140 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2141 local OST_DEACTIVE_IDX=-1
2146 for OSC in $MDS_OSCS; do
2147 OST=$(osc_to_ost $OSC)
2148 OSTIDX=$(index_from_ostuuid $OST)
2149 if [ $OST_DEACTIVE_IDX == -1 ]; then
2150 OST_DEACTIVE_IDX=$OSTIDX
2152 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2153 echo $OSC "is Deactivated:"
2154 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2158 OSTIDX=$(index_from_ostuuid $OST)
2159 test_mkdir $DIR/$tdir
2160 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2162 for OSC in $MDS_OSCS; do
2163 OST=$(osc_to_ost $OSC)
2164 OSTIDX=$(index_from_ostuuid $OST)
2165 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2166 echo $OST "is degraded:"
2167 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2168 obdfilter.$OST.degraded=1
2173 createmany -o $DIR/$tdir/$tfile $fcount
2175 for OSC in $MDS_OSCS; do
2176 OST=$(osc_to_ost $OSC)
2177 OSTIDX=$(index_from_ostuuid $OST)
2178 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2179 echo $OST "is recovered from degraded:"
2180 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2181 obdfilter.$OST.degraded=0
2183 do_facet $SINGLEMDS lctl --device %$OSC activate
2187 # all osp devices get activated, hence -1 stripe count restored
2188 local stripe_count=0
2190 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2191 # devices get activated.
2193 $LFS setstripe -c -1 $DIR/$tfile
2194 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2196 [ $stripe_count -ne $OSTCOUNT ] &&
2197 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2200 run_test 27y "create files while OST0 is degraded and the rest inactive"
2206 lmm_count=$($LFS getstripe -c $1)
2207 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2208 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2210 local old_ifs="$IFS"
2212 fid=($($LFS path2fid $1))
2215 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2216 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2218 # compare lmm_seq and lu_fid->f_seq
2219 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2220 # compare lmm_object_id and lu_fid->oid
2221 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2223 # check the trusted.fid attribute of the OST objects of the file
2224 local have_obdidx=false
2226 $LFS getstripe $1 | while read obdidx oid hex seq; do
2227 # skip lines up to and including "obdidx"
2228 [ -z "$obdidx" ] && break
2229 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2230 $have_obdidx || continue
2232 local ost=$((obdidx + 1))
2233 local dev=$(ostdevname $ost)
2236 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2238 seq=$(echo $seq | sed -e "s/^0x//g")
2239 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2240 oid_hex=$(echo $oid)
2242 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2244 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2248 # Don't unmount/remount the OSTs if we don't need to do that.
2249 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2250 # update too, until that use mount/ll_decode_filter_fid/mount.
2251 # Re-enable when debugfs will understand new filter_fid.
2253 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2254 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2255 $dev 2>/dev/null" | grep "parent=")
2257 if [ -z "$ff" ]; then
2259 mount_fstype ost$ost
2260 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2261 $(facet_mntpt ost$ost)/$obj_file)
2262 unmount_fstype ost$ost
2263 start ost$ost $dev $OST_MOUNT_OPTS
2267 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2269 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2271 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2272 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2274 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2275 # stripe_size=1048576 component_id=1 component_start=0 \
2276 # component_end=33554432
2277 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2278 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2279 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2281 if grep -q 'stripe=' <<<$ff; then
2282 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2284 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2285 # into f_ver in this case. See comment on ff_parent.
2286 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2289 # compare lmm_seq and filter_fid->ff_parent.f_seq
2290 [ $ff_pseq = $lmm_seq ] ||
2291 error "FF parent SEQ $ff_pseq != $lmm_seq"
2292 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2293 [ $ff_poid = $lmm_oid ] ||
2294 error "FF parent OID $ff_poid != $lmm_oid"
2295 (($ff_pstripe == $stripe_nr)) ||
2296 error "FF stripe $ff_pstripe != $stripe_nr"
2298 stripe_nr=$((stripe_nr + 1))
2299 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2301 if grep -q 'stripe_count=' <<<$ff; then
2302 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2303 -e 's/ .*//' <<<$ff)
2304 [ $lmm_count = $ff_scnt ] ||
2305 error "FF stripe count $lmm_count != $ff_scnt"
2311 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2312 remote_ost_nodsh && skip "remote OST with nodsh"
2314 test_mkdir $DIR/$tdir
2315 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2316 { error "setstripe -c -1 failed"; return 1; }
2317 # We need to send a write to every object to get parent FID info set.
2318 # This _should_ also work for setattr, but does not currently.
2319 # touch $DIR/$tdir/$tfile-1 ||
2320 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2321 { error "dd $tfile-1 failed"; return 2; }
2322 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2323 { error "setstripe -c -1 failed"; return 3; }
2324 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2325 { error "dd $tfile-2 failed"; return 4; }
2327 # make sure write RPCs have been sent to OSTs
2330 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2331 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2333 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2335 test_27A() { # b=19102
2336 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2338 save_layout_restore_at_exit $MOUNT
2339 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2340 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2341 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2342 local default_size=$($LFS getstripe -S $MOUNT)
2343 local default_offset=$($LFS getstripe -i $MOUNT)
2344 local dsize=$(do_facet $SINGLEMDS \
2345 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2346 [ $default_size -eq $dsize ] ||
2347 error "stripe size $default_size != $dsize"
2348 [ $default_offset -eq -1 ] ||
2349 error "stripe offset $default_offset != -1"
2351 run_test 27A "check filesystem-wide default LOV EA values"
2353 test_27B() { # LU-2523
2354 test_mkdir $DIR/$tdir
2355 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2357 # open f1 with O_LOV_DELAY_CREATE
2359 # call setstripe ioctl on open file descriptor for f1
2361 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2365 # open f1 with O_LOV_DELAY_CREATE
2367 # call setstripe ioctl on open file descriptor for f1
2369 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2371 # Allow multiop to fail in imitation of NFS's busted semantics.
2374 run_test 27B "call setstripe on open unlinked file/rename victim"
2376 # 27C family tests full striping and overstriping
2377 test_27Ca() { #LU-2871
2378 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2386 test_mkdir $DIR/$tdir
2388 for i in $(seq 0 $((OSTCOUNT - 1))); do
2389 # set stripe across all OSTs starting from OST$i
2390 $LFS setstripe -i $i -c -1 $tfile$i
2391 # get striping information
2392 ost_idx=($($LFS getstripe $tfile$i |
2393 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2394 echo "OST Index: ${ost_idx[*]}"
2397 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2398 error "${#ost_idx[@]} != $OSTCOUNT"
2400 for index in $(seq 0 $((OSTCOUNT - 1))); do
2402 for j in "${ost_idx[@]}"; do
2403 if [ $index -eq $j ]; then
2409 error "Can not find $index in ${ost_idx[*]}"
2413 run_test 27Ca "check full striping across all OSTs"
2416 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2417 skip "server does not support overstriping"
2418 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2419 skip_env "too many osts, skipping"
2421 test_mkdir -p $DIR/$tdir
2422 local setcount=$(($OSTCOUNT * 2))
2423 [ $setcount -lt 160 ] || large_xattr_enabled ||
2424 skip_env "ea_inode feature disabled"
2426 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2427 error "setstripe failed"
2429 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2430 [ $count -eq $setcount ] ||
2431 error "stripe count $count, should be $setcount"
2433 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2434 error "overstriped should be set in pattern"
2436 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2439 run_test 27Cb "more stripes than OSTs with -C"
2442 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2443 skip "server does not support overstriping"
2444 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2446 test_mkdir -p $DIR/$tdir
2447 local setcount=$(($OSTCOUNT - 1))
2449 [ $setcount -lt 160 ] || large_xattr_enabled ||
2450 skip_env "ea_inode feature disabled"
2452 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2453 error "setstripe failed"
2455 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2456 [ $count -eq $setcount ] ||
2457 error "stripe count $count, should be $setcount"
2459 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2460 error "overstriped should not be set in pattern"
2462 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2465 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2468 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2469 skip "server does not support overstriping"
2470 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2471 large_xattr_enabled || skip_env "ea_inode feature disabled"
2473 test_mkdir -p $DIR/$tdir
2474 local setcount=$LOV_MAX_STRIPE_COUNT
2476 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2477 error "setstripe failed"
2479 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2480 [ $count -eq $setcount ] ||
2481 error "stripe count $count, should be $setcount"
2483 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2484 error "overstriped should be set in pattern"
2486 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2489 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2491 run_test 27Cd "test maximum stripe count"
2494 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2495 skip "server does not support overstriping"
2496 test_mkdir -p $DIR/$tdir
2498 pool_add $TESTNAME || error "Pool creation failed"
2499 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2503 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2504 error "setstripe failed"
2506 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2507 [ $count -eq $setcount ] ||
2508 error "stripe count $count, should be $setcount"
2510 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2511 error "overstriped should be set in pattern"
2513 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2516 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2518 run_test 27Ce "test pool with overstriping"
2521 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2522 skip "server does not support overstriping"
2523 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2524 skip_env "too many osts, skipping"
2526 test_mkdir -p $DIR/$tdir
2528 local setcount=$(($OSTCOUNT * 2))
2529 [ $setcount -lt 160 ] || large_xattr_enabled ||
2530 skip_env "ea_inode feature disabled"
2532 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2533 error "setstripe failed"
2535 echo 1 > $DIR/$tdir/$tfile
2537 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2538 [ $count -eq $setcount ] ||
2539 error "stripe count $count, should be $setcount"
2541 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2542 error "overstriped should be set in pattern"
2544 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2547 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2549 run_test 27Cf "test default inheritance with overstriping"
2552 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2553 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2554 remote_mds_nodsh && skip "remote MDS with nodsh"
2556 local POOL=${POOL:-testpool}
2558 local last_ost=$(($OSTCOUNT - 1))
2560 local ost_list=$(seq $first_ost $ost_step $last_ost)
2561 local ost_range="$first_ost $last_ost $ost_step"
2563 test_mkdir $DIR/$tdir
2564 pool_add $POOL || error "pool_add failed"
2565 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2568 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2570 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2571 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2572 skip27D+=" -s 30,31"
2573 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2574 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2575 skip27D+=" -s 32,33"
2576 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2578 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2579 error "llapi_layout_test failed"
2581 destroy_test_pools || error "destroy test pools failed"
2583 run_test 27D "validate llapi_layout API"
2585 # Verify that default_easize is increased from its initial value after
2586 # accessing a widely striped file.
2588 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2589 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2590 skip "client does not have LU-3338 fix"
2592 # 72 bytes is the minimum space required to store striping
2593 # information for a file striped across one OST:
2594 # (sizeof(struct lov_user_md_v3) +
2595 # sizeof(struct lov_user_ost_data_v1))
2597 $LCTL set_param -n llite.*.default_easize $min_easize ||
2598 error "lctl set_param failed"
2599 local easize=$($LCTL get_param -n llite.*.default_easize)
2601 [ $easize -eq $min_easize ] ||
2602 error "failed to set default_easize"
2604 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2605 error "setstripe failed"
2606 # In order to ensure stat() call actually talks to MDS we need to
2607 # do something drastic to this file to shake off all lock, e.g.
2608 # rename it (kills lookup lock forcing cache cleaning)
2609 mv $DIR/$tfile $DIR/${tfile}-1
2610 ls -l $DIR/${tfile}-1
2613 easize=$($LCTL get_param -n llite.*.default_easize)
2615 [ $easize -gt $min_easize ] ||
2616 error "default_easize not updated"
2618 run_test 27E "check that default extended attribute size properly increases"
2620 test_27F() { # LU-5346/LU-7975
2621 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2622 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2623 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2624 skip "Need MDS version at least 2.8.51"
2625 remote_ost_nodsh && skip "remote OST with nodsh"
2627 test_mkdir $DIR/$tdir
2629 $LFS setstripe -c 2 $DIR/$tdir
2631 # stop all OSTs to reproduce situation for LU-7975 ticket
2632 for num in $(seq $OSTCOUNT); do
2636 # open/create f0 with O_LOV_DELAY_CREATE
2637 # truncate f0 to a non-0 size
2639 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2641 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2642 # open/write it again to force delayed layout creation
2643 cat /etc/hosts > $DIR/$tdir/f0 &
2647 for num in $(seq $OSTCOUNT); do
2648 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2649 error "ost$num failed to start"
2652 wait $catpid || error "cat failed"
2654 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2655 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2656 error "wrong stripecount"
2659 run_test 27F "Client resend delayed layout creation with non-zero size"
2661 test_27G() { #LU-10629
2662 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2663 skip "Need MDS version at least 2.11.51"
2664 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2665 remote_mds_nodsh && skip "remote MDS with nodsh"
2666 local POOL=${POOL:-testpool}
2667 local ostrange="0 0 1"
2669 test_mkdir $DIR/$tdir
2670 touch $DIR/$tdir/$tfile.nopool
2671 pool_add $POOL || error "pool_add failed"
2672 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2673 $LFS setstripe -p $POOL $DIR/$tdir
2675 local pool=$($LFS getstripe -p $DIR/$tdir)
2677 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2678 touch $DIR/$tdir/$tfile.default
2679 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2680 $LFS find $DIR/$tdir -type f --pool $POOL
2681 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2682 [[ "$found" == "2" ]] ||
2683 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2685 $LFS setstripe -d $DIR/$tdir
2687 pool=$($LFS getstripe -p -d $DIR/$tdir)
2689 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2691 run_test 27G "Clear OST pool from stripe"
2694 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2695 skip "Need MDS version newer than 2.11.54"
2696 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2697 test_mkdir $DIR/$tdir
2698 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2699 touch $DIR/$tdir/$tfile
2700 $LFS getstripe -c $DIR/$tdir/$tfile
2701 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2702 error "two-stripe file doesn't have two stripes"
2704 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2705 $LFS getstripe -y $DIR/$tdir/$tfile
2706 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2707 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2708 error "expected l_ost_idx: [02]$ not matched"
2710 # make sure ost list has been cleared
2711 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2712 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2713 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2715 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2717 run_test 27H "Set specific OSTs stripe"
2720 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2721 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2722 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2723 skip "Need MDS version newer than 2.12.52"
2724 local pool=$TESTNAME
2725 local ostrange="1 1 1"
2727 save_layout_restore_at_exit $MOUNT
2728 $LFS setstripe -c 2 -i 0 $MOUNT
2729 pool_add $pool || error "pool_add failed"
2730 pool_add_targets $pool $ostrange ||
2731 error "pool_add_targets failed"
2732 test_mkdir $DIR/$tdir
2733 $LFS setstripe -p $pool $DIR/$tdir
2734 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2735 $LFS getstripe $DIR/$tdir/$tfile
2737 run_test 27I "check that root dir striping does not break parent dir one"
2740 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2741 skip "Need MDS version newer than 2.12.51"
2743 test_mkdir $DIR/$tdir
2744 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2745 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2747 # create foreign file (raw way)
2748 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2749 error "creating $tfile w/ hex flags w/o --foreign should fail"
2751 ! $LFS setstripe --foreign --flags foo \
2752 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2753 error "creating $tfile with '--flags foo' should fail"
2755 ! $LFS setstripe --foreign --flags 0xffffffff \
2756 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2757 error "creating $tfile w/ 0xffffffff flags should fail"
2759 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2760 -t 1 -F 0xda08 || error "create_foreign_file failed"
2762 # verify foreign file (raw way)
2763 parse_foreign_file -f $DIR/$tdir/$tfile |
2764 grep "lov_foreign_magic: 0x0BD70BD0" ||
2765 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2766 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2767 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2768 parse_foreign_file -f $DIR/$tdir/$tfile |
2769 grep "lov_foreign_size: 73" ||
2770 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2771 parse_foreign_file -f $DIR/$tdir/$tfile |
2772 grep "lov_foreign_type: 1" ||
2773 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2774 parse_foreign_file -f $DIR/$tdir/$tfile |
2775 grep "lov_foreign_flags: 0x0000DA08" ||
2776 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2777 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2778 grep "lov_foreign_value: 0x" |
2779 sed -e 's/lov_foreign_value: 0x//')
2780 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2781 [[ $lov = ${lov2// /} ]] ||
2782 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2784 # create foreign file (lfs + API)
2785 $LFS setstripe --foreign=none --flags 0xda08 \
2786 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2787 error "$DIR/$tdir/${tfile}2: create failed"
2789 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2790 grep "lfm_magic:.*0x0BD70BD0" ||
2791 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2792 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2793 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2794 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2795 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2796 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2797 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2798 grep "lfm_flags:.*0x0000DA08" ||
2799 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2800 $LFS getstripe $DIR/$tdir/${tfile}2 |
2801 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2802 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2804 # modify striping should fail
2805 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2806 error "$DIR/$tdir/$tfile: setstripe should fail"
2807 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2808 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2811 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2812 cat $DIR/$tdir/${tfile}2 &&
2813 error "$DIR/$tdir/${tfile}2: read should fail"
2814 cat /etc/passwd > $DIR/$tdir/$tfile &&
2815 error "$DIR/$tdir/$tfile: write should fail"
2816 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2817 error "$DIR/$tdir/${tfile}2: write should fail"
2820 chmod 222 $DIR/$tdir/$tfile ||
2821 error "$DIR/$tdir/$tfile: chmod failed"
2822 chmod 222 $DIR/$tdir/${tfile}2 ||
2823 error "$DIR/$tdir/${tfile}2: chmod failed"
2826 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2827 error "$DIR/$tdir/$tfile: chown failed"
2828 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2829 error "$DIR/$tdir/${tfile}2: chown failed"
2831 # rename should work
2832 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2833 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2834 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2835 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2837 #remove foreign file
2838 rm $DIR/$tdir/${tfile}.new ||
2839 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2840 rm $DIR/$tdir/${tfile}2.new ||
2841 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2843 run_test 27J "basic ops on file with foreign LOV"
2846 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2847 skip "Need MDS version newer than 2.12.49"
2849 test_mkdir $DIR/$tdir
2850 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2851 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2853 # create foreign dir (raw way)
2854 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2855 error "creating $tdir w/ hex flags w/o --foreign should fail"
2857 ! $LFS setdirstripe --foreign --flags foo \
2858 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2859 error "creating $tdir with '--flags foo' should fail"
2861 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2862 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2863 error "creating $tdir w/ 0xffffffff flags should fail"
2865 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2866 error "create_foreign_dir FAILED"
2868 # verify foreign dir (raw way)
2869 parse_foreign_dir -d $DIR/$tdir/$tdir |
2870 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2871 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2872 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2873 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2874 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2875 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2876 parse_foreign_dir -d $DIR/$tdir/$tdir |
2877 grep "lmv_foreign_flags: 55813$" ||
2878 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2879 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2880 grep "lmv_foreign_value: 0x" |
2881 sed 's/lmv_foreign_value: 0x//')
2882 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2884 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2886 # create foreign dir (lfs + API)
2887 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2888 $DIR/$tdir/${tdir}2 ||
2889 error "$DIR/$tdir/${tdir}2: create failed"
2891 $LFS getdirstripe -v $DIR/$tdir/${tdir}2
2893 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2894 grep "lfm_magic:.*0x0CD50CD0" ||
2895 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2896 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2897 # - sizeof(lfm_type) - sizeof(lfm_flags)
2898 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2899 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2900 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2901 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2902 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2903 grep "lfm_flags:.*0x0000DA05" ||
2904 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2905 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2906 grep "lfm_value.*${uuid1}@${uuid2}" ||
2907 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2909 # file create in dir should fail
2910 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
2911 touch $DIR/$tdir/${tdir}2/$tfile &&
2912 error "$DIR/${tdir}2: file create should fail"
2915 chmod 777 $DIR/$tdir/$tdir ||
2916 error "$DIR/$tdir: chmod failed"
2917 chmod 777 $DIR/$tdir/${tdir}2 ||
2918 error "$DIR/${tdir}2: chmod failed"
2921 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2922 error "$DIR/$tdir: chown failed"
2923 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2924 error "$DIR/${tdir}2: chown failed"
2926 # rename should work
2927 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2928 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2929 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2930 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2933 rmdir $DIR/$tdir/${tdir}.new ||
2934 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2935 rmdir $DIR/$tdir/${tdir}2.new ||
2936 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2938 run_test 27K "basic ops on dir with foreign LMV"
2941 remote_mds_nodsh && skip "remote MDS with nodsh"
2943 local POOL=${POOL:-$TESTNAME}
2945 pool_add $POOL || error "pool_add failed"
2947 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2948 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2949 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2951 run_test 27L "lfs pool_list gives correct pool name"
2954 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2955 skip "Need MDS version >= than 2.12.57"
2956 remote_mds_nodsh && skip "remote MDS with nodsh"
2957 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2959 # Set default striping on directory
2962 local mdts=$(comma_list $(mdts_nodes))
2964 # if we run against a 2.12 server which lacks overstring support
2965 # then the connect_flag will not report overstriping, even if client
2967 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
2968 stripe_opt="-C $setcount"
2969 elif (( $OSTCOUNT >= $setcount )); then
2970 stripe_opt="-c $setcount"
2972 skip "server does not support overstriping"
2975 test_mkdir $DIR/$tdir
2977 # Validate existing append_* params and ensure restore
2978 local pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
2979 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
2980 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
2982 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2983 ((orig_count == 1)) || error "expected append_stripe_count == 1, got $orig_count"
2984 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1"
2986 $LFS setstripe $stripe_opt $DIR/$tdir
2988 echo 1 > $DIR/$tdir/${tfile}.1
2989 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2990 [ $count -eq $setcount ] ||
2991 error "(1) stripe count $count, should be $setcount"
2993 local appendcount=$orig_count
2994 echo 1 >> $DIR/$tdir/${tfile}.2_append
2995 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2996 [ $count -eq $appendcount ] ||
2997 error "(2)stripe count $count, should be $appendcount for append"
2999 # Disable O_APPEND striping, verify it works
3000 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3002 # Should now get the default striping, which is 4
3004 echo 1 >> $DIR/$tdir/${tfile}.3_append
3005 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3006 [ $count -eq $setcount ] ||
3007 error "(3) stripe count $count, should be $setcount"
3009 # Try changing the stripe count for append files
3010 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3012 # Append striping is now 2 (directory default is still 4)
3014 echo 1 >> $DIR/$tdir/${tfile}.4_append
3015 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3016 [ $count -eq $appendcount ] ||
3017 error "(4) stripe count $count, should be $appendcount for append"
3019 # Test append stripe count of -1
3020 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3021 appendcount=$OSTCOUNT
3022 echo 1 >> $DIR/$tdir/${tfile}.5
3023 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3024 [ $count -eq $appendcount ] ||
3025 error "(5) stripe count $count, should be $appendcount for append"
3027 # Set append striping back to default of 1
3028 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3030 # Try a new default striping, PFL + DOM
3031 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3033 # Create normal DOM file, DOM returns stripe count == 0
3035 touch $DIR/$tdir/${tfile}.6
3036 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3037 [ $count -eq $setcount ] ||
3038 error "(6) stripe count $count, should be $setcount"
3042 echo 1 >> $DIR/$tdir/${tfile}.7_append
3043 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3044 [ $count -eq $appendcount ] ||
3045 error "(7) stripe count $count, should be $appendcount for append"
3047 # Clean up DOM layout
3048 $LFS setstripe -d $DIR/$tdir
3050 save_layout_restore_at_exit $MOUNT
3051 # Now test that append striping works when layout is from root
3052 $LFS setstripe -c 2 $MOUNT
3053 # Make a special directory for this
3054 mkdir $DIR/${tdir}/${tdir}.2
3056 # Verify for normal file
3058 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3059 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3060 [ $count -eq $setcount ] ||
3061 error "(8) stripe count $count, should be $setcount"
3064 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3065 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3066 [ $count -eq $appendcount ] ||
3067 error "(9) stripe count $count, should be $appendcount for append"
3069 # Now test O_APPEND striping with pools
3070 pool_add $TESTNAME || error "pool creation failed"
3071 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3072 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3074 echo 1 >> $DIR/$tdir/${tfile}.10_append
3076 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3077 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3079 # Check that count is still correct
3081 echo 1 >> $DIR/$tdir/${tfile}.11_append
3082 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3083 [ $count -eq $appendcount ] ||
3084 error "(11) stripe count $count, should be $appendcount for append"
3086 # Disable O_APPEND stripe count, verify pool works separately
3087 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3089 echo 1 >> $DIR/$tdir/${tfile}.12_append
3091 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3092 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3094 # Remove pool setting, verify it's not applied
3095 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3097 echo 1 >> $DIR/$tdir/${tfile}.13_append
3099 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3100 [ "$pool" = "" ] || error "(13) pool found: $pool"
3102 run_test 27M "test O_APPEND striping"
3105 combined_mgs_mds && skip "needs separate MGS/MDT"
3107 pool_add $TESTNAME || error "pool_add failed"
3108 do_facet mgs "$LCTL pool_list $FSNAME" |
3109 grep -Fx "${FSNAME}.${TESTNAME}" ||
3110 error "lctl pool_list on MGS failed"
3112 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3114 clean_foreign_symlink() {
3116 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3117 for i in $DIR/$tdir/* ; do
3118 $LFS unlink_foreign $i || true
3123 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3124 skip "Need MDS version newer than 2.12.51"
3126 test_mkdir $DIR/$tdir
3127 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3128 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3130 trap clean_foreign_symlink EXIT
3132 # enable foreign_symlink behaviour
3133 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3135 # foreign symlink LOV format is a partial path by default
3137 # create foreign file (lfs + API)
3138 $LFS setstripe --foreign=symlink --flags 0xda05 \
3139 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3140 error "$DIR/$tdir/${tfile}: create failed"
3142 $LFS getstripe -v $DIR/$tdir/${tfile} |
3143 grep "lfm_magic:.*0x0BD70BD0" ||
3144 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3145 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3146 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3147 $LFS getstripe -v $DIR/$tdir/${tfile} |
3148 grep "lfm_flags:.*0x0000DA05" ||
3149 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3150 $LFS getstripe $DIR/$tdir/${tfile} |
3151 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3152 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3154 # modify striping should fail
3155 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3156 error "$DIR/$tdir/$tfile: setstripe should fail"
3158 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3159 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3160 cat /etc/passwd > $DIR/$tdir/$tfile &&
3161 error "$DIR/$tdir/$tfile: write should fail"
3163 # rename should succeed
3164 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3165 error "$DIR/$tdir/$tfile: rename has failed"
3167 #remove foreign_symlink file should fail
3168 rm $DIR/$tdir/${tfile}.new &&
3169 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3172 mkdir /tmp/${uuid1} ||
3173 error "/tmp/${uuid1}: mkdir has failed"
3174 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3175 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3176 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3177 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3178 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3179 #read should succeed now
3180 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3181 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3182 #write should succeed now
3183 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3184 error "$DIR/$tdir/${tfile}.new: write should succeed"
3185 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3186 error "$DIR/$tdir/${tfile}.new: diff has failed"
3187 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3188 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3190 #check that getstripe still works
3191 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3192 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3194 # chmod should still succeed
3195 chmod 644 $DIR/$tdir/${tfile}.new ||
3196 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3198 # chown should still succeed
3199 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3200 error "$DIR/$tdir/${tfile}.new: chown has failed"
3202 # rename should still succeed
3203 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3204 error "$DIR/$tdir/${tfile}.new: rename has failed"
3206 #remove foreign_symlink file should still fail
3207 rm $DIR/$tdir/${tfile} &&
3208 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3210 #use special ioctl() to unlink foreign_symlink file
3211 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3212 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3215 run_test 27O "basic ops on foreign file of symlink type"
3218 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3219 skip "Need MDS version newer than 2.12.49"
3221 test_mkdir $DIR/$tdir
3222 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3223 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3225 trap clean_foreign_symlink EXIT
3227 # enable foreign_symlink behaviour
3228 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3230 # foreign symlink LMV format is a partial path by default
3232 # create foreign dir (lfs + API)
3233 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3234 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3235 error "$DIR/$tdir/${tdir}: create failed"
3237 $LFS getdirstripe -v $DIR/$tdir/${tdir}
3239 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3240 grep "lfm_magic:.*0x0CD50CD0" ||
3241 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3242 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3243 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3244 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3245 grep "lfm_flags:.*0x0000DA05" ||
3246 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3247 $LFS getdirstripe $DIR/$tdir/${tdir} |
3248 grep "lfm_value.*${uuid1}/${uuid2}" ||
3249 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3251 # file create in dir should fail
3252 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3253 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
3255 # rename should succeed
3256 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3257 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3259 #remove foreign_symlink dir should fail
3260 rmdir $DIR/$tdir/${tdir}.new &&
3261 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3264 mkdir -p /tmp/${uuid1}/${uuid2} ||
3265 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3266 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3267 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3268 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3269 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3270 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3271 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3272 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3274 #check that getstripe fails now that foreign_symlink enabled
3275 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3276 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3278 # file create in dir should work now
3279 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3280 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3281 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3282 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3283 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3284 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3286 # chmod should still succeed
3287 chmod 755 $DIR/$tdir/${tdir}.new ||
3288 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3290 # chown should still succeed
3291 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3292 error "$DIR/$tdir/${tdir}.new: chown has failed"
3294 # rename should still succeed
3295 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3296 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3298 #remove foreign_symlink dir should still fail
3299 rmdir $DIR/$tdir/${tdir} &&
3300 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3302 #use special ioctl() to unlink foreign_symlink file
3303 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3304 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3306 #created file should still exist
3307 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3308 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3309 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3310 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3312 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3315 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3316 stack_trap "rm -f $TMP/$tfile*"
3318 test_mkdir $DIR/$tdir-1
3319 test_mkdir $DIR/$tdir-2
3321 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3322 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3324 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3325 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3327 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3328 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3330 # Create some bad symlinks and ensure that we don't loop
3331 # forever or something. These should return ELOOP (40) and
3332 # ENOENT (2) but I don't want to test for that because there's
3333 # always some weirdo architecture that needs to ruin
3334 # everything by defining these error numbers differently.
3336 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3337 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3339 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3340 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3344 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3347 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
3348 skip "need MDS 2.14.55 or later"
3349 (( $OSTCOUNT >= 2 )) || skip_env "needs at least 2 OSTs"
3351 local testdir="$DIR/$tdir"
3352 test_mkdir -p $testdir
3353 stack_trap "rm -rf $testdir"
3354 $LFS setstripe -c -1 $testdir || error "setstripe failed"
3356 local f1="$testdir/f1"
3357 touch $f1 || error "failed to touch $f1"
3358 local count=$($LFS getstripe -c $f1)
3359 (( $count == $OSTCOUNT )) || error "wrong stripe count"
3361 do_facet $SINGLEMDS $LCTL set_param lod.*.max_stripecount=-1
3362 (( $? == 34 )) || error "setting max_stripecount to -1 should fail and return ERANGE"
3364 local maxcount=$(($OSTCOUNT - 1))
3365 local mdts=$(comma_list $(mdts_nodes))
3366 do_nodes $mdts $LCTL set_param lod.*.max_stripecount=$maxcount
3367 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_stripecount=0"
3369 local f2="$testdir/f2"
3370 touch $f2 || error "failed to touch $f2"
3371 local count=$($LFS getstripe -c $f2)
3372 (( $count == $maxcount )) || error "wrong stripe count"
3374 run_test 27R "test max_stripecount limitation when stripe count is set to -1"
3377 [ $(facet_host client) == $(facet_host ost1) ] &&
3378 skip "need ost1 and client on different nodes"
3380 #define OBD_FAIL_OSC_NO_GRANT 0x411
3381 $LCTL set_param fail_loc=0x20000411 fail_val=1
3382 #define OBD_FAIL_OST_ENOSPC 0x215
3383 do_facet ost1 "$LCTL set_param fail_loc=0x80000215"
3384 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3385 $MULTIOP $DIR/$tfile oO_WRONLY:P$((4 * 1024 * 1024 + 10 * 4096))c ||
3386 error "multiop failed"
3388 run_test 27T "no eio on close on partial write due to enosp"
3391 local dir=$DIR/$tdir
3392 local file=$dir/$tfile
3393 local append_pool=${TESTNAME}-append
3394 local normal_pool=${TESTNAME}-normal
3398 local mdts=$(comma_list $(mdts_nodes))
3401 # (( $MDS1_VERSION >= $(version_code 2.15.42) )) ||
3402 # skip "Need MDS version at least 2.15.42"
3404 # Validate existing append_* params and ensure restore
3405 pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3406 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3407 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3409 stripe_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3410 ((stripe_count == 1)) || error "expected append_stripe_count != 0, got $stripe_count"
3411 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$stripe_count"
3413 pool_add $append_pool || error "pool creation failed"
3414 pool_add_targets $append_pool 0 1 || error "Pool add targets failed"
3416 pool_add $normal_pool || error "pool creation failed"
3417 pool_add_targets $normal_pool 0 1 || error "Pool add targets failed"
3420 $LFS setstripe -E 1M -c 1 -p $normal_pool -E 2M -c 2 -p $normal_pool -E eof -c -1 $dir
3423 $LFS getstripe $file.1
3425 pool=$($LFS getstripe -p $file.1)
3426 [[ "$pool" == "$normal_pool" ]] || error "got pool '$pool', expected '$normal_pool'"
3428 stripe_count2=$($LFS getstripe -c $file.1)
3429 ((stripe_count2 == stripe_count)) ||
3430 error "got stripe_count '$stripe_count2', expected '$stripe_count'"
3432 do_nodes $mdts $LCTL set_param mdd.*.append_pool=$append_pool
3435 $LFS getstripe $file.2
3437 pool=$($LFS getstripe -p $file.2)
3438 [[ "$pool" == "$append_pool" ]] || error "got pool '$pool', expected '$append_pool'"
3440 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3443 $LFS getstripe $file.3
3445 stripe_count2=$($LFS getstripe -c $file.3)
3446 ((stripe_count2 == 2)) || error "got stripe_count '$stripe_count2', expected 2"
3448 run_test 27U "append pool and stripe count work with composite default layout"
3450 # createtest also checks that device nodes are created and
3451 # then visible correctly (#2091)
3452 test_28() { # bug 2091
3454 $CREATETEST $DIR/d28/ct || error "createtest failed"
3456 run_test 28 "create/mknod/mkdir with bad file types ============"
3459 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3461 [ $MDS1_VERSION -ge $(version_code 2.14.51) ] && {
3463 stack_trap "restore_opencache"
3466 sync; sleep 1; sync # flush out any dirty pages from previous tests
3473 declare -i LOCKCOUNTORIG=0
3474 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3475 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3477 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3479 declare -i LOCKUNUSEDCOUNTORIG=0
3480 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3481 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3488 declare -i LOCKCOUNTCURRENT=0
3489 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3490 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3493 declare -i LOCKUNUSEDCOUNTCURRENT=0
3494 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3495 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3498 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3499 $LCTL set_param -n ldlm.dump_namespaces ""
3500 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3501 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3502 log "dumped log to $TMP/test_29.dk (bug 5793)"
3505 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3506 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3507 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3508 log "dumped log to $TMP/test_29.dk (bug 5793)"
3512 run_test 29 "IT_GETATTR regression ============================"
3514 test_30a() { # was test_30
3515 cp $(which ls) $DIR || cp /bin/ls $DIR
3516 $DIR/ls / || error "Can't execute binary from lustre"
3519 run_test 30a "execute binary from Lustre (execve) =============="
3522 cp `which ls` $DIR || cp /bin/ls $DIR
3524 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3527 run_test 30b "execute binary from Lustre as non-root ==========="
3529 test_30c() { # b=22376
3530 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3532 cp $(which ls) $DIR || cp /bin/ls $DIR
3534 cancel_lru_locks mdc
3535 cancel_lru_locks osc
3536 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3539 run_test 30c "execute binary from Lustre without read perms ===="
3542 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3544 for i in {1..10}; do
3545 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3548 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3549 wait $PID || error "executing dd from Lustre failed"
3555 run_test 30d "execute binary from Lustre while clear locks"
3558 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3559 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3561 run_test 31a "open-unlink file =================================="
3564 touch $DIR/f31 || error "touch $DIR/f31 failed"
3565 ln $DIR/f31 $DIR/f31b || error "ln failed"
3566 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3567 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3569 run_test 31b "unlink file with multiple links while open ======="
3572 touch $DIR/f31 || error "touch $DIR/f31 failed"
3573 ln $DIR/f31 $DIR/f31c || error "ln failed"
3574 multiop_bg_pause $DIR/f31 O_uc ||
3575 error "multiop_bg_pause for $DIR/f31 failed"
3577 $MULTIOP $DIR/f31c Ouc
3578 kill -USR1 $MULTIPID
3581 run_test 31c "open-unlink file with multiple links ============="
3584 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3585 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3587 run_test 31d "remove of open directory ========================="
3589 test_31e() { # bug 2904
3590 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3592 run_test 31e "remove of open non-empty directory ==============="
3594 test_31f() { # bug 4554
3595 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3598 test_mkdir $DIR/d31f
3599 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3600 cp /etc/hosts $DIR/d31f
3602 $LFS getstripe $DIR/d31f/hosts
3603 multiop_bg_pause $DIR/d31f D_c || return 1
3606 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3607 test_mkdir $DIR/d31f
3608 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3609 cp /etc/hosts $DIR/d31f
3611 $LFS getstripe $DIR/d31f/hosts
3612 multiop_bg_pause $DIR/d31f D_c || return 1
3615 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3616 wait $MULTIPID || error "first opendir $MULTIPID failed"
3620 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3621 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3624 run_test 31f "remove of open directory with open-unlink file ==="
3627 echo "-- cross directory link --"
3628 test_mkdir -c1 $DIR/${tdir}ga
3629 test_mkdir -c1 $DIR/${tdir}gb
3630 touch $DIR/${tdir}ga/f
3631 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3632 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3633 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3634 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3635 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3637 run_test 31g "cross directory link==============="
3640 echo "-- cross directory link --"
3641 test_mkdir -c1 $DIR/${tdir}
3642 test_mkdir -c1 $DIR/${tdir}/dir
3643 touch $DIR/${tdir}/f
3644 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3645 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3646 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3647 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3648 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3650 run_test 31h "cross directory link under child==============="
3653 echo "-- cross directory link --"
3654 test_mkdir -c1 $DIR/$tdir
3655 test_mkdir -c1 $DIR/$tdir/dir
3656 touch $DIR/$tdir/dir/f
3657 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3658 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3659 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3660 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3661 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3663 run_test 31i "cross directory link under parent==============="
3666 test_mkdir -c1 -p $DIR/$tdir
3667 test_mkdir -c1 -p $DIR/$tdir/dir1
3668 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3669 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3670 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3671 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3674 run_test 31j "link for directory==============="
3677 test_mkdir -c1 -p $DIR/$tdir
3679 touch $DIR/$tdir/exist
3680 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3681 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3682 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3683 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3684 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3685 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3686 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3689 run_test 31k "link to file: the same, non-existing, dir==============="
3695 touch $DIR/d31m2/exist
3696 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3697 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3698 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3699 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3700 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3701 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3704 run_test 31m "link to file: the same, non-existing, dir==============="
3707 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3708 nlink=$(stat --format=%h $DIR/$tfile)
3709 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3711 local cmd="exec $fd<$DIR/$tfile"
3714 trap "eval $cmd" EXIT
3715 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3716 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3717 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3718 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3719 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3722 run_test 31n "check link count of unlinked file"
3725 local tempfile=$(mktemp $1_XXXXXX)
3726 mlink $tempfile $1 2> /dev/null &&
3727 echo "$BASHPID: link $tempfile to $1 succeeded"
3731 test_31o() { # LU-2901
3732 test_mkdir $DIR/$tdir
3733 for LOOP in $(seq 100); do
3734 rm -f $DIR/$tdir/$tfile*
3735 for THREAD in $(seq 8); do
3736 link_one $DIR/$tdir/$tfile.$LOOP &
3739 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3740 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3741 error "$LINKS duplicate links to $tfile.$LOOP" &&
3745 run_test 31o "duplicate hard links with same filename"
3748 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3750 test_mkdir $DIR/$tdir
3751 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3752 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3754 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3755 error "open unlink test1 failed"
3756 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3757 error "open unlink test2 failed"
3759 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3760 error "test1 still exists"
3761 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3762 error "test2 still exists"
3764 run_test 31p "remove of open striped directory"
3767 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3769 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3770 index=$($LFS getdirstripe -i $DIR/$tdir)
3771 [ $index -eq 3 ] || error "first stripe index $index != 3"
3772 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3773 [ $index -eq 1 ] || error "second stripe index $index != 1"
3775 # when "-c <stripe_count>" is set, the number of MDTs specified after
3776 # "-i" should equal to the stripe count
3777 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3779 run_test 31q "create striped directory on specific MDTs"
3783 touch $DIR/$tfile.target
3784 touch $DIR/$tfile.source
3786 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
3787 $LCTL set_param fail_loc=0x1419 fail_val=3
3788 cat $DIR/$tfile.target &
3791 # Guarantee open is waiting before we get here
3793 mv $DIR/$tfile.source $DIR/$tfile.target
3797 if [[ $RC -ne 0 ]]; then
3798 error "open with cat failed, rc=$RC"
3801 run_test 31r "open-rename(replace) race"
3803 cleanup_test32_mount() {
3806 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3807 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3808 losetup -d $loopdev || true
3814 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3816 echo "== more mountpoints and symlinks ================="
3817 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3818 trap cleanup_test32_mount EXIT
3819 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3820 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3821 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3822 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3823 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3824 cleanup_test32_mount
3826 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3831 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3832 trap cleanup_test32_mount EXIT
3833 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3834 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3835 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3836 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3837 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3838 cleanup_test32_mount
3840 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3843 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3845 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3846 trap cleanup_test32_mount EXIT
3847 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3848 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3849 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3850 test_mkdir -p $DIR/$tdir/d2/test_dir
3851 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3852 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3853 cleanup_test32_mount
3855 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3860 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3861 trap cleanup_test32_mount EXIT
3862 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3863 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3864 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3865 test_mkdir -p $DIR/$tdir/d2/test_dir
3866 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3867 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3868 cleanup_test32_mount
3870 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3874 test_mkdir -p $DIR/$tdir/tmp
3875 local tmp_dir=$DIR/$tdir/tmp
3876 ln -s $DIR/$tdir $tmp_dir/symlink11
3877 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3878 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3879 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3881 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3885 test_mkdir -p $DIR/$tdir/tmp
3886 local tmp_dir=$DIR/$tdir/tmp
3887 ln -s $DIR/$tdir $tmp_dir/symlink11
3888 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3889 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3890 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3892 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3895 local tmp_dir=$DIR/$tdir/tmp
3896 test_mkdir -p $tmp_dir
3897 test_mkdir $DIR/${tdir}2
3898 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3899 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3900 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3901 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3902 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3903 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3905 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3908 rm -fr $DIR/$tdir $DIR/${tdir}2
3909 tmp_dir=$DIR/$tdir/tmp
3910 test_mkdir -p $tmp_dir
3911 test_mkdir $DIR/${tdir}2
3912 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3913 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3914 ls $tmp_dir/symlink12 || error "listing symlink12"
3915 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3917 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3920 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3922 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3923 trap cleanup_test32_mount EXIT
3924 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3925 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3926 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3927 touch $DIR/$tdir/test_file
3928 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3929 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3930 cleanup_test32_mount
3932 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3935 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3937 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3938 trap cleanup_test32_mount EXIT
3939 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3940 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3941 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3942 touch $DIR/$tdir/test_file
3943 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3944 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3945 cleanup_test32_mount
3947 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3950 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3953 trap cleanup_test32_mount EXIT
3954 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3955 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3956 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3957 test_mkdir -p $DIR/$tdir/d2
3958 touch $DIR/$tdir/d2/test_file || error "touch failed"
3959 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3960 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3961 cleanup_test32_mount
3963 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3966 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3969 trap cleanup_test32_mount EXIT
3970 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3971 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3972 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3973 test_mkdir -p $DIR/$tdir/d2
3974 touch $DIR/$tdir/d2/test_file || error "touch failed"
3975 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3976 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3977 cleanup_test32_mount
3979 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3983 test_mkdir -p $DIR/d32m/tmp
3984 TMP_DIR=$DIR/d32m/tmp
3985 ln -s $DIR $TMP_DIR/symlink11
3986 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3987 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3988 error "symlink11 not a link"
3989 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3990 error "symlink01 not a link"
3992 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3996 test_mkdir -p $DIR/d32n/tmp
3997 TMP_DIR=$DIR/d32n/tmp
3998 ln -s $DIR $TMP_DIR/symlink11
3999 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
4000 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
4001 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
4003 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
4007 test_mkdir -p $DIR/d32o/tmp
4008 TMP_DIR=$DIR/d32o/tmp
4009 ln -s $DIR/$tfile $TMP_DIR/symlink12
4010 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4011 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
4012 error "symlink12 not a link"
4013 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
4014 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
4015 error "$DIR/d32o/tmp/symlink12 not file type"
4016 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
4017 error "$DIR/d32o/symlink02 not file type"
4019 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
4029 test_mkdir -p $DIR/d32p/tmp
4031 TMP_DIR=$DIR/d32p/tmp
4033 ln -s $DIR/$tfile $TMP_DIR/symlink12
4035 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4037 cat $DIR/d32p/tmp/symlink12 ||
4038 error "Can't open $DIR/d32p/tmp/symlink12"
4040 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
4043 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
4046 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4048 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4049 trap cleanup_test32_mount EXIT
4050 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4051 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4052 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4053 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4054 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
4055 cleanup_test32_mount
4057 run_test 32q "stat follows mountpoints in Lustre (should return error)"
4060 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4062 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4063 trap cleanup_test32_mount EXIT
4064 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4065 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4066 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4067 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4068 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
4069 cleanup_test32_mount
4071 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
4076 chmod 444 $DIR/$tfile
4077 chown $RUNAS_ID $DIR/$tfile
4079 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4082 run_test 33aa "write file with mode 444 (should return error)"
4086 test_mkdir $DIR/$tdir
4087 chown $RUNAS_ID $DIR/$tdir
4088 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
4089 error "$RUNAS create $tdir/$tfile failed"
4090 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4091 error "open RDWR" || true
4093 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4097 test_mkdir $DIR/$tdir
4098 chown $RUNAS_ID $DIR/$tdir
4099 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4101 run_test 33b "test open file with malformed flags (No panic)"
4104 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4105 remote_ost_nodsh && skip "remote OST with nodsh"
4113 test_mkdir $DIR/$tdir
4114 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4117 for ostnum in $(seq $OSTCOUNT); do
4118 # test-framework's OST numbering is one-based, while Lustre's
4120 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4121 # check if at least some write_bytes stats are counted
4122 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4123 obdfilter.$ostname.stats |
4124 awk '/^write_bytes/ {print $7}' )
4125 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4126 if (( ${write_bytes:-0} > 0 )); then
4132 $all_zeros || return 0
4135 echo foo > $DIR/$tdir/bar
4139 # Total up write_bytes after writing. We'd better find non-zeros.
4140 for ostnum in $(seq $OSTCOUNT); do
4141 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4142 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4143 obdfilter/$ostname/stats |
4144 awk '/^write_bytes/ {print $7}' )
4145 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4146 if (( ${write_bytes:-0} > 0 )); then
4153 for ostnum in $(seq $OSTCOUNT); do
4154 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4155 echo "Check write_bytes is in obdfilter.*.stats:"
4156 do_facet ost$ostnum lctl get_param -n \
4157 obdfilter.$ostname.stats
4159 error "OST not keeping write_bytes stats (b=22312)"
4162 run_test 33c "test write_bytes stats"
4165 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4166 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4169 local remote_dir=$DIR/$tdir/remote_dir
4171 test_mkdir $DIR/$tdir
4172 $LFS mkdir -i $MDTIDX $remote_dir ||
4173 error "create remote directory failed"
4175 touch $remote_dir/$tfile
4176 chmod 444 $remote_dir/$tfile
4177 chown $RUNAS_ID $remote_dir/$tfile
4179 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4181 chown $RUNAS_ID $remote_dir
4182 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4183 error "create" || true
4184 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4185 error "open RDWR" || true
4186 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4188 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4191 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4195 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4196 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4197 mkdir $DIR/$tdir/local_dir
4199 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4200 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4201 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4203 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4204 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4206 rmdir $DIR/$tdir/* || error "rmdir failed"
4209 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4210 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4211 mkdir $DIR/$tdir/local_dir
4213 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4214 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4215 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4217 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4218 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4220 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4223 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4224 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4225 mkdir $DIR/$tdir/local_dir
4227 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4228 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4229 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4231 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4232 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4234 run_test 33e "mkdir and striped directory should have same mode"
4238 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4242 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4243 remote_mds_nodsh && skip "remote MDS with nodsh"
4246 chmod go+rwx $DIR/$tdir
4247 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4248 trap cleanup_33f EXIT
4250 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4251 error "cannot create striped directory"
4253 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4254 error "cannot create files in striped directory"
4256 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4257 error "cannot remove files in striped directory"
4259 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4260 error "cannot remove striped directory"
4264 run_test 33f "nonroot user can create, access, and remove a striped directory"
4267 mkdir -p $DIR/$tdir/dir2
4269 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4271 [[ $err =~ "exists" ]] || error "Not exists error"
4273 run_test 33g "nonroot user create already existing root created file"
4279 test_mkdir -c $MDSCOUNT -H $hash_type $DIR/$tdir ||
4280 error "lfs mkdir -H $hash_type $tdir failed"
4281 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4283 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4287 for fname in $DIR/$tdir/$tfile.bak \
4288 $DIR/$tdir/$tfile.SAV \
4289 $DIR/$tdir/$tfile.orig \
4290 $DIR/$tdir/$tfile~; do
4291 touch $fname || error "touch $fname failed"
4292 index2=$($LFS getstripe -m $fname)
4293 (( $index == $index2 )) ||
4294 error "$fname MDT index mismatch $index != $index2"
4298 local patterns=(".$tfile.XXXXXX" "$tfile.XXXXXXXX")
4301 for pattern in ${patterns[*]}; do
4302 echo "pattern $pattern"
4303 fname=$DIR/$tdir/$pattern
4304 for (( i = 0; i < $count; i++ )); do
4305 fname=$(mktemp $DIR/$tdir/$pattern) ||
4306 error "mktemp $DIR/$tdir/$pattern failed"
4307 index2=$($LFS getstripe -m $fname)
4308 (( $index == $index2 )) && continue
4310 failed=$((failed + 1))
4311 echo "$fname MDT index mismatch $index != $index2"
4315 echo "$failed/$count MDT index mismatches, expect ~2-4"
4316 (( failed < 10 )) || error "MDT index mismatch $failed/$count times"
4321 # verify that "crush" is still broken with all files on same MDT,
4322 # crush2 should have about 1/MDSCOUNT files on each MDT, with margin
4323 [[ "$hash_type" == "crush" ]] && expect=$count ||
4324 expect=$((count / MDSCOUNT))
4326 # crush2 doesn't put all-numeric suffixes on the same MDT,
4327 # filename like $tfile.12345678 should *not* be considered temp
4328 for pattern in ${patterns[*]}; do
4329 local base=${pattern%%X*}
4330 local suff=${pattern#$base}
4332 echo "pattern $pattern"
4333 for (( i = 0; i < $count; i++ )); do
4334 fname=$DIR/$tdir/$base$((${suff//X/1} + i))
4335 touch $fname || error "touch $fname failed"
4336 index2=$($LFS getstripe -m $fname)
4337 (( $index != $index2 )) && continue
4343 # the number of "bad" hashes is random, as it depends on the random
4344 # filenames generated by "mktemp". Allow some margin in the results.
4345 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4346 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4347 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4348 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4351 # crush2 doesn't put suffixes with special characters on the same MDT
4352 # filename like $tfile.txt.1234 should *not* be considered temp
4353 for pattern in ${patterns[*]}; do
4354 local base=${pattern%%X*}
4355 local suff=${pattern#$base}
4357 pattern=$base...${suff/XXX}
4358 echo "pattern=$pattern"
4359 for (( i = 0; i < $count; i++ )); do
4360 fname=$(mktemp $DIR/$tdir/$pattern) ||
4361 error "touch $fname failed"
4362 index2=$($LFS getstripe -m $fname)
4363 (( $index != $index2 )) && continue
4369 # the number of "bad" hashes is random, as it depends on the random
4370 # filenames generated by "mktemp". Allow some margin in the results.
4371 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4372 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4373 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4374 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4378 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4379 (( $MDS1_VERSION >= $(version_code 2.13.50) )) ||
4380 skip "Need MDS version at least 2.13.50"
4384 run_test 33h "temp file is located on the same MDT as target (crush)"
4387 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4388 echo "MDS1_VERSION=$MDS1_VERSION version_code=$(version_code 2.15.0)"
4389 (( $MDS1_VERSION > $(version_code 2.15.0) )) ||
4390 skip "Need MDS version at least 2.15.0 for crush2"
4394 run_test 33hh "temp file is located on the same MDT as target (crush2)"
4398 (( MDSCOUNT < 2 )) && skip "needs >= 2 MDTs"
4400 local FNAME=$(str_repeat 'f' 250)
4402 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
4403 createmany -o $DIR/$tdir/$FNAME 1000 || error "createmany failed"
4408 count=$($LFS getstripe -m $DIR/$tdir/* | grep -cw 1)
4410 local MDC=$(lctl dl | awk '/MDT0001-mdc-[^M]/ { print $4 }')
4412 lctl --device %$MDC deactivate
4413 stack_trap "lctl --device %$MDC activate"
4414 ls $DIR/$tdir > /dev/null && error "ls should return an error"
4415 total=$(\ls -l $DIR/$tdir | wc -l)
4416 # "ls -l" will list total in the first line
4417 total=$((total - 1))
4418 (( total + count == 1000 )) ||
4419 error "ls list $total files, $count files on MDT1"
4421 run_test 33i "striped directory can be accessed when one MDT is down"
4424 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4426 mkdir -p $DIR/$tdir/
4428 $LFS setdirstripe -D -i0,1 $DIR/$tdir/striped_dir_a &&
4429 error "setdirstripe -D -i0,1 incorrectly succeeded"
4431 $LFS setdirstripe -D -i0,1 -c1 $DIR/$tdir/striped_dir_b &&
4432 error "setdirstripe -D -i0,1 -c1 incorrectly succeeded"
4434 $LFS setdirstripe -D -i0,1 -c3 $DIR/$tdir/striped_dir_c &&
4435 error "setdirstripe -D -i0,1 -c3 incorrectly succeeded"
4437 $LFS setdirstripe -i0,1 $DIR/$tdir/striped_dir_e ||
4438 error "-D was not specified, but still failed"
4440 run_test 33j "lfs setdirstripe -D -i x,y,x should fail"
4442 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4445 $MCREATE $DIR/f34 || error "mcreate failed"
4446 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4447 error "getstripe failed"
4448 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4449 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4450 error "getstripe failed"
4451 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4452 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4454 run_test 34a "truncate file that has not been opened ==========="
4457 [ ! -f $DIR/f34 ] && test_34a
4458 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4459 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4460 $OPENFILE -f O_RDONLY $DIR/f34
4461 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4462 error "getstripe failed"
4463 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4464 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4466 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4469 [ ! -f $DIR/f34 ] && test_34a
4470 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4471 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4472 $OPENFILE -f O_RDWR $DIR/f34
4473 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4474 error "$LFS getstripe failed"
4475 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4476 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4478 run_test 34c "O_RDWR opening file-with-size works =============="
4481 [ ! -f $DIR/f34 ] && test_34a
4482 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4484 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4485 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4488 run_test 34d "write to sparse file ============================="
4492 $MCREATE $DIR/f34e || error "mcreate failed"
4493 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4494 $CHECKSTAT -s 1000 $DIR/f34e ||
4495 error "Size of $DIR/f34e not equal to 1000 bytes"
4496 $OPENFILE -f O_RDWR $DIR/f34e
4497 $CHECKSTAT -s 1000 $DIR/f34e ||
4498 error "Size of $DIR/f34e not equal to 1000 bytes"
4500 run_test 34e "create objects, some with size and some without =="
4502 test_34f() { # bug 6242, 6243
4503 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4507 $MCREATE $DIR/f34f || error "mcreate failed"
4508 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4509 dd if=$DIR/f34f of=$TMP/f34f
4510 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4511 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4512 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4513 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4514 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4516 run_test 34f "read from a file with no objects until EOF ======="
4519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4521 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4523 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4524 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4525 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4526 cancel_lru_locks osc
4527 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4528 error "wrong size after lock cancel"
4530 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4531 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4532 error "expanding truncate failed"
4533 cancel_lru_locks osc
4534 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4535 error "wrong expanded size after lock cancel"
4537 run_test 34g "truncate long file ==============================="
4540 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4545 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4546 sync # Flush the cache so that multiop below does not block on cache
4547 # flush when getting the group lock
4548 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4551 # Since just timed wait is not good enough, let's do a sync write
4552 # that way we are sure enough time for a roundtrip + processing
4553 # passed + 2 seconds of extra margin.
4554 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4558 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4559 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4563 local nsz=`stat -c %s $DIR/$tfile`
4564 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4566 run_test 34h "ftruncate file under grouplock should not block"
4569 cp /bin/sh $DIR/f35a
4571 chown $RUNAS_ID $DIR/f35a
4572 $RUNAS $DIR/f35a && error || true
4575 run_test 35a "exec file with mode 444 (should return and not leak)"
4579 utime $DIR/f36 || error "utime failed for MDS"
4581 run_test 36a "MDS utime check (mknod, utime)"
4585 utime $DIR/f36 || error "utime failed for OST"
4587 run_test 36b "OST utime check (open, utime)"
4592 chown $RUNAS_ID $DIR/d36
4593 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4595 run_test 36c "non-root MDS utime check (mknod, utime)"
4598 [ ! -d $DIR/d36 ] && test_36c
4599 echo "" > $DIR/d36/f36
4600 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4602 run_test 36d "non-root OST utime check (open, utime)"
4605 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4607 test_mkdir $DIR/$tdir
4608 touch $DIR/$tdir/$tfile
4609 $RUNAS utime $DIR/$tdir/$tfile &&
4610 error "utime worked, expected failure" || true
4612 run_test 36e "utime on non-owned file (should return error)"
4616 local LANG_SAVE=$LANG
4617 local LC_LANG_SAVE=$LC_LANG
4618 export LANG=C LC_LANG=C # for date language
4620 DATESTR="Dec 20 2000"
4621 test_mkdir $DIR/$tdir
4622 lctl set_param fail_loc=$fl
4624 cp /etc/hosts $DIR/$tdir/$tfile
4625 sync & # write RPC generated with "current" inode timestamp, but delayed
4627 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4628 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4629 cancel_lru_locks $OSC
4630 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4632 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4633 echo "BEFORE: $LS_BEFORE" && \
4634 echo "AFTER : $LS_AFTER" && \
4635 echo "WANT : $DATESTR" && \
4636 error "$DIR/$tdir/$tfile timestamps changed" || true
4638 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4642 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4644 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4645 subr_36fh "0x80000214"
4647 run_test 36f "utime on file racing with OST BRW write =========="
4650 remote_ost_nodsh && skip "remote OST with nodsh"
4651 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4652 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4653 skip "Need MDS version at least 2.12.51"
4658 local tgt="obdfilter"
4660 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4662 test_mkdir $DIR/$tdir
4663 fmd_max_age=$(do_facet $facet \
4664 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4667 echo "FMD max age: ${fmd_max_age}s"
4668 touch $DIR/$tdir/$tfile
4669 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4670 gawk '{cnt=cnt+$1} END{print cnt}')
4671 echo "FMD before: $fmd"
4673 error "FMD wasn't create by touch"
4674 sleep $((fmd_max_age + 12))
4675 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4676 gawk '{cnt=cnt+$1} END{print cnt}')
4677 echo "FMD after: $fmd"
4679 error "FMD wasn't expired by ping"
4681 run_test 36g "FMD cache expiry ====================="
4684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4686 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4687 subr_36fh "0x80000227"
4689 run_test 36h "utime on file racing with OST BRW write =========="
4692 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4694 test_mkdir $DIR/$tdir
4695 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4697 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4698 local new_mtime=$((mtime + 200))
4700 #change Modify time of striped dir
4701 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4702 error "change mtime failed"
4704 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4706 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4708 run_test 36i "change mtime on striped directory"
4710 # test_37 - duplicate with tests 32q 32r
4713 local file=$DIR/$tfile
4715 openfile -f O_DIRECTORY $file
4718 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4719 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4721 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4723 test_39a() { # was test_39
4725 touch $DIR/${tfile}2
4726 # ls -l $DIR/$tfile $DIR/${tfile}2
4727 # ls -lu $DIR/$tfile $DIR/${tfile}2
4728 # ls -lc $DIR/$tfile $DIR/${tfile}2
4730 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4731 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4733 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4735 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4737 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4738 error "O_TRUNC didn't change timestamps"
4741 run_test 39a "mtime changed on create"
4744 test_mkdir -c1 $DIR/$tdir
4745 cp -p /etc/passwd $DIR/$tdir/fopen
4746 cp -p /etc/passwd $DIR/$tdir/flink
4747 cp -p /etc/passwd $DIR/$tdir/funlink
4748 cp -p /etc/passwd $DIR/$tdir/frename
4749 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4752 echo "aaaaaa" >> $DIR/$tdir/fopen
4753 echo "aaaaaa" >> $DIR/$tdir/flink
4754 echo "aaaaaa" >> $DIR/$tdir/funlink
4755 echo "aaaaaa" >> $DIR/$tdir/frename
4757 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4758 local link_new=`stat -c %Y $DIR/$tdir/flink`
4759 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4760 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4762 cat $DIR/$tdir/fopen > /dev/null
4763 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4764 rm -f $DIR/$tdir/funlink2
4765 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4767 for (( i=0; i < 2; i++ )) ; do
4768 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4769 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4770 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4771 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4773 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4774 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4775 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4776 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4778 cancel_lru_locks $OSC
4779 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4782 run_test 39b "mtime change on open, link, unlink, rename ======"
4784 # this should be set to past
4785 TEST_39_MTIME=`date -d "1 year ago" +%s`
4791 local mtime0=`stat -c %Y $DIR1/$tfile`
4793 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4794 local mtime1=`stat -c %Y $DIR1/$tfile`
4795 [ "$mtime1" = $TEST_39_MTIME ] || \
4796 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4799 echo hello >> $DIR1/$tfile
4801 local mtime2=`stat -c %Y $DIR1/$tfile`
4802 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4803 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4805 mv $DIR1/$tfile $DIR1/$tfile-1
4807 for (( i=0; i < 2; i++ )) ; do
4808 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4809 [ "$mtime2" = "$mtime3" ] || \
4810 error "mtime ($mtime2) changed (to $mtime3) on rename"
4812 cancel_lru_locks $OSC
4813 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4816 run_test 39c "mtime change on rename ==========================="
4820 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4823 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4825 for (( i=0; i < 2; i++ )) ; do
4826 local mtime=`stat -c %Y $DIR1/$tfile`
4827 [ $mtime = $TEST_39_MTIME ] || \
4828 error "mtime($mtime) is not set to $TEST_39_MTIME"
4830 cancel_lru_locks $OSC
4831 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4834 run_test 39d "create, utime, stat =============================="
4838 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4841 local mtime1=`stat -c %Y $DIR1/$tfile`
4843 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4845 for (( i=0; i < 2; i++ )) ; do
4846 local mtime2=`stat -c %Y $DIR1/$tfile`
4847 [ $mtime2 = $TEST_39_MTIME ] || \
4848 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4850 cancel_lru_locks $OSC
4851 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4854 run_test 39e "create, stat, utime, stat ========================"
4858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4861 mtime1=`stat -c %Y $DIR1/$tfile`
4864 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4866 for (( i=0; i < 2; i++ )) ; do
4867 local mtime2=`stat -c %Y $DIR1/$tfile`
4868 [ $mtime2 = $TEST_39_MTIME ] || \
4869 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4871 cancel_lru_locks $OSC
4872 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4875 run_test 39f "create, stat, sleep, utime, stat ================="
4879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4881 echo hello >> $DIR1/$tfile
4882 local mtime1=`stat -c %Y $DIR1/$tfile`
4885 chmod o+r $DIR1/$tfile
4887 for (( i=0; i < 2; i++ )) ; do
4888 local mtime2=`stat -c %Y $DIR1/$tfile`
4889 [ "$mtime1" = "$mtime2" ] || \
4890 error "lost mtime: $mtime2, should be $mtime1"
4892 cancel_lru_locks $OSC
4893 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4896 run_test 39g "write, chmod, stat ==============================="
4900 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4906 echo hello >> $DIR1/$tfile
4907 local mtime1=`stat -c %Y $DIR1/$tfile`
4909 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4911 if [ "$d1" != "$d2" ]; then
4912 echo "write and touch not within one second"
4914 for (( i=0; i < 2; i++ )) ; do
4915 local mtime2=`stat -c %Y $DIR1/$tfile`
4916 [ "$mtime2" = $TEST_39_MTIME ] || \
4917 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4919 cancel_lru_locks $OSC
4920 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4924 run_test 39h "write, utime within one second, stat ============="
4927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4932 echo hello >> $DIR1/$tfile
4933 local mtime1=`stat -c %Y $DIR1/$tfile`
4935 mv $DIR1/$tfile $DIR1/$tfile-1
4937 for (( i=0; i < 2; i++ )) ; do
4938 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4940 [ "$mtime1" = "$mtime2" ] || \
4941 error "lost mtime: $mtime2, should be $mtime1"
4943 cancel_lru_locks $OSC
4944 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4947 run_test 39i "write, rename, stat =============================="
4950 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4952 start_full_debug_logging
4956 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4957 lctl set_param fail_loc=0x80000412
4958 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4959 error "multiop failed"
4961 local mtime1=`stat -c %Y $DIR1/$tfile`
4963 mv $DIR1/$tfile $DIR1/$tfile-1
4965 kill -USR1 $multipid
4966 wait $multipid || error "multiop close failed"
4968 for (( i=0; i < 2; i++ )) ; do
4969 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4970 [ "$mtime1" = "$mtime2" ] ||
4971 error "mtime is lost on close: $mtime2, " \
4975 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4977 lctl set_param fail_loc=0
4978 stop_full_debug_logging
4980 run_test 39j "write, rename, close, stat ======================="
4983 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4988 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4990 local mtime1=`stat -c %Y $DIR1/$tfile`
4992 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4994 kill -USR1 $multipid
4995 wait $multipid || error "multiop close failed"
4997 for (( i=0; i < 2; i++ )) ; do
4998 local mtime2=`stat -c %Y $DIR1/$tfile`
5000 [ "$mtime2" = $TEST_39_MTIME ] || \
5001 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
5004 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5007 run_test 39k "write, utime, close, stat ========================"
5009 # this should be set to future
5010 TEST_39_ATIME=`date -d "1 year" +%s`
5013 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5014 remote_mds_nodsh && skip "remote MDS with nodsh"
5016 local atime_diff=$(do_facet $SINGLEMDS \
5017 lctl get_param -n mdd.*MDT0000*.atime_diff)
5019 mkdir_on_mdt0 $DIR/$tdir
5021 # test setting directory atime to future
5022 touch -a -d @$TEST_39_ATIME $DIR/$tdir
5023 local atime=$(stat -c %X $DIR/$tdir)
5024 [ "$atime" = $TEST_39_ATIME ] ||
5025 error "atime is not set to future: $atime, $TEST_39_ATIME"
5027 # test setting directory atime from future to now
5028 local now=$(date +%s)
5029 touch -a -d @$now $DIR/$tdir
5031 atime=$(stat -c %X $DIR/$tdir)
5032 [ "$atime" -eq "$now" ] ||
5033 error "atime is not updated from future: $atime, $now"
5035 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
5038 # test setting directory atime when now > dir atime + atime_diff
5039 local d1=$(date +%s)
5041 local d2=$(date +%s)
5042 cancel_lru_locks mdc
5043 atime=$(stat -c %X $DIR/$tdir)
5044 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5045 error "atime is not updated : $atime, should be $d2"
5047 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
5050 # test not setting directory atime when now < dir atime + atime_diff
5052 cancel_lru_locks mdc
5053 atime=$(stat -c %X $DIR/$tdir)
5054 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5055 error "atime is updated to $atime, should remain $d1<atime<$d2"
5057 do_facet $SINGLEMDS \
5058 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5060 run_test 39l "directory atime update ==========================="
5063 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5067 local far_past_mtime=$(date -d "May 29 1953" +%s)
5068 local far_past_atime=$(date -d "Dec 17 1903" +%s)
5070 touch -m -d @$far_past_mtime $DIR1/$tfile
5071 touch -a -d @$far_past_atime $DIR1/$tfile
5073 for (( i=0; i < 2; i++ )) ; do
5074 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
5075 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
5076 error "atime or mtime set incorrectly"
5078 cancel_lru_locks $OSC
5079 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5082 run_test 39m "test atime and mtime before 1970"
5084 test_39n() { # LU-3832
5085 remote_mds_nodsh && skip "remote MDS with nodsh"
5087 local atime_diff=$(do_facet $SINGLEMDS \
5088 lctl get_param -n mdd.*MDT0000*.atime_diff)
5093 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
5096 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
5097 atime0=$(stat -c %X $DIR/$tfile)
5100 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5101 atime1=$(stat -c %X $DIR/$tfile)
5104 cancel_lru_locks mdc
5105 cancel_lru_locks osc
5106 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5107 atime2=$(stat -c %X $DIR/$tfile)
5109 do_facet $SINGLEMDS \
5110 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5112 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
5113 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
5115 run_test 39n "check that O_NOATIME is honored"
5118 TESTDIR=$DIR/$tdir/$tfile
5119 [ -e $TESTDIR ] && rm -rf $TESTDIR
5126 links2=$(stat -c %h .)
5127 [ $(($links1 + 2)) != $links2 ] &&
5128 error "wrong links count $(($links1 + 2)) != $links2"
5130 links3=$(stat -c %h .)
5131 [ $(($links1 + 1)) != $links3 ] &&
5132 error "wrong links count $links1 != $links3"
5135 run_test 39o "directory cached attributes updated after create"
5138 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
5141 TESTDIR=$DIR/$tdir/$tdir
5142 [ -e $TESTDIR ] && rm -rf $TESTDIR
5143 test_mkdir -p $TESTDIR
5147 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
5148 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
5150 links2=$(stat -c %h .)
5151 [ $(($links1 + 2)) != $links2 ] &&
5152 error "wrong links count $(($links1 + 2)) != $links2"
5154 links3=$(stat -c %h .)
5155 [ $(($links1 + 1)) != $links3 ] &&
5156 error "wrong links count $links1 != $links3"
5159 run_test 39p "remote directory cached attributes updated after create ========"
5162 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
5163 skip "no atime update on old OST"
5164 if [ "$ost1_FSTYPE" != ldiskfs ]; then
5165 skip_env "ldiskfs only test"
5169 saved_adiff=$(do_facet ost1 \
5170 lctl get_param -n obdfilter.*OST0000.atime_diff)
5171 stack_trap "do_facet ost1 \
5172 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
5174 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
5176 $LFS setstripe -i 0 $DIR/$tfile
5177 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
5178 error "can't write initial file"
5179 cancel_lru_locks osc
5181 # exceed atime_diff and access file
5183 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
5184 error "can't udpate atime"
5186 local atime_cli=$(stat -c %X $DIR/$tfile)
5187 echo "client atime: $atime_cli"
5188 # allow atime update to be written to device
5189 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
5192 local ostdev=$(ostdevname 1)
5193 local fid=($($LFS getstripe $DIR/$tfile | grep 0x))
5194 local seq=${fid[3]#0x}
5198 if [ $seq == 0 ]; then
5201 oid_hex=${fid[2]#0x}
5203 local objpath="O/$seq/d$(($oid % 32))/$oid_hex"
5204 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
5206 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
5207 local atime_ost=$(do_facet ost1 "$cmd" |&
5208 awk -F'[: ]' '/atime:/ { print $4 }')
5209 (( atime_cli == atime_ost )) ||
5210 error "atime on client $atime_cli != ost $atime_ost"
5212 run_test 39r "lazy atime update on OST"
5214 test_39q() { # LU-8041
5215 local testdir=$DIR/$tdir
5217 multiop_bg_pause $testdir D_c || error "multiop failed"
5219 cancel_lru_locks mdc
5220 kill -USR1 $multipid
5221 local atime=$(stat -c %X $testdir)
5222 [ "$atime" -ne 0 ] || error "atime is zero"
5224 run_test 39q "close won't zero out atime"
5233 umount_client $MOUNT
5234 mount_client $MOUNT relatime
5236 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer conv=fsync
5237 atime0=$(stat -c %X $DIR/$tfile)
5239 # First read updates atime
5241 cat $DIR/$tfile >/dev/null
5242 atime1=$(stat -c %X $DIR/$tfile) # (atime = atime0 + 1)
5244 # Next reads do not update atime
5246 cat $DIR/$tfile >/dev/null
5247 atime2=$(stat -c %X $DIR/$tfile) # (atime = atime0 + 1)
5249 # If mtime is greater than atime, atime is updated
5251 touch -m $DIR/$tfile # (mtime = now)
5253 cat $DIR/$tfile >/dev/null # (atime is updated because atime < mtime)
5254 atime3=$(stat -c %X $DIR/$tfile) # (atime = mtime = atime0 + 3)
5256 # Next reads do not update atime
5258 cat $DIR/$tfile >/dev/null
5259 atime4=$(stat -c %X $DIR/$tfile)
5261 # Remount the client to clear 'relatime' option
5262 remount_client $MOUNT
5264 if (( MDS1_VERSION >= $(version_code 2.15.50) )); then
5265 # The full test lasted less than default atime_diff
5266 # Client was remounted to clear 'relatime' option for next tests
5267 # and to confirm atime was written to disk
5268 local atime5=$(stat -c %X $DIR/$tfile)
5269 (( atime3 == atime5 )) ||
5270 error "atime3 $atime3 != atime5 $atime5"
5273 (( atime0 < atime1 )) ||
5274 error "atime $atime0 should be smaller than $atime1"
5275 (( atime1 == atime2 )) ||
5276 error "atime $atime1 was updated to $atime2"
5277 (( atime1 < atime3 )) || error "atime1 $atime1 != atime3 $atime3"
5278 (( atime3 == atime4 )) || error "atime3 $atime3 != atime4 $atime4"
5280 run_test 39s "relatime is supported"
5283 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5284 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5285 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5286 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5287 error "$tfile is not 4096 bytes in size"
5289 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5293 small_write $DIR/f41 18
5295 run_test 41 "test small file write + fstat ====================="
5297 count_ost_writes() {
5298 lctl get_param -n ${OSC}.*.stats |
5299 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5300 END { printf("%0.0f", writes) }'
5307 BG_DIRTY_RATIO_SAVE=10
5308 MAX_BG_DIRTY_RATIO=25
5312 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5313 # dirty_ratio, dirty_background_ratio
5314 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5315 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5316 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5317 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5319 # if file not here, we are a 2.4 kernel
5320 kill -CONT `pidof kupdated`
5325 # setup the trap first, so someone cannot exit the test at the
5326 # exact wrong time and mess up a machine
5327 trap start_writeback EXIT
5328 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5329 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5330 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5331 sysctl -w vm.dirty_writeback_centisecs=0
5332 sysctl -w vm.dirty_writeback_centisecs=0
5333 # save and increase /proc/sys/vm/dirty_ratio
5334 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5335 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5336 # save and increase /proc/sys/vm/dirty_background_ratio
5337 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5338 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5340 # if file not here, we are a 2.4 kernel
5341 kill -STOP `pidof kupdated`
5345 # ensure that all stripes have some grant before we test client-side cache
5347 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5348 dd if=/dev/zero of=$i bs=4k count=1
5353 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5354 # file truncation, and file removal.
5356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5359 cancel_lru_locks $OSC
5361 sync; sleep 1; sync # just to be safe
5362 BEFOREWRITES=`count_ost_writes`
5363 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5364 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5365 AFTERWRITES=`count_ost_writes`
5366 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5367 error "$BEFOREWRITES < $AFTERWRITES"
5370 run_test 42a "ensure that we don't flush on close"
5373 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5376 cancel_lru_locks $OSC
5379 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5380 BEFOREWRITES=$(count_ost_writes)
5381 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
5382 AFTERWRITES=$(count_ost_writes)
5383 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5384 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5386 BEFOREWRITES=$(count_ost_writes)
5387 sync || error "sync: $?"
5388 AFTERWRITES=$(count_ost_writes)
5389 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5390 error "$BEFOREWRITES < $AFTERWRITES on sync"
5392 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5396 run_test 42b "test destroy of file with cached dirty data ======"
5398 # if these tests just want to test the effect of truncation,
5399 # they have to be very careful. consider:
5400 # - the first open gets a {0,EOF}PR lock
5401 # - the first write conflicts and gets a {0, count-1}PW
5402 # - the rest of the writes are under {count,EOF}PW
5403 # - the open for truncate tries to match a {0,EOF}PR
5404 # for the filesize and cancels the PWs.
5405 # any number of fixes (don't get {0,EOF} on open, match
5406 # composite locks, do smarter file size management) fix
5407 # this, but for now we want these tests to verify that
5408 # the cancellation with truncate intent works, so we
5409 # start the file with a full-file pw lock to match against
5410 # until the truncate.
5415 cancel_lru_locks $OSC
5417 # prime the file with 0,EOF PW to match
5421 # now the real test..
5422 dd if=/dev/zero of=$file bs=1024 count=100
5423 BEFOREWRITES=`count_ost_writes`
5424 $TRUNCATE $file $offset
5425 cancel_lru_locks $OSC
5426 AFTERWRITES=`count_ost_writes`
5431 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5434 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5435 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5438 run_test 42c "test partial truncate of file with cached dirty data"
5441 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5443 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
5444 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
5445 $LCTL set_param debug=+cache
5448 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5449 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5452 run_test 42d "test complete truncate of file with cached dirty data"
5454 test_42e() { # bug22074
5455 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5457 local TDIR=$DIR/${tdir}e
5458 local pages=16 # hardcoded 16 pages, don't change it.
5459 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5460 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5464 test_mkdir $DIR/${tdir}e
5465 $LFS setstripe -c 1 $TDIR
5466 createmany -o $TDIR/f $files
5468 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5470 # we assume that with $OSTCOUNT files, at least one of them will
5471 # be allocated on OST0.
5472 warmup_files=$((OSTCOUNT * max_dirty_mb))
5473 createmany -o $TDIR/w $warmup_files
5475 # write a large amount of data into one file and sync, to get good
5476 # avail_grant number from OST.
5477 for ((i=0; i<$warmup_files; i++)); do
5478 idx=$($LFS getstripe -i $TDIR/w$i)
5479 [ $idx -ne 0 ] && continue
5480 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5483 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5485 $LCTL get_param $proc_osc0/cur_dirty_bytes
5486 $LCTL get_param $proc_osc0/cur_grant_bytes
5488 # create as much dirty pages as we can while not to trigger the actual
5489 # RPCs directly. but depends on the env, VFS may trigger flush during this
5490 # period, hopefully we are good.
5491 for ((i=0; i<$warmup_files; i++)); do
5492 idx=$($LFS getstripe -i $TDIR/w$i)
5493 [ $idx -ne 0 ] && continue
5494 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5496 $LCTL get_param $proc_osc0/cur_dirty_bytes
5497 $LCTL get_param $proc_osc0/cur_grant_bytes
5499 # perform the real test
5500 $LCTL set_param $proc_osc0/rpc_stats 0
5501 for ((;i<$files; i++)); do
5502 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5503 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5506 $LCTL get_param $proc_osc0/rpc_stats
5509 local have_ppr=false
5510 $LCTL get_param $proc_osc0/rpc_stats |
5511 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5512 # skip lines until we are at the RPC histogram data
5513 [ "$PPR" == "pages" ] && have_ppr=true && continue
5514 $have_ppr || continue
5516 # we only want the percent stat for < 16 pages
5517 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5519 percent=$((percent + WPCT))
5520 if [[ $percent -gt 15 ]]; then
5521 error "less than 16-pages write RPCs" \
5528 run_test 42e "verify sub-RPC writes are not done synchronously"
5530 test_43A() { # was test_43
5531 test_mkdir $DIR/$tdir
5532 cp -p /bin/ls $DIR/$tdir/$tfile
5533 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5535 # give multiop a chance to open
5538 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5540 # Wait for multiop to exit
5543 run_test 43A "execution of file opened for write should return -ETXTBSY"
5546 test_mkdir $DIR/$tdir
5547 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5548 $DIR/$tdir/sleep 60 &
5550 # Make sure exec of $tdir/sleep wins race with truncate
5552 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5555 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5558 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5560 test_mkdir $DIR/$tdir
5561 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5562 $DIR/$tdir/sleep 60 &
5564 # Make sure exec of $tdir/sleep wins race with truncate
5566 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5569 run_test 43b "truncate of file being executed should return -ETXTBSY"
5572 local testdir="$DIR/$tdir"
5575 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5576 ( cd $testdir && md5sum -c )
5578 run_test 43c "md5sum of copy into lustre"
5580 test_44A() { # was test_44
5581 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5583 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5584 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5586 run_test 44A "zero length read from a sparse stripe"
5589 local nstripe=$($LFS getstripe -c -d $DIR)
5590 [ -z "$nstripe" ] && skip "can't get stripe info"
5591 [[ $nstripe -gt $OSTCOUNT ]] &&
5592 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5594 local stride=$($LFS getstripe -S -d $DIR)
5595 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5596 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5599 OFFSETS="0 $((stride/2)) $((stride-1))"
5600 for offset in $OFFSETS; do
5601 for i in $(seq 0 $((nstripe-1))); do
5602 local GLOBALOFFSETS=""
5604 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5605 local myfn=$DIR/d44a-$size
5606 echo "--------writing $myfn at $size"
5607 ll_sparseness_write $myfn $size ||
5608 error "ll_sparseness_write"
5609 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5610 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5611 error "ll_sparseness_verify $GLOBALOFFSETS"
5613 for j in $(seq 0 $((nstripe-1))); do
5615 size=$((((j + $nstripe )*$stride + $offset)))
5616 ll_sparseness_write $myfn $size ||
5617 error "ll_sparseness_write"
5618 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5620 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5621 error "ll_sparseness_verify $GLOBALOFFSETS"
5626 run_test 44a "test sparse pwrite ==============================="
5630 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5636 before=`dirty_osc_total`
5637 echo executing "\"$*\""
5639 after=`dirty_osc_total`
5640 echo before $before, after $after
5643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5646 # Obtain grants from OST if it supports it
5647 echo blah > ${f}_grant
5650 do_dirty_record "echo blah > $f"
5651 [[ $before -eq $after ]] && error "write wasn't cached"
5652 do_dirty_record "> $f"
5653 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5654 do_dirty_record "echo blah > $f"
5655 [[ $before -eq $after ]] && error "write wasn't cached"
5656 do_dirty_record "sync"
5657 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5658 do_dirty_record "echo blah > $f"
5659 [[ $before -eq $after ]] && error "write wasn't cached"
5660 do_dirty_record "cancel_lru_locks osc"
5661 [[ $before -gt $after ]] ||
5662 error "lock cancellation didn't lower dirty count"
5665 run_test 45 "osc io page accounting ============================"
5667 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5668 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5669 # objects offset and an assert hit when an rpc was built with 1023's mapped
5670 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5672 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5677 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5679 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5680 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5684 run_test 46 "dirtying a previously written page ================"
5686 # test_47 is removed "Device nodes check" is moved to test_28
5688 test_48a() { # bug 2399
5689 [ "$mds1_FSTYPE" = "zfs" ] &&
5690 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5691 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5693 test_mkdir $DIR/$tdir
5695 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5696 test_mkdir $DIR/$tdir
5697 touch foo || error "'touch foo' failed after recreating cwd"
5699 touch .foo || error "'touch .foo' failed after recreating cwd"
5701 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5702 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5703 cd . || error "'cd .' failed after recreating cwd"
5704 mkdir . && error "'mkdir .' worked after recreating cwd"
5705 rmdir . && error "'rmdir .' worked after recreating cwd"
5706 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5707 cd .. || error "'cd ..' failed after recreating cwd"
5709 run_test 48a "Access renamed working dir (should return errors)="
5711 test_48b() { # bug 2399
5713 test_mkdir $DIR/$tdir
5715 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5716 touch foo && error "'touch foo' worked after removing cwd"
5717 mkdir foo && error "'mkdir foo' worked after removing cwd"
5718 touch .foo && error "'touch .foo' worked after removing cwd"
5719 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5720 ls . > /dev/null && error "'ls .' worked after removing cwd"
5721 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5722 mkdir . && error "'mkdir .' worked after removing cwd"
5723 rmdir . && error "'rmdir .' worked after removing cwd"
5724 ln -s . foo && error "'ln -s .' worked after removing cwd"
5725 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5727 run_test 48b "Access removed working dir (should return errors)="
5729 test_48c() { # bug 2350
5730 #lctl set_param debug=-1
5733 test_mkdir -p $DIR/$tdir/dir
5735 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5736 $TRACE touch foo && error "touch foo worked after removing cwd"
5737 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5738 touch .foo && error "touch .foo worked after removing cwd"
5739 mkdir .foo && error "mkdir .foo worked after removing cwd"
5740 $TRACE ls . && error "'ls .' worked after removing cwd"
5741 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5742 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5743 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5744 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5745 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5747 run_test 48c "Access removed working subdir (should return errors)"
5749 test_48d() { # bug 2350
5750 #lctl set_param debug=-1
5753 test_mkdir -p $DIR/$tdir/dir
5755 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5756 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5757 $TRACE touch foo && error "'touch foo' worked after removing parent"
5758 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5759 touch .foo && error "'touch .foo' worked after removing parent"
5760 mkdir .foo && error "mkdir .foo worked after removing parent"
5761 $TRACE ls . && error "'ls .' worked after removing parent"
5762 $TRACE ls .. && error "'ls ..' worked after removing parent"
5763 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5764 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5765 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5768 run_test 48d "Access removed parent subdir (should return errors)"
5770 test_48e() { # bug 4134
5771 #lctl set_param debug=-1
5774 test_mkdir -p $DIR/$tdir/dir
5776 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5777 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5778 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5779 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5780 # On a buggy kernel addition of "touch foo" after cd .. will
5781 # produce kernel oops in lookup_hash_it
5782 touch ../foo && error "'cd ..' worked after recreate parent"
5784 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5786 run_test 48e "Access to recreated parent subdir (should return errors)"
5789 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5790 skip "need MDS >= 2.13.55"
5791 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5792 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5793 skip "needs different host for mdt1 mdt2"
5794 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5796 $LFS mkdir -i0 $DIR/$tdir
5797 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5799 for d in sub1 sub2 sub3; do
5800 #define OBD_FAIL_OSD_REF_DEL 0x19c
5801 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5802 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5805 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5807 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5809 test_49() { # LU-1030
5810 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5811 remote_ost_nodsh && skip "remote OST with nodsh"
5813 # get ost1 size - $FSNAME-OST0000
5814 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5816 # write 800M at maximum
5817 [[ $ost1_size -lt 2 ]] && ost1_size=2
5818 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5820 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5821 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5824 # change max_pages_per_rpc while writing the file
5825 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5826 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5827 # loop until dd process exits
5828 while ps ax -opid | grep -wq $dd_pid; do
5829 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5830 sleep $((RANDOM % 5 + 1))
5832 # restore original max_pages_per_rpc
5833 $LCTL set_param $osc1_mppc=$orig_mppc
5834 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5836 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5840 test_mkdir $DIR/$tdir
5842 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5844 run_test 50 "special situations: /proc symlinks ==============="
5846 test_51a() { # was test_51
5847 # bug 1516 - create an empty entry right after ".." then split dir
5848 test_mkdir -c1 $DIR/$tdir
5849 touch $DIR/$tdir/foo
5850 $MCREATE $DIR/$tdir/bar
5852 createmany -m $DIR/$tdir/longfile 201
5854 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5855 $MCREATE $DIR/$tdir/longfile$FNUM
5860 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5862 run_test 51a "special situations: split htree with empty entry =="
5864 cleanup_print_lfs_df () {
5871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5873 local dir=$DIR/$tdir
5874 local nrdirs=$((65536 + 100))
5876 # cleanup the directory
5879 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5883 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5884 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5885 [[ $numfree -lt $nrdirs ]] &&
5886 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5888 # need to check free space for the directories as well
5889 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5890 numfree=$(( blkfree / $(fs_inode_ksize) ))
5891 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5893 trap cleanup_print_lfs_df EXIT
5896 createmany -d $dir/d $nrdirs || {
5897 unlinkmany $dir/d $nrdirs
5898 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5902 nrdirs=$(ls -U $dir | wc -l)
5904 # unlink all but 100 subdirectories, then check it still works
5906 local delete=$((nrdirs - left))
5911 # for ldiskfs the nlink count should be 1, but this is OSD specific
5912 # and so this is listed for informational purposes only
5913 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5914 unlinkmany -d $dir/d $delete ||
5915 error "unlink of first $delete subdirs failed"
5917 echo "nlink between: $(stat -c %h $dir)"
5918 local found=$(ls -U $dir | wc -l)
5919 [ $found -ne $left ] &&
5920 error "can't find subdirs: found only $found, expected $left"
5922 unlinkmany -d $dir/d $delete $left ||
5923 error "unlink of second $left subdirs failed"
5924 # regardless of whether the backing filesystem tracks nlink accurately
5925 # or not, the nlink count shouldn't be more than "." and ".." here
5926 local after=$(stat -c %h $dir)
5927 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5928 echo "nlink after: $after"
5930 cleanup_print_lfs_df
5932 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5935 local stripecount=$1
5938 log "create files with stripecount=$stripecount"
5939 $LFS setstripe -C $stripecount $DIR/$tdir
5940 createmany -o $DIR/$tdir/t- $nfiles
5941 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5942 for ((n = 0; n < $OSTCOUNT; n++)); do
5943 objs[$n]=$(awk -vobjs=0 '($1 == '$n') { objs += 1 } \
5944 END { printf("%0.0f", objs) }' $TMP/$tfile)
5945 objs0[$n]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5946 '($1 == '$n') { objs += 1 } \
5947 END { printf("%0.0f", objs) }')
5948 log "OST$n has ${objs[$n]} objects, ${objs0[$n]} are index 0"
5950 unlinkmany $DIR/$tdir/t- $nfiles
5955 local max=6 # allow variance of (1 - $min/$max) = 33% by default
5957 # For some combinations of stripecount and OSTCOUNT current code
5958 # is not ideal, and allocates 50% fewer *first* objects to some OSTs
5959 # than others. Rather than skipping this test entirely, check that
5960 # and keep testing to ensure imbalance does not get worse. LU-15282
5961 (( (OSTCOUNT == 6 && stripecount == 4) ||
5962 (OSTCOUNT == 10 && (stripecount == 4 || stripecount == 8)) ||
5963 (OSTCOUNT == 12 && (stripecount == 8 || stripecount == 9)))) && max=9
5964 for ((nlast=0, n = 1; n < $OSTCOUNT; nlast=n,n++)); do
5965 (( ${objs[$n]} > ${objs[$nlast]} * 4 / 5 )) ||
5966 { $LFS df && $LFS df -i &&
5967 error "stripecount=$stripecount: " \
5968 "OST $n has fewer objects vs. OST $nlast " \
5969 "(${objs[$n]} < ${objs[$nlast]} x 4/5)"; }
5970 (( ${objs[$n]} < ${objs[$nlast]} * 5 / 4 )) ||
5971 { $LFS df && $LFS df -i &&
5972 error "stripecount=$stripecount: " \
5973 "OST $n has more objects vs. OST $nlast " \
5974 "(${objs[$n]} > ${objs[$nlast]} x 5/4)"; }
5976 (( ${objs0[$n]} > ${objs0[$nlast]} * $min / $max )) ||
5977 { $LFS df && $LFS df -i &&
5978 error "stripecount=$stripecount: " \
5979 "OST $n has fewer #0 objects vs. OST $nlast " \
5980 "(${objs0[$n]} < ${objs0[$nlast]} x $min/$max)"; }
5981 (( ${objs0[$n]} < ${objs0[$nlast]} * $max / $min )) ||
5982 { $LFS df && $LFS df -i &&
5983 error "stripecount=$stripecount: " \
5984 "OST $n has more #0 objects vs. OST $nlast " \
5985 "(${objs0[$n]} > ${objs0[$nlast]} x $max/$min)"; }
5990 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5991 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5995 local nfiles=$((per_ost * OSTCOUNT))
5996 local mdts=$(comma_list $(mdts_nodes))
5997 local param="osp.*.create_count"
5998 local qos_old=$(do_facet mds1 \
5999 "$LCTL get_param -n lod.$FSNAME-*.qos_threshold_rr" | head -n 1)
6002 "$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=100"
6003 stack_trap "do_nodes $mdts \
6004 '$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=${qos_old%%%}'"
6006 test_mkdir $DIR/$tdir
6007 local dirstripes=$(lfs getdirstripe -c $DIR/$tdir)
6008 (( dirstripes > 0 )) || dirstripes=1
6010 # Ensure enough OST objects precreated for tests to pass without
6011 # running out of objects. This is an LOV r-r OST algorithm test,
6012 # not an OST object precreation test.
6013 local old=$(do_facet mds1 "$LCTL get_param -n $param" | head -n 1)
6014 (( old >= nfiles )) ||
6016 local create_count=$((nfiles * OSTCOUNT / dirstripes))
6018 do_nodes $mdts "$LCTL set_param $param=$create_count"
6019 stack_trap "do_nodes $mdts $LCTL set_param $param=$old"
6021 # trigger precreation from all MDTs for all OSTs
6022 for ((i = 0; i < $MDSCOUNT * 2; i++ )); do
6023 $LFS setstripe -c -1 $DIR/$tdir/wide.$i
6027 for ((stripecount = 3; stripecount <= $OSTCOUNT; stripecount++)); do
6028 sleep 8 # allow object precreation to catch up
6029 test_51d_sub $stripecount $nfiles
6032 run_test 51d "check LOV round-robin OST object distribution"
6035 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6036 skip_env "ldiskfs only test"
6039 test_mkdir -c1 $DIR/$tdir
6040 test_mkdir -c1 $DIR/$tdir/d0
6042 touch $DIR/$tdir/d0/foo
6043 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
6044 error "file exceed 65000 nlink limit!"
6045 unlinkmany $DIR/$tdir/d0/f- 65001
6048 run_test 51e "check file nlink limit"
6051 test_mkdir $DIR/$tdir
6054 local ulimit_old=$(ulimit -n)
6055 local spare=20 # number of spare fd's for scripts/libraries, etc.
6056 local mdt=$($LFS getstripe -m $DIR/$tdir)
6057 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
6059 echo "MDT$mdt numfree=$numfree, max=$max"
6060 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
6061 if [ $((numfree + spare)) -gt $ulimit_old ]; then
6062 while ! ulimit -n $((numfree + spare)); do
6063 numfree=$((numfree * 3 / 4))
6065 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
6067 echo "left ulimit at $ulimit_old"
6070 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
6071 unlinkmany $DIR/$tdir/f $numfree
6072 error "create+open $numfree files in $DIR/$tdir failed"
6074 ulimit -n $ulimit_old
6076 # if createmany exits at 120s there will be fewer than $numfree files
6077 unlinkmany $DIR/$tdir/f $numfree || true
6079 run_test 51f "check many open files limit"
6082 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
6083 test_mkdir $DIR/$tdir
6084 touch $DIR/$tdir/foo
6085 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
6086 echo bar >> $DIR/$tdir/foo || error "append bar failed"
6087 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6088 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6089 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6091 echo foo >> $DIR/$tdir/foo || error "append foo failed"
6092 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6093 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
6095 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
6096 cp -r $DIR/$tdir $TMP/
6097 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
6099 run_test 52a "append-only flag test (should return errors)"
6102 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
6103 test_mkdir $DIR/$tdir
6104 touch $DIR/$tdir/foo
6105 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
6106 cat test > $DIR/$tdir/foo && error "cat test worked"
6107 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6108 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6109 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6111 echo foo >> $DIR/$tdir/foo && error "echo worked"
6112 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6113 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
6114 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
6115 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
6117 chattr -i $DIR/$tdir/foo || error "chattr failed"
6119 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
6121 run_test 52b "immutable flag test (should return errors) ======="
6124 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6125 remote_mds_nodsh && skip "remote MDS with nodsh"
6126 remote_ost_nodsh && skip "remote OST with nodsh"
6139 local support_last_seq=true
6141 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
6142 support_last_seq=false
6145 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
6147 for value in $(do_facet $SINGLEMDS \
6148 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
6149 param=$(echo ${value[0]} | cut -d "=" -f1)
6150 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
6152 if $support_last_seq; then
6153 param_seq=$(echo $param |
6154 sed -e s/prealloc_last_id/prealloc_last_seq/g)
6155 mds_last_seq=$(do_facet $SINGLEMDS \
6156 $LCTL get_param -n $param_seq)
6158 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
6160 ostnum=$(index_from_ostuuid ${ostname}_UUID)
6161 node=$(facet_active_host ost$((ostnum+1)))
6162 param="obdfilter.$ostname.last_id"
6163 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
6164 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
6165 ost_last_id=$ost_last
6167 if $support_last_seq; then
6168 ost_last_id=$(echo $ost_last |
6169 awk -F':' '{print $2}' |
6171 ost_last_seq=$(echo $ost_last |
6172 awk -F':' '{print $1}')
6173 [[ $ost_last_seq = $mds_last_seq ]] || continue
6176 if [[ $ost_last_id != $mds_last ]]; then
6177 error "$ost_last_id != $mds_last"
6184 $found || error "can not match last_seq/last_id for $mdtosc"
6187 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
6190 perl -MSocket -e ';' || skip "no Socket perl module installed"
6192 $SOCKETSERVER $DIR/socket ||
6193 error "$SOCKETSERVER $DIR/socket failed: $?"
6194 $SOCKETCLIENT $DIR/socket ||
6195 error "$SOCKETCLIENT $DIR/socket failed: $?"
6196 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
6198 run_test 54a "unix domain socket test =========================="
6204 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
6206 run_test 54b "char device works in lustre ======================"
6209 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
6210 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
6211 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
6213 for i in $(seq 3 7); do
6214 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
6223 loopdev="$DIR/loop54c"
6226 $UMOUNT $DIR/$tdir || rc=$?
6227 losetup -d $loopdev || true
6228 losetup -d $LOOPDEV || true
6229 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
6234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6236 loopdev="$DIR/loop54c"
6239 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
6240 trap cleanup_54c EXIT
6241 mknod $loopdev b 7 $LOOPNUM
6242 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
6243 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
6244 losetup $loopdev $DIR/$tfile ||
6245 error "can't set up $loopdev for $DIR/$tfile"
6246 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
6247 test_mkdir $DIR/$tdir
6248 mount -t ext2 $loopdev $DIR/$tdir ||
6249 error "error mounting $loopdev on $DIR/$tdir"
6250 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
6253 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
6257 run_test 54c "block device works in lustre ====================="
6260 local pipe="$DIR/$tfile.pipe"
6261 local string="aaaaaa"
6264 echo -n "$string" > $pipe &
6265 local result=$(cat $pipe)
6266 [[ "$result" == "$string" ]] || error "$result != $string"
6268 run_test 54d "fifo device works in lustre ======================"
6273 cp -aL /dev/console $f
6274 echo $string > $f || error "echo $string to $f failed"
6276 run_test 54e "console/tty device works in lustre ======================"
6281 local dir=$DIR/$tdir
6284 test_mkdir -p $dir/dir
6285 for i in $(seq $numfiles); do
6287 touch $dir/dir/file$i
6290 local numcomp=$($LFS getstripe --component-count $dir)
6292 [[ $numcomp == 0 ]] && numcomp=1
6294 # test lfs getstripe with --recursive
6295 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
6297 [[ $filenum -eq $((numfiles * 2)) ]] ||
6298 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
6299 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
6300 [[ $filenum -eq $numfiles ]] ||
6301 error "$LFS getstripe $dir: found $filenum, not $numfiles"
6302 echo "$LFS getstripe showed obdidx or l_ost_idx"
6304 # test lfs getstripe with file instead of dir
6305 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
6306 [[ $filenum -eq 1 ]] ||
6307 error "$LFS getstripe $dir/file1: found $filenum, not 1"
6308 echo "$LFS getstripe file1 passed"
6310 #test lfs getstripe with --verbose
6311 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
6312 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
6313 error "$LFS getstripe --verbose $dir: "\
6314 "got $filenum want $((numfiles * numcomp)) lmm_magic"
6315 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
6316 error "$LFS getstripe $dir: showed lmm_magic"
6318 #test lfs getstripe with -v prints lmm_fid
6319 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
6320 local countfids=$((numdirs + numfiles * numcomp))
6321 [[ $filenum -eq $countfids ]] ||
6322 error "$LFS getstripe -v $dir: "\
6323 "got $filenum want $countfids lmm_fid"
6324 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
6325 error "$LFS getstripe $dir: showed lmm_fid by default"
6326 echo "$LFS getstripe --verbose passed"
6328 #check for FID information
6329 local fid1=$($LFS getstripe --fid $dir/file1)
6330 local fid2=$($LFS getstripe --verbose $dir/file1 |
6331 awk '/lmm_fid: / { print $2; exit; }')
6332 local fid3=$($LFS path2fid $dir/file1)
6334 [ "$fid1" != "$fid2" ] &&
6335 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
6336 [ "$fid1" != "$fid3" ] &&
6337 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
6338 echo "$LFS getstripe --fid passed"
6340 #test lfs getstripe with --obd
6341 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6342 error "$LFS getstripe --obd wrong_uuid: should return error"
6344 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6347 local obduuid=$(ostuuid_from_index $ostidx)
6348 local found=$($LFS getstripe -r --obd $obduuid $dir |
6349 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6351 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6352 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6354 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6357 [[ $found -eq $filenum ]] ||
6358 error "$LFS getstripe --obd: found $found expect $filenum"
6359 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6360 sed '/^[ ]*'${ostidx}'[ ]/d' |
6361 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6362 error "$LFS getstripe --obd: should not show file on other obd"
6363 echo "$LFS getstripe --obd passed"
6365 run_test 56a "check $LFS getstripe"
6368 local dir=$DIR/$tdir
6372 for i in $(seq $numdirs); do
6373 test_mkdir $dir/dir$i
6376 # test lfs getdirstripe default mode is non-recursion, which is
6377 # different from lfs getstripe
6378 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6380 [[ $dircnt -eq 1 ]] ||
6381 error "$LFS getdirstripe: found $dircnt, not 1"
6382 dircnt=$($LFS getdirstripe --recursive $dir |
6383 grep -c lmv_stripe_count)
6384 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6385 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6387 run_test 56b "check $LFS getdirstripe"
6390 remote_ost_nodsh && skip "remote OST with nodsh"
6393 local ost_name=$(ostname_from_index $ost_idx)
6394 local old_status=$(ost_dev_status $ost_idx)
6395 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6397 [[ -z "$old_status" ]] ||
6398 skip_env "OST $ost_name is in $old_status status"
6400 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6401 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6402 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6403 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6404 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6405 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6408 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6409 error "$LFS df -v showing inactive devices"
6412 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6414 [[ "$new_status" =~ "D" ]] ||
6415 error "$ost_name status is '$new_status', missing 'D'"
6416 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6417 [[ "$new_status" =~ "N" ]] ||
6418 error "$ost_name status is '$new_status', missing 'N'"
6420 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6421 [[ "$new_status" =~ "f" ]] ||
6422 error "$ost_name status is '$new_status', missing 'f'"
6425 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6426 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6427 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6428 [[ -z "$p" ]] && restore_lustre_params < $p || true
6431 new_status=$(ost_dev_status $ost_idx)
6432 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6433 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6434 # can't check 'f' as devices may actually be on flash
6436 run_test 56c "check 'lfs df' showing device status"
6439 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6440 local osts=$($LFS df -v $MOUNT | grep -c OST)
6444 (( mdts == MDSCOUNT )) ||
6445 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6446 (( osts == OSTCOUNT )) ||
6447 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6449 run_test 56d "'lfs df -v' prints only configured devices"
6452 err_enoent=2 # No such file or directory
6453 err_eopnotsupp=95 # Operation not supported
6455 enoent_mnt=/pmt1 # Invalid dentry. Path not present
6456 notsup_mnt=/tmp # Valid dentry, but Not a lustreFS
6458 # Check for handling of path not exists
6459 output=$($LFS df $enoent_mnt 2>&1)
6462 fs=$(echo $output | awk -F: '{print $2}' | awk '{print $3}' | tr -d \')
6463 [[ $fs = $enoent_mnt && $ret -eq $err_enoent ]] ||
6464 error "expect failure $err_enoent, not $ret"
6466 # Check for handling of non-Lustre FS
6467 output=$($LFS df $notsup_mnt)
6470 fs=$(echo $output | awk '{print $1}' | awk -F: '{print $2}')
6471 [[ $fs = $notsup_mnt && $ret -eq $err_eopnotsupp ]] ||
6472 error "expect success $err_eopnotsupp, not $ret"
6474 # Check for multiple LustreFS argument
6475 output=$($LFS df $MOUNT $MOUNT $MOUNT | grep -c "filesystem_summary:")
6478 [[ $output -eq 3 && $ret -eq 0 ]] ||
6479 error "expect success 3, not $output, rc = $ret"
6481 # Check for correct non-Lustre FS handling among multiple
6483 output=$($LFS df $MOUNT $notsup_mnt $MOUNT |
6484 grep -c "filesystem_summary:"; exit ${PIPESTATUS[0]})
6487 [[ $output -eq 2 && $ret -eq $err_eopnotsupp ]] ||
6488 error "expect success 2, not $output, rc = $ret"
6490 run_test 56e "'lfs df' Handle non LustreFS & multiple LustreFS"
6495 local local_tdir="$1"
6496 local local_numfiles="$2"
6497 local local_numdirs="$3"
6498 local dir_params="$4"
6499 local dir_stripe_params="$5"
6501 if [ ! -d "$local_tdir" ] ; then
6502 test_mkdir -p $dir_stripe_params $local_tdir
6503 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6504 for i in $(seq $local_numfiles) ; do
6505 touch $local_tdir/file$i
6507 for i in $(seq $local_numdirs) ; do
6508 test_mkdir $dir_stripe_params $local_tdir/dir$i
6509 for j in $(seq $local_numfiles) ; do
6510 touch $local_tdir/dir$i/file$j
6516 setup_56_special() {
6518 local local_numfiles=$2
6519 local local_numdirs=$3
6521 setup_56 $local_tdir $local_numfiles $local_numdirs
6523 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6524 for i in $(seq $local_numfiles) ; do
6525 mknod $local_tdir/loop${i}b b 7 $i
6526 mknod $local_tdir/null${i}c c 1 3
6527 ln -s $local_tdir/file1 $local_tdir/link${i}
6529 for i in $(seq $local_numdirs) ; do
6530 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6531 mknod $local_tdir/dir$i/null${i}c c 1 3
6532 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6538 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6539 local expected=$(($NUMDIRS + 2))
6541 setup_56 $dir $NUMFILES $NUMDIRS
6543 # test lfs find with -name
6544 for i in $(seq $NUMFILES) ; do
6545 local nums=$($LFS find -name "*$i" $dir | wc -l)
6547 [ $nums -eq $expected ] ||
6548 error "lfs find -name '*$i' $dir wrong: "\
6549 "found $nums, expected $expected"
6552 run_test 56g "check lfs find -name"
6555 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6556 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6558 setup_56 $dir $NUMFILES $NUMDIRS
6560 # test lfs find with ! -name
6561 for i in $(seq $NUMFILES) ; do
6562 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6564 [ $nums -eq $expected ] ||
6565 error "lfs find ! -name '*$i' $dir wrong: "\
6566 "found $nums, expected $expected"
6569 run_test 56h "check lfs find ! -name"
6572 local dir=$DIR/$tdir
6576 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6579 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6581 run_test 56i "check 'lfs find -ost UUID' skips directories"
6584 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6586 setup_56_special $dir $NUMFILES $NUMDIRS
6588 local expected=$((NUMDIRS + 1))
6589 local cmd="$LFS find -type d $dir"
6590 local nums=$($cmd | wc -l)
6592 [ $nums -eq $expected ] ||
6593 error "'$cmd' wrong: found $nums, expected $expected"
6595 run_test 56j "check lfs find -type d"
6598 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6600 setup_56_special $dir $NUMFILES $NUMDIRS
6602 local expected=$(((NUMDIRS + 1) * NUMFILES))
6603 local cmd="$LFS find -type f $dir"
6604 local nums=$($cmd | wc -l)
6606 [ $nums -eq $expected ] ||
6607 error "'$cmd' wrong: found $nums, expected $expected"
6609 run_test 56k "check lfs find -type f"
6612 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6614 setup_56_special $dir $NUMFILES $NUMDIRS
6616 local expected=$((NUMDIRS + NUMFILES))
6617 local cmd="$LFS find -type b $dir"
6618 local nums=$($cmd | wc -l)
6620 [ $nums -eq $expected ] ||
6621 error "'$cmd' wrong: found $nums, expected $expected"
6623 run_test 56l "check lfs find -type b"
6626 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6628 setup_56_special $dir $NUMFILES $NUMDIRS
6630 local expected=$((NUMDIRS + NUMFILES))
6631 local cmd="$LFS find -type c $dir"
6632 local nums=$($cmd | wc -l)
6633 [ $nums -eq $expected ] ||
6634 error "'$cmd' wrong: found $nums, expected $expected"
6636 run_test 56m "check lfs find -type c"
6639 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6640 setup_56_special $dir $NUMFILES $NUMDIRS
6642 local expected=$((NUMDIRS + NUMFILES))
6643 local cmd="$LFS find -type l $dir"
6644 local nums=$($cmd | wc -l)
6646 [ $nums -eq $expected ] ||
6647 error "'$cmd' wrong: found $nums, expected $expected"
6649 run_test 56n "check lfs find -type l"
6652 local dir=$DIR/$tdir
6654 setup_56 $dir $NUMFILES $NUMDIRS
6655 utime $dir/file1 > /dev/null || error "utime (1)"
6656 utime $dir/file2 > /dev/null || error "utime (2)"
6657 utime $dir/dir1 > /dev/null || error "utime (3)"
6658 utime $dir/dir2 > /dev/null || error "utime (4)"
6659 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6660 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6663 local nums=$($LFS find -mtime +0 $dir | wc -l)
6665 [ $nums -eq $expected ] ||
6666 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6669 cmd="$LFS find -mtime 0 $dir"
6670 nums=$($cmd | wc -l)
6671 [ $nums -eq $expected ] ||
6672 error "'$cmd' wrong: found $nums, expected $expected"
6674 run_test 56o "check lfs find -mtime for old files"
6677 local dir=$DIR/$tdir
6681 # just to make sure there is something that won't be found
6683 touch $dir/$tfile.now
6685 for age in year week day hour min; do
6686 count=$((count + 1))
6688 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6689 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6690 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6692 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6693 local nums=$($cmd | wc -l)
6694 [ $nums -eq $expected ] ||
6695 error "'$cmd' wrong: found $nums, expected $expected"
6697 cmd="$LFS find $dir -atime $count${age:0:1}"
6698 nums=$($cmd | wc -l)
6699 [ $nums -eq $expected ] ||
6700 error "'$cmd' wrong: found $nums, expected $expected"
6704 cmd="$LFS find $dir -ctime +1s -type f"
6705 nums=$($cmd | wc -l)
6706 (( $nums == $count * 2 + 1)) ||
6707 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6709 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6711 test_newerXY_base() {
6714 local dir=$DIR/$tdir
6718 if [ $y == "t" ]; then
6719 if [ $x == "b" ]; then
6720 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6722 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6725 ref=$DIR/$tfile.newer.$x$y
6726 touch $ref || error "touch $ref failed"
6729 echo "before = $ref"
6731 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6733 if [ $y == "t" ]; then
6734 if [ $x == "b" ]; then
6735 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6737 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6740 negref=$DIR/$tfile.negnewer.$x$y
6741 touch $negref || error "touch $negref failed"
6744 echo "after = $negref"
6745 local cmd="$LFS find $dir -newer$x$y $ref"
6746 local nums=$(eval $cmd | wc -l)
6747 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6749 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6750 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6752 cmd="$LFS find $dir ! -newer$x$y $negref"
6753 nums=$(eval $cmd | wc -l)
6754 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6755 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6757 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6758 nums=$(eval $cmd | wc -l)
6759 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6760 error "'$cmd' wrong: found $nums between, expected $expected"; }
6766 test_newerXY_base "a" "a"
6767 test_newerXY_base "a" "m"
6768 test_newerXY_base "a" "c"
6769 test_newerXY_base "m" "a"
6770 test_newerXY_base "m" "m"
6771 test_newerXY_base "m" "c"
6772 test_newerXY_base "c" "a"
6773 test_newerXY_base "c" "m"
6774 test_newerXY_base "c" "c"
6776 test_newerXY_base "a" "t"
6777 test_newerXY_base "m" "t"
6778 test_newerXY_base "c" "t"
6780 [[ $MDS1_VERSION -lt $(version_code 2.13.54) ||
6781 $CLIENT_VERSION -lt $(version_code 2.13.54) ]] &&
6782 ! btime_supported && echo "btime unsupported" && return 0
6784 test_newerXY_base "b" "b"
6785 test_newerXY_base "b" "t"
6787 run_test 56oc "check lfs find -newerXY work"
6790 local dir=$DIR/$tdir
6795 $LFS find $dir -btime -1d -type f
6802 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
6803 ! btime_supported && skip "btime unsupported on MDS"
6805 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6806 ! btime_supported && skip "btime unsupported on clients"
6808 local dir=$DIR/$tdir
6809 local ref=$DIR/$tfile.ref
6810 local negref=$DIR/$tfile.negref
6812 mkdir $dir || error "mkdir $dir failed"
6813 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6814 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6815 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6816 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6817 touch $ref || error "touch $ref failed"
6818 # sleep 3 seconds at least
6821 local before=$(do_facet mds1 date +%s)
6822 local skew=$(($(date +%s) - before + 1))
6824 if (( skew < 0 && skew > -5 )); then
6825 sleep $((0 - skew + 1))
6829 # Set the dir stripe params to limit files all on MDT0,
6830 # otherwise we need to calc the max clock skew between
6831 # the client and MDTs.
6832 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6834 touch $negref || error "touch $negref failed"
6836 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6837 local nums=$($cmd | wc -l)
6838 local expected=$(((NUMFILES + 1) * NUMDIRS))
6840 [ $nums -eq $expected ] ||
6841 error "'$cmd' wrong: found $nums, expected $expected"
6843 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6844 nums=$($cmd | wc -l)
6845 expected=$((NUMFILES + 1))
6846 [ $nums -eq $expected ] ||
6847 error "'$cmd' wrong: found $nums, expected $expected"
6849 [ $skew -lt 0 ] && return
6851 local after=$(do_facet mds1 date +%s)
6852 local age=$((after - before + 1 + skew))
6854 cmd="$LFS find $dir -btime -${age}s -type f"
6855 nums=$($cmd | wc -l)
6856 expected=$(((NUMFILES + 1) * NUMDIRS))
6858 echo "Clock skew between client and server: $skew, age:$age"
6859 [ $nums -eq $expected ] ||
6860 error "'$cmd' wrong: found $nums, expected $expected"
6862 expected=$(($NUMDIRS + 1))
6863 cmd="$LFS find $dir -btime -${age}s -type d"
6864 nums=$($cmd | wc -l)
6865 [ $nums -eq $expected ] ||
6866 error "'$cmd' wrong: found $nums, expected $expected"
6867 rm -f $ref $negref || error "Failed to remove $ref $negref"
6869 run_test 56od "check lfs find -btime with units"
6872 [ $RUNAS_ID -eq $UID ] &&
6873 skip_env "RUNAS_ID = UID = $UID -- skipping"
6875 local dir=$DIR/$tdir
6877 setup_56 $dir $NUMFILES $NUMDIRS
6878 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6880 local expected=$NUMFILES
6881 local cmd="$LFS find -uid $RUNAS_ID $dir"
6882 local nums=$($cmd | wc -l)
6884 [ $nums -eq $expected ] ||
6885 error "'$cmd' wrong: found $nums, expected $expected"
6887 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6888 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6889 nums=$($cmd | wc -l)
6890 [ $nums -eq $expected ] ||
6891 error "'$cmd' wrong: found $nums, expected $expected"
6893 run_test 56p "check lfs find -uid and ! -uid"
6896 [ $RUNAS_ID -eq $UID ] &&
6897 skip_env "RUNAS_ID = UID = $UID -- skipping"
6899 local dir=$DIR/$tdir
6901 setup_56 $dir $NUMFILES $NUMDIRS
6902 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6904 local expected=$NUMFILES
6905 local cmd="$LFS find -gid $RUNAS_GID $dir"
6906 local nums=$($cmd | wc -l)
6908 [ $nums -eq $expected ] ||
6909 error "'$cmd' wrong: found $nums, expected $expected"
6911 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6912 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6913 nums=$($cmd | wc -l)
6914 [ $nums -eq $expected ] ||
6915 error "'$cmd' wrong: found $nums, expected $expected"
6917 run_test 56q "check lfs find -gid and ! -gid"
6920 local dir=$DIR/$tdir
6922 setup_56 $dir $NUMFILES $NUMDIRS
6925 local cmd="$LFS find -size 0 -type f -lazy $dir"
6926 local nums=$($cmd | wc -l)
6928 [ $nums -eq $expected ] ||
6929 error "'$cmd' wrong: found $nums, expected $expected"
6930 cmd="$LFS find -size 0 -type f $dir"
6931 nums=$($cmd | wc -l)
6932 [ $nums -eq $expected ] ||
6933 error "'$cmd' wrong: found $nums, expected $expected"
6936 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6937 nums=$($cmd | wc -l)
6938 [ $nums -eq $expected ] ||
6939 error "'$cmd' wrong: found $nums, expected $expected"
6940 cmd="$LFS find ! -size 0 -type f $dir"
6941 nums=$($cmd | wc -l)
6942 [ $nums -eq $expected ] ||
6943 error "'$cmd' wrong: found $nums, expected $expected"
6945 echo "test" > $dir/$tfile
6946 echo "test2" > $dir/$tfile.2 && sync
6948 cmd="$LFS find -size 5 -type f -lazy $dir"
6949 nums=$($cmd | wc -l)
6950 [ $nums -eq $expected ] ||
6951 error "'$cmd' wrong: found $nums, expected $expected"
6952 cmd="$LFS find -size 5 -type f $dir"
6953 nums=$($cmd | wc -l)
6954 [ $nums -eq $expected ] ||
6955 error "'$cmd' wrong: found $nums, expected $expected"
6958 cmd="$LFS find -size +5 -type f -lazy $dir"
6959 nums=$($cmd | wc -l)
6960 [ $nums -eq $expected ] ||
6961 error "'$cmd' wrong: found $nums, expected $expected"
6962 cmd="$LFS find -size +5 -type f $dir"
6963 nums=$($cmd | wc -l)
6964 [ $nums -eq $expected ] ||
6965 error "'$cmd' wrong: found $nums, expected $expected"
6968 cmd="$LFS find -size +0 -type f -lazy $dir"
6969 nums=$($cmd | wc -l)
6970 [ $nums -eq $expected ] ||
6971 error "'$cmd' wrong: found $nums, expected $expected"
6972 cmd="$LFS find -size +0 -type f $dir"
6973 nums=$($cmd | wc -l)
6974 [ $nums -eq $expected ] ||
6975 error "'$cmd' wrong: found $nums, expected $expected"
6978 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6979 nums=$($cmd | wc -l)
6980 [ $nums -eq $expected ] ||
6981 error "'$cmd' wrong: found $nums, expected $expected"
6982 cmd="$LFS find ! -size -5 -type f $dir"
6983 nums=$($cmd | wc -l)
6984 [ $nums -eq $expected ] ||
6985 error "'$cmd' wrong: found $nums, expected $expected"
6988 cmd="$LFS find -size -5 -type f -lazy $dir"
6989 nums=$($cmd | wc -l)
6990 [ $nums -eq $expected ] ||
6991 error "'$cmd' wrong: found $nums, expected $expected"
6992 cmd="$LFS find -size -5 -type f $dir"
6993 nums=$($cmd | wc -l)
6994 [ $nums -eq $expected ] ||
6995 error "'$cmd' wrong: found $nums, expected $expected"
6997 run_test 56r "check lfs find -size works"
7004 cancel_lru_locks $OSC
7006 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
7007 local nums=$($cmd | wc -l)
7009 [ $nums -eq $expected ] ||
7010 error "'$cmd' wrong: found $nums, expected $expected"
7012 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
7014 if (( rpcs_before + glimpses != rpcs_after )); then
7015 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
7016 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
7018 if [[ $glimpses == 0 ]]; then
7019 error "'$cmd' should not send glimpse RPCs to OST"
7021 error "'$cmd' should send $glimpses glimpse RPCs to OST"
7027 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
7028 skip "MDS < 2.12.58 doesn't return LSOM data"
7029 local dir=$DIR/$tdir
7030 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
7032 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
7034 # statahead_agl may cause extra glimpse which confuses results. LU-13017
7035 $LCTL set_param -n llite.*.statahead_agl=0
7036 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
7038 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7039 # open and close all files to ensure LSOM is updated
7040 cancel_lru_locks $OSC
7041 find $dir -type f | xargs cat > /dev/null
7043 # expect_found glimpse_rpcs command_to_run
7044 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
7045 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
7046 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
7047 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
7049 echo "test" > $dir/$tfile
7050 echo "test2" > $dir/$tfile.2 && sync
7051 cancel_lru_locks $OSC
7052 cat $dir/$tfile $dir/$tfile.2 > /dev/null
7054 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
7055 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
7056 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
7057 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
7059 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
7060 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
7061 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
7062 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
7063 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
7064 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
7066 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
7069 local dir=$DIR/$tdir
7070 local tmp=$TMP/$tfile.log
7073 test_mkdir -p $dir || error "failed to mkdir $dir"
7074 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
7075 error "failed to setstripe $dir/$tfile"
7076 mdt_idx=$($LFS getdirstripe -i $dir)
7077 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
7079 stack_trap "rm -f $tmp" EXIT
7080 $LFS find --size +100K --ost 0 $dir |& tee $tmp
7081 ! grep -q obd_uuid $tmp ||
7082 error "failed to find --size +100K --ost 0 $dir"
7083 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
7084 ! grep -q obd_uuid $tmp ||
7085 error "failed to find --size +100K --mdt $mdt_idx $dir"
7087 run_test 56rb "check lfs find --size --ost/--mdt works"
7090 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
7091 local dir=$DIR/$tdir
7094 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
7095 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
7096 (( $MDSCOUNT > 2 )) &&
7097 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
7098 mkdir $dir/$tdir-{1..10}
7099 touch $dir/$tfile-{1..10}
7101 found=$($LFS find $dir --mdt-count 2 | wc -l)
7103 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
7105 found=$($LFS find $dir -T +1 | wc -l)
7106 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
7107 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
7109 found=$($LFS find $dir --mdt-hash all_char | wc -l)
7111 (( $found == $expect )) || error "found $found all_char, expect $expect"
7113 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
7114 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
7115 (( $found == $expect )) || error "found $found all_char, expect $expect"
7117 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
7119 test_56s() { # LU-611 #LU-9369
7120 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
7122 local dir=$DIR/$tdir
7123 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
7125 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7126 for i in $(seq $NUMDIRS); do
7127 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
7130 local expected=$NUMDIRS
7131 local cmd="$LFS find -c $OSTCOUNT $dir"
7132 local nums=$($cmd | wc -l)
7134 [ $nums -eq $expected ] || {
7135 $LFS getstripe -R $dir
7136 error "'$cmd' wrong: found $nums, expected $expected"
7139 expected=$((NUMDIRS + onestripe))
7140 cmd="$LFS find -stripe-count +0 -type f $dir"
7141 nums=$($cmd | wc -l)
7142 [ $nums -eq $expected ] || {
7143 $LFS getstripe -R $dir
7144 error "'$cmd' wrong: found $nums, expected $expected"
7148 cmd="$LFS find -stripe-count 1 -type f $dir"
7149 nums=$($cmd | wc -l)
7150 [ $nums -eq $expected ] || {
7151 $LFS getstripe -R $dir
7152 error "'$cmd' wrong: found $nums, expected $expected"
7155 cmd="$LFS find -stripe-count -2 -type f $dir"
7156 nums=$($cmd | wc -l)
7157 [ $nums -eq $expected ] || {
7158 $LFS getstripe -R $dir
7159 error "'$cmd' wrong: found $nums, expected $expected"
7163 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
7164 nums=$($cmd | wc -l)
7165 [ $nums -eq $expected ] || {
7166 $LFS getstripe -R $dir
7167 error "'$cmd' wrong: found $nums, expected $expected"
7170 run_test 56s "check lfs find -stripe-count works"
7172 test_56t() { # LU-611 #LU-9369
7173 local dir=$DIR/$tdir
7175 setup_56 $dir 0 $NUMDIRS
7176 for i in $(seq $NUMDIRS); do
7177 $LFS setstripe -S 8M $dir/dir$i/$tfile
7180 local expected=$NUMDIRS
7181 local cmd="$LFS find -S 8M $dir"
7182 local nums=$($cmd | wc -l)
7184 [ $nums -eq $expected ] || {
7185 $LFS getstripe -R $dir
7186 error "'$cmd' wrong: found $nums, expected $expected"
7190 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
7192 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
7194 expected=$(((NUMDIRS + 1) * NUMFILES))
7195 cmd="$LFS find -stripe-size 512k -type f $dir"
7196 nums=$($cmd | wc -l)
7197 [ $nums -eq $expected ] ||
7198 error "'$cmd' wrong: found $nums, expected $expected"
7200 cmd="$LFS find -stripe-size +320k -type f $dir"
7201 nums=$($cmd | wc -l)
7202 [ $nums -eq $expected ] ||
7203 error "'$cmd' wrong: found $nums, expected $expected"
7205 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
7206 cmd="$LFS find -stripe-size +200k -type f $dir"
7207 nums=$($cmd | wc -l)
7208 [ $nums -eq $expected ] ||
7209 error "'$cmd' wrong: found $nums, expected $expected"
7211 cmd="$LFS find -stripe-size -640k -type f $dir"
7212 nums=$($cmd | wc -l)
7213 [ $nums -eq $expected ] ||
7214 error "'$cmd' wrong: found $nums, expected $expected"
7217 cmd="$LFS find -stripe-size 256k -type f $dir"
7218 nums=$($cmd | wc -l)
7219 [ $nums -eq $expected ] ||
7220 error "'$cmd' wrong: found $nums, expected $expected"
7222 cmd="$LFS find -stripe-size -320k -type f $dir"
7223 nums=$($cmd | wc -l)
7224 [ $nums -eq $expected ] ||
7225 error "'$cmd' wrong: found $nums, expected $expected"
7228 cmd="$LFS find -stripe-size 1024k -type f $dir"
7229 nums=$($cmd | wc -l)
7230 [ $nums -eq $expected ] ||
7231 error "'$cmd' wrong: found $nums, expected $expected"
7233 run_test 56t "check lfs find -stripe-size works"
7235 test_56u() { # LU-611
7236 local dir=$DIR/$tdir
7238 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
7240 if [[ $OSTCOUNT -gt 1 ]]; then
7241 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
7247 local expected=$(((NUMDIRS + 1) * NUMFILES))
7248 local cmd="$LFS find -stripe-index 0 -type f $dir"
7249 local nums=$($cmd | wc -l)
7251 [ $nums -eq $expected ] ||
7252 error "'$cmd' wrong: found $nums, expected $expected"
7255 cmd="$LFS find -stripe-index 1 -type f $dir"
7256 nums=$($cmd | wc -l)
7257 [ $nums -eq $expected ] ||
7258 error "'$cmd' wrong: found $nums, expected $expected"
7260 cmd="$LFS find ! -stripe-index 0 -type f $dir"
7261 nums=$($cmd | wc -l)
7262 [ $nums -eq $expected ] ||
7263 error "'$cmd' wrong: found $nums, expected $expected"
7266 # This should produce an error and not return any files
7267 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
7268 nums=$($cmd 2>/dev/null | wc -l)
7269 [ $nums -eq $expected ] ||
7270 error "'$cmd' wrong: found $nums, expected $expected"
7272 if [[ $OSTCOUNT -gt 1 ]]; then
7273 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
7274 cmd="$LFS find -stripe-index 0,1 -type f $dir"
7275 nums=$($cmd | wc -l)
7276 [ $nums -eq $expected ] ||
7277 error "'$cmd' wrong: found $nums, expected $expected"
7280 run_test 56u "check lfs find -stripe-index works"
7284 local dir=$DIR/$tdir
7286 setup_56 $dir $NUMFILES $NUMDIRS
7288 UUID=$(mdtuuid_from_index $mdt_idx $dir)
7289 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
7291 for file in $($LFS find -m $UUID $dir); do
7292 file_midx=$($LFS getstripe -m $file)
7293 [ $file_midx -eq $mdt_idx ] ||
7294 error "lfs find -m $UUID != getstripe -m $file_midx"
7297 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
7300 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
7301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7303 local dir=$DIR/$tdir
7305 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
7307 local stripe_size=$($LFS getstripe -S -d $dir) ||
7308 error "$LFS getstripe -S -d $dir failed"
7309 stripe_size=${stripe_size%% *}
7311 local file_size=$((stripe_size * OSTCOUNT))
7312 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
7313 local required_space=$((file_num * file_size))
7314 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
7316 (( free_space >= required_space / 1024 )) ||
7317 skip_env "need $required_space, have $free_space kbytes"
7320 local dd_count=$((file_size / dd_bs))
7322 # write data into the files
7327 for ((i = 1; i <= NUMFILES; i++ )); do
7329 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7330 error "write data into $file failed"
7332 for ((i = 1; i <= NUMDIRS; i++ )); do
7333 for ((j = 1; j <= NUMFILES; j++ )); do
7334 file=$dir/dir$i/file$j
7335 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7336 error "write data into $file failed"
7340 # $LFS_MIGRATE will fail if hard link migration is unsupported
7341 if (( MDS1_VERSION > $(version_code 2.5.55) )); then
7342 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
7343 error "creating links to $dir/dir1/file1 failed"
7348 (( OSTCOUNT <= 1 )) || expected=$((OSTCOUNT - 1))
7351 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
7354 eval $cmd || error "$cmd failed"
7356 check_stripe_count $dir/file1 $expected
7358 if (( $MDS1_VERSION >= $(version_code 2.6.90) )); then
7359 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
7360 # OST 1 if it is on OST 0. This file is small enough to
7361 # be on only one stripe.
7362 file=$dir/migr_1_ost
7363 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
7364 error "write data into $file failed"
7365 local obdidx=$($LFS getstripe -i $file)
7366 local oldmd5=$(md5sum $file)
7369 (( obdidx != 0 )) || newobdidx=1
7370 cmd="$LFS migrate -i $newobdidx $file"
7372 eval $cmd || error "$cmd failed"
7374 local realobdix=$($LFS getstripe -i $file)
7375 local newmd5=$(md5sum $file)
7377 (( $newobdidx == $realobdix )) ||
7378 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
7379 [[ "$oldmd5" == "$newmd5" ]] ||
7380 error "md5sum differ: $oldmd5, $newmd5"
7384 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7386 eval $cmd || error "$cmd failed"
7388 for (( j = 1; j <= NUMFILES; j++ )); do
7389 check_stripe_count $dir/dir1/file$j $expected
7392 # lfs_migrate works with lfs find
7393 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7394 $LFS_MIGRATE -y -c $expected"
7396 eval $cmd || error "$cmd failed"
7398 for (( i = 2; i <= NUMFILES; i++ )); do
7399 check_stripe_count $dir/file$i $expected
7401 for (( i = 2; i <= NUMDIRS; i++ )); do
7402 for (( j = 1; j <= NUMFILES; j++ )); do
7403 check_stripe_count $dir/dir$i/file$j $expected
7407 run_test 56wa "check lfs_migrate -c stripe_count works"
7410 local file1=$DIR/$tdir/file1
7411 local create_pool=false
7412 local initial_pool=$($LFS getstripe -p $DIR)
7416 echo -n "Creating test dir..."
7417 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7420 echo -n "Creating test file..."
7421 touch $file1 || error "cannot create file"
7424 echo -n "Detecting existing pools..."
7425 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7427 if [ ${#pool_list[@]} -gt 0 ]; then
7428 echo "${pool_list[@]}"
7429 for thispool in "${pool_list[@]}"; do
7430 if [[ -z "$initial_pool" ||
7431 "$initial_pool" != "$thispool" ]]; then
7433 echo "Using existing pool '$pool'"
7438 echo "none detected."
7440 if [ -z "$pool" ]; then
7441 pool=${POOL:-testpool}
7442 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7443 echo -n "Creating pool '$pool'..."
7445 pool_add $pool &> /dev/null ||
7446 error "pool_add failed"
7449 echo -n "Adding target to pool..."
7450 pool_add_targets $pool 0 0 1 &> /dev/null ||
7451 error "pool_add_targets failed"
7455 echo -n "Setting pool using -p option..."
7456 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7457 error "migrate failed rc = $?"
7460 echo -n "Verifying test file is in pool after migrating..."
7461 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7462 error "file was not migrated to pool $pool"
7465 echo -n "Removing test file from pool '$pool'..."
7466 # "lfs migrate $file" won't remove the file from the pool
7467 # until some striping information is changed.
7468 $LFS migrate -c 1 $file1 &> /dev/null ||
7469 error "cannot remove from pool"
7470 [ "$($LFS getstripe -p $file1)" ] &&
7471 error "pool still set"
7474 echo -n "Setting pool using --pool option..."
7475 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7476 error "migrate failed rc = $?"
7481 if $create_pool; then
7482 destroy_test_pools 2> /dev/null ||
7483 error "destroy test pools failed"
7486 run_test 56wb "check lfs_migrate pool support"
7489 local file1="$DIR/$tdir/$tfile"
7499 echo -n "Creating test dir..."
7500 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7501 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7502 error "cannot set stripe by '-S 1M -c 1'"
7505 echo -n "Setting initial stripe for test file..."
7506 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7507 error "cannot set stripe"
7508 cur_ssize=$($LFS getstripe -S "$file1")
7509 (( cur_ssize == 524288 )) || error "setstripe -S $cur_ssize != 524288"
7512 dd if=/dev/urandom of=$file1 bs=1M count=12 || error "dd $file1 failed"
7513 stack_trap "rm -f $file1"
7514 md5="$(md5sum $file1)"
7516 # File currently set to -S 512K -c 1
7518 # Ensure -c and -S options are rejected when -R is set
7519 echo -n "Verifying incompatible options are detected..."
7520 $LFS_MIGRATE -R -c 1 "$file1" &&
7521 error "incompatible -R and -c options not detected"
7522 $LFS_MIGRATE -R -S 1M "$file1" &&
7523 error "incompatible -R and -S options not detected"
7524 $LFS_MIGRATE -R -p pool "$file1" &&
7525 error "incompatible -R and -p options not detected"
7526 $LFS_MIGRATE -R -E eof -c 1 "$file1" &&
7527 error "incompatible -R and -E options not detected"
7528 $LFS_MIGRATE -R -A "$file1" &&
7529 error "incompatible -R and -A options not detected"
7530 $LFS_MIGRATE -A -c 1 "$file1" &&
7531 error "incompatible -A and -c options not detected"
7532 $LFS_MIGRATE -A -S 1M "$file1" &&
7533 error "incompatible -A and -S options not detected"
7534 $LFS_MIGRATE -A -p pool "$file1" &&
7535 error "incompatible -A and -p options not detected"
7536 $LFS_MIGRATE -A -E eof -c 1 "$file1" &&
7537 error "incompatible -A and -E options not detected"
7540 # Ensure unrecognized options are passed through to 'lfs migrate'
7541 echo -n "Verifying -S option is passed through to lfs migrate..."
7542 $LFS_MIGRATE -y -S 1M "$file1" || error "migration failed"
7543 cur_ssize=$($LFS getstripe -S "$file1")
7544 (( cur_ssize == 1048576 )) || error "migrate -S $cur_ssize != 1048576"
7545 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (1)"
7548 # File currently set to -S 1M -c 1
7550 # Ensure long options are supported
7551 echo -n "Verifying long options supported..."
7552 $LFS_MIGRATE --non-block "$file1" ||
7553 error "long option without argument not supported"
7554 $LFS_MIGRATE --stripe-size 512K "$file1" ||
7555 error "long option with argument not supported"
7556 cur_ssize=$($LFS getstripe -S "$file1")
7557 (( cur_ssize == 524288 )) ||
7558 error "migrate --stripe-size $cur_ssize != 524288"
7559 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (2)"
7562 # File currently set to -S 512K -c 1
7564 if (( OSTCOUNT > 1 )); then
7565 echo -n "Verifying explicit stripe count can be set..."
7566 $LFS_MIGRATE -c 2 "$file1" || error "migrate failed"
7567 cur_scount=$($LFS getstripe -c "$file1")
7568 (( cur_scount == 2 )) || error "migrate -c $cur_scount != 2"
7569 [[ "$(md5sum $file1)" == "$md5" ]] ||
7570 error "file data has changed (3)"
7574 # File currently set to -S 512K -c 1 or -S 512K -c 2
7576 # Ensure parent striping is used if -R is set, and no stripe
7577 # count or size is specified
7578 echo -n "Setting stripe for parent directory..."
7579 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7580 error "cannot set stripe '-S 2M -c 1'"
7581 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (4)"
7584 echo -n "Verifying restripe option uses parent stripe settings..."
7585 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7586 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7587 $LFS_MIGRATE -R "$file1" || error "migrate failed"
7588 cur_ssize=$($LFS getstripe -S "$file1")
7589 (( cur_ssize == parent_ssize )) ||
7590 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7591 cur_scount=$($LFS getstripe -c "$file1")
7592 (( cur_scount == parent_scount )) ||
7593 error "migrate -R stripe_count $cur_scount != $parent_scount"
7594 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (5)"
7597 # File currently set to -S 1M -c 1
7599 # Ensure striping is preserved if -R is not set, and no stripe
7600 # count or size is specified
7601 echo -n "Verifying striping size preserved when not specified..."
7602 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7603 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7604 error "cannot set stripe on parent directory"
7605 $LFS_MIGRATE "$file1" || error "migrate failed"
7606 cur_ssize=$($LFS getstripe -S "$file1")
7607 (( cur_ssize == orig_ssize )) ||
7608 error "migrate by default $cur_ssize != $orig_ssize"
7609 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (6)"
7612 # Ensure file name properly detected when final option has no argument
7613 echo -n "Verifying file name properly detected..."
7614 $LFS_MIGRATE "$file1" ||
7615 error "file name interpreted as option argument"
7616 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (7)"
7619 # Ensure PFL arguments are passed through properly
7620 echo -n "Verifying PFL options passed through..."
7621 new_scount=$(((OSTCOUNT + 1) / 2))
7622 $LFS_MIGRATE -E 1M -c 1 -E 16M -c $new_scount -E eof -c -1 "$file1" ||
7623 error "migrate PFL arguments failed"
7624 cur_comp=$($LFS getstripe --comp-count $file1)
7625 (( cur_comp == 3 )) || error "component count '$cur_comp' != 3"
7626 cur_scount=$($LFS getstripe --stripe-count $file1)
7627 (( cur_scount == new_scount)) ||
7628 error "PFL stripe count $cur_scount != $new_scount"
7629 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (8)"
7632 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7635 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
7637 local file1=$DIR/$tdir/$tfile
7639 echo -n "Creating test dir..."
7640 test_mkdir $DIR/$tdir || error "cannot create dir"
7643 echo -n "Creating test file..."
7644 echo "$tfile" > $file1
7647 # Ensure 'lfs migrate' will fail by using a non-existent option,
7648 # and make sure rsync is not called to recover
7649 echo -n "Make sure --no-rsync option works..."
7650 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7651 grep -q 'refusing to fall back to rsync' ||
7652 error "rsync was called with --no-rsync set"
7655 # Ensure rsync is called without trying 'lfs migrate' first
7656 echo -n "Make sure --rsync option works..."
7657 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7658 grep -q 'falling back to rsync' &&
7659 error "lfs migrate was called with --rsync set"
7662 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7668 test_mkdir $td || error "cannot create $td"
7669 touch $tf || error "cannot touch $tf"
7671 echo -n "Make sure --non-direct|-D works..."
7672 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7673 grep -q "lfs migrate --non-direct" ||
7674 error "--non-direct option cannot work correctly"
7675 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7676 grep -q "lfs migrate -D" ||
7677 error "-D option cannot work correctly"
7680 run_test 56we "check lfs_migrate --non-direct|-D support"
7683 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7684 check_swap_layouts_support
7686 local dir=$DIR/$tdir
7687 local ref1=/etc/passwd
7688 local file1=$dir/file1
7690 test_mkdir $dir || error "creating dir $dir"
7691 $LFS setstripe -c 2 $file1
7693 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7694 stripe=$($LFS getstripe -c $file1)
7695 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7696 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7701 run_test 56x "lfs migration support"
7704 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7705 check_swap_layouts_support
7707 local dir=$DIR/$tdir/$testnum
7711 local ref1=/etc/passwd
7712 local file1=$dir/file1
7714 $LFS setstripe -c 2 $file1
7716 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7718 local stripe=$($LFS getstripe -c $file1)
7720 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7721 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7726 run_test 56xa "lfs migration --block support"
7728 check_migrate_links() {
7729 [[ "$1" == "--rsync" ]] && local opts="--rsync -y" && shift
7731 local file1="$dir/file1"
7735 local total_count=$(($begin + $count - 1))
7736 local symlink_count=10
7739 if [ ! -f "$file1" ]; then
7740 echo -n "creating initial file..."
7741 $LFS setstripe -c 1 -S "512k" "$file1" ||
7742 error "cannot setstripe initial file"
7745 echo -n "creating symlinks..."
7746 for s in $(seq 1 $symlink_count); do
7747 ln -s "$file1" "$dir/slink$s" ||
7748 error "cannot create symlinks"
7752 echo -n "creating nonlinked files..."
7753 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7754 error "cannot create nonlinked files"
7759 if [ ! -f "$dir/file$total_count" ]; then
7760 echo -n "creating hard links $begin:$total_count..."
7761 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7762 /dev/null || error "cannot create hard links"
7766 echo -n "checking number of hard links listed in xattrs..."
7767 local fid=$($LFS getstripe -F "$file1")
7768 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7771 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7772 skip "hard link list has unexpected size, skipping test"
7774 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7775 error "link names should exceed xattrs size"
7778 echo -n "migrating files..."
7779 local migrate_out=$($runas $LFS_MIGRATE $opts -S '1m' $dir)
7781 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7784 # make sure all links have been properly migrated
7785 echo -n "verifying files..."
7786 fid=$($LFS getstripe -F "$file1") ||
7787 error "cannot get fid for file $file1"
7788 for i in $(seq 2 $total_count); do
7789 local fid2=$($LFS getstripe -F $dir/file$i)
7791 [ "$fid2" == "$fid" ] ||
7792 error "migrated hard link has mismatched FID"
7795 # make sure hard links were properly detected, and migration was
7796 # performed only once for the entire link set; nonlinked files should
7798 local actual=$(grep -c 'done' <<< "$migrate_out")
7799 local expected=$(($uniq_count + 1))
7801 [ "$actual" -eq "$expected" ] ||
7802 error "hard links individually migrated ($actual != $expected)"
7804 # make sure the correct number of hard links are present
7805 local hardlinks=$(stat -c '%h' "$file1")
7807 [ $hardlinks -eq $total_count ] ||
7808 error "num hard links $hardlinks != $total_count"
7815 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7816 skip "Need MDS version at least 2.10.55"
7818 local dir="$DIR/$tdir"
7820 test_mkdir "$dir" || error "cannot create dir $dir"
7822 echo "testing lfs migrate mode when all links fit within xattrs"
7823 check_migrate_links "$dir" 2 99
7825 echo "testing rsync mode when all links fit within xattrs"
7826 check_migrate_links --rsync "$dir" 2 99
7828 echo "testing lfs migrate mode when all links do not fit within xattrs"
7829 check_migrate_links "$dir" 101 100
7831 echo "testing rsync mode when all links do not fit within xattrs"
7832 check_migrate_links --rsync "$dir" 101 100
7834 chown -R $RUNAS_ID $dir
7835 echo "testing non-root lfs migrate mode when not all links are in xattr"
7836 check_migrate_links "$dir" 101 100 "$RUNAS"
7841 run_test 56xb "lfs migration hard link support"
7844 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7846 local dir="$DIR/$tdir"
7848 test_mkdir "$dir" || error "cannot create dir $dir"
7850 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7851 echo -n "Setting initial stripe for 20MB test file..."
7852 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7853 error "cannot setstripe 20MB file"
7855 echo -n "Sizing 20MB test file..."
7856 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
7858 echo -n "Verifying small file autostripe count is 1..."
7859 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
7860 error "cannot migrate 20MB file"
7861 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7862 error "cannot get stripe for $dir/20mb"
7863 [ $stripe_count -eq 1 ] ||
7864 error "unexpected stripe count $stripe_count for 20MB file"
7868 # Test 2: File is small enough to fit within the available space on
7869 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7870 # have at least an additional 1KB for each desired stripe for test 3
7871 echo -n "Setting stripe for 1GB test file..."
7872 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7874 echo -n "Sizing 1GB test file..."
7875 # File size is 1GB + 3KB
7876 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7879 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7880 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7881 if (( avail > 524288 * OSTCOUNT )); then
7882 echo -n "Migrating 1GB file..."
7883 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7884 error "cannot migrate 1GB file"
7886 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7887 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7888 error "cannot getstripe for 1GB file"
7889 [ $stripe_count -eq 2 ] ||
7890 error "unexpected stripe count $stripe_count != 2"
7894 # Test 3: File is too large to fit within the available space on
7895 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7896 if [ $OSTCOUNT -ge 3 ]; then
7897 # The required available space is calculated as
7898 # file size (1GB + 3KB) / OST count (3).
7899 local kb_per_ost=349526
7901 echo -n "Migrating 1GB file with limit..."
7902 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7903 error "cannot migrate 1GB file with limit"
7906 stripe_count=$($LFS getstripe -c "$dir/1gb")
7907 echo -n "Verifying 1GB autostripe count with limited space..."
7908 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7909 error "unexpected stripe count $stripe_count (min 3)"
7916 run_test 56xc "lfs migration autostripe"
7919 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7921 local dir=$DIR/$tdir
7922 local f_mgrt=$dir/$tfile.mgrt
7923 local f_yaml=$dir/$tfile.yaml
7924 local f_copy=$dir/$tfile.copy
7925 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7926 local layout_copy="-c 2 -S 2M -i 1"
7927 local yamlfile=$dir/yamlfile
7928 local layout_before;
7931 test_mkdir "$dir" || error "cannot create dir $dir"
7932 $LFS setstripe $layout_yaml $f_yaml ||
7933 error "cannot setstripe $f_yaml with layout $layout_yaml"
7934 $LFS getstripe --yaml $f_yaml > $yamlfile
7935 $LFS setstripe $layout_copy $f_copy ||
7936 error "cannot setstripe $f_copy with layout $layout_copy"
7938 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7940 # 1. test option --yaml
7941 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7942 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7943 layout_before=$(get_layout_param $f_yaml)
7944 layout_after=$(get_layout_param $f_mgrt)
7945 [ "$layout_after" == "$layout_before" ] ||
7946 error "lfs_migrate --yaml: $layout_after != $layout_before"
7948 # 2. test option --copy
7949 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7950 error "cannot migrate $f_mgrt with --copy $f_copy"
7951 layout_before=$(SKIP_INDEX=yes get_layout_param $f_copy)
7952 layout_after=$(SKIP_INDEX=yes get_layout_param $f_mgrt)
7953 [ "$layout_after" == "$layout_before" ] ||
7954 error "lfs_migrate --copy: $layout_after != $layout_before"
7956 run_test 56xd "check lfs_migrate --yaml and --copy support"
7959 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7961 local dir=$DIR/$tdir
7962 local f_comp=$dir/$tfile
7963 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7964 local layout_before=""
7965 local layout_after=""
7967 test_mkdir "$dir" || error "cannot create dir $dir"
7968 $LFS setstripe $layout $f_comp ||
7969 error "cannot setstripe $f_comp with layout $layout"
7970 layout_before=$(SKIP_INDEX=yes get_layout_param $f_comp)
7971 dd if=/dev/zero of=$f_comp bs=1M count=4
7973 # 1. migrate a comp layout file by lfs_migrate
7974 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7975 layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
7976 [ "$layout_before" == "$layout_after" ] ||
7977 error "lfs_migrate: $layout_before != $layout_after"
7979 # 2. migrate a comp layout file by lfs migrate
7980 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7981 layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
7982 [ "$layout_before" == "$layout_after" ] ||
7983 error "lfs migrate: $layout_before != $layout_after"
7985 run_test 56xe "migrate a composite layout file"
7988 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7990 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7991 skip "Need server version at least 2.13.53"
7993 local dir=$DIR/$tdir
7994 local f_comp=$dir/$tfile
7995 local layout="-E 1M -c1 -E -1 -c2"
7999 test_mkdir "$dir" || error "cannot create dir $dir"
8000 $LFS setstripe $layout $f_comp ||
8001 error "cannot setstripe $f_comp with layout $layout"
8002 fid_before=$($LFS getstripe --fid $f_comp)
8003 dd if=/dev/zero of=$f_comp bs=1M count=4
8005 # 1. migrate a comp layout file to a comp layout
8006 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
8007 fid_after=$($LFS getstripe --fid $f_comp)
8008 [ "$fid_before" == "$fid_after" ] ||
8009 error "comp-to-comp migrate: $fid_before != $fid_after"
8011 # 2. migrate a comp layout file to a plain layout
8012 $LFS migrate -c2 $f_comp ||
8013 error "cannot migrate $f_comp by lfs migrate"
8014 fid_after=$($LFS getstripe --fid $f_comp)
8015 [ "$fid_before" == "$fid_after" ] ||
8016 error "comp-to-plain migrate: $fid_before != $fid_after"
8018 # 3. migrate a plain layout file to a comp layout
8019 $LFS migrate $layout $f_comp ||
8020 error "cannot migrate $f_comp by lfs migrate"
8021 fid_after=$($LFS getstripe --fid $f_comp)
8022 [ "$fid_before" == "$fid_after" ] ||
8023 error "plain-to-comp migrate: $fid_before != $fid_after"
8025 run_test 56xf "FID is not lost during migration of a composite layout file"
8027 check_file_ost_range() {
8034 file_range=($($LFS getstripe -y "$file" |
8035 awk '/l_ost_idx:/ { print $NF }'))
8037 if [[ "${#file_range[@]}" = 0 ]]; then
8038 echo "No osts found for $file"
8042 for idx in "${file_range[@]}"; do
8043 [[ " $range " =~ " $idx " ]] ||
8051 local stripe_opt="$1"
8054 local pool_ostidx="$(seq $* | tr '\n' ' ')"
8056 $LFS migrate $stripe_opt -p $pool $DIR/$tfile ||
8057 error "Fail to migrate $tfile on $pool"
8058 [[ "$($LFS getstripe -p $DIR/$tfile)" = "$pool" ]] ||
8059 error "$tfile is not in pool $pool"
8060 check_file_ost_range "$DIR/$tfile" $pool_ostidx ||
8061 error "$tfile osts mismatch with pool $pool (osts $pool_ostidx)"
8065 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
8066 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
8067 [[ $MDS1_VERSION -gt $(version_code 2.14.52) ]] ||
8068 skip "Need MDS version newer than 2.14.52"
8070 local -a pool_names=("${TESTNAME}_0" "${TESTNAME}_1" "${TESTNAME}_2")
8071 local -a pool_ranges=("0 0" "1 1" "0 1")
8074 for i in "${!pool_names[@]}"; do
8075 pool_add ${pool_names[$i]} ||
8076 error "pool_add failed (pool: ${pool_names[$i]})"
8077 pool_add_targets ${pool_names[$i]} ${pool_ranges[$i]} ||
8078 error "pool_add_targets failed (pool: ${pool_names[$i]})"
8081 # init the file to migrate
8082 $LFS setstripe -c1 -i1 $DIR/$tfile ||
8083 error "Unable to create $tfile on OST1"
8084 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=4 status=none ||
8085 error "Unable to write on $tfile"
8087 echo "1. migrate $tfile on pool ${pool_names[0]}"
8088 sub_test_56xg "-c-1" "${pool_names[0]}" ${pool_ranges[0]}
8090 echo "2. migrate $tfile on pool ${pool_names[2]}"
8091 sub_test_56xg "-c-1 -S2M" "${pool_names[2]}" ${pool_ranges[2]}
8093 echo "3. migrate $tfile on pool ${pool_names[1]}"
8094 sub_test_56xg "-n -c-1" "${pool_names[1]}" ${pool_ranges[1]}
8096 echo "4. migrate $tfile on pool ${pool_names[2]} with default stripe parameters"
8097 sub_test_56xg "" "${pool_names[2]}" ${pool_ranges[2]}
8101 destroy_test_pools ||
8102 error "pool_destroy failed"
8104 run_test 56xg "lfs migrate pool support"
8107 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8110 local file1=$DIR/$tfile
8111 local tmp1=$TMP/$tfile.tmp
8113 $LFS setstripe -c 2 $file1
8115 stack_trap "rm -f $file1 $tmp1"
8116 dd if=/dev/urandom of=$tmp1 bs=1M count=$size_mb ||
8117 error "error creating $tmp1"
8121 local start=$SECONDS
8123 $LFS migrate --stats --stats-interval=1 -W 1M -c 1 $file1 ||
8124 error "migrate failed rc = $?"
8126 local elapsed=$((SECONDS - start))
8128 # with 1MB/s, elapsed should equal size_mb
8129 (( elapsed >= size_mb * 95 / 100 )) ||
8130 error "'lfs migrate -W' too fast ($elapsed < 0.95 * $size_mb)?"
8132 (( elapsed <= size_mb * 120 / 100 )) ||
8133 error_not_in_vm "'lfs migrate -W' slow ($elapsed > 1.2 * $size_mb)"
8135 (( elapsed <= size_mb * 150 / 100 )) ||
8136 error "'lfs migrate -W' too slow in VM ($elapsed > 2 * $size_mb 2)"
8138 stripe=$($LFS getstripe -c $file1)
8139 (( $stripe == 1 )) || error "stripe of $file1 is $stripe != 1"
8140 cmp $file1 $tmp1 || error "content mismatch $file1 differs from $tmp1"
8142 # Clean up file (since it is multiple MB)
8145 run_test 56xh "lfs migrate bandwidth limitation support"
8148 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8149 verify_yaml_available || skip_env "YAML verification not installed"
8152 local file1=$DIR/$tfile.1
8153 local file2=$DIR/$tfile.2
8154 local file3=$DIR/$tfile.3
8155 local output_file=$DIR/$tfile.out
8156 local tmp1=$TMP/$tfile.tmp
8158 $LFS setstripe -c 2 $file1
8159 $LFS setstripe -c 2 $file2
8160 $LFS setstripe -c 2 $file3
8162 stack_trap "rm -f $file1 $file2 $file3 $tmp1 $output_file"
8163 dd if=/dev/urandom of=$tmp1 bs=1M count=$size_mb ||
8164 error "error creating $tmp1"
8170 $LFS migrate --stats --stats-interval=1 \
8171 -c 1 $file1 $file2 $file3 1> $output_file ||
8172 error "migrate failed rc = $?"
8175 cat $output_file | verify_yaml || error "rename_stats is not valid YAML"
8177 # Clean up file (since it is multiple MB)
8178 rm -f $file1 $file2 $file3 $tmp1 $output_file
8180 run_test 56xi "lfs migrate stats support"
8183 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
8184 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
8187 local dir=$DIR/$tdir
8191 test_mkdir -p $dir || error "creating dir $dir"
8192 touch $f1 || error "creating std file $f1"
8193 $MULTIOP $f2 H2c || error "creating released file $f2"
8195 # a directory can be raid0, so ask only for files
8196 res=$($LFS find $dir -L raid0 -type f | wc -l)
8197 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
8199 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
8200 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
8202 # only files can be released, so no need to force file search
8203 res=$($LFS find $dir -L released)
8204 [[ $res == $f2 ]] || error "search released: found $res != $f2"
8206 res=$($LFS find $dir -type f \! -L released)
8207 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
8209 run_test 56y "lfs find -L raid0|released"
8211 test_56z() { # LU-4824
8212 # This checks to make sure 'lfs find' continues after errors
8213 # There are two classes of errors that should be caught:
8214 # - If multiple paths are provided, all should be searched even if one
8216 # - If errors are encountered during the search, it should not terminate
8218 local dir=$DIR/$tdir
8222 for i in d{0..9}; do
8224 touch $dir/$i/$tfile
8226 $LFS find $DIR/non_existent_dir $dir &&
8227 error "$LFS find did not return an error"
8228 # Make a directory unsearchable. This should NOT be the last entry in
8229 # directory order. Arbitrarily pick the 6th entry
8230 chmod 700 $($LFS find $dir -type d | sed '6!d')
8232 $RUNAS $LFS find $DIR/non_existent $dir
8233 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
8235 # The user should be able to see 10 directories and 9 files
8236 (( count == 19 )) ||
8237 error "$LFS find found $count != 19 entries after error"
8239 run_test 56z "lfs find should continue after an error"
8241 test_56aa() { # LU-5937
8242 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
8244 local dir=$DIR/$tdir
8247 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
8249 createmany -o $dir/striped_dir/${tfile}- 1024
8250 local dirs=$($LFS find --size +8k $dir/)
8252 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
8254 run_test 56aa "lfs find --size under striped dir"
8256 test_56ab() { # LU-10705
8257 test_mkdir $DIR/$tdir
8258 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
8259 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
8260 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
8261 # Flush writes to ensure valid blocks. Need to be more thorough for
8262 # ZFS, since blocks are not allocated/returned to client immediately.
8264 wait_zfs_commit ost1 2
8265 cancel_lru_locks osc
8268 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
8270 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
8272 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
8273 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
8275 rm -f $DIR/$tdir/$tfile.[123]
8277 run_test 56ab "lfs find --blocks"
8281 local dir="$DIR/$tdir"
8282 local perms=(001 002 003 004 005 006 007
8283 010 020 030 040 050 060 070
8284 100 200 300 400 500 600 700
8285 111 222 333 444 555 666 777)
8286 local perm_minus=(8 8 4 8 4 4 2
8290 local perm_slash=(8 8 12 8 12 12 14
8293 16 16 24 16 24 24 28)
8296 for perm in ${perms[*]}; do
8297 touch "$dir/$tfile.$perm"
8298 chmod $perm "$dir/$tfile.$perm"
8301 for ((i = 0; i < ${#perms[*]}; i++)); do
8302 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
8304 error "lfs find -perm ${perms[i]}:"\
8307 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
8308 (( $num == ${perm_minus[i]} )) ||
8309 error "lfs find -perm -${perms[i]}:"\
8310 "$num != ${perm_minus[i]}"
8312 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
8313 (( $num == ${perm_slash[i]} )) ||
8314 error "lfs find -perm /${perms[i]}:"\
8315 "$num != ${perm_slash[i]}"
8318 run_test 56aca "check lfs find -perm with octal representation"
8321 local dir=$DIR/$tdir
8322 # p is the permission of write and execute for user, group and other
8323 # without the umask. It is used to test +wx.
8324 local p=$(printf "%o" "$((0333 & ~$(umask)))")
8325 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
8326 local symbolic=(+t a+t u+t g+t o+t
8332 o=r,ug+o,u+w u=r,a+u,u+w
8333 g=r,ugo=g,u+w u+x,+X +X
8334 u+x,u+X u+X u+x,g+X o+r,+X
8338 for perm in ${perms[*]}; do
8339 touch "$dir/$tfile.$perm"
8340 chmod $perm "$dir/$tfile.$perm"
8343 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
8344 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
8347 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
8350 run_test 56acb "check lfs find -perm with symbolic representation"
8353 local dir=$DIR/$tdir
8354 local tests="17777 787 789 abcd
8355 ug=uu ug=a ug=gu uo=ou urw
8359 for err in $tests; do
8360 if $LFS find $dir -perm $err 2>/dev/null; then
8361 error "lfs find -perm $err: parsing should have failed"
8365 run_test 56acc "check parsing error for lfs find -perm"
8368 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
8369 skip "Need MDS version at least 2.10.50"
8371 # Create composite files with one component
8372 local dir=$DIR/$tdir
8374 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
8375 # Create composite files with three components
8376 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
8377 # Create non-composite files
8378 createmany -o $dir/${tfile}- 10
8380 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
8382 [[ $nfiles == 10 ]] ||
8383 error "lfs find -E 1M found $nfiles != 10 files"
8385 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
8386 [[ $nfiles == 25 ]] ||
8387 error "lfs find ! -E 1M found $nfiles != 25 files"
8389 # All files have a component that starts at 0
8390 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
8391 [[ $nfiles == 35 ]] ||
8392 error "lfs find --component-start 0 - $nfiles != 35 files"
8394 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
8395 [[ $nfiles == 15 ]] ||
8396 error "lfs find --component-start 2M - $nfiles != 15 files"
8398 # All files created here have a componenet that does not starts at 2M
8399 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
8400 [[ $nfiles == 35 ]] ||
8401 error "lfs find ! --component-start 2M - $nfiles != 35 files"
8403 # Find files with a specified number of components
8404 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
8405 [[ $nfiles == 15 ]] ||
8406 error "lfs find --component-count 3 - $nfiles != 15 files"
8408 # Remember non-composite files have a component count of zero
8409 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
8410 [[ $nfiles == 10 ]] ||
8411 error "lfs find --component-count 0 - $nfiles != 10 files"
8413 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
8414 [[ $nfiles == 20 ]] ||
8415 error "lfs find ! --component-count 3 - $nfiles != 20 files"
8417 # All files have a flag called "init"
8418 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
8419 [[ $nfiles == 35 ]] ||
8420 error "lfs find --component-flags init - $nfiles != 35 files"
8422 # Multi-component files will have a component not initialized
8423 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
8424 [[ $nfiles == 15 ]] ||
8425 error "lfs find !--component-flags init - $nfiles != 15 files"
8430 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
8433 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
8434 skip "Need MDS version at least 2.10.57"
8444 # create mirrored directories and mirrored files
8445 mkdir $td || error "mkdir $td failed"
8446 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
8447 createmany -o $tf- 10 || error "create $tf- failed"
8449 for i in $(seq 2); do
8451 mkdir $dir || error "mkdir $dir failed"
8452 $LFS mirror create -N$((3 + i)) $dir ||
8453 error "create mirrored dir $dir failed"
8454 createmany -o $dir/$tfile- 10 ||
8455 error "create $dir/$tfile- failed"
8458 # change the states of some mirrored files
8460 for i in $(seq 2); do
8462 for j in $(seq 4 9); do
8463 echo foo > $dir/$tfile-$j
8467 # find mirrored files with specific mirror count
8468 cmd="$LFS find --mirror-count 3 --type f $td"
8469 nfiles=$($cmd | wc -l)
8470 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
8472 cmd="$LFS find ! --mirror-count 3 --type f $td"
8473 nfiles=$($cmd | wc -l)
8474 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
8476 cmd="$LFS find --mirror-count +2 --type f $td"
8477 nfiles=$($cmd | wc -l)
8478 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8480 cmd="$LFS find --mirror-count -6 --type f $td"
8481 nfiles=$($cmd | wc -l)
8482 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8484 # find mirrored files with specific file state
8485 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
8486 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
8488 cmd="$LFS find --mirror-state=ro --type f $td"
8489 nfiles=$($cmd | wc -l)
8490 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
8492 cmd="$LFS find ! --mirror-state=ro --type f $td"
8493 nfiles=$($cmd | wc -l)
8494 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8496 cmd="$LFS find --mirror-state=wp --type f $td"
8497 nfiles=$($cmd | wc -l)
8498 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8500 cmd="$LFS find ! --mirror-state=sp --type f $td"
8501 nfiles=$($cmd | wc -l)
8502 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8504 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
8506 test_56da() { # LU-14179
8507 local path=$DIR/$tdir
8512 local longdir=$(str_repeat 'a' 255)
8514 for i in {1..15}; do
8521 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
8526 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
8529 touch $(str_repeat 'f' 255)
8531 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
8532 error "lfs find reported an error"
8536 run_test 56da "test lfs find with long paths"
8538 test_56ea() { #LU-10378
8539 local path=$DIR/$tdir
8540 local pool=$TESTNAME
8543 pool_add $pool || error "pool_add $pool failed"
8544 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8545 error "adding targets to $pool failed"
8547 # Set default pool on directory before creating file
8548 mkdir $path || error "mkdir $path failed"
8549 $LFS setstripe -p $pool $path ||
8550 error "set OST pool on $pool failed"
8551 touch $path/$tfile || error "touch $path/$tfile failed"
8553 # Compare basic file attributes from -printf and stat
8554 local attr_printf=$($LFS find $path/$tfile -printf "%A@ %T@ %C@ %U %G")
8555 local attr_stat=$(stat -c "%X %Y %Z %u %g" $path/$tfile)
8557 [[ "${attr_printf}" == "${attr_stat}" ]] ||
8558 error "Attrs from lfs find and stat don't match"
8560 # Compare Lustre attributes from lfs find and lfs getstripe
8561 local lattr_printf=$($LFS find $path/$tfile -printf "%Lc %LS %Li %Lp")
8562 local str_cnt=$($LFS getstripe --stripe-count $path/$tfile)
8563 local str_size=$($LFS getstripe --stripe-size $path/$tfile)
8564 local str_idx=$($LFS getstripe --stripe-index $path/$tfile)
8565 local fpool=$($LFS getstripe --pool $path/$tfile)
8566 local lattr_getstr="${str_cnt} ${str_size} ${str_idx} ${fpool}"
8568 [[ "${lattr_printf}" == "${lattr_getstr}" ]] ||
8569 error "Attrs from lfs find and lfs getstripe don't match"
8571 # Verify behavior for unknown escape/format sequences
8572 local esc_printf=$($LFS find $path/$tfile -printf '\\ %% \Q %Q')
8574 [[ "${esc_printf}" == '\ % \Q %Q' ]] ||
8575 error "Escape/format codes don't match"
8577 run_test 56ea "test lfs find -printf option"
8580 local dir=$DIR/$tdir
8581 local subdir_1=$dir/subdir_1
8583 test_mkdir -p $subdir_1
8584 ln -s subdir_1 $dir/link_1
8586 $LFS getstripe $dir | grep "^$dir/link_1$" -A1 ||
8587 error "symlink is not followed"
8589 $LFS getstripe --no-follow $dir |
8590 grep "^$dir/link_1 has no stripe info$" ||
8591 error "symlink should not have stripe info"
8594 ln -s testfile $dir/file_link_2
8596 $LFS getstripe $dir | grep "^$dir/file_link_2$" -A1 ||
8597 error "symlink is not followed"
8599 $LFS getstripe --no-follow $dir |
8600 grep "^$dir/file_link_2 has no stripe info$" ||
8601 error "symlink should not have stripe info"
8603 run_test 56eb "check lfs getstripe on symlink"
8606 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8607 # note test will not do anything if MDS is not local
8608 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8609 skip_env "ldiskfs only test"
8611 remote_mds_nodsh && skip "remote MDS with nodsh"
8613 local MNTDEV="osd*.*MDT*.mntdev"
8614 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
8615 [ -z "$DEV" ] && error "can't access $MNTDEV"
8616 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
8617 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
8618 error "can't access $DEV"
8619 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
8620 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
8624 run_test 57a "verify MDS filesystem created with large inodes =="
8627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8628 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8629 skip_env "ldiskfs only test"
8631 remote_mds_nodsh && skip "remote MDS with nodsh"
8633 local dir=$DIR/$tdir
8636 local fileN=$dir/f$filecount
8638 rm -rf $dir || error "removing $dir"
8640 local mdtidx=$($LFS getstripe -m $dir)
8641 local mdtname=MDT$(printf %04x $mdtidx)
8642 local facet=mds$((mdtidx + 1))
8644 echo "mcreating $filecount files"
8645 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
8647 # verify that files do not have EAs yet
8648 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
8649 error "$file1 has an EA"
8650 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
8651 error "$fileN has an EA"
8655 df $dir #make sure we get new statfs data
8656 local mdsfree=$(do_facet $facet \
8657 lctl get_param -n osd*.*$mdtname.kbytesfree)
8658 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8661 echo "opening files to create objects/EAs"
8662 for file in $(seq -f $dir/f%g 1 $filecount); do
8663 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
8664 error "opening $file"
8667 # verify that files have EAs now
8668 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
8669 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
8671 sleep 1 #make sure we get new statfs data
8673 local mdsfree2=$(do_facet $facet \
8674 lctl get_param -n osd*.*$mdtname.kbytesfree)
8675 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8677 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
8678 if [ "$mdsfree" != "$mdsfree2" ]; then
8679 error "MDC before $mdcfree != after $mdcfree2"
8681 echo "MDC before $mdcfree != after $mdcfree2"
8682 echo "unable to confirm if MDS has large inodes"
8687 run_test 57b "default LOV EAs are stored inside large inodes ==="
8690 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8691 [ -z "$(which wiretest 2>/dev/null)" ] &&
8692 skip_env "could not find wiretest"
8696 run_test 58 "verify cross-platform wire constants =============="
8699 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8701 echo "touch 130 files"
8702 createmany -o $DIR/f59- 130
8704 unlinkmany $DIR/f59- 130
8706 # wait for commitment of removal
8707 wait_delete_completed
8709 run_test 59 "verify cancellation of llog records async ========="
8711 TEST60_HEAD="test_60 run $RANDOM"
8713 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8714 remote_mgs_nodsh && skip "remote MGS with nodsh"
8715 do_facet mgs "! which run-llog.sh &> /dev/null" &&
8716 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
8717 skip_env "missing subtest run-llog.sh"
8719 log "$TEST60_HEAD - from kernel mode"
8720 do_facet mgs "$LCTL dk > /dev/null"
8721 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
8722 do_facet mgs $LCTL dk > $TMP/$tfile
8724 # LU-6388: test llog_reader
8725 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
8726 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
8727 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
8728 skip_env "missing llog_reader"
8729 local fstype=$(facet_fstype mgs)
8730 [ $fstype != ldiskfs -a $fstype != zfs ] &&
8731 skip_env "Only for ldiskfs or zfs type mgs"
8733 local mntpt=$(facet_mntpt mgs)
8734 local mgsdev=$(mgsdevname 1)
8746 #get fid and record list
8747 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
8749 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
8751 #remount mgs as ldiskfs or zfs type
8752 stop mgs || error "stop mgs failed"
8753 mount_fstype mgs || error "remount mgs failed"
8754 for ((i = 0; i < ${#fid_list[@]}; i++)); do
8757 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
8758 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
8763 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
8765 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
8767 echo "obj_file is $obj_file"
8768 do_facet mgs $llog_reader $obj_file
8770 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
8771 awk '{ print $3 }' | sed -e "s/^type=//g")
8772 if [ $rec_type != $rec ]; then
8773 echo "FAILED test_60a wrong record type $rec_type," \
8779 #check obj path if record type is LLOG_LOGID_MAGIC
8780 if [ "$rec" == "1064553b" ]; then
8781 path=$(do_facet mgs $llog_reader $obj_file |
8782 grep "path=" | awk '{ print $NF }' |
8783 sed -e "s/^path=//g")
8784 if [ $obj_file != $mntpt/$path ]; then
8785 echo "FAILED test_60a wrong obj path" \
8786 "$montpt/$path, should be $obj_file"
8793 #restart mgs before "error", otherwise it will block the next test
8794 stop mgs || error "stop mgs failed"
8795 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
8796 $pass || error "test failed, see FAILED test_60a messages for specifics"
8798 run_test 60a "llog_test run from kernel module and test llog_reader"
8800 test_60b() { # bug 6411
8801 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8804 LLOG_COUNT=$(do_facet mgs dmesg |
8805 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
8806 /llog_[a-z]*.c:[0-9]/ {
8818 [[ $LLOG_COUNT -gt 120 ]] &&
8819 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
8821 run_test 60b "limit repeated messages from CERROR/CWARN"
8824 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8826 echo "create 5000 files"
8827 createmany -o $DIR/f60c- 5000
8828 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
8829 lctl set_param fail_loc=0x80000137
8830 unlinkmany $DIR/f60c- 5000
8831 lctl set_param fail_loc=0
8833 run_test 60c "unlink file when mds full"
8836 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8838 SAVEPRINTK=$(lctl get_param -n printk)
8839 # verify "lctl mark" is even working"
8840 MESSAGE="test message ID $RANDOM $$"
8841 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8842 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
8844 lctl set_param printk=0 || error "set lnet.printk failed"
8845 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
8846 MESSAGE="new test message ID $RANDOM $$"
8847 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
8848 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8849 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
8851 lctl set_param -n printk="$SAVEPRINTK"
8853 run_test 60d "test printk console message masking"
8856 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8857 remote_mds_nodsh && skip "remote MDS with nodsh"
8860 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
8861 do_facet mds1 lctl set_param fail_loc=0x15b
8864 run_test 60e "no space while new llog is being created"
8867 local old_path=$($LCTL get_param -n debug_path)
8869 stack_trap "$LCTL set_param debug_path=$old_path"
8870 stack_trap "rm -f $TMP/$tfile*"
8871 rm -f $TMP/$tfile* 2> /dev/null
8872 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8873 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
8874 test_mkdir $DIR/$tdir
8875 # retry in case the open is cached and not released
8876 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
8877 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
8881 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
8883 run_test 60f "change debug_path works"
8889 test_mkdir -c $MDSCOUNT $DIR/$tdir
8894 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
8895 -c $MDSCOUNT $DIR/$tdir/subdir$index \
8897 mkdir $DIR/$tdir/subdir$index 2>/dev/null
8898 rmdir $DIR/$tdir/subdir$index 2>/dev/null
8899 index=$((index + 1))
8905 for i in {0..100}; do
8906 # define OBD_FAIL_OSD_TXN_START 0x19a
8907 local index=$((i % MDSCOUNT + 1))
8909 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
8916 for i in $(seq $MDSCOUNT); do
8917 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
8920 mkdir $DIR/$tdir/new || error "mkdir failed"
8921 rmdir $DIR/$tdir/new || error "rmdir failed"
8923 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
8925 for i in $(seq $MDSCOUNT); do
8926 wait_update_facet mds$i "$LCTL get_param -n \
8927 mdd.$(facet_svc mds$i).lfsck_namespace |
8928 awk '/^status/ { print \\\$2 }'" "completed"
8932 rm -rf $DIR/$tdir || error "rmdir failed"
8934 run_test 60g "transaction abort won't cause MDT hung"
8937 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
8938 skip "Need MDS version at least 2.12.52"
8939 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
8943 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
8944 #define OBD_FAIL_MDS_STRIPE_FID 0x189
8945 for fail_loc in 0x80000188 0x80000189; do
8946 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
8947 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
8948 error "mkdir $dir-$fail_loc failed"
8949 for i in {0..10}; do
8950 # create may fail on missing stripe
8951 echo $i > $DIR/$tdir-$fail_loc/$i
8953 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8954 error "getdirstripe $tdir-$fail_loc failed"
8955 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
8956 error "migrate $tdir-$fail_loc failed"
8957 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8958 error "getdirstripe $tdir-$fail_loc failed"
8959 pushd $DIR/$tdir-$fail_loc
8961 echo $f | cmp $f - || error "$f data mismatch"
8964 rm -rf $DIR/$tdir-$fail_loc
8967 run_test 60h "striped directory with missing stripes can be accessed"
8969 function t60i_load() {
8971 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
8972 $LCTL set_param fail_loc=0x131c fail_val=1
8973 for ((i=0; i<5000; i++)); do
8974 touch $DIR/$tdir/f$i
8979 changelog_register || error "changelog_register failed"
8980 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
8981 changelog_users $SINGLEMDS | grep -q $cl_user ||
8982 error "User $cl_user not found in changelog_users"
8983 changelog_chmask "ALL"
8986 for((i=0; i<100; i++)); do
8987 changelog_dump >/dev/null ||
8988 error "can't read changelog"
8992 changelog_deregister || error "changelog_deregister failed"
8993 $LCTL set_param fail_loc=0
8995 run_test 60i "llog: new record vs reader race"
8998 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
8999 skip "need MDS version at least 2.15.50"
9000 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9001 remote_mds_nodsh && skip "remote MDS with nodsh"
9002 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
9004 changelog_users $SINGLEMDS | grep "^cl" &&
9005 skip "active changelog user"
9007 local llog_reader=$(do_facet $SINGLEMDS "which llog_reader 2> /dev/null")
9009 [[ -z $(do_facet $SINGLEMDS ls -d $llog_reader 2> /dev/null) ]] &&
9010 skip_env "missing llog_reader"
9012 mkdir_on_mdt0 $DIR/$tdir
9014 local f=$DIR/$tdir/$tfile
9019 changelog_register || error "cannot register changelog user"
9021 # set changelog_mask to ALL
9022 changelog_chmask "ALL"
9025 createmany -o ${f}- 100 || error "createmany failed as $RUNAS_ID"
9026 unlinkmany ${f}- 100 || error "unlinkmany failed"
9028 tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
9029 mdt_dev=$(facet_device $SINGLEMDS)
9031 do_facet $SINGLEMDS sync
9032 plain=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'dump changelog_catalog \
9033 $tmpfile' $mdt_dev; $llog_reader $tmpfile" |
9034 awk '{match($0,"path=([^ ]+)",a)}END{print a[1]}')
9036 stack_trap "do_facet $SINGLEMDS rm -f $tmpfile"
9038 # if $tmpfile is not on EXT3 filesystem for some reason
9039 [[ ${plain:0:1} == 'O' ]] ||
9040 skip "path $plain is not in 'O/1/d<n>/<n>' format"
9042 size=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'dump $plain $tmpfile' \
9043 $mdt_dev; stat -c %s $tmpfile")
9044 echo "Truncate llog from $size to $((size - size % 8192))"
9045 size=$((size - size % 8192))
9046 do_facet $SINGLEMDS $TRUNCATE $tmpfile $size
9047 errs=$(do_facet $SINGLEMDS "$llog_reader $tmpfile" |
9048 grep -c 'in bitmap only')
9049 (( $errs > 0 )) || error "llog_reader didn't find lost records"
9051 size=$((size - 9000))
9052 echo "Corrupt llog in the middle at $size"
9053 do_facet $SINGLEMDS dd if=/dev/urandom of=$tmpfile bs=1 seek=$size \
9054 count=333 conv=notrunc
9055 errs=$(do_facet $SINGLEMDS "$llog_reader $tmpfile" |
9056 grep -c 'next chunk')
9057 (( $errs > 0 )) || error "llog_reader didn't skip bad chunk"
9059 run_test 60j "llog_reader reports corruptions"
9062 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9065 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
9066 cancel_lru_locks osc
9067 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
9070 run_test 61a "mmap() writes don't make sync hang ================"
9073 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
9075 run_test 61b "mmap() of unstriped file is successful"
9077 # bug 2330 - insufficient obd_match error checking causes LBUG
9079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9083 cancel_lru_locks osc
9084 lctl set_param fail_loc=0x405
9085 cat $f && error "cat succeeded, expect -EIO"
9086 lctl set_param fail_loc=0
9088 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
9089 # match every page all of the time.
9090 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
9092 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
9093 # Though this test is irrelevant anymore, it helped to reveal some
9094 # other grant bugs (LU-4482), let's keep it.
9095 test_63a() { # was test_63
9096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9098 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
9100 for i in `seq 10` ; do
9101 dd if=/dev/zero of=$DIR/f63 bs=8k &
9107 rm -f $DIR/f63 || true
9109 run_test 63a "Verify oig_wait interruption does not crash ======="
9111 # bug 2248 - async write errors didn't return to application on sync
9112 # bug 3677 - async write errors left page locked
9114 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9117 lctl set_param debug=-1
9119 # ensure we have a grant to do async writes
9120 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
9123 sync # sync lest earlier test intercept the fail_loc
9125 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9126 lctl set_param fail_loc=0x80000406
9127 $MULTIOP $DIR/$tfile Owy && \
9128 error "sync didn't return ENOMEM"
9129 sync; sleep 2; sync # do a real sync this time to flush page
9130 lctl get_param -n llite.*.dump_page_cache | grep locked && \
9131 error "locked page left in cache after async error" || true
9134 run_test 63b "async write errors should be returned to fsync ==="
9137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9140 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
9142 run_test 64a "verify filter grant calculations (in kernel) ====="
9145 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9147 bash oos.sh $MOUNT || error "oos.sh failed: $?"
9149 run_test 64b "check out-of-space detection on client"
9152 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
9154 run_test 64c "verify grant shrink"
9160 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
9163 # this does exactly what osc_request.c:osc_announce_cached() does in
9164 # order to calculate max amount of grants to ask from server
9168 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
9169 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
9171 ((rpc_in_flight++));
9172 nrpages=$((nrpages * rpc_in_flight))
9174 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
9176 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
9178 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
9179 local undirty=$((nrpages * PAGE_SIZE))
9181 local max_extent_pages
9182 max_extent_pages=$(import_param $tgt grant_max_extent_size)
9183 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
9184 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
9185 local grant_extent_tax
9186 grant_extent_tax=$(import_param $tgt grant_extent_tax)
9188 undirty=$((undirty + nrextents * grant_extent_tax))
9193 # this is size of unit for grant allocation. It should be equal to
9194 # what tgt_grant.c:tgt_grant_chunk() calculates
9198 local grant_extent_tax
9200 max_brw_size=$(import_param $tgt max_brw_size)
9202 grant_extent_tax=$(import_param $tgt grant_extent_tax)
9204 echo $(((max_brw_size + grant_extent_tax) * 2))
9208 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
9209 skip "OST < 2.10.55 doesn't limit grants enough"
9211 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
9213 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
9214 skip "no grant_param connect flag"
9216 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9218 $LCTL set_param -n -n debug="$OLDDEBUG" || true
9219 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9222 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
9223 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
9225 $LFS setstripe $DIR/$tfile -i 0 -c 1
9226 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
9229 while kill -0 $ddpid; do
9230 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
9232 if [[ $cur_grant -gt $max_cur_granted ]]; then
9234 error "cur_grant $cur_grant > $max_cur_granted"
9240 run_test 64d "check grant limit exceed"
9246 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
9248 ((cur_grants == expected)) ||
9249 error "$msg: grants mismatch: $cur_grants, expected $expected"
9253 echo $((($1 + $2 - 1) & ~($2 - 1)))
9257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9258 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
9259 skip "Need OSS version at least 2.11.56"
9261 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9262 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9263 $LCTL set_param debug=+cache
9265 # Remount client to reset grant
9266 remount_client $MOUNT || error "failed to remount client"
9267 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9269 local init_grants=$(import_param $osc_tgt initial_grant)
9271 check_grants $osc_tgt $init_grants "init grants"
9273 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9274 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9275 local gbs=$(import_param $osc_tgt grant_block_size)
9277 # write random number of bytes from max_brw_size / 4 to max_brw_size
9278 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9279 # align for direct io
9280 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9281 # round to grant consumption unit
9282 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9284 local grants=$((wb_round_up + extent_tax))
9286 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9288 # define OBD_FAIL_TGT_NO_GRANT 0x725
9289 # make the server not grant more back
9290 do_facet ost1 $LCTL set_param fail_loc=0x725
9291 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
9293 do_facet ost1 $LCTL set_param fail_loc=0
9295 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
9297 rm -f $DIR/$tfile || error "rm failed"
9299 # Remount client to reset grant
9300 remount_client $MOUNT || error "failed to remount client"
9301 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9303 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9305 # define OBD_FAIL_TGT_NO_GRANT 0x725
9306 # make the server not grant more back
9307 do_facet ost1 $LCTL set_param fail_loc=0x725
9308 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
9309 do_facet ost1 $LCTL set_param fail_loc=0
9311 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
9313 run_test 64e "check grant consumption (no grant allocation)"
9316 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9318 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9319 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9320 $LCTL set_param debug=+cache
9322 # Remount client to reset grant
9323 remount_client $MOUNT || error "failed to remount client"
9324 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9326 local init_grants=$(import_param $osc_tgt initial_grant)
9327 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9328 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9329 local gbs=$(import_param $osc_tgt grant_block_size)
9330 local chunk=$(grant_chunk $osc_tgt)
9332 # write random number of bytes from max_brw_size / 4 to max_brw_size
9333 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9334 # align for direct io
9335 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9336 # round to grant consumption unit
9337 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9339 local grants=$((wb_round_up + extent_tax))
9341 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9342 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
9343 error "error writing to $DIR/$tfile"
9345 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9346 "direct io with grant allocation"
9348 rm -f $DIR/$tfile || error "rm failed"
9350 # Remount client to reset grant
9351 remount_client $MOUNT || error "failed to remount client"
9352 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9354 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9356 local cmd="oO_WRONLY:w${write_bytes}_yc"
9358 $MULTIOP $DIR/$tfile $cmd &
9362 check_grants $osc_tgt $((init_grants - grants)) \
9363 "buffered io, not write rpc"
9365 kill -USR1 $MULTIPID
9368 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9369 "buffered io, one RPC"
9371 run_test 64f "check grant consumption (with grant allocation)"
9374 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
9375 skip "Need MDS version at least 2.14.56"
9377 local mdts=$(comma_list $(mdts_nodes))
9379 local old=$($LCTL get_param mdc.$FSNAME-*.grant_shrink_interval |
9381 stack_trap "$LCTL set_param $old"
9383 # generate dirty pages and increase dirty granted on MDT
9384 stack_trap "rm -f $DIR/$tfile-*"
9385 for (( i = 0; i < 10; i++)); do
9386 $LFS setstripe -E 1M -L mdt $DIR/$tfile-$i ||
9387 error "can't set stripe"
9388 dd if=/dev/zero of=$DIR/$tfile-$i bs=128k count=1 ||
9390 $LFS getstripe $DIR/$tfile-$i | grep -q pattern.*mdt || {
9391 $LFS getstripe $DIR/$tfile-$i
9392 error "not DoM file"
9399 # wait until grant shrink reset grant dirty on MDTs
9400 for ((i = 0; i < 120; i++)); do
9401 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9402 awk '{sum=sum+$1} END {print sum}')
9403 vm_dirty=$(awk '/Dirty:/{print $2}' /proc/meminfo)
9404 echo "$grant_dirty grants, $vm_dirty pages"
9405 (( grant_dirty + vm_dirty == 0 )) && break
9406 (( i == 3 )) && sync &&
9407 $LCTL set_param mdc.$FSNAME-*.grant_shrink_interval=5
9411 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9412 awk '{sum=sum+$1} END {print sum}')
9413 (( grant_dirty == 0 )) || error "$grant_dirty on MDT"
9415 run_test 64g "grant shrink on MDT"
9418 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9419 skip "need OST at least 2.14.56 to avoid grant shrink on read"
9421 local instance=$($LFS getname -i $DIR)
9422 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9423 local num_exps=$(do_facet ost1 \
9424 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
9425 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9426 local avail=$($LCTL get_param -n osc.*OST0000-osc-$instance.kbytesavail)
9427 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9429 # 10MiB is for file to be written, max_brw_size * 16 *
9430 # num_exps is space reserve so that tgt_grant_shrink() decided
9432 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
9433 (( avail * 1024 < expect )) &&
9434 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
9436 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
9437 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
9438 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
9439 $LCTL set_param osc.*OST0000*.grant_shrink=1
9440 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
9442 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9443 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
9445 # drop cache so that coming read would do rpc
9446 cancel_lru_locks osc
9448 # shrink interval is set to 10, pause for 7 seconds so that
9449 # grant thread did not wake up yet but coming read entered
9450 # shrink mode for rpc (osc_should_shrink_grant())
9453 declare -a cur_grant_bytes
9454 declare -a tot_granted
9455 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9456 tot_granted[0]=$(do_facet ost1 \
9457 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9459 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
9461 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9462 tot_granted[1]=$(do_facet ost1 \
9463 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9465 # grant change should be equal on both sides
9466 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
9467 tot_granted[0] - tot_granted[1])) ||
9468 error "grant change mismatch, " \
9469 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
9470 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
9472 run_test 64h "grant shrink on read"
9475 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9476 skip "need OST at least 2.14.56 to avoid grant shrink on replay"
9478 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9479 remote_ost_nodsh && skip "remote OSTs with nodsh"
9481 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9483 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
9485 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
9486 local instance=$($LFS getname -i $DIR)
9488 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9489 local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
9491 # shrink grants and simulate rpc loss
9492 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
9493 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
9494 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
9498 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
9500 local testid=$(echo $TESTNAME | tr '_' ' ')
9502 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
9503 grep "GRANT, real grant" &&
9504 error "client has more grants then it owns" || true
9506 run_test 64i "shrink on reconnect"
9508 # bug 1414 - set/get directories' stripe info
9510 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9512 test_mkdir $DIR/$tdir
9514 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
9516 run_test 65a "directory with no stripe info"
9519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9521 test_mkdir $DIR/$tdir
9522 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9524 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9527 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
9529 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
9532 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9533 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
9535 test_mkdir $DIR/$tdir
9536 local stripesize=$($LFS getstripe -S $DIR/$tdir)
9538 $LFS setstripe -S $((stripesize * 4)) -i 1 \
9539 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
9541 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
9543 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
9546 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9548 test_mkdir $DIR/$tdir
9549 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
9550 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9552 if [[ $STRIPECOUNT -le 0 ]]; then
9554 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
9555 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
9556 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
9558 sc=$(($STRIPECOUNT - 1))
9560 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
9561 touch $DIR/$tdir/f4 $DIR/$tdir/f5
9562 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
9563 error "lverify failed"
9565 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
9568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9570 test_mkdir $DIR/$tdir
9572 $LFS setstripe $DIR/$tdir || error "setstripe"
9573 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9574 error "no stripe info failed"
9576 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
9578 run_test 65e "directory setstripe defaults"
9581 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9583 test_mkdir $DIR/${tdir}f
9584 $RUNAS $LFS setstripe $DIR/${tdir}f &&
9585 error "setstripe succeeded" || true
9587 run_test 65f "dir setstripe permission (should return error) ==="
9590 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9592 test_mkdir $DIR/$tdir
9593 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9595 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9596 error "setstripe -S failed"
9597 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
9598 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9599 error "delete default stripe failed"
9601 run_test 65g "directory setstripe -d"
9604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9606 test_mkdir $DIR/$tdir
9607 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9609 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9610 error "setstripe -S failed"
9611 test_mkdir $DIR/$tdir/dd1
9612 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
9613 error "stripe info inherit failed"
9615 run_test 65h "directory stripe info inherit ===================="
9618 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9620 save_layout_restore_at_exit $MOUNT
9622 # bug6367: set non-default striping on root directory
9623 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
9625 # bug12836: getstripe on -1 default directory striping
9626 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
9628 # bug12836: getstripe -v on -1 default directory striping
9629 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
9631 # bug12836: new find on -1 default directory striping
9632 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
9634 run_test 65i "various tests to set root directory striping"
9636 test_65j() { # bug6367
9637 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9641 # if we aren't already remounting for each test, do so for this test
9642 if [ "$I_MOUNTED" = "yes" ]; then
9643 cleanup || error "failed to unmount"
9647 save_layout_restore_at_exit $MOUNT
9649 $LFS setstripe -d $MOUNT || error "setstripe failed"
9651 run_test 65j "set default striping on root directory (bug 6367)="
9655 wait_delete_completed
9656 do_facet $SINGLEMDS "lctl set_param -n \
9657 osp.$ost*MDT0000.max_create_count=$max_count"
9658 do_facet $SINGLEMDS "lctl set_param -n \
9659 osp.$ost*MDT0000.create_count=$count"
9660 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9661 echo $INACTIVE_OSC "is Activate"
9663 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9666 test_65k() { # bug11679
9667 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9668 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9669 remote_mds_nodsh && skip "remote MDS with nodsh"
9671 local disable_precreate=true
9672 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
9673 disable_precreate=false
9675 echo "Check OST status: "
9676 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
9677 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
9679 for OSC in $MDS_OSCS; do
9680 echo $OSC "is active"
9681 do_facet $SINGLEMDS lctl --device %$OSC activate
9684 for INACTIVE_OSC in $MDS_OSCS; do
9685 local ost=$(osc_to_ost $INACTIVE_OSC)
9686 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
9687 lov.*md*.target_obd |
9688 awk -F: /$ost/'{ print $1 }' | head -n 1)
9691 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
9692 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
9694 echo "Deactivate: " $INACTIVE_OSC
9695 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
9697 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
9698 osp.$ost*MDT0000.create_count")
9699 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
9700 osp.$ost*MDT0000.max_create_count")
9701 $disable_precreate &&
9702 do_facet $SINGLEMDS "lctl set_param -n \
9703 osp.$ost*MDT0000.max_create_count=0"
9705 for idx in $(seq 0 $((OSTCOUNT - 1))); do
9706 [ -f $DIR/$tdir/$idx ] && continue
9707 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
9708 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
9710 error "setstripe $idx should succeed"; }
9711 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
9713 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
9716 do_facet $SINGLEMDS "lctl set_param -n \
9717 osp.$ost*MDT0000.max_create_count=$max_count"
9718 do_facet $SINGLEMDS "lctl set_param -n \
9719 osp.$ost*MDT0000.create_count=$count"
9720 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9721 echo $INACTIVE_OSC "is Activate"
9723 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9726 run_test 65k "validate manual striping works properly with deactivated OSCs"
9728 test_65l() { # bug 12836
9729 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9731 test_mkdir -p $DIR/$tdir/test_dir
9732 $LFS setstripe -c -1 $DIR/$tdir/test_dir
9733 $LFS find -mtime -1 $DIR/$tdir >/dev/null
9735 run_test 65l "lfs find on -1 stripe dir ========================"
9738 local layout=$(save_layout $MOUNT)
9739 $RUNAS $LFS setstripe -c 2 $MOUNT && {
9740 restore_layout $MOUNT $layout
9741 error "setstripe should fail by non-root users"
9745 run_test 65m "normal user can't set filesystem default stripe"
9748 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
9749 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
9750 skip "Need MDS version at least 2.12.50"
9751 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9753 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
9754 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
9755 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
9757 save_layout_restore_at_exit $MOUNT
9759 # new subdirectory under root directory should not inherit
9760 # the default layout from root
9761 local dir1=$MOUNT/$tdir-1
9762 mkdir $dir1 || error "mkdir $dir1 failed"
9763 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
9764 error "$dir1 shouldn't have LOV EA"
9766 # delete the default layout on root directory
9767 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
9769 local dir2=$MOUNT/$tdir-2
9770 mkdir $dir2 || error "mkdir $dir2 failed"
9771 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
9772 error "$dir2 shouldn't have LOV EA"
9774 # set a new striping pattern on root directory
9775 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9776 local new_def_stripe_size=$((def_stripe_size * 2))
9777 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
9778 error "set stripe size on $MOUNT failed"
9780 # new file created in $dir2 should inherit the new stripe size from
9781 # the filesystem default
9782 local file2=$dir2/$tfile-2
9783 touch $file2 || error "touch $file2 failed"
9785 local file2_stripe_size=$($LFS getstripe -S $file2)
9786 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
9788 echo "file2_stripe_size: '$file2_stripe_size'"
9789 echo "new_def_stripe_size: '$new_def_stripe_size'"
9790 error "$file2 didn't inherit stripe size $new_def_stripe_size"
9793 local dir3=$MOUNT/$tdir-3
9794 mkdir $dir3 || error "mkdir $dir3 failed"
9795 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
9796 # the root layout, which is the actual default layout that will be used
9797 # when new files are created in $dir3.
9798 local dir3_layout=$(get_layout_param $dir3)
9799 local root_dir_layout=$(get_layout_param $MOUNT)
9800 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
9802 echo "dir3_layout: '$dir3_layout'"
9803 echo "root_dir_layout: '$root_dir_layout'"
9804 error "$dir3 should show the default layout from $MOUNT"
9807 # set OST pool on root directory
9808 local pool=$TESTNAME
9809 pool_add $pool || error "add $pool failed"
9810 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9811 error "add targets to $pool failed"
9813 $LFS setstripe -p $pool $MOUNT ||
9814 error "set OST pool on $MOUNT failed"
9816 # new file created in $dir3 should inherit the pool from
9817 # the filesystem default
9818 local file3=$dir3/$tfile-3
9819 touch $file3 || error "touch $file3 failed"
9821 local file3_pool=$($LFS getstripe -p $file3)
9822 [[ "$file3_pool" = "$pool" ]] ||
9823 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
9825 local dir4=$MOUNT/$tdir-4
9826 mkdir $dir4 || error "mkdir $dir4 failed"
9827 local dir4_layout=$(get_layout_param $dir4)
9828 root_dir_layout=$(get_layout_param $MOUNT)
9829 echo "$LFS getstripe -d $dir4"
9830 $LFS getstripe -d $dir4
9831 echo "$LFS getstripe -d $MOUNT"
9832 $LFS getstripe -d $MOUNT
9833 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
9835 echo "dir4_layout: '$dir4_layout'"
9836 echo "root_dir_layout: '$root_dir_layout'"
9837 error "$dir4 should show the default layout from $MOUNT"
9840 # new file created in $dir4 should inherit the pool from
9841 # the filesystem default
9842 local file4=$dir4/$tfile-4
9843 touch $file4 || error "touch $file4 failed"
9845 local file4_pool=$($LFS getstripe -p $file4)
9846 [[ "$file4_pool" = "$pool" ]] ||
9847 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
9849 # new subdirectory under non-root directory should inherit
9850 # the default layout from its parent directory
9851 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
9852 error "set directory layout on $dir4 failed"
9854 local dir5=$dir4/$tdir-5
9855 mkdir $dir5 || error "mkdir $dir5 failed"
9857 dir4_layout=$(get_layout_param $dir4)
9858 local dir5_layout=$(get_layout_param $dir5)
9859 [[ "$dir4_layout" = "$dir5_layout" ]] ||
9861 echo "dir4_layout: '$dir4_layout'"
9862 echo "dir5_layout: '$dir5_layout'"
9863 error "$dir5 should inherit the default layout from $dir4"
9866 # though subdir under ROOT doesn't inherit default layout, but
9867 # its sub dir/file should be created with default layout.
9868 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
9869 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
9870 skip "Need MDS version at least 2.12.59"
9872 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
9873 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
9874 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
9876 if [ $default_lmv_hash == "none" ]; then
9877 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
9879 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
9880 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
9883 $LFS setdirstripe -D -c 2 $MOUNT ||
9884 error "setdirstripe -D -c 2 failed"
9885 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
9886 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
9887 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
9889 # $dir4 layout includes pool
9890 $LFS setstripe -S $((new_def_stripe_size * 2)) $dir4
9891 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9892 error "pool lost on setstripe"
9893 $LFS setstripe -E -1 -S $new_def_stripe_size $dir4
9894 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9895 error "pool lost on compound layout setstripe"
9897 run_test 65n "don't inherit default layout from root for new subdirectories"
9900 (( $MDS1_VERSION >= $(version_code 2.14.57) )) ||
9901 skip "need MDS version at least 2.14.57"
9903 # set OST pool on root directory
9904 local pool=$TESTNAME
9906 pool_add $pool || error "add $pool failed"
9907 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9908 error "add targets to $pool failed"
9910 local dir1=$MOUNT/$tdir
9912 mkdir $dir1 || error "mkdir $dir1 failed"
9914 # set a new striping pattern on root directory
9915 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9917 $LFS setstripe -p $pool $dir1 ||
9918 error "set directory layout on $dir1 failed"
9920 # $dir1 layout includes pool
9921 $LFS setstripe -S $((def_stripe_size * 2)) $dir1
9922 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9923 error "pool lost on setstripe"
9924 $LFS setstripe -E 1M -L mdt -E -1 -c 1 $dir1
9925 $LFS getstripe $dir1
9926 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9927 error "pool lost on compound layout setstripe"
9929 $LFS setdirstripe -i 0 -c 2 $dir1/dir2 ||
9930 error "setdirstripe failed on sub-dir with inherited pool"
9931 $LFS getstripe $dir1/dir2
9932 [[ "$pool" = $($LFS getstripe -p -d $dir1/dir2) ]] ||
9933 error "pool lost on compound layout setdirstripe"
9935 $LFS setstripe -E -1 -c 1 $dir1
9936 $LFS getstripe -d $dir1
9937 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9938 error "pool lost on setstripe"
9940 run_test 65o "pool inheritance for mdt component"
9942 test_65p () { # LU-16152
9943 local src_dir=$DIR/$tdir/src_dir
9944 local dst_dir=$DIR/$tdir/dst_dir
9945 local yaml_file=$DIR/$tdir/layout.yaml
9948 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
9949 skip "Need at least version 2.15.51"
9951 test_mkdir -p $src_dir
9952 $LFS setstripe -E 2048M -c 4 -E EOF -c 8 $src_dir ||
9953 error "failed to setstripe"
9954 $LFS getstripe --yaml -d $src_dir > $yaml_file ||
9955 error "failed to getstripe"
9957 test_mkdir -p $dst_dir
9958 $LFS setstripe --yaml $yaml_file $dst_dir ||
9959 error "failed to setstripe with yaml file"
9960 border=$($LFS getstripe -d $dst_dir |
9961 awk '/lcme_extent.e_end:/ { print $2; exit; }') ||
9962 error "failed to getstripe"
9964 # 2048M is 0x80000000, or 2147483648
9965 (( $border == 2147483648 )) ||
9966 error "failed to handle huge number in yaml layout"
9968 run_test 65p "setstripe with yaml file and huge number"
9970 # bug 2543 - update blocks count on client
9972 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9974 local COUNT=${COUNT:-8}
9975 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
9976 sync; sync_all_data; sync; sync_all_data
9977 cancel_lru_locks osc
9978 local BLOCKS=$(ls -s --block-size=1k $DIR/f66 | awk '{ print $1 }')
9979 (( BLOCKS >= COUNT )) || error "$DIR/f66 blocks $BLOCKS < $COUNT"
9981 run_test 66 "update inode blocks count on client ==============="
9984 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
9988 swapon -s | awk '($1 == "'$1'") { print $4 }'
9991 # bug5265, obdfilter oa2dentry return -ENOENT
9992 # #define OBD_FAIL_SRV_ENOENT 0x217
9994 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9995 remote_ost_nodsh && skip "remote OST with nodsh"
9998 $LFS setstripe -c 1 -i 0 $f
10000 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
10002 do_facet ost1 lctl set_param fail_loc=0x217
10003 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
10004 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
10006 do_facet ost1 lctl set_param fail_loc=0
10007 $DIRECTIO write $f 0 2 || error "write error"
10009 cancel_lru_locks osc
10010 $DIRECTIO read $f 0 1 || error "read error"
10012 do_facet ost1 lctl set_param fail_loc=0x217
10013 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
10015 do_facet ost1 lctl set_param fail_loc=0
10018 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
10021 test_mkdir $DIR/$tdir
10022 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
10023 bash rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
10025 run_test 71 "Running dbench on lustre (don't segment fault) ===="
10027 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
10028 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10029 [ "$RUNAS_ID" = "$UID" ] &&
10030 skip_env "RUNAS_ID = UID = $UID -- skipping"
10031 # Check that testing environment is properly set up. Skip if not
10032 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
10033 skip_env "User $RUNAS_ID does not exist - skipping"
10036 chmod 777 $DIR/$tfile
10037 chmod ug+s $DIR/$tfile
10038 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
10039 error "$RUNAS dd $DIR/$tfile failed"
10040 # See if we are still setuid/sgid
10041 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
10042 error "S/gid is not dropped on write"
10043 # Now test that MDS is updated too
10044 cancel_lru_locks mdc
10045 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
10046 error "S/gid is not dropped on MDS"
10049 run_test 72a "Test that remove suid works properly (bug5695) ===="
10051 test_72b() { # bug 24226 -- keep mode setting when size is not changing
10054 [ "$RUNAS_ID" = "$UID" ] &&
10055 skip_env "RUNAS_ID = UID = $UID -- skipping"
10056 [ "$RUNAS_ID" -eq 0 ] &&
10057 skip_env "RUNAS_ID = 0 -- skipping"
10058 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10059 # Check that testing environment is properly set up. Skip if not
10060 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
10061 skip_env "User $RUNAS_ID does not exist - skipping"
10063 touch $DIR/${tfile}-f{g,u}
10064 test_mkdir $DIR/${tfile}-dg
10065 test_mkdir $DIR/${tfile}-du
10066 chmod 770 $DIR/${tfile}-{f,d}{g,u}
10067 chmod g+s $DIR/${tfile}-{f,d}g
10068 chmod u+s $DIR/${tfile}-{f,d}u
10069 for perm in 777 2777 4777; do
10070 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
10071 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
10072 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
10073 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
10077 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
10079 # bug 3462 - multiple simultaneous MDC requests
10081 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10083 test_mkdir $DIR/d73-1
10084 test_mkdir $DIR/d73-2
10085 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
10088 lctl set_param fail_loc=0x80000129
10089 $MULTIOP $DIR/d73-1/f73-2 Oc &
10091 lctl set_param fail_loc=0
10093 $MULTIOP $DIR/d73-2/f73-3 Oc &
10097 wait $pid1 || return 1
10101 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
10102 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
10103 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
10107 run_test 73 "multiple MDC requests (should not deadlock)"
10109 test_74a() { # bug 6149, 6184
10110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10113 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
10115 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
10116 # will spin in a tight reconnection loop
10117 $LCTL set_param fail_loc=0x8000030e
10118 # get any lock that won't be difficult - lookup works.
10120 $LCTL set_param fail_loc=0
10124 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
10126 test_74b() { # bug 13310
10127 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10129 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
10131 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
10132 # will spin in a tight reconnection loop
10133 $LCTL set_param fail_loc=0x8000030e
10134 # get a "difficult" lock
10136 $LCTL set_param fail_loc=0
10140 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
10143 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10145 #define OBD_FAIL_LDLM_NEW_LOCK
10146 $LCTL set_param fail_loc=0x319
10147 touch $DIR/$tfile && error "touch successful"
10148 $LCTL set_param fail_loc=0
10151 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
10153 slab_lic=/sys/kernel/slab/lustre_inode_cache
10155 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
10156 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
10157 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
10160 test_76a() { # Now for b=20433, added originally in b=1443
10161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10163 cancel_lru_locks osc
10164 # there may be some slab objects cached per core
10165 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
10166 local before=$(num_objects)
10167 local count=$((512 * cpus))
10168 [ "$SLOW" = "no" ] && count=$((128 * cpus))
10169 local margin=$((count / 10))
10170 if [[ -f $slab_lic/aliases ]]; then
10171 local aliases=$(cat $slab_lic/aliases)
10172 (( aliases > 0 )) && margin=$((margin * aliases))
10175 echo "before slab objects: $before"
10176 for i in $(seq $count); do
10180 cancel_lru_locks osc
10181 local after=$(num_objects)
10182 echo "created: $count, after slab objects: $after"
10183 # shared slab counts are not very accurate, allow significant margin
10184 # the main goal is that the cache growth is not permanently > $count
10185 while (( after > before + margin )); do
10187 after=$(num_objects)
10189 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
10190 if (( wait > 60 )); then
10191 error "inode slab grew from $before+$margin to $after"
10195 run_test 76a "confirm clients recycle inodes properly ===="
10198 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10199 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
10202 local before=$(num_objects)
10204 for i in $(seq $count); do
10209 local after=$(num_objects)
10212 while (( after > before )); do
10214 after=$(num_objects)
10216 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
10217 if (( wait > 60 )); then
10218 error "inode slab grew from $before to $after"
10222 echo "slab objects before: $before, after: $after"
10224 run_test 76b "confirm clients recycle directory inodes properly ===="
10226 export ORIG_CSUM=""
10229 # Note: in sptlrpc modes which enable its own bulk checksum, the
10230 # original crc32_le bulk checksum will be automatically disabled,
10231 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
10232 # will be checked by sptlrpc code against sptlrpc bulk checksum.
10233 # In this case set_checksums() will not be no-op, because sptlrpc
10234 # bulk checksum will be enabled all through the test.
10236 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
10237 lctl set_param -n osc.*.checksums $1
10241 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
10242 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
10243 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
10244 tr -d [] | head -n1)}
10245 set_checksum_type()
10247 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
10249 log "set checksum type to $1, rc = $rc"
10253 get_osc_checksum_type()
10255 # arugment 1: OST name, like OST0000
10257 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
10258 sed 's/.*\[\(.*\)\].*/\1/g')
10260 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
10261 echo $checksum_type
10264 F77_TMP=$TMP/f77-temp
10267 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
10268 error "error writing to $F77_TMP"
10271 test_77a() { # bug 10889
10272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10273 $GSS && skip_env "could not run with gss"
10275 [ ! -f $F77_TMP ] && setup_f77
10277 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
10281 run_test 77a "normal checksum read/write operation"
10283 test_77b() { # bug 10889
10284 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10285 $GSS && skip_env "could not run with gss"
10287 [ ! -f $F77_TMP ] && setup_f77
10288 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10289 $LCTL set_param fail_loc=0x80000409
10292 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10293 error "dd error: $?"
10294 $LCTL set_param fail_loc=0
10296 for algo in $CKSUM_TYPES; do
10297 cancel_lru_locks osc
10298 set_checksum_type $algo
10299 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10300 $LCTL set_param fail_loc=0x80000408
10301 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
10302 $LCTL set_param fail_loc=0
10305 set_checksum_type $ORIG_CSUM_TYPE
10308 run_test 77b "checksum error on client write, read"
10313 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
10315 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
10316 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
10317 $check_ost && [ -n "$ost_file_prefix" ] &&
10318 do_facet ost1 rm -f ${ost_file_prefix}\*
10322 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10323 $GSS && skip_env "could not run with gss"
10324 remote_ost_nodsh && skip "remote OST with nodsh"
10327 local osc_file_prefix
10329 local check_ost=false
10330 local ost_file_prefix
10336 # ensure corruption will occur on first OSS/OST
10337 $LFS setstripe -i 0 $DIR/$tfile
10339 [ ! -f $F77_TMP ] && setup_f77
10340 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10341 error "dd write error: $?"
10342 fid=$($LFS path2fid $DIR/$tfile)
10344 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
10347 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
10348 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
10350 echo "OSS do not support bulk pages dump upon error"
10353 osc_file_prefix=$($LCTL get_param -n debug_path)
10354 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
10356 trap cleanup_77c EXIT
10359 # enable bulk pages dump upon error on Client
10360 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
10361 # enable bulk pages dump upon error on OSS
10363 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
10365 # flush Client cache to allow next read to reach OSS
10366 cancel_lru_locks osc
10368 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10369 $LCTL set_param fail_loc=0x80000408
10370 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
10371 $LCTL set_param fail_loc=0
10375 # check cksum dump on Client
10376 osc_file=$(ls ${osc_file_prefix}*)
10377 [ -n "$osc_file" ] || error "no checksum dump file on Client"
10378 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
10379 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
10380 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
10381 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
10383 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
10384 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10385 error "dump content does not match on Client"
10387 $check_ost || skip "No need to check cksum dump on OSS"
10389 # check cksum dump on OSS
10390 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
10391 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
10392 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
10393 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
10394 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10395 error "dump content does not match on OSS"
10399 run_test 77c "checksum error on client read with debug"
10401 test_77d() { # bug 10889
10402 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10403 $GSS && skip_env "could not run with gss"
10405 stack_trap "rm -f $DIR/$tfile"
10406 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10407 $LCTL set_param fail_loc=0x80000409
10409 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10410 error "direct write: rc=$?"
10411 $LCTL set_param fail_loc=0
10414 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10415 $LCTL set_param fail_loc=0x80000408
10417 cancel_lru_locks osc
10418 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10419 error "direct read: rc=$?"
10420 $LCTL set_param fail_loc=0
10423 run_test 77d "checksum error on OST direct write, read"
10425 test_77f() { # bug 10889
10426 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10427 $GSS && skip_env "could not run with gss"
10430 stack_trap "rm -f $DIR/$tfile"
10431 for algo in $CKSUM_TYPES; do
10432 cancel_lru_locks osc
10433 set_checksum_type $algo
10434 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10435 $LCTL set_param fail_loc=0x409
10436 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
10437 error "direct write succeeded"
10438 $LCTL set_param fail_loc=0
10440 set_checksum_type $ORIG_CSUM_TYPE
10443 run_test 77f "repeat checksum error on write (expect error)"
10445 test_77g() { # bug 10889
10446 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10447 $GSS && skip_env "could not run with gss"
10448 remote_ost_nodsh && skip "remote OST with nodsh"
10450 [ ! -f $F77_TMP ] && setup_f77
10452 local file=$DIR/$tfile
10453 stack_trap "rm -f $file" EXIT
10455 $LFS setstripe -c 1 -i 0 $file
10456 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
10457 do_facet ost1 lctl set_param fail_loc=0x8000021a
10459 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
10460 error "write error: rc=$?"
10461 do_facet ost1 lctl set_param fail_loc=0
10464 cancel_lru_locks osc
10465 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
10466 do_facet ost1 lctl set_param fail_loc=0x8000021b
10468 cmp $F77_TMP $file || error "file compare failed"
10469 do_facet ost1 lctl set_param fail_loc=0
10472 run_test 77g "checksum error on OST write, read"
10474 test_77k() { # LU-10906
10475 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10476 $GSS && skip_env "could not run with gss"
10478 local cksum_param="osc.$FSNAME*.checksums"
10479 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
10483 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
10484 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
10485 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
10488 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
10489 error "failed to set checksum=$i on MGS"
10490 wait_update $HOSTNAME "$get_checksum" $i
10492 echo "remount client, checksum should be $i"
10493 remount_client $MOUNT || error "failed to remount client"
10494 checksum=$(eval $get_checksum)
10495 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10497 # remove persistent param to avoid races with checksum mountopt below
10498 do_facet mgs $LCTL set_param -P -d $cksum_param ||
10499 error "failed to delete checksum on MGS"
10501 for opt in "checksum" "nochecksum"; do
10502 #remount with mount option
10503 echo "remount client with option $opt, checksum should be $i"
10504 umount_client $MOUNT || error "failed to umount client"
10505 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
10506 error "failed to mount client with option '$opt'"
10507 checksum=$(eval $get_checksum)
10508 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10512 remount_client $MOUNT || error "failed to remount client"
10514 run_test 77k "enable/disable checksum correctly"
10517 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10518 $GSS && skip_env "could not run with gss"
10521 stack_trap "set_checksums $ORIG_CSUM" EXIT
10522 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10524 set_checksum_type invalid && error "unexpected success of invalid checksum type"
10526 $LFS setstripe -c 1 -i 0 $DIR/$tfile
10527 for algo in $CKSUM_TYPES; do
10528 set_checksum_type $algo || error "fail to set checksum type $algo"
10529 osc_algo=$(get_osc_checksum_type OST0000)
10530 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
10532 # no locks, no reqs to let the connection idle
10533 cancel_lru_locks osc
10534 lru_resize_disable osc
10535 wait_osc_import_state client ost1 IDLE
10537 # ensure ost1 is connected
10538 stat $DIR/$tfile >/dev/null || error "can't stat"
10539 wait_osc_import_state client ost1 FULL
10541 osc_algo=$(get_osc_checksum_type OST0000)
10542 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
10546 run_test 77l "preferred checksum type is remembered after reconnected"
10548 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
10553 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
10554 skip "Need at least version 2.14.52"
10555 local param=checksum_speed
10557 $LCTL get_param $param || error "reading $param failed"
10559 csum_speeds=$($LCTL get_param -n $param)
10561 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
10562 error "known checksum types are missing"
10564 run_test 77m "Verify checksum_speed is correctly read"
10566 check_filefrag_77n() {
10571 while read extidx a b start end rest; do
10572 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
10573 nr_ext=$(( $nr_ext + 1 ))
10574 starts+=( ${start%..} )
10577 done < <( filefrag -sv $1 )
10579 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
10584 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
10587 $TRUNCATE $DIR/$tfile 0
10588 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
10589 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
10590 check_filefrag_77n $DIR/$tfile ||
10591 skip "$tfile blocks not contiguous around hole"
10594 stack_trap "set_checksums $ORIG_CSUM" EXIT
10595 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10596 stack_trap "rm -f $DIR/$tfile"
10598 for algo in $CKSUM_TYPES; do
10599 if [[ "$algo" =~ ^t10 ]]; then
10600 set_checksum_type $algo ||
10601 error "fail to set checksum type $algo"
10602 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
10603 error "fail to read $tfile with $algo"
10609 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
10612 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
10613 skip "Need MDS version at least 2.14.55"
10614 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
10615 skip "Need OST version at least 2.14.55"
10616 local ofd=obdfilter
10619 # print OST checksum_type
10620 echo "$ofd.$FSNAME-*.checksum_type:"
10621 do_nodes $(comma_list $(osts_nodes)) \
10622 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type
10624 # print MDT checksum_type
10625 echo "$mdt.$FSNAME-*.checksum_type:"
10626 do_nodes $(comma_list $(mdts_nodes)) \
10627 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type
10629 local o_count=$(do_nodes $(comma_list $(osts_nodes)) \
10630 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l)
10632 (( $o_count == $OSTCOUNT )) ||
10633 error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT"
10635 local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \
10636 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l)
10638 (( $m_count == $MDSCOUNT )) ||
10639 error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT"
10641 run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))"
10643 cleanup_test_78() {
10648 test_78() { # bug 10901
10649 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10650 remote_ost || skip_env "local OST"
10653 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
10654 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
10655 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
10656 echo "MemTotal: $MEMTOTAL"
10658 # reserve 256MB of memory for the kernel and other running processes,
10659 # and then take 1/2 of the remaining memory for the read/write buffers.
10660 if [ $MEMTOTAL -gt 512 ] ;then
10661 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
10663 # for those poor memory-starved high-end clusters...
10664 MEMTOTAL=$((MEMTOTAL / 2))
10666 echo "Mem to use for directio: $MEMTOTAL"
10668 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
10669 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
10670 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
10671 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
10673 echo "Smallest OST: $SMALLESTOST"
10674 [[ $SMALLESTOST -lt 10240 ]] &&
10675 skip "too small OSTSIZE, useless to run large O_DIRECT test"
10677 trap cleanup_test_78 EXIT
10679 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
10680 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
10682 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
10683 echo "File size: $F78SIZE"
10684 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
10685 for i in $(seq 1 $NSEQ); do
10686 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
10687 echo directIO rdwr round $i of $NSEQ
10688 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
10693 run_test 78 "handle large O_DIRECT writes correctly ============"
10695 test_79() { # bug 12743
10696 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10698 wait_delete_completed
10700 BKTOTAL=$(calc_osc_kbytes kbytestotal)
10701 BKFREE=$(calc_osc_kbytes kbytesfree)
10702 BKAVAIL=$(calc_osc_kbytes kbytesavail)
10704 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
10705 DFTOTAL=`echo $STRING | cut -d, -f1`
10706 DFUSED=`echo $STRING | cut -d, -f2`
10707 DFAVAIL=`echo $STRING | cut -d, -f3`
10708 DFFREE=$(($DFTOTAL - $DFUSED))
10710 ALLOWANCE=$((64 * $OSTCOUNT))
10712 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
10713 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
10714 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
10716 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
10717 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
10718 error "df free($DFFREE) mismatch OST free($BKFREE)"
10720 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
10721 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
10722 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
10725 run_test 79 "df report consistency check ======================="
10727 test_80() { # bug 10718
10728 remote_ost_nodsh && skip "remote OST with nodsh"
10729 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10731 # relax strong synchronous semantics for slow backends like ZFS
10732 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
10733 local soc="obdfilter.*.sync_lock_cancel"
10734 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10736 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
10737 if [ -z "$save" ]; then
10738 soc="obdfilter.*.sync_on_lock_cancel"
10739 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10742 if [ "$save" != "never" ]; then
10743 local hosts=$(comma_list $(osts_nodes))
10745 do_nodes $hosts $LCTL set_param $soc=never
10746 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
10750 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
10751 sync; sleep 1; sync
10752 local before=$(date +%s)
10753 cancel_lru_locks osc
10754 local after=$(date +%s)
10755 local diff=$((after - before))
10756 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
10760 run_test 80 "Page eviction is equally fast at high offsets too"
10762 test_81a() { # LU-456
10763 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10764 remote_ost_nodsh && skip "remote OST with nodsh"
10766 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10767 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
10768 do_facet ost1 lctl set_param fail_loc=0x80000228
10770 # write should trigger a retry and success
10771 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10772 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10774 if [ $RC -ne 0 ] ; then
10775 error "write should success, but failed for $RC"
10778 run_test 81a "OST should retry write when get -ENOSPC ==============="
10780 test_81b() { # LU-456
10781 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10782 remote_ost_nodsh && skip "remote OST with nodsh"
10784 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10785 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
10786 do_facet ost1 lctl set_param fail_loc=0x228
10788 # write should retry several times and return -ENOSPC finally
10789 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10790 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10793 if [ $RC -ne $ENOSPC ] ; then
10794 error "dd should fail for -ENOSPC, but succeed."
10797 run_test 81b "OST should return -ENOSPC when retry still fails ======="
10800 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
10802 test_mkdir $DIR/$tdir.cvsroot
10803 chown $RUNAS_ID $DIR/$tdir.cvsroot
10806 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
10809 # some versions of cvs import exit(1) when asked to import links or
10810 # files they can't read. ignore those files.
10811 local toignore=$(find . -type l -printf '-I %f\n' -o \
10812 ! -perm /4 -printf '-I %f\n')
10813 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
10814 $tdir.reposname vtag rtag
10817 test_mkdir $DIR/$tdir.reposname
10818 chown $RUNAS_ID $DIR/$tdir.reposname
10819 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
10821 cd $DIR/$tdir.reposname
10823 $RUNAS cvs add -m 'addmsg' foo99
10825 $RUNAS cvs commit -m 'nomsg' foo99
10826 rm -fr $DIR/$tdir.cvsroot
10828 run_test 99 "cvs strange file/directory operations"
10831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10832 [[ "$NETTYPE" =~ tcp ]] ||
10833 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
10834 remote_ost_nodsh && skip "remote OST with nodsh"
10835 remote_mds_nodsh && skip "remote MDS with nodsh"
10837 skip "useless for local single node setup"
10839 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
10840 [ "$PROT" != "tcp" ] && continue
10841 RPORT=$(echo $REMOTE | cut -d: -f2)
10842 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
10845 LPORT=`echo $LOCAL | cut -d: -f2`
10846 if [ $LPORT -ge 1024 ]; then
10847 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
10849 error_exit "local: $LPORT > 1024, remote: $RPORT"
10852 [ "$rc" = 0 ] || error_exit "privileged port not found" )
10854 run_test 100 "check local port using privileged port ==========="
10856 function get_named_value()
10860 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
10863 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
10864 awk '/^max_cached_mb/ { print $2 }')
10867 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
10872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10877 local cache_limit=32
10879 $LCTL set_param -n osc.*-osc*.rpc_stats=0
10880 trap cleanup_101a EXIT
10881 $LCTL set_param -n llite.*.read_ahead_stats=0
10882 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
10885 # randomly read 10000 of 64K chunks from file 3x 32MB in size
10887 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
10888 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
10891 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
10892 get_named_value 'read.but.discarded'); do
10893 discard=$(($discard + $s))
10897 $LCTL get_param osc.*-osc*.rpc_stats
10898 $LCTL get_param llite.*.read_ahead_stats
10900 # Discard is generally zero, but sometimes a few random reads line up
10901 # and trigger larger readahead, which is wasted & leads to discards.
10902 if [[ $(($discard)) -gt $nreads ]]; then
10903 error "too many ($discard) discarded pages"
10905 rm -f $DIR/$tfile || true
10907 run_test 101a "check read-ahead for random reads"
10909 setup_test101bc() {
10910 test_mkdir $DIR/$tdir
10912 local FILE_LENGTH=$2
10915 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
10917 local list=$(comma_list $(osts_nodes))
10918 set_osd_param $list '' read_cache_enable 0
10919 set_osd_param $list '' writethrough_cache_enable 0
10921 trap cleanup_test101bc EXIT
10922 # prepare the read-ahead file
10923 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
10925 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
10926 count=$FILE_SIZE_MB 2> /dev/null
10930 cleanup_test101bc() {
10935 local list=$(comma_list $(osts_nodes))
10936 set_osd_param $list '' read_cache_enable 1
10937 set_osd_param $list '' writethrough_cache_enable 1
10941 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
10946 local stripe_size=$2
10947 local stride_length=$((stripe_size / read_size))
10948 local stride_width=$((stride_length * OSTCOUNT))
10949 local discard_limit=$(( ((stride_length - 1) * 3 / stride_width) *
10950 (stride_width - stride_length) ))
10951 local discard=$($LCTL get_param -n llite.*.read_ahead_stats |
10952 get_named_value 'read.but.discarded' | calc_total)
10954 if [[ $discard -gt $discard_limit ]]; then
10955 $LCTL get_param llite.*.read_ahead_stats
10956 error "($discard limit ${discard_limit}) discarded pages with size (${read_size})"
10958 echo "Read-ahead success for size ${read_size}"
10963 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10964 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10966 local STRIPE_SIZE=1048576
10967 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
10969 if [ $SLOW == "yes" ]; then
10970 local FILE_LENGTH=$((STRIDE_SIZE * 64))
10972 local FILE_LENGTH=$((STRIDE_SIZE * 8))
10975 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
10977 # prepare the read-ahead file
10978 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10979 cancel_lru_locks osc
10980 for BIDX in 2 4 8 16 32 64 128 256
10982 local BSIZE=$((BIDX*4096))
10983 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
10984 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
10985 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
10986 $LCTL set_param -n llite.*.read_ahead_stats=0
10987 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
10988 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
10989 cancel_lru_locks osc
10990 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
10995 run_test 101b "check stride-io mode read-ahead ================="
10998 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11000 local STRIPE_SIZE=1048576
11001 local FILE_LENGTH=$((STRIPE_SIZE*100))
11004 local osc_rpc_stats
11006 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
11008 cancel_lru_locks osc
11009 $LCTL set_param osc.*.rpc_stats=0
11010 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
11011 $LCTL get_param osc.*.rpc_stats
11012 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
11013 local stats=$($LCTL get_param -n $osc_rpc_stats)
11014 local lines=$(echo "$stats" | awk 'END {print NR;}')
11017 if [ $lines -le 20 ]; then
11018 echo "continue debug"
11021 for size in 1 2 4 8; do
11022 local rpc=$(echo "$stats" |
11023 awk '($1 == "'$size':") {print $2; exit; }')
11024 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
11025 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
11027 echo "$osc_rpc_stats check passed!"
11032 run_test 101c "check stripe_size aligned read-ahead"
11035 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11037 local file=$DIR/$tfile
11038 local sz_MB=${FILESIZE_101d:-80}
11039 local ra_MB=${READAHEAD_MB:-40}
11041 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
11042 [ $free_MB -lt $sz_MB ] &&
11043 skip "Need free space ${sz_MB}M, have ${free_MB}M"
11045 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
11046 $LFS setstripe -c -1 $file || error "setstripe failed"
11048 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
11049 echo Cancel LRU locks on lustre client to flush the client cache
11050 cancel_lru_locks osc
11052 echo Disable read-ahead
11053 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
11054 $LCTL set_param -n llite.*.max_read_ahead_mb=0
11055 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
11056 $LCTL get_param -n llite.*.max_read_ahead_mb
11058 echo "Reading the test file $file with read-ahead disabled"
11059 local sz_KB=$((sz_MB * 1024 / 4))
11060 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
11061 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
11062 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
11063 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
11065 echo "Cancel LRU locks on lustre client to flush the client cache"
11066 cancel_lru_locks osc
11067 echo Enable read-ahead with ${ra_MB}MB
11068 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
11070 echo "Reading the test file $file with read-ahead enabled"
11071 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
11072 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
11074 echo "read-ahead disabled time read $raOFF"
11075 echo "read-ahead enabled time read $raON"
11078 wait_delete_completed
11080 # use awk for this check instead of bash because it handles decimals
11081 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
11082 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
11084 run_test 101d "file read with and without read-ahead enabled"
11087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11089 local file=$DIR/$tfile
11090 local size_KB=500 #KB
11094 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
11095 local need_KB=$((count * size_KB))
11096 [[ $free_KB -le $need_KB ]] &&
11097 skip_env "Need free space $need_KB, have $free_KB"
11099 echo "Creating $count ${size_KB}K test files"
11100 for ((i = 0; i < $count; i++)); do
11101 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
11104 echo "Cancel LRU locks on lustre client to flush the client cache"
11105 cancel_lru_locks $OSC
11107 echo "Reset readahead stats"
11108 $LCTL set_param -n llite.*.read_ahead_stats=0
11110 for ((i = 0; i < $count; i++)); do
11111 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
11114 $LCTL get_param llite.*.max_cached_mb
11115 $LCTL get_param llite.*.read_ahead_stats
11116 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11117 get_named_value 'misses' | calc_total)
11119 for ((i = 0; i < $count; i++)); do
11120 rm -rf $file.$i 2>/dev/null
11123 #10000 means 20% reads are missing in readahead
11124 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
11126 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
11129 which iozone || skip_env "no iozone installed"
11131 local old_debug=$($LCTL get_param debug)
11132 old_debug=${old_debug#*=}
11133 $LCTL set_param debug="reada mmap"
11135 # create a test file
11136 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
11138 echo Cancel LRU locks on lustre client to flush the client cache
11139 cancel_lru_locks osc
11141 echo Reset readahead stats
11142 $LCTL set_param -n llite.*.read_ahead_stats=0
11144 echo mmap read the file with small block size
11145 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
11148 echo checking missing pages
11149 $LCTL get_param llite.*.read_ahead_stats
11150 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11151 get_named_value 'misses' | calc_total)
11153 $LCTL set_param debug="$old_debug"
11154 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
11157 run_test 101f "check mmap read performance"
11159 test_101g_brw_size_test() {
11161 local pages=$((mb * 1048576 / PAGE_SIZE))
11162 local file=$DIR/$tfile
11164 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
11165 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
11166 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
11167 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
11171 stack_trap "rm -f $file" EXIT
11172 $LCTL set_param -n osc.*.rpc_stats=0
11174 # 10 RPCs should be enough for the test
11176 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
11177 { error "dd write ${mb} MB blocks failed"; return 3; }
11178 cancel_lru_locks osc
11179 dd of=/dev/null if=$file bs=${mb}M count=$count ||
11180 { error "dd write ${mb} MB blocks failed"; return 4; }
11182 # calculate number of full-sized read and write RPCs
11183 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
11184 sed -n '/pages per rpc/,/^$/p' |
11185 awk '/'$pages':/ { reads += $2; writes += $6 }; \
11186 END { print reads,writes }'))
11187 # allow one extra full-sized read RPC for async readahead
11188 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
11189 { error "${rpcs[0]} != $count read RPCs"; return 5; }
11190 [[ ${rpcs[1]} == $count ]] ||
11191 { error "${rpcs[1]} != $count write RPCs"; return 6; }
11195 remote_ost_nodsh && skip "remote OST with nodsh"
11198 local osts=$(get_facets OST)
11199 local list=$(comma_list $(osts_nodes))
11200 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11201 local brw_size="obdfilter.*.brw_size"
11203 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11205 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
11207 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
11208 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
11209 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
11210 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
11211 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
11212 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
11214 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
11217 if [[ $orig_mb -lt 16 ]]; then
11218 save_lustre_params $osts "$brw_size" > $p
11219 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
11220 error "set 16MB RPC size failed"
11222 echo "remount client to enable new RPC size"
11223 remount_client $MOUNT || error "remount_client failed"
11226 test_101g_brw_size_test 16 || error "16MB RPC test failed"
11227 # should be able to set brw_size=12, but no rpc_stats for that
11228 test_101g_brw_size_test 8 || error "8MB RPC test failed"
11231 test_101g_brw_size_test 4 || error "4MB RPC test failed"
11233 if [[ $orig_mb -lt 16 ]]; then
11234 restore_lustre_params < $p
11235 remount_client $MOUNT || error "remount_client restore failed"
11238 rm -f $p $DIR/$tfile
11240 run_test 101g "Big bulk(4/16 MiB) readahead"
11243 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11245 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
11246 error "dd 70M file failed"
11247 echo Cancel LRU locks on lustre client to flush the client cache
11248 cancel_lru_locks osc
11250 echo "Reset readahead stats"
11251 $LCTL set_param -n llite.*.read_ahead_stats 0
11253 echo "Read 10M of data but cross 64M bundary"
11254 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
11255 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11256 get_named_value 'misses' | calc_total)
11257 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
11258 rm -f $p $DIR/$tfile
11260 run_test 101h "Readahead should cover current read window"
11263 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
11264 error "dd 10M file failed"
11266 local max_per_file_mb=$($LCTL get_param -n \
11267 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
11268 cancel_lru_locks osc
11269 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
11270 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
11271 error "set max_read_ahead_per_file_mb to 1 failed"
11273 echo "Reset readahead stats"
11274 $LCTL set_param llite.*.read_ahead_stats=0
11276 dd if=$DIR/$tfile of=/dev/null bs=2M
11278 $LCTL get_param llite.*.read_ahead_stats
11279 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11280 awk '/misses/ { print $2 }')
11281 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
11284 run_test 101i "allow current readahead to exceed reservation"
11287 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
11288 error "setstripe $DIR/$tfile failed"
11289 local file_size=$((1048576 * 16))
11290 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
11291 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
11293 echo Disable read-ahead
11294 $LCTL set_param -n llite.*.max_read_ahead_mb=0
11296 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
11297 for blk in $PAGE_SIZE 1048576 $file_size; do
11298 cancel_lru_locks osc
11299 echo "Reset readahead stats"
11300 $LCTL set_param -n llite.*.read_ahead_stats=0
11301 local count=$(($file_size / $blk))
11302 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
11303 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11304 get_named_value 'failed.to.fast.read' | calc_total)
11305 $LCTL get_param -n llite.*.read_ahead_stats
11306 [ $miss -eq $count ] || error "expected $count got $miss"
11309 rm -f $p $DIR/$tfile
11311 run_test 101j "A complete read block should be submitted when no RA"
11315 local file=$DIR/$tfile
11317 check_set_fallocate_or_skip
11319 $LCTL set_param -n llite.*.read_ahead_stats=0
11320 fallocate -l 16K $file || error "failed to fallocate $file"
11321 cancel_lru_locks osc
11322 $MULTIOP $file or1048576c
11323 $LCTL get_param llite.*.read_ahead_stats
11325 run_test 101k "read ahead for small file"
11328 test_mkdir $DIR/$tdir
11329 chown $RUNAS_ID $DIR/$tdir
11332 STRIPE_COUNT=$OSTCOUNT
11333 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
11335 trap cleanup_test102 EXIT
11337 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
11339 for num in 1 2 3 4; do
11340 for count in $(seq 1 $STRIPE_COUNT); do
11341 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
11342 local size=`expr $STRIPE_SIZE \* $num`
11343 local file=file"$num-$idx-$count"
11344 $1 $LFS setstripe -S $size -i $idx -c $count $file
11350 $1 tar cf $TMP/f102.tar $tdir --xattrs
11353 cleanup_test102() {
11355 rm -f $TMP/f102.tar
11356 rm -rf $DIR/d0.sanity/d102
11360 [ "$UID" != 0 ] && skip "must run as root"
11361 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
11362 skip_env "must have user_xattr"
11364 [ -z "$(which setfattr 2>/dev/null)" ] &&
11365 skip_env "could not find setfattr"
11367 local testfile=$DIR/$tfile
11370 echo "set/get xattr..."
11371 setfattr -n trusted.name1 -v value1 $testfile ||
11372 error "setfattr -n trusted.name1=value1 $testfile failed"
11373 getfattr -n trusted.name1 $testfile 2> /dev/null |
11374 grep "trusted.name1=.value1" ||
11375 error "$testfile missing trusted.name1=value1"
11377 setfattr -n user.author1 -v author1 $testfile ||
11378 error "setfattr -n user.author1=author1 $testfile failed"
11379 getfattr -n user.author1 $testfile 2> /dev/null |
11380 grep "user.author1=.author1" ||
11381 error "$testfile missing trusted.author1=author1"
11383 echo "listxattr..."
11384 setfattr -n trusted.name2 -v value2 $testfile ||
11385 error "$testfile unable to set trusted.name2"
11386 setfattr -n trusted.name3 -v value3 $testfile ||
11387 error "$testfile unable to set trusted.name3"
11388 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
11389 grep "trusted.name" | wc -l) -eq 3 ] ||
11390 error "$testfile missing 3 trusted.name xattrs"
11392 setfattr -n user.author2 -v author2 $testfile ||
11393 error "$testfile unable to set user.author2"
11394 setfattr -n user.author3 -v author3 $testfile ||
11395 error "$testfile unable to set user.author3"
11396 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
11397 grep "user.author" | wc -l) -eq 3 ] ||
11398 error "$testfile missing 3 user.author xattrs"
11400 echo "remove xattr..."
11401 setfattr -x trusted.name1 $testfile ||
11402 error "$testfile error deleting trusted.name1"
11403 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
11404 error "$testfile did not delete trusted.name1 xattr"
11406 setfattr -x user.author1 $testfile ||
11407 error "$testfile error deleting user.author1"
11408 echo "set lustre special xattr ..."
11409 $LFS setstripe -c1 $testfile
11410 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
11411 awk -F "=" '/trusted.lov/ { print $2 }' )
11412 setfattr -n "trusted.lov" -v $lovea $testfile ||
11413 error "$testfile doesn't ignore setting trusted.lov again"
11414 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
11415 error "$testfile allow setting invalid trusted.lov"
11418 run_test 102a "user xattr test =================================="
11420 check_102b_layout() {
11422 local testfile=$DIR/$tfile
11424 echo "test layout '$layout'"
11425 $LFS setstripe $layout $testfile || error "setstripe failed"
11426 $LFS getstripe -y $testfile
11428 echo "get/set/list trusted.lov xattr ..." # b=10930
11429 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
11430 [[ "$value" =~ "trusted.lov" ]] ||
11431 error "can't get trusted.lov from $testfile"
11432 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
11433 error "getstripe failed"
11435 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
11437 value=$(cut -d= -f2 <<<$value)
11438 # LU-13168: truncated xattr should fail if short lov_user_md header
11439 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
11440 lens="${#value}" || lens="$(seq 4 2 ${#value})"
11441 for len in $lens; do
11442 echo "setfattr $len $testfile.2"
11443 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
11444 [ $len -lt 66 ] && error "short xattr len=$len worked"
11446 local stripe_size=$($LFS getstripe -S $testfile.2)
11447 local stripe_count=$($LFS getstripe -c $testfile.2)
11448 [[ $stripe_size -eq 65536 ]] ||
11449 error "stripe size $stripe_size != 65536"
11450 [[ $stripe_count -eq $stripe_count_orig ]] ||
11451 error "stripe count $stripe_count != $stripe_count_orig"
11452 rm $testfile $testfile.2
11456 [ -z "$(which setfattr 2>/dev/null)" ] &&
11457 skip_env "could not find setfattr"
11458 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11460 # check plain layout
11461 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
11463 # and also check composite layout
11464 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
11467 run_test 102b "getfattr/setfattr for trusted.lov EAs"
11470 [ -z "$(which setfattr 2>/dev/null)" ] &&
11471 skip_env "could not find setfattr"
11472 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11474 # b10930: get/set/list lustre.lov xattr
11475 echo "get/set/list lustre.lov xattr ..."
11476 test_mkdir $DIR/$tdir
11477 chown $RUNAS_ID $DIR/$tdir
11478 local testfile=$DIR/$tdir/$tfile
11479 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
11480 error "setstripe failed"
11481 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
11482 error "getstripe failed"
11483 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
11484 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
11486 local testfile2=${testfile}2
11487 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
11488 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
11490 $RUNAS $MCREATE $testfile2
11491 $RUNAS setfattr -n lustre.lov -v $value $testfile2
11492 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
11493 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
11494 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
11495 [ $stripe_count -eq $STRIPECOUNT ] ||
11496 error "stripe count $stripe_count != $STRIPECOUNT"
11498 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
11500 compare_stripe_info1() {
11501 local stripe_index_all_zero=true
11503 for num in 1 2 3 4; do
11504 for count in $(seq 1 $STRIPE_COUNT); do
11505 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
11506 local size=$((STRIPE_SIZE * num))
11507 local file=file"$num-$offset-$count"
11508 stripe_size=$($LFS getstripe -S $PWD/$file)
11509 [[ $stripe_size -ne $size ]] &&
11510 error "$file: size $stripe_size != $size"
11511 stripe_count=$($LFS getstripe -c $PWD/$file)
11512 # allow fewer stripes to be created, ORI-601
11513 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
11514 error "$file: count $stripe_count != $count"
11515 stripe_index=$($LFS getstripe -i $PWD/$file)
11516 [[ $stripe_index -ne 0 ]] &&
11517 stripe_index_all_zero=false
11521 $stripe_index_all_zero &&
11522 error "all files are being extracted starting from OST index 0"
11526 have_xattrs_include() {
11527 tar --help | grep -q xattrs-include &&
11528 echo --xattrs-include="lustre.*"
11532 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11533 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11535 XINC=$(have_xattrs_include)
11537 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11538 cd $DIR/$tdir/$tdir
11539 compare_stripe_info1
11541 run_test 102d "tar restore stripe info from tarfile,not keep osts"
11544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11545 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11547 XINC=$(have_xattrs_include)
11549 test_mkdir $DIR/$tdir.restore
11551 tar cf - --xattrs $tdir | tar xf - \
11552 -C $DIR/$tdir.restore --xattrs $XINC
11553 cd $DIR/$tdir.restore/$tdir
11554 compare_stripe_info1
11556 run_test 102f "tar copy files, not keep osts"
11559 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
11560 skip "must have user_xattr"
11561 [ -z "$(which setfattr 2>/dev/null)" ] &&
11562 skip_env "could not find setfattr"
11563 [ -z "$(which getfattr 2>/dev/null)" ] &&
11564 skip_env "could not find getfattr"
11566 local xsize=${1:-1024} # in bytes
11567 local file=$DIR/$tfile
11568 local value="$(generate_string $xsize)"
11569 local xbig=trusted.big
11573 log "save $xbig on $file"
11574 if [ -z "$toobig" ]
11576 setfattr -n $xbig -v $value $file ||
11577 error "saving $xbig on $file failed"
11579 setfattr -n $xbig -v $value $file &&
11580 error "saving $xbig on $file succeeded"
11584 local orig=$(get_xattr_value $xbig $file)
11585 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
11587 local xsml=trusted.sml
11588 log "save $xsml on $file"
11589 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
11591 local new=$(get_xattr_value $xbig $file)
11592 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
11594 log "grow $xsml on $file"
11595 setfattr -n $xsml -v "$value" $file ||
11596 error "growing $xsml on $file failed"
11598 new=$(get_xattr_value $xbig $file)
11599 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
11600 log "$xbig still valid after growing $xsml"
11605 test_102h() { # bug 15777
11608 run_test 102h "grow xattr from inside inode to external block"
11611 large_xattr_enabled || skip_env "ea_inode feature disabled"
11613 echo "setting xattr of max xattr size: $(max_xattr_size)"
11614 grow_xattr $(max_xattr_size)
11616 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
11617 echo "This should fail:"
11618 grow_xattr $(($(max_xattr_size) + 10)) 1
11620 run_test 102ha "grow xattr from inside inode to external inode"
11622 test_102i() { # bug 17038
11623 [ -z "$(which getfattr 2>/dev/null)" ] &&
11624 skip "could not find getfattr"
11627 ln -s $DIR/$tfile $DIR/${tfile}link
11628 getfattr -n trusted.lov $DIR/$tfile ||
11629 error "lgetxattr on $DIR/$tfile failed"
11630 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
11631 grep -i "no such attr" ||
11632 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
11633 rm -f $DIR/$tfile $DIR/${tfile}link
11635 run_test 102i "lgetxattr test on symbolic link ============"
11638 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11639 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11641 XINC=$(have_xattrs_include)
11642 setup_test102 "$RUNAS"
11643 chown $RUNAS_ID $DIR/$tdir
11644 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11645 cd $DIR/$tdir/$tdir
11646 compare_stripe_info1 "$RUNAS"
11648 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
11651 [ -z "$(which setfattr 2>/dev/null)" ] &&
11652 skip "could not find setfattr"
11655 # b22187 just check that does not crash for regular file.
11656 setfattr -n trusted.lov $DIR/$tfile
11657 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
11658 local test_kdir=$DIR/$tdir
11659 test_mkdir $test_kdir
11660 local default_size=$($LFS getstripe -S $test_kdir)
11661 local default_count=$($LFS getstripe -c $test_kdir)
11662 local default_offset=$($LFS getstripe -i $test_kdir)
11663 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
11664 error 'dir setstripe failed'
11665 setfattr -n trusted.lov $test_kdir
11666 local stripe_size=$($LFS getstripe -S $test_kdir)
11667 local stripe_count=$($LFS getstripe -c $test_kdir)
11668 local stripe_offset=$($LFS getstripe -i $test_kdir)
11669 [ $stripe_size -eq $default_size ] ||
11670 error "stripe size $stripe_size != $default_size"
11671 [ $stripe_count -eq $default_count ] ||
11672 error "stripe count $stripe_count != $default_count"
11673 [ $stripe_offset -eq $default_offset ] ||
11674 error "stripe offset $stripe_offset != $default_offset"
11675 rm -rf $DIR/$tfile $test_kdir
11677 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
11680 [ -z "$(which getfattr 2>/dev/null)" ] &&
11681 skip "could not find getfattr"
11683 # LU-532 trusted. xattr is invisible to non-root
11684 local testfile=$DIR/$tfile
11688 echo "listxattr as user..."
11689 chown $RUNAS_ID $testfile
11690 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
11691 grep -q "trusted" &&
11692 error "$testfile trusted xattrs are user visible"
11696 run_test 102l "listxattr size test =================================="
11698 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
11699 local path=$DIR/$tfile
11702 listxattr_size_check $path || error "listattr_size_check $path failed"
11704 run_test 102m "Ensure listxattr fails on small bufffer ========"
11708 getxattr() { # getxattr path name
11709 # Return the base64 encoding of the value of xattr name on path.
11713 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
11715 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11717 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11719 getfattr --absolute-names --encoding=base64 --name=$name $path |
11720 awk -F= -v name=$name '$1 == name {
11721 print substr($0, index($0, "=") + 1);
11725 test_102n() { # LU-4101 mdt: protect internal xattrs
11726 [ -z "$(which setfattr 2>/dev/null)" ] &&
11727 skip "could not find setfattr"
11728 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
11730 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
11733 local file0=$DIR/$tfile.0
11734 local file1=$DIR/$tfile.1
11735 local xattr0=$TMP/$tfile.0
11736 local xattr1=$TMP/$tfile.1
11737 local namelist="lov lma lmv link fid version som hsm"
11741 rm -rf $file0 $file1 $xattr0 $xattr1
11742 touch $file0 $file1
11744 # Get 'before' xattrs of $file1.
11745 getfattr --absolute-names --dump --match=- $file1 > $xattr0
11747 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
11748 namelist+=" lfsck_namespace"
11749 for name in $namelist; do
11750 # Try to copy xattr from $file0 to $file1.
11751 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11753 setfattr --name=trusted.$name --value="$value" $file1 ||
11754 error "setxattr 'trusted.$name' failed"
11756 # Try to set a garbage xattr.
11757 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11759 if [[ x$name == "xlov" ]]; then
11760 setfattr --name=trusted.lov --value="$value" $file1 &&
11761 error "setxattr invalid 'trusted.lov' success"
11763 setfattr --name=trusted.$name --value="$value" $file1 ||
11764 error "setxattr invalid 'trusted.$name' failed"
11767 # Try to remove the xattr from $file1. We don't care if this
11768 # appears to succeed or fail, we just don't want there to be
11769 # any changes or crashes.
11770 setfattr --remove=$trusted.$name $file1 2> /dev/null
11773 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
11776 # Try to copy xattr from $file0 to $file1.
11777 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11779 setfattr --name=trusted.$name --value="$value" $file1 ||
11780 error "setxattr 'trusted.$name' failed"
11782 # Try to set a garbage xattr.
11783 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11785 setfattr --name=trusted.$name --value="$value" $file1 ||
11786 error "setxattr 'trusted.$name' failed"
11788 # Try to remove the xattr from $file1. We don't care if this
11789 # appears to succeed or fail, we just don't want there to be
11790 # any changes or crashes.
11791 setfattr --remove=$trusted.$name $file1 2> /dev/null
11794 # Get 'after' xattrs of file1.
11795 getfattr --absolute-names --dump --match=- $file1 > $xattr1
11797 if ! diff $xattr0 $xattr1; then
11798 error "before and after xattrs of '$file1' differ"
11801 rm -rf $file0 $file1 $xattr0 $xattr1
11805 run_test 102n "silently ignore setxattr on internal trusted xattrs"
11807 test_102p() { # LU-4703 setxattr did not check ownership
11808 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
11809 skip "MDS needs to be at least 2.5.56"
11811 local testfile=$DIR/$tfile
11815 echo "setfacl as user..."
11816 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
11817 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
11819 echo "setfattr as user..."
11820 setfacl -m "u:$RUNAS_ID:---" $testfile
11821 $RUNAS setfattr -x system.posix_acl_access $testfile
11822 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
11824 run_test 102p "check setxattr(2) correctly fails without permission"
11827 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
11828 skip "MDS needs to be at least 2.6.92"
11830 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
11832 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
11835 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
11836 skip "MDS needs to be at least 2.6.93"
11838 touch $DIR/$tfile || error "touch"
11839 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
11840 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
11841 rm $DIR/$tfile || error "rm"
11844 mkdir -p $DIR/$tdir || error "mkdir"
11845 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11846 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11847 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11848 error "$testfile error deleting user.author1"
11849 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11850 grep "user.$(basename $tdir)" &&
11851 error "$tdir did not delete user.$(basename $tdir)"
11852 rmdir $DIR/$tdir || error "rmdir"
11855 test_mkdir $DIR/$tdir
11856 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11857 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11858 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11859 error "$testfile error deleting user.author1"
11860 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11861 grep "user.$(basename $tdir)" &&
11862 error "$tdir did not delete user.$(basename $tdir)"
11863 rmdir $DIR/$tdir || error "rm striped dir"
11865 run_test 102r "set EAs with empty values"
11868 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11869 skip "MDS needs to be at least 2.11.52"
11871 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11873 save_lustre_params client "llite.*.xattr_cache" > $save
11875 for cache in 0 1; do
11876 lctl set_param llite.*.xattr_cache=$cache
11879 touch $DIR/$tfile || error "touch"
11880 for prefix in lustre security system trusted user; do
11881 # Note getxattr() may fail with 'Operation not
11882 # supported' or 'No such attribute' depending
11883 # on prefix and cache.
11884 getfattr -n $prefix.n102s $DIR/$tfile &&
11885 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
11889 restore_lustre_params < $save
11891 run_test 102s "getting nonexistent xattrs should fail"
11894 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11895 skip "MDS needs to be at least 2.11.52"
11897 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11899 save_lustre_params client "llite.*.xattr_cache" > $save
11901 for cache in 0 1; do
11902 lctl set_param llite.*.xattr_cache=$cache
11904 for buf_size in 0 256; do
11906 touch $DIR/$tfile || error "touch"
11907 setfattr -n user.multiop $DIR/$tfile
11908 $MULTIOP $DIR/$tfile oa$buf_size ||
11909 error "cannot get zero length xattr value (buf_size = $buf_size)"
11913 restore_lustre_params < $save
11915 run_test 102t "zero length xattr values handled correctly"
11919 local test=$LUSTRE/tests/acl/$1.test
11920 local tmp=$(mktemp -t $1-XXXXXX).test
11928 local sedusers="-e s/bin/$bin/g -e s/daemon/$dmn/g"
11929 local sedgroups="-e s/:users/:$grp/g"
11930 [[ -z "$nbd" ]] || sedusers+=" -e s/nobody/$nbd/g"
11932 sed $sedusers $sedgroups < $test > $tmp
11933 stack_trap "rm -f $tmp"
11934 [[ -s $tmp ]] || error "sed failed to create test script"
11936 echo "performing $1 with bin='$bin' daemon='$dmn' users='$grp'..."
11937 $LUSTRE/tests/acl/run $tmp || error "run_acl_subtest '$1' failed"
11941 [ "$UID" != 0 ] && skip "must run as root"
11942 $GSS && skip_env "could not run under gss"
11943 [[ "$(lctl get_param -n mdc.*-mdc-*.connect_flags)" =~ "acl" ]] ||
11944 skip_env "must have acl enabled"
11945 which setfacl || skip_env "could not find setfacl"
11946 remote_mds_nodsh && skip "remote MDS with nodsh"
11948 ACLBIN=${ACLBIN:-"bin"}
11949 ACLDMN=${ACLDMN:-"daemon"}
11950 ACLGRP=${ACLGRP:-"users"}
11951 ACLNBD=${ACLNBD:-"nobody"}
11954 [[ "$(id -u $ACLBIN)" != "$(do_facet mds1 id -u $ACLBIN)" ]]; then
11955 echo "bad 'bin' user '$ACLBIN', using '$USER0'"
11957 if ! id $ACLBIN ; then
11959 skip_env "can't find suitable ACL 'bin' $ACLBIN"
11962 if ! id $ACLDMN || (( $(id -u $ACLDMN) < $(id -u $ACLBIN) )) ||
11963 [[ "$(id -u $ACLDMN)" != "$(do_facet mds1 id -u $ACLDMN)" ]]; then
11964 echo "bad 'daemon' user '$ACLDMN', using '$USER1'"
11966 if ! id $ACLDMN ; then
11968 skip_env "can't find suitable ACL 'daemon' $ACLDMN"
11971 if ! getent group $ACLGRP; then
11972 echo "missing 'users' group '$ACLGRP', using '$TSTUSR'"
11974 if ! getent group $ACLGRP; then
11975 echo "cannot find group '$ACLGRP', adding it"
11977 add_group 60000 $ACLGRP
11981 local bingid=$(getent group $ACLBIN | cut -d: -f 3)
11982 local dmngid=$(getent group $ACLDMN | cut -d: -f 3)
11983 local grpgid=$(getent group $ACLGRP | cut -d: -f 3)
11985 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
11986 echo "group '$ACLGRP' has low gid=$grpgid, use '$TSTUSR'"
11988 if ! getent group $ACLGRP; then
11989 echo "cannot find group '$ACLGRP', adding it"
11991 add_group 60000 $ACLGRP
11993 grpgid=$(getent group $ACLGRP | cut -d: -f 3)
11994 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
11996 skip_env "$ACLGRP gid=$grpgid less than $bingid|$dmngid"
12000 gpasswd -a $ACLDMN $ACLBIN ||
12001 error "setting client group failed" # LU-5641
12002 do_facet mds1 gpasswd -a $ACLDMN $ACLBIN ||
12003 error "setting MDS group failed" # LU-5641
12005 declare -a identity_old
12007 for num in $(seq $MDSCOUNT); do
12008 switch_identity $num true || identity_old[$num]=$?
12011 SAVE_UMASK=$(umask)
12013 mkdir -p $DIR/$tdir
12016 run_acl_subtest cp $ACLBIN $ACLDMN $ACLGRP
12017 run_acl_subtest getfacl-noacl $ACLBIN $ACLDMN $ACLGRP
12018 run_acl_subtest misc $ACLBIN $ACLDMN $ACLGRP
12019 run_acl_subtest permissions $ACLBIN $ACLDMN $ACLGRP
12020 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
12021 # CentOS7- uses nobody=99, while newer distros use nobody=65534
12022 if ! id -u $ACLNBD ||
12023 (( $(id -u nobody) != $(do_facet mds1 id -u nobody) )); then
12025 if ! id -u $ACLNBD; then
12029 if [[ -n "$ACLNBD" ]] && ! getent group $ACLNBD; then
12030 add_group $(id -u $ACLNBD) $ACLNBD
12031 if ! getent group $ACLNBD; then
12035 if (( $MDS1_VERSION > $(version_code 2.8.55) )) &&
12036 [[ -n "$ACLNBD" ]] && which setfattr; then
12037 run_acl_subtest permissions_xattr \
12038 $ACLBIN $ACLDMN $ACLGRP $ACLNBD
12039 elif [[ -z "$ACLNBD" ]]; then
12040 echo "skip 'permission_xattr' test - missing 'nobody' user/grp"
12042 echo "skip 'permission_xattr' test - missing setfattr command"
12044 run_acl_subtest setfacl $ACLBIN $ACLDMN $ACLGRP
12046 # inheritance test got from HP
12047 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
12048 chmod +x make-tree || error "chmod +x failed"
12049 run_acl_subtest inheritance $ACLBIN $ACLDMN $ACLGRP
12052 echo "LU-974 ignore umask when acl is enabled..."
12053 run_acl_subtest 974 $ACLBIN $ACLDMN $ACLGRP
12054 if [ $MDSCOUNT -ge 2 ]; then
12055 run_acl_subtest 974_remote $ACLBIN $ACLDMN $ACLGRP
12058 echo "LU-2561 newly created file is same size as directory..."
12059 if [ "$mds1_FSTYPE" != "zfs" ]; then
12060 run_acl_subtest 2561 $ACLBIN $ACLDMN $ACLGRP
12062 run_acl_subtest 2561_zfs $ACLBIN $ACLDMN $ACLGRP
12065 run_acl_subtest 4924 $ACLBIN $ACLDMN $ACLGRP
12070 for num in $(seq $MDSCOUNT); do
12071 if [ "${identity_old[$num]}" = 1 ]; then
12072 switch_identity $num false || identity_old[$num]=$?
12076 run_test 103a "acl test"
12082 for U in {0..511}; do
12084 local O=$(printf "%04o" $U)
12086 umask $(printf "%04o" $((511 ^ $O)))
12087 $LFS setstripe -c 1 $DIR/$tfile.s$O
12088 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
12090 (( $S == ($O & 0666) )) ||
12091 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
12093 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
12094 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
12095 (( $S == ($O & 0666) )) ||
12096 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
12098 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
12099 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
12100 (( $S == ($O & 0666) )) ||
12101 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
12102 rm -f $DIR/$tfile.[smp]$0
12106 # limit the concurrently running threads to 64. LU-11878
12107 local idx=$((U % 64))
12108 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
12113 run_test 103b "umask lfs setstripe"
12116 mkdir -p $DIR/$tdir
12117 cp -rp $DIR/$tdir $DIR/$tdir.bak
12119 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
12120 error "$DIR/$tdir shouldn't contain default ACL"
12121 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
12122 error "$DIR/$tdir.bak shouldn't contain default ACL"
12125 run_test 103c "'cp -rp' won't set empty acl"
12130 local saved_debug=$($LCTL get_param -n debug)
12132 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
12133 skip "MDS needs to be at least 2.14.52"
12135 large_xattr_enabled || skip_env "ea_inode feature disabled"
12137 mkdir -p $DIR/$tdir
12138 # add big LOV EA to cause reply buffer overflow earlier
12139 $LFS setstripe -C 1000 $DIR/$tdir
12140 lctl set_param mdc.*-mdc*.stats=clear
12142 $LCTL set_param debug=0
12143 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
12144 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
12146 # add a large number of default ACLs (expect 8000+ for 2.13+)
12147 for U in {2..7000}; do
12148 setfacl -d -m user:$U:rwx $DIR/$tdir ||
12149 error "Able to add just $U default ACLs"
12151 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
12152 echo "$numacl default ACLs created"
12154 stat $DIR/$tdir || error "Cannot stat directory"
12155 # check file creation
12156 touch $DIR/$tdir/$tfile ||
12157 error "failed to create $tfile with $numacl default ACLs"
12158 stat $DIR/$tdir/$tfile || error "Cannot stat file"
12159 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12160 echo "$fileacl ACLs were inherited"
12161 (( $fileacl == $numacl )) ||
12162 error "Not all default ACLs were inherited: $numacl != $fileacl"
12163 # check that new ACLs creation adds new ACLs to inherited ACLs
12164 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
12165 error "Cannot set new ACL"
12166 numacl=$((numacl + 1))
12167 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12168 (( $fileacl == $numacl )) ||
12169 error "failed to add new ACL: $fileacl != $numacl as expected"
12170 # adds more ACLs to a file to reach their maximum at 8000+
12172 for U in {20000..25000}; do
12173 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
12174 numacl=$((numacl + 1))
12176 echo "Added $numacl more ACLs to the file"
12177 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12178 echo "Total $fileacl ACLs in file"
12179 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
12180 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
12181 rmdir $DIR/$tdir || error "Cannot remove directory"
12183 run_test 103e "inheritance of big amount of default ACLs"
12186 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
12187 skip "MDS needs to be at least 2.14.51"
12189 large_xattr_enabled || skip_env "ea_inode feature disabled"
12191 # enable changelog to consume more internal MDD buffers
12194 mkdir -p $DIR/$tdir
12196 $LFS setstripe -C 1000 $DIR/$tdir
12197 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
12198 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
12199 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
12200 rmdir $DIR/$tdir || error "Cannot remove directory"
12202 run_test 103f "changelog doesn't interfere with default ACLs buffers"
12205 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12208 lfs df || error "lfs df failed"
12209 lfs df -ih || error "lfs df -ih failed"
12210 lfs df -h $DIR || error "lfs df -h $DIR failed"
12211 lfs df -i $DIR || error "lfs df -i $DIR failed"
12212 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
12213 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
12215 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
12216 lctl --device %$OSC deactivate
12217 lfs df || error "lfs df with deactivated OSC failed"
12218 lctl --device %$OSC activate
12219 # wait the osc back to normal
12220 wait_osc_import_ready client ost
12222 lfs df || error "lfs df with reactivated OSC failed"
12225 run_test 104a "lfs df [-ih] [path] test ========================="
12228 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12229 [ $RUNAS_ID -eq $UID ] &&
12230 skip_env "RUNAS_ID = UID = $UID -- skipping"
12232 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
12233 grep "Permission denied" | wc -l)))
12234 if [ $denied_cnt -ne 0 ]; then
12235 error "lfs check servers test failed"
12238 run_test 104b "$RUNAS lfs check servers test ===================="
12241 # Verify $1 is within range of $2.
12242 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
12243 # $1 is <= 2% of $2. Else Fail.
12246 # Strip all units (M, G, T)
12247 actual=$(echo $1 | tr -d A-Z)
12248 expect=$(echo $2 | tr -d A-Z)
12250 expect_lo=$(($expect * 98 / 100)) # 2% below
12251 expect_hi=$(($expect * 102 / 100)) # 2% above
12253 # permit 2% drift above and below
12254 (( $actual >= $expect_lo && $actual <= $expect_hi ))
12258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12259 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
12261 local ost_param="osd-zfs.$FSNAME-OST0000."
12262 local mdt_param="osd-zfs.$FSNAME-MDT0000."
12263 local ofacets=$(get_facets OST)
12264 local mfacets=$(get_facets MDS)
12265 local saved_ost_blocks=
12266 local saved_mdt_blocks=
12268 echo "Before recordsize change"
12269 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
12270 df=($(df -h | grep "$MOUNT"$))
12273 echo "lfs output : ${lfs_df[*]}"
12274 echo "df output : ${df[*]}"
12276 for facet in ${ofacets//,/ }; do
12277 if [ -z $saved_ost_blocks ]; then
12278 saved_ost_blocks=$(do_facet $facet \
12279 lctl get_param -n $ost_param.blocksize)
12280 echo "OST Blocksize: $saved_ost_blocks"
12282 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12283 do_facet $facet zfs set recordsize=32768 $ost
12286 # BS too small. Sufficient for functional testing.
12287 for facet in ${mfacets//,/ }; do
12288 if [ -z $saved_mdt_blocks ]; then
12289 saved_mdt_blocks=$(do_facet $facet \
12290 lctl get_param -n $mdt_param.blocksize)
12291 echo "MDT Blocksize: $saved_mdt_blocks"
12293 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12294 do_facet $facet zfs set recordsize=32768 $mdt
12297 # Give new values chance to reflect change
12300 echo "After recordsize change"
12301 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
12302 df_after=($(df -h | grep "$MOUNT"$))
12305 echo "lfs output : ${lfs_df_after[*]}"
12306 echo "df output : ${df_after[*]}"
12309 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
12310 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
12311 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
12312 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
12313 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
12314 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
12317 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
12318 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
12319 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
12320 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
12321 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
12322 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
12324 # Restore MDT recordize back to original
12325 for facet in ${mfacets//,/ }; do
12326 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12327 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
12330 # Restore OST recordize back to original
12331 for facet in ${ofacets//,/ }; do
12332 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12333 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
12338 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
12341 (( $RUNAS_ID != $UID )) ||
12342 skip_env "RUNAS_ID = UID = $UID -- skipping"
12344 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
12345 skip "lustre version doesn't support lctl dl with non-root"
12347 # debugfs only allows root users to access files, so the
12348 # previous move of the "devices" file to debugfs broke
12349 # "lctl dl" for non-root users. The LU-9680 Netlink
12350 # interface again allows non-root users to list devices.
12351 [ "$($RUNAS $LCTL dl | wc -l)" -ge 3 ] ||
12352 error "lctl dl doesn't work for non root"
12354 ost_count="$($RUNAS $LCTL dl | grep $FSNAME-OST* | wc -l)"
12355 [ "$ost_count" -eq $OSTCOUNT ] ||
12356 error "lctl dl reports wrong number of OST devices"
12358 mdt_count="$($RUNAS $LCTL dl | grep $FSNAME-MDT* | wc -l)"
12359 [ "$mdt_count" -eq $MDSCOUNT ] ||
12360 error "lctl dl reports wrong number of MDT devices"
12362 run_test 104d "$RUNAS lctl dl test"
12365 # doesn't work on 2.4 kernels
12367 if $(flock_is_enabled); then
12368 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
12370 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
12374 run_test 105a "flock when mounted without -o flock test ========"
12378 if $(flock_is_enabled); then
12379 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
12381 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
12385 run_test 105b "fcntl when mounted without -o flock test ========"
12389 if $(flock_is_enabled); then
12390 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
12392 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
12396 run_test 105c "lockf when mounted without -o flock test"
12398 test_105d() { # bug 15924
12399 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12401 test_mkdir $DIR/$tdir
12402 flock_is_enabled || skip_env "mount w/o flock enabled"
12403 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
12404 $LCTL set_param fail_loc=0x80000315
12405 flocks_test 2 $DIR/$tdir
12407 run_test 105d "flock race (should not freeze) ========"
12409 test_105e() { # bug 22660 && 22040
12410 flock_is_enabled || skip_env "mount w/o flock enabled"
12413 flocks_test 3 $DIR/$tfile
12415 run_test 105e "Two conflicting flocks from same process"
12417 test_106() { #bug 10921
12418 test_mkdir $DIR/$tdir
12419 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
12420 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
12422 run_test 106 "attempt exec of dir followed by chown of that dir"
12425 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12433 local save_pattern=$(sysctl -n kernel.core_pattern)
12434 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
12435 sysctl -w kernel.core_pattern=$file
12436 sysctl -w kernel.core_uses_pid=0
12438 ulimit -c unlimited
12444 kill -s 11 $SLEEPPID
12446 if [ -e $file ]; then
12447 size=`stat -c%s $file`
12448 [ $size -eq 0 ] && error "Fail to create core file $file"
12450 error "Fail to create core file $file"
12453 sysctl -w kernel.core_pattern=$save_pattern
12454 sysctl -w kernel.core_uses_pid=$save_uses_pid
12457 run_test 107 "Coredump on SIG"
12460 test_mkdir $DIR/$tdir
12461 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
12462 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
12463 error "mkdir with 256 char should fail, but did not"
12464 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
12465 error "create with 255 char failed"
12466 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
12467 error "create with 256 char should fail, but did not"
12472 run_test 110 "filename length checking"
12474 test_116a() { # was previously test_116()
12475 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12476 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12477 remote_mds_nodsh && skip "remote MDS with nodsh"
12479 echo -n "Free space priority "
12480 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
12485 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
12486 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
12487 stack_trap simple_cleanup_common
12489 # Check if we need to generate uneven OSTs
12490 test_mkdir -p $DIR/$tdir/OST${MINI}
12491 local FILL=$((MINV / 4))
12492 local DIFF=$((MAXV - MINV))
12493 local DIFF2=$((DIFF * 100 / MINV))
12495 local threshold=$(do_facet $SINGLEMDS \
12496 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
12497 threshold=${threshold%%%}
12498 echo -n "Check for uneven OSTs: "
12499 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
12501 if [[ $DIFF2 -gt $threshold ]]; then
12503 echo "Don't need to fill OST$MINI"
12505 # generate uneven OSTs. Write 2% over the QOS threshold value
12507 DIFF=$((threshold - DIFF2 + 2))
12508 DIFF2=$((MINV * DIFF / 100))
12509 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
12510 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
12511 error "setstripe failed"
12512 DIFF=$((DIFF2 / 2048))
12514 while [ $i -lt $DIFF ]; do
12516 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
12517 bs=2M count=1 2>/dev/null
12526 DIFF=$((MAXV - MINV))
12527 DIFF2=$((DIFF * 100 / MINV))
12528 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
12529 if [ $DIFF2 -gt $threshold ]; then
12532 skip "QOS imbalance criteria not met"
12540 # now fill using QOS
12541 $LFS setstripe -c 1 $DIR/$tdir
12542 FILL=$((FILL / 200))
12543 if [ $FILL -gt 600 ]; then
12546 echo "writing $FILL files to QOS-assigned OSTs"
12548 while [ $i -lt $FILL ]; do
12550 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
12551 count=1 2>/dev/null
12554 echo "wrote $i 200k files"
12558 echo "Note: free space may not be updated, so measurements might be off"
12560 DIFF2=$((MAXV - MINV))
12561 echo "free space delta: orig $DIFF final $DIFF2"
12562 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
12563 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
12564 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
12565 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
12566 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
12567 if [[ $DIFF -gt 0 ]]; then
12568 FILL=$((DIFF2 * 100 / DIFF - 100))
12569 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
12572 # Figure out which files were written where
12573 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12574 awk '/'$MINI1': / {print $2; exit}')
12576 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12577 echo "$MINC files created on smaller OST $MINI1"
12578 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12579 awk '/'$MAXI1': / {print $2; exit}')
12581 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12582 echo "$MAXC files created on larger OST $MAXI1"
12583 if [[ $MINC -gt 0 ]]; then
12584 FILL=$((MAXC * 100 / MINC - 100))
12585 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
12587 [[ $MAXC -gt $MINC ]] ||
12588 error_ignore LU-9 "stripe QOS didn't balance free space"
12590 run_test 116a "stripe QOS: free space balance ==================="
12592 test_116b() { # LU-2093
12593 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12594 remote_mds_nodsh && skip "remote MDS with nodsh"
12596 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
12597 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
12598 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
12599 [ -z "$old_rr" ] && skip "no QOS"
12600 do_facet $SINGLEMDS lctl set_param \
12601 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
12602 mkdir -p $DIR/$tdir
12603 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
12604 createmany -o $DIR/$tdir/f- 20 || error "can't create"
12605 do_facet $SINGLEMDS lctl set_param fail_loc=0
12607 do_facet $SINGLEMDS lctl set_param \
12608 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
12610 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
12612 test_117() # bug 10891
12614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12616 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
12617 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
12618 lctl set_param fail_loc=0x21e
12619 > $DIR/$tfile || error "truncate failed"
12620 lctl set_param fail_loc=0
12621 echo "Truncate succeeded."
12624 run_test 117 "verify osd extend =========="
12626 NO_SLOW_RESENDCOUNT=4
12627 export OLD_RESENDCOUNT=""
12628 set_resend_count () {
12629 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
12630 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
12631 lctl set_param -n $PROC_RESENDCOUNT $1
12632 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
12635 # for reduce test_118* time (b=14842)
12636 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12638 # Reset async IO behavior after error case
12640 FILE=$DIR/reset_async
12642 # Ensure all OSCs are cleared
12643 $LFS setstripe -c -1 $FILE
12644 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
12649 test_118a() #bug 11710
12651 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12655 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12656 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12657 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12659 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12660 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12665 run_test 118a "verify O_SYNC works =========="
12669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12670 remote_ost_nodsh && skip "remote OST with nodsh"
12674 #define OBD_FAIL_SRV_ENOENT 0x217
12675 set_nodes_failloc "$(osts_nodes)" 0x217
12676 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12678 set_nodes_failloc "$(osts_nodes)" 0
12679 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12680 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12683 if [[ $RC -eq 0 ]]; then
12684 error "Must return error due to dropped pages, rc=$RC"
12688 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12689 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12693 echo "Dirty pages not leaked on ENOENT"
12695 # Due to the above error the OSC will issue all RPCs syncronously
12696 # until a subsequent RPC completes successfully without error.
12697 $MULTIOP $DIR/$tfile Ow4096yc
12702 run_test 118b "Reclaim dirty pages on fatal error =========="
12706 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12708 # for 118c, restore the original resend count, LU-1940
12709 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
12710 set_resend_count $OLD_RESENDCOUNT
12711 remote_ost_nodsh && skip "remote OST with nodsh"
12715 #define OBD_FAIL_OST_EROFS 0x216
12716 set_nodes_failloc "$(osts_nodes)" 0x216
12718 # multiop should block due to fsync until pages are written
12719 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12723 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12724 error "Multiop failed to block on fsync, pid=$MULTIPID"
12727 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12729 if [[ $WRITEBACK -eq 0 ]]; then
12730 error "No page in writeback, writeback=$WRITEBACK"
12733 set_nodes_failloc "$(osts_nodes)" 0
12736 if [[ $RC -ne 0 ]]; then
12737 error "Multiop fsync failed, rc=$RC"
12740 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12741 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12743 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12744 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12748 echo "Dirty pages flushed via fsync on EROFS"
12751 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
12753 # continue to use small resend count to reduce test_118* time (b=14842)
12754 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12758 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12759 remote_ost_nodsh && skip "remote OST with nodsh"
12763 #define OBD_FAIL_OST_BRW_PAUSE_BULK
12764 set_nodes_failloc "$(osts_nodes)" 0x214
12765 # multiop should block due to fsync until pages are written
12766 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12770 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12771 error "Multiop failed to block on fsync, pid=$MULTIPID"
12774 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12776 if [[ $WRITEBACK -eq 0 ]]; then
12777 error "No page in writeback, writeback=$WRITEBACK"
12780 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
12781 set_nodes_failloc "$(osts_nodes)" 0
12783 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12784 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12786 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12787 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12791 echo "Dirty pages gaurenteed flushed via fsync"
12794 run_test 118d "Fsync validation inject a delay of the bulk =========="
12797 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12801 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
12802 lctl set_param fail_loc=0x8000040a
12804 # Should simulate EINVAL error which is fatal
12805 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12807 if [[ $RC -eq 0 ]]; then
12808 error "Must return error due to dropped pages, rc=$RC"
12811 lctl set_param fail_loc=0x0
12813 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12814 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12815 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12817 if [[ $LOCKED -ne 0 ]]; then
12818 error "Locked pages remain in cache, locked=$LOCKED"
12821 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12822 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12826 echo "No pages locked after fsync"
12831 run_test 118f "Simulate unrecoverable OSC side error =========="
12834 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12838 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
12839 lctl set_param fail_loc=0x406
12841 # simulate local -ENOMEM
12842 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12845 lctl set_param fail_loc=0
12846 if [[ $RC -eq 0 ]]; then
12847 error "Must return error due to dropped pages, rc=$RC"
12850 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12851 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12852 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12854 if [[ $LOCKED -ne 0 ]]; then
12855 error "Locked pages remain in cache, locked=$LOCKED"
12858 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12859 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12863 echo "No pages locked after fsync"
12868 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
12871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12872 remote_ost_nodsh && skip "remote OST with nodsh"
12876 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12877 set_nodes_failloc "$(osts_nodes)" 0x20e
12878 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12879 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12882 set_nodes_failloc "$(osts_nodes)" 0
12883 if [[ $RC -eq 0 ]]; then
12884 error "Must return error due to dropped pages, rc=$RC"
12887 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12888 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12889 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12891 if [[ $LOCKED -ne 0 ]]; then
12892 error "Locked pages remain in cache, locked=$LOCKED"
12895 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12896 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12900 echo "No pages locked after fsync"
12904 run_test 118h "Verify timeout in handling recoverables errors =========="
12906 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12910 remote_ost_nodsh && skip "remote OST with nodsh"
12914 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12915 set_nodes_failloc "$(osts_nodes)" 0x20e
12917 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12918 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12921 set_nodes_failloc "$(osts_nodes)" 0
12925 if [[ $RC -ne 0 ]]; then
12926 error "got error, but should be not, rc=$RC"
12929 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12930 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12931 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12932 if [[ $LOCKED -ne 0 ]]; then
12933 error "Locked pages remain in cache, locked=$LOCKED"
12936 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12937 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12941 echo "No pages locked after fsync"
12945 run_test 118i "Fix error before timeout in recoverable error =========="
12947 [ "$SLOW" = "no" ] && set_resend_count 4
12950 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12951 remote_ost_nodsh && skip "remote OST with nodsh"
12955 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
12956 set_nodes_failloc "$(osts_nodes)" 0x220
12958 # return -EIO from OST
12959 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12961 set_nodes_failloc "$(osts_nodes)" 0x0
12962 if [[ $RC -eq 0 ]]; then
12963 error "Must return error due to dropped pages, rc=$RC"
12966 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12967 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12968 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12969 if [[ $LOCKED -ne 0 ]]; then
12970 error "Locked pages remain in cache, locked=$LOCKED"
12973 # in recoverable error on OST we want resend and stay until it finished
12974 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12975 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12979 echo "No pages locked after fsync"
12983 run_test 118j "Simulate unrecoverable OST side error =========="
12987 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12988 remote_ost_nodsh && skip "remote OSTs with nodsh"
12990 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12991 set_nodes_failloc "$(osts_nodes)" 0x20e
12992 test_mkdir $DIR/$tdir
12994 for ((i=0;i<10;i++)); do
12995 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
12996 error "dd to $DIR/$tdir/$tfile-$i failed" )&
13003 set_nodes_failloc "$(osts_nodes)" 0
13006 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
13008 test_118l() # LU-646
13010 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13012 test_mkdir $DIR/$tdir
13013 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
13016 run_test 118l "fsync dir"
13018 test_118m() # LU-3066
13020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13022 test_mkdir $DIR/$tdir
13023 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
13026 run_test 118m "fdatasync dir ========="
13028 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
13035 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13036 remote_ost_nodsh && skip "remote OSTs with nodsh"
13038 # Sleep to avoid a cached response.
13039 #define OBD_STATFS_CACHE_SECONDS 1
13042 # Inject a 10 second delay in the OST_STATFS handler.
13043 #define OBD_FAIL_OST_STATFS_DELAY 0x242
13044 set_nodes_failloc "$(osts_nodes)" 0x242
13047 stat --file-system $MOUNT > /dev/null
13050 set_nodes_failloc "$(osts_nodes)" 0
13052 if ((end - begin > 20)); then
13053 error "statfs took $((end - begin)) seconds, expected 10"
13056 run_test 118n "statfs() sends OST_STATFS requests in parallel"
13058 test_119a() # bug 11737
13060 BSIZE=$((512 * 1024))
13061 directio write $DIR/$tfile 0 1 $BSIZE
13062 # We ask to read two blocks, which is more than a file size.
13063 # directio will indicate an error when requested and actual
13064 # sizes aren't equeal (a normal situation in this case) and
13065 # print actual read amount.
13066 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
13067 if [ "$NOB" != "$BSIZE" ]; then
13068 error "read $NOB bytes instead of $BSIZE"
13072 run_test 119a "Short directIO read must return actual read amount"
13074 test_119b() # bug 11737
13076 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13078 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
13079 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
13081 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
13082 error "direct read failed"
13085 run_test 119b "Sparse directIO read must return actual read amount"
13087 test_119c() # bug 13099
13090 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
13091 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
13094 run_test 119c "Testing for direct read hitting hole"
13096 test_119d() # bug 15950
13098 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13100 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
13101 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
13103 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
13104 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
13105 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
13106 lctl set_param fail_loc=0x40d
13107 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
13110 cat $DIR/$tfile > /dev/null &
13111 lctl set_param fail_loc=0
13114 log "the DIO writes have completed, now wait for the reads (should not block very long)"
13116 [ -n "`ps h -p $pid_reads -o comm`" ] && \
13117 error "the read rpcs have not completed in 2s"
13119 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
13121 run_test 119d "The DIO path should try to send a new rpc once one is completed"
13124 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13125 remote_mds_nodsh && skip "remote MDS with nodsh"
13126 test_mkdir -i0 -c1 $DIR/$tdir
13127 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13128 skip_env "no early lock cancel on server"
13130 lru_resize_disable mdc
13131 lru_resize_disable osc
13132 cancel_lru_locks mdc
13133 # asynchronous object destroy at MDT could cause bl ast to client
13134 cancel_lru_locks osc
13136 stat $DIR/$tdir > /dev/null
13137 can1=$(do_facet mds1 \
13138 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13139 awk '/ldlm_cancel/ {print $2}')
13140 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13141 awk '/ldlm_bl_callback/ {print $2}')
13142 test_mkdir -i0 -c1 $DIR/$tdir/d1
13143 can2=$(do_facet mds1 \
13144 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13145 awk '/ldlm_cancel/ {print $2}')
13146 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13147 awk '/ldlm_bl_callback/ {print $2}')
13148 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13149 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13150 lru_resize_enable mdc
13151 lru_resize_enable osc
13153 run_test 120a "Early Lock Cancel: mkdir test"
13156 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13157 remote_mds_nodsh && skip "remote MDS with nodsh"
13158 test_mkdir $DIR/$tdir
13159 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13160 skip_env "no early lock cancel on server"
13162 lru_resize_disable mdc
13163 lru_resize_disable osc
13164 cancel_lru_locks mdc
13165 stat $DIR/$tdir > /dev/null
13166 can1=$(do_facet $SINGLEMDS \
13167 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13168 awk '/ldlm_cancel/ {print $2}')
13169 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13170 awk '/ldlm_bl_callback/ {print $2}')
13171 touch $DIR/$tdir/f1
13172 can2=$(do_facet $SINGLEMDS \
13173 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13174 awk '/ldlm_cancel/ {print $2}')
13175 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13176 awk '/ldlm_bl_callback/ {print $2}')
13177 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13178 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13179 lru_resize_enable mdc
13180 lru_resize_enable osc
13182 run_test 120b "Early Lock Cancel: create test"
13185 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13186 remote_mds_nodsh && skip "remote MDS with nodsh"
13187 test_mkdir -i0 -c1 $DIR/$tdir
13188 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13189 skip "no early lock cancel on server"
13191 lru_resize_disable mdc
13192 lru_resize_disable osc
13193 test_mkdir -i0 -c1 $DIR/$tdir/d1
13194 test_mkdir -i0 -c1 $DIR/$tdir/d2
13195 touch $DIR/$tdir/d1/f1
13196 cancel_lru_locks mdc
13197 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
13198 can1=$(do_facet mds1 \
13199 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13200 awk '/ldlm_cancel/ {print $2}')
13201 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13202 awk '/ldlm_bl_callback/ {print $2}')
13203 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13204 can2=$(do_facet mds1 \
13205 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13206 awk '/ldlm_cancel/ {print $2}')
13207 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13208 awk '/ldlm_bl_callback/ {print $2}')
13209 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13210 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13211 lru_resize_enable mdc
13212 lru_resize_enable osc
13214 run_test 120c "Early Lock Cancel: link test"
13217 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13218 remote_mds_nodsh && skip "remote MDS with nodsh"
13219 test_mkdir -i0 -c1 $DIR/$tdir
13220 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13221 skip_env "no early lock cancel on server"
13223 lru_resize_disable mdc
13224 lru_resize_disable osc
13226 cancel_lru_locks mdc
13227 stat $DIR/$tdir > /dev/null
13228 can1=$(do_facet mds1 \
13229 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13230 awk '/ldlm_cancel/ {print $2}')
13231 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13232 awk '/ldlm_bl_callback/ {print $2}')
13233 chmod a+x $DIR/$tdir
13234 can2=$(do_facet mds1 \
13235 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13236 awk '/ldlm_cancel/ {print $2}')
13237 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13238 awk '/ldlm_bl_callback/ {print $2}')
13239 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13240 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13241 lru_resize_enable mdc
13242 lru_resize_enable osc
13244 run_test 120d "Early Lock Cancel: setattr test"
13247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13248 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13249 skip_env "no early lock cancel on server"
13250 remote_mds_nodsh && skip "remote MDS with nodsh"
13252 local dlmtrace_set=false
13254 test_mkdir -i0 -c1 $DIR/$tdir
13255 lru_resize_disable mdc
13256 lru_resize_disable osc
13257 ! $LCTL get_param debug | grep -q dlmtrace &&
13258 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
13259 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
13260 cancel_lru_locks mdc
13261 cancel_lru_locks osc
13262 dd if=$DIR/$tdir/f1 of=/dev/null
13263 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
13264 # XXX client can not do early lock cancel of OST lock
13265 # during unlink (LU-4206), so cancel osc lock now.
13267 cancel_lru_locks osc
13268 can1=$(do_facet mds1 \
13269 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13270 awk '/ldlm_cancel/ {print $2}')
13271 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13272 awk '/ldlm_bl_callback/ {print $2}')
13273 unlink $DIR/$tdir/f1
13275 can2=$(do_facet mds1 \
13276 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13277 awk '/ldlm_cancel/ {print $2}')
13278 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13279 awk '/ldlm_bl_callback/ {print $2}')
13280 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
13281 $LCTL dk $TMP/cancel.debug.txt
13282 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
13283 $LCTL dk $TMP/blocking.debug.txt
13284 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
13285 lru_resize_enable mdc
13286 lru_resize_enable osc
13288 run_test 120e "Early Lock Cancel: unlink test"
13291 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13292 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13293 skip_env "no early lock cancel on server"
13294 remote_mds_nodsh && skip "remote MDS with nodsh"
13296 test_mkdir -i0 -c1 $DIR/$tdir
13297 lru_resize_disable mdc
13298 lru_resize_disable osc
13299 test_mkdir -i0 -c1 $DIR/$tdir/d1
13300 test_mkdir -i0 -c1 $DIR/$tdir/d2
13301 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
13302 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
13303 cancel_lru_locks mdc
13304 cancel_lru_locks osc
13305 dd if=$DIR/$tdir/d1/f1 of=/dev/null
13306 dd if=$DIR/$tdir/d2/f2 of=/dev/null
13307 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
13308 # XXX client can not do early lock cancel of OST lock
13309 # during rename (LU-4206), so cancel osc lock now.
13311 cancel_lru_locks osc
13312 can1=$(do_facet mds1 \
13313 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13314 awk '/ldlm_cancel/ {print $2}')
13315 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13316 awk '/ldlm_bl_callback/ {print $2}')
13317 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13319 can2=$(do_facet mds1 \
13320 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13321 awk '/ldlm_cancel/ {print $2}')
13322 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13323 awk '/ldlm_bl_callback/ {print $2}')
13324 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13325 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13326 lru_resize_enable mdc
13327 lru_resize_enable osc
13329 run_test 120f "Early Lock Cancel: rename test"
13332 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13333 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13334 skip_env "no early lock cancel on server"
13335 remote_mds_nodsh && skip "remote MDS with nodsh"
13337 lru_resize_disable mdc
13338 lru_resize_disable osc
13340 echo create $count files
13341 test_mkdir $DIR/$tdir
13342 cancel_lru_locks mdc
13343 cancel_lru_locks osc
13346 can0=$(do_facet $SINGLEMDS \
13347 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13348 awk '/ldlm_cancel/ {print $2}')
13349 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13350 awk '/ldlm_bl_callback/ {print $2}')
13351 createmany -o $DIR/$tdir/f $count
13353 can1=$(do_facet $SINGLEMDS \
13354 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13355 awk '/ldlm_cancel/ {print $2}')
13356 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13357 awk '/ldlm_bl_callback/ {print $2}')
13359 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
13360 echo rm $count files
13363 can2=$(do_facet $SINGLEMDS \
13364 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13365 awk '/ldlm_cancel/ {print $2}')
13366 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13367 awk '/ldlm_bl_callback/ {print $2}')
13369 echo total: $count removes in $((t2-t1))
13370 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
13372 # wait for commitment of removal
13373 lru_resize_enable mdc
13374 lru_resize_enable osc
13376 run_test 120g "Early Lock Cancel: performance test"
13378 test_121() { #bug #10589
13379 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13382 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
13383 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
13384 lctl set_param fail_loc=0x310
13385 cancel_lru_locks osc > /dev/null
13386 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
13387 lctl set_param fail_loc=0
13388 [[ $reads -eq $writes ]] ||
13389 error "read $reads blocks, must be $writes blocks"
13391 run_test 121 "read cancel race ========="
13393 test_123a_base() { # was test 123, statahead(bug 11401)
13397 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
13398 log "testing UP system. Performance may be lower than expected."
13401 running_in_vm && SLOWOK=1
13404 test_mkdir $DIR/$tdir
13405 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
13406 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
13408 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
13409 createmany -o $DIR/$tdir/$tfile $j $((i - j))
13411 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
13412 lctl set_param -n llite.*.statahead_max 0
13413 lctl get_param llite.*.statahead_max
13414 cancel_lru_locks mdc
13415 cancel_lru_locks osc
13417 time $lsx $DIR/$tdir | wc -l
13419 delta=$((etime - stime))
13420 log "$lsx $i files without statahead: $delta sec"
13421 lctl set_param llite.*.statahead_max=$max
13423 swrong=$(lctl get_param -n llite.*.statahead_stats |
13424 awk '/statahead.wrong:/ { print $NF }')
13425 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
13426 cancel_lru_locks mdc
13427 cancel_lru_locks osc
13429 time $lsx $DIR/$tdir | wc -l
13431 delta_sa=$((etime - stime))
13432 log "$lsx $i files with statahead: $delta_sa sec"
13433 lctl get_param -n llite.*.statahead_stats
13434 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13435 awk '/statahead.wrong:/ { print $NF }')
13437 [[ $swrong -lt $ewrong ]] &&
13438 log "statahead was stopped, maybe too many locks held!"
13439 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
13441 if (( $delta_sa*100 > $delta*105 && $delta_sa > $delta+2)); then
13442 max=$(lctl get_param -n llite.*.statahead_max |
13444 lctl set_param -n llite.*.statahead_max 0
13445 lctl get_param llite.*.statahead_max
13446 cancel_lru_locks mdc
13447 cancel_lru_locks osc
13449 time $lsx $DIR/$tdir | wc -l
13451 delta=$((etime - stime))
13452 log "$lsx $i files again without statahead: $delta sec"
13453 lctl set_param llite.*.statahead_max=$max
13454 if (( $delta_sa*100 > delta*105 && delta_sa > delta+2 )); then
13455 if [ $SLOWOK -eq 0 ]; then
13456 error "$lsx $i files is slower with statahead!"
13458 log "$lsx $i files is slower with statahead!"
13464 [ $delta -gt 20 ] && break
13465 [ $delta -gt 8 ] && MULT=$((50 / delta))
13466 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
13474 delta=$((etime - stime))
13475 log "rm -r $DIR/$tdir/: $delta seconds"
13477 lctl get_param -n llite.*.statahead_stats
13481 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13483 test_123a_base "ls -l"
13485 run_test 123aa "verify statahead work"
13488 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13490 statx_supported || skip_env "Test must be statx() syscall supported"
13492 test_123a_base "$STATX -l"
13494 run_test 123ab "verify statahead work by using statx"
13497 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13499 statx_supported || skip_env "Test must be statx() syscall supported"
13506 cancel_lru_locks $OSC
13507 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13508 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
13509 awk '/agl.total:/ { print $NF }')
13510 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
13511 test_123a_base "$STATX --cached=always -D"
13512 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
13513 awk '/agl.total:/ { print $NF }')
13514 [ $agl_before -eq $agl_after ] ||
13515 error "Should not trigger AGL thread - $agl_before:$agl_after"
13516 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13517 [ $rpcs_after -eq $rpcs_before ] ||
13518 error "$STATX should not send glimpse RPCs to $OSC"
13520 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
13522 test_123b () { # statahead(bug 15027)
13523 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13525 test_mkdir $DIR/$tdir
13526 createmany -o $DIR/$tdir/$tfile-%d 1000
13528 cancel_lru_locks mdc
13529 cancel_lru_locks osc
13531 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
13532 lctl set_param fail_loc=0x80000803
13533 ls -lR $DIR/$tdir > /dev/null
13535 lctl set_param fail_loc=0x0
13536 lctl get_param -n llite.*.statahead_stats
13541 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
13544 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
13546 test_mkdir -i 0 -c 1 $DIR/$tdir.0
13547 test_mkdir -i 1 -c 1 $DIR/$tdir.1
13548 touch $DIR/$tdir.1/{1..3}
13549 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
13551 remount_client $MOUNT
13553 $MULTIOP $DIR/$tdir.0 Q
13555 # let statahead to complete
13556 ls -l $DIR/$tdir.0 > /dev/null
13558 testid=$(echo $TESTNAME | tr '_' ' ')
13559 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
13560 error "statahead warning" || true
13562 run_test 123c "Can not initialize inode warning on DNE statahead"
13569 test_mkdir -c -1 $DIR/$tdir || error "test_mkdir $DIR/$tdir failed"
13570 $LFS setdirstripe -D -c $MDSCOUNT $DIR/$tdir ||
13571 error "setdirstripe $DIR/$tdir failed"
13572 createmany -d $DIR/$tdir/$tfile $num || error "createmany $num failed"
13573 remount_client $MOUNT
13574 $LCTL get_param llite.*.statahead_max
13575 $LCTL set_param llite.*.statahead_stats=0 ||
13576 error "clear statahead_stats failed"
13577 swrong=$(lctl get_param -n llite.*.statahead_stats |
13578 awk '/statahead.wrong:/ { print $NF }')
13579 ls -l $DIR/$tdir || error "ls -l $DIR/$tdir failed"
13580 # wait for statahead thread finished to update hit/miss stats.
13582 $LCTL get_param -n llite.*.statahead_stats
13583 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13584 awk '/statahead.wrong:/ { print $NF }')
13585 (( $swrong == $ewrong )) ||
13586 log "statahead was stopped, maybe too many locks held!"
13588 run_test 123d "Statahead on striped directories works correctly"
13591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13592 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13593 skip_env "no lru resize on server"
13597 test_mkdir $DIR/$tdir
13599 log "create $NR files at $DIR/$tdir"
13600 createmany -o $DIR/$tdir/f $NR ||
13601 error "failed to create $NR files in $DIR/$tdir"
13603 cancel_lru_locks mdc
13604 ls -l $DIR/$tdir > /dev/null
13608 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
13609 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
13610 LRU_SIZE=$($LCTL get_param -n $PARAM)
13611 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
13612 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
13614 log "NS=$(basename $NSDIR)"
13619 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
13620 skip "Not enough cached locks created!"
13622 log "LRU=$LRU_SIZE"
13626 # We know that lru resize allows one client to hold $LIMIT locks
13627 # for 10h. After that locks begin to be killed by client.
13629 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
13631 if [ $LIMIT -lt $LRU_SIZE ]; then
13632 skip "Limit is too small $LIMIT"
13635 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
13636 # killing locks. Some time was spent for creating locks. This means
13637 # that up to the moment of sleep finish we must have killed some of
13638 # them (10-100 locks). This depends on how fast ther were created.
13639 # Many of them were touched in almost the same moment and thus will
13640 # be killed in groups.
13641 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
13643 # Use $LRU_SIZE_B here to take into account real number of locks
13644 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
13645 local LRU_SIZE_B=$LRU_SIZE
13647 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
13648 log "OLD_LVF=$OLD_LVF"
13649 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
13651 # Let's make sure that we really have some margin. Client checks
13652 # cached locks every 10 sec.
13653 SLEEP=$((SLEEP+20))
13654 log "Sleep ${SLEEP} sec"
13656 while ((SEC<$SLEEP)); do
13660 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
13661 echo -n "$LRU_SIZE"
13664 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
13665 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
13667 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
13668 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
13669 unlinkmany $DIR/$tdir/f $NR
13673 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
13674 log "unlink $NR files at $DIR/$tdir"
13675 unlinkmany $DIR/$tdir/f $NR
13677 run_test 124a "lru resize ======================================="
13679 get_max_pool_limit()
13681 local limit=$($LCTL get_param \
13682 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
13684 for l in $limit; do
13685 if [[ $l -gt $max ]]; then
13693 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13694 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13695 skip_env "no lru resize on server"
13697 LIMIT=$(get_max_pool_limit)
13699 NR=$(($(default_lru_size)*20))
13700 if [[ $NR -gt $LIMIT ]]; then
13701 log "Limit lock number by $LIMIT locks"
13705 IFree=$(mdsrate_inodes_available)
13706 if [ $IFree -lt $NR ]; then
13707 log "Limit lock number by $IFree inodes"
13711 lru_resize_disable mdc
13712 test_mkdir -p $DIR/$tdir/disable_lru_resize
13714 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
13715 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
13716 cancel_lru_locks mdc
13719 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13722 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13725 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13729 nolruresize_delta=$((etime-stime))
13730 log "ls -la time: $nolruresize_delta seconds"
13731 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13732 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
13734 lru_resize_enable mdc
13735 test_mkdir -p $DIR/$tdir/enable_lru_resize
13737 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
13738 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
13739 cancel_lru_locks mdc
13742 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13745 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13748 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13752 lruresize_delta=$((etime-stime))
13753 log "ls -la time: $lruresize_delta seconds"
13754 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13756 if [ $lruresize_delta -gt $nolruresize_delta ]; then
13757 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
13758 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
13759 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
13761 log "lru resize performs the same with no lru resize"
13763 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
13765 run_test 124b "lru resize (performance test) ======================="
13768 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13769 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13770 skip_env "no lru resize on server"
13772 # cache ununsed locks on client
13774 cancel_lru_locks mdc
13775 test_mkdir $DIR/$tdir
13776 createmany -o $DIR/$tdir/f $nr ||
13777 error "failed to create $nr files in $DIR/$tdir"
13778 ls -l $DIR/$tdir > /dev/null
13780 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13781 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13782 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13783 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13784 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13786 # set lru_max_age to 1 sec
13787 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13788 echo "sleep $((recalc_p * 2)) seconds..."
13789 sleep $((recalc_p * 2))
13791 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13792 # restore lru_max_age
13793 $LCTL set_param -n $nsdir.lru_max_age $max_age
13794 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13795 unlinkmany $DIR/$tdir/f $nr
13797 run_test 124c "LRUR cancel very aged locks"
13800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13801 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13802 skip_env "no lru resize on server"
13804 # cache ununsed locks on client
13807 lru_resize_disable mdc
13808 stack_trap "lru_resize_enable mdc" EXIT
13810 cancel_lru_locks mdc
13812 # asynchronous object destroy at MDT could cause bl ast to client
13813 test_mkdir $DIR/$tdir
13814 createmany -o $DIR/$tdir/f $nr ||
13815 error "failed to create $nr files in $DIR/$tdir"
13816 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
13818 ls -l $DIR/$tdir > /dev/null
13820 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13821 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13822 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13823 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13825 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13827 # set lru_max_age to 1 sec
13828 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13829 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
13831 echo "sleep $((recalc_p * 2)) seconds..."
13832 sleep $((recalc_p * 2))
13834 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13836 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13838 run_test 124d "cancel very aged locks if lru-resize diasbaled"
13840 test_125() { # 13358
13841 $LCTL get_param -n llite.*.client_type | grep -q local ||
13842 skip "must run as local client"
13843 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
13844 skip_env "must have acl enabled"
13845 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13847 test_mkdir $DIR/$tdir
13848 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
13849 setfacl -R -m u:$USER0:rwx $DIR/$tdir ||
13850 error "setfacl $DIR/$tdir failed"
13851 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
13853 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
13855 test_126() { # bug 12829/13455
13856 $GSS && skip_env "must run as gss disabled"
13857 $LCTL get_param -n llite.*.client_type | grep -q local ||
13858 skip "must run as local client"
13859 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
13861 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
13862 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
13864 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
13866 run_test 126 "check that the fsgid provided by the client is taken into account"
13868 test_127a() { # bug 15521
13869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13870 local name count samp unit min max sum sumsq
13871 local tmpfile=$TMP/$tfile.tmp
13873 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
13874 echo "stats before reset"
13875 stack_trap "rm -f $tmpfile"
13876 local now=$(date +%s)
13878 $LCTL get_param osc.*.stats | tee $tmpfile
13880 local snapshot_time=$(awk '/snapshot_time/ { print $2; exit }' $tmpfile)
13881 local start_time=$(awk '/start_time/ { print $2; exit }' $tmpfile)
13882 local elapsed=$(awk '/elapsed_time/ { print $2; exit }' $tmpfile)
13883 local uptime=$(awk '{ print $1 }' /proc/uptime)
13885 # snapshot_time should match POSIX epoch time, allow some delta for VMs
13886 (( ${snapshot_time%\.*} >= $now - 5 &&
13887 ${snapshot_time%\.*} <= $now + 5 )) ||
13888 error "snapshot_time=$snapshot_time != now=$now"
13889 # elapsed _should_ be from mount, but at least less than uptime
13890 (( ${elapsed%\.*} < ${uptime%\.*} )) ||
13891 error "elapsed=$elapsed > uptime=$uptime"
13892 (( ${snapshot_time%\.*} - ${start_time%\.*} >= ${elapsed%\.*} - 2 &&
13893 ${snapshot_time%\.*} - ${start_time%\.*} <= ${elapsed%\.*} + 2 )) ||
13894 error "elapsed=$elapsed != $snapshot_time - $start_time"
13896 $LCTL set_param osc.*.stats=0
13897 local reset=$(date +%s)
13898 local fsize=$((2048 * 1024))
13900 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
13901 cancel_lru_locks osc
13902 dd if=$DIR/$tfile of=/dev/null bs=$fsize
13905 $LCTL get_param osc.*0000-osc-*.stats > $tmpfile
13906 while read name count samp unit min max sum sumsq; do
13907 [[ "$samp" == "samples" ]] || continue
13909 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13910 [ ! $min ] && error "Missing min value for $name proc entry"
13911 eval $name=$count || error "Wrong proc format"
13914 read_bytes|write_bytes)
13915 [[ "$unit" =~ "bytes" ]] ||
13916 error "unit is not 'bytes': $unit"
13917 (( $min >= 4096 )) || error "min is too small: $min"
13918 (( $min <= $fsize )) || error "min is too big: $min"
13919 (( $max >= 4096 )) || error "max is too small: $max"
13920 (( $max <= $fsize )) || error "max is too big: $max"
13921 (( $sum == $fsize )) || error "sum is wrong: $sum"
13922 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
13923 error "sumsquare is too small: $sumsq"
13924 (( $sumsq <= $fsize * $fsize )) ||
13925 error "sumsquare is too big: $sumsq"
13927 ost_read|ost_write)
13928 [[ "$unit" =~ "usec" ]] ||
13929 error "unit is not 'usec': $unit"
13935 #check that we actually got some stats
13936 [ "$read_bytes" ] || error "Missing read_bytes stats"
13937 [ "$write_bytes" ] || error "Missing write_bytes stats"
13938 [ "$read_bytes" != 0 ] || error "no read done"
13939 [ "$write_bytes" != 0 ] || error "no write done"
13941 snapshot_time=$(awk '/snapshot_time/ { print $2; exit }' $tmpfile)
13942 start_time=$(awk '/start_time/ { print $2; exit }' $tmpfile)
13943 elapsed=$(awk '/elapsed_time/ { print $2; exit }' $tmpfile)
13945 # snapshot_time should match POSIX epoch time, allow some delta for VMs
13946 (( ${snapshot_time%\.*} >= $now - 5 &&
13947 ${snapshot_time%\.*} <= $now + 5 )) ||
13948 error "reset snapshot_time=$snapshot_time != now=$now"
13949 # elapsed should be from time of stats reset
13950 (( ${elapsed%\.*} >= $now - $reset - 2 &&
13951 ${elapsed%\.*} <= $now - $reset + 2 )) ||
13952 error "reset elapsed=$elapsed > $now - $reset"
13953 (( ${snapshot_time%\.*} - ${start_time%\.*} >= ${elapsed%\.*} - 2 &&
13954 ${snapshot_time%\.*} - ${start_time%\.*} <= ${elapsed%\.*} + 2 )) ||
13955 error "reset elapsed=$elapsed != $snapshot_time - $start_time"
13957 run_test 127a "verify the client stats are sane"
13959 test_127b() { # bug LU-333
13960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13961 local name count samp unit min max sum sumsq
13963 echo "stats before reset"
13964 $LCTL get_param llite.*.stats
13965 $LCTL set_param llite.*.stats=0
13967 # perform 2 reads and writes so MAX is different from SUM.
13968 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13969 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13970 cancel_lru_locks osc
13971 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13972 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13974 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
13975 stack_trap "rm -f $TMP/$tfile.tmp"
13976 while read name count samp unit min max sum sumsq; do
13977 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13978 eval $name=$count || error "Wrong proc format"
13981 read_bytes|write_bytes)
13982 [[ "$unit" =~ "bytes" ]] ||
13983 error "unit is not 'bytes': $unit"
13984 (( $count == 2 )) || error "count is not 2: $count"
13985 (( $min == $PAGE_SIZE )) ||
13986 error "min is not $PAGE_SIZE: $min"
13987 (( $max == $PAGE_SIZE )) ||
13988 error "max is not $PAGE_SIZE: $max"
13989 (( $sum == $PAGE_SIZE * 2 )) ||
13990 error "sum is not $((PAGE_SIZE * 2)): $sum"
13993 [[ "$unit" =~ "usec" ]] ||
13994 error "unit is not 'usec': $unit"
13998 done < $TMP/$tfile.tmp
14000 #check that we actually got some stats
14001 [ "$read_bytes" ] || error "Missing read_bytes stats"
14002 [ "$write_bytes" ] || error "Missing write_bytes stats"
14003 [ "$read_bytes" != 0 ] || error "no read done"
14004 [ "$write_bytes" != 0 ] || error "no write done"
14006 run_test 127b "verify the llite client stats are sane"
14008 test_127c() { # LU-12394
14009 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
14016 $LCTL set_param llite.*.extents_stats=1
14017 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
14019 # Use two stripes so there is enough space in default config
14020 $LFS setstripe -c 2 $DIR/$tfile
14022 # Extent stats start at 0-4K and go in power of two buckets
14023 # LL_HIST_START = 12 --> 2^12 = 4K
14024 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
14025 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
14027 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
14029 # Write and read, 2x each, second time at a non-zero offset
14030 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
14031 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
14032 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
14033 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
14037 $LCTL get_param llite.*.extents_stats
14040 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
14042 local bucket=$($LCTL get_param -n llite.*.extents_stats |
14044 reads=$(echo $bucket | awk '{print $5}')
14045 writes=$(echo $bucket | awk '{print $9}')
14046 [ "$reads" -eq $count ] ||
14047 error "$reads reads in < $bsize bucket, expect $count"
14048 [ "$writes" -eq $count ] ||
14049 error "$writes writes in < $bsize bucket, expect $count"
14052 # Test mmap write and read
14053 $LCTL set_param llite.*.extents_stats=c
14055 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
14056 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
14057 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
14059 $LCTL get_param llite.*.extents_stats
14061 count=$(((size*1024) / PAGE_SIZE))
14063 bsize=$((2 * PAGE_SIZE / 1024))K
14065 bucket=$($LCTL get_param -n llite.*.extents_stats |
14067 reads=$(echo $bucket | awk '{print $5}')
14068 writes=$(echo $bucket | awk '{print $9}')
14069 # mmap writes fault in the page first, creating an additonal read
14070 [ "$reads" -eq $((2 * count)) ] ||
14071 error "$reads reads in < $bsize bucket, expect $count"
14072 [ "$writes" -eq $count ] ||
14073 error "$writes writes in < $bsize bucket, expect $count"
14075 run_test 127c "test llite extent stats with regular & mmap i/o"
14077 test_128() { # bug 15212
14079 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
14084 result=$(grep error $TMP/$tfile.log)
14085 rm -f $DIR/$tfile $TMP/$tfile.log
14086 [ -z "$result" ] ||
14087 error "consecutive find's under interactive lfs failed"
14089 run_test 128 "interactive lfs for 2 consecutive find's"
14091 set_dir_limits () {
14096 local ldproc=/proc/fs/ldiskfs
14097 local facets=$(get_facets MDS)
14099 for facet in ${facets//,/ }; do
14100 canondev=$(ldiskfs_canon \
14101 *.$(convert_facet2label $facet).mntdev $facet)
14102 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
14103 ldproc=/sys/fs/ldiskfs
14104 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
14105 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
14109 check_mds_dmesg() {
14110 local facets=$(get_facets MDS)
14111 for facet in ${facets//,/ }; do
14112 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
14118 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14119 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
14120 skip "Need MDS version with at least 2.5.56"
14121 if [ "$mds1_FSTYPE" != ldiskfs ]; then
14122 skip_env "ldiskfs only test"
14124 remote_mds_nodsh && skip "remote MDS with nodsh"
14127 local has_warning=false
14130 mkdir -p $DIR/$tdir
14132 # block size of mds1
14133 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
14134 set_dir_limits $maxsize $((maxsize * 6 / 8))
14135 stack_trap "set_dir_limits 0 0"
14136 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
14137 local dirsize=$(stat -c%s "$DIR/$tdir")
14139 while (( $dirsize <= $maxsize )); do
14140 $MCREATE $DIR/$tdir/file_base_$nfiles
14142 # check two errors:
14143 # ENOSPC for ext4 max_dir_size, which has been used since
14144 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
14145 if (( rc == ENOSPC )); then
14147 echo "rc=$rc returned as expected after $nfiles files"
14149 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
14150 error "create failed w/o dir size limit"
14152 # messages may be rate limited if test is run repeatedly
14153 check_mds_dmesg '"is approaching max"' ||
14154 echo "warning message should be output"
14155 check_mds_dmesg '"has reached max"' ||
14156 echo "reached message should be output"
14158 dirsize=$(stat -c%s "$DIR/$tdir")
14160 [[ $dirsize -ge $maxsize ]] && return 0
14161 error "dirsize $dirsize < $maxsize after $nfiles files"
14162 elif (( rc != 0 )); then
14165 nfiles=$((nfiles + 1))
14166 dirsize=$(stat -c%s "$DIR/$tdir")
14169 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
14171 run_test 129 "test directory size limit ========================"
14180 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
14181 [[ -z "$filefrag_op" ]] || skip_env "filefrag does not support FIEMAP"
14183 trap cleanup_130 EXIT RETURN
14185 local fm_file=$DIR/$tfile
14186 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
14187 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
14188 error "dd failed for $fm_file"
14190 # LU-1795: test filefrag/FIEMAP once, even if unsupported on ZFS
14191 filefrag -ves $fm_file
14193 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14194 skip "LU-1941: FIEMAP unimplemented on ZFS"
14195 (( $rc == 0 )) || error "filefrag $fm_file failed"
14197 filefrag_op=$(filefrag -ve -k $fm_file |
14198 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14199 local lun=$($LFS getstripe -i $fm_file)
14201 local start_blk=$(echo $filefrag_op | cut -d: -f2 | cut -d. -f1)
14204 for line in $filefrag_op; do
14205 local frag_lun=$(echo $line | cut -d: -f5)
14206 local ext_len=$(echo $line | cut -d: -f4)
14208 if (( $frag_lun != $lun )); then
14209 error "FIEMAP on 1-stripe file($fm_file) failed"
14212 (( tot_len += ext_len ))
14215 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
14216 error "FIEMAP on 1-stripe file($fm_file) failed"
14220 echo "FIEMAP on single striped file succeeded"
14222 run_test 130a "FIEMAP (1-stripe file)"
14225 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14227 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14228 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14229 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14230 skip "LU-1941: FIEMAP unimplemented on ZFS"
14232 trap cleanup_130 EXIT RETURN
14234 local fm_file=$DIR/$tfile
14235 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
14236 error "setstripe on $fm_file"
14238 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
14239 error "dd failed on $fm_file"
14241 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14242 filefrag_op=$(filefrag -ve -k $fm_file |
14243 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14245 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14246 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14252 for line in $filefrag_op; do
14253 local frag_lun=$(echo $line | cut -d: -f5 |
14254 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14255 local ext_len=$(echo $line | cut -d: -f4)
14256 if (( $frag_lun != $last_lun )); then
14257 if (( tot_len != 1024 )); then
14258 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14261 (( num_luns += 1 ))
14265 (( tot_len += ext_len ))
14268 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
14269 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14273 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
14275 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
14278 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14280 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14281 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14282 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14283 skip "LU-1941: FIEMAP unimplemented on ZFS"
14285 trap cleanup_130 EXIT RETURN
14287 local fm_file=$DIR/$tfile
14288 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
14290 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
14291 error "dd failed on $fm_file"
14293 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14294 filefrag_op=$(filefrag -ve -k $fm_file |
14295 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14297 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14298 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14303 for line in $filefrag_op; do
14304 local frag_lun=$(echo $line | cut -d: -f5 |
14305 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14306 local ext_len=$(echo $line | cut -d: -f4)
14307 if (( $frag_lun != $last_lun )); then
14308 local logical=$(echo $line | cut -d: -f2 | cut -d. -f1)
14309 if (( logical != 512 )); then
14310 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
14313 if (( tot_len != 512 )); then
14314 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14317 (( num_luns += 1 ))
14321 (( tot_len += ext_len ))
14324 if (( num_luns != 2 || tot_len != 512 )); then
14325 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14329 echo "FIEMAP on 2-stripe file with hole succeeded"
14331 run_test 130c "FIEMAP (2-stripe file with hole)"
14334 (( $OSTCOUNT >= 3 )) || skip "needs >= 3 OSTs"
14336 filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14337 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14338 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14339 skip "LU-1941: FIEMAP unimplemented on ZFS"
14341 trap cleanup_130 EXIT RETURN
14343 local fm_file=$DIR/$tfile
14344 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
14345 error "setstripe on $fm_file"
14347 local actual_stripe_count=$($LFS getstripe -c $fm_file)
14348 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
14349 error "dd failed on $fm_file"
14351 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14352 filefrag_op=$(filefrag -ve -k $fm_file |
14353 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14355 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14356 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14361 for line in $filefrag_op; do
14362 local frag_lun=$(echo $line | cut -d: -f5 |
14363 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14364 local ext_len=$(echo $line | cut -d: -f4)
14365 if (( $frag_lun != $last_lun )); then
14366 if (( tot_len != 1024 )); then
14367 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14370 (( num_luns += 1 ))
14374 (( tot_len += ext_len ))
14377 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
14378 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14382 echo "FIEMAP on N-stripe file succeeded"
14384 run_test 130d "FIEMAP (N-stripe file)"
14387 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14389 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14390 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14391 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14392 skip "LU-1941: FIEMAP unimplemented on ZFS"
14394 trap cleanup_130 EXIT RETURN
14396 local fm_file=$DIR/$tfile
14397 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
14400 local expected_len=$(( (num_blks / 2) * 64 ))
14401 for ((i = 0; i < $num_blks; i++)); do
14402 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
14403 conv=notrunc > /dev/null 2>&1
14406 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14407 filefrag_op=$(filefrag -ve -k $fm_file |
14408 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14410 local last_lun=$(echo $filefrag_op | cut -d: -f5)
14415 for line in $filefrag_op; do
14416 local frag_lun=$(echo $line | cut -d: -f5)
14417 local ext_len=$(echo $line | cut -d: -f4)
14418 if (( $frag_lun != $last_lun )); then
14419 if (( tot_len != $expected_len )); then
14420 error "OST$last_lun $tot_len != $expected_len"
14422 (( num_luns += 1 ))
14426 (( tot_len += ext_len ))
14429 if (( num_luns != 2 || tot_len != $expected_len )); then
14430 error "OST$last_lun $num_luns != 2, $tot_len != $expected_len"
14433 echo "FIEMAP with continuation calls succeeded"
14435 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
14438 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14439 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14440 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14441 skip "LU-1941: FIEMAP unimplemented on ZFS"
14443 local fm_file=$DIR/$tfile
14444 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
14445 error "multiop create with lov_delay_create on $fm_file"
14447 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14448 filefrag_extents=$(filefrag -vek $fm_file |
14449 awk '/extents? found/ { print $2 }')
14450 if (( $filefrag_extents != 0 )); then
14451 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
14456 run_test 130f "FIEMAP (unstriped file)"
14459 (( $MDS1_VERSION >= $(version_code 2.12.53) )) ||
14460 skip "Need MDS version with at least 2.12.53 for overstriping"
14461 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14462 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14463 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14464 skip "LU-1941: FIEMAP unimplemented on ZFS"
14466 local file=$DIR/$tfile
14467 local nr=$((OSTCOUNT * 100))
14469 $LFS setstripe -C $nr $file || error "failed to setstripe -C $nr $file"
14471 stack_trap "rm -f $file"
14472 dd if=/dev/zero of=$file count=$nr bs=1M
14474 nr=$($LFS getstripe -c $file)
14476 local extents=$(filefrag -v $file |
14477 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
14479 echo "filefrag list $extents extents in file with stripecount $nr"
14480 if (( extents < nr )); then
14481 $LFS getstripe $file
14483 error "filefrag printed $extents < $nr extents"
14486 run_test 130g "FIEMAP (overstripe file)"
14488 # Test for writev/readv
14490 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
14491 error "writev test failed"
14492 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
14493 error "readv failed"
14496 run_test 131a "test iov's crossing stripe boundary for writev/readv"
14499 local fsize=$((524288 + 1048576 + 1572864))
14500 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
14501 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14502 error "append writev test failed"
14504 ((fsize += 1572864 + 1048576))
14505 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
14506 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14507 error "append writev test failed"
14510 run_test 131b "test append writev"
14513 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
14516 run_test 131c "test read/write on file w/o objects"
14519 rwv -f $DIR/$tfile -w -n 1 1572864
14520 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
14521 if [ "$NOB" != 1572864 ]; then
14522 error "Short read filed: read $NOB bytes instead of 1572864"
14526 run_test 131d "test short read"
14529 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
14530 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
14531 error "read hitting hole failed"
14534 run_test 131e "test read hitting hole"
14542 # open 11 samples [usecs] 468 4793 13658 35791898
14544 mds*) res=($(do_facet $facet \
14545 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op"))
14547 ost*) res=($(do_facet $facet \
14548 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op"))
14550 *) error "Wrong facet '$facet'" ;;
14552 [[ -n "$res" ]] || error "counter for $op on $facet not incremented"
14553 # if $want is zero, it means any stat increment is ok.
14554 if (( $want > 0 )); then
14555 local count=${res[1]}
14557 if (( $count != $want )); then
14558 if [[ $facet =~ "mds" ]]; then
14559 do_nodes $(comma_list $(mdts_nodes)) \
14560 $LCTL get_param mdt.*.md_stats
14562 do_nodes $(comma_list $(osts-nodes)) \
14563 $LCTL get_param obdfilter.*.stats
14565 error "The $op counter on $facet is $count, not $want"
14571 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14572 remote_ost_nodsh && skip "remote OST with nodsh"
14573 remote_mds_nodsh && skip "remote MDS with nodsh"
14574 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14575 skip_env "MDS doesn't support rename stats"
14577 local testdir=$DIR/${tdir}/stats_testdir
14579 mkdir -p $DIR/${tdir}
14582 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14583 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14585 # verify mdt stats first.
14586 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
14587 check_stats $SINGLEMDS "mkdir" 1
14589 # clear "open" from "lfs mkdir" above
14590 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14591 touch ${testdir}/${tfile} || error "touch failed"
14592 check_stats $SINGLEMDS "open" 1
14593 check_stats $SINGLEMDS "close" 1
14594 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
14595 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
14596 check_stats $SINGLEMDS "mknod" 2
14598 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
14599 check_stats $SINGLEMDS "unlink" 1
14600 rm -f ${testdir}/${tfile} || error "file remove failed"
14601 check_stats $SINGLEMDS "unlink" 2
14603 # remove working dir and check mdt stats again.
14604 rmdir ${testdir} || error "rmdir failed"
14605 check_stats $SINGLEMDS "rmdir" 1
14607 local testdir1=$DIR/${tdir}/stats_testdir1
14608 mkdir_on_mdt0 -p ${testdir}
14609 mkdir_on_mdt0 -p ${testdir1}
14610 touch ${testdir1}/test1
14611 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
14612 check_stats $SINGLEMDS "crossdir_rename" 1
14614 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
14615 check_stats $SINGLEMDS "samedir_rename" 1
14617 rm -rf $DIR/${tdir}
14619 run_test 133a "Verifying MDT stats ========================================"
14624 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14625 remote_ost_nodsh && skip "remote OST with nodsh"
14626 remote_mds_nodsh && skip "remote MDS with nodsh"
14628 local testdir=$DIR/${tdir}/stats_testdir
14630 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
14631 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
14632 touch ${testdir}/${tfile} || error "touch failed"
14633 cancel_lru_locks mdc
14636 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14637 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14639 # extra mdt stats verification.
14640 chmod 444 ${testdir}/${tfile} || error "chmod failed"
14641 check_stats $SINGLEMDS "setattr" 1
14642 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14643 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
14645 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
14646 check_stats $SINGLEMDS "getattr" 1
14648 rm -rf $DIR/${tdir}
14650 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
14651 # so the check below is not reliable
14652 [ $MDSCOUNT -eq 1 ] || return 0
14654 # Sleep to avoid a cached response.
14655 #define OBD_STATFS_CACHE_SECONDS 1
14657 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14658 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14659 $LFS df || error "lfs failed"
14660 check_stats $SINGLEMDS "statfs" 1
14662 # check aggregated statfs (LU-10018)
14663 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
14665 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
14668 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14669 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14671 check_stats $SINGLEMDS "statfs" 1
14673 # We want to check that the client didn't send OST_STATFS to
14674 # ost1 but the MDT also uses OST_STATFS for precreate. So some
14675 # extra care is needed here.
14676 if remote_mds; then
14677 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
14678 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
14680 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
14681 [ "$res" ] && error "OST got STATFS"
14686 run_test 133b "Verifying extra MDT stats =================================="
14689 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14690 remote_ost_nodsh && skip "remote OST with nodsh"
14691 remote_mds_nodsh && skip "remote MDS with nodsh"
14693 local testdir=$DIR/$tdir/stats_testdir
14695 test_mkdir -p $testdir
14697 # verify obdfilter stats.
14698 $LFS setstripe -c 1 -i 0 $testdir/$tfile
14700 cancel_lru_locks osc
14701 wait_delete_completed
14704 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14705 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14707 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
14710 cancel_lru_locks osc
14711 check_stats ost1 "write" 1
14713 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
14714 check_stats ost1 "read" 1
14716 > $testdir/$tfile || error "truncate failed"
14717 check_stats ost1 "punch" 1
14719 rm -f $testdir/$tfile || error "file remove failed"
14720 wait_delete_completed
14721 check_stats ost1 "destroy" 1
14725 run_test 133c "Verifying OST stats ========================================"
14732 while [ $value -ge 2 ]; do
14737 if [ $orig -gt $order ]; then
14745 local size=('K' 'M' 'G' 'T');
14747 local size_string=$value
14749 while [ $value -ge 1024 ]; do
14750 if [ $i -gt 3 ]; then
14751 #T is the biggest unit we get here, if that is bigger,
14753 size_string=${value}T
14756 value=$((value >> 10))
14757 if [ $value -lt 1024 ]; then
14758 size_string=${value}${size[$i]}
14767 get_rename_size() {
14769 local context=${2:-.}
14770 local sample=$(do_facet $SINGLEMDS $LCTL \
14771 get_param mdt.$FSNAME-MDT0000.rename_stats |
14772 grep -A1 $context |
14773 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
14778 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14779 remote_ost_nodsh && skip "remote OST with nodsh"
14780 remote_mds_nodsh && skip "remote MDS with nodsh"
14781 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14782 skip_env "MDS doesn't support rename stats"
14784 local testdir1=$DIR/${tdir}/stats_testdir1
14785 local testdir2=$DIR/${tdir}/stats_testdir2
14786 mkdir -p $DIR/${tdir} || error "mkdir $tdir failed"
14788 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14790 mkdir_on_mdt0 ${testdir1} || error "mkdir $testdir1 failed"
14791 mkdir_on_mdt0 ${testdir2} || error "mkdir $testdir2 failed"
14793 createmany -o $testdir1/test 512 || error "createmany failed"
14795 # check samedir rename size
14796 mv ${testdir1}/test0 ${testdir1}/test_0
14798 local testdir1_size=$(ls -l $DIR/${tdir} |
14799 awk '/stats_testdir1/ {print $5}')
14800 local testdir2_size=$(ls -l $DIR/${tdir} |
14801 awk '/stats_testdir2/ {print $5}')
14803 testdir1_size=$(order_2 $testdir1_size)
14804 testdir2_size=$(order_2 $testdir2_size)
14806 testdir1_size=$(size_in_KMGT $testdir1_size)
14807 testdir2_size=$(size_in_KMGT $testdir2_size)
14809 echo "source rename dir size: ${testdir1_size}"
14810 echo "target rename dir size: ${testdir2_size}"
14812 local cmd="do_facet $SINGLEMDS $LCTL "
14813 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
14815 eval $cmd || error "$cmd failed"
14816 local samedir=$($cmd | grep 'same_dir')
14817 local same_sample=$(get_rename_size $testdir1_size)
14818 [ -z "$samedir" ] && error "samedir_rename_size count error"
14819 [[ $same_sample -eq 1 ]] ||
14820 error "samedir_rename_size error $same_sample"
14821 echo "Check same dir rename stats success"
14823 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14825 # check crossdir rename size
14826 mv ${testdir1}/test_0 ${testdir2}/test_0
14828 testdir1_size=$(ls -l $DIR/${tdir} |
14829 awk '/stats_testdir1/ {print $5}')
14830 testdir2_size=$(ls -l $DIR/${tdir} |
14831 awk '/stats_testdir2/ {print $5}')
14833 testdir1_size=$(order_2 $testdir1_size)
14834 testdir2_size=$(order_2 $testdir2_size)
14836 testdir1_size=$(size_in_KMGT $testdir1_size)
14837 testdir2_size=$(size_in_KMGT $testdir2_size)
14839 echo "source rename dir size: ${testdir1_size}"
14840 echo "target rename dir size: ${testdir2_size}"
14842 eval $cmd || error "$cmd failed"
14843 local crossdir=$($cmd | grep 'crossdir')
14844 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
14845 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
14846 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
14847 [[ $src_sample -eq 1 ]] ||
14848 error "crossdir_rename_size error $src_sample"
14849 [[ $tgt_sample -eq 1 ]] ||
14850 error "crossdir_rename_size error $tgt_sample"
14851 echo "Check cross dir rename stats success"
14852 rm -rf $DIR/${tdir}
14854 run_test 133d "Verifying rename_stats ========================================"
14857 remote_mds_nodsh && skip "remote MDS with nodsh"
14858 remote_ost_nodsh && skip "remote OST with nodsh"
14859 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14861 local testdir=$DIR/${tdir}/stats_testdir
14862 local ctr f0 f1 bs=32768 count=42 sum
14864 mkdir -p ${testdir} || error "mkdir failed"
14866 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
14868 for ctr in {write,read}_bytes; do
14870 cancel_lru_locks osc
14872 do_facet ost1 $LCTL set_param -n \
14873 "obdfilter.*.exports.clear=clear"
14875 if [ $ctr = write_bytes ]; then
14877 f1=${testdir}/${tfile}
14879 f0=${testdir}/${tfile}
14883 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
14886 cancel_lru_locks osc
14888 sum=$(do_facet ost1 $LCTL get_param \
14889 "obdfilter.*.exports.*.stats" |
14890 awk -v ctr=$ctr 'BEGIN { sum = 0 }
14891 $1 == ctr { sum += $7 }
14892 END { printf("%0.0f", sum) }')
14894 if ((sum != bs * count)); then
14895 error "Bad $ctr sum, expected $((bs * count)), got $sum"
14899 rm -rf $DIR/${tdir}
14901 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
14904 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
14905 skip "too old lustre for get_param -R ($facet_ver)"
14907 # verifying readability.
14908 $LCTL get_param -R '*' &> /dev/null
14910 # Verifing writability with badarea_io.
14911 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14912 local skipped_params='force_lbug|changelog_mask|daemon_file'
14913 $LCTL list_param -FR '*' | grep '=' | tr -d = |
14914 egrep -v "$skipped_params" |
14915 xargs -n 1 find $proc_dirs -name |
14916 xargs -n 1 badarea_io ||
14917 error "client badarea_io failed"
14919 # remount the FS in case writes/reads /proc break the FS
14920 cleanup || error "failed to unmount"
14921 setup || error "failed to setup"
14923 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
14926 remote_mds_nodsh && skip "remote MDS with nodsh"
14927 remote_ost_nodsh && skip "remote OST with nodsh"
14929 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14930 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
14932 for facet in mds1 ost1; do
14933 local facet_ver=$(lustre_version_code $facet)
14934 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
14935 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
14937 log "$facet: too old lustre for get_param -R"
14939 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
14940 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
14941 tr -d = | egrep -v $skipped_params |
14942 xargs -n 1 find $proc_dirs -name |
14943 xargs -n 1 badarea_io" ||
14944 error "$facet badarea_io failed"
14946 skip_noexit "$facet: too old lustre for get_param -R"
14950 # remount the FS in case writes/reads /proc break the FS
14951 cleanup || error "failed to unmount"
14952 setup || error "failed to setup"
14954 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
14957 remote_mds_nodsh && skip "remote MDS with nodsh"
14958 remote_ost_nodsh && skip "remote OST with nodsh"
14959 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
14960 skip "Need MDS version at least 2.9.54"
14963 for facet in client mds1 ost1; do
14964 # Get the list of files that are missing the terminating newline
14965 local plist=$(do_facet $facet
14966 $LCTL list_param -FR '*' | grep '=' | tr -d =)
14968 for ent in $plist; do
14969 local missing=$(do_facet $facet $LCTL get_param $ent \|\
14970 awk -v FS='\v' -v RS='\v\v' \
14971 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
14972 print FILENAME}'" 2>/dev/null)
14973 [ -z $missing ] || {
14974 do_facet $facet $LCTL get_param $ent | od -An -tx1
14975 error "file does not end with newline: $facet-$ent"
14980 run_test 133h "Proc files should end with newlines"
14983 remote_mds_nodsh && skip "remote MDS with nodsh"
14984 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14985 skip "Need MDS version at least 2.7.54"
14987 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14988 cancel_lru_locks mdc
14990 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14991 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14992 [ $unused -eq 0 ] || error "$unused locks are not cleared"
14995 createmany -o $DIR/$tdir/f $nr ||
14996 error "failed to create $nr files in $DIR/$tdir"
14997 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14999 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
15000 do_facet mds1 $LCTL set_param fail_loc=0x327
15001 do_facet mds1 $LCTL set_param fail_val=500
15004 echo "sleep 10 seconds ..."
15006 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
15008 do_facet mds1 $LCTL set_param fail_loc=0
15009 do_facet mds1 $LCTL set_param fail_val=0
15010 [ $lck_cnt -lt $unused ] ||
15011 error "No locks reclaimed, before:$unused, after:$lck_cnt"
15014 unlinkmany $DIR/$tdir/f $nr
15016 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
15019 remote_mds_nodsh && skip "remote MDS with nodsh"
15020 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
15021 skip "Need MDS version at least 2.7.54"
15023 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
15024 cancel_lru_locks mdc
15026 local low_wm=$(do_facet mds1 $LCTL get_param -n \
15027 ldlm.lock_reclaim_threshold_mb)
15028 # disable reclaim temporarily
15029 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
15031 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
15032 do_facet mds1 $LCTL set_param fail_loc=0x328
15033 do_facet mds1 $LCTL set_param fail_val=500
15035 $LCTL set_param debug=+trace
15038 createmany -o $DIR/$tdir/f $nr &
15039 local create_pid=$!
15041 echo "Sleep $TIMEOUT seconds ..."
15043 if ! ps -p $create_pid > /dev/null 2>&1; then
15044 do_facet mds1 $LCTL set_param fail_loc=0
15045 do_facet mds1 $LCTL set_param fail_val=0
15046 do_facet mds1 $LCTL set_param \
15047 ldlm.lock_reclaim_threshold_mb=${low_wm}m
15048 error "createmany finished incorrectly!"
15050 do_facet mds1 $LCTL set_param fail_loc=0
15051 do_facet mds1 $LCTL set_param fail_val=0
15052 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
15053 wait $create_pid || return 1
15055 unlinkmany $DIR/$tdir/f $nr
15057 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
15060 remote_mds_nodsh && skip "remote MDS with nodsh"
15061 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
15062 skip "Need MDS version at least 2.13.50"
15065 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
15067 #define OBD_FAIL_PLAIN_RECORDS 0x1319
15068 #set only one record at plain llog
15069 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
15071 #fill already existed plain llog each 64767
15072 #wrapping whole catalog
15073 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
15075 createmany -o $DIR/$tdir/$tfile_ 64700
15076 for (( i = 0; i < 64700; i = i + 2 ))
15078 rm $DIR/$tdir/$tfile_$i &
15079 rm $DIR/$tdir/$tfile_$((i + 1)) &
15084 #waiting osp synchronization
15085 wait_delete_completed
15087 run_test 135 "Race catalog processing"
15090 remote_mds_nodsh && skip "remote MDS with nodsh"
15091 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
15092 skip "Need MDS version at least 2.13.50"
15095 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
15096 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
15097 #set only one record at plain llog
15098 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
15099 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
15101 #fill already existed 2 plain llogs each 64767
15102 #wrapping whole catalog
15103 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
15104 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
15105 wait_delete_completed
15107 createmany -o $DIR/$tdir/$tfile_ 10
15110 do_facet $SINGLEMDS $LCTL set_param fail_val=3
15111 for (( i = 0; i < 10; i = i + 3 ))
15113 rm $DIR/$tdir/$tfile_$i &
15114 rm $DIR/$tdir/$tfile_$((i + 1)) &
15118 rm $DIR/$tdir/$tfile_$((i + 2)) &
15121 #waiting osp synchronization
15122 wait_delete_completed
15124 run_test 136 "Race catalog processing 2"
15126 test_140() { #bug-17379
15127 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15129 test_mkdir $DIR/$tdir
15130 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
15131 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
15133 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
15134 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
15136 while i=$((i + 1)); do
15138 cd $i || error "Changing to $i"
15139 ln -s ../stat stat || error "Creating stat symlink"
15140 # Read the symlink until ELOOP present,
15141 # not LBUGing the system is considered success,
15142 # we didn't overrun the stack.
15143 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
15144 if [ $ret -ne 0 ]; then
15145 if [ $ret -eq 40 ]; then
15148 error "Open stat symlink"
15154 echo "The symlink depth = $i"
15155 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
15156 error "Invalid symlink depth"
15158 # Test recursive symlink
15159 ln -s symlink_self symlink_self
15160 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
15161 echo "open symlink_self returns $ret"
15162 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
15164 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
15167 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15169 local TF="$TMP/$tfile"
15171 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15172 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
15174 cancel_lru_locks $OSC
15175 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
15176 remount_client $MOUNT
15178 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
15181 $TRUNCATE $DIR/$tfile 6000
15182 cancel_lru_locks $OSC
15183 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
15186 echo "12345" >>$DIR/$tfile
15187 cancel_lru_locks $OSC
15188 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
15191 echo "12345" >>$DIR/$tfile
15192 cancel_lru_locks $OSC
15193 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
15195 run_test 150a "truncate/append tests"
15198 check_set_fallocate_or_skip
15202 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15203 out=$(check_fallocate $DIR/$tfile 2>&1) ||
15204 skip_eopnotsupp "$out|check_fallocate failed"
15206 run_test 150b "Verify fallocate (prealloc) functionality"
15209 check_set_fallocate_or_skip
15212 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15213 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
15215 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
15216 # precomputed md5sum for 20MB of zeroes
15217 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
15218 local sum=($(md5sum $DIR/$tfile))
15220 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
15222 check_set_fallocate 1
15225 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
15226 sum=($(md5sum $DIR/$tfile))
15228 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
15230 run_test 150bb "Verify fallocate modes both zero space"
15233 check_set_fallocate_or_skip
15234 local striping="-c2"
15236 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15237 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
15238 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
15239 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
15240 local want=$((OSTCOUNT * 1048576))
15242 # Must allocate all requested space, not more than 5% extra
15243 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15244 error "bytes $bytes is not $want"
15248 echo "verify fallocate on PFL file"
15250 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
15252 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
15253 error "Create $DIR/$tfile failed"
15254 fallocate -l $((1048576 * 512)) $DIR/$tfile || error "fallocate failed"
15255 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
15256 want=$((512 * 1048576))
15258 # Must allocate all requested space, not more than 5% extra
15259 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15260 error "bytes $bytes is not $want"
15262 run_test 150c "Verify fallocate Size and Blocks"
15265 check_set_fallocate_or_skip
15266 local striping="-c2"
15268 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
15270 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15271 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
15272 error "setstripe failed"
15273 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
15274 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
15275 local want=$((OSTCOUNT * 1048576))
15277 # Must allocate all requested space, not more than 5% extra
15278 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15279 error "bytes $bytes is not $want"
15281 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
15284 check_set_fallocate_or_skip
15288 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15289 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15290 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15292 # Find OST with Minimum Size
15293 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15294 sort -un | head -1)
15296 # Get 100MB per OST of the available space to reduce run time
15297 # else 60% of the available space if we are running SLOW tests
15298 if [ $SLOW == "no" ]; then
15299 local space=$((1024 * 100 * OSTCOUNT))
15301 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
15304 fallocate -l${space}k $DIR/$tfile ||
15305 error "fallocate ${space}k $DIR/$tfile failed"
15306 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
15308 # get size immediately after fallocate. This should be correctly
15310 local size=$(stat -c '%s' $DIR/$tfile)
15311 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
15313 # Sleep for a while for statfs to get updated. And not pull from cache.
15316 echo "df after fallocate:"
15319 (( size / 1024 == space )) || error "size $size != requested $space"
15320 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
15321 error "used $used < space $space"
15323 rm $DIR/$tfile || error "rm failed"
15325 wait_delete_completed
15327 echo "df after unlink:"
15330 run_test 150e "Verify 60% of available OST space consumed by fallocate"
15335 local want_size_before=20480 # in bytes
15336 local want_blocks_before=40 # 512 sized blocks
15337 local want_blocks_after=24 # 512 sized blocks
15338 local length=$(((want_blocks_before - want_blocks_after) * 512))
15340 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
15341 skip "need at least 2.14.0 for fallocate punch"
15343 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
15344 skip "LU-14160: punch mode is not implemented on OSD ZFS"
15347 check_set_fallocate_or_skip
15348 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15350 [[ "x$DOM" == "xyes" ]] &&
15351 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
15353 echo "Verify fallocate punch: Range within the file range"
15354 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
15355 error "dd failed for bs 4096 and count 5"
15357 # Call fallocate with punch range which is within the file range
15358 out=$(fallocate -p --offset 4096 -l $length $DIR/$tfile 2>&1) ||
15359 skip_eopnotsupp "$out|fallocate: offset 4096 and length $length"
15360 # client must see changes immediately after fallocate
15361 size=$(stat -c '%s' $DIR/$tfile)
15362 blocks=$(stat -c '%b' $DIR/$tfile)
15364 # Verify punch worked.
15365 (( blocks == want_blocks_after )) ||
15366 error "punch failed: blocks $blocks != $want_blocks_after"
15368 (( size == want_size_before )) ||
15369 error "punch failed: size $size != $want_size_before"
15371 # Verify there is hole in file
15372 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
15373 # precomputed md5sum
15374 local expect="4a9a834a2db02452929c0a348273b4aa"
15376 cksum=($(md5sum $DIR/$tfile))
15377 [[ "${cksum[0]}" == "$expect" ]] ||
15378 error "unexpected MD5SUM after punch: ${cksum[0]}"
15380 # Start second sub-case for fallocate punch.
15381 echo "Verify fallocate punch: Range overlapping and less than blocksize"
15382 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
15383 error "dd failed for bs 4096 and count 5"
15385 # Punch range less than block size will have no change in block count
15386 want_blocks_after=40 # 512 sized blocks
15388 # Punch overlaps two blocks and less than blocksize
15389 out=$(fallocate -p --offset 4000 -l 3000 $DIR/$tfile 2>&1) ||
15390 skip_eopnotsupp "$out|fallocate: offset 4000 length 3000"
15391 size=$(stat -c '%s' $DIR/$tfile)
15392 blocks=$(stat -c '%b' $DIR/$tfile)
15394 # Verify punch worked.
15395 (( blocks == want_blocks_after )) ||
15396 error "punch failed: blocks $blocks != $want_blocks_after"
15398 (( size == want_size_before )) ||
15399 error "punch failed: size $size != $want_size_before"
15401 # Verify if range is really zero'ed out. We expect Zeros.
15402 # precomputed md5sum
15403 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
15404 cksum=($(md5sum $DIR/$tfile))
15405 [[ "${cksum[0]}" == "$expect" ]] ||
15406 error "unexpected MD5SUM after punch: ${cksum[0]}"
15408 run_test 150f "Verify fallocate punch functionality"
15416 local BS=4096 # Block size in bytes
15418 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
15419 skip "need at least 2.14.0 for fallocate punch"
15421 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
15422 skip "LU-14160: punch mode is not implemented on OSD ZFS"
15425 check_set_fallocate_or_skip
15426 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15428 if [[ "x$DOM" == "xyes" ]]; then
15429 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
15430 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
15432 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15433 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15436 # Get 100MB per OST of the available space to reduce run time
15437 # else 60% of the available space if we are running SLOW tests
15438 if [ $SLOW == "no" ]; then
15439 space=$((1024 * 100 * OSTCOUNT))
15441 # Find OST with Minimum Size
15442 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15443 sort -un | head -1)
15444 echo "min size OST: $space"
15445 space=$(((space * 60)/100 * OSTCOUNT))
15447 # space in 1k units, round to 4k blocks
15448 local blkcount=$((space * 1024 / $BS))
15450 echo "Verify fallocate punch: Very large Range"
15451 fallocate -l${space}k $DIR/$tfile ||
15452 error "fallocate ${space}k $DIR/$tfile failed"
15453 # write 1M at the end, start and in the middle
15454 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
15455 error "dd failed: bs $BS count 256"
15456 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
15457 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
15458 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
15459 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
15462 size=$(stat -c '%s' $DIR/$tfile)
15464 # gather punch length.
15465 local punch_size=$((size - (BS * 2)))
15467 echo "punch_size = $punch_size"
15468 echo "size - punch_size: $((size - punch_size))"
15469 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
15471 # Call fallocate to punch all except 2 blocks. We leave the
15472 # first and the last block
15473 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
15474 out=$(fallocate -p --offset $BS -l $punch_size $DIR/$tfile 2>&1) ||
15475 skip_eopnotsupp "$out|fallocate: offset $BS length $punch_size"
15477 size_after=$(stat -c '%s' $DIR/$tfile)
15478 blocks_after=$(stat -c '%b' $DIR/$tfile)
15480 # Verify punch worked.
15481 # Size should be kept
15482 (( size == size_after )) ||
15483 error "punch failed: size $size != $size_after"
15485 # two 4k data blocks to remain plus possible 1 extra extent block
15486 (( blocks_after <= ((BS / 512) * 3) )) ||
15487 error "too many blocks remains: $blocks_after"
15489 # Verify that file has hole between the first and the last blocks
15490 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
15491 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
15493 echo "Hole at [$hole_start, $hole_end)"
15494 (( hole_start == BS )) ||
15495 error "no hole at offset $BS after punch"
15497 (( hole_end == BS + punch_size )) ||
15498 error "data at offset $hole_end < $((BS + punch_size))"
15500 run_test 150g "Verify fallocate punch on large range"
15503 local file=$DIR/$tfile
15506 check_set_fallocate_or_skip
15507 statx_supported || skip_env "Test must be statx() syscall supported"
15509 # fallocate() does not update the size information on the MDT
15510 fallocate -l 16K $file || error "failed to fallocate $file"
15511 cancel_lru_locks $OSC
15512 # STATX with cached-always mode will not send glimpse RPCs to OST,
15513 # it uses the caching attrs on the client side as much as possible.
15514 size=$($STATX --cached=always -c %s $file)
15515 [ $size == 16384 ] ||
15516 error "size after fallocate() is $size, expected 16384"
15518 run_test 150h "Verify extend fallocate updates the file size"
15520 #LU-2902 roc_hit was not able to read all values from lproc
15521 function roc_hit_init() {
15522 local list=$(comma_list $(osts_nodes))
15523 local dir=$DIR/$tdir-check
15524 local file=$dir/$tfile
15530 #use setstripe to do a write to every ost
15531 for i in $(seq 0 $((OSTCOUNT-1))); do
15532 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
15533 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
15534 idx=$(printf %04x $i)
15535 BEFORE=$(get_osd_param $list *OST*$idx stats |
15536 awk '$1 == "cache_access" {sum += $7}
15537 END { printf("%0.0f", sum) }')
15539 cancel_lru_locks osc
15540 cat $file >/dev/null
15542 AFTER=$(get_osd_param $list *OST*$idx stats |
15543 awk '$1 == "cache_access" {sum += $7}
15544 END { printf("%0.0f", sum) }')
15546 echo BEFORE:$BEFORE AFTER:$AFTER
15547 if ! let "AFTER - BEFORE == 4"; then
15549 error "roc_hit is not safe to use"
15557 function roc_hit() {
15558 local list=$(comma_list $(osts_nodes))
15559 echo $(get_osd_param $list '' stats |
15560 awk '$1 == "cache_hit" {sum += $7}
15561 END { printf("%0.0f", sum) }')
15564 function set_cache() {
15567 if [ "$2" == "off" ]; then
15570 local list=$(comma_list $(osts_nodes))
15571 set_osd_param $list '' $1_cache_enable $on
15573 cancel_lru_locks osc
15577 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15578 remote_ost_nodsh && skip "remote OST with nodsh"
15581 local list=$(comma_list $(osts_nodes))
15583 # check whether obdfilter is cache capable at all
15584 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
15585 skip "not cache-capable obdfilter"
15588 # check cache is enabled on all obdfilters
15589 if get_osd_param $list '' read_cache_enable | grep 0; then
15590 skip "oss cache is disabled"
15593 set_osd_param $list '' writethrough_cache_enable 1
15595 # check write cache is enabled on all obdfilters
15596 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
15597 skip "oss write cache is NOT enabled"
15602 #define OBD_FAIL_OBD_NO_LRU 0x609
15603 do_nodes $list $LCTL set_param fail_loc=0x609
15605 # pages should be in the case right after write
15606 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
15609 local BEFORE=$(roc_hit)
15610 cancel_lru_locks osc
15611 cat $DIR/$tfile >/dev/null
15612 local AFTER=$(roc_hit)
15614 do_nodes $list $LCTL set_param fail_loc=0
15616 if ! let "AFTER - BEFORE == CPAGES"; then
15617 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
15620 cancel_lru_locks osc
15621 # invalidates OST cache
15622 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
15623 set_osd_param $list '' read_cache_enable 0
15624 cat $DIR/$tfile >/dev/null
15626 # now data shouldn't be found in the cache
15628 cancel_lru_locks osc
15629 cat $DIR/$tfile >/dev/null
15631 if let "AFTER - BEFORE != 0"; then
15632 error "IN CACHE: before: $BEFORE, after: $AFTER"
15635 set_osd_param $list '' read_cache_enable 1
15638 run_test 151 "test cache on oss and controls ==============================="
15641 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15643 local TF="$TMP/$tfile"
15645 # simulate ENOMEM during write
15646 #define OBD_FAIL_OST_NOMEM 0x226
15647 lctl set_param fail_loc=0x80000226
15648 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
15650 sync || error "sync failed"
15651 lctl set_param fail_loc=0
15653 # discard client's cache
15654 cancel_lru_locks osc
15656 # simulate ENOMEM during read
15657 lctl set_param fail_loc=0x80000226
15658 cmp $TF $DIR/$tfile || error "cmp failed"
15659 lctl set_param fail_loc=0
15663 run_test 152 "test read/write with enomem ============================"
15666 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
15668 run_test 153 "test if fdatasync does not crash ======================="
15670 dot_lustre_fid_permission_check() {
15672 local ffid=$MOUNT/.lustre/fid/$fid
15675 echo "stat fid $fid"
15676 stat $ffid || error "stat $ffid failed."
15677 echo "touch fid $fid"
15678 touch $ffid || error "touch $ffid failed."
15679 echo "write to fid $fid"
15680 cat /etc/hosts > $ffid || error "write $ffid failed."
15681 echo "read fid $fid"
15682 diff /etc/hosts $ffid || error "read $ffid failed."
15683 echo "append write to fid $fid"
15684 cat /etc/hosts >> $ffid || error "append write $ffid failed."
15685 echo "rename fid $fid"
15686 mv $ffid $test_dir/$tfile.1 &&
15687 error "rename $ffid to $tfile.1 should fail."
15688 touch $test_dir/$tfile.1
15689 mv $test_dir/$tfile.1 $ffid &&
15690 error "rename $tfile.1 to $ffid should fail."
15691 rm -f $test_dir/$tfile.1
15692 echo "truncate fid $fid"
15693 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
15694 echo "link fid $fid"
15695 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
15696 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
15697 echo "setfacl fid $fid"
15698 setfacl -R -m u:$USER0:rwx $ffid ||
15699 error "setfacl $ffid failed"
15700 echo "getfacl fid $fid"
15701 getfacl $ffid || error "getfacl $ffid failed."
15703 echo "unlink fid $fid"
15704 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
15705 echo "mknod fid $fid"
15706 mknod $ffid c 1 3 && error "mknod $ffid should fail."
15708 fid=[0xf00000400:0x1:0x0]
15709 ffid=$MOUNT/.lustre/fid/$fid
15711 echo "stat non-exist fid $fid"
15712 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
15713 echo "write to non-exist fid $fid"
15714 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
15715 echo "link new fid $fid"
15716 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
15718 mkdir -p $test_dir/$tdir
15719 touch $test_dir/$tdir/$tfile
15720 fid=$($LFS path2fid $test_dir/$tdir)
15723 error "error: could not get fid for $test_dir/$dir/$tfile."
15725 ffid=$MOUNT/.lustre/fid/$fid
15728 ls $ffid || error "ls $ffid failed."
15729 echo "touch $fid/$tfile.1"
15730 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
15732 echo "touch $MOUNT/.lustre/fid/$tfile"
15733 touch $MOUNT/.lustre/fid/$tfile && \
15734 error "touch $MOUNT/.lustre/fid/$tfile should fail."
15736 echo "setxattr to $MOUNT/.lustre/fid"
15737 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
15739 echo "listxattr for $MOUNT/.lustre/fid"
15740 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
15742 echo "delxattr from $MOUNT/.lustre/fid"
15743 setfattr -x trusted.name1 $MOUNT/.lustre/fid
15745 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
15746 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
15747 error "touch invalid fid should fail."
15749 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
15750 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
15751 error "touch non-normal fid should fail."
15753 echo "rename $tdir to $MOUNT/.lustre/fid"
15754 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
15755 error "rename to $MOUNT/.lustre/fid should fail."
15757 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
15759 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
15760 local new_obf_mode=777
15762 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
15763 chmod $new_obf_mode $DIR/.lustre/fid ||
15764 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
15766 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
15767 [ $obf_mode -eq $new_obf_mode ] ||
15768 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
15770 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
15771 chmod $old_obf_mode $DIR/.lustre/fid ||
15772 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
15775 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
15776 fid=$($LFS path2fid $test_dir/$tfile-2)
15778 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
15780 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
15781 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
15782 error "create lov data thru .lustre failed"
15784 echo "cp /etc/passwd $test_dir/$tfile-2"
15785 cp /etc/passwd $test_dir/$tfile-2 ||
15786 error "copy to $test_dir/$tfile-2 failed."
15787 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
15788 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
15789 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
15791 rm -rf $test_dir/tfile.lnk
15792 rm -rf $test_dir/$tfile-2
15796 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15797 skip "Need MDS version at least 2.4.1"
15799 local tf=$DIR/$tfile
15802 local fid=$($LFS path2fid $tf)
15803 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
15805 # check that we get the same pathname back
15808 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
15809 echo "$rootpath $fid"
15810 found=$($LFS fid2path $rootpath "$fid")
15811 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
15812 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
15815 # check wrong root path format
15816 rootpath=$MOUNT"_wrong"
15817 found=$($LFS fid2path $rootpath "$fid")
15818 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
15820 run_test 154A "lfs path2fid and fid2path basic checks"
15823 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15824 skip "Need MDS version at least 2.4.1"
15826 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
15827 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
15828 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
15829 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
15831 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
15832 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
15834 # check that we get the same pathname
15835 echo "PFID: $PFID, name: $name"
15836 local FOUND=$($LFS fid2path $MOUNT "$PFID")
15837 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
15838 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
15839 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
15841 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
15843 run_test 154B "verify the ll_decode_linkea tool"
15846 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15847 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15848 (( $MDS1_VERSION >= $(version_code 2.2.51) )) ||
15849 skip "Need MDS version at least 2.2.51"
15850 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
15852 cp /etc/hosts $DIR/$tfile
15854 fid=$($LFS path2fid $DIR/$tfile)
15856 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
15858 dot_lustre_fid_permission_check "$fid" $DIR ||
15859 error "dot lustre permission check $fid failed"
15861 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
15863 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
15865 touch $MOUNT/.lustre/file &&
15866 error "creation is not allowed under .lustre"
15868 mkdir $MOUNT/.lustre/dir &&
15869 error "mkdir is not allowed under .lustre"
15873 run_test 154a "Open-by-FID"
15876 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15877 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15878 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15879 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
15880 skip "Need MDS version at least 2.2.51"
15882 local remote_dir=$DIR/$tdir/remote_dir
15886 mkdir -p $DIR/$tdir
15887 $LFS mkdir -i $MDTIDX $remote_dir ||
15888 error "create remote directory failed"
15890 cp /etc/hosts $remote_dir/$tfile
15892 fid=$($LFS path2fid $remote_dir/$tfile)
15894 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
15896 dot_lustre_fid_permission_check "$fid" $remote_dir ||
15897 error "dot lustre permission check $fid failed"
15900 run_test 154b "Open-by-FID for remote directory"
15903 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15904 skip "Need MDS version at least 2.4.1"
15906 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
15907 local FID1=$($LFS path2fid $DIR/$tfile.1)
15908 local FID2=$($LFS path2fid $DIR/$tfile.2)
15909 local FID3=$($LFS path2fid $DIR/$tfile.3)
15912 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
15913 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
15914 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
15916 [ "$FID" = "${!want}" ] ||
15917 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
15921 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
15923 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
15924 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
15928 run_test 154c "lfs path2fid and fid2path multiple arguments"
15931 remote_mds_nodsh && skip "remote MDS with nodsh"
15932 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
15933 skip "Need MDS version at least 2.5.53"
15935 if remote_mds; then
15936 nid=$($LCTL list_nids | sed "s/\./\\\./g")
15940 local proc_ofile="mdt.*.exports.'$nid'.open_files"
15947 local fid=$($LFS path2fid $DIR/$tfile)
15950 cmd="exec $fd<$DIR/$tfile"
15952 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
15953 echo "$fid_list" | grep "$fid"
15956 cmd="exec $fd>/dev/null"
15958 if [ $rc -ne 0 ]; then
15959 error "FID $fid not found in open files list $fid_list"
15962 run_test 154d "Verify open file fid"
15966 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
15967 skip "Need MDS version at least 2.6.50"
15969 if ls -a $MOUNT | grep -q '^\.lustre$'; then
15970 error ".lustre returned by readdir"
15973 run_test 154e ".lustre is not returned by readdir"
15976 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15978 # create parent directory on a single MDT to avoid cross-MDT hardlinks
15979 mkdir_on_mdt0 $DIR/$tdir
15980 # test dirs inherit from its stripe
15981 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
15982 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
15983 cp /etc/hosts $DIR/$tdir/foo1/$tfile
15984 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
15987 # get fid of parents
15988 local FID0=$($LFS path2fid $DIR/$tdir)
15989 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
15990 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
15991 local FID3=$($LFS path2fid $DIR)
15993 # check that path2fid --parents returns expected <parent_fid>/name
15994 # 1) test for a directory (single parent)
15995 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
15996 [ "$parent" == "$FID0/foo1" ] ||
15997 error "expected parent: $FID0/foo1, got: $parent"
15999 # 2) test for a file with nlink > 1 (multiple parents)
16000 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
16001 echo "$parent" | grep -F "$FID1/$tfile" ||
16002 error "$FID1/$tfile not returned in parent list"
16003 echo "$parent" | grep -F "$FID2/link" ||
16004 error "$FID2/link not returned in parent list"
16006 # 3) get parent by fid
16007 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
16008 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16009 echo "$parent" | grep -F "$FID1/$tfile" ||
16010 error "$FID1/$tfile not returned in parent list (by fid)"
16011 echo "$parent" | grep -F "$FID2/link" ||
16012 error "$FID2/link not returned in parent list (by fid)"
16014 # 4) test for entry in root directory
16015 parent=$($LFS path2fid --parents $DIR/f)
16016 echo "$parent" | grep -F "$FID3/f" ||
16017 error "$FID3/f not returned in parent list"
16019 # 5) test it on root directory
16020 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
16021 error "$MOUNT should not have parents"
16023 # enable xattr caching and check that linkea is correctly updated
16024 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
16025 save_lustre_params client "llite.*.xattr_cache" > $save
16026 lctl set_param llite.*.xattr_cache 1
16028 # 6.1) linkea update on rename
16029 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
16031 # get parents by fid
16032 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16033 # foo1 should no longer be returned in parent list
16034 echo "$parent" | grep -F "$FID1" &&
16035 error "$FID1 should no longer be in parent list"
16036 # the new path should appear
16037 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
16038 error "$FID2/$tfile.moved is not in parent list"
16040 # 6.2) linkea update on unlink
16041 rm -f $DIR/$tdir/foo2/link
16042 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16043 # foo2/link should no longer be returned in parent list
16044 echo "$parent" | grep -F "$FID2/link" &&
16045 error "$FID2/link should no longer be in parent list"
16049 restore_lustre_params < $save
16052 run_test 154f "get parent fids by reading link ea"
16056 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
16057 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
16058 skip "Need MDS version at least 2.6.92"
16060 mkdir_on_mdt0 $DIR/$tdir
16061 llapi_fid_test -d $DIR/$tdir
16063 run_test 154g "various llapi FID tests"
16065 test_155_small_load() {
16066 local temp=$TMP/$tfile
16067 local file=$DIR/$tfile
16069 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
16070 error "dd of=$temp bs=6096 count=1 failed"
16072 cancel_lru_locks $OSC
16073 cmp $temp $file || error "$temp $file differ"
16075 $TRUNCATE $temp 6000
16076 $TRUNCATE $file 6000
16077 cmp $temp $file || error "$temp $file differ (truncate1)"
16079 echo "12345" >>$temp
16080 echo "12345" >>$file
16081 cmp $temp $file || error "$temp $file differ (append1)"
16083 echo "12345" >>$temp
16084 echo "12345" >>$file
16085 cmp $temp $file || error "$temp $file differ (append2)"
16091 test_155_big_load() {
16092 remote_ost_nodsh && skip "remote OST with nodsh"
16094 local temp=$TMP/$tfile
16095 local file=$DIR/$tfile
16098 local cache_size=$(do_facet ost$((MAXI+1)) \
16099 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
16101 # LU-16042: can not get the cache size on Arm64 VM here, fallback to a
16103 if [ -z "$cache_size" ]; then
16106 local large_file_size=$((cache_size * 2))
16108 echo "OSS cache size: $cache_size KB"
16109 echo "Large file size: $large_file_size KB"
16111 [ $MAXV -le $large_file_size ] &&
16112 skip_env "max available OST size needs > $large_file_size KB"
16114 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
16116 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
16117 error "dd of=$temp bs=$large_file_size count=1k failed"
16120 cancel_lru_locks osc
16121 cmp $temp $file || error "$temp $file differ"
16127 save_writethrough() {
16128 local facets=$(get_facets OST)
16130 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
16134 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16136 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16138 save_writethrough $p
16141 set_cache writethrough on
16142 test_155_small_load
16143 restore_lustre_params < $p
16146 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
16149 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16151 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16153 save_writethrough $p
16156 set_cache writethrough off
16157 test_155_small_load
16158 restore_lustre_params < $p
16161 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
16164 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16166 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16168 save_writethrough $p
16171 set_cache writethrough on
16172 test_155_small_load
16173 restore_lustre_params < $p
16176 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
16179 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16181 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16183 save_writethrough $p
16186 set_cache writethrough off
16187 test_155_small_load
16188 restore_lustre_params < $p
16191 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
16194 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16196 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16198 save_writethrough $p
16201 set_cache writethrough on
16203 restore_lustre_params < $p
16206 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
16209 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16211 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16213 save_writethrough $p
16216 set_cache writethrough off
16218 restore_lustre_params < $p
16221 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
16224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16226 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16228 save_writethrough $p
16231 set_cache writethrough on
16233 restore_lustre_params < $p
16236 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
16239 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16241 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16243 save_writethrough $p
16246 set_cache writethrough off
16248 restore_lustre_params < $p
16251 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
16254 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16255 remote_ost_nodsh && skip "remote OST with nodsh"
16256 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
16257 skip "stats not implemented on old servers"
16258 [ "$ost1_FSTYPE" = "zfs" ] &&
16259 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
16264 local file="$DIR/$tfile"
16265 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16267 save_writethrough $p
16270 log "Turn on read and write cache"
16272 set_cache writethrough on
16274 log "Write data and read it back."
16275 log "Read should be satisfied from the cache."
16276 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16278 cancel_lru_locks osc
16279 cat $file >/dev/null
16281 if ! let "AFTER - BEFORE == CPAGES"; then
16282 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
16284 log "cache hits: before: $BEFORE, after: $AFTER"
16287 log "Read again; it should be satisfied from the cache."
16289 cancel_lru_locks osc
16290 cat $file >/dev/null
16292 if ! let "AFTER - BEFORE == CPAGES"; then
16293 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
16295 log "cache hits:: before: $BEFORE, after: $AFTER"
16298 log "Turn off the read cache and turn on the write cache"
16300 set_cache writethrough on
16302 log "Read again; it should be satisfied from the cache."
16304 cancel_lru_locks osc
16305 cat $file >/dev/null
16307 if ! let "AFTER - BEFORE == CPAGES"; then
16308 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
16310 log "cache hits:: before: $BEFORE, after: $AFTER"
16313 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
16314 # > 2.12.56 uses pagecache if cached
16315 log "Read again; it should not be satisfied from the cache."
16317 cancel_lru_locks osc
16318 cat $file >/dev/null
16320 if ! let "AFTER - BEFORE == 0"; then
16321 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
16323 log "cache hits:: before: $BEFORE, after: $AFTER"
16327 log "Write data and read it back."
16328 log "Read should be satisfied from the cache."
16329 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16331 cancel_lru_locks osc
16332 cat $file >/dev/null
16334 if ! let "AFTER - BEFORE == CPAGES"; then
16335 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
16337 log "cache hits:: before: $BEFORE, after: $AFTER"
16340 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
16341 # > 2.12.56 uses pagecache if cached
16342 log "Read again; it should not be satisfied from the cache."
16344 cancel_lru_locks osc
16345 cat $file >/dev/null
16347 if ! let "AFTER - BEFORE == 0"; then
16348 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
16350 log "cache hits:: before: $BEFORE, after: $AFTER"
16354 log "Turn off read and write cache"
16356 set_cache writethrough off
16358 log "Write data and read it back"
16359 log "It should not be satisfied from the cache."
16361 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16362 cancel_lru_locks osc
16364 cat $file >/dev/null
16366 if ! let "AFTER - BEFORE == 0"; then
16367 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
16369 log "cache hits:: before: $BEFORE, after: $AFTER"
16372 log "Turn on the read cache and turn off the write cache"
16374 set_cache writethrough off
16376 log "Write data and read it back"
16377 log "It should not be satisfied from the cache."
16379 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16381 cancel_lru_locks osc
16382 cat $file >/dev/null
16384 if ! let "AFTER - BEFORE == 0"; then
16385 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
16387 log "cache hits:: before: $BEFORE, after: $AFTER"
16390 log "Read again; it should be satisfied from the cache."
16392 cancel_lru_locks osc
16393 cat $file >/dev/null
16395 if ! let "AFTER - BEFORE == CPAGES"; then
16396 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
16398 log "cache hits:: before: $BEFORE, after: $AFTER"
16401 restore_lustre_params < $p
16404 run_test 156 "Verification of tunables"
16407 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16408 remote_mds_nodsh && skip "remote MDS with nodsh"
16409 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
16410 skip "Need MDS version at least 2.2.0"
16412 changelog_register || error "changelog_register failed"
16413 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16414 changelog_users $SINGLEMDS | grep -q $cl_user ||
16415 error "User $cl_user not found in changelog_users"
16417 mkdir_on_mdt0 $DIR/$tdir
16420 test_mkdir -p $DIR/$tdir/pics/2008/zachy
16421 changelog_clear 0 || error "changelog_clear failed"
16422 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
16423 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
16424 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
16425 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
16426 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
16427 rm $DIR/$tdir/pics/desktop.jpg
16429 echo "verifying changelog mask"
16430 changelog_chmask "-MKDIR"
16431 changelog_chmask "-CLOSE"
16433 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
16434 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
16436 changelog_chmask "+MKDIR"
16437 changelog_chmask "+CLOSE"
16439 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
16440 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
16442 MKDIRS=$(changelog_dump | grep -c "MKDIR")
16443 CLOSES=$(changelog_dump | grep -c "CLOSE")
16444 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
16445 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
16448 echo "verifying target fid"
16449 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
16450 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
16451 [ "$fidc" == "$fidf" ] ||
16452 error "changelog '$tfile' fid $fidc != file fid $fidf"
16453 echo "verifying parent fid"
16454 # The FID returned from the Changelog may be the directory shard on
16455 # a different MDT, and not the FID returned by path2fid on the parent.
16456 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
16457 # since this is what will matter when recreating this file in the tree.
16458 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
16459 local pathp=$($LFS fid2path $MOUNT "$fidp")
16460 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
16461 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
16463 echo "getting records for $cl_user"
16464 changelog_users $SINGLEMDS
16465 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
16467 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
16468 error "changelog_clear failed"
16469 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
16470 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
16471 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
16472 error "user index expect $user_rec1 + $nclr != $user_rec2"
16474 local min0_rec=$(changelog_users $SINGLEMDS |
16475 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
16476 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
16477 awk '{ print $1; exit; }')
16479 changelog_dump | tail -n 5
16480 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
16481 [ $first_rec == $((min0_rec + 1)) ] ||
16482 error "first index should be $min0_rec + 1 not $first_rec"
16484 # LU-3446 changelog index reset on MDT restart
16485 local cur_rec1=$(changelog_users $SINGLEMDS |
16486 awk '/^current.index:/ { print $NF }')
16487 changelog_clear 0 ||
16488 error "clear all changelog records for $cl_user failed"
16489 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
16490 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
16491 error "Fail to start $SINGLEMDS"
16492 local cur_rec2=$(changelog_users $SINGLEMDS |
16493 awk '/^current.index:/ { print $NF }')
16494 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
16495 [ $cur_rec1 == $cur_rec2 ] ||
16496 error "current index should be $cur_rec1 not $cur_rec2"
16498 echo "verifying users from this test are deregistered"
16499 changelog_deregister || error "changelog_deregister failed"
16500 changelog_users $SINGLEMDS | grep -q $cl_user &&
16501 error "User '$cl_user' still in changelog_users"
16503 # lctl get_param -n mdd.*.changelog_users
16504 # current_index: 144
16505 # ID index (idle seconds)
16506 # cl3 144 (2) mask=<list>
16507 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
16508 # this is the normal case where all users were deregistered
16509 # make sure no new records are added when no users are present
16510 local last_rec1=$(changelog_users $SINGLEMDS |
16511 awk '/^current.index:/ { print $NF }')
16512 touch $DIR/$tdir/chloe
16513 local last_rec2=$(changelog_users $SINGLEMDS |
16514 awk '/^current.index:/ { print $NF }')
16515 echo "verify changelogs are off: $last_rec1 == $last_rec2"
16516 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
16518 # any changelog users must be leftovers from a previous test
16519 changelog_users $SINGLEMDS
16520 echo "other changelog users; can't verify off"
16523 run_test 160a "changelog sanity"
16525 test_160b() { # LU-3587
16526 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16527 remote_mds_nodsh && skip "remote MDS with nodsh"
16528 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
16529 skip "Need MDS version at least 2.2.0"
16531 changelog_register || error "changelog_register failed"
16532 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16533 changelog_users $SINGLEMDS | grep -q $cl_user ||
16534 error "User '$cl_user' not found in changelog_users"
16536 local longname1=$(str_repeat a 255)
16537 local longname2=$(str_repeat b 255)
16540 echo "creating very long named file"
16541 touch $longname1 || error "create of '$longname1' failed"
16542 echo "renaming very long named file"
16543 mv $longname1 $longname2
16545 changelog_dump | grep RENME | tail -n 5
16548 run_test 160b "Verify that very long rename doesn't crash in changelog"
16551 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16552 remote_mds_nodsh && skip "remote MDS with nodsh"
16554 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
16555 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
16556 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
16557 skip "Need MDS version at least 2.5.58 or 2.5.2+"
16561 # Registration step
16562 changelog_register || error "changelog_register failed"
16565 mkdir -p $DIR/$tdir
16566 $MCREATE $DIR/$tdir/foo_160c
16567 changelog_chmask "-TRUNC"
16568 $TRUNCATE $DIR/$tdir/foo_160c 200
16569 changelog_chmask "+TRUNC"
16570 $TRUNCATE $DIR/$tdir/foo_160c 199
16571 changelog_dump | tail -n 5
16572 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
16573 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
16575 run_test 160c "verify that changelog log catch the truncate event"
16578 remote_mds_nodsh && skip "remote MDS with nodsh"
16579 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16580 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16581 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
16582 skip "Need MDS version at least 2.7.60"
16584 # Registration step
16585 changelog_register || error "changelog_register failed"
16587 mkdir -p $DIR/$tdir/migrate_dir
16588 changelog_clear 0 || error "changelog_clear failed"
16590 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
16591 changelog_dump | tail -n 5
16592 local migrates=$(changelog_dump | grep -c "MIGRT")
16593 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
16595 run_test 160d "verify that changelog log catch the migrate event"
16598 remote_mds_nodsh && skip "remote MDS with nodsh"
16601 changelog_register || error "changelog_register failed"
16603 local MDT0=$(facet_svc $SINGLEMDS)
16606 # No user (expect fail)
16607 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
16609 if [ $rc -eq 0 ]; then
16610 error "Should fail without user"
16611 elif [ $rc -ne 4 ]; then
16612 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
16615 # Delete a future user (expect fail)
16616 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
16618 if [ $rc -eq 0 ]; then
16619 error "Deleted non-existant user cl77"
16620 elif [ $rc -ne 2 ]; then
16621 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
16624 # Clear to a bad index (1 billion should be safe)
16625 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
16628 if [ $rc -eq 0 ]; then
16629 error "Successfully cleared to invalid CL index"
16630 elif [ $rc -ne 22 ]; then
16631 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
16634 run_test 160e "changelog negative testing (should return errors)"
16637 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16638 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16639 skip "Need MDS version at least 2.10.56"
16641 local mdts=$(comma_list $(mdts_nodes))
16644 changelog_register || error "first changelog_register failed"
16645 changelog_register || error "second changelog_register failed"
16647 declare -A cl_user1
16648 declare -A cl_user2
16653 # generate some changelog records to accumulate on each MDT
16654 # use all_char because created files should be evenly distributed
16655 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16656 error "test_mkdir $tdir failed"
16657 log "$(date +%s): creating first files"
16658 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16659 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
16660 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
16663 # check changelogs have been generated
16664 local start=$SECONDS
16665 local idle_time=$((MDSCOUNT * 5 + 5))
16666 local nbcl=$(changelog_dump | wc -l)
16667 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16669 for param in "changelog_max_idle_time=$idle_time" \
16671 "changelog_min_gc_interval=2" \
16672 "changelog_min_free_cat_entries=3"; do
16673 local MDT0=$(facet_svc $SINGLEMDS)
16674 local var="${param%=*}"
16675 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16677 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16678 do_nodes $mdts $LCTL set_param mdd.*.$param
16681 # force cl_user2 to be idle (1st part), but also cancel the
16682 # cl_user1 records so that it is not evicted later in the test.
16683 local sleep1=$((idle_time / 2))
16684 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
16687 # simulate changelog catalog almost full
16688 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
16689 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
16691 for i in $(seq $MDSCOUNT); do
16692 cl_users=(${CL_USERS[mds$i]})
16693 cl_user1[mds$i]="${cl_users[0]}"
16694 cl_user2[mds$i]="${cl_users[1]}"
16696 [ -n "${cl_user1[mds$i]}" ] ||
16697 error "mds$i: no user registered"
16698 [ -n "${cl_user2[mds$i]}" ] ||
16699 error "mds$i: only ${cl_user2[mds$i]} is registered"
16701 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16702 [ -n "$user_rec1" ] ||
16703 error "mds$i: User ${cl_user1[mds$i]} not registered"
16704 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16705 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16706 [ -n "$user_rec2" ] ||
16707 error "mds$i: User ${cl_user1[mds$i]} not registered"
16708 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16709 "$user_rec1 + 2 == $user_rec2"
16710 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16711 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16712 "$user_rec1 + 2, but is $user_rec2"
16713 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16714 [ -n "$user_rec2" ] ||
16715 error "mds$i: User ${cl_user2[mds$i]} not registered"
16716 [ $user_rec1 == $user_rec2 ] ||
16717 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16718 "$user_rec1, but is $user_rec2"
16721 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
16722 local sleep2=$((idle_time - (SECONDS - start) + 1))
16723 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
16726 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16727 # cl_user1 should be OK because it recently processed records.
16728 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
16729 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16730 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
16731 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
16734 # ensure gc thread is done
16735 for i in $(mdts_nodes); do
16736 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16737 error "$i: GC-thread not done"
16741 for (( i = 1; i <= MDSCOUNT; i++ )); do
16742 # check cl_user1 still registered
16743 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16744 error "mds$i: User ${cl_user1[mds$i]} not registered"
16745 # check cl_user2 unregistered
16746 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16747 error "mds$i: User ${cl_user2[mds$i]} still registered"
16749 # check changelogs are present and starting at $user_rec1 + 1
16750 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16751 [ -n "$user_rec1" ] ||
16752 error "mds$i: User ${cl_user1[mds$i]} not registered"
16753 first_rec=$($LFS changelog $(facet_svc mds$i) |
16754 awk '{ print $1; exit; }')
16756 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16757 [ $((user_rec1 + 1)) == $first_rec ] ||
16758 error "mds$i: rec $first_rec != $user_rec1 + 1"
16761 run_test 160f "changelog garbage collect (timestamped users)"
16764 remote_mds_nodsh && skip "remote MDS with nodsh"
16765 [[ $MDS1_VERSION -ge $(version_code 2.14.55) ]] ||
16766 skip "Need MDS version at least 2.14.55"
16768 local mdts=$(comma_list $(mdts_nodes))
16771 changelog_register || error "first changelog_register failed"
16772 changelog_register || error "second changelog_register failed"
16774 declare -A cl_user1
16775 declare -A cl_user2
16780 # generate some changelog records to accumulate on each MDT
16781 # use all_char because created files should be evenly distributed
16782 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16783 error "test_mkdir $tdir failed"
16784 for ((i = 0; i < MDSCOUNT; i++)); do
16785 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16786 error "create $DIR/$tdir/d$i.1 failed"
16789 # check changelogs have been generated
16790 local nbcl=$(changelog_dump | wc -l)
16791 (( $nbcl > 0 )) || error "no changelogs found"
16793 # reduce the max_idle_indexes value to make sure we exceed it
16794 for param in "changelog_max_idle_indexes=2" \
16796 "changelog_min_gc_interval=2"; do
16797 local MDT0=$(facet_svc $SINGLEMDS)
16798 local var="${param%=*}"
16799 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16801 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16802 do_nodes $mdts $LCTL set_param mdd.*.$param ||
16803 error "unable to set mdd.*.$param"
16806 local start=$SECONDS
16807 for i in $(seq $MDSCOUNT); do
16808 cl_users=(${CL_USERS[mds$i]})
16809 cl_user1[mds$i]="${cl_users[0]}"
16810 cl_user2[mds$i]="${cl_users[1]}"
16812 [ -n "${cl_user1[mds$i]}" ] ||
16813 error "mds$i: user1 is not registered"
16814 [ -n "${cl_user2[mds$i]}" ] ||
16815 error "mds$i: only ${cl_user1[mds$i]} is registered"
16817 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16818 [ -n "$user_rec1" ] ||
16819 error "mds$i: user1 ${cl_user1[mds$i]} not found"
16820 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16821 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16822 [ -n "$user_rec2" ] ||
16823 error "mds$i: user1 ${cl_user1[mds$i]} not found (2)"
16824 echo "mds$i: verifying user1 ${cl_user1[mds$i]} clear: " \
16825 "$user_rec1 + 2 == $user_rec2"
16826 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16827 error "mds$i: user1 ${cl_user1[mds$i]} index " \
16828 "expected $user_rec1 + 2, but is $user_rec2"
16829 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16830 [ -n "$user_rec2" ] ||
16831 error "mds$i: user2 ${cl_user2[mds$i]} not found"
16832 [ $user_rec1 == $user_rec2 ] ||
16833 error "mds$i: user2 ${cl_user2[mds$i]} index " \
16834 "expected $user_rec1, but is $user_rec2"
16837 # ensure we are past the previous changelog_min_gc_interval set above
16838 local sleep2=$((start + 2 - SECONDS))
16839 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
16840 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16841 # cl_user1 should be OK because it recently processed records.
16842 for ((i = 0; i < MDSCOUNT; i++)); do
16843 $LFS mkdir -i $i $DIR/$tdir/d$i.3 ||
16844 error "create $DIR/$tdir/d$i.3 failed"
16847 # ensure gc thread is done
16848 for i in $(mdts_nodes); do
16849 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16850 error "$i: GC-thread not done"
16854 for (( i = 1; i <= MDSCOUNT; i++ )); do
16855 # check cl_user1 still registered
16856 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16857 error "mds$i: user1 ${cl_user1[mds$i]} not found (3)"
16858 # check cl_user2 unregistered
16859 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16860 error "mds$i: user2 ${cl_user2[mds$i]} is registered"
16862 # check changelogs are present and starting at $user_rec1 + 1
16863 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16864 [ -n "$user_rec1" ] ||
16865 error "mds$i: user1 ${cl_user1[mds$i]} not found (4)"
16866 first_rec=$($LFS changelog $(facet_svc mds$i) |
16867 awk '{ print $1; exit; }')
16869 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16870 [ $((user_rec1 + 1)) == $first_rec ] ||
16871 error "mds$i: rec $first_rec != $user_rec1 + 1"
16874 run_test 160g "changelog garbage collect on idle records"
16877 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16878 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16879 skip "Need MDS version at least 2.10.56"
16881 local mdts=$(comma_list $(mdts_nodes))
16884 changelog_register || error "first changelog_register failed"
16885 changelog_register || error "second changelog_register failed"
16887 declare -A cl_user1
16888 declare -A cl_user2
16893 # generate some changelog records to accumulate on each MDT
16894 # use all_char because created files should be evenly distributed
16895 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16896 error "test_mkdir $tdir failed"
16897 for ((i = 0; i < MDSCOUNT; i++)); do
16898 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16899 error "create $DIR/$tdir/d$i.1 failed"
16902 # check changelogs have been generated
16903 local nbcl=$(changelog_dump | wc -l)
16904 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16906 for param in "changelog_max_idle_time=10" \
16908 "changelog_min_gc_interval=2"; do
16909 local MDT0=$(facet_svc $SINGLEMDS)
16910 local var="${param%=*}"
16911 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16913 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16914 do_nodes $mdts $LCTL set_param mdd.*.$param
16917 # force cl_user2 to be idle (1st part)
16920 for i in $(seq $MDSCOUNT); do
16921 cl_users=(${CL_USERS[mds$i]})
16922 cl_user1[mds$i]="${cl_users[0]}"
16923 cl_user2[mds$i]="${cl_users[1]}"
16925 [ -n "${cl_user1[mds$i]}" ] ||
16926 error "mds$i: no user registered"
16927 [ -n "${cl_user2[mds$i]}" ] ||
16928 error "mds$i: only ${cl_user2[mds$i]} is registered"
16930 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16931 [ -n "$user_rec1" ] ||
16932 error "mds$i: User ${cl_user1[mds$i]} not registered"
16933 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16934 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16935 [ -n "$user_rec2" ] ||
16936 error "mds$i: User ${cl_user1[mds$i]} not registered"
16937 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16938 "$user_rec1 + 2 == $user_rec2"
16939 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16940 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16941 "$user_rec1 + 2, but is $user_rec2"
16942 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16943 [ -n "$user_rec2" ] ||
16944 error "mds$i: User ${cl_user2[mds$i]} not registered"
16945 [ $user_rec1 == $user_rec2 ] ||
16946 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16947 "$user_rec1, but is $user_rec2"
16950 # force cl_user2 to be idle (2nd part) and to reach
16951 # changelog_max_idle_time
16954 # force each GC-thread start and block then
16955 # one per MDT/MDD, set fail_val accordingly
16956 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
16957 do_nodes $mdts $LCTL set_param fail_loc=0x1316
16959 # generate more changelogs to trigger fail_loc
16960 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16961 error "create $DIR/$tdir/${tfile}bis failed"
16963 # stop MDT to stop GC-thread, should be done in back-ground as it will
16964 # block waiting for the thread to be released and exit
16965 declare -A stop_pids
16966 for i in $(seq $MDSCOUNT); do
16968 stop_pids[mds$i]=$!
16971 for i in $(mdts_nodes); do
16974 local facets=$(facets_up_on_host $i)
16976 for facet in ${facets//,/ }; do
16977 if [[ $facet == mds* ]]; then
16981 # ensure each MDS's gc threads are still present and all in "R"
16982 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
16983 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
16984 error "$i: expected $nb GC-thread"
16986 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
16988 error "$i: GC-thread not found in R-state"
16989 # check umounts of each MDT on MDS have reached kthread_stop()
16990 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
16991 error "$i: expected $nb umount"
16993 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
16994 error "$i: umount not found in D-state"
16997 # release all GC-threads
16998 do_nodes $mdts $LCTL set_param fail_loc=0
17000 # wait for MDT stop to complete
17001 for i in $(seq $MDSCOUNT); do
17002 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
17006 # may try to check if any orphan changelog records are present
17007 # via ldiskfs/zfs and llog_reader...
17009 # re-start/mount MDTs
17010 for i in $(seq $MDSCOUNT); do
17011 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
17012 error "Fail to start mds$i"
17016 for i in $(seq $MDSCOUNT); do
17017 # check cl_user1 still registered
17018 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
17019 error "mds$i: User ${cl_user1[mds$i]} not registered"
17020 # check cl_user2 unregistered
17021 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
17022 error "mds$i: User ${cl_user2[mds$i]} still registered"
17024 # check changelogs are present and starting at $user_rec1 + 1
17025 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17026 [ -n "$user_rec1" ] ||
17027 error "mds$i: User ${cl_user1[mds$i]} not registered"
17028 first_rec=$($LFS changelog $(facet_svc mds$i) |
17029 awk '{ print $1; exit; }')
17031 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
17032 [ $((user_rec1 + 1)) == $first_rec ] ||
17033 error "mds$i: first index should be $user_rec1 + 1, " \
17034 "but is $first_rec"
17037 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
17042 local mdts=$(comma_list $(mdts_nodes))
17044 changelog_register || error "first changelog_register failed"
17046 # generate some changelog records to accumulate on each MDT
17047 # use all_char because created files should be evenly distributed
17048 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17049 error "test_mkdir $tdir failed"
17050 for ((i = 0; i < MDSCOUNT; i++)); do
17051 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17052 error "create $DIR/$tdir/d$i.1 failed"
17055 # check changelogs have been generated
17056 local nbcl=$(changelog_dump | wc -l)
17057 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17059 # simulate race between register and unregister
17060 # XXX as fail_loc is set per-MDS, with DNE configs the race
17061 # simulation will only occur for one MDT per MDS and for the
17062 # others the normal race scenario will take place
17063 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
17064 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
17065 do_nodes $mdts $LCTL set_param fail_val=1
17067 # unregister 1st user
17068 changelog_deregister &
17070 # wait some time for deregister work to reach race rdv
17072 # register 2nd user
17073 changelog_register || error "2nd user register failed"
17075 wait $pid1 || error "1st user deregister failed"
17079 declare -A LAST_REC
17080 for i in $(seq $MDSCOUNT); do
17081 if changelog_users mds$i | grep "^cl"; then
17082 # make sure new records are added with one user present
17083 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
17084 awk '/^current.index:/ { print $NF }')
17086 error "mds$i has no user registered"
17090 # generate more changelog records to accumulate on each MDT
17091 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
17092 error "create $DIR/$tdir/${tfile}bis failed"
17094 for i in $(seq $MDSCOUNT); do
17095 last_rec=$(changelog_users $SINGLEMDS |
17096 awk '/^current.index:/ { print $NF }')
17097 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
17098 [ $last_rec != ${LAST_REC[mds$i]} ] ||
17099 error "changelogs are off on mds$i"
17102 run_test 160i "changelog user register/unregister race"
17105 remote_mds_nodsh && skip "remote MDS with nodsh"
17106 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
17107 skip "Need MDS version at least 2.12.56"
17109 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
17110 stack_trap "umount $MOUNT2" EXIT
17112 changelog_register || error "first changelog_register failed"
17113 stack_trap "changelog_deregister" EXIT
17115 # generate some changelog
17116 # use all_char because created files should be evenly distributed
17117 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17118 error "mkdir $tdir failed"
17119 for ((i = 0; i < MDSCOUNT; i++)); do
17120 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17121 error "create $DIR/$tdir/d$i.1 failed"
17124 # open the changelog device
17125 exec 3>/dev/changelog-$FSNAME-MDT0000
17126 stack_trap "exec 3>&-" EXIT
17127 exec 4</dev/changelog-$FSNAME-MDT0000
17128 stack_trap "exec 4<&-" EXIT
17130 # umount the first lustre mount
17132 stack_trap "mount_client $MOUNT" EXIT
17134 # read changelog, which may or may not fail, but should not crash
17138 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17139 changelog_users $SINGLEMDS | grep -q $cl_user ||
17140 error "User $cl_user not found in changelog_users"
17142 printf 'clear:'$cl_user':0' >&3
17144 run_test 160j "client can be umounted while its chanangelog is being used"
17147 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17148 remote_mds_nodsh && skip "remote MDS with nodsh"
17150 mkdir -p $DIR/$tdir/1/1
17152 changelog_register || error "changelog_register failed"
17153 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17155 changelog_users $SINGLEMDS | grep -q $cl_user ||
17156 error "User '$cl_user' not found in changelog_users"
17157 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
17158 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
17159 rmdir $DIR/$tdir/1/1 & sleep 1
17161 touch $DIR/$tdir/2/2
17162 rm -rf $DIR/$tdir/2
17167 changelog_dump | grep rmdir || error "rmdir not recorded"
17169 run_test 160k "Verify that changelog records are not lost"
17171 # Verifies that a file passed as a parameter has recently had an operation
17172 # performed on it that has generated an MTIME changelog which contains the
17173 # correct parent FID. As files might reside on a different MDT from the
17174 # parent directory in DNE configurations, the FIDs are translated to paths
17175 # before being compared, which should be identical
17176 compare_mtime_changelog() {
17184 mdtidx=$($LFS getstripe --mdt-index $file)
17185 mdtidx=$(printf "%04x" $mdtidx)
17187 # Obtain the parent FID from the MTIME changelog
17188 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
17189 [ -z "$mtime" ] && error "MTIME changelog not recorded"
17191 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
17192 [ -z "$cl_fid" ] && error "parent FID not present"
17194 # Verify that the path for the parent FID is the same as the path for
17195 # the test directory
17196 pdir=$($LFS fid2path $MOUNT "$cl_fid")
17200 [[ "${pdir%/}" == "$dir" ]] ||
17201 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
17205 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17207 remote_mds_nodsh && skip "remote MDS with nodsh"
17208 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
17209 skip "Need MDS version at least 2.13.55"
17213 changelog_register || error "changelog_register failed"
17214 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17216 changelog_users $SINGLEMDS | grep -q $cl_user ||
17217 error "User '$cl_user' not found in changelog_users"
17219 # Clear some types so that MTIME changelogs are generated
17220 changelog_chmask "-CREAT"
17221 changelog_chmask "-CLOSE"
17223 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
17225 # Test CL_MTIME during setattr
17226 touch $DIR/$tdir/$tfile
17227 compare_mtime_changelog $DIR/$tdir/$tfile
17229 # Test CL_MTIME during close
17230 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
17231 compare_mtime_changelog $DIR/$tdir/${tfile}_2
17233 run_test 160l "Verify that MTIME changelog records contain the parent FID"
17236 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17237 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17238 skip "Need MDS version at least 2.14.51"
17245 changelog_register || error "first changelog_register failed"
17246 changelog_register || error "second changelog_register failed"
17248 cl_users=(${CL_USERS[mds1]})
17249 cl_user1="${cl_users[0]}"
17250 cl_user2="${cl_users[1]}"
17251 # generate some changelog records to accumulate on MDT0
17252 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17253 createmany -m $DIR/$tdir/$tfile 50 ||
17254 error "create $DIR/$tdir/$tfile failed"
17255 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
17258 # check changelogs have been generated
17259 local nbcl=$(changelog_dump | wc -l)
17260 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17262 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
17263 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
17265 __changelog_clear mds1 $cl_user1 +10
17266 __changelog_clear mds1 $cl_user2 0 &
17269 __changelog_clear mds1 $cl_user1 0 ||
17270 error "fail to cancel record for $cl_user1"
17272 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
17274 run_test 160m "Changelog clear race"
17277 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17278 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17279 skip "Need MDS version at least 2.14.51"
17288 changelog_register || error "first changelog_register failed"
17290 cl_users=(${CL_USERS[mds1]})
17291 cl_user1="${cl_users[0]}"
17293 # generate some changelog records to accumulate on MDT0
17294 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17295 first_rec=$(changelog_users $SINGLEMDS |
17296 awk '/^current.index:/ { print $NF }')
17297 while (( last_rec < (( first_rec + 65000)) )); do
17298 createmany -m $DIR/$tdir/$tfile 10000 ||
17299 error "create $DIR/$tdir/$tfile failed"
17301 for i in $(seq 0 10000); do
17302 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
17306 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
17307 error "unlinkmany failed unlink"
17308 last_rec=$(changelog_users $SINGLEMDS |
17309 awk '/^current.index:/ { print $NF }')
17310 echo last record $last_rec
17311 (( last_rec == 0 )) && error "no changelog found"
17314 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
17315 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
17317 __changelog_clear mds1 $cl_user1 0 &
17320 __changelog_clear mds1 $cl_user1 0 ||
17321 error "fail to cancel record for $cl_user1"
17323 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
17325 run_test 160n "Changelog destroy race"
17328 local mdt="$(facet_svc $SINGLEMDS)"
17330 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
17331 remote_mds_nodsh && skip "remote MDS with nodsh"
17332 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
17333 skip "Need MDS version at least 2.14.52"
17335 changelog_register --user test_160o -m unlnk+close+open ||
17336 error "changelog_register failed"
17338 do_facet $SINGLEMDS $LCTL --device $mdt \
17339 changelog_register -u "Tt3_-#" &&
17340 error "bad symbols in name should fail"
17342 do_facet $SINGLEMDS $LCTL --device $mdt \
17343 changelog_register -u test_160o &&
17344 error "the same name registration should fail"
17346 do_facet $SINGLEMDS $LCTL --device $mdt \
17347 changelog_register -u test_160toolongname &&
17348 error "too long name registration should fail"
17350 changelog_chmask "MARK+HSM"
17351 lctl get_param mdd.*.changelog*mask
17352 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17353 changelog_users $SINGLEMDS | grep -q $cl_user ||
17354 error "User $cl_user not found in changelog_users"
17356 echo $cl_user | grep -q test_160o ||
17357 error "User $cl_user has no specific name 'test160o'"
17360 changelog_clear 0 || error "changelog_clear failed"
17361 # generate some changelog records to accumulate on MDT0
17362 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17363 touch $DIR/$tdir/$tfile # open 1
17365 OPENS=$(changelog_dump | grep -c "OPEN")
17366 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
17368 # must be no MKDIR it wasn't set as user mask
17369 MKDIR=$(changelog_dump | grep -c "MKDIR")
17370 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
17372 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
17373 mdd.$mdt.changelog_current_mask -n)
17374 # register maskless user
17375 changelog_register || error "changelog_register failed"
17376 # effective mask should be not changed because it is not minimal
17377 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17378 mdd.$mdt.changelog_current_mask -n)
17379 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
17380 # set server mask to minimal value
17381 changelog_chmask "MARK"
17382 # check effective mask again, should be treated as DEFMASK now
17383 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17384 mdd.$mdt.changelog_current_mask -n)
17385 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
17387 if (( $MDS1_VERSION >= $(version_code 2.15.52) )) ; then
17388 # set server mask back to some value
17389 changelog_chmask "CLOSE,UNLNK"
17390 # check effective mask again, should not remain as DEFMASK
17391 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17392 mdd.$mdt.changelog_current_mask -n)
17393 [[ $mask != *"HLINK"* ]] || error "mask is still DEFMASK"
17396 do_facet $SINGLEMDS $LCTL --device $mdt \
17397 changelog_deregister -u test_160o ||
17398 error "cannot deregister by name"
17400 run_test 160o "changelog user name and mask"
17403 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17404 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17405 skip "Need MDS version at least 2.14.51"
17406 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
17412 changelog_register || error "first changelog_register failed"
17414 cl_users=(${CL_USERS[mds1]})
17415 cl_user1="${cl_users[0]}"
17417 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17418 createmany -m $DIR/$tdir/$tfile 50 ||
17419 error "create $DIR/$tdir/$tfile failed"
17420 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
17423 # check changelogs have been generated
17424 entry_count=$(changelog_dump | wc -l)
17425 ((entry_count != 0)) || error "no changelog entries found"
17427 # remove changelog_users and check that orphan entries are removed
17429 local dev=$(mdsdevname 1)
17430 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $dev"
17431 start mds1 $dev $MDS_MOUNT_OPTS || error "cannot start mds1"
17432 entry_count=$(changelog_dump | wc -l)
17433 ((entry_count == 0)) ||
17434 error "found $entry_count changelog entries, expected none"
17436 run_test 160p "Changelog orphan cleanup with no users"
17439 local mdt="$(facet_svc $SINGLEMDS)"
17442 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
17443 remote_mds_nodsh && skip "remote MDS with nodsh"
17444 [ $MDS1_VERSION -ge $(version_code 2.14.54) ] ||
17445 skip "Need MDS version at least 2.14.54"
17447 # set server mask to minimal value like server init does
17448 changelog_chmask "MARK"
17449 clu=$(do_facet $SINGLEMDS $LCTL --device $mdt changelog_register -n) ||
17450 error "changelog_register failed"
17451 # check effective mask again, should be treated as DEFMASK now
17452 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17453 mdd.$mdt.changelog_current_mask -n)
17454 do_facet $SINGLEMDS $LCTL --device $mdt changelog_deregister $clu ||
17455 error "changelog_deregister failed"
17456 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
17458 run_test 160q "changelog effective mask is DEFMASK if not set"
17461 remote_mds_nodsh && skip "remote MDS with nodsh"
17462 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
17463 skip "Need MDS version at least 2.14.55"
17465 local mdts=$(comma_list $(mdts_nodes))
17467 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
17468 do_nodes $mdts $LCTL set_param fail_loc=0x1314 \
17469 fail_val=$((24 * 3600 * 10))
17471 # Create a user which is 10 days old
17472 changelog_register || error "first changelog_register failed"
17474 declare -A cl_user1
17477 # generate some changelog records to accumulate on each MDT
17478 # use all_char because created files should be evenly distributed
17479 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17480 error "test_mkdir $tdir failed"
17481 for ((i = 0; i < MDSCOUNT; i++)); do
17482 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17483 error "create $DIR/$tdir/d$i.1 failed"
17486 # check changelogs have been generated
17487 local nbcl=$(changelog_dump | wc -l)
17488 (( nbcl > 0 )) || error "no changelogs found"
17490 # reduce the max_idle_indexes value to make sure we exceed it
17491 for param in "changelog_max_idle_indexes=2097446912" \
17492 "changelog_max_idle_time=2592000" \
17494 "changelog_min_gc_interval=2"; do
17495 local MDT0=$(facet_svc $SINGLEMDS)
17496 local var="${param%=*}"
17497 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17499 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17500 do_nodes $mdts $LCTL set_param mdd.*.$param ||
17501 error "unable to set mdd.*.$param"
17504 local start=$SECONDS
17505 for i in $(seq $MDSCOUNT); do
17506 cl_users=(${CL_USERS[mds$i]})
17507 cl_user1[mds$i]="${cl_users[0]}"
17509 [[ -n "${cl_user1[mds$i]}" ]] ||
17510 error "mds$i: no user registered"
17513 #define OBD_FAIL_MDS_CHANGELOG_IDX_PUMP 0x16d
17514 do_nodes $mdts $LCTL set_param fail_loc=0x16d fail_val=500000000
17516 # ensure we are past the previous changelog_min_gc_interval set above
17517 local sleep2=$((start + 2 - SECONDS))
17518 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17520 # Generate one more changelog to trigger GC
17521 for ((i = 0; i < MDSCOUNT; i++)); do
17522 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
17523 error "create $DIR/$tdir/d$i.3 failed"
17526 # ensure gc thread is done
17527 for node in $(mdts_nodes); do
17528 wait_update $node "pgrep chlg_gc_thread" "" 20 ||
17529 error "$node: GC-thread not done"
17532 do_nodes $mdts $LCTL set_param fail_loc=0
17534 for (( i = 1; i <= MDSCOUNT; i++ )); do
17535 # check cl_user1 is purged
17536 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" &&
17537 error "mds$i: User ${cl_user1[mds$i]} is registered"
17541 run_test 160s "changelog garbage collect on idle records * time"
17544 remote_mds_nodsh && skip "remote MDS with nodsh"
17545 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
17546 skip "Need MDS version at least 2.15.50"
17548 local MDT0=$(facet_svc $SINGLEMDS)
17554 changelog_register --user user1 -m all ||
17555 error "user1 failed to register"
17557 mkdir_on_mdt0 $DIR/$tdir
17558 # create default overstripe to maximize changelog size
17559 $LFS setstripe -C 8 $DIR/$tdir || error "setstripe failed"
17560 createmany -o $DIR/$tdir/u1_ 2000 || error "createmany for user1 failed"
17561 llog_size1=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
17563 # user2 consumes less records so less space
17564 changelog_register --user user2 || error "user2 failed to register"
17565 createmany -o $DIR/$tdir/u2_ 500 || error "createmany for user2 failed"
17566 llog_size2=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
17568 # check changelogs have been generated
17569 local nbcl=$(changelog_dump | wc -l)
17570 (( nbcl > 0 )) || error "no changelogs found"
17572 # reduce the changelog_min_gc_interval to force check
17573 for param in "changelog_gc=1" "changelog_min_gc_interval=2"; do
17574 local var="${param%=*}"
17575 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17577 stack_trap "do_facet mds1 $LCTL set_param mdd.$MDT0.$var=$old"
17578 do_facet mds1 $LCTL set_param mdd.$MDT0.$param ||
17579 error "unable to set mdd.*.$param"
17583 cl_users=(${CL_USERS[mds1]})
17584 cl_user1="${cl_users[0]}"
17585 cl_user2="${cl_users[1]}"
17587 [[ -n $cl_user1 ]] ||
17588 error "mds1: user #1 isn't registered"
17589 [[ -n $cl_user2 ]] ||
17590 error "mds1: user #2 isn't registered"
17592 # ensure we are past the previous changelog_min_gc_interval set above
17593 local sleep2=$((start + 2 - SECONDS))
17594 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17596 #define OBD_FAIL_MDS_CHANGELOG_ENOSPC 0x018c
17597 do_facet mds1 $LCTL set_param fail_loc=0x018c \
17598 fail_val=$(((llog_size1 + llog_size2) / 2))
17600 # Generate more changelog to trigger GC
17601 createmany -o $DIR/$tdir/u3_ 4 ||
17602 error "create failed for more files"
17604 # ensure gc thread is done
17605 wait_update_facet mds1 "pgrep chlg_gc_thread" "" 20 ||
17606 error "mds1: GC-thread not done"
17608 do_facet mds1 $LCTL set_param fail_loc=0
17610 # check cl_user1 is purged
17611 changelog_users mds1 | grep -q "$cl_user1" &&
17612 error "User $cl_user1 is registered"
17613 # check cl_user2 is not purged
17614 changelog_users mds1 | grep -q "$cl_user2" ||
17615 error "User $cl_user2 is not registered"
17617 run_test 160t "changelog garbage collect on lack of space"
17620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17622 test_mkdir -c1 $DIR/$tdir
17623 cp /etc/hosts $DIR/$tdir/$tfile
17624 test_mkdir -c1 $DIR/$tdir/foo1
17625 test_mkdir -c1 $DIR/$tdir/foo2
17626 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
17627 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
17628 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
17629 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
17630 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
17631 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17632 $LFS fid2path $DIR $FID
17633 error "bad link ea"
17636 rm $DIR/$tdir/foo2/zachary
17638 rm $DIR/$tdir/foo2/thor
17640 rm $DIR/$tdir/$tfile
17642 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
17643 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
17644 { $LFS fid2path $DIR $FID; error "bad link rename"; }
17645 rm $DIR/$tdir/foo2/maggie
17648 local longname=$tfile.avg_len_is_thirty_two_
17649 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
17650 error_noexit 'failed to unlink many hardlinks'" EXIT
17651 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
17652 error "failed to hardlink many files"
17653 links=$($LFS fid2path $DIR $FID | wc -l)
17654 echo -n "${links}/1000 links in link EA"
17655 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
17657 run_test 161a "link ea sanity"
17660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17661 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
17664 local remote_dir=$DIR/$tdir/remote_dir
17666 mkdir -p $DIR/$tdir
17667 $LFS mkdir -i $MDTIDX $remote_dir ||
17668 error "create remote directory failed"
17670 cp /etc/hosts $remote_dir/$tfile
17671 mkdir -p $remote_dir/foo1
17672 mkdir -p $remote_dir/foo2
17673 ln $remote_dir/$tfile $remote_dir/foo1/sofia
17674 ln $remote_dir/$tfile $remote_dir/foo2/zachary
17675 ln $remote_dir/$tfile $remote_dir/foo1/luna
17676 ln $remote_dir/$tfile $remote_dir/foo2/thor
17678 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
17680 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17681 $LFS fid2path $DIR $FID
17682 error "bad link ea"
17685 rm $remote_dir/foo2/zachary
17687 rm $remote_dir/foo2/thor
17689 rm $remote_dir/$tfile
17691 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
17692 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
17693 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
17694 $LFS fid2path $DIR $FID
17695 error "bad link rename"
17697 rm $remote_dir/foo2/maggie
17700 local longname=filename_avg_len_is_thirty_two_
17701 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
17702 error "failed to hardlink many files"
17703 links=$($LFS fid2path $DIR $FID | wc -l)
17704 echo -n "${links}/1000 links in link EA"
17705 [[ ${links} -gt 60 ]] ||
17706 error "expected at least 60 links in link EA"
17707 unlinkmany $remote_dir/foo2/$longname 1000 ||
17708 error "failed to unlink many hardlinks"
17710 run_test 161b "link ea sanity under remote directory"
17713 remote_mds_nodsh && skip "remote MDS with nodsh"
17714 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17715 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
17716 skip "Need MDS version at least 2.1.5"
17718 # define CLF_RENAME_LAST 0x0001
17719 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
17720 changelog_register || error "changelog_register failed"
17723 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
17724 touch $DIR/$tdir/foo_161c
17725 touch $DIR/$tdir/bar_161c
17726 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17727 changelog_dump | grep RENME | tail -n 5
17728 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17729 changelog_clear 0 || error "changelog_clear failed"
17730 if [ x$flags != "x0x1" ]; then
17731 error "flag $flags is not 0x1"
17734 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
17735 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
17736 touch $DIR/$tdir/foo_161c
17737 touch $DIR/$tdir/bar_161c
17738 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17739 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17740 changelog_dump | grep RENME | tail -n 5
17741 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17742 changelog_clear 0 || error "changelog_clear failed"
17743 if [ x$flags != "x0x0" ]; then
17744 error "flag $flags is not 0x0"
17746 echo "rename overwrite a target having nlink > 1," \
17747 "changelog record has flags of $flags"
17749 # rename doesn't overwrite a target (changelog flag 0x0)
17750 touch $DIR/$tdir/foo_161c
17751 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
17752 changelog_dump | grep RENME | tail -n 5
17753 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
17754 changelog_clear 0 || error "changelog_clear failed"
17755 if [ x$flags != "x0x0" ]; then
17756 error "flag $flags is not 0x0"
17758 echo "rename doesn't overwrite a target," \
17759 "changelog record has flags of $flags"
17761 # define CLF_UNLINK_LAST 0x0001
17762 # unlink a file having nlink = 1 (changelog flag 0x1)
17763 rm -f $DIR/$tdir/foo2_161c
17764 changelog_dump | grep UNLNK | tail -n 5
17765 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17766 changelog_clear 0 || error "changelog_clear failed"
17767 if [ x$flags != "x0x1" ]; then
17768 error "flag $flags is not 0x1"
17770 echo "unlink a file having nlink = 1," \
17771 "changelog record has flags of $flags"
17773 # unlink a file having nlink > 1 (changelog flag 0x0)
17774 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17775 rm -f $DIR/$tdir/foobar_161c
17776 changelog_dump | grep UNLNK | tail -n 5
17777 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17778 changelog_clear 0 || error "changelog_clear failed"
17779 if [ x$flags != "x0x0" ]; then
17780 error "flag $flags is not 0x0"
17782 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
17784 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
17787 remote_mds_nodsh && skip "remote MDS with nodsh"
17788 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
17793 changelog_register || error "changelog_register failed"
17795 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
17796 # interfer with $MOUNT/.lustre/fid/ access
17798 [[ $? -eq 0 ]] || error "mkdir failed"
17800 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
17801 $LCTL set_param fail_loc=0x8000140c
17803 $LCTL set_param fail_val=5
17806 echo foofoo > $DIR/$tdir/$tfile &
17809 # wait for create to be delayed
17813 [[ $? -eq 0 ]] || error "create should be blocked"
17815 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
17816 stack_trap "rm -f $tempfile"
17817 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
17818 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
17819 # some delay may occur during ChangeLog publishing and file read just
17820 # above, that could allow file write to happen finally
17821 [[ -s $tempfile ]] && echo "file should be empty"
17823 $LCTL set_param fail_loc=0
17826 [[ $? -eq 0 ]] || error "create failed"
17828 run_test 161d "create with concurrent .lustre/fid access"
17831 local expected="$1"
17836 path=$($LFS fid2path "$@")
17839 if [ $rc -ne 0 ]; then
17840 error "path looked up of '$expected' failed: rc=$rc"
17841 elif [ "$path" != "$expected" ]; then
17842 error "path looked up '$path' instead of '$expected'"
17844 echo "FID '$fid' resolves to path '$path' as expected"
17848 test_162a() { # was test_162
17849 test_mkdir -p -c1 $DIR/$tdir/d2
17850 touch $DIR/$tdir/d2/$tfile
17851 touch $DIR/$tdir/d2/x1
17852 touch $DIR/$tdir/d2/x2
17853 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
17854 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
17856 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
17857 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
17860 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
17861 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
17862 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
17864 # softlink to wrong file
17865 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
17866 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
17867 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
17870 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
17871 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
17872 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
17873 # fid2path dir/fsname should both work
17874 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
17875 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
17877 # hardlink count: check that there are 2 links
17878 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
17879 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
17881 # hardlink indexing: remove the first link
17882 rm $DIR/$tdir/d2/p/q/r/hlink
17883 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
17885 run_test 162a "path lookup sanity"
17888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17889 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17892 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17893 error "create striped dir failed"
17895 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
17896 tail -n 1 | awk '{print $2}')
17897 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
17899 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
17900 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
17903 for ((i=0;i<5;i++)); do
17904 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
17905 error "get fid for f$i failed"
17906 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
17908 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
17909 error "get fid for d$i failed"
17910 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
17915 run_test 162b "striped directory path lookup sanity"
17917 # LU-4239: Verify fid2path works with paths 100 or more directories deep
17919 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
17920 skip "Need MDS version at least 2.7.51"
17922 local lpath=$tdir.local
17923 local rpath=$tdir.remote
17925 test_mkdir $DIR/$lpath
17926 test_mkdir $DIR/$rpath
17928 for ((i = 0; i <= 101; i++)); do
17931 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
17932 error "get fid for local directory $DIR/$lpath failed"
17933 check_path "$DIR/$lpath" $MOUNT $FID --link 0
17936 test_mkdir $DIR/$rpath
17937 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
17938 error "get fid for remote directory $DIR/$rpath failed"
17939 check_path "$DIR/$rpath" $MOUNT $FID --link 0
17944 run_test 162c "fid2path works with paths 100 or more directories deep"
17946 oalr_event_count() {
17950 awk -v name="${FSNAME}-OST0000" \
17951 -v event="${event}" \
17952 '$1 == "TRACE" && $2 == event && $3 == name' \
17957 oalr_expect_event_count() {
17960 local expect="${3}"
17963 count=$(oalr_event_count "${event}" "${trace}")
17964 if ((count == expect)); then
17968 error_noexit "${event} event count was '${count}', expected ${expect}"
17974 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
17976 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
17980 sync # Flush previous IOs so we can count log entries.
17981 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
17982 stack_trap cleanup_165 EXIT
17986 local trace="/tmp/${tfile}.trace"
17990 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17991 skip "OFD access log unsupported"
17994 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17997 do_facet ost1 ofd_access_log_reader --list
18000 do_facet ost1 killall -TERM ofd_access_log_reader
18004 if ((rc != 0)); then
18005 error "ofd_access_log_reader exited with rc = '${rc}'"
18008 # Parse trace file for discovery events:
18009 oalr_expect_event_count alr_log_add "${trace}" 1
18010 oalr_expect_event_count alr_log_eof "${trace}" 1
18011 oalr_expect_event_count alr_log_free "${trace}" 1
18013 run_test 165a "ofd access log discovery"
18016 local trace="/tmp/${tfile}.trace"
18017 local file="${DIR}/${tfile}"
18026 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18027 skip "OFD access log unsupported"
18030 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18033 do_facet ost1 ofd_access_log_reader --list
18035 lfs setstripe -c 1 -i 0 "${file}"
18036 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18037 error "cannot create '${file}'"
18040 do_facet ost1 killall -TERM ofd_access_log_reader
18044 if ((rc != 0)); then
18045 error "ofd_access_log_reader exited with rc = '${rc}'"
18048 oalr_expect_event_count alr_log_entry "${trace}" 1
18050 pfid1=$($LFS path2fid "${file}")
18052 # 1 2 3 4 5 6 7 8 9 10
18053 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
18054 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
18056 echo "entry = '${entry[*]}'" >&2
18059 if [[ "${pfid1}" != "${pfid2}" ]]; then
18060 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
18064 if ((size != 1048576)); then
18065 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
18069 if [[ "${flags}" != "w" ]]; then
18070 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
18073 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18076 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
18077 error "cannot read '${file}'"
18080 do_facet ost1 killall -TERM ofd_access_log_reader
18084 if ((rc != 0)); then
18085 error "ofd_access_log_reader exited with rc = '${rc}'"
18088 oalr_expect_event_count alr_log_entry "${trace}" 1
18090 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
18091 echo "entry = '${entry[*]}'" >&2
18094 if [[ "${pfid1}" != "${pfid2}" ]]; then
18095 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
18099 if ((size != 524288)); then
18100 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
18104 if [[ "${flags}" != "r" ]]; then
18105 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
18108 run_test 165b "ofd access log entries are produced and consumed"
18111 local trace="/tmp/${tfile}.trace"
18112 local file="${DIR}/${tdir}/${tfile}"
18114 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18115 skip "OFD access log unsupported"
18117 test_mkdir "${DIR}/${tdir}"
18120 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18123 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
18125 # 4096 / 64 = 64. Create twice as many entries.
18126 for ((i = 0; i < 128; i++)); do
18127 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
18128 error "cannot create file"
18133 do_facet ost1 killall -TERM ofd_access_log_reader
18136 if ((rc != 0)); then
18137 error "ofd_access_log_reader exited with rc = '${rc}'"
18140 unlinkmany "${file}-%d" 128
18142 run_test 165c "full ofd access logs do not block IOs"
18144 oal_get_read_count() {
18147 # STATS lustre-OST0001 alr_read_count 1
18149 do_facet ost1 cat "${stats}" |
18150 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
18151 END { print count; }'
18154 oal_expect_read_count() {
18159 # Ask ofd_access_log_reader to write stats.
18160 do_facet ost1 killall -USR1 ofd_access_log_reader
18162 # Allow some time for things to happen.
18165 count=$(oal_get_read_count "${stats}")
18166 if ((count == expect)); then
18170 error_noexit "bad read count, got ${count}, expected ${expect}"
18171 do_facet ost1 cat "${stats}" >&2
18176 local stats="/tmp/${tfile}.stats"
18177 local file="${DIR}/${tdir}/${tfile}"
18178 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
18180 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18181 skip "OFD access log unsupported"
18183 test_mkdir "${DIR}/${tdir}"
18186 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
18189 lfs setstripe -c 1 -i 0 "${file}"
18191 do_facet ost1 lctl set_param "${param}=rw"
18192 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18193 error "cannot create '${file}'"
18194 oal_expect_read_count "${stats}" 1
18196 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18197 error "cannot read '${file}'"
18198 oal_expect_read_count "${stats}" 2
18200 do_facet ost1 lctl set_param "${param}=r"
18201 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18202 error "cannot create '${file}'"
18203 oal_expect_read_count "${stats}" 2
18205 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18206 error "cannot read '${file}'"
18207 oal_expect_read_count "${stats}" 3
18209 do_facet ost1 lctl set_param "${param}=w"
18210 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18211 error "cannot create '${file}'"
18212 oal_expect_read_count "${stats}" 4
18214 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18215 error "cannot read '${file}'"
18216 oal_expect_read_count "${stats}" 4
18218 do_facet ost1 lctl set_param "${param}=0"
18219 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18220 error "cannot create '${file}'"
18221 oal_expect_read_count "${stats}" 4
18223 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18224 error "cannot read '${file}'"
18225 oal_expect_read_count "${stats}" 4
18227 do_facet ost1 killall -TERM ofd_access_log_reader
18230 if ((rc != 0)); then
18231 error "ofd_access_log_reader exited with rc = '${rc}'"
18234 run_test 165d "ofd_access_log mask works"
18237 local stats="/tmp/${tfile}.stats"
18238 local file0="${DIR}/${tdir}-0/${tfile}"
18239 local file1="${DIR}/${tdir}-1/${tfile}"
18241 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18242 skip "OFD access log unsupported"
18244 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
18246 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
18247 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
18249 lfs setstripe -c 1 -i 0 "${file0}"
18250 lfs setstripe -c 1 -i 0 "${file1}"
18253 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
18256 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
18257 error "cannot create '${file0}'"
18259 oal_expect_read_count "${stats}" 0
18261 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
18262 error "cannot create '${file1}'"
18264 oal_expect_read_count "${stats}" 1
18266 do_facet ost1 killall -TERM ofd_access_log_reader
18269 if ((rc != 0)); then
18270 error "ofd_access_log_reader exited with rc = '${rc}'"
18273 run_test 165e "ofd_access_log MDT index filter works"
18276 local trace="/tmp/${tfile}.trace"
18281 do_facet ost1 timeout 60 ofd_access_log_reader \
18282 --exit-on-close --debug=- --trace=- > "${trace}" &
18289 if ((rc != 0)); then
18290 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
18295 run_test 165f "ofd_access_log_reader --exit-on-close works"
18298 # do directio so as not to populate the page cache
18299 log "creating a 10 Mb file"
18300 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
18301 error "multiop failed while creating a file"
18302 log "starting reads"
18303 dd if=$DIR/$tfile of=/dev/null bs=4096 &
18304 log "truncating the file"
18305 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
18306 error "multiop failed while truncating the file"
18308 kill %+ || true # reads might have finished
18309 echo "wait until dd is finished"
18311 log "removing the temporary file"
18312 rm -rf $DIR/$tfile || error "tmp file removal failed"
18314 run_test 169 "parallel read and truncate should not deadlock"
18317 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18319 $LCTL clear # bug 18514
18320 $LCTL debug_daemon start $TMP/${tfile}_log_good
18322 $LCTL debug_daemon stop
18323 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
18324 error "sed failed to read log_good"
18326 $LCTL debug_daemon start $TMP/${tfile}_log_good
18328 $LCTL debug_daemon stop
18330 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
18331 error "lctl df log_bad failed"
18333 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
18334 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
18336 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
18337 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
18339 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
18340 error "bad_line good_line1 good_line2 are empty"
18342 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
18343 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
18344 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
18346 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
18347 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
18348 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
18350 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
18351 error "bad_line_new good_line_new are empty"
18353 local expected_good=$((good_line1 + good_line2*2))
18355 rm -f $TMP/${tfile}*
18356 # LU-231, short malformed line may not be counted into bad lines
18357 if [ $bad_line -ne $bad_line_new ] &&
18358 [ $bad_line -ne $((bad_line_new - 1)) ]; then
18359 error "expected $bad_line bad lines, but got $bad_line_new"
18363 if [ $expected_good -ne $good_line_new ]; then
18364 error "expected $expected_good good lines, but got $good_line_new"
18369 run_test 170 "test lctl df to handle corrupted log ====================="
18371 test_171() { # bug20592
18372 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18374 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
18375 $LCTL set_param fail_loc=0x50e
18376 $LCTL set_param fail_val=3000
18377 multiop_bg_pause $DIR/$tfile O_s || true
18379 kill -USR1 $MULTIPID
18383 if dmesg | grep "recursive fault"; then
18384 error "caught a recursive fault"
18386 $LCTL set_param fail_loc=0
18389 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
18393 #define OBD_FAIL_OBD_CLEANUP 0x60e
18394 $LCTL set_param fail_loc=0x60e
18395 umount $MOUNT || error "umount $MOUNT failed"
18396 stack_trap "mount_client $MOUNT"
18398 (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )) ||
18399 error "no client OBDs are remained"
18401 $LCTL dl | while read devno state type name foo; do
18404 $LCTL --device $name cleanup
18405 $LCTL --device $name detach
18408 # skip server devices
18413 if (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )); then
18414 $LCTL dl | egrep " osc | lov | lmv | mdc "
18415 error "some client OBDs are still remained"
18419 run_test 172 "manual device removal with lctl cleanup/detach ======"
18421 # it would be good to share it with obdfilter-survey/iokit-libecho code
18422 setup_obdecho_osc () {
18425 local obdfilter_name=$2
18426 echo "Creating new osc for $obdfilter_name on $ost_nid"
18427 # make sure we can find loopback nid
18428 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
18430 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
18431 ${obdfilter_name}_osc_UUID || rc=2; }
18432 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
18433 ${obdfilter_name}_UUID $ost_nid || rc=3; }
18437 cleanup_obdecho_osc () {
18438 local obdfilter_name=$1
18439 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
18440 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
18447 local pages=${3:-64}
18452 local obd_size=$(get_obd_size $node $OBD)
18453 local page_size=$(get_page_size $node)
18454 if [[ -n "$obd_size" ]]; then
18455 local new_count=$((obd_size / (pages * page_size / 1024)))
18456 [[ $new_count -ge $count ]] || count=$new_count
18459 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
18460 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
18462 if [ $rc -eq 0 ]; then
18463 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
18464 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
18466 echo "New object id is $id"
18467 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
18469 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
18470 "test_brw $count w v $pages $id" || rc=4; }
18471 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
18473 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
18474 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
18475 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
18476 { do_facet $node "$LCTL --device ec detach" || rc=6; }
18477 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
18482 skip "obdecho on osc is no longer supported"
18484 run_test 180a "test obdecho on osc"
18487 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18488 remote_ost_nodsh && skip "remote OST with nodsh"
18490 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
18491 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
18492 error "failed to load module obdecho"
18494 local target=$(do_facet ost1 $LCTL dl |
18495 awk '/obdfilter/ { print $4; exit; }')
18497 if [ -n "$target" ]; then
18498 obdecho_test $target ost1 || error "obdecho_test failed with $?"
18500 do_facet ost1 $LCTL dl
18501 error "there is no obdfilter target on ost1"
18504 run_test 180b "test obdecho directly on obdfilter"
18506 test_180c() { # LU-2598
18507 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18508 remote_ost_nodsh && skip "remote OST with nodsh"
18509 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
18510 skip "Need MDS version at least 2.4.0"
18512 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
18513 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
18514 error "failed to load module obdecho"
18516 local target=$(do_facet ost1 $LCTL dl |
18517 awk '/obdfilter/ { print $4; exit; }')
18519 if [ -n "$target" ]; then
18520 local pages=16384 # 64MB bulk I/O RPC size
18522 obdecho_test "$target" ost1 "$pages" ||
18523 error "obdecho_test with pages=$pages failed with $?"
18525 do_facet ost1 $LCTL dl
18526 error "there is no obdfilter target on ost1"
18529 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
18531 test_181() { # bug 22177
18532 test_mkdir $DIR/$tdir
18533 # create enough files to index the directory
18534 createmany -o $DIR/$tdir/foobar 4000
18535 # print attributes for debug purpose
18538 multiop_bg_pause $DIR/$tdir D_Sc || return 1
18540 # remove the files & current working dir
18541 unlinkmany $DIR/$tdir/foobar 4000
18543 kill -USR1 $MULTIPID
18545 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
18548 run_test 181 "Test open-unlinked dir ========================"
18554 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18556 $LCTL set_param mdc.*.rpc_stats=clear
18558 for (( i = 0; i < $tcount; i++ )) ; do
18559 mkdir $DIR/$tdir/$i
18562 for (( i = 0; i < $tcount; i++ )) ; do
18563 createmany -o $DIR/$tdir/$i/f- $fcount &
18567 for (( i = 0; i < $tcount; i++ )) ; do
18568 unlinkmany $DIR/$tdir/$i/f- $fcount &
18572 $LCTL get_param mdc.*.rpc_stats
18576 run_test 182a "Test parallel modify metadata operations from mdc"
18579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18580 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
18587 do_facet mds1 $LCTL list_param \
18588 osp.$FSNAME-MDT*-osp-MDT*.rpc_stats ||
18589 skip "MDS lacks parallel RPC handling"
18591 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18593 rpc_count=$(do_facet mds1 $LCTL get_param -n \
18594 osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight)
18597 createmany -i 0 -d $DIR/$tdir/t- $tcount
18599 for (( i = 0; i < $tcount; i++ )) ; do
18600 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18604 delta=$((etime - stime))
18605 echo "Time for file creation $delta sec for $rpc_count parallel RPCs"
18608 for (( i = 0; i < $tcount; i++ )) ; do
18609 unlinkmany -d $DIR/$tdir/$i/d- $dcount &
18613 delta=$((etime - stime))
18614 echo "Time for file removal $delta sec for $rpc_count parallel RPCs"
18618 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18620 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=1
18623 createmany -i 0 -d $DIR/$tdir/t- $tcount
18625 for (( i = 0; i < $tcount; i++ )) ; do
18626 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18630 delta=$((etime - stime))
18631 echo "Time for file creation $delta sec for 1 RPC sent at a time"
18634 for (( i = 0; i < $tcount; i++ )) ; do
18635 unlinkmany -d $DIR/$tdir/t-$i/d- $dcount &
18639 delta=$((etime - stime))
18640 echo "Time for file removal $delta sec for 1 RPC sent at a time"
18642 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=$rpc_count
18644 run_test 182b "Test parallel modify metadata operations from osp"
18646 test_183() { # LU-2275
18647 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18648 remote_mds_nodsh && skip "remote MDS with nodsh"
18649 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
18650 skip "Need MDS version at least 2.3.56"
18652 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18653 echo aaa > $DIR/$tdir/$tfile
18655 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
18656 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
18658 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
18659 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
18661 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
18663 # Flush negative dentry cache
18664 touch $DIR/$tdir/$tfile
18666 # We are not checking for any leaked references here, they'll
18667 # become evident next time we do cleanup with module unload.
18670 run_test 183 "No crash or request leak in case of strange dispositions ========"
18672 # test suite 184 is for LU-2016, LU-2017
18674 check_swap_layouts_support
18676 dir0=$DIR/$tdir/$testnum
18677 test_mkdir -p -c1 $dir0
18682 $LFS setstripe -c1 $file1
18684 $LFS setstripe -c2 $file2
18686 gen1=$($LFS getstripe -g $file1)
18687 gen2=$($LFS getstripe -g $file2)
18689 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
18690 gen=$($LFS getstripe -g $file1)
18691 [[ $gen1 != $gen ]] ||
18692 error "Layout generation on $file1 does not change"
18693 gen=$($LFS getstripe -g $file2)
18694 [[ $gen2 != $gen ]] ||
18695 error "Layout generation on $file2 does not change"
18697 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
18698 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
18700 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
18702 run_test 184a "Basic layout swap"
18705 check_swap_layouts_support
18707 dir0=$DIR/$tdir/$testnum
18708 mkdir -p $dir0 || error "creating dir $dir0"
18715 $LFS setstripe -c1 $file1
18716 $LFS setstripe -c2 $file2
18717 $LFS setstripe -c1 $file3
18718 chown $RUNAS_ID $file3
18719 gen1=$($LFS getstripe -g $file1)
18720 gen2=$($LFS getstripe -g $file2)
18722 $LFS swap_layouts $dir1 $dir2 &&
18723 error "swap of directories layouts should fail"
18724 $LFS swap_layouts $dir1 $file1 &&
18725 error "swap of directory and file layouts should fail"
18726 $RUNAS $LFS swap_layouts $file1 $file2 &&
18727 error "swap of file we cannot write should fail"
18728 $LFS swap_layouts $file1 $file3 &&
18729 error "swap of file with different owner should fail"
18730 /bin/true # to clear error code
18732 run_test 184b "Forbidden layout swap (will generate errors)"
18735 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
18736 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
18737 check_swap_layouts_support
18738 check_swap_layout_no_dom $DIR
18740 local dir0=$DIR/$tdir/$testnum
18741 mkdir -p $dir0 || error "creating dir $dir0"
18743 local ref1=$dir0/ref1
18744 local ref2=$dir0/ref2
18745 local file1=$dir0/file1
18746 local file2=$dir0/file2
18747 # create a file large enough for the concurrent test
18748 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
18749 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
18750 echo "ref file size: ref1($(stat -c %s $ref1))," \
18751 "ref2($(stat -c %s $ref2))"
18754 dd if=$ref1 of=$file1 bs=16k &
18757 # Make sure dd starts to copy file, but wait at most 5 seconds
18759 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
18761 $LFS swap_layouts $file1 $file2
18764 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
18765 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
18767 # how many bytes copied before swapping layout
18768 local copied=$(stat -c %s $file2)
18769 local remaining=$(stat -c %s $ref1)
18770 remaining=$((remaining - copied))
18771 echo "Copied $copied bytes before swapping layout..."
18773 cmp -n $copied $file1 $ref2 | grep differ &&
18774 error "Content mismatch [0, $copied) of ref2 and file1"
18775 cmp -n $copied $file2 $ref1 ||
18776 error "Content mismatch [0, $copied) of ref1 and file2"
18777 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
18778 error "Content mismatch [$copied, EOF) of ref1 and file1"
18781 rm -f $ref1 $ref2 $file1 $file2
18783 run_test 184c "Concurrent write and layout swap"
18786 check_swap_layouts_support
18787 check_swap_layout_no_dom $DIR
18788 [ -z "$(which getfattr 2>/dev/null)" ] &&
18789 skip_env "no getfattr command"
18791 local file1=$DIR/$tdir/$tfile-1
18792 local file2=$DIR/$tdir/$tfile-2
18793 local file3=$DIR/$tdir/$tfile-3
18797 mkdir -p $DIR/$tdir
18798 touch $file1 || error "create $file1 failed"
18799 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18800 error "create $file2 failed"
18801 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18802 error "create $file3 failed"
18803 lovea1=$(get_layout_param $file1)
18805 $LFS swap_layouts $file2 $file3 ||
18806 error "swap $file2 $file3 layouts failed"
18807 $LFS swap_layouts $file1 $file2 ||
18808 error "swap $file1 $file2 layouts failed"
18810 lovea2=$(get_layout_param $file2)
18813 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
18815 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18816 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
18818 run_test 184d "allow stripeless layouts swap"
18821 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
18822 skip "Need MDS version at least 2.6.94"
18823 check_swap_layouts_support
18824 check_swap_layout_no_dom $DIR
18825 [ -z "$(which getfattr 2>/dev/null)" ] &&
18826 skip_env "no getfattr command"
18828 local file1=$DIR/$tdir/$tfile-1
18829 local file2=$DIR/$tdir/$tfile-2
18830 local file3=$DIR/$tdir/$tfile-3
18833 mkdir -p $DIR/$tdir
18834 touch $file1 || error "create $file1 failed"
18835 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18836 error "create $file2 failed"
18837 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18838 error "create $file3 failed"
18840 $LFS swap_layouts $file1 $file2 ||
18841 error "swap $file1 $file2 layouts failed"
18843 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18844 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
18846 echo 123 > $file1 || error "Should be able to write into $file1"
18848 $LFS swap_layouts $file1 $file3 ||
18849 error "swap $file1 $file3 layouts failed"
18851 echo 123 > $file1 || error "Should be able to write into $file1"
18853 rm -rf $file1 $file2 $file3
18855 run_test 184e "Recreate layout after stripeless layout swaps"
18858 # Create a file with name longer than sizeof(struct stat) ==
18859 # 144 to see if we can get chars from the file name to appear
18860 # in the returned striping. Note that 'f' == 0x66.
18861 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
18863 mkdir -p $DIR/$tdir
18864 mcreate $DIR/$tdir/$file
18865 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
18866 error "IOC_MDC_GETFILEINFO returned garbage striping"
18869 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
18871 test_185() { # LU-2441
18872 # LU-3553 - no volatile file support in old servers
18873 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
18874 skip "Need MDS version at least 2.3.60"
18876 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18877 touch $DIR/$tdir/spoo
18878 local mtime1=$(stat -c "%Y" $DIR/$tdir)
18879 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
18880 error "cannot create/write a volatile file"
18881 [ "$FILESET" == "" ] &&
18882 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
18883 error "FID is still valid after close"
18885 multiop_bg_pause $DIR/$tdir vVw4096_c
18892 # assume that the next FID for this client is sequential, since stdout
18893 # is unfortunately eaten by multiop_bg_pause
18894 local n=$((${fidv[1]} + 1))
18895 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
18896 if [ "$FILESET" == "" ]; then
18897 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
18898 error "FID is missing before close"
18900 kill -USR1 $multi_pid
18901 # 1 second delay, so if mtime change we will see it
18903 local mtime2=$(stat -c "%Y" $DIR/$tdir)
18904 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
18906 run_test 185 "Volatile file support"
18908 function create_check_volatile() {
18912 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
18915 local FID=$(cat /tmp/${tfile}.fid)
18916 [ "$FID" == "" ] && error "can't get FID for volatile"
18917 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
18918 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
18919 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
18923 cancel_lru_locks mdc # flush opencache
18924 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
18929 # LU-12516 - volatile creation via .lustre
18930 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
18931 skip "Need MDS version at least 2.3.55"
18933 create_check_volatile 0
18934 [ $MDSCOUNT -lt 2 ] && return 0
18937 create_check_volatile 1
18941 run_test 185a "Volatile file creation in .lustre/fid/"
18944 remote_mds_nodsh && skip "remote MDS with nodsh"
18945 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18946 skip "Need MDS version at least 2.3.0"
18948 local dir0=$DIR/$tdir/$testnum
18949 mkdir -p $dir0 || error "creating dir $dir0"
18951 local file=$dir0/file1
18952 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
18953 local dv1=$($LFS data_version $file)
18954 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
18955 local dv2=$($LFS data_version $file)
18956 [[ $dv1 != $dv2 ]] ||
18957 error "data version did not change on write $dv1 == $dv2"
18962 run_test 187a "Test data version change"
18965 remote_mds_nodsh && skip "remote MDS with nodsh"
18966 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18967 skip "Need MDS version at least 2.3.0"
18969 local dir0=$DIR/$tdir/$testnum
18970 mkdir -p $dir0 || error "creating dir $dir0"
18972 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
18973 [[ ${DV[0]} != ${DV[1]} ]] ||
18974 error "data version did not change on write"\
18975 " ${DV[0]} == ${DV[1]}"
18980 run_test 187b "Test data version change on volatile file"
18983 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18984 remote_mgs_nodsh && skip "remote MGS with nodsh"
18985 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
18987 local POOL=${POOL:-cea1}
18988 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
18989 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
18992 local last_ost=$(($OSTCOUNT - 1))
18994 local ost_list=$(seq $first_ost $ost_step $last_ost)
18995 local ost_range="$first_ost $last_ost $ost_step"
18996 local test_path=$POOL_ROOT/$POOL_DIR_NAME
18997 local file_dir=$POOL_ROOT/file_tst
18998 local subdir=$test_path/subdir
19002 # former test_200a test_200b
19003 pool_add $POOL || { rc=$? ; break; }
19004 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
19005 # former test_200c test_200d
19006 mkdir -p $test_path
19007 pool_set_dir $POOL $test_path || { rc=$? ; break; }
19008 pool_check_dir $POOL $test_path || { rc=$? ; break; }
19010 pool_check_dir $POOL $subdir || { rc=$? ; break; }
19011 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
19012 || { rc=$? ; break; }
19013 # former test_200e test_200f
19014 local files=$((OSTCOUNT*3))
19015 pool_alloc_files $POOL $test_path $files "$ost_list" \
19016 || { rc=$? ; break; }
19017 pool_create_files $POOL $file_dir $files "$ost_list" \
19018 || { rc=$? ; break; }
19019 # former test_200g test_200h
19020 pool_lfs_df $POOL || { rc=$? ; break; }
19021 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
19023 # former test_201a test_201b test_201c
19024 pool_remove_first_target $POOL || { rc=$? ; break; }
19026 local f=$test_path/$tfile
19027 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
19028 pool_remove $POOL $f || { rc=$? ; break; }
19036 run_test 200 "OST pools"
19038 # usage: default_attr <count | size | offset>
19040 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
19043 # usage: check_default_stripe_attr
19044 check_default_stripe_attr() {
19045 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
19048 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
19050 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
19054 error "unknown getstripe attr '$1'"
19057 [ $ACTUAL == $EXPECTED ] ||
19058 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
19062 test_mkdir $DIR/$tdir
19063 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
19065 check_default_stripe_attr --stripe-count
19066 check_default_stripe_attr --stripe-size
19067 check_default_stripe_attr --stripe-index
19069 run_test 204a "Print default stripe attributes"
19072 test_mkdir $DIR/$tdir
19073 $LFS setstripe --stripe-count 1 $DIR/$tdir
19075 check_default_stripe_attr --stripe-size
19076 check_default_stripe_attr --stripe-index
19078 run_test 204b "Print default stripe size and offset"
19081 test_mkdir $DIR/$tdir
19082 $LFS setstripe --stripe-size 65536 $DIR/$tdir
19084 check_default_stripe_attr --stripe-count
19085 check_default_stripe_attr --stripe-index
19087 run_test 204c "Print default stripe count and offset"
19090 test_mkdir $DIR/$tdir
19091 $LFS setstripe --stripe-index 0 $DIR/$tdir
19093 check_default_stripe_attr --stripe-count
19094 check_default_stripe_attr --stripe-size
19096 run_test 204d "Print default stripe count and size"
19099 test_mkdir $DIR/$tdir
19100 $LFS setstripe -d $DIR/$tdir
19102 check_default_stripe_attr --stripe-count --raw
19103 check_default_stripe_attr --stripe-size --raw
19104 check_default_stripe_attr --stripe-index --raw
19106 run_test 204e "Print raw stripe attributes"
19109 test_mkdir $DIR/$tdir
19110 $LFS setstripe --stripe-count 1 $DIR/$tdir
19112 check_default_stripe_attr --stripe-size --raw
19113 check_default_stripe_attr --stripe-index --raw
19115 run_test 204f "Print raw stripe size and offset"
19118 test_mkdir $DIR/$tdir
19119 $LFS setstripe --stripe-size 65536 $DIR/$tdir
19121 check_default_stripe_attr --stripe-count --raw
19122 check_default_stripe_attr --stripe-index --raw
19124 run_test 204g "Print raw stripe count and offset"
19127 test_mkdir $DIR/$tdir
19128 $LFS setstripe --stripe-index 0 $DIR/$tdir
19130 check_default_stripe_attr --stripe-count --raw
19131 check_default_stripe_attr --stripe-size --raw
19133 run_test 204h "Print raw stripe count and size"
19135 # Figure out which job scheduler is being used, if any,
19136 # or use a fake one
19137 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
19138 JOBENV=SLURM_JOB_ID
19139 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
19141 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
19143 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
19144 JOBENV=LOADL_STEP_ID
19145 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
19148 $LCTL list_param jobid_name > /dev/null 2>&1
19149 if [ $? -eq 0 ]; then
19155 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
19157 verify_jobstats() {
19162 # we don't really need to clear the stats for this test to work, since each
19163 # command has a unique jobid, but it makes debugging easier if needed.
19164 # for facet in $facets; do
19165 # local dev=$(convert_facet2label $facet)
19166 # # clear old jobstats
19167 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
19170 # use a new JobID for each test, or we might see an old one
19171 [ "$JOBENV" = "FAKE_JOBID" ] &&
19172 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
19174 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
19176 [ "$JOBENV" = "nodelocal" ] && {
19177 FAKE_JOBID=id.$testnum.%e.$RANDOM
19178 $LCTL set_param jobid_name=$FAKE_JOBID
19179 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
19182 log "Test: ${cmd[*]}"
19183 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
19185 if [ $JOBENV = "FAKE_JOBID" ]; then
19186 FAKE_JOBID=$JOBVAL ${cmd[*]}
19191 # all files are created on OST0000
19192 for facet in $facets; do
19193 local stats="*.$(convert_facet2label $facet).job_stats"
19195 # strip out libtool wrappers for in-tree executables
19196 if (( $(do_facet $facet lctl get_param $stats |
19197 sed -e 's/\.lt-/./' | grep -cw $JOBVAL) != 1 )); then
19198 do_facet $facet lctl get_param $stats
19199 error "No jobstats for $JOBVAL found on $facet::$stats"
19205 local new_jobenv=$1
19207 set_persistent_param_and_check client "jobid_var" \
19208 "$FSNAME.sys.jobid_var" $new_jobenv
19211 test_205a() { # Job stats
19212 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19213 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
19214 skip "Need MDS version with at least 2.7.1"
19215 remote_mgs_nodsh && skip "remote MGS with nodsh"
19216 remote_mds_nodsh && skip "remote MDS with nodsh"
19217 remote_ost_nodsh && skip "remote OST with nodsh"
19218 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
19219 skip "Server doesn't support jobstats"
19220 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
19222 local old_jobenv=$($LCTL get_param -n jobid_var)
19223 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
19225 if [[ $PERM_CMD == *"set_param -P"* ]]; then
19226 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
19228 stack_trap "do_facet mgs $PERM_CMD \
19229 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
19233 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
19234 mdt.*.job_cleanup_interval | head -n 1)
19235 local new_interval=5
19236 do_facet $SINGLEMDS \
19237 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
19238 stack_trap "do_facet $SINGLEMDS \
19239 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
19240 local start=$SECONDS
19244 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
19245 verify_jobstats "$cmd" "$SINGLEMDS"
19247 cmd="rmdir $DIR/$tdir"
19248 verify_jobstats "$cmd" "$SINGLEMDS"
19249 # mkdir on secondary MDT
19250 if [ $MDSCOUNT -gt 1 ]; then
19251 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
19252 verify_jobstats "$cmd" "mds2"
19255 cmd="mknod $DIR/$tfile c 1 3"
19256 verify_jobstats "$cmd" "$SINGLEMDS"
19258 cmd="rm -f $DIR/$tfile"
19259 verify_jobstats "$cmd" "$SINGLEMDS"
19260 # create all files on OST0000 so verify_jobstats can find OST stats
19262 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
19263 verify_jobstats "$cmd" "$SINGLEMDS"
19265 cmd="touch $DIR/$tfile"
19266 verify_jobstats "$cmd" "$SINGLEMDS ost1"
19268 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
19269 verify_jobstats "$cmd" "ost1"
19271 cancel_lru_locks osc
19272 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
19273 verify_jobstats "$cmd" "ost1"
19275 cmd="$TRUNCATE $DIR/$tfile 0"
19276 verify_jobstats "$cmd" "$SINGLEMDS ost1"
19278 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
19279 verify_jobstats "$cmd" "$SINGLEMDS"
19280 # jobstats expiry - sleep until old stats should be expired
19281 local left=$((new_interval + 5 - (SECONDS - start)))
19282 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
19283 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
19285 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
19286 verify_jobstats "$cmd" "$SINGLEMDS"
19287 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
19288 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
19290 # Ensure that jobid are present in changelog (if supported by MDS)
19291 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
19292 changelog_dump | tail -10
19293 jobids=$(changelog_dump | tail -9 | grep -c "j=")
19294 [ $jobids -eq 9 ] ||
19295 error "Wrong changelog jobid count $jobids != 9"
19299 jobstats_set $JOBENV
19301 changelog_dump | grep $tfile
19302 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
19303 [ $jobids -eq 0 ] ||
19304 error "Unexpected jobids when jobid_var=$JOBENV"
19307 # test '%j' access to environment variable - if supported
19308 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
19309 JOBENV="JOBCOMPLEX"
19310 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
19312 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19315 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
19316 JOBENV="JOBCOMPLEX"
19317 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
19319 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19322 # test '%j' access to per-session jobid - if supported
19323 if lctl list_param jobid_this_session > /dev/null 2>&1
19325 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
19326 lctl set_param jobid_this_session=$USER
19328 JOBENV="JOBCOMPLEX"
19329 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
19331 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19334 run_test 205a "Verify job stats"
19336 # LU-13117, LU-13597
19338 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
19339 skip "Need MDS version at least 2.13.54.91"
19341 local job_stats="mdt.*.job_stats"
19342 local old_jobid=$(do_facet mds1 $LCTL get_param jobid_var)
19344 do_facet mds1 $LCTL set_param $job_stats=clear
19346 # Setting jobid_var to USER might not be supported
19347 [[ -n "$old_jobid" ]] && stack_trap "$LCTL set_param $old_jobid"
19348 $LCTL set_param jobid_var=USER || true
19349 stack_trap "$LCTL set_param $($LCTL get_param jobid_name)"
19350 $LCTL set_param jobid_name="%j.%e.%u"
19352 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
19353 do_facet mds1 $LCTL get_param $job_stats | grep "job_id:.*foolish" &&
19354 { do_facet mds1 $LCTL get_param $job_stats;
19355 error "Unexpected jobid found"; }
19356 do_facet mds1 $LCTL get_param $job_stats | grep "open:.*min.*max.*sum"||
19357 { do_facet mds1 $LCTL get_param $job_stats;
19358 error "wrong job_stats format found"; }
19360 (( $MDS1_VERSION <= $(version_code 2.15.0) )) &&
19361 echo "MDS does not yet escape jobid" && return 0
19362 $LCTL set_param jobid_var=TEST205b
19363 env -i TEST205b="has sp" touch $DIR/$tfile.2
19364 do_facet mds1 $LCTL get_param $job_stats | grep "has.*x20sp" ||
19365 { do_facet mds1 $LCTL get_param $job_stats;
19366 error "jobid not escaped"; }
19368 run_test 205b "Verify job stats jobid and output format"
19372 $LCTL set_param llite.*.stats=0
19373 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
19374 $LCTL get_param llite.*.stats
19375 $LCTL get_param llite.*.stats | grep \
19376 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
19377 error "wrong client stats format found"
19379 run_test 205c "Verify client stats format"
19382 local file=$DIR/$tdir/$tfile
19384 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
19385 skip "need lustre >= 2.15.53 for lljobstat"
19386 (( $OST1_VERSION >= $(version_code 2.15.53) )) ||
19387 skip "need lustre >= 2.15.53 for lljobstat"
19388 verify_yaml_available || skip_env "YAML verification not installed"
19390 test_mkdir -i 0 $DIR/$tdir
19391 $LFS setstripe -E 1M -L mdt -E -1 $file || error "create file failed"
19393 dd if=/dev/zero of=$file bs=1M count=10 conv=sync ||
19394 error "failed to write data to $file"
19397 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats"
19398 echo -n 'verify rename_stats...'
19399 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats" |
19400 verify_yaml || error "rename_stats is not valid YAML"
19403 echo -n 'verify mdt job_stats...'
19404 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.job_stats" |
19405 verify_yaml || error "job_stats on mds1 is not valid YAML"
19408 echo -n 'verify ost job_stats...'
19409 do_facet ost1 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.job_stats" |
19410 verify_yaml || error "job_stats on ost1 is not valid YAML"
19413 run_test 205d "verify the format of some stats files"
19417 local file=$DIR/$tdir/$tfile
19419 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
19420 skip "need lustre >= 2.15.53 for lljobstat"
19421 (( $OST1_VERSION >= $(version_code 2.15.53) )) ||
19422 skip "need lustre >= 2.15.53 for lljobstat"
19423 verify_yaml_available || skip_env "YAML verification not installed"
19425 mkdir_on_mdt0 $DIR/$tdir || error "failed to create dir"
19427 $LFS setstripe -E EOF -i 0 -c 1 $file ||
19428 error "failed to create $file on ost1"
19429 dd if=/dev/zero of=$file bs=1M count=10 oflag=sync ||
19430 error "failed to write data to $file"
19432 do_facet mds1 "$LCTL get_param *.*.job_stats"
19433 do_facet ost1 "$LCTL get_param *.*.job_stats"
19435 do_facet ost1 "lljobstat -n 1 -i 0 -c 1000"
19436 do_facet ost1 "lljobstat -n 1 -i 0 -c 1000" | verify_yaml ||
19437 error "The output of lljobstat is not an valid YAML"
19439 # verify that job dd.0 does exist and has some ops on ost1
19440 # typically this line is like:
19441 # - dd.0: {ops: 20, ...}
19442 ops_comma=$(do_facet ost1 "lljobstat -n 1 -i 0 -c 1000" |
19443 awk '$2=="dd.0:" {print $4}')
19445 (( ${ops_comma%,} >= 10 )) ||
19446 error "cannot find job dd.0 with ops >= 10"
19448 run_test 205e "verify the output of lljobstat"
19450 # LU-1480, LU-1773 and LU-1657
19452 mkdir -p $DIR/$tdir
19453 $LFS setstripe -c -1 $DIR/$tdir
19454 #define OBD_FAIL_LOV_INIT 0x1403
19455 $LCTL set_param fail_loc=0xa0001403
19456 $LCTL set_param fail_val=1
19457 touch $DIR/$tdir/$tfile || true
19459 run_test 206 "fail lov_init_raid0() doesn't lbug"
19462 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
19463 local fsz=`stat -c %s $DIR/$tfile`
19464 cancel_lru_locks mdc
19466 # do not return layout in getattr intent
19467 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
19468 $LCTL set_param fail_loc=0x170
19469 local sz=`stat -c %s $DIR/$tfile`
19471 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
19475 run_test 207a "can refresh layout at glimpse"
19478 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
19479 local cksum=`md5sum $DIR/$tfile`
19480 local fsz=`stat -c %s $DIR/$tfile`
19481 cancel_lru_locks mdc
19482 cancel_lru_locks osc
19484 # do not return layout in getattr intent
19485 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
19486 $LCTL set_param fail_loc=0x171
19488 # it will refresh layout after the file is opened but before read issues
19489 echo checksum is "$cksum"
19490 echo "$cksum" |md5sum -c --quiet || error "file differs"
19494 run_test 207b "can refresh layout at open"
19497 # FIXME: in this test suite, only RD lease is used. This is okay
19498 # for now as only exclusive open is supported. After generic lease
19499 # is done, this test suite should be revised. - Jinshan
19501 remote_mds_nodsh && skip "remote MDS with nodsh"
19502 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
19503 skip "Need MDS version at least 2.4.52"
19505 echo "==== test 1: verify get lease work"
19506 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
19508 echo "==== test 2: verify lease can be broken by upcoming open"
19509 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
19513 $MULTIOP $DIR/$tfile oO_RDWR:c
19514 kill -USR1 $PID && wait $PID || error "break lease error"
19516 echo "==== test 3: verify lease can't be granted if an open already exists"
19517 $MULTIOP $DIR/$tfile oO_RDWR:_c &
19521 $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
19522 kill -USR1 $PID && wait $PID || error "open file error"
19524 echo "==== test 4: lease can sustain over recovery"
19525 $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
19531 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
19533 echo "==== test 5: lease broken can't be regained by replay"
19534 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
19538 # open file to break lease and then recovery
19539 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
19542 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
19546 run_test 208 "Exclusive open"
19549 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
19550 skip_env "must have disp_stripe"
19553 sync; sleep 5; sync;
19555 echo 3 > /proc/sys/vm/drop_caches
19556 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
19557 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
19558 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
19560 # open/close 500 times
19561 for i in $(seq 500); do
19565 echo 3 > /proc/sys/vm/drop_caches
19566 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
19567 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
19568 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
19570 echo "before: $req_before, after: $req_after"
19571 [ $((req_after - req_before)) -ge 300 ] &&
19572 error "open/close requests are not freed"
19575 run_test 209 "read-only open/close requests should be freed promptly"
19580 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
19584 $LFS getstripe $DIR/$tfile
19586 wait $pid || error "multiop failed"
19588 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
19592 $LFS getstripe $DIR/$tfile
19594 wait $pid || error "multiop failed"
19596 run_test 210 "lfs getstripe does not break leases"
19600 size=$((size % 8192 + 1))
19601 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
19602 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
19603 rm -f $DIR/f212 $DIR/f212.xyz
19605 run_test 212 "Sendfile test ============================================"
19608 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
19609 cancel_lru_locks osc
19610 lctl set_param fail_loc=0x8000040f
19611 # generate a read lock
19612 cat $DIR/$tfile > /dev/null
19613 # write to the file, it will try to cancel the above read lock.
19614 cat /etc/hosts >> $DIR/$tfile
19616 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
19618 test_214() { # for bug 20133
19619 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
19620 for (( i=0; i < 340; i++ )) ; do
19621 touch $DIR/$tdir/d214c/a$i
19624 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
19625 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
19626 ls $DIR/d214c || error "ls $DIR/d214c failed"
19627 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
19628 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
19630 run_test 214 "hash-indexed directory test - bug 20133"
19632 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
19633 create_lnet_proc_files() {
19634 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
19637 # counterpart of create_lnet_proc_files
19638 remove_lnet_proc_files() {
19639 rm -f $TMP/lnet_$1.sys
19642 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19643 # 3rd arg as regexp for body
19644 check_lnet_proc_stats() {
19645 local l=$(cat "$TMP/lnet_$1" |wc -l)
19646 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
19648 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
19651 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19652 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
19653 # optional and can be regexp for 2nd line (lnet.routes case)
19654 check_lnet_proc_entry() {
19655 local blp=2 # blp stands for 'position of 1st line of body'
19656 [ -z "$5" ] || blp=3 # lnet.routes case
19658 local l=$(cat "$TMP/lnet_$1" |wc -l)
19659 # subtracting one from $blp because the body can be empty
19660 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
19662 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
19663 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
19665 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
19666 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
19668 # bail out if any unexpected line happened
19669 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
19670 [ "$?" != 0 ] || error "$2 misformatted"
19673 test_215() { # for bugs 18102, 21079, 21517
19674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19676 local N='(0|[1-9][0-9]*)' # non-negative numeric
19677 local P='[1-9][0-9]*' # positive numeric
19678 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
19679 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
19680 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
19681 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
19683 local L1 # regexp for 1st line
19684 local L2 # regexp for 2nd line (optional)
19685 local BR # regexp for the rest (body)
19687 # lnet.stats should look as 11 space-separated non-negative numerics
19688 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
19689 create_lnet_proc_files "stats"
19690 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
19691 remove_lnet_proc_files "stats"
19693 # lnet.routes should look like this:
19694 # Routing disabled/enabled
19695 # net hops priority state router
19696 # where net is a string like tcp0, hops > 0, priority >= 0,
19697 # state is up/down,
19698 # router is a string like 192.168.1.1@tcp2
19699 L1="^Routing (disabled|enabled)$"
19700 L2="^net +hops +priority +state +router$"
19701 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
19702 create_lnet_proc_files "routes"
19703 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
19704 remove_lnet_proc_files "routes"
19706 # lnet.routers should look like this:
19707 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
19708 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
19709 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
19710 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
19711 L1="^ref +rtr_ref +alive +router$"
19712 BR="^$P +$P +(up|down) +$NID$"
19713 create_lnet_proc_files "routers"
19714 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
19715 remove_lnet_proc_files "routers"
19717 # lnet.peers should look like this:
19718 # nid refs state last max rtr min tx min queue
19719 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
19720 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
19721 # numeric (0 or >0 or <0), queue >= 0.
19722 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
19723 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
19724 create_lnet_proc_files "peers"
19725 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
19726 remove_lnet_proc_files "peers"
19728 # lnet.buffers should look like this:
19729 # pages count credits min
19730 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
19731 L1="^pages +count +credits +min$"
19732 BR="^ +$N +$N +$I +$I$"
19733 create_lnet_proc_files "buffers"
19734 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
19735 remove_lnet_proc_files "buffers"
19737 # lnet.nis should look like this:
19738 # nid status alive refs peer rtr max tx min
19739 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
19740 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
19741 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
19742 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
19743 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
19744 create_lnet_proc_files "nis"
19745 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
19746 remove_lnet_proc_files "nis"
19748 # can we successfully write to lnet.stats?
19749 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
19751 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
19753 test_216() { # bug 20317
19754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19755 remote_ost_nodsh && skip "remote OST with nodsh"
19758 local facets=$(get_facets OST)
19759 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19761 save_lustre_params client "osc.*.contention_seconds" > $p
19762 save_lustre_params $facets \
19763 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
19764 save_lustre_params $facets \
19765 "ldlm.namespaces.filter-*.contended_locks" >> $p
19766 save_lustre_params $facets \
19767 "ldlm.namespaces.filter-*.contention_seconds" >> $p
19768 clear_stats osc.*.osc_stats
19770 # agressive lockless i/o settings
19771 do_nodes $(comma_list $(osts_nodes)) \
19772 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
19773 ldlm.namespaces.filter-*.contended_locks=0 \
19774 ldlm.namespaces.filter-*.contention_seconds=60"
19775 lctl set_param -n osc.*.contention_seconds=60
19777 $DIRECTIO write $DIR/$tfile 0 10 4096
19778 $CHECKSTAT -s 40960 $DIR/$tfile
19780 # disable lockless i/o
19781 do_nodes $(comma_list $(osts_nodes)) \
19782 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
19783 ldlm.namespaces.filter-*.contended_locks=32 \
19784 ldlm.namespaces.filter-*.contention_seconds=0"
19785 lctl set_param -n osc.*.contention_seconds=0
19786 clear_stats osc.*.osc_stats
19788 dd if=/dev/zero of=$DIR/$tfile count=0
19789 $CHECKSTAT -s 0 $DIR/$tfile
19791 restore_lustre_params <$p
19795 run_test 216 "check lockless direct write updates file size and kms correctly"
19797 test_217() { # bug 22430
19798 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19803 for node in $(nodes_list); do
19804 nid=$(host_nids_address $node $NETTYPE)
19805 if [[ $nid = *-* ]] ; then
19806 echo "lctl ping $(h2nettype $nid)"
19807 lctl ping $(h2nettype $nid)
19809 echo "skipping $node (no hyphen detected)"
19813 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
19816 # do directio so as not to populate the page cache
19817 log "creating a 10 Mb file"
19818 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
19819 log "starting reads"
19820 dd if=$DIR/$tfile of=/dev/null bs=4096 &
19821 log "truncating the file"
19822 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
19824 kill %+ || true # reads might have finished
19825 echo "wait until dd is finished"
19827 log "removing the temporary file"
19828 rm -rf $DIR/$tfile || error "tmp file removal failed"
19830 run_test 218 "parallel read and truncate should not deadlock"
19833 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19835 # write one partial page
19836 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
19837 # set no grant so vvp_io_commit_write will do sync write
19838 $LCTL set_param fail_loc=0x411
19839 # write a full page at the end of file
19840 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
19842 $LCTL set_param fail_loc=0
19843 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
19844 $LCTL set_param fail_loc=0x411
19845 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
19848 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
19849 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
19851 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
19853 test_220() { #LU-325
19854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19855 remote_ost_nodsh && skip "remote OST with nodsh"
19856 remote_mds_nodsh && skip "remote MDS with nodsh"
19857 remote_mgs_nodsh && skip "remote MGS with nodsh"
19861 # create on MDT0000 so the last_id and next_id are correct
19862 mkdir_on_mdt0 $DIR/$tdir
19863 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
19867 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
19868 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
19869 osp.$mdtosc_proc1.prealloc_last_id)
19870 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
19871 osp.$mdtosc_proc1.prealloc_next_id)
19875 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
19876 #define OBD_FAIL_OST_ENOINO 0x229
19877 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
19878 create_pool $FSNAME.$TESTNAME || return 1
19879 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
19881 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
19883 MDSOBJS=$((last_id - next_id))
19884 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
19886 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
19887 echo "OST still has $count kbytes free"
19889 echo "create $MDSOBJS files @next_id..."
19890 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
19892 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19893 osp.$mdtosc_proc1.prealloc_last_id)
19894 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19895 osp.$mdtosc_proc1.prealloc_next_id)
19897 echo "after creation, last_id=$last_id2, next_id=$next_id2"
19902 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
19903 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
19905 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
19906 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
19907 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
19908 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
19909 echo "unlink $MDSOBJS files @$next_id..."
19910 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
19912 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
19915 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19917 dd if=`which date` of=$MOUNT/date oflag=sync
19918 chmod +x $MOUNT/date
19920 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
19921 $LCTL set_param fail_loc=0x80001401
19923 $MOUNT/date > /dev/null
19926 run_test 221 "make sure fault and truncate race to not cause OOM"
19929 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19932 test_mkdir $DIR/$tdir
19933 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19934 createmany -o $DIR/$tdir/$tfile 10
19935 cancel_lru_locks mdc
19936 cancel_lru_locks osc
19937 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19938 $LCTL set_param fail_loc=0x31a
19939 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
19940 $LCTL set_param fail_loc=0
19943 run_test 222a "AGL for ls should not trigger CLIO lock failure"
19946 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19949 test_mkdir $DIR/$tdir
19950 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19951 createmany -o $DIR/$tdir/$tfile 10
19952 cancel_lru_locks mdc
19953 cancel_lru_locks osc
19954 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19955 $LCTL set_param fail_loc=0x31a
19956 rm -r $DIR/$tdir || error "AGL for rmdir failed"
19957 $LCTL set_param fail_loc=0
19959 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
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_NOLOCK 0x31b
19971 $LCTL set_param fail_loc=0x31b
19972 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
19973 $LCTL set_param fail_loc=0
19976 run_test 223 "osc reenqueue if without AGL lock granted ======================="
19978 test_224a() { # LU-1039, MRP-303
19979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19980 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
19981 $LCTL set_param fail_loc=0x508
19982 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fsync
19983 $LCTL set_param fail_loc=0
19986 run_test 224a "Don't panic on bulk IO failure"
19988 test_224bd_sub() { # LU-1039, MRP-303
19989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19993 dd if=/dev/urandom of=$TMP/$tfile bs=1M count=1
19995 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19997 dd if=$TMP/$tfile of=$DIR/$tfile bs=1M count=1
19998 cancel_lru_locks osc
20000 stack_trap "set_checksums $ORIG_CSUM" EXIT
20001 local at_max_saved=0
20003 # adaptive timeouts may prevent seeing the issue
20004 if at_is_enabled; then
20005 at_max_saved=$(at_max_get mds)
20006 at_max_set 0 mds client
20007 stack_trap "at_max_set $at_max_saved mds client" EXIT
20010 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
20011 do_facet ost1 $LCTL set_param fail_val=$timeout fail_loc=0x80000515
20012 dd of=$TMP/$tfile.new if=$DIR/$tfile bs=1M count=1 || "$@"
20014 do_facet ost1 $LCTL set_param fail_loc=0
20015 cmp $TMP/$tfile $TMP/$tfile.new || error "file contents wrong"
20020 test_224bd_sub 3 error "dd failed"
20022 run_test 224b "Don't panic on bulk IO failure"
20024 test_224c() { # LU-6441
20025 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20026 remote_mds_nodsh && skip "remote MDS with nodsh"
20028 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
20029 save_writethrough $p
20030 set_cache writethrough on
20032 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
20033 local at_max=$($LCTL get_param -n at_max)
20034 local timeout=$($LCTL get_param -n timeout)
20035 local test_at="at_max"
20036 local param_at="$FSNAME.sys.at_max"
20037 local test_timeout="timeout"
20038 local param_timeout="$FSNAME.sys.timeout"
20040 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
20042 set_persistent_param_and_check client "$test_at" "$param_at" 0
20043 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
20045 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
20046 do_facet ost1 "$LCTL set_param fail_loc=0x520"
20047 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20048 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
20050 do_facet ost1 "$LCTL set_param fail_loc=0"
20052 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
20053 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
20056 $LCTL set_param -n $pages_per_rpc
20057 restore_lustre_params < $p
20060 run_test 224c "Don't hang if one of md lost during large bulk RPC"
20062 test_224d() { # LU-11169
20063 test_224bd_sub $((TIMEOUT + 2)) error "dd failed"
20065 run_test 224d "Don't corrupt data on bulk IO timeout"
20067 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
20069 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20070 if [ -z ${MDSSURVEY} ]; then
20071 skip_env "mds-survey not found"
20073 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
20074 skip "Need MDS version at least 2.2.51"
20076 local mds=$(facet_host $SINGLEMDS)
20077 local target=$(do_nodes $mds 'lctl dl' |
20078 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
20080 local cmd1="file_count=1000 thrhi=4"
20081 local cmd2="dir_count=2 layer=mdd stripe_count=0"
20082 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
20083 local cmd="$cmd1 $cmd2 $cmd3"
20085 rm -f ${TMP}/mds_survey*
20087 eval $cmd || error "mds-survey with zero-stripe failed"
20088 cat ${TMP}/mds_survey*
20089 rm -f ${TMP}/mds_survey*
20091 run_test 225a "Metadata survey sanity with zero-stripe"
20094 if [ -z ${MDSSURVEY} ]; then
20095 skip_env "mds-survey not found"
20097 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
20098 skip "Need MDS version at least 2.2.51"
20099 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20100 remote_mds_nodsh && skip "remote MDS with nodsh"
20101 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
20102 skip_env "Need to mount OST to test"
20105 local mds=$(facet_host $SINGLEMDS)
20106 local target=$(do_nodes $mds 'lctl dl' |
20107 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
20109 local cmd1="file_count=1000 thrhi=4"
20110 local cmd2="dir_count=2 layer=mdd stripe_count=1"
20111 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
20112 local cmd="$cmd1 $cmd2 $cmd3"
20114 rm -f ${TMP}/mds_survey*
20116 eval $cmd || error "mds-survey with stripe_count failed"
20117 cat ${TMP}/mds_survey*
20118 rm -f ${TMP}/mds_survey*
20120 run_test 225b "Metadata survey sanity with stripe_count = 1"
20122 mcreate_path2fid () {
20128 local path=$DIR/$tdir/$name
20133 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
20134 error "cannot create $desc"
20136 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
20138 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
20140 fid_path=$($LFS fid2path $MOUNT $fid)
20142 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
20144 [ "$path" == "$fid_path" ] ||
20145 error "fid2path returned $fid_path, expected $path"
20147 echo "pass with $path and $fid"
20152 mkdir -p $DIR/$tdir
20154 mcreate_path2fid 0010666 0 0 fifo "FIFO"
20155 mcreate_path2fid 0020666 1 3 null "character special file (null)"
20156 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
20157 mcreate_path2fid 0040666 0 0 dir "directory"
20158 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
20159 mcreate_path2fid 0100666 0 0 file "regular file"
20160 mcreate_path2fid 0120666 0 0 link "symbolic link"
20161 mcreate_path2fid 0140666 0 0 sock "socket"
20163 run_test 226a "call path2fid and fid2path on files of all type"
20166 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20171 mkdir -p $DIR/$tdir
20172 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
20173 error "create remote directory failed"
20174 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
20175 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
20176 "character special file (null)"
20177 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
20178 "character special file (no device)"
20179 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
20180 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
20181 "block special file (loop)"
20182 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
20183 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
20184 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
20186 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
20189 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20190 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
20191 skip "Need MDS version at least 2.13.55"
20193 local submnt=/mnt/submnt
20194 local srcfile=/etc/passwd
20195 local dstfile=$submnt/passwd
20201 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
20202 error "create remote directory failed"
20203 mkdir -p $submnt || error "create $submnt failed"
20204 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
20205 error "mount $submnt failed"
20206 stack_trap "umount $submnt" EXIT
20208 cp $srcfile $dstfile
20209 fid=$($LFS path2fid $dstfile)
20210 path=$($LFS fid2path $submnt "$fid")
20211 [ "$path" = "$dstfile" ] ||
20212 error "fid2path $submnt $fid failed ($path != $dstfile)"
20214 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
20216 # LU-1299 Executing or running ldd on a truncated executable does not
20217 # cause an out-of-memory condition.
20219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20220 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
20222 dd if=$(which date) of=$MOUNT/date bs=1k count=1
20223 chmod +x $MOUNT/date
20225 $MOUNT/date > /dev/null
20226 ldd $MOUNT/date > /dev/null
20229 run_test 227 "running truncated executable does not cause OOM"
20231 # LU-1512 try to reuse idle OI blocks
20233 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20234 remote_mds_nodsh && skip "remote MDS with nodsh"
20235 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
20237 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
20238 local myDIR=$DIR/$tdir
20241 #define OBD_FAIL_SEQ_EXHAUST 0x1002
20242 $LCTL set_param fail_loc=0x80001002
20243 createmany -o $myDIR/t- 10000
20244 $LCTL set_param fail_loc=0
20245 # The guard is current the largest FID holder
20247 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
20249 local IDX=$(($SEQ % 64))
20251 do_facet $SINGLEMDS sync
20252 # Make sure journal flushed.
20254 local blk1=$(do_facet $SINGLEMDS \
20255 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20256 grep Blockcount | awk '{print $4}')
20258 # Remove old files, some OI blocks will become idle.
20259 unlinkmany $myDIR/t- 10000
20260 # Create new files, idle OI blocks should be reused.
20261 createmany -o $myDIR/t- 2000
20262 do_facet $SINGLEMDS sync
20263 # Make sure journal flushed.
20265 local blk2=$(do_facet $SINGLEMDS \
20266 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20267 grep Blockcount | awk '{print $4}')
20269 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
20271 run_test 228a "try to reuse idle OI blocks"
20274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20275 remote_mds_nodsh && skip "remote MDS with nodsh"
20276 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
20278 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
20279 local myDIR=$DIR/$tdir
20282 #define OBD_FAIL_SEQ_EXHAUST 0x1002
20283 $LCTL set_param fail_loc=0x80001002
20284 createmany -o $myDIR/t- 10000
20285 $LCTL set_param fail_loc=0
20286 # The guard is current the largest FID holder
20288 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
20290 local IDX=$(($SEQ % 64))
20292 do_facet $SINGLEMDS sync
20293 # Make sure journal flushed.
20295 local blk1=$(do_facet $SINGLEMDS \
20296 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20297 grep Blockcount | awk '{print $4}')
20299 # Remove old files, some OI blocks will become idle.
20300 unlinkmany $myDIR/t- 10000
20303 stop $SINGLEMDS || error "Fail to stop MDT."
20305 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
20306 error "Fail to start MDT."
20308 client_up || error "Fail to df."
20309 # Create new files, idle OI blocks should be reused.
20310 createmany -o $myDIR/t- 2000
20311 do_facet $SINGLEMDS sync
20312 # Make sure journal flushed.
20314 local blk2=$(do_facet $SINGLEMDS \
20315 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20316 grep Blockcount | awk '{print $4}')
20318 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
20320 run_test 228b "idle OI blocks can be reused after MDT restart"
20324 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20325 remote_mds_nodsh && skip "remote MDS with nodsh"
20326 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
20328 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
20329 local myDIR=$DIR/$tdir
20332 #define OBD_FAIL_SEQ_EXHAUST 0x1002
20333 $LCTL set_param fail_loc=0x80001002
20334 # 20000 files can guarantee there are index nodes in the OI file
20335 createmany -o $myDIR/t- 20000
20336 $LCTL set_param fail_loc=0
20337 # The guard is current the largest FID holder
20339 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
20341 local IDX=$(($SEQ % 64))
20343 do_facet $SINGLEMDS sync
20344 # Make sure journal flushed.
20346 local blk1=$(do_facet $SINGLEMDS \
20347 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20348 grep Blockcount | awk '{print $4}')
20350 # Remove old files, some OI blocks will become idle.
20351 unlinkmany $myDIR/t- 20000
20353 # The OI file should become empty now
20355 # Create new files, idle OI blocks should be reused.
20356 createmany -o $myDIR/t- 2000
20357 do_facet $SINGLEMDS sync
20358 # Make sure journal flushed.
20360 local blk2=$(do_facet $SINGLEMDS \
20361 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20362 grep Blockcount | awk '{print $4}')
20364 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
20366 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
20368 test_229() { # LU-2482, LU-3448
20369 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20370 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
20371 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
20372 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
20376 # Create a file with a released layout and stripe count 2.
20377 $MULTIOP $DIR/$tfile H2c ||
20378 error "failed to create file with released layout"
20380 $LFS getstripe -v $DIR/$tfile
20382 local pattern=$($LFS getstripe -L $DIR/$tfile)
20383 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
20385 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
20387 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
20388 stat $DIR/$tfile || error "failed to stat released file"
20390 chown $RUNAS_ID $DIR/$tfile ||
20391 error "chown $RUNAS_ID $DIR/$tfile failed"
20393 chgrp $RUNAS_ID $DIR/$tfile ||
20394 error "chgrp $RUNAS_ID $DIR/$tfile failed"
20396 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
20397 rm $DIR/$tfile || error "failed to remove released file"
20399 run_test 229 "getstripe/stat/rm/attr changes work on released files"
20402 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20403 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20404 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20405 skip "Need MDS version at least 2.11.52"
20409 test_mkdir $DIR/$tdir
20410 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
20411 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
20412 [ $mdt_idx -ne 0 ] &&
20413 error "create local directory on wrong MDT $mdt_idx"
20415 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
20416 error "create remote directory failed"
20417 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
20418 [ $mdt_idx -ne $MDTIDX ] &&
20419 error "create remote directory on wrong MDT $mdt_idx"
20421 createmany -o $DIR/$tdir/test_230/t- 10 ||
20422 error "create files on remote directory failed"
20423 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
20424 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
20425 rm -r $DIR/$tdir || error "unlink remote directory failed"
20427 run_test 230a "Create remote directory and files under the remote directory"
20430 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20431 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20432 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20433 skip "Need MDS version at least 2.11.52"
20441 local migrate_dir=$DIR/$tdir/migrate_dir
20442 local other_dir=$DIR/$tdir/other_dir
20444 test_mkdir $DIR/$tdir
20445 test_mkdir -i0 -c1 $migrate_dir
20446 test_mkdir -i0 -c1 $other_dir
20447 for ((i=0; i<10; i++)); do
20448 mkdir -p $migrate_dir/dir_${i}
20449 createmany -o $migrate_dir/dir_${i}/f 10 ||
20450 error "create files under remote dir failed $i"
20453 cp /etc/passwd $migrate_dir/$tfile
20454 cp /etc/passwd $other_dir/$tfile
20455 chattr +SAD $migrate_dir
20456 chattr +SAD $migrate_dir/$tfile
20458 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20459 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20460 local old_dir_mode=$(stat -c%f $migrate_dir)
20461 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
20463 mkdir -p $migrate_dir/dir_default_stripe2
20464 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
20465 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
20467 mkdir -p $other_dir
20468 ln $migrate_dir/$tfile $other_dir/luna
20469 ln $migrate_dir/$tfile $migrate_dir/sofia
20470 ln $other_dir/$tfile $migrate_dir/david
20471 ln -s $migrate_dir/$tfile $other_dir/zachary
20472 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
20473 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
20479 for len in 58 59 60; do
20480 lnktgt=$(str_repeat 'l' $len)
20481 touch $migrate_dir/$lnktgt
20482 ln -s $lnktgt $migrate_dir/${len}char_ln
20486 for len in 4094 4095; do
20487 lnktgt=$(str_repeat 'l' $len)
20488 ln -s $lnktgt $migrate_dir/${len}char_ln
20492 for len in 254 255; do
20493 touch $migrate_dir/$(str_repeat 'l' $len)
20496 $LFS migrate -m $MDTIDX $migrate_dir ||
20497 error "fails on migrating remote dir to MDT1"
20499 echo "migratate to MDT1, then checking.."
20500 for ((i = 0; i < 10; i++)); do
20501 for file in $(find $migrate_dir/dir_${i}); do
20502 mdt_index=$($LFS getstripe -m $file)
20503 # broken symlink getstripe will fail
20504 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
20505 error "$file is not on MDT${MDTIDX}"
20509 # the multiple link file should still in MDT0
20510 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
20511 [ $mdt_index == 0 ] ||
20512 error "$file is not on MDT${MDTIDX}"
20514 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20515 [ "$old_dir_flag" = "$new_dir_flag" ] ||
20516 error " expect $old_dir_flag get $new_dir_flag"
20518 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20519 [ "$old_file_flag" = "$new_file_flag" ] ||
20520 error " expect $old_file_flag get $new_file_flag"
20522 local new_dir_mode=$(stat -c%f $migrate_dir)
20523 [ "$old_dir_mode" = "$new_dir_mode" ] ||
20524 error "expect mode $old_dir_mode get $new_dir_mode"
20526 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
20527 [ "$old_file_mode" = "$new_file_mode" ] ||
20528 error "expect mode $old_file_mode get $new_file_mode"
20530 diff /etc/passwd $migrate_dir/$tfile ||
20531 error "$tfile different after migration"
20533 diff /etc/passwd $other_dir/luna ||
20534 error "luna different after migration"
20536 diff /etc/passwd $migrate_dir/sofia ||
20537 error "sofia different after migration"
20539 diff /etc/passwd $migrate_dir/david ||
20540 error "david different after migration"
20542 diff /etc/passwd $other_dir/zachary ||
20543 error "zachary different after migration"
20545 diff /etc/passwd $migrate_dir/${tfile}_ln ||
20546 error "${tfile}_ln different after migration"
20548 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
20549 error "${tfile}_ln_other different after migration"
20551 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
20552 [ $stripe_count = 2 ] ||
20553 error "dir strpe_count $d != 2 after migration."
20555 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
20556 [ $stripe_count = 2 ] ||
20557 error "file strpe_count $d != 2 after migration."
20559 #migrate back to MDT0
20562 $LFS migrate -m $MDTIDX $migrate_dir ||
20563 error "fails on migrating remote dir to MDT0"
20565 echo "migrate back to MDT0, checking.."
20566 for file in $(find $migrate_dir); do
20567 mdt_index=$($LFS getstripe -m $file)
20568 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
20569 error "$file is not on MDT${MDTIDX}"
20572 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20573 [ "$old_dir_flag" = "$new_dir_flag" ] ||
20574 error " expect $old_dir_flag get $new_dir_flag"
20576 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20577 [ "$old_file_flag" = "$new_file_flag" ] ||
20578 error " expect $old_file_flag get $new_file_flag"
20580 local new_dir_mode=$(stat -c%f $migrate_dir)
20581 [ "$old_dir_mode" = "$new_dir_mode" ] ||
20582 error "expect mode $old_dir_mode get $new_dir_mode"
20584 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
20585 [ "$old_file_mode" = "$new_file_mode" ] ||
20586 error "expect mode $old_file_mode get $new_file_mode"
20588 diff /etc/passwd ${migrate_dir}/$tfile ||
20589 error "$tfile different after migration"
20591 diff /etc/passwd ${other_dir}/luna ||
20592 error "luna different after migration"
20594 diff /etc/passwd ${migrate_dir}/sofia ||
20595 error "sofia different after migration"
20597 diff /etc/passwd ${other_dir}/zachary ||
20598 error "zachary different after migration"
20600 diff /etc/passwd $migrate_dir/${tfile}_ln ||
20601 error "${tfile}_ln different after migration"
20603 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
20604 error "${tfile}_ln_other different after migration"
20606 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
20607 [ $stripe_count = 2 ] ||
20608 error "dir strpe_count $d != 2 after migration."
20610 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
20611 [ $stripe_count = 2 ] ||
20612 error "file strpe_count $d != 2 after migration."
20614 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20616 run_test 230b "migrate directory"
20619 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20620 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20621 remote_mds_nodsh && skip "remote MDS with nodsh"
20622 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20623 skip "Need MDS version at least 2.11.52"
20629 local migrate_dir=$DIR/$tdir/migrate_dir
20631 #If migrating directory fails in the middle, all entries of
20632 #the directory is still accessiable.
20633 test_mkdir $DIR/$tdir
20634 test_mkdir -i0 -c1 $migrate_dir
20635 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
20637 createmany -o $migrate_dir/f $total ||
20638 error "create files under ${migrate_dir} failed"
20640 # fail after migrating top dir, and this will fail only once, so the
20641 # first sub file migration will fail (currently f3), others succeed.
20642 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
20643 do_facet mds1 lctl set_param fail_loc=0x1801
20644 local t=$(ls $migrate_dir | wc -l)
20645 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
20646 error "migrate should fail"
20647 local u=$(ls $migrate_dir | wc -l)
20648 [ "$u" == "$t" ] || error "$u != $t during migration"
20650 # add new dir/file should succeed
20651 mkdir $migrate_dir/dir ||
20652 error "mkdir failed under migrating directory"
20653 touch $migrate_dir/file ||
20654 error "create file failed under migrating directory"
20656 # add file with existing name should fail
20657 for file in $migrate_dir/f*; do
20658 stat $file > /dev/null || error "stat $file failed"
20659 $OPENFILE -f O_CREAT:O_EXCL $file &&
20660 error "open(O_CREAT|O_EXCL) $file should fail"
20661 $MULTIOP $file m && error "create $file should fail"
20662 touch $DIR/$tdir/remote_dir/$tfile ||
20663 error "touch $tfile failed"
20664 ln $DIR/$tdir/remote_dir/$tfile $file &&
20665 error "link $file should fail"
20666 mdt_index=$($LFS getstripe -m $file)
20667 if [ $mdt_index == 0 ]; then
20668 # file failed to migrate is not allowed to rename to
20669 mv $DIR/$tdir/remote_dir/$tfile $file &&
20670 error "rename to $file should fail"
20672 mv $DIR/$tdir/remote_dir/$tfile $file ||
20673 error "rename to $file failed"
20675 echo hello >> $file || error "write $file failed"
20678 # resume migration with different options should fail
20679 $LFS migrate -m 0 $migrate_dir &&
20680 error "migrate -m 0 $migrate_dir should fail"
20682 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
20683 error "migrate -c 2 $migrate_dir should fail"
20685 # resume migration should succeed
20686 $LFS migrate -m $MDTIDX $migrate_dir ||
20687 error "migrate $migrate_dir failed"
20689 echo "Finish migration, then checking.."
20690 for file in $(find $migrate_dir); do
20691 mdt_index=$($LFS getstripe -m $file)
20692 [ $mdt_index == $MDTIDX ] ||
20693 error "$file is not on MDT${MDTIDX}"
20696 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20698 run_test 230c "check directory accessiblity if migration failed"
20701 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20702 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20703 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20704 skip "Need MDS version at least 2.11.52"
20706 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
20708 local migrate_dir=$DIR/$tdir/migrate_dir
20718 old_index=$((RANDOM % MDSCOUNT))
20719 old_count=$((MDSCOUNT - old_index))
20720 new_index=$((RANDOM % MDSCOUNT))
20721 new_count=$((MDSCOUNT - new_index))
20722 new_hash=1 # for all_char
20724 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
20725 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
20727 test_mkdir $DIR/$tdir
20728 test_mkdir -i $old_index -c $old_count $migrate_dir
20730 for ((i=0; i<100; i++)); do
20731 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
20732 createmany -o $migrate_dir/dir_${i}/f 100 ||
20733 error "create files under remote dir failed $i"
20736 echo -n "Migrate from MDT$old_index "
20737 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
20738 echo -n "to MDT$new_index"
20739 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
20742 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
20743 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
20744 error "migrate remote dir error"
20746 echo "Finish migration, then checking.."
20747 for file in $(find $migrate_dir -maxdepth 1); do
20748 mdt_index=$($LFS getstripe -m $file)
20749 if [ $mdt_index -lt $new_index ] ||
20750 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
20751 error "$file is on MDT$mdt_index"
20755 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20757 run_test 230d "check migrate big directory"
20760 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20761 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20762 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20763 skip "Need MDS version at least 2.11.52"
20770 mkdir_on_mdt0 $DIR/$tdir
20771 mkdir $DIR/$tdir/migrate_dir
20772 mkdir $DIR/$tdir/other_dir
20773 touch $DIR/$tdir/migrate_dir/a
20774 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
20775 ls $DIR/$tdir/other_dir
20777 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20778 error "migrate dir fails"
20780 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20781 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20783 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20784 [ $mdt_index == 0 ] || error "a is not on MDT0"
20786 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
20787 error "migrate dir fails"
20789 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
20790 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
20792 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20793 [ $mdt_index == 1 ] || error "a is not on MDT1"
20795 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
20796 [ $mdt_index == 1 ] || error "b is not on MDT1"
20798 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20799 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
20801 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
20803 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20805 run_test 230e "migrate mulitple local link files"
20808 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20809 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20810 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20811 skip "Need MDS version at least 2.11.52"
20816 mkdir -p $DIR/$tdir
20817 mkdir $DIR/$tdir/migrate_dir
20818 $LFS mkdir -i1 $DIR/$tdir/other_dir
20819 touch $DIR/$tdir/migrate_dir/a
20820 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
20821 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
20822 ls $DIR/$tdir/other_dir
20824 # a should be migrated to MDT1, since no other links on MDT0
20825 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20826 error "#1 migrate dir fails"
20827 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20828 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20829 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20830 [ $mdt_index == 1 ] || error "a is not on MDT1"
20832 # a should stay on MDT1, because it is a mulitple link file
20833 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20834 error "#2 migrate dir fails"
20835 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20836 [ $mdt_index == 1 ] || error "a is not on MDT1"
20838 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20839 error "#3 migrate dir fails"
20841 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20842 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
20843 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
20845 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
20846 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
20848 # a should be migrated to MDT0, since no other links on MDT1
20849 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20850 error "#4 migrate dir fails"
20851 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20852 [ $mdt_index == 0 ] || error "a is not on MDT0"
20854 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20856 run_test 230f "migrate mulitple remote link files"
20859 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20860 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20861 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20862 skip "Need MDS version at least 2.11.52"
20864 mkdir -p $DIR/$tdir/migrate_dir
20866 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
20867 error "migrating dir to non-exist MDT succeeds"
20870 run_test 230g "migrate dir to non-exist MDT"
20873 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20874 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20875 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20876 skip "Need MDS version at least 2.11.52"
20880 mkdir -p $DIR/$tdir/migrate_dir
20882 $LFS migrate -m1 $DIR &&
20883 error "migrating mountpoint1 should fail"
20885 $LFS migrate -m1 $DIR/$tdir/.. &&
20886 error "migrating mountpoint2 should fail"
20889 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
20890 error "migrating $tdir/migrate_dir/.. should fail"
20894 run_test 230h "migrate .. and root"
20897 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20898 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20899 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20900 skip "Need MDS version at least 2.11.52"
20902 mkdir -p $DIR/$tdir/migrate_dir
20904 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
20905 error "migration fails with a tailing slash"
20907 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
20908 error "migration fails with two tailing slashes"
20910 run_test 230i "lfs migrate -m tolerates trailing slashes"
20913 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20914 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
20915 skip "Need MDS version at least 2.11.52"
20917 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20918 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
20919 error "create $tfile failed"
20920 cat /etc/passwd > $DIR/$tdir/$tfile
20922 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20924 cmp /etc/passwd $DIR/$tdir/$tfile ||
20925 error "DoM file mismatch after migration"
20927 run_test 230j "DoM file data not changed after dir migration"
20930 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
20931 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20932 skip "Need MDS version at least 2.11.56"
20935 local files_on_starting_mdt=0
20937 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
20938 $LFS getdirstripe $DIR/$tdir
20939 for i in $(seq $total); do
20940 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
20941 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20942 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20945 echo "$files_on_starting_mdt files on MDT0"
20947 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
20948 $LFS getdirstripe $DIR/$tdir
20950 files_on_starting_mdt=0
20951 for i in $(seq $total); do
20952 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20953 error "file $tfile.$i mismatch after migration"
20954 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
20955 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20958 echo "$files_on_starting_mdt files on MDT1 after migration"
20959 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
20961 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
20962 $LFS getdirstripe $DIR/$tdir
20964 files_on_starting_mdt=0
20965 for i in $(seq $total); do
20966 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20967 error "file $tfile.$i mismatch after 2nd migration"
20968 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20969 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20972 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
20973 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
20977 run_test 230k "file data not changed after dir migration"
20980 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20981 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20982 skip "Need MDS version at least 2.11.56"
20984 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
20985 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
20986 error "create files under remote dir failed $i"
20987 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20989 run_test 230l "readdir between MDTs won't crash"
20992 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20993 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20994 skip "Need MDS version at least 2.11.56"
20997 local mig_dir=$DIR/$tdir/migrate_dir
20998 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
21002 echo "Creating files and dirs with xattrs"
21003 test_mkdir $DIR/$tdir
21004 test_mkdir -i0 -c1 $mig_dir
21006 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
21007 error "cannot set xattr attr1 on dir"
21008 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
21009 error "cannot set xattr attr2 on dir"
21010 touch $mig_dir/dir/f0
21011 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
21012 error "cannot set xattr attr1 on file"
21013 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
21014 error "cannot set xattr attr2 on file"
21015 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
21016 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
21017 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
21018 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
21019 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
21020 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
21021 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
21022 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
21023 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
21025 echo "Migrating to MDT1"
21026 $LFS migrate -m $MDTIDX $mig_dir ||
21027 error "fails on migrating dir to MDT1"
21029 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
21030 echo "Checking xattrs"
21031 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
21032 [ "$val" = $longstr ] ||
21033 error "expecting xattr1 $longstr on dir, found $val"
21034 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
21035 [ "$val" = $shortstr ] ||
21036 error "expecting xattr2 $shortstr on dir, found $val"
21037 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
21038 [ "$val" = $longstr ] ||
21039 error "expecting xattr1 $longstr on file, found $val"
21040 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
21041 [ "$val" = $shortstr ] ||
21042 error "expecting xattr2 $shortstr on file, found $val"
21044 run_test 230m "xattrs not changed after dir migration"
21047 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21048 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
21049 skip "Need MDS version at least 2.13.53"
21051 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
21052 cat /etc/hosts > $DIR/$tdir/$tfile
21053 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
21054 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
21056 cmp /etc/hosts $DIR/$tdir/$tfile ||
21057 error "File data mismatch after migration"
21059 run_test 230n "Dir migration with mirrored file"
21062 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
21063 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
21064 skip "Need MDS version at least 2.13.52"
21066 local mdts=$(comma_list $(mdts_nodes))
21068 local restripe_status
21072 [[ $mds1_FSTYPE == zfs ]] && timeout=300
21074 # in case "crush" hash type is not set
21075 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
21077 restripe_status=$(do_facet mds1 $LCTL get_param -n \
21078 mdt.*MDT0000.enable_dir_restripe)
21079 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
21080 stack_trap "do_nodes $mdts $LCTL set_param \
21081 mdt.*.enable_dir_restripe=$restripe_status"
21084 createmany -m $DIR/$tdir/f 100 ||
21085 error "create files under remote dir failed $i"
21086 createmany -d $DIR/$tdir/d 100 ||
21087 error "create dirs under remote dir failed $i"
21089 for i in $(seq 2 $MDSCOUNT); do
21090 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
21091 $LFS setdirstripe -c $i $DIR/$tdir ||
21092 error "split -c $i $tdir failed"
21093 wait_update $HOSTNAME \
21094 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
21095 error "dir split not finished"
21096 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
21097 awk '/migrate/ {sum += $2} END { print sum }')
21098 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
21099 # delta is around total_files/stripe_count
21100 (( $delta < 200 / (i - 1) + 4 )) ||
21101 error "$delta files migrated >= $((200 / (i - 1) + 4))"
21104 run_test 230o "dir split"
21107 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
21108 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
21109 skip "Need MDS version at least 2.13.52"
21111 local mdts=$(comma_list $(mdts_nodes))
21113 local restripe_status
21117 [[ $mds1_FSTYPE == zfs ]] && timeout=300
21119 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
21121 restripe_status=$(do_facet mds1 $LCTL get_param -n \
21122 mdt.*MDT0000.enable_dir_restripe)
21123 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
21124 stack_trap "do_nodes $mdts $LCTL set_param \
21125 mdt.*.enable_dir_restripe=$restripe_status"
21127 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
21128 createmany -m $DIR/$tdir/f 100 ||
21129 error "create files under remote dir failed"
21130 createmany -d $DIR/$tdir/d 100 ||
21131 error "create dirs under remote dir failed"
21133 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
21134 local mdt_hash="crush"
21136 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
21137 $LFS setdirstripe -c $c $DIR/$tdir ||
21138 error "split -c $c $tdir failed"
21139 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
21140 mdt_hash="$mdt_hash,fixed"
21141 elif [ $c -eq 1 ]; then
21144 wait_update $HOSTNAME \
21145 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
21146 error "dir merge not finished"
21147 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
21148 awk '/migrate/ {sum += $2} END { print sum }')
21149 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
21150 # delta is around total_files/stripe_count
21151 (( delta < 200 / c + 4 )) ||
21152 error "$delta files migrated >= $((200 / c + 4))"
21155 run_test 230p "dir merge"
21158 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
21159 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
21160 skip "Need MDS version at least 2.13.52"
21162 local mdts=$(comma_list $(mdts_nodes))
21163 local saved_threshold=$(do_facet mds1 \
21164 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
21165 local saved_delta=$(do_facet mds1 \
21166 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
21167 local threshold=100
21170 local stripe_count=0
21175 # test with fewer files on ZFS
21176 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
21178 stack_trap "do_nodes $mdts $LCTL set_param \
21179 mdt.*.dir_split_count=$saved_threshold"
21180 stack_trap "do_nodes $mdts $LCTL set_param \
21181 mdt.*.dir_split_delta=$saved_delta"
21182 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
21183 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
21184 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
21185 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
21186 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
21187 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
21189 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
21190 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
21192 create=$((threshold * 3 / 2))
21193 while [ $stripe_count -lt $MDSCOUNT ]; do
21194 createmany -m $DIR/$tdir/f $total $create ||
21195 error "create sub files failed"
21196 stat $DIR/$tdir > /dev/null
21197 total=$((total + create))
21198 stripe_count=$((stripe_count + delta))
21199 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
21201 wait_update $HOSTNAME \
21202 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
21203 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
21205 wait_update $HOSTNAME \
21206 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
21207 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
21209 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
21210 echo "$nr_files/$total files on MDT$stripe_index after split"
21211 # allow 10% margin of imbalance with crush hash
21212 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
21213 error "$nr_files files on MDT$stripe_index after split"
21215 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
21216 [ $nr_files -eq $total ] ||
21217 error "total sub files $nr_files != $total"
21220 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
21222 echo "fixed layout directory won't auto split"
21223 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
21224 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
21225 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
21226 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
21227 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
21229 run_test 230q "dir auto split"
21232 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
21233 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
21234 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
21235 skip "Need MDS version at least 2.13.54"
21237 # maximum amount of local locks:
21238 # parent striped dir - 2 locks
21239 # new stripe in parent to migrate to - 1 lock
21240 # source and target - 2 locks
21241 # Total 5 locks for regular file
21242 mkdir -p $DIR/$tdir
21243 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
21244 touch $DIR/$tdir/dir1/eee
21246 # create 4 hardlink for 4 more locks
21247 # Total: 9 locks > RS_MAX_LOCKS (8)
21248 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
21249 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
21250 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
21251 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
21252 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
21253 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
21254 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
21255 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
21257 cancel_lru_locks mdc
21259 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
21260 error "migrate dir fails"
21262 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21264 run_test 230r "migrate with too many local locks"
21267 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
21268 skip "Need MDS version at least 2.14.52"
21270 local mdts=$(comma_list $(mdts_nodes))
21271 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
21272 mdt.*MDT0000.enable_dir_restripe)
21274 stack_trap "do_nodes $mdts $LCTL set_param \
21275 mdt.*.enable_dir_restripe=$restripe_status"
21279 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
21280 test_mkdir $DIR/$tdir
21281 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
21282 error "$LFS mkdir should return EEXIST if target exists"
21286 run_test 230s "lfs mkdir should return -EEXIST if target exists"
21290 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
21291 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
21292 skip "Need MDS version at least 2.14.50"
21294 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
21295 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
21296 $LFS project -p 1 -s $DIR/$tdir ||
21297 error "set $tdir project id failed"
21298 $LFS project -p 2 -s $DIR/$tdir/subdir ||
21299 error "set subdir project id failed"
21300 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
21302 run_test 230t "migrate directory with project ID set"
21306 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
21307 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
21308 skip "Need MDS version at least 2.14.53"
21312 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
21313 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
21314 $LFS migrate -m -1 $DIR/$tdir/sub{0..99} || error "migrate sub failed"
21315 for i in $(seq 0 $((MDSCOUNT - 1))); do
21316 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
21317 echo "$count dirs migrated to MDT$i"
21319 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
21320 (( count >= MDSCOUNT - 1 )) || error "dirs migrated to $count MDTs"
21322 run_test 230u "migrate directory by QOS"
21326 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
21327 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
21328 skip "Need MDS version at least 2.14.53"
21332 mkdir $DIR/$tdir || error "mkdir $tdir failed"
21333 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
21334 $LFS migrate -m 0,2,1 $DIR/$tdir || error "migrate $tdir failed"
21335 for i in $(seq 0 $((MDSCOUNT - 1))); do
21336 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
21337 echo "$count subdirs migrated to MDT$i"
21338 (( i == 3 )) && (( count > 0 )) &&
21339 error "subdir shouldn't be migrated to MDT3"
21341 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
21342 (( count == 3 )) || error "dirs migrated to $count MDTs"
21344 run_test 230v "subdir migrated to the MDT where its parent is located"
21347 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
21348 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
21349 skip "Need MDS version at least 2.15.0"
21351 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
21352 createmany -o $DIR/$tdir/f 10 || error "create files failed"
21353 createmany -d $DIR/$tdir/d 10 || error "create dirs failed"
21355 $LFS migrate -m 1 -c $MDSCOUNT -d $DIR/$tdir ||
21356 error "migrate failed"
21358 (( $($LFS getdirstripe -c $DIR/$tdir) == MDSCOUNT )) ||
21359 error "$tdir stripe count mismatch"
21361 for i in $(seq 0 9); do
21362 (( $($LFS getdirstripe -c $DIR/$tdir/d$i) == 0 )) ||
21363 error "d$i is striped"
21366 run_test 230w "non-recursive mode dir migration"
21369 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
21370 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
21371 skip "Need MDS version at least 2.15.0"
21373 mkdir -p $DIR/$tdir || error "mkdir failed"
21374 createmany -d $DIR/$tdir/sub 100 || error "createmany failed"
21376 local mdt_name=$(mdtname_from_index 0)
21377 local low=$(do_facet mds2 $LCTL get_param -n \
21378 osp.*$mdt_name-osp-MDT0001.reserved_ino_low)
21379 local high=$(do_facet mds2 $LCTL get_param -n \
21380 osp.*$mdt_name-osp-MDT0001.reserved_ino_high)
21381 local ffree=$($LFS df -i $MOUNT | awk "/$mdt_name/ { print \$4 }")
21382 local maxage=$(do_facet mds2 $LCTL get_param -n \
21383 osp.*$mdt_name-osp-MDT0001.maxage)
21385 stack_trap "do_facet mds2 $LCTL set_param -n \
21386 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low \
21387 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high" EXIT
21388 stack_trap "do_facet mds2 $LCTL set_param -n \
21389 osp.*$mdt_name-osp-MDT0001.maxage=$maxage" EXIT
21391 do_facet mds2 $LCTL set_param -n \
21392 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$((ffree + 1))
21393 do_facet mds2 $LCTL set_param -n osp.*$mdt_name-osp-MDT0001.maxage=1
21395 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir &&
21396 error "migrate $tdir should fail"
21398 do_facet mds2 $LCTL set_param -n \
21399 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low
21400 do_facet mds2 $LCTL set_param -n \
21401 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high
21403 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir ||
21404 error "migrate failed"
21405 (( $($LFS getdirstripe -c $DIR/$tdir) == $MDSCOUNT )) ||
21406 error "$tdir stripe count mismatch"
21408 run_test 230x "dir migration check space"
21412 # For simplicity this test assumes that max_pages_per_rpc
21413 # is the same across all OSCs
21414 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
21415 local bulk_size=$((max_pages * PAGE_SIZE))
21416 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
21419 mkdir -p $DIR/$tdir
21420 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
21421 error "failed to set stripe with -S ${brw_size}M option"
21423 # clear the OSC stats
21424 $LCTL set_param osc.*.stats=0 &>/dev/null
21427 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
21428 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
21429 oflag=direct &>/dev/null || error "dd failed"
21431 sync; sleep 1; sync # just to be safe
21432 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
21433 if [ x$nrpcs != "x1" ]; then
21434 $LCTL get_param osc.*.stats
21435 error "found $nrpcs ost_write RPCs, not 1 as expected"
21439 # Drop the OSC cache, otherwise we will read from it
21440 cancel_lru_locks osc
21442 # clear the OSC stats
21443 $LCTL set_param osc.*.stats=0 &>/dev/null
21445 # Client reads $bulk_size.
21446 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
21447 iflag=direct &>/dev/null || error "dd failed"
21449 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
21450 if [ x$nrpcs != "x1" ]; then
21451 $LCTL get_param osc.*.stats
21452 error "found $nrpcs ost_read RPCs, not 1 as expected"
21455 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
21458 mkdir -p $DIR/$tdir
21460 for i in {0..1023}; do
21461 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
21462 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
21463 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
21467 run_test 231b "must not assert on fully utilized OST request buffer"
21470 mkdir -p $DIR/$tdir
21471 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
21473 #define OBD_FAIL_LDLM_OST_LVB 0x31c
21474 do_facet ost1 $LCTL set_param fail_loc=0x31c
21476 # ignore dd failure
21477 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
21479 do_facet ost1 $LCTL set_param fail_loc=0
21480 umount_client $MOUNT || error "umount failed"
21481 mount_client $MOUNT || error "mount failed"
21482 stop ost1 || error "cannot stop ost1"
21483 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21485 run_test 232a "failed lock should not block umount"
21488 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
21489 skip "Need MDS version at least 2.10.58"
21491 mkdir -p $DIR/$tdir
21492 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
21493 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
21495 cancel_lru_locks osc
21497 #define OBD_FAIL_LDLM_OST_LVB 0x31c
21498 do_facet ost1 $LCTL set_param fail_loc=0x31c
21501 $LFS data_version $DIR/$tdir/$tfile || true
21503 do_facet ost1 $LCTL set_param fail_loc=0
21504 umount_client $MOUNT || error "umount failed"
21505 mount_client $MOUNT || error "mount failed"
21506 stop ost1 || error "cannot stop ost1"
21507 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21509 run_test 232b "failed data version lock should not block umount"
21512 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
21513 skip "Need MDS version at least 2.3.64"
21514 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
21516 local fid=$($LFS path2fid $MOUNT)
21518 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21519 error "cannot access $MOUNT using its FID '$fid'"
21521 run_test 233a "checking that OBF of the FS root succeeds"
21524 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
21525 skip "Need MDS version at least 2.5.90"
21526 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
21528 local fid=$($LFS path2fid $MOUNT/.lustre)
21530 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21531 error "cannot access $MOUNT/.lustre using its FID '$fid'"
21533 fid=$($LFS path2fid $MOUNT/.lustre/fid)
21534 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21535 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
21537 run_test 233b "checking that OBF of the FS .lustre succeeds"
21540 local p="$TMP/sanityN-$TESTNAME.parameters"
21541 save_lustre_params client "llite.*.xattr_cache" > $p
21542 lctl set_param llite.*.xattr_cache 1 ||
21543 skip_env "xattr cache is not supported"
21545 mkdir -p $DIR/$tdir || error "mkdir failed"
21546 touch $DIR/$tdir/$tfile || error "touch failed"
21547 # OBD_FAIL_LLITE_XATTR_ENOMEM
21548 $LCTL set_param fail_loc=0x1405
21549 getfattr -n user.attr $DIR/$tdir/$tfile &&
21550 error "getfattr should have failed with ENOMEM"
21551 $LCTL set_param fail_loc=0x0
21554 restore_lustre_params < $p
21557 run_test 234 "xattr cache should not crash on ENOMEM"
21560 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
21561 skip "Need MDS version at least 2.4.52"
21563 flock_deadlock $DIR/$tfile
21568 124) error "process hangs on a deadlock"
21570 *) error "error executing flock_deadlock $DIR/$tfile"
21574 run_test 235 "LU-1715: flock deadlock detection does not work properly"
21578 check_swap_layouts_support
21580 local ref1=/etc/passwd
21581 local ref2=/etc/group
21582 local file1=$DIR/$tdir/f1
21583 local file2=$DIR/$tdir/f2
21585 test_mkdir -c1 $DIR/$tdir
21586 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
21587 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
21588 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
21589 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
21590 local fd=$(free_fd)
21591 local cmd="exec $fd<>$file2"
21594 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
21595 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
21598 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
21603 run_test 236 "Layout swap on open unlinked file"
21605 # LU-4659 linkea consistency
21607 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
21608 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
21609 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
21610 skip "Need MDS version at least 2.5.58 or 2.5.2+"
21613 ln $DIR/$tfile $DIR/$tfile.lnk
21614 touch $DIR/$tfile.new
21615 mv $DIR/$tfile.new $DIR/$tfile
21616 local fid1=$($LFS path2fid $DIR/$tfile)
21617 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
21618 local path1=$($LFS fid2path $FSNAME "$fid1")
21619 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
21620 local path2=$($LFS fid2path $FSNAME "$fid2")
21621 [ $tfile.lnk == $path2 ] ||
21622 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
21625 run_test 238 "Verify linkea consistency"
21627 test_239A() { # was test_239
21628 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
21629 skip "Need MDS version at least 2.5.60"
21631 local list=$(comma_list $(mdts_nodes))
21633 mkdir -p $DIR/$tdir
21634 createmany -o $DIR/$tdir/f- 5000
21635 unlinkmany $DIR/$tdir/f- 5000
21636 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
21637 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
21638 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
21639 osp.*MDT*.sync_in_flight" | calc_sum)
21640 [ "$changes" -eq 0 ] || error "$changes not synced"
21642 run_test 239A "osp_sync test"
21644 test_239a() { #LU-5297
21645 remote_mds_nodsh && skip "remote MDS with nodsh"
21648 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
21649 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
21650 chgrp $RUNAS_GID $DIR/$tfile
21651 wait_delete_completed
21653 run_test 239a "process invalid osp sync record correctly"
21655 test_239b() { #LU-5297
21656 remote_mds_nodsh && skip "remote MDS with nodsh"
21659 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
21660 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
21661 chgrp $RUNAS_GID $DIR/$tfile1
21662 wait_delete_completed
21663 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
21665 chgrp $RUNAS_GID $DIR/$tfile2
21666 wait_delete_completed
21668 run_test 239b "process osp sync record with ENOMEM error correctly"
21671 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21672 remote_mds_nodsh && skip "remote MDS with nodsh"
21674 mkdir -p $DIR/$tdir
21676 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
21677 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
21678 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
21679 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
21681 umount_client $MOUNT || error "umount failed"
21682 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
21683 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
21684 mount_client $MOUNT || error "failed to mount client"
21686 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
21687 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
21689 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
21695 for LOOP in $(seq $count); do
21696 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
21697 cancel_lru_locks $OSC || true
21705 for LOOP in $(seq $1); do
21706 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
21711 test_241a() { # was test_241
21712 local bsize=$PAGE_SIZE
21714 (( bsize < 40960 )) && bsize=40960
21715 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21717 cancel_lru_locks $OSC
21718 test_241_bio 1000 $bsize &
21720 test_241_dio 1000 $bsize
21723 run_test 241a "bio vs dio"
21726 local bsize=$PAGE_SIZE
21728 (( bsize < 40960 )) && bsize=40960
21729 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21731 test_241_dio 1000 $bsize &
21733 test_241_dio 1000 $bsize
21736 run_test 241b "dio vs dio"
21739 remote_mds_nodsh && skip "remote MDS with nodsh"
21741 mkdir_on_mdt0 $DIR/$tdir
21742 touch $DIR/$tdir/$tfile
21744 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
21745 do_facet mds1 lctl set_param fail_loc=0x105
21746 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
21748 do_facet mds1 lctl set_param fail_loc=0
21749 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
21751 run_test 242 "mdt_readpage failure should not cause directory unreadable"
21755 test_mkdir $DIR/$tdir
21756 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
21758 run_test 243 "various group lock tests"
21762 test_mkdir $DIR/$tdir
21763 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
21764 sendfile_grouplock $DIR/$tdir/$tfile || \
21765 error "sendfile+grouplock failed"
21768 run_test 244a "sendfile with group lock tests"
21772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
21775 local size=$((1024*1024))
21777 test_mkdir $DIR/$tdir
21778 for i in $(seq 1 $threads); do
21779 local file=$DIR/$tdir/file_$((i / 10))
21780 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
21783 for i in $(seq 1 $threads); do
21787 run_test 244b "multi-threaded write with group lock"
21790 local flagname="multi_mod_rpcs"
21791 local connect_data_name="max_mod_rpcs"
21794 # check if multiple modify RPCs flag is set
21795 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
21796 grep "connect_flags:")
21799 echo "$out" | grep -qw $flagname
21800 if [ $? -ne 0 ]; then
21801 echo "connect flag $flagname is not set"
21805 # check if multiple modify RPCs data is set
21806 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
21809 echo "$out" | grep -qw $connect_data_name ||
21810 error "import should have connect data $connect_data_name"
21812 run_test 245a "check mdc connection flag/data: multiple modify RPCs"
21815 local flagname="multi_mod_rpcs"
21816 local connect_data_name="max_mod_rpcs"
21819 remote_mds_nodsh && skip "remote MDS with nodsh"
21820 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
21822 # check if multiple modify RPCs flag is set
21823 out=$(do_facet mds1 \
21824 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import |
21825 grep "connect_flags:")
21828 [[ "$out" =~ $flagname ]] || skip "connect flag $flagname is not set"
21830 # check if multiple modify RPCs data is set
21831 out=$(do_facet mds1 \
21832 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import)
21834 [[ "$out" =~ $connect_data_name ]] ||
21837 error "missing connect data $connect_data_name"
21840 run_test 245b "check osp connection flag/data: multiple modify RPCs"
21846 umount_client $submount
21851 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21853 skip_env "Fileset feature is not supported"
21855 local submount=${MOUNT}_$tdir
21858 mkdir -p $submount || error "mkdir $submount failed"
21859 FILESET="$FILESET/$tdir" mount_client $submount ||
21860 error "mount $submount failed"
21861 trap "cleanup_247 $submount" EXIT
21862 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
21863 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
21864 error "read $MOUNT/$tdir/$tfile failed"
21865 cleanup_247 $submount
21867 run_test 247a "mount subdir as fileset"
21870 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21871 skip_env "Fileset feature is not supported"
21873 local submount=${MOUNT}_$tdir
21875 rm -rf $MOUNT/$tdir
21876 mkdir -p $submount || error "mkdir $submount failed"
21878 FILESET="$FILESET/$tdir" mount_client $submount &&
21879 error "mount $submount should fail"
21882 run_test 247b "mount subdir that dose not exist"
21885 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21886 skip_env "Fileset feature is not supported"
21888 local submount=${MOUNT}_$tdir
21890 mkdir -p $MOUNT/$tdir/dir1
21891 mkdir -p $submount || error "mkdir $submount failed"
21892 trap "cleanup_247 $submount" EXIT
21893 FILESET="$FILESET/$tdir" mount_client $submount ||
21894 error "mount $submount failed"
21895 local fid=$($LFS path2fid $MOUNT/)
21896 $LFS fid2path $submount $fid && error "fid2path should fail"
21897 cleanup_247 $submount
21899 run_test 247c "running fid2path outside subdirectory root"
21902 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21903 skip "Fileset feature is not supported"
21905 local submount=${MOUNT}_$tdir
21907 mkdir -p $MOUNT/$tdir/dir1
21908 mkdir -p $submount || error "mkdir $submount failed"
21909 FILESET="$FILESET/$tdir" mount_client $submount ||
21910 error "mount $submount failed"
21911 trap "cleanup_247 $submount" EXIT
21913 local td=$submount/dir1
21914 local fid=$($LFS path2fid $td)
21915 [ -z "$fid" ] && error "path2fid unable to get $td FID"
21917 # check that we get the same pathname back
21920 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
21921 echo "$rootpath $fid"
21922 found=$($LFS fid2path $rootpath "$fid")
21923 [ -n "$found" ] || error "fid2path should succeed"
21924 [ "$found" == "$td" ] || error "fid2path $found != $td"
21926 # check wrong root path format
21927 rootpath=$submount"_wrong"
21928 found=$($LFS fid2path $rootpath "$fid")
21929 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
21931 cleanup_247 $submount
21933 run_test 247d "running fid2path inside subdirectory root"
21937 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21939 skip "Fileset feature is not supported"
21941 local submount=${MOUNT}_$tdir
21944 mkdir -p $submount || error "mkdir $submount failed"
21945 FILESET="$FILESET/.." mount_client $submount &&
21946 error "mount $submount should fail"
21949 run_test 247e "mount .. as fileset"
21952 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
21953 (( $MDS1_VERSION >= $(version_code 2.14.50.162) )) ||
21954 skip "Need at least version 2.14.50.162"
21955 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21956 skip "Fileset feature is not supported"
21958 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
21959 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
21960 error "mkdir remote failed"
21961 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
21962 error "mkdir remote/subdir failed"
21963 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
21964 error "mkdir striped failed"
21965 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
21967 local submount=${MOUNT}_$tdir
21969 mkdir -p $submount || error "mkdir $submount failed"
21970 stack_trap "rmdir $submount"
21973 local fileset=$FILESET
21974 local mdts=$(comma_list $(mdts_nodes))
21976 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
21977 for dir in $tdir/remote $tdir/remote/subdir $tdir/striped \
21978 $tdir/striped/subdir $tdir/striped/.; do
21979 FILESET="$fileset/$dir" mount_client $submount ||
21980 error "mount $dir failed"
21981 umount_client $submount
21984 run_test 247f "mount striped or remote directory as fileset"
21986 test_subdir_mount_lock()
21989 local submount=${MOUNT}_$(basename $testdir)
21991 touch $DIR/$testdir/$tfile || error "touch $tfile failed"
21993 mkdir -p $submount || error "mkdir $submount failed"
21994 stack_trap "rmdir $submount"
21996 FILESET="$fileset/$testdir" mount_client $submount ||
21997 error "mount $FILESET failed"
21998 stack_trap "umount $submount"
22000 local mdts=$(comma_list $(mdts_nodes))
22004 stat $submount > /dev/null || error "stat $submount failed"
22005 cancel_lru_locks $MDC
22006 stat $submount > /dev/null || error "stat $submount failed"
22007 stat $submount/$tfile > /dev/null || error "stat $tfile failed"
22008 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
22009 stat $submount/$tfile > /dev/null || error "stat $tfile failed"
22010 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
22011 awk '/getattr/ {sum += $2} END {print sum}')
22013 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
22017 (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
22019 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
22020 error "mkdir $tdir failed"
22021 test_subdir_mount_lock $tdir
22023 run_test 247g "striped directory submount revalidate ROOT from cache"
22026 (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
22027 (( $MDS1_VERSION >= $(version_code 2.15.51) )) ||
22028 skip "Need MDS version at least 2.15.51"
22030 $LFS mkdir -i 1 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
22031 test_subdir_mount_lock $tdir
22032 mkdir_on_mdt -i 0 $DIR/$tdir/$tdir.0 || error "mkdir $tdir.0 failed"
22033 mkdir_on_mdt -i 1 $DIR/$tdir/$tdir.0/$tdir.1 ||
22034 error "mkdir $tdir.1 failed"
22035 test_subdir_mount_lock $tdir/$tdir.0/$tdir.1
22037 run_test 247h "remote directory submount revalidate ROOT from cache"
22040 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
22041 [ -z "$fast_read_sav" ] && skip "no fast read support"
22043 # create a large file for fast read verification
22044 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
22046 # make sure the file is created correctly
22047 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
22048 { rm -f $DIR/$tfile; skip "file creation error"; }
22050 echo "Test 1: verify that fast read is 4 times faster on cache read"
22052 # small read with fast read enabled
22053 $LCTL set_param -n llite.*.fast_read=1
22054 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
22055 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
22056 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
22057 # small read with fast read disabled
22058 $LCTL set_param -n llite.*.fast_read=0
22059 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
22060 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
22061 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
22063 # verify that fast read is 4 times faster for cache read
22064 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
22065 error_not_in_vm "fast read was not 4 times faster: " \
22066 "$t_fast vs $t_slow"
22068 echo "Test 2: verify the performance between big and small read"
22069 $LCTL set_param -n llite.*.fast_read=1
22071 # 1k non-cache read
22072 cancel_lru_locks osc
22073 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
22074 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
22075 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
22077 # 1M non-cache read
22078 cancel_lru_locks osc
22079 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
22080 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
22081 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
22083 # verify that big IO is not 4 times faster than small IO
22084 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
22085 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
22087 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
22090 run_test 248a "fast read verification"
22093 # Default short_io_bytes=16384, try both smaller and larger sizes.
22094 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
22095 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
22096 echo "bs=53248 count=113 normal buffered write"
22097 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
22098 error "dd of initial data file failed"
22099 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
22101 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
22102 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
22103 error "dd with sync normal writes failed"
22104 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
22106 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
22107 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
22108 error "dd with sync small writes failed"
22109 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
22111 cancel_lru_locks osc
22113 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
22114 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
22115 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
22116 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
22117 iflag=direct || error "dd with O_DIRECT small read failed"
22118 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
22119 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
22120 error "compare $TMP/$tfile.1 failed"
22122 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
22123 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
22125 # just to see what the maximum tunable value is, and test parsing
22126 echo "test invalid parameter 2MB"
22127 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
22128 error "too-large short_io_bytes allowed"
22129 echo "test maximum parameter 512KB"
22130 # if we can set a larger short_io_bytes, run test regardless of version
22131 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
22132 # older clients may not allow setting it this large, that's OK
22133 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
22134 skip "Need at least client version 2.13.50"
22135 error "medium short_io_bytes failed"
22137 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
22138 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
22140 echo "test large parameter 64KB"
22141 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
22142 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
22144 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
22145 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
22146 error "dd with sync large writes failed"
22147 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
22149 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
22150 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
22151 num=$((113 * 4096 / PAGE_SIZE))
22152 echo "bs=$size count=$num oflag=direct large write $tfile.3"
22153 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
22154 error "dd with O_DIRECT large writes failed"
22155 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
22156 error "compare $DIR/$tfile.3 failed"
22158 cancel_lru_locks osc
22160 echo "bs=$size count=$num iflag=direct large read $tfile.2"
22161 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
22162 error "dd with O_DIRECT large read failed"
22163 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
22164 error "compare $TMP/$tfile.2 failed"
22166 echo "bs=$size count=$num iflag=direct large read $tfile.3"
22167 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
22168 error "dd with O_DIRECT large read failed"
22169 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
22170 error "compare $TMP/$tfile.3 failed"
22172 run_test 248b "test short_io read and write for both small and large sizes"
22174 test_249() { # LU-7890
22175 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
22176 skip "Need at least version 2.8.54"
22179 $LFS setstripe -c 1 $DIR/$tfile
22180 # Offset 2T == 4k * 512M
22181 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
22182 error "dd to 2T offset failed"
22184 run_test 249 "Write above 2T file size"
22187 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
22188 && skip "no 16TB file size limit on ZFS"
22190 $LFS setstripe -c 1 $DIR/$tfile
22191 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
22192 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
22193 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
22194 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
22195 conv=notrunc,fsync && error "append succeeded"
22198 run_test 250 "Write above 16T limit"
22201 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
22203 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
22204 #Skip once - writing the first stripe will succeed
22205 $LCTL set_param fail_loc=0xa0001407 fail_val=1
22206 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
22207 error "short write happened"
22209 $LCTL set_param fail_loc=0xa0001407 fail_val=1
22210 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
22211 error "short read happened"
22215 run_test 251 "Handling short read and write correctly"
22218 remote_mds_nodsh && skip "remote MDS with nodsh"
22219 remote_ost_nodsh && skip "remote OST with nodsh"
22220 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
22221 skip_env "ldiskfs only test"
22231 # check lr_reader on OST0000
22233 dev=$(facet_device $tgt)
22234 out=$(do_facet $tgt $LR_READER $dev)
22235 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
22237 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
22238 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
22239 error "Invalid uuid returned by $LR_READER on target $tgt"
22240 echo -e "uuid returned by $LR_READER is '$uuid'\n"
22242 # check lr_reader -c on MDT0000
22244 dev=$(facet_device $tgt)
22245 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
22246 skip "$LR_READER does not support additional options"
22248 out=$(do_facet $tgt $LR_READER -c $dev)
22249 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
22251 num=$(echo "$out" | grep -c "mdtlov")
22252 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
22253 error "Invalid number of mdtlov clients returned by $LR_READER"
22254 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
22256 # check lr_reader -cr on MDT0000
22257 out=$(do_facet $tgt $LR_READER -cr $dev)
22258 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
22260 echo "$out" | grep -q "^reply_data:$" ||
22261 error "$LR_READER should have returned 'reply_data' section"
22262 num=$(echo "$out" | grep -c "client_generation")
22263 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
22265 run_test 252 "check lr_reader tool"
22268 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22269 remote_mds_nodsh && skip "remote MDS with nodsh"
22270 remote_mgs_nodsh && skip "remote MGS with nodsh"
22274 local ost_name=$(ostname_from_index $ostidx)
22277 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
22278 do_facet $SINGLEMDS $LCTL get_param -n \
22279 osp.$mdtosc_proc1.reserved_mb_high ||
22280 skip "remote MDS does not support reserved_mb_high"
22284 wait_delete_completed
22287 pool_add $TESTNAME || error "Pool creation failed"
22288 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
22290 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
22291 error "Setstripe failed"
22293 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
22295 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
22297 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
22299 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
22300 osp.$mdtosc_proc1.prealloc_status)
22301 echo "prealloc_status $oa_status"
22303 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
22304 error "File creation should fail"
22306 #object allocation was stopped, but we still able to append files
22307 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
22308 oflag=append || error "Append failed"
22310 rm -f $DIR/$tdir/$tfile.0
22312 # For this test, we want to delete the files we created to go out of
22313 # space but leave the watermark, so we remain nearly out of space
22314 ost_watermarks_enospc_delete_files $tfile $ostidx
22316 wait_delete_completed
22320 for i in $(seq 10 12); do
22321 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
22322 2>/dev/null || error "File creation failed after rm"
22325 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
22326 osp.$mdtosc_proc1.prealloc_status)
22327 echo "prealloc_status $oa_status"
22329 if (( oa_status != 0 )); then
22330 error "Object allocation still disable after rm"
22333 run_test 253 "Check object allocation limit"
22336 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22337 remote_mds_nodsh && skip "remote MDS with nodsh"
22339 local mdt=$(facet_svc $SINGLEMDS)
22341 do_facet $SINGLEMDS $LCTL get_param -n mdd.$mdt.changelog_size ||
22342 skip "MDS does not support changelog_size"
22346 changelog_register || error "changelog_register failed"
22348 changelog_clear 0 || error "changelog_clear failed"
22350 local size1=$(do_facet $SINGLEMDS \
22351 $LCTL get_param -n mdd.$mdt.changelog_size)
22352 echo "Changelog size $size1"
22355 $LFS mkdir -i 0 $DIR/$tdir
22357 mkdir -p $DIR/$tdir/pics/2008/zachy
22358 touch $DIR/$tdir/pics/2008/zachy/timestamp
22359 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
22360 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
22361 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
22362 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
22363 rm $DIR/$tdir/pics/desktop.jpg
22365 local size2=$(do_facet $SINGLEMDS \
22366 $LCTL get_param -n mdd.$mdt.changelog_size)
22367 echo "Changelog size after work $size2"
22369 (( $size2 > $size1 )) ||
22370 error "new Changelog size=$size2 less than old size=$size1"
22372 run_test 254 "Check changelog size"
22379 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
22380 awk -F: '{print $2}' | grep $type > /dev/null
22381 if [ $? -ne 0 ]; then
22391 lfs ladvise -a willread $file > /dev/null 2>&1
22392 if [ $? -eq 0 ]; then
22396 lfs ladvise -a willread $file 2>&1 |
22397 grep "Inappropriate ioctl for device" > /dev/null
22398 if [ $? -eq 0 ]; then
22405 bc <<<"scale=2; ($1 - $2) * 100 / $2"
22408 # run a random read IO workload
22409 # usage: random_read_iops <filename> <filesize> <iosize>
22410 random_read_iops() {
22413 local iosize=${3:-4096}
22415 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
22416 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
22419 drop_file_oss_cache() {
22423 $LFS ladvise -a dontneed $file 2>/dev/null ||
22424 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
22427 ladvise_willread_performance()
22430 local average_origin=0
22431 local average_cache=0
22432 local average_ladvise=0
22434 for ((i = 1; i <= $repeat; i++)); do
22435 echo "Iter $i/$repeat: reading without willread hint"
22436 cancel_lru_locks osc
22437 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
22438 local speed_origin=$(random_read_iops $DIR/$tfile $size)
22439 echo "Iter $i/$repeat: uncached speed: $speed_origin"
22440 average_origin=$(bc <<<"$average_origin + $speed_origin")
22442 cancel_lru_locks osc
22443 local speed_cache=$(random_read_iops $DIR/$tfile $size)
22444 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
22445 average_cache=$(bc <<<"$average_cache + $speed_cache")
22447 cancel_lru_locks osc
22448 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
22449 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
22450 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
22451 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
22452 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
22454 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
22455 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
22456 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
22458 speedup_cache=$(percent $average_cache $average_origin)
22459 speedup_ladvise=$(percent $average_ladvise $average_origin)
22461 echo "Average uncached read: $average_origin"
22462 echo "Average speedup with OSS cached read: " \
22463 "$average_cache = +$speedup_cache%"
22464 echo "Average speedup with ladvise willread: " \
22465 "$average_ladvise = +$speedup_ladvise%"
22467 local lowest_speedup=20
22468 if (( ${average_cache%.*} < $lowest_speedup )); then
22469 echo "Speedup with OSS cached read less than $lowest_speedup%,"\
22470 " got $average_cache%. Skipping ladvise willread check."
22474 # the test won't work on ZFS until it supports 'ladvise dontneed', but
22475 # it is still good to run until then to exercise 'ladvise willread'
22476 ! $LFS ladvise -a dontneed $DIR/$tfile &&
22477 [ "$ost1_FSTYPE" = "zfs" ] &&
22478 echo "osd-zfs does not support dontneed or drop_caches" &&
22481 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
22482 (( ${average_ladvise%.*} > ${lowest_speedup%.*} )) ||
22483 error_not_in_vm "Speedup with willread is less than " \
22484 "$lowest_speedup%, got $average_ladvise%"
22488 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
22489 skip "lustre < 2.8.54 does not support ladvise "
22490 remote_ost_nodsh && skip "remote OST with nodsh"
22492 stack_trap "rm -f $DIR/$tfile"
22493 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
22495 ladvise_no_type willread $DIR/$tfile &&
22496 skip "willread ladvise is not supported"
22498 ladvise_no_ioctl $DIR/$tfile &&
22499 skip "ladvise ioctl is not supported"
22502 local size=$((size_mb * 1048576))
22503 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
22504 error "dd to $DIR/$tfile failed"
22506 lfs ladvise -a willread $DIR/$tfile ||
22507 error "Ladvise failed with no range argument"
22509 lfs ladvise -a willread -s 0 $DIR/$tfile ||
22510 error "Ladvise failed with no -l or -e argument"
22512 lfs ladvise -a willread -e 1 $DIR/$tfile ||
22513 error "Ladvise failed with only -e argument"
22515 lfs ladvise -a willread -l 1 $DIR/$tfile ||
22516 error "Ladvise failed with only -l argument"
22518 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
22519 error "End offset should not be smaller than start offset"
22521 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
22522 error "End offset should not be equal to start offset"
22524 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
22525 error "Ladvise failed with overflowing -s argument"
22527 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
22528 error "Ladvise failed with overflowing -e argument"
22530 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
22531 error "Ladvise failed with overflowing -l argument"
22533 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
22534 error "Ladvise succeeded with conflicting -l and -e arguments"
22536 echo "Synchronous ladvise should wait"
22538 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
22539 do_nodes $(comma_list $(osts_nodes)) \
22540 $LCTL set_param fail_val=$delay fail_loc=0x237
22542 local start_ts=$SECONDS
22543 lfs ladvise -a willread $DIR/$tfile ||
22544 error "Ladvise failed with no range argument"
22545 local end_ts=$SECONDS
22546 local inteval_ts=$((end_ts - start_ts))
22548 if [ $inteval_ts -lt $(($delay - 1)) ]; then
22549 error "Synchronous advice didn't wait reply"
22552 echo "Asynchronous ladvise shouldn't wait"
22553 local start_ts=$SECONDS
22554 lfs ladvise -a willread -b $DIR/$tfile ||
22555 error "Ladvise failed with no range argument"
22556 local end_ts=$SECONDS
22557 local inteval_ts=$((end_ts - start_ts))
22559 if [ $inteval_ts -gt $(($delay / 2)) ]; then
22560 error "Asynchronous advice blocked"
22563 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
22564 ladvise_willread_performance
22566 run_test 255a "check 'lfs ladvise -a willread'"
22572 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
22576 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
22577 skip "lustre < 2.8.54 does not support ladvise "
22578 remote_ost_nodsh && skip "remote OST with nodsh"
22580 stack_trap "rm -f $DIR/$tfile"
22581 lfs setstripe -c 1 -i 0 $DIR/$tfile
22583 ladvise_no_type dontneed $DIR/$tfile &&
22584 skip "dontneed ladvise is not supported"
22586 ladvise_no_ioctl $DIR/$tfile &&
22587 skip "ladvise ioctl is not supported"
22589 ! $LFS ladvise -a dontneed $DIR/$tfile &&
22590 [ "$ost1_FSTYPE" = "zfs" ] &&
22591 skip "zfs-osd does not support 'ladvise dontneed'"
22594 local size=$((size_mb * 1048576))
22595 # In order to prevent disturbance of other processes, only check 3/4
22596 # of the memory usage
22597 local kibibytes=$((size_mb * 1024 * 3 / 4))
22599 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
22600 error "dd to $DIR/$tfile failed"
22602 #force write to complete before dropping OST cache & checking memory
22605 local total=$(facet_meminfo ost1 MemTotal)
22606 echo "Total memory: $total KiB"
22608 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
22609 local before_read=$(facet_meminfo ost1 Cached)
22610 echo "Cache used before read: $before_read KiB"
22612 lfs ladvise -a willread $DIR/$tfile ||
22613 error "Ladvise willread failed"
22614 local after_read=$(facet_meminfo ost1 Cached)
22615 echo "Cache used after read: $after_read KiB"
22617 lfs ladvise -a dontneed $DIR/$tfile ||
22618 error "Ladvise dontneed again failed"
22619 local no_read=$(facet_meminfo ost1 Cached)
22620 echo "Cache used after dontneed ladvise: $no_read KiB"
22622 if [ $total -lt $((before_read + kibibytes)) ]; then
22623 echo "Memory is too small, abort checking"
22627 if [ $((before_read + kibibytes)) -gt $after_read ]; then
22628 error "Ladvise willread should use more memory" \
22629 "than $kibibytes KiB"
22632 if [ $((no_read + kibibytes)) -gt $after_read ]; then
22633 error "Ladvise dontneed should release more memory" \
22634 "than $kibibytes KiB"
22637 run_test 255b "check 'lfs ladvise -a dontneed'"
22640 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
22641 skip "lustre < 2.10.50 does not support lockahead"
22643 local ost1_imp=$(get_osc_import_name client ost1)
22644 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
22652 test_mkdir -p $DIR/$tdir
22653 $LFS setstripe -i 0 -c 1 $DIR/$tdir
22655 #test 10 returns only success/failure
22657 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22659 if [ $rc -eq 255 ]; then
22660 error "Ladvise test${i} failed, ${rc}"
22663 #test 11 counts lock enqueue requests, all others count new locks
22665 count=$(do_facet ost1 \
22666 $LCTL get_param -n ost.OSS.ost.stats)
22667 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
22669 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22671 if [ $rc -eq 255 ]; then
22672 error "Ladvise test${i} failed, ${rc}"
22675 new_count=$(do_facet ost1 \
22676 $LCTL get_param -n ost.OSS.ost.stats)
22677 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
22678 awk '{ print $2 }')
22680 difference="$((new_count - count))"
22681 if [ $difference -ne $rc ]; then
22682 error "Ladvise test${i}, bad enqueue count, returned " \
22683 "${rc}, actual ${difference}"
22686 for i in $(seq 12 21); do
22687 # If we do not do this, we run the risk of having too many
22688 # locks and starting lock cancellation while we are checking
22690 cancel_lru_locks osc
22692 count=$($LCTL get_param -n \
22693 ldlm.namespaces.$imp_name.lock_unused_count)
22695 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22697 if [ $rc -eq 255 ]; then
22698 error "Ladvise test ${i} failed, ${rc}"
22701 new_count=$($LCTL get_param -n \
22702 ldlm.namespaces.$imp_name.lock_unused_count)
22703 difference="$((new_count - count))"
22705 # Test 15 output is divided by 100 to map down to valid return
22706 if [ $i -eq 15 ]; then
22710 if [ $difference -ne $rc ]; then
22711 error "Ladvise test ${i}, bad lock count, returned " \
22712 "${rc}, actual ${difference}"
22716 #test 22 returns only success/failure
22718 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22720 if [ $rc -eq 255 ]; then
22721 error "Ladvise test${i} failed, ${rc}"
22724 run_test 255c "suite of ladvise lockahead tests"
22727 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22728 remote_mds_nodsh && skip "remote MDS with nodsh"
22729 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22730 changelog_users $SINGLEMDS | grep "^cl" &&
22731 skip "active changelog user"
22737 mdt_dev=$(facet_device $SINGLEMDS)
22740 changelog_register || error "changelog_register failed"
22743 mkdir_on_mdt -i$(($(facet_number $SINGLEMDS) - 1)) $DIR/$tdir
22745 changelog_clear 0 || error "changelog_clear failed"
22748 touch $DIR/$tdir/{1..10}
22751 stop $SINGLEMDS || error "Fail to stop MDT"
22754 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
22755 error "Fail to start MDT"
22757 #after mount new plainllog is used
22758 touch $DIR/$tdir/{11..19}
22759 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
22760 stack_trap "rm -f $tmpfile"
22761 cat_sl=$(do_facet $SINGLEMDS "sync; \
22762 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22763 llog_reader $tmpfile | grep -c type=1064553b")
22764 do_facet $SINGLEMDS llog_reader $tmpfile
22766 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
22768 changelog_clear 0 || error "changelog_clear failed"
22770 cat_sl=$(do_facet $SINGLEMDS "sync; \
22771 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22772 llog_reader $tmpfile | grep -c type=1064553b")
22774 if (( cat_sl == 2 )); then
22775 error "Empty plain llog was not deleted from changelog catalog"
22776 elif (( cat_sl != 1 )); then
22777 error "Active plain llog shouldn't be deleted from catalog"
22780 run_test 256 "Check llog delete for empty and not full state"
22783 remote_mds_nodsh && skip "remote MDS with nodsh"
22784 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
22785 skip "Need MDS version at least 2.8.55"
22787 test_mkdir $DIR/$tdir
22789 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
22790 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
22793 #define OBD_FAIL_MDS_XATTR_REP 0x161
22794 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
22795 local facet=mds$((mdtidx + 1))
22796 set_nodes_failloc $(facet_active_host $facet) 0x80000161
22797 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
22799 stop $facet || error "stop MDS failed"
22800 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
22801 error "start MDS fail"
22802 wait_recovery_complete $facet
22804 run_test 257 "xattr locks are not lost"
22806 # Verify we take the i_mutex when security requires it
22808 #define OBD_FAIL_IMUTEX_SEC 0x141c
22809 $LCTL set_param fail_loc=0x141c
22811 chmod u+s $DIR/$tfile
22812 chmod a+rwx $DIR/$tfile
22813 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22815 if [ $RC -ne 0 ]; then
22816 error "error, failed to take i_mutex, rc=$?"
22820 run_test 258a "verify i_mutex security behavior when suid attributes is set"
22822 # Verify we do NOT take the i_mutex in the normal case
22824 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
22825 $LCTL set_param fail_loc=0x141d
22828 chmod a+rw $DIR/$tfile
22829 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22831 if [ $RC -ne 0 ]; then
22832 error "error, took i_mutex unnecessarily, rc=$?"
22837 run_test 258b "verify i_mutex security behavior"
22840 local file=$DIR/$tfile
22844 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22846 stack_trap "rm -f $file" EXIT
22848 wait_delete_completed
22849 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22850 echo "before: $before"
22852 $LFS setstripe -i 0 -c 1 $file
22853 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
22855 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22856 echo "after write: $after"
22858 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
22859 do_facet ost1 $LCTL set_param fail_loc=0x2301
22861 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22862 echo "after truncate: $after"
22865 do_facet ost1 $LCTL set_param fail_loc=0
22866 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22868 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22869 echo "after restart: $after"
22870 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
22871 error "missing truncate?"
22875 run_test 259 "crash at delayed truncate"
22878 #define OBD_FAIL_MDC_CLOSE 0x806
22879 $LCTL set_param fail_loc=0x80000806
22883 run_test 260 "Check mdc_close fail"
22885 ### Data-on-MDT sanity tests ###
22887 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22888 skip "Need MDS version at least 2.10.55 for DoM"
22891 local dom=$DIR/$tdir/dom_file
22892 local tmp=$DIR/$tdir/tmp_file
22894 mkdir_on_mdt0 $DIR/$tdir
22896 # basic checks for DoM component creation
22897 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
22898 error "Can set MDT layout to non-first entry"
22900 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
22901 error "Can define multiple entries as MDT layout"
22903 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
22905 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
22906 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
22907 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
22909 local mdtidx=$($LFS getstripe -m $dom)
22910 local mdtname=MDT$(printf %04x $mdtidx)
22911 local facet=mds$((mdtidx + 1))
22912 local space_check=1
22914 # Skip free space checks with ZFS
22915 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
22919 local size_tmp=$((65536 * 3))
22920 local mdtfree1=$(do_facet $facet \
22921 lctl get_param -n osd*.*$mdtname.kbytesfree)
22923 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22924 # check also direct IO along write
22925 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
22926 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22928 cmp $tmp $dom || error "file data is different"
22929 [ $(stat -c%s $dom) == $size_tmp ] ||
22930 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22931 if [ $space_check == 1 ]; then
22932 local mdtfree2=$(do_facet $facet \
22933 lctl get_param -n osd*.*$mdtname.kbytesfree)
22935 # increase in usage from by $size_tmp
22936 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22937 error "MDT free space wrong after write: " \
22938 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22942 local size_dom=10000
22944 $TRUNCATE $dom $size_dom
22945 [ $(stat -c%s $dom) == $size_dom ] ||
22946 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
22947 if [ $space_check == 1 ]; then
22948 mdtfree1=$(do_facet $facet \
22949 lctl get_param -n osd*.*$mdtname.kbytesfree)
22950 # decrease in usage from $size_tmp to new $size_dom
22951 [ $(($mdtfree1 - $mdtfree2)) -ge \
22952 $(((size_tmp - size_dom) / 1024)) ] ||
22953 error "MDT free space is wrong after truncate: " \
22954 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
22960 size_dom=$((size_dom + size_tmp))
22961 [ $(stat -c%s $dom) == $size_dom ] ||
22962 error "bad size after append: $(stat -c%s $dom) != $size_dom"
22963 if [ $space_check == 1 ]; then
22964 mdtfree2=$(do_facet $facet \
22965 lctl get_param -n osd*.*$mdtname.kbytesfree)
22966 # increase in usage by $size_tmp from previous
22967 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22968 error "MDT free space is wrong after append: " \
22969 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22974 if [ $space_check == 1 ]; then
22975 mdtfree1=$(do_facet $facet \
22976 lctl get_param -n osd*.*$mdtname.kbytesfree)
22977 # decrease in usage by $size_dom from previous
22978 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
22979 error "MDT free space is wrong after removal: " \
22980 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
22983 # combined striping
22984 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
22985 error "Can't create DoM + OST striping"
22987 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
22988 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22989 # check also direct IO along write
22990 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22992 cmp $tmp $dom || error "file data is different"
22993 [ $(stat -c%s $dom) == $size_tmp ] ||
22994 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22999 run_test 270a "DoM: basic functionality tests"
23002 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23003 skip "Need MDS version at least 2.10.55"
23005 local dom=$DIR/$tdir/dom_file
23006 local max_size=1048576
23008 mkdir -p $DIR/$tdir
23009 $LFS setstripe -E $max_size -L mdt $dom
23011 # truncate over the limit
23012 $TRUNCATE $dom $(($max_size + 1)) &&
23013 error "successful truncate over the maximum size"
23014 # write over the limit
23015 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
23016 error "successful write over the maximum size"
23017 # append over the limit
23018 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
23019 echo "12345" >> $dom && error "successful append over the maximum size"
23024 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
23027 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23028 skip "Need MDS version at least 2.10.55"
23030 mkdir -p $DIR/$tdir
23031 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23033 # check files inherit DoM EA
23034 touch $DIR/$tdir/first
23035 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
23036 error "bad pattern"
23037 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
23038 error "bad stripe count"
23039 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
23040 error "bad stripe size"
23042 # check directory inherits DoM EA and uses it as default
23043 mkdir $DIR/$tdir/subdir
23044 touch $DIR/$tdir/subdir/second
23045 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
23046 error "bad pattern in sub-directory"
23047 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
23048 error "bad stripe count in sub-directory"
23049 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
23050 error "bad stripe size in sub-directory"
23053 run_test 270c "DoM: DoM EA inheritance tests"
23056 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23057 skip "Need MDS version at least 2.10.55"
23059 mkdir -p $DIR/$tdir
23060 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23062 # inherit default DoM striping
23063 mkdir $DIR/$tdir/subdir
23064 touch $DIR/$tdir/subdir/f1
23066 # change default directory striping
23067 $LFS setstripe -c 1 $DIR/$tdir/subdir
23068 touch $DIR/$tdir/subdir/f2
23069 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
23070 error "wrong default striping in file 2"
23071 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
23072 error "bad pattern in file 2"
23075 run_test 270d "DoM: change striping from DoM to RAID0"
23078 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23079 skip "Need MDS version at least 2.10.55"
23081 mkdir -p $DIR/$tdir/dom
23082 mkdir -p $DIR/$tdir/norm
23085 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
23086 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
23088 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
23089 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
23091 # find DoM files by layout
23092 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
23093 [ $NUM -eq $DOMFILES ] ||
23094 error "lfs find -L: found $NUM, expected $DOMFILES"
23095 echo "Test 1: lfs find 20 DOM files by layout: OK"
23097 # there should be 1 dir with default DOM striping
23098 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
23100 error "lfs find -L: found $NUM, expected 1 dir"
23101 echo "Test 2: lfs find 1 DOM dir by layout: OK"
23103 # find DoM files by stripe size
23104 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
23105 [ $NUM -eq $DOMFILES ] ||
23106 error "lfs find -S: found $NUM, expected $DOMFILES"
23107 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
23109 # find files by stripe offset except DoM files
23110 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
23111 [ $NUM -eq $NORMFILES ] ||
23112 error "lfs find -i: found $NUM, expected $NORMFILES"
23113 echo "Test 5: lfs find no DOM files by stripe index: OK"
23116 run_test 270e "DoM: lfs find with DoM files test"
23119 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23120 skip "Need MDS version at least 2.10.55"
23122 local mdtname=${FSNAME}-MDT0000-mdtlov
23123 local dom=$DIR/$tdir/dom_file
23124 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
23125 lod.$mdtname.dom_stripesize)
23126 local dom_limit=131072
23128 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
23129 local dom_current=$(do_facet mds1 $LCTL get_param -n \
23130 lod.$mdtname.dom_stripesize)
23131 [ ${dom_limit} -eq ${dom_current} ] ||
23132 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
23134 $LFS mkdir -i 0 -c 1 $DIR/$tdir
23135 $LFS setstripe -d $DIR/$tdir
23136 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
23137 error "Can't set directory default striping"
23139 # exceed maximum stripe size
23140 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
23141 error "Can't create file with $((dom_limit * 2)) DoM stripe"
23142 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
23143 error "Able to create DoM component size more than LOD limit"
23145 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
23146 dom_current=$(do_facet mds1 $LCTL get_param -n \
23147 lod.$mdtname.dom_stripesize)
23148 [ 0 -eq ${dom_current} ] ||
23149 error "Can't set zero DoM stripe limit"
23152 # attempt to create DoM file on server with disabled DoM should
23153 # remove DoM entry from layout and be succeed
23154 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
23155 error "Can't create DoM file (DoM is disabled)"
23156 [ $($LFS getstripe -L $dom) == "mdt" ] &&
23157 error "File has DoM component while DoM is disabled"
23160 # attempt to create DoM file with only DoM stripe should return error
23161 $LFS setstripe -E $dom_limit -L mdt $dom &&
23162 error "Able to create DoM-only file while DoM is disabled"
23164 # too low values to be aligned with smallest stripe size 64K
23165 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
23166 dom_current=$(do_facet mds1 $LCTL get_param -n \
23167 lod.$mdtname.dom_stripesize)
23168 [ 30000 -eq ${dom_current} ] &&
23169 error "Can set too small DoM stripe limit"
23171 # 64K is a minimal stripe size in Lustre, expect limit of that size
23172 [ 65536 -eq ${dom_current} ] ||
23173 error "Limit is not set to 64K but ${dom_current}"
23175 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
23176 dom_current=$(do_facet mds1 $LCTL get_param -n \
23177 lod.$mdtname.dom_stripesize)
23179 [ 2147483648 -eq ${dom_current} ] &&
23180 error "Can set too large DoM stripe limit"
23182 do_facet mds1 $LCTL set_param -n \
23183 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
23184 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
23185 error "Can't create DoM component size after limit change"
23186 do_facet mds1 $LCTL set_param -n \
23187 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
23188 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
23189 error "Can't create DoM file after limit decrease"
23190 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
23191 error "Can create big DoM component after limit decrease"
23192 touch ${dom}_def ||
23193 error "Can't create file with old default layout"
23195 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
23198 run_test 270f "DoM: maximum DoM stripe size checks"
23201 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
23202 skip "Need MDS version at least 2.13.52"
23203 local dom=$DIR/$tdir/$tfile
23205 $LFS mkdir -i 0 -c 1 $DIR/$tdir
23206 local lodname=${FSNAME}-MDT0000-mdtlov
23208 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
23209 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
23210 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
23211 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
23213 local dom_limit=1024
23214 local dom_threshold="50%"
23216 $LFS setstripe -d $DIR/$tdir
23217 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
23218 error "Can't set directory default striping"
23220 do_facet mds1 $LCTL set_param -n \
23221 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
23222 # set 0 threshold and create DOM file to change tunable stripesize
23223 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
23224 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
23225 error "Failed to create $dom file"
23226 # now tunable dom_cur_stripesize should reach maximum
23227 local dom_current=$(do_facet mds1 $LCTL get_param -n \
23228 lod.${lodname}.dom_stripesize_cur_kb)
23229 [[ $dom_current == $dom_limit ]] ||
23230 error "Current DOM stripesize is not maximum"
23233 # set threshold for further tests
23234 do_facet mds1 $LCTL set_param -n \
23235 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
23236 echo "DOM threshold is $dom_threshold free space"
23239 # Spoof bfree to exceed threshold
23240 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
23241 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
23242 for spfree in 40 20 0 15 30 55; do
23243 do_facet mds1 $LCTL set_param -n fail_val=$spfree
23244 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
23245 error "Failed to create $dom file"
23246 dom_def=$(do_facet mds1 $LCTL get_param -n \
23247 lod.${lodname}.dom_stripesize_cur_kb)
23248 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
23249 [[ $dom_def != $dom_current ]] ||
23250 error "Default stripe size was not changed"
23251 if (( spfree > 0 )) ; then
23252 dom_set=$($LFS getstripe -S $dom)
23253 (( dom_set == dom_def * 1024 )) ||
23254 error "DOM component size is still old"
23256 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
23257 error "DoM component is set with no free space"
23260 dom_current=$dom_def
23263 run_test 270g "DoM: default DoM stripe size depends on free space"
23266 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
23267 skip "Need MDS version at least 2.13.53"
23269 local mdtname=${FSNAME}-MDT0000-mdtlov
23270 local dom=$DIR/$tdir/$tfile
23271 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
23273 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
23274 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
23276 $LFS mkdir -i 0 -c 1 $DIR/$tdir
23277 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
23278 error "can't create OST file"
23279 # mirrored file with DOM entry in the second mirror
23280 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
23281 error "can't create mirror with DoM component"
23283 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
23285 # DOM component in the middle and has other enries in the same mirror,
23286 # should succeed but lost DoM component
23287 $LFS setstripe --copy=${dom}_1 $dom ||
23288 error "Can't create file from OST|DOM mirror layout"
23289 # check new file has no DoM layout after all
23290 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
23291 error "File has DoM component while DoM is disabled"
23293 run_test 270h "DoM: DoM stripe removal when disabled on server"
23296 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
23297 skip "Need MDS version at least 2.14.54"
23300 # DoM with plain layout
23301 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir &&
23302 error "default plain layout with DoM must fail"
23303 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir/$tfile &&
23304 error "setstripe plain file layout with DoM must fail"
23305 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir &&
23306 error "default DoM layout with bad striping must fail"
23307 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir/$tfile &&
23308 error "setstripe to DoM layout with bad striping must fail"
23311 run_test 270i "DoM: setting invalid DoM striping should fail"
23314 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23315 skip "Need MDS version at least 2.10.55"
23317 local dom=$DIR/$tdir/dom
23319 mkdir -p $DIR/$tdir
23321 $LFS setstripe -E 1024K -L mdt $dom
23323 lctl set_param -n mdc.*.stats=clear
23324 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
23325 cat $dom > /dev/null
23326 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
23327 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
23331 run_test 271a "DoM: data is cached for read after write"
23334 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23335 skip "Need MDS version at least 2.10.55"
23337 local dom=$DIR/$tdir/dom
23339 mkdir -p $DIR/$tdir
23341 $LFS setstripe -E 1024K -L mdt -E EOF $dom
23343 lctl set_param -n mdc.*.stats=clear
23344 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
23345 cancel_lru_locks mdc
23346 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
23347 # second stat to check size is cached on client
23348 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
23349 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
23350 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
23353 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
23356 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23357 skip "Need MDS version at least 2.10.55"
23359 local dom=$DIR/$tdir/dom
23361 mkdir -p $DIR/$tdir
23363 $LFS setstripe -E 1024K -L mdt -E EOF $dom
23365 lctl set_param -n mdc.*.stats=clear
23366 lctl set_param -n osc.*.stats=clear
23367 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
23368 cancel_lru_locks mdc
23369 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
23370 # second stat to check size is cached on client
23371 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
23372 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
23373 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
23374 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
23375 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
23378 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
23384 local mdt=MDT$(printf %04x $mdtidx)
23386 if [ -z $param ]; then
23387 lctl get_param -n mdc.*$mdt*.stats
23389 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
23394 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23395 skip "Need MDS version at least 2.10.55"
23397 local dom=$DIR/$tdir/dom
23399 mkdir -p $DIR/$tdir
23401 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23403 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
23404 local facet=mds$((mdtidx + 1))
23406 cancel_lru_locks mdc
23407 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
23408 createmany -o $dom 1000
23409 lctl set_param -n mdc.*.stats=clear
23410 smalliomany -w $dom 1000 200
23411 get_mdc_stats $mdtidx
23412 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
23413 # Each file has 1 open, 1 IO enqueues, total 2000
23414 # but now we have also +1 getxattr for security.capability, total 3000
23415 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
23416 unlinkmany $dom 1000
23418 cancel_lru_locks mdc
23419 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
23420 createmany -o $dom 1000
23421 lctl set_param -n mdc.*.stats=clear
23422 smalliomany -w $dom 1000 200
23423 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
23424 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
23425 # for OPEN and IO lock.
23426 [ $((enq - enq_2)) -ge 1000 ] ||
23427 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
23428 unlinkmany $dom 1000
23431 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
23433 cleanup_271def_tests() {
23439 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
23440 skip "Need MDS version at least 2.10.57"
23442 local dom=$DIR/$tdir/dom
23443 local tmp=$TMP/$tfile
23444 trap "cleanup_271def_tests $tmp" EXIT
23446 mkdir -p $DIR/$tdir
23448 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23450 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
23452 cancel_lru_locks mdc
23453 dd if=/dev/urandom of=$tmp bs=1000 count=1
23454 dd if=$tmp of=$dom bs=1000 count=1
23455 cancel_lru_locks mdc
23457 cat /etc/hosts >> $tmp
23458 lctl set_param -n mdc.*.stats=clear
23460 # append data to the same file it should update local page
23461 echo "Append to the same page"
23462 cat /etc/hosts >> $dom
23463 local num=$(get_mdc_stats $mdtidx ost_read)
23464 local ra=$(get_mdc_stats $mdtidx req_active)
23465 local rw=$(get_mdc_stats $mdtidx req_waittime)
23467 [ -z $num ] || error "$num READ RPC occured"
23468 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23472 cmp $tmp $dom || error "file miscompare"
23474 cancel_lru_locks mdc
23475 lctl set_param -n mdc.*.stats=clear
23477 echo "Open and read file"
23478 cat $dom > /dev/null
23479 local num=$(get_mdc_stats $mdtidx ost_read)
23480 local ra=$(get_mdc_stats $mdtidx req_active)
23481 local rw=$(get_mdc_stats $mdtidx req_waittime)
23483 [ -z $num ] || error "$num READ RPC occured"
23484 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23488 cmp $tmp $dom || error "file miscompare"
23492 run_test 271d "DoM: read on open (1K file in reply buffer)"
23495 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
23496 skip "Need MDS version at least 2.10.57"
23498 local dom=$DIR/$tdir/dom
23499 local tmp=$TMP/$tfile
23500 trap "cleanup_271def_tests $tmp" EXIT
23502 mkdir -p $DIR/$tdir
23504 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23506 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
23508 cancel_lru_locks mdc
23509 dd if=/dev/urandom of=$tmp bs=265000 count=1
23510 dd if=$tmp of=$dom bs=265000 count=1
23511 cancel_lru_locks mdc
23512 cat /etc/hosts >> $tmp
23513 lctl set_param -n mdc.*.stats=clear
23515 echo "Append to the same page"
23516 cat /etc/hosts >> $dom
23517 local num=$(get_mdc_stats $mdtidx ost_read)
23518 local ra=$(get_mdc_stats $mdtidx req_active)
23519 local rw=$(get_mdc_stats $mdtidx req_waittime)
23521 [ -z $num ] || error "$num READ RPC occured"
23522 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23526 cmp $tmp $dom || error "file miscompare"
23528 cancel_lru_locks mdc
23529 lctl set_param -n mdc.*.stats=clear
23531 echo "Open and read file"
23532 cat $dom > /dev/null
23533 local num=$(get_mdc_stats $mdtidx ost_read)
23534 local ra=$(get_mdc_stats $mdtidx req_active)
23535 local rw=$(get_mdc_stats $mdtidx req_waittime)
23537 [ -z $num ] && num=0
23538 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
23539 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23543 cmp $tmp $dom || error "file miscompare"
23547 run_test 271f "DoM: read on open (200K file and read tail)"
23550 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
23551 skip "Skipping due to old client or server version"
23553 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
23555 $CHECKSTAT -t file $DIR1/$tfile
23557 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
23560 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
23561 $LCTL set_param fail_loc=0x80000314
23562 rm $DIR1/$tfile || error "Unlink fails"
23564 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
23565 [ $RC -eq 0 ] || error "Failed write to stale object"
23567 run_test 271g "Discard DoM data vs client flush race"
23570 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23571 skip "Need MDS version at least 2.11.50"
23573 local dom=$DIR/$tdir/dom
23574 mkdir -p $DIR/$tdir
23576 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
23577 dd if=/dev/urandom of=$dom bs=512K count=1 ||
23578 error "failed to write data into $dom"
23579 local old_md5=$(md5sum $dom)
23581 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
23582 error "failed to migrate to the same DoM component"
23584 local new_md5=$(md5sum $dom)
23586 [ "$old_md5" == "$new_md5" ] ||
23587 error "md5sum differ: $old_md5, $new_md5"
23589 [ $($LFS getstripe -c $dom) -eq 2 ] ||
23590 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
23592 run_test 272a "DoM migration: new layout with the same DOM component"
23595 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23596 skip "Need MDS version at least 2.11.50"
23598 local dom=$DIR/$tdir/dom
23599 mkdir -p $DIR/$tdir
23600 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23602 local mdtidx=$($LFS getstripe -m $dom)
23603 local mdtname=MDT$(printf %04x $mdtidx)
23604 local facet=mds$((mdtidx + 1))
23606 local mdtfree1=$(do_facet $facet \
23607 lctl get_param -n osd*.*$mdtname.kbytesfree)
23608 dd if=/dev/urandom of=$dom bs=2M count=1 ||
23609 error "failed to write data into $dom"
23610 local old_md5=$(md5sum $dom)
23611 cancel_lru_locks mdc
23612 local mdtfree1=$(do_facet $facet \
23613 lctl get_param -n osd*.*$mdtname.kbytesfree)
23615 $LFS migrate -c2 $dom ||
23616 error "failed to migrate to the new composite layout"
23617 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
23618 error "MDT stripe was not removed"
23620 cancel_lru_locks mdc
23621 local new_md5=$(md5sum $dom)
23622 [ "$old_md5" == "$new_md5" ] ||
23623 error "$old_md5 != $new_md5"
23625 # Skip free space checks with ZFS
23626 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23627 local mdtfree2=$(do_facet $facet \
23628 lctl get_param -n osd*.*$mdtname.kbytesfree)
23629 [ $mdtfree2 -gt $mdtfree1 ] ||
23630 error "MDT space is not freed after migration"
23634 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
23637 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23638 skip "Need MDS version at least 2.11.50"
23640 local dom=$DIR/$tdir/$tfile
23641 mkdir -p $DIR/$tdir
23642 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23644 local mdtidx=$($LFS getstripe -m $dom)
23645 local mdtname=MDT$(printf %04x $mdtidx)
23646 local facet=mds$((mdtidx + 1))
23648 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23649 error "failed to write data into $dom"
23650 local old_md5=$(md5sum $dom)
23651 cancel_lru_locks mdc
23652 local mdtfree1=$(do_facet $facet \
23653 lctl get_param -n osd*.*$mdtname.kbytesfree)
23655 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
23656 error "failed to migrate to the new composite layout"
23657 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
23658 error "MDT stripe was not removed"
23660 cancel_lru_locks mdc
23661 local new_md5=$(md5sum $dom)
23662 [ "$old_md5" == "$new_md5" ] ||
23663 error "$old_md5 != $new_md5"
23665 # Skip free space checks with ZFS
23666 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23667 local mdtfree2=$(do_facet $facet \
23668 lctl get_param -n osd*.*$mdtname.kbytesfree)
23669 [ $mdtfree2 -gt $mdtfree1 ] ||
23670 error "MDS space is not freed after migration"
23674 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
23677 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23678 skip "Need MDS version at least 2.12.55"
23680 local dom=$DIR/$tdir/$tfile
23681 mkdir -p $DIR/$tdir
23682 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23684 local mdtidx=$($LFS getstripe -m $dom)
23685 local mdtname=MDT$(printf %04x $mdtidx)
23686 local facet=mds$((mdtidx + 1))
23688 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23689 error "failed to write data into $dom"
23690 local old_md5=$(md5sum $dom)
23691 cancel_lru_locks mdc
23692 local mdtfree1=$(do_facet $facet \
23693 lctl get_param -n osd*.*$mdtname.kbytesfree)
23695 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
23696 error "failed mirroring to the new composite layout"
23697 $LFS mirror resync $dom ||
23698 error "failed mirror resync"
23699 $LFS mirror split --mirror-id 1 -d $dom ||
23700 error "failed mirror split"
23702 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
23703 error "MDT stripe was not removed"
23705 cancel_lru_locks mdc
23706 local new_md5=$(md5sum $dom)
23707 [ "$old_md5" == "$new_md5" ] ||
23708 error "$old_md5 != $new_md5"
23710 # Skip free space checks with ZFS
23711 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23712 local mdtfree2=$(do_facet $facet \
23713 lctl get_param -n osd*.*$mdtname.kbytesfree)
23714 [ $mdtfree2 -gt $mdtfree1 ] ||
23715 error "MDS space is not freed after DOM mirror deletion"
23719 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
23722 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23723 skip "Need MDS version at least 2.12.55"
23725 local dom=$DIR/$tdir/$tfile
23726 mkdir -p $DIR/$tdir
23727 $LFS setstripe -c 2 $dom
23729 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23730 error "failed to write data into $dom"
23731 local old_md5=$(md5sum $dom)
23734 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
23735 error "failed mirroring to the DOM layout"
23736 $LFS mirror resync $dom ||
23737 error "failed mirror resync"
23738 $LFS mirror split --mirror-id 1 -d $dom ||
23739 error "failed mirror split"
23741 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23742 error "MDT stripe wasn't set"
23745 local new_md5=$(md5sum $dom)
23746 [ "$old_md5" == "$new_md5" ] ||
23747 error "$old_md5 != $new_md5"
23751 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
23754 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23755 skip "Need MDS version at least 2.12.55"
23757 local dom=$DIR/$tdir/$tfile
23758 mkdir -p $DIR/$tdir
23759 $LFS setstripe -c 2 $dom
23761 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23762 error "failed to write data into $dom"
23763 local old_md5=$(md5sum $dom)
23766 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
23767 error "failed migrating to the DOM file"
23769 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23770 error "MDT stripe wasn't set"
23773 local new_md5=$(md5sum $dom)
23774 [ "$old_md5" != "$new_md5" ] &&
23775 error "$old_md5 != $new_md5"
23779 run_test 272f "DoM migration: OST-striped file to DOM file"
23782 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23783 skip "Need MDS version at least 2.11.50"
23785 # Layout swap cannot be done if either file has DOM component,
23786 # this will never be supported, migration should be used instead
23788 local dom=$DIR/$tdir/$tfile
23789 mkdir -p $DIR/$tdir
23791 $LFS setstripe -c2 ${dom}_plain
23792 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
23793 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
23794 error "can swap layout with DoM component"
23795 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
23796 error "can swap layout with DoM component"
23798 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
23799 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
23800 error "can swap layout with DoM component"
23801 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
23802 error "can swap layout with DoM component"
23805 run_test 273a "DoM: layout swapping should fail with DOM"
23808 mkdir -p $DIR/$tdir
23809 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
23811 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
23812 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
23814 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
23816 run_test 273b "DoM: race writeback and object destroy"
23819 remote_ost_nodsh && skip "remote OST with nodsh"
23820 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
23821 skip "Need OST version >= 2.10.57"
23823 local file=$DIR/$tfile
23826 oss=$(comma_list $(osts_nodes))
23828 dd if=/dev/urandom of=$file bs=1M count=2 ||
23829 error "failed to create a file"
23830 cancel_lru_locks osc
23833 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23834 error "failed to read a file"
23836 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
23837 $LCTL set_param fail_loc=0x8000031f
23839 cancel_lru_locks osc &
23842 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
23843 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
23844 #IO takes another lock, but matches the PENDING one
23845 #and places it to the IO RPC
23846 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23847 error "failed to read a file with PENDING lock"
23849 run_test 275 "Read on a canceled duplicate lock"
23852 remote_ost_nodsh && skip "remote OST with nodsh"
23855 do_facet ost1 "(while true; do \
23856 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
23857 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
23860 for LOOP in $(seq 20); do
23862 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
23865 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
23866 rm $TMP/sanity_276_pid"
23868 run_test 276 "Race between mount and obd_statfs"
23871 $LCTL set_param ldlm.namespaces.*.lru_size=0
23872 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23873 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23874 grep ^used_mb | awk '{print $2}')
23875 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
23876 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
23877 oflag=direct conv=notrunc
23878 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23879 grep ^used_mb | awk '{print $2}')
23880 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
23882 run_test 277 "Direct IO shall drop page cache"
23885 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
23886 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23887 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
23888 skip "needs the same host for mdt1 mdt2" && return
23893 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
23894 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
23900 echo "Starting MDTs"
23901 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
23903 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
23905 do_facet mds2 $LCTL set_param fail_loc=0
23907 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
23908 wait_recovery_complete mds2
23910 run_test 278 "Race starting MDS between MDTs stop/start"
23913 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
23914 skip "Need MGS version at least 2.13.52"
23915 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23916 combined_mgs_mds || skip "needs combined MGS/MDT"
23918 umount_client $MOUNT
23919 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
23920 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
23922 mount_client $MOUNT &
23924 stop mgs || error "stop mgs failed"
23925 #for a race mgs would crash
23926 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
23927 # make sure we unmount client before remounting
23929 umount_client $MOUNT
23930 mount_client $MOUNT || error "mount client failed"
23932 run_test 280 "Race between MGS umount and client llog processing"
23934 cleanup_test_300() {
23938 test_striped_dir() {
23943 mkdir -p $DIR/$tdir
23945 SAVE_UMASK=$(umask)
23946 trap cleanup_test_300 RETURN EXIT
23948 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
23949 $DIR/$tdir/striped_dir ||
23950 error "set striped dir error"
23952 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
23953 [ "$mode" = "755" ] || error "expect 755 got $mode"
23955 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
23956 error "getdirstripe failed"
23957 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
23958 if [ "$stripe_count" != "2" ]; then
23959 error "1:stripe_count is $stripe_count, expect 2"
23961 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
23962 if [ "$stripe_count" != "2" ]; then
23963 error "2:stripe_count is $stripe_count, expect 2"
23966 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
23967 if [ "$stripe_index" != "$mdt_index" ]; then
23968 error "stripe_index is $stripe_index, expect $mdt_index"
23971 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23972 error "nlink error after create striped dir"
23974 mkdir $DIR/$tdir/striped_dir/a
23975 mkdir $DIR/$tdir/striped_dir/b
23977 stat $DIR/$tdir/striped_dir/a ||
23978 error "create dir under striped dir failed"
23979 stat $DIR/$tdir/striped_dir/b ||
23980 error "create dir under striped dir failed"
23982 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
23983 error "nlink error after mkdir"
23985 rmdir $DIR/$tdir/striped_dir/a
23986 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
23987 error "nlink error after rmdir"
23989 rmdir $DIR/$tdir/striped_dir/b
23990 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23991 error "nlink error after rmdir"
23993 chattr +i $DIR/$tdir/striped_dir
23994 createmany -o $DIR/$tdir/striped_dir/f 10 &&
23995 error "immutable flags not working under striped dir!"
23996 chattr -i $DIR/$tdir/striped_dir
23998 rmdir $DIR/$tdir/striped_dir ||
23999 error "rmdir striped dir error"
24007 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
24008 skip "skipped for lustre < 2.7.0"
24009 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24010 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24012 test_striped_dir 0 || error "failed on striped dir on MDT0"
24013 test_striped_dir 1 || error "failed on striped dir on MDT0"
24015 run_test 300a "basic striped dir sanity test"
24018 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
24019 skip "skipped for lustre < 2.7.0"
24020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24021 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24028 test_mkdir $DIR/$tdir || error "mkdir fail"
24029 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
24030 error "set striped dir error"
24031 for i in {0..9}; do
24032 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
24034 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
24035 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
24036 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
24038 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
24039 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
24040 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
24044 run_test 300b "check ctime/mtime for striped dir"
24047 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
24048 skip "skipped for lustre < 2.7.0"
24049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24050 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24054 mkdir_on_mdt0 $DIR/$tdir
24055 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
24056 error "set striped dir error"
24058 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
24059 error "chown striped dir failed"
24061 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
24062 error "create 5k files failed"
24064 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
24066 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
24070 run_test 300c "chown && check ls under striped directory"
24073 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
24074 skip "skipped for lustre < 2.7.0"
24075 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24076 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24081 mkdir -p $DIR/$tdir
24082 $LFS setstripe -c 2 $DIR/$tdir
24084 #local striped directory
24085 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
24086 error "set striped dir error"
24087 #look at the directories for debug purposes
24089 $LFS getdirstripe $DIR/$tdir
24090 ls -l $DIR/$tdir/striped_dir
24091 $LFS getdirstripe $DIR/$tdir/striped_dir
24092 createmany -o $DIR/$tdir/striped_dir/f 10 ||
24093 error "create 10 files failed"
24095 #remote striped directory
24096 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
24097 error "set striped dir error"
24098 #look at the directories for debug purposes
24100 $LFS getdirstripe $DIR/$tdir
24101 ls -l $DIR/$tdir/remote_striped_dir
24102 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
24103 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
24104 error "create 10 files failed"
24106 for file in $(find $DIR/$tdir); do
24107 stripe_count=$($LFS getstripe -c $file)
24108 [ $stripe_count -eq 2 ] ||
24109 error "wrong stripe $stripe_count for $file"
24114 run_test 300d "check default stripe under striped directory"
24117 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24118 skip "Need MDS version at least 2.7.55"
24119 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24120 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24125 mkdir -p $DIR/$tdir
24127 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
24128 error "set striped dir error"
24130 touch $DIR/$tdir/striped_dir/a
24131 touch $DIR/$tdir/striped_dir/b
24132 touch $DIR/$tdir/striped_dir/c
24134 mkdir $DIR/$tdir/striped_dir/dir_a
24135 mkdir $DIR/$tdir/striped_dir/dir_b
24136 mkdir $DIR/$tdir/striped_dir/dir_c
24138 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
24139 error "set striped adir under striped dir error"
24141 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
24142 error "set striped bdir under striped dir error"
24144 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
24145 error "set striped cdir under striped dir error"
24147 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
24148 error "rename dir under striped dir fails"
24150 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
24151 error "rename dir under different stripes fails"
24153 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
24154 error "rename file under striped dir should succeed"
24156 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
24157 error "rename dir under striped dir should succeed"
24161 run_test 300e "check rename under striped directory"
24164 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24165 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24166 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24167 skip "Need MDS version at least 2.7.55"
24173 mkdir -p $DIR/$tdir
24175 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
24176 error "set striped dir error"
24178 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
24179 error "set striped dir error"
24181 touch $DIR/$tdir/striped_dir/a
24182 mkdir $DIR/$tdir/striped_dir/dir_a
24183 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
24184 error "create striped dir under striped dir fails"
24186 touch $DIR/$tdir/striped_dir1/b
24187 mkdir $DIR/$tdir/striped_dir1/dir_b
24188 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
24189 error "create striped dir under striped dir fails"
24191 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
24192 error "rename dir under different striped dir should fail"
24194 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
24195 error "rename striped dir under diff striped dir should fail"
24197 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
24198 error "rename file under diff striped dirs fails"
24202 run_test 300f "check rename cross striped directory"
24204 test_300_check_default_striped_dir()
24207 local default_count=$2
24208 local default_index=$3
24211 local dir_stripe_index
24214 echo "checking $dirname $default_count $default_index"
24215 $LFS setdirstripe -D -c $default_count -i $default_index \
24216 -H all_char $DIR/$tdir/$dirname ||
24217 error "set default stripe on striped dir error"
24218 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
24219 [ $stripe_count -eq $default_count ] ||
24220 error "expect $default_count get $stripe_count for $dirname"
24222 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
24223 [ $stripe_index -eq $default_index ] ||
24224 error "expect $default_index get $stripe_index for $dirname"
24226 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
24227 error "create dirs failed"
24229 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
24230 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
24231 for dir in $(find $DIR/$tdir/$dirname/*); do
24232 stripe_count=$($LFS getdirstripe -c $dir)
24233 (( $stripe_count == $default_count )) ||
24234 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
24235 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
24236 error "stripe count $default_count != $stripe_count for $dir"
24238 stripe_index=$($LFS getdirstripe -i $dir)
24239 [ $default_index -eq -1 ] ||
24240 [ $stripe_index -eq $default_index ] ||
24241 error "$stripe_index != $default_index for $dir"
24243 #check default stripe
24244 stripe_count=$($LFS getdirstripe -D -c $dir)
24245 [ $stripe_count -eq $default_count ] ||
24246 error "default count $default_count != $stripe_count for $dir"
24248 stripe_index=$($LFS getdirstripe -D -i $dir)
24249 [ $stripe_index -eq $default_index ] ||
24250 error "default index $default_index != $stripe_index for $dir"
24252 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
24256 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24257 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24258 skip "Need MDS version at least 2.7.55"
24264 mkdir_on_mdt0 $DIR/$tdir
24265 mkdir $DIR/$tdir/normal_dir
24267 #Checking when client cache stripe index
24268 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
24269 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
24270 error "create striped_dir failed"
24272 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
24273 error "create dir0 fails"
24274 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
24275 [ $stripe_index -eq 0 ] ||
24276 error "dir0 expect index 0 got $stripe_index"
24278 mkdir $DIR/$tdir/striped_dir/dir1 ||
24279 error "create dir1 fails"
24280 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
24281 [ $stripe_index -eq 1 ] ||
24282 error "dir1 expect index 1 got $stripe_index"
24284 #check default stripe count/stripe index
24285 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
24286 test_300_check_default_striped_dir normal_dir 1 0
24287 test_300_check_default_striped_dir normal_dir -1 1
24288 test_300_check_default_striped_dir normal_dir 2 -1
24290 #delete default stripe information
24291 echo "delete default stripeEA"
24292 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
24293 error "set default stripe on striped dir error"
24295 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
24296 for dir in $(find $DIR/$tdir/normal_dir/*); do
24297 stripe_count=$($LFS getdirstripe -c $dir)
24298 [ $stripe_count -eq 0 ] ||
24299 error "expect 1 get $stripe_count for $dir"
24302 run_test 300g "check default striped directory for normal directory"
24305 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24306 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24307 skip "Need MDS version at least 2.7.55"
24313 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
24314 error "set striped dir error"
24316 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
24317 test_300_check_default_striped_dir striped_dir 1 0
24318 test_300_check_default_striped_dir striped_dir -1 1
24319 test_300_check_default_striped_dir striped_dir 2 -1
24321 #delete default stripe information
24322 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
24323 error "set default stripe on striped dir error"
24325 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
24326 for dir in $(find $DIR/$tdir/striped_dir/*); do
24327 stripe_count=$($LFS getdirstripe -c $dir)
24328 [ $stripe_count -eq 0 ] ||
24329 error "expect 1 get $stripe_count for $dir"
24332 run_test 300h "check default striped directory for striped directory"
24335 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
24336 (( $MDSCOUNT >= 2 )) || skip_env "needs >= 2 MDTs"
24337 (( $MDS1_VERSION >= $(version_code 2.7.55) )) ||
24338 skip "Need MDS version at least 2.7.55"
24345 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
24346 error "set striped dir error"
24348 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
24349 error "create files under striped dir failed"
24351 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
24352 error "set striped hashdir error"
24354 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
24355 error "create dir0 under hash dir failed"
24356 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
24357 error "create dir1 under hash dir failed"
24358 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
24359 error "create dir2 under hash dir failed"
24361 # unfortunately, we need to umount to clear dir layout cache for now
24362 # once we fully implement dir layout, we can drop this
24363 umount_client $MOUNT || error "umount failed"
24364 mount_client $MOUNT || error "mount failed"
24366 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
24367 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
24368 (( $dircnt == 2 )) || error "lfs find striped dir got $dircnt != 2"
24370 if (( $MDS1_VERSION > $(version_code 2.15.0) )); then
24371 $LFS mkdir -i0 -c$MDSCOUNT -H crush2 $DIR/$tdir/hashdir/d3 ||
24372 error "create crush2 dir $tdir/hashdir/d3 failed"
24373 $LFS find -H crush2 $DIR/$tdir/hashdir
24374 dircnt=$($LFS find -H crush2 $DIR/$tdir/hashdir | wc -l)
24375 (( $dircnt == 1 )) || error "find crush2 dir got $dircnt != 1"
24377 # mkdir with an invalid hash type (hash=fail_val) from client
24378 # should be replaced on MDS with a valid (default) hash type
24379 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
24380 $LCTL set_param fail_loc=0x1901 fail_val=99
24381 $LFS mkdir -c2 $DIR/$tdir/hashdir/d99
24383 local hash=$($LFS getdirstripe -H $DIR/$tdir/hashdir/d99)
24384 local expect=$(do_facet mds1 \
24385 $LCTL get_param -n lod.$FSNAME-MDT0000-mdtlov.mdt_hash)
24386 [[ $hash == $expect ]] ||
24387 error "d99 hash '$hash' != expected hash '$expect'"
24390 #set the stripe to be unknown hash type on read
24391 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
24392 $LCTL set_param fail_loc=0x1901 fail_val=99
24393 for ((i = 0; i < 10; i++)); do
24394 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
24395 error "stat f-$i failed"
24396 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
24399 touch $DIR/$tdir/striped_dir/f0 &&
24400 error "create under striped dir with unknown hash should fail"
24402 $LCTL set_param fail_loc=0
24404 umount_client $MOUNT || error "umount failed"
24405 mount_client $MOUNT || error "mount failed"
24409 run_test 300i "client handle unknown hash type striped directory"
24412 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24413 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24414 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24415 skip "Need MDS version at least 2.7.55"
24422 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
24423 $LCTL set_param fail_loc=0x1702
24424 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
24425 error "set striped dir error"
24427 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
24428 error "create files under striped dir failed"
24430 $LCTL set_param fail_loc=0
24432 rm -rf $DIR/$tdir || error "unlink striped dir fails"
24436 run_test 300j "test large update record"
24439 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24440 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24441 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24442 skip "Need MDS version at least 2.7.55"
24444 # this test needs a huge transaction
24446 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24447 osd*.$FSNAME-MDT0000.kbytestotal")
24448 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
24455 #define OBD_FAIL_LARGE_STRIPE 0x1703
24456 $LCTL set_param fail_loc=0x1703
24457 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
24458 error "set striped dir error"
24459 $LCTL set_param fail_loc=0
24461 $LFS getdirstripe $DIR/$tdir/striped_dir ||
24462 error "getstripeddir fails"
24463 rm -rf $DIR/$tdir/striped_dir ||
24464 error "unlink striped dir fails"
24468 run_test 300k "test large striped directory"
24471 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24472 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24473 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24474 skip "Need MDS version at least 2.7.55"
24478 test_mkdir -p $DIR/$tdir/striped_dir
24479 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
24480 error "chown $RUNAS_ID failed"
24481 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
24482 error "set default striped dir failed"
24484 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
24485 $LCTL set_param fail_loc=0x80000158
24486 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
24488 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
24489 [ $stripe_index -eq 1 ] ||
24490 error "expect 1 get $stripe_index for $dir"
24492 run_test 300l "non-root user to create dir under striped dir with stale layout"
24495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24496 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
24497 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24498 skip "Need MDS version at least 2.7.55"
24500 mkdir -p $DIR/$tdir/striped_dir
24501 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
24502 error "set default stripes dir error"
24504 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
24506 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
24507 [ $stripe_count -eq 0 ] ||
24508 error "expect 0 get $stripe_count for a"
24510 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
24511 error "set default stripes dir error"
24513 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
24515 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
24516 [ $stripe_count -eq 0 ] ||
24517 error "expect 0 get $stripe_count for b"
24519 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
24520 error "set default stripes dir error"
24522 mkdir $DIR/$tdir/striped_dir/c &&
24523 error "default stripe_index is invalid, mkdir c should fails"
24525 rm -rf $DIR/$tdir || error "rmdir fails"
24527 run_test 300m "setstriped directory on single MDT FS"
24530 local list=$(comma_list $(mdts_nodes))
24533 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24537 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24538 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24539 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24540 skip "Need MDS version at least 2.7.55"
24541 remote_mds_nodsh && skip "remote MDS with nodsh"
24544 local list=$(comma_list $(mdts_nodes))
24546 trap cleanup_300n RETURN EXIT
24547 mkdir -p $DIR/$tdir
24548 chmod 777 $DIR/$tdir
24549 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
24550 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
24551 error "create striped dir succeeds with gid=0"
24553 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
24554 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
24555 error "create striped dir fails with gid=-1"
24557 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24558 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
24559 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
24560 error "set default striped dir succeeds with gid=0"
24563 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
24564 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
24565 error "set default striped dir fails with gid=-1"
24568 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24569 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
24570 error "create test_dir fails"
24571 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
24572 error "create test_dir1 fails"
24573 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
24574 error "create test_dir2 fails"
24577 run_test 300n "non-root user to create dir under striped dir with default EA"
24580 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24581 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24582 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24583 skip "Need MDS version at least 2.7.55"
24588 mkdir -p $DIR/$tdir
24590 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
24591 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
24592 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
24593 skip "not enough free inodes $numfree1 $numfree2"
24596 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
24597 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
24598 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
24599 skip "not enough free space $numfree1 $numfree2"
24602 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
24603 error "setdirstripe fails"
24605 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
24606 error "create dirs fails"
24608 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
24609 ls $DIR/$tdir/striped_dir > /dev/null ||
24610 error "ls striped dir fails"
24611 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
24612 error "unlink big striped dir fails"
24614 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
24617 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24618 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24619 remote_mds_nodsh && skip "remote MDS with nodsh"
24621 mkdir_on_mdt0 $DIR/$tdir
24623 #define OBD_FAIL_OUT_ENOSPC 0x1704
24624 do_facet mds2 lctl set_param fail_loc=0x80001704
24625 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
24626 && error "create striped directory should fail"
24628 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
24630 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
24633 run_test 300p "create striped directory without space"
24636 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24637 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24639 local fd=$(free_fd)
24640 local cmd="exec $fd<$tdir"
24642 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
24645 trap "eval $cmd" EXIT
24646 cd $tdir || error "cd $tdir fails"
24647 rmdir ../$tdir || error "rmdir $tdir fails"
24648 mkdir local_dir && error "create dir succeeds"
24649 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
24653 run_test 300q "create remote directory under orphan directory"
24656 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24657 skip "Need MDS version at least 2.7.55" && return
24658 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24662 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
24663 error "set striped dir error"
24665 $LFS getdirstripe $DIR/$tdir/striped_dir ||
24666 error "getstripeddir fails"
24669 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
24670 awk '/lmv_stripe_count:/ { print $2 }')
24672 [ $MDSCOUNT -ne $stripe_count ] &&
24673 error "wrong stripe count $stripe_count expected $MDSCOUNT"
24675 rm -rf $DIR/$tdir/striped_dir ||
24676 error "unlink striped dir fails"
24678 run_test 300r "test -1 striped directory"
24680 test_300s_helper() {
24683 local stripe_dir=$DIR/$tdir/striped_dir.$count
24685 $LFS mkdir -c $count $stripe_dir ||
24686 error "lfs mkdir -c error"
24688 $LFS getdirstripe $stripe_dir ||
24689 error "lfs getdirstripe fails"
24692 stripe_count=$($LFS getdirstripe $stripe_dir |
24693 awk '/lmv_stripe_count:/ { print $2 }')
24695 [ $count -ne $stripe_count ] &&
24696 error_noexit "bad stripe count $stripe_count expected $count"
24699 dupe_stripes=$($LFS getdirstripe $stripe_dir |
24700 awk '/0x/ {count[$1] += 1}; END {
24701 for (idx in count) {
24702 if (count[idx]>1) {
24703 print "index " idx " count " count[idx]
24708 if [[ -n "$dupe_stripes" ]] ; then
24709 lfs getdirstripe $stripe_dir
24710 error_noexit "Dupe MDT above: $dupe_stripes "
24713 rm -rf $stripe_dir ||
24714 error_noexit "unlink $stripe_dir fails"
24718 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24719 skip "Need MDS version at least 2.7.55" && return
24720 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24723 for count in $(seq 2 $MDSCOUNT); do
24724 test_300s_helper $count
24727 run_test 300s "test lfs mkdir -c without -i"
24730 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
24731 skip "need MDS 2.14.55 or later"
24732 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
24734 local testdir="$DIR/$tdir/striped_dir"
24735 local dir1=$testdir/dir1
24736 local dir2=$testdir/dir2
24740 $LFS setdirstripe -D -c -1 --max-inherit=3 $testdir ||
24741 error "failed to set default stripe count for $testdir"
24744 local stripe_count=$($LFS getdirstripe -c $dir1)
24746 (( $stripe_count == $MDSCOUNT )) || error "wrong stripe count"
24748 local max_count=$((MDSCOUNT - 1))
24749 local mdts=$(comma_list $(mdts_nodes))
24751 do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=$max_count
24752 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=0"
24755 stripe_count=$($LFS getdirstripe -c $dir2)
24757 (( $stripe_count == $max_count )) || error "wrong stripe count"
24759 run_test 300t "test max_mdt_stripecount"
24761 prepare_remote_file() {
24762 mkdir $DIR/$tdir/src_dir ||
24763 error "create remote source failed"
24765 cp /etc/hosts $DIR/$tdir/src_dir/a ||
24766 error "cp to remote source failed"
24767 touch $DIR/$tdir/src_dir/a
24769 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
24770 error "create remote target dir failed"
24772 touch $DIR/$tdir/tgt_dir/b
24774 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
24775 error "rename dir cross MDT failed!"
24777 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
24778 error "src_child still exists after rename"
24780 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
24781 error "missing file(a) after rename"
24783 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
24784 error "diff after rename"
24788 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24789 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24791 local remote_file=$DIR/$tdir/tgt_dir/b
24793 mkdir -p $DIR/$tdir
24795 prepare_remote_file || error "prepare remote file failed"
24798 $OPENUNLINK $remote_file $remote_file ||
24799 error "openunlink $remote_file failed"
24800 $CHECKSTAT -a $remote_file || error "$remote_file exists"
24802 run_test 310a "open unlink remote file"
24805 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24806 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24808 local remote_file=$DIR/$tdir/tgt_dir/b
24810 mkdir -p $DIR/$tdir
24812 prepare_remote_file || error "prepare remote file failed"
24814 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24815 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
24816 $CHECKSTAT -t file $remote_file || error "check file failed"
24818 run_test 310b "unlink remote file with multiple links while open"
24821 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24822 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
24824 local remote_file=$DIR/$tdir/tgt_dir/b
24826 mkdir -p $DIR/$tdir
24828 prepare_remote_file || error "prepare remote file failed"
24830 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24831 multiop_bg_pause $remote_file O_uc ||
24832 error "mulitop failed for remote file"
24834 $MULTIOP $DIR/$tfile Ouc
24835 kill -USR1 $MULTIPID
24838 run_test 310c "open-unlink remote file with multiple links"
24842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24843 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
24844 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
24845 skip "lustre < 2.8.54 does not contain LU-4825 fix"
24846 remote_mds_nodsh && skip "remote MDS with nodsh"
24848 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24849 local mdts=$(comma_list $(mdts_nodes))
24851 mkdir -p $DIR/$tdir
24852 $LFS setstripe -i 0 -c 1 $DIR/$tdir
24853 createmany -o $DIR/$tdir/$tfile. 1000
24855 # statfs data is not real time, let's just calculate it
24856 old_iused=$((old_iused + 1000))
24858 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24859 osp.*OST0000*MDT0000.create_count")
24860 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24861 osp.*OST0000*MDT0000.max_create_count")
24862 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
24864 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
24865 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
24866 [ $index -ne 0 ] || error "$tfile stripe index is 0"
24868 unlinkmany $DIR/$tdir/$tfile. 1000
24870 do_nodes $mdts "$LCTL set_param -n \
24871 osp.*OST0000*.max_create_count=$max_count"
24872 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
24873 do_nodes $mdts "$LCTL set_param -n \
24874 osp.*OST0000*.create_count=$count"
24875 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
24876 grep "=0" && error "create_count is zero"
24879 for i in $(seq 120); do
24880 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24881 # system may be too busy to destroy all objs in time, use
24882 # a somewhat small value to not fail autotest
24883 [ $((old_iused - new_iused)) -gt 400 ] && break
24887 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
24888 [ $((old_iused - new_iused)) -gt 400 ] ||
24889 error "objs not destroyed after unlink"
24891 run_test 311 "disable OSP precreate, and unlink should destroy objs"
24897 local fid=($($LFS getstripe $tf | grep 0x))
24898 local seq=${fid[3]#0x}
24899 local objid=${fid[1]}
24901 local vdevdir=$(dirname $(facet_vdevice $ost))
24902 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
24903 local zfs_zapid=$(do_facet $ost $cmd |
24904 grep -w "/O/$seq/d$((objid%32))" -C 5 |
24905 awk '/Object/{getline; print $1}')
24906 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
24907 awk "/$objid = /"'{printf $3}')
24912 zfs_object_blksz() {
24916 local vdevdir=$(dirname $(facet_vdevice $ost))
24917 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
24918 local blksz=$(do_facet $ost $cmd $objid |
24919 awk '/dblk/{getline; printf $4}')
24921 case "${blksz: -1}" in
24922 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
24923 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
24930 test_312() { # LU-4856
24931 remote_ost_nodsh && skip "remote OST with nodsh"
24932 [[ "$ost1_FSTYPE" == "zfs" ]] || skip "the test only applies to zfs"
24934 local max_blksz=$(do_facet ost1 \
24935 $ZFS get -p recordsize $(facet_device ost1) |
24936 awk '!/VALUE/{print $3}')
24937 local tf=$DIR/$tfile
24939 $LFS setstripe -c1 $tf
24940 local facet="ost$(($($LFS getstripe -i $tf) + 1))"
24942 # Get ZFS object id
24943 local zfs_objid=$(zfs_get_objid $facet $tf)
24944 # block size change by sequential overwrite
24947 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
24948 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
24950 local blksz=$(zfs_object_blksz $facet $zfs_objid)
24951 [[ $blksz -eq $bs ]] || error "blksz error: $blksz, expected: $bs"
24955 $LFS setstripe -c1 $tf
24956 facet="ost$(($($LFS getstripe -i $tf) + 1))"
24958 # block size change by sequential append write
24959 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
24960 zfs_objid=$(zfs_get_objid $facet $tf)
24963 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
24964 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
24965 oflag=sync conv=notrunc
24967 blksz=$(zfs_object_blksz $facet $zfs_objid)
24968 (( $blksz == 2 * count * PAGE_SIZE )) ||
24969 error "blksz error, actual $blksz, " \
24970 "expected: 2 * $count * $PAGE_SIZE"
24975 $LFS setstripe -c1 $tf
24976 facet="ost$(($($LFS getstripe -i $tf) + 1))"
24977 zfs_objid=$(zfs_get_objid $facet $tf)
24979 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
24980 blksz=$(zfs_object_blksz $facet $zfs_objid)
24981 (( blksz == PAGE_SIZE )) ||
24982 error "blksz error: $blksz, expected: $PAGE_SIZE"
24984 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
24985 blksz=$(zfs_object_blksz $facet $zfs_objid)
24986 (( blksz == 65536 )) || error "blksz error: $blksz, expected: 64k"
24988 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
24989 blksz=$(zfs_object_blksz $facet $zfs_objid)
24990 (( blksz == 65536 )) || error "rewrite error: $blksz, expected: 64k"
24992 run_test 312 "make sure ZFS adjusts its block size by write pattern"
24995 remote_ost_nodsh && skip "remote OST with nodsh"
24997 local file=$DIR/$tfile
25000 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
25002 # define OBD_FAIL_TGT_RCVD_EIO 0x720
25003 do_facet ost1 "$LCTL set_param fail_loc=0x720"
25004 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
25005 error "write should failed"
25006 do_facet ost1 "$LCTL set_param fail_loc=0"
25009 run_test 313 "io should fail after last_rcvd update fail"
25012 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
25014 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
25015 do_facet ost1 "$LCTL set_param fail_loc=0x720"
25017 wait_delete_completed
25018 do_facet ost1 "$LCTL set_param fail_loc=0"
25020 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
25022 test_315() { # LU-618
25023 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
25025 local file=$DIR/$tfile
25028 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
25029 error "multiop file write failed"
25030 $MULTIOP $file oO_RDONLY:r4063232_c &
25035 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
25038 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
25041 run_test 315 "read should be accounted"
25044 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
25045 large_xattr_enabled || skip "ea_inode feature disabled"
25047 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
25048 mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
25049 chown nobody $DIR/$tdir/d || error "chown $tdir/d failed"
25050 touch $DIR/$tdir/d/$tfile || error "touch $tdir/d/$tfile failed"
25052 $LFS migrate -m1 $DIR/$tdir/d || error "lfs migrate -m1 failed"
25054 run_test 316 "lfs migrate of file with large_xattr enabled"
25057 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
25058 skip "Need MDS version at least 2.11.53"
25059 if [ "$ost1_FSTYPE" == "zfs" ]; then
25060 skip "LU-10370: no implementation for ZFS"
25064 local grant_blk_size
25066 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
25067 awk '/grant_block_size:/ { print $2; exit; }')
25069 # Create File of size 5M. Truncate it to below size's and verify
25072 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
25073 error "Create file $DIR/$tfile failed"
25074 stack_trap "rm -f $DIR/$tfile" EXIT
25076 for trunc_sz in 2097152 4097 4000 509 0; do
25077 $TRUNCATE $DIR/$tfile $trunc_sz ||
25078 error "truncate $tfile to $trunc_sz failed"
25079 local sz=$(stat --format=%s $DIR/$tfile)
25080 local blk=$(stat --format=%b $DIR/$tfile)
25081 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
25082 grant_blk_size) * 8))
25084 if [[ $blk -ne $trunc_blk ]]; then
25085 $(which stat) $DIR/$tfile
25086 error "Expected Block $trunc_blk got $blk for $tfile"
25089 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
25090 error "Expected Size $trunc_sz got $sz for $tfile"
25095 # Create file with a hole and write actual 65536 bytes which aligned
25096 # with 4K and 64K PAGE_SIZE. Block count must be 128.
25099 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 seek=5 conv=fsync ||
25100 error "Create file : $DIR/$tfile"
25103 # Truncate to size $trunc_sz bytes. Strip tail blocks and leave only 8
25104 # blocks. The block count must drop to 8.
25106 trunc_sz=$(($(stat --format=%s $DIR/$tfile) -
25107 ((bs - grant_blk_size) + 1)))
25108 $TRUNCATE $DIR/$tfile $trunc_sz ||
25109 error "truncate $tfile to $trunc_sz failed"
25111 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
25112 sz=$(stat --format=%s $DIR/$tfile)
25113 blk=$(stat --format=%b $DIR/$tfile)
25115 if [[ $blk -ne $trunc_bsz ]]; then
25116 $(which stat) $DIR/$tfile
25117 error "Expected Block $trunc_bsz got $blk for $tfile"
25120 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
25121 error "Expected Size $trunc_sz got $sz for $tfile"
25123 run_test 317 "Verify blocks get correctly update after truncate"
25126 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
25127 local old_max_active=$($LCTL get_param -n \
25128 ${llite_name}.max_read_ahead_async_active \
25131 $LCTL set_param llite.*.max_read_ahead_async_active=256
25132 local max_active=$($LCTL get_param -n \
25133 ${llite_name}.max_read_ahead_async_active \
25135 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
25137 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
25138 error "set max_read_ahead_async_active should succeed"
25140 $LCTL set_param llite.*.max_read_ahead_async_active=512
25141 max_active=$($LCTL get_param -n \
25142 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
25143 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
25145 # restore @max_active
25146 [ $old_max_active -ne 0 ] && $LCTL set_param \
25147 llite.*.max_read_ahead_async_active=$old_max_active
25149 local old_threshold=$($LCTL get_param -n \
25150 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
25151 local max_per_file_mb=$($LCTL get_param -n \
25152 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
25154 local invalid=$(($max_per_file_mb + 1))
25156 llite.*.read_ahead_async_file_threshold_mb=$invalid\
25157 && error "set $invalid should fail"
25159 local valid=$(($invalid - 1))
25161 llite.*.read_ahead_async_file_threshold_mb=$valid ||
25162 error "set $valid should succeed"
25163 local threshold=$($LCTL get_param -n \
25164 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
25165 [ $threshold -eq $valid ] || error \
25166 "expect threshold $valid got $threshold"
25168 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
25170 run_test 318 "Verify async readahead tunables"
25173 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
25175 local before=$(date +%s)
25177 local mdir=$DIR/$tdir
25178 local file=$mdir/xxx
25180 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
25183 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
25184 $LCTL set_param fail_val=5 fail_loc=0x8000032c
25185 $LFS migrate -m1 $mdir &
25188 dd if=$file of=/dev/null
25190 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
25191 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
25193 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
25195 run_test 319 "lost lease lock on migrate error"
25197 test_398a() { # LU-4198
25198 local ost1_imp=$(get_osc_import_name client ost1)
25199 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
25202 $LFS setstripe -c 1 -i 0 $DIR/$tfile
25203 $LCTL set_param ldlm.namespaces.*.lru_size=clear
25205 # Disabled: DIO does not push out buffered I/O pages, see LU-12587
25206 # request a new lock on client
25207 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
25209 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
25210 #local lock_count=$($LCTL get_param -n \
25211 # ldlm.namespaces.$imp_name.lru_size)
25212 #[[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
25214 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
25216 # no lock cached, should use lockless DIO and not enqueue new lock
25217 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct \
25219 error "dio write failed"
25220 lock_count=$($LCTL get_param -n \
25221 ldlm.namespaces.$imp_name.lru_size)
25222 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
25224 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
25226 # no lock cached, should use locked DIO append
25227 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct oflag=append \
25228 conv=notrunc || error "DIO append failed"
25229 lock_count=$($LCTL get_param -n \
25230 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
25231 [[ $lock_count -ne 0 ]] || error "lock still must be held by DIO append"
25233 run_test 398a "direct IO should cancel lock otherwise lockless"
25235 test_398b() { # LU-4198
25236 local before=$(date +%s)
25240 which fio || skip_env "no fio installed"
25241 $LFS setstripe -c -1 -S 1M $DIR/$tfile
25242 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
25244 # Single page, multiple pages, stripe size, 4*stripe size
25245 for bsize in $(( $PAGE_SIZE )) $(( 4*$PAGE_SIZE )) 1048576 4194304; do
25246 echo "mix direct rw ${bsize} by fio with $njobs jobs..."
25247 fio --name=rand-rw --rw=randrw --bs=$bsize --direct=1 \
25248 --numjobs=$njobs --fallocate=none \
25249 --iodepth=16 --allow_file_create=0 \
25250 --size=$((size/njobs))M \
25251 --filename=$DIR/$tfile &
25254 echo "mix buffer rw ${bsize} by fio with $njobs jobs..."
25255 fio --name=rand-rw --rw=randrw --bs=$bsize \
25256 --numjobs=$njobs --fallocate=none \
25257 --iodepth=16 --allow_file_create=0 \
25258 --size=$((size/njobs))M \
25259 --filename=$DIR/$tfile || true
25263 evict=$(do_facet client $LCTL get_param \
25264 osc.$FSNAME-OST*-osc-*/state |
25265 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
25267 [ -z "$evict" ] || [[ $evict -le $before ]] ||
25268 (do_facet client $LCTL get_param \
25269 osc.$FSNAME-OST*-osc-*/state;
25270 error "eviction happened: $evict before:$before")
25274 run_test 398b "DIO and buffer IO race"
25276 test_398c() { # LU-4198
25277 local ost1_imp=$(get_osc_import_name client ost1)
25278 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
25281 which fio || skip_env "no fio installed"
25283 saved_debug=$($LCTL get_param -n debug)
25284 $LCTL set_param debug=0
25286 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
25287 ((size /= 1024)) # by megabytes
25288 ((size /= 2)) # write half of the OST at most
25289 [ $size -gt 40 ] && size=40 #reduce test time anyway
25291 $LFS setstripe -c 1 $DIR/$tfile
25293 # it seems like ldiskfs reserves more space than necessary if the
25294 # writing blocks are not mapped, so it extends the file firstly
25295 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
25296 cancel_lru_locks osc
25298 # clear and verify rpc_stats later
25299 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
25302 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
25303 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
25304 --numjobs=$njobs --fallocate=none --ioengine=libaio \
25305 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
25306 --filename=$DIR/$tfile
25307 [ $? -eq 0 ] || error "fio write error"
25309 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
25310 error "Locks were requested while doing AIO"
25312 # get the percentage of 1-page I/O
25313 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
25314 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
25316 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
25318 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
25319 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
25320 --numjobs=$njobs --fallocate=none --ioengine=libaio \
25321 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
25322 --filename=$DIR/$tfile
25323 [ $? -eq 0 ] || error "fio mixed read write error"
25325 echo "AIO with large block size ${size}M"
25326 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
25327 --numjobs=1 --fallocate=none --ioengine=libaio \
25328 --iodepth=16 --allow_file_create=0 --size=${size}M \
25329 --filename=$DIR/$tfile
25330 [ $? -eq 0 ] || error "fio large block size failed"
25333 $LCTL set_param debug="$saved_debug"
25335 run_test 398c "run fio to test AIO"
25337 test_398d() { # LU-13846
25338 which aiocp || skip_env "no aiocp installed"
25339 local aio_file=$DIR/$tfile.aio
25341 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
25343 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
25344 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
25345 stack_trap "rm -f $DIR/$tfile $aio_file"
25347 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
25349 # make sure we don't crash and fail properly
25350 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
25351 error "aio not aligned with PAGE SIZE should fail"
25353 rm -f $DIR/$tfile $aio_file
25355 run_test 398d "run aiocp to verify block size > stripe size"
25358 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
25359 touch $DIR/$tfile.new
25360 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
25362 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
25364 test_398f() { # LU-14687
25365 which aiocp || skip_env "no aiocp installed"
25366 local aio_file=$DIR/$tfile.aio
25368 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
25370 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
25371 stack_trap "rm -f $DIR/$tfile $aio_file"
25373 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
25374 $LCTL set_param fail_loc=0x1418
25375 # make sure we don't crash and fail properly
25376 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
25377 error "aio with page allocation failure succeeded"
25378 $LCTL set_param fail_loc=0
25379 diff $DIR/$tfile $aio_file
25380 [[ $? != 0 ]] || error "no diff after failed aiocp"
25382 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
25384 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
25385 # stripe and i/o size must be > stripe size
25386 # Old style synchronous DIO waits after submitting each chunk, resulting in a
25387 # single RPC in flight. This test shows async DIO submission is working by
25388 # showing multiple RPCs in flight.
25389 test_398g() { # LU-13798
25390 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
25392 # We need to do some i/o first to acquire enough grant to put our RPCs
25393 # in flight; otherwise a new connection may not have enough grant
25395 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25396 error "parallel dio failed"
25397 stack_trap "rm -f $DIR/$tfile"
25399 # Reduce RPC size to 1M to avoid combination in to larger RPCs
25400 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
25401 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
25402 stack_trap "$LCTL set_param -n $pages_per_rpc"
25404 # Recreate file so it's empty
25406 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
25407 #Pause rpc completion to guarantee we see multiple rpcs in flight
25408 #define OBD_FAIL_OST_BRW_PAUSE_BULK
25409 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
25410 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25413 $LCTL set_param osc.*.rpc_stats=c
25415 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25416 error "parallel dio failed"
25417 stack_trap "rm -f $DIR/$tfile"
25419 $LCTL get_param osc.*-OST0000-*.rpc_stats
25420 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
25421 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
25422 grep "8:" | awk '{print $8}')
25423 # We look at the "8 rpcs in flight" field, and verify A) it is present
25424 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
25425 # as expected for an 8M DIO to a file with 1M stripes.
25426 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
25428 # Verify turning off parallel dio works as expected
25430 $LCTL set_param osc.*.rpc_stats=c
25431 $LCTL set_param llite.*.parallel_dio=0
25432 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
25434 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25435 error "dio with parallel dio disabled failed"
25437 # Ideally, we would see only one RPC in flight here, but there is an
25438 # unavoidable race between i/o completion and RPC in flight counting,
25439 # so while only 1 i/o is in flight at a time, the RPC in flight counter
25440 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
25441 # So instead we just verify it's always < 8.
25442 $LCTL get_param osc.*-OST0000-*.rpc_stats
25443 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
25444 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
25445 grep '^$' -B1 | grep . | awk '{print $1}')
25446 [ $ret != "8:" ] ||
25447 error "we should see fewer than 8 RPCs in flight (saw $ret)"
25449 run_test 398g "verify parallel dio async RPC submission"
25451 test_398h() { # LU-13798
25452 local dio_file=$DIR/$tfile.dio
25454 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
25456 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25457 stack_trap "rm -f $DIR/$tfile $dio_file"
25459 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
25460 error "parallel dio failed"
25461 diff $DIR/$tfile $dio_file
25462 [[ $? == 0 ]] || error "file diff after aiocp"
25464 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
25466 test_398i() { # LU-13798
25467 local dio_file=$DIR/$tfile.dio
25469 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
25471 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25472 stack_trap "rm -f $DIR/$tfile $dio_file"
25474 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
25475 $LCTL set_param fail_loc=0x1418
25476 # make sure we don't crash and fail properly
25477 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
25478 error "parallel dio page allocation failure succeeded"
25479 diff $DIR/$tfile $dio_file
25480 [[ $? != 0 ]] || error "no diff after failed aiocp"
25482 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
25484 test_398j() { # LU-13798
25485 # Stripe size > RPC size but less than i/o size tests split across
25486 # stripes and RPCs for individual i/o op
25487 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
25489 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
25490 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
25491 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
25492 stack_trap "$LCTL set_param -n $pages_per_rpc"
25494 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25495 error "parallel dio write failed"
25496 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
25498 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
25499 error "parallel dio read failed"
25500 diff $DIR/$tfile $DIR/$tfile.2
25501 [[ $? == 0 ]] || error "file diff after parallel dio read"
25503 run_test 398j "test parallel dio where stripe size > rpc_size"
25505 test_398k() { # LU-13798
25506 wait_delete_completed
25509 # 4 stripe file; we will cause out of space on OST0
25510 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
25512 # Fill OST0 (if it's not too large)
25513 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
25515 if [[ $ORIGFREE -gt $MAXFREE ]]; then
25516 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
25518 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
25519 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
25520 error "dd should fill OST0"
25521 stack_trap "rm -f $DIR/$tfile.1"
25523 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25527 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
25528 error "file is not 0 bytes in size"
25530 # dd above should not succeed, but don't error until here so we can
25531 # get debug info above
25533 error "parallel dio write with enospc succeeded"
25534 stack_trap "rm -f $DIR/$tfile"
25536 run_test 398k "test enospc on first stripe"
25538 test_398l() { # LU-13798
25539 wait_delete_completed
25542 # 4 stripe file; we will cause out of space on OST0
25543 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
25544 # happens on the second i/o chunk we issue
25545 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
25547 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
25548 stack_trap "rm -f $DIR/$tfile"
25550 # Fill OST0 (if it's not too large)
25551 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
25553 if [[ $ORIGFREE -gt $MAXFREE ]]; then
25554 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
25556 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
25557 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
25558 error "dd should fill OST0"
25559 stack_trap "rm -f $DIR/$tfile.1"
25561 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
25563 stack_trap "rm -f $DIR/$tfile.2"
25565 # Check that short write completed as expected
25566 ls -la $DIR/$tfile.2
25567 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
25568 error "file is not 1M in size"
25570 # dd above should not succeed, but don't error until here so we can
25571 # get debug info above
25573 error "parallel dio write with enospc succeeded"
25575 # Truncate source file to same length as output file and diff them
25576 $TRUNCATE $DIR/$tfile 1048576
25577 diff $DIR/$tfile $DIR/$tfile.2
25578 [[ $? == 0 ]] || error "data incorrect after short write"
25580 run_test 398l "test enospc on intermediate stripe/RPC"
25582 test_398m() { # LU-13798
25583 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
25585 # Set up failure on OST0, the first stripe:
25586 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
25587 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
25588 # OST0 is on ost1, OST1 is on ost2.
25589 # So this fail_val specifies OST0
25590 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
25591 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25593 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
25594 error "parallel dio write with failure on first stripe succeeded"
25595 stack_trap "rm -f $DIR/$tfile"
25596 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25598 # Place data in file for read
25599 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25600 error "parallel dio write failed"
25602 # Fail read on OST0, first stripe
25603 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
25604 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
25605 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
25606 error "parallel dio read with error on first stripe succeeded"
25607 rm -f $DIR/$tfile.2
25608 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25610 # Switch to testing on OST1, second stripe
25611 # Clear file contents, maintain striping
25613 # Set up failure on OST1, second stripe:
25614 do_facet ost2 $LCTL set_param fail_loc=0x20e fail_val=2
25615 stack_trap "do_facet ost2 $LCTL set_param fail_loc=0"
25617 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
25618 error "parallel dio write with failure on second stripe succeeded"
25619 stack_trap "rm -f $DIR/$tfile"
25620 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
25622 # Place data in file for read
25623 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25624 error "parallel dio write failed"
25626 # Fail read on OST1, second stripe
25627 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
25628 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
25629 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
25630 error "parallel dio read with error on second stripe succeeded"
25631 rm -f $DIR/$tfile.2
25632 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
25634 run_test 398m "test RPC failures with parallel dio"
25636 # Parallel submission of DIO should not cause problems for append, but it's
25637 # important to verify.
25638 test_398n() { # LU-13798
25639 $LFS setstripe -C 2 -S 1M $DIR/$tfile
25641 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
25642 error "dd to create source file failed"
25643 stack_trap "rm -f $DIR/$tfile"
25645 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
25646 error "parallel dio write with failure on second stripe succeeded"
25647 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
25648 diff $DIR/$tfile $DIR/$tfile.1
25649 [[ $? == 0 ]] || error "data incorrect after append"
25652 run_test 398n "test append with parallel DIO"
25655 directio rdwr $DIR/$tfile 0 1 1 || error "bad KMS"
25657 run_test 398o "right kms with DIO"
25660 local read_write=$1
25661 if [ "$read_write" = "write" ]; then
25662 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
25663 elif [ "$read_write" = "read" ]; then
25664 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
25666 error "argument error"
25669 # turn off debug for performance testing
25670 local saved_debug=$($LCTL get_param -n debug)
25671 $LCTL set_param debug=0
25673 $LFS setstripe -c 1 -i 0 $DIR/$tfile
25675 # get ost1 size - $FSNAME-OST0000
25676 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
25677 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
25678 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
25680 if [ "$read_write" = "read" ]; then
25681 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
25684 local start_time=$(date +%s.%N)
25685 $dd_cmd bs=1M count=$blocks oflag=sync ||
25686 error "real dd $read_write error"
25687 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
25689 if [ "$read_write" = "write" ]; then
25693 # define OBD_FAIL_OST_FAKE_RW 0x238
25694 do_facet ost1 $LCTL set_param fail_loc=0x238
25696 local start_time=$(date +%s.%N)
25697 $dd_cmd bs=1M count=$blocks oflag=sync ||
25698 error "fake dd $read_write error"
25699 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
25701 if [ "$read_write" = "write" ]; then
25703 cancel_lru_locks osc
25704 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
25705 error "$tfile size not $blocks MB"
25707 do_facet ost1 $LCTL set_param fail_loc=0
25709 echo "fake $read_write $duration_fake vs. normal $read_write" \
25710 "$duration in seconds"
25711 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
25712 error_not_in_vm "fake write is slower"
25714 $LCTL set_param -n debug="$saved_debug"
25717 test_399a() { # LU-7655 for OST fake write
25718 remote_ost_nodsh && skip "remote OST with nodsh"
25722 run_test 399a "fake write should not be slower than normal write"
25724 test_399b() { # LU-8726 for OST fake read
25725 remote_ost_nodsh && skip "remote OST with nodsh"
25726 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
25727 skip_env "ldiskfs only test"
25732 run_test 399b "fake read should not be slower than normal read"
25734 test_400a() { # LU-1606, was conf-sanity test_74
25735 if ! which $CC > /dev/null 2>&1; then
25736 skip_env "$CC is not installed"
25739 local extra_flags=''
25740 local out=$TMP/$tfile
25741 local prefix=/usr/include/lustre
25744 # Oleg removes .c files in his test rig so test if any c files exist
25745 [[ -n "$(ls -A $LUSTRE_TESTS_API_DIR)" ]] ||
25746 skip_env "Needed .c test files are missing"
25748 if ! [[ -d $prefix ]]; then
25749 # Assume we're running in tree and fixup the include path.
25750 extra_flags+=" -I$LUSTRE/../lnet/include/uapi"
25751 extra_flags+=" -I$LUSTRE/include/uapi -I$LUSTRE/include"
25752 extra_flags+=" -L$LUSTRE/utils/.libs"
25755 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
25756 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
25757 error "client api broken"
25761 run_test 400a "Lustre client api program can compile and link"
25763 test_400b() { # LU-1606, LU-5011
25765 local out=$TMP/$tfile
25766 local prefix=/usr/include/linux/lustre
25768 # We use a hard coded prefix so that this test will not fail
25769 # when run in tree. There are headers in lustre/include/lustre/
25770 # that are not packaged (like lustre_idl.h) and have more
25771 # complicated include dependencies (like config.h and lnet/types.h).
25772 # Since this test about correct packaging we just skip them when
25773 # they don't exist (see below) rather than try to fixup cppflags.
25775 if ! which $CC > /dev/null 2>&1; then
25776 skip_env "$CC is not installed"
25779 for header in $prefix/*.h; do
25780 if ! [[ -f "$header" ]]; then
25784 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
25785 continue # lustre_ioctl.h is internal header
25788 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
25789 error "cannot compile '$header'"
25793 run_test 400b "packaged headers can be compiled"
25795 test_401a() { #LU-7437
25796 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
25797 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
25799 #count the number of parameters by "list_param -R"
25800 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
25801 #count the number of parameters by listing proc files
25802 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
25803 echo "proc_dirs='$proc_dirs'"
25804 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
25805 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
25808 [ $params -eq $procs ] ||
25809 error "found $params parameters vs. $procs proc files"
25811 # test the list_param -D option only returns directories
25812 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
25813 #count the number of parameters by listing proc directories
25814 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
25817 [ $params -eq $procs ] ||
25818 error "found $params parameters vs. $procs proc files"
25820 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
25823 # jobid_var may not allow arbitrary values, so use jobid_name
25825 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25826 local testname=jobid_name tmp='testing%p'
25828 local testname=jobid_var tmp=testing
25831 local save=$($LCTL get_param -n $testname)
25833 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
25834 error "no error returned when setting bad parameters"
25836 local jobid_new=$($LCTL get_param -n foe $testname baz)
25837 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
25839 $LCTL set_param -n fog=bam $testname=$save bat=fog
25840 local jobid_old=$($LCTL get_param -n foe $testname bag)
25841 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
25843 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
25846 # jobid_var may not allow arbitrary values, so use jobid_name
25848 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25849 local testname=jobid_name
25851 local testname=jobid_var
25854 local jobid_var_old=$($LCTL get_param -n $testname)
25855 local jobid_var_new
25857 $LCTL set_param $testname= &&
25858 error "no error returned for 'set_param a='"
25860 jobid_var_new=$($LCTL get_param -n $testname)
25861 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25862 error "$testname was changed by setting without value"
25864 $LCTL set_param $testname &&
25865 error "no error returned for 'set_param a'"
25867 jobid_var_new=$($LCTL get_param -n $testname)
25868 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25869 error "$testname was changed by setting without value"
25871 run_test 401c "Verify 'lctl set_param' without value fails in either format."
25874 # jobid_var may not allow arbitrary values, so use jobid_name
25876 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25877 local testname=jobid_name new_value='foo=bar%p'
25879 local testname=jobid_var new_valuie=foo=bar
25882 local jobid_var_old=$($LCTL get_param -n $testname)
25883 local jobid_var_new
25885 $LCTL set_param $testname=$new_value ||
25886 error "'set_param a=b' did not accept a value containing '='"
25888 jobid_var_new=$($LCTL get_param -n $testname)
25889 [[ "$jobid_var_new" == "$new_value" ]] ||
25890 error "'set_param a=b' failed on a value containing '='"
25892 # Reset the $testname to test the other format
25893 $LCTL set_param $testname=$jobid_var_old
25894 jobid_var_new=$($LCTL get_param -n $testname)
25895 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25896 error "failed to reset $testname"
25898 $LCTL set_param $testname $new_value ||
25899 error "'set_param a b' did not accept a value containing '='"
25901 jobid_var_new=$($LCTL get_param -n $testname)
25902 [[ "$jobid_var_new" == "$new_value" ]] ||
25903 error "'set_param a b' failed on a value containing '='"
25905 $LCTL set_param $testname $jobid_var_old
25906 jobid_var_new=$($LCTL get_param -n $testname)
25907 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25908 error "failed to reset $testname"
25910 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
25912 test_401e() { # LU-14779
25913 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
25914 error "lctl list_param MGC* failed"
25915 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
25916 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
25917 error "lctl get_param lru_size failed"
25919 run_test 401e "verify 'lctl get_param' works with NID in parameter"
25922 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
25923 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
25924 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
25925 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
25926 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
25927 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
25928 remote_mds_nodsh && skip "remote MDS with nodsh"
25930 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
25931 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
25932 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
25933 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
25934 echo "Touch failed - OK"
25936 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
25939 local file1=$DIR/$tfile.1
25940 local file2=$DIR/$tfile.2
25941 local tfile=$TMP/$tfile
25943 rm -f $file1 $file2 $tfile
25948 # 30 sec OBD_TIMEOUT in ll_getattr()
25949 # right before populating st_nlink
25950 $LCTL set_param fail_loc=0x80001409
25951 stat -c %h $file1 > $tfile &
25953 # create an alias, drop all locks and reclaim the dentry
25955 cancel_lru_locks mdc
25956 cancel_lru_locks osc
25957 sysctl -w vm.drop_caches=2
25961 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
25963 rm -f $tfile $file1 $file2
25965 run_test 403 "i_nlink should not drop to zero due to aliasing"
25967 test_404() { # LU-6601
25968 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
25969 skip "Need server version newer than 2.8.52"
25970 remote_mds_nodsh && skip "remote MDS with nodsh"
25972 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
25973 awk '/osp .*-osc-MDT/ { print $4}')
25976 for osp in $mosps; do
25977 echo "Deactivate: " $osp
25978 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
25979 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25980 awk -vp=$osp '$4 == p { print $2 }')
25981 [ $stat = IN ] || {
25982 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25983 error "deactivate error"
25985 echo "Activate: " $osp
25986 do_facet $SINGLEMDS $LCTL --device %$osp activate
25987 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25988 awk -vp=$osp '$4 == p { print $2 }')
25989 [ $stat = UP ] || {
25990 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25991 error "activate error"
25995 run_test 404 "validate manual {de}activated works properly for OSPs"
25998 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
25999 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
26000 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
26001 skip "Layout swap lock is not supported"
26003 check_swap_layouts_support
26004 check_swap_layout_no_dom $DIR
26006 test_mkdir $DIR/$tdir
26007 swap_lock_test -d $DIR/$tdir ||
26008 error "One layout swap locked test failed"
26010 run_test 405 "Various layout swap lock tests"
26013 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
26014 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
26015 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
26016 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26017 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
26018 skip "Need MDS version at least 2.8.50"
26020 local def_stripe_size=$($LFS getstripe -S $MOUNT)
26021 local test_pool=$TESTNAME
26023 pool_add $test_pool || error "pool_add failed"
26024 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
26025 error "pool_add_targets failed"
26027 save_layout_restore_at_exit $MOUNT
26029 # parent set default stripe count only, child will stripe from both
26030 # parent and fs default
26031 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
26032 error "setstripe $MOUNT failed"
26033 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
26034 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
26035 for i in $(seq 10); do
26036 local f=$DIR/$tdir/$tfile.$i
26037 touch $f || error "touch failed"
26038 local count=$($LFS getstripe -c $f)
26039 [ $count -eq $OSTCOUNT ] ||
26040 error "$f stripe count $count != $OSTCOUNT"
26041 local offset=$($LFS getstripe -i $f)
26042 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
26043 local size=$($LFS getstripe -S $f)
26044 [ $size -eq $((def_stripe_size * 2)) ] ||
26045 error "$f stripe size $size != $((def_stripe_size * 2))"
26046 local pool=$($LFS getstripe -p $f)
26047 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
26050 # change fs default striping, delete parent default striping, now child
26051 # will stripe from new fs default striping only
26052 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
26053 error "change $MOUNT default stripe failed"
26054 $LFS setstripe -c 0 $DIR/$tdir ||
26055 error "delete $tdir default stripe failed"
26056 for i in $(seq 11 20); do
26057 local f=$DIR/$tdir/$tfile.$i
26058 touch $f || error "touch $f failed"
26059 local count=$($LFS getstripe -c $f)
26060 [ $count -eq 1 ] || error "$f stripe count $count != 1"
26061 local offset=$($LFS getstripe -i $f)
26062 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
26063 local size=$($LFS getstripe -S $f)
26064 [ $size -eq $def_stripe_size ] ||
26065 error "$f stripe size $size != $def_stripe_size"
26066 local pool=$($LFS getstripe -p $f)
26067 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
26070 unlinkmany $DIR/$tdir/$tfile. 1 20
26072 local f=$DIR/$tdir/$tfile
26073 pool_remove_all_targets $test_pool $f
26074 pool_remove $test_pool $f
26076 run_test 406 "DNE support fs default striping"
26079 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
26080 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
26081 skip "Need MDS version at least 2.8.55"
26082 remote_mds_nodsh && skip "remote MDS with nodsh"
26084 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
26085 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
26086 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
26087 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
26088 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
26090 #define OBD_FAIL_DT_TXN_STOP 0x2019
26091 for idx in $(seq $MDSCOUNT); do
26092 do_facet mds$idx "lctl set_param fail_loc=0x2019"
26094 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
26095 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
26096 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
26099 run_test 407 "transaction fail should cause operation fail"
26102 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
26104 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
26105 lctl set_param fail_loc=0x8000040a
26106 # let ll_prepare_partial_page() fail
26107 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
26111 # create at least 100 unused inodes so that
26112 # shrink_icache_memory(0) should not return 0
26113 touch $DIR/$tfile-{0..100}
26114 rm -f $DIR/$tfile-{0..100}
26117 echo 2 > /proc/sys/vm/drop_caches
26119 run_test 408 "drop_caches should not hang due to page leaks"
26123 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26125 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
26126 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
26127 touch $DIR/$tdir/guard || error "(2) Fail to create"
26129 local PREFIX=$(str_repeat 'A' 128)
26130 echo "Create 1K hard links start at $(date)"
26131 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
26132 error "(3) Fail to hard link"
26134 echo "Links count should be right although linkEA overflow"
26135 stat $DIR/$tdir/guard || error "(4) Fail to stat"
26136 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
26137 [ $linkcount -eq 1001 ] ||
26138 error "(5) Unexpected hard links count: $linkcount"
26140 echo "List all links start at $(date)"
26141 ls -l $DIR/$tdir/foo > /dev/null ||
26142 error "(6) Fail to list $DIR/$tdir/foo"
26144 echo "Unlink hard links start at $(date)"
26145 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
26146 error "(7) Fail to unlink"
26147 echo "Unlink hard links finished at $(date)"
26149 run_test 409 "Large amount of cross-MDTs hard links on the same file"
26153 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
26154 skip "Need client version at least 2.9.59"
26155 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
26156 skip "Need MODULES build"
26158 # Create a file, and stat it from the kernel
26159 local testfile=$DIR/$tfile
26162 local run_id=$RANDOM
26163 local my_ino=$(stat --format "%i" $testfile)
26165 # Try to insert the module. This will always fail as the
26166 # module is designed to not be inserted.
26167 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
26170 # Anything but success is a test failure
26172 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
26173 error "no inode match"
26175 run_test 410 "Test inode number returned from kernel thread"
26177 cleanup_test411_cgroup() {
26183 local cg_basedir=/sys/fs/cgroup/memory
26185 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
26186 skip "no setup for cgroup"
26188 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
26189 error "test file creation failed"
26190 cancel_lru_locks osc
26192 # Create a very small memory cgroup to force a slab allocation error
26193 local cgdir=$cg_basedir/osc_slab_alloc
26194 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
26195 trap "cleanup_test411_cgroup $cgdir" EXIT
26196 echo 2M > $cgdir/memory.kmem.limit_in_bytes
26197 echo 1M > $cgdir/memory.limit_in_bytes
26199 # Should not LBUG, just be killed by oom-killer
26200 # dd will return 0 even allocation failure in some environment.
26201 # So don't check return value
26202 bash -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
26203 cleanup_test411_cgroup $cgdir
26207 run_test 411 "Slab allocation error with cgroup does not LBUG"
26210 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
26211 (( $MDS1_VERSION >= $(version_code 2.10.55) )) ||
26212 skip "Need server version at least 2.10.55"
26214 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
26215 error "mkdir failed"
26216 $LFS getdirstripe $DIR/$tdir
26217 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
26218 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
26219 error "expect $((MDSCOUT - 1)) get $stripe_index"
26220 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
26221 [ $stripe_count -eq 2 ] ||
26222 error "expect 2 get $stripe_count"
26224 (( $MDS1_VERSION >= $(version_code 2.14.55) )) || return 0
26229 # subdirs should be on the same MDT as parent
26230 for i in $(seq 0 $((MDSCOUNT - 1))); do
26231 $LFS mkdir -i $i $DIR/$tdir/mdt$i || error "mkdir mdt$i failed"
26232 mkdir $DIR/$tdir/mdt$i/sub || error "mkdir sub failed"
26233 index=$($LFS getstripe -m $DIR/$tdir/mdt$i/sub)
26234 (( index == i )) || error "mdt$i/sub on MDT$index"
26237 # stripe offset -1, ditto
26238 for i in {1..10}; do
26239 $LFS mkdir -i -1 $DIR/$tdir/qos$i || error "mkdir qos$i failed"
26240 index=$($LFS getstripe -m $DIR/$tdir/qos$i)
26241 mkdir $DIR/$tdir/qos$i/sub || error "mkdir sub failed"
26242 index2=$($LFS getstripe -m $DIR/$tdir/qos$i/sub)
26243 (( index == index2 )) ||
26244 error "qos$i on MDT$index, sub on MDT$index2"
26247 local testdir=$DIR/$tdir/inherit
26249 $LFS mkdir -i 1 --max-inherit=3 $testdir || error "mkdir inherit failed"
26252 testdir=$testdir/s$i
26253 mkdir $testdir || error "mkdir $testdir failed"
26254 index=$($LFS getstripe -m $testdir)
26255 (( index == 1 )) ||
26256 error "$testdir on MDT$index"
26259 # not inherit any more
26260 testdir=$testdir/s3
26261 mkdir $testdir || error "mkdir $testdir failed"
26262 getfattr -d -m dmv $testdir | grep dmv &&
26263 error "default LMV set on $testdir" || true
26265 run_test 412 "mkdir on specific MDTs"
26267 TEST413_COUNT=${TEST413_COUNT:-200}
26268 generate_uneven_mdts() {
26270 local lmv_qos_maxage
26271 local lod_qos_maxage
26281 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
26282 $LCTL set_param lmv.*.qos_maxage=1
26283 stack_trap "$LCTL set_param \
26284 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
26285 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
26286 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
26287 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
26288 lod.*.mdt_qos_maxage=1
26289 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
26290 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
26293 echo "Check for uneven MDTs: "
26295 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26296 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26297 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26299 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26300 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26303 for ((i = 1; i < ${#ffree[@]}; i++)); do
26304 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26305 if [ $tmp -gt $max ]; then
26309 if [ $tmp -lt $min ]; then
26315 (( ${ffree[min_index]} > 0 )) ||
26316 skip "no free files in MDT$min_index"
26317 (( ${ffree[min_index]} < 10000000 )) ||
26318 skip "too many free files in MDT$min_index"
26320 # Check if we need to generate uneven MDTs
26321 local diff=$(((max - min) * 100 / min))
26322 local testdir=$DIR/$tdir-fillmdt
26326 while (( diff < threshold )); do
26328 # generate uneven MDTs, create till $threshold% diff
26329 echo -n "weight diff=$diff% must be > $threshold% ..."
26330 echo "Fill MDT$min_index with $TEST413_COUNT files: loop $i"
26331 testdir=$DIR/$tdir-fillmdt/$i
26332 [ -d $testdir ] && continue
26333 $LFS mkdir -i $min_index $testdir ||
26334 error "mkdir $testdir failed"
26335 $LFS setstripe -E 1M -L mdt $testdir ||
26336 error "setstripe $testdir failed"
26338 for ((F=0; F < TEST413_COUNT; F++)); do
26339 dd if=/dev/zero of=$testdir/f.$F bs=128K count=1 > \
26340 /dev/null 2>&1 || error "dd $F failed"
26342 sync; sleep 1; sync
26344 # wait for QOS to update
26345 (( SECONDS < start + 1 )) && sleep $((start + 1 - SECONDS))
26347 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
26348 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
26349 max=$(((${ffree[max_index]} >> 8) *
26350 (${bavail[max_index]} * bsize >> 16)))
26351 min=$(((${ffree[min_index]} >> 8) *
26352 (${bavail[min_index]} * bsize >> 16)))
26353 diff=$(((max - min) * 100 / min))
26357 echo "MDT filesfree available: ${ffree[*]}"
26358 echo "MDT blocks available: ${bavail[*]}"
26359 echo "weight diff=$diff%"
26364 local stripe_count=$2
26365 local mdts=$(comma_list $(mdts_nodes))
26368 local lmv_qos_prio_free
26369 local lmv_qos_threshold_rr
26370 local lmv_qos_maxage
26371 local lod_qos_prio_free
26372 local lod_qos_threshold_rr
26373 local lod_qos_maxage
26377 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
26378 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
26379 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
26381 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
26382 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
26383 stack_trap "$LCTL set_param \
26384 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
26385 stack_trap "$LCTL set_param \
26386 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
26387 stack_trap "$LCTL set_param \
26388 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
26390 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
26391 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
26392 lod_qos_prio_free=${lod_qos_prio_free%%%}
26393 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
26394 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
26395 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
26396 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
26397 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
26398 stack_trap "do_nodes $mdts $LCTL set_param \
26399 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
26400 stack_trap "do_nodes $mdts $LCTL set_param \
26401 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
26402 stack_trap "do_nodes $mdts $LCTL set_param \
26403 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
26405 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
26406 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
26408 testdir=$DIR/$tdir-s$stripe_count/rr
26410 local stripe_index=$($LFS getstripe -m $testdir)
26411 local test_mkdir_rr=true
26413 getfattr -d -m dmv -e hex $testdir | grep dmv
26414 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
26415 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
26416 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
26417 test_mkdir_rr=false
26422 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
26423 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
26425 stack_trap "unlinkmany -d $testdir/subdir $((100 * MDSCOUNT))"
26426 for (( i = 0; i < 100 * MDSCOUNT; i++ )); do
26427 eval $mkdir_cmd $testdir/subdir$i ||
26428 error "$mkdir_cmd subdir$i failed"
26431 for (( i = 0; i < $MDSCOUNT; i++ )); do
26432 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
26433 echo "$count directories created on MDT$i"
26434 if $test_mkdir_rr; then
26435 (( $count == 100 )) ||
26436 error "subdirs are not evenly distributed"
26437 elif (( $i == $stripe_index )); then
26438 (( $count == 100 * MDSCOUNT )) ||
26439 error "$count subdirs created on MDT$i"
26441 (( $count == 0 )) ||
26442 error "$count subdirs created on MDT$i"
26445 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
26446 count=$($LFS getdirstripe $testdir/* |
26447 grep -c -P "^\s+$i\t")
26448 echo "$count stripes created on MDT$i"
26449 # deviation should < 5% of average
26450 (( $count >= 95 * stripe_count &&
26451 $count <= 105 * stripe_count)) ||
26452 error "stripes are not evenly distributed"
26457 echo "Check for uneven MDTs: "
26467 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26468 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26469 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26471 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26472 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26475 for ((i = 1; i < ${#ffree[@]}; i++)); do
26476 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26477 if [ $tmp -gt $max ]; then
26481 if [ $tmp -lt $min ]; then
26487 (( ${ffree[min_index]} > 0 )) ||
26488 skip "no free files in MDT$min_index"
26489 (( ${ffree[min_index]} < 10000000 )) ||
26490 skip "too many free files in MDT$min_index"
26492 echo "MDT filesfree available: ${ffree[*]}"
26493 echo "MDT blocks available: ${bavail[*]}"
26494 echo "weight diff=$(((max - min) * 100 / min))%"
26496 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
26498 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
26499 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
26500 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
26501 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
26502 # decrease statfs age, so that it can be updated in time
26503 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
26504 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
26508 testdir=$DIR/$tdir-s$stripe_count/qos
26511 stack_trap "unlinkmany -d $testdir/subdir $((num * MDSCOUNT))"
26512 for (( i = 0; i < num * MDSCOUNT; i++ )); do
26513 eval $mkdir_cmd $testdir/subdir$i ||
26514 error "$mkdir_cmd subdir$i failed"
26518 for (( i = 0; i < $MDSCOUNT; i++ )); do
26519 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
26520 (( count > max )) && max=$count
26521 echo "$count directories created on MDT$i"
26524 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
26526 # D-value should > 10% of averge
26527 (( max - min > num / 10 )) ||
26528 error "subdirs shouldn't be evenly distributed: $max - $min < $((num / 10))"
26530 # ditto for stripes
26531 if (( stripe_count > 1 )); then
26533 for (( i = 0; i < $MDSCOUNT; i++ )); do
26534 count=$($LFS getdirstripe $testdir/* |
26535 grep -c -P "^\s+$i\t")
26536 (( count > max )) && max=$count
26537 echo "$count stripes created on MDT$i"
26540 min=$($LFS getdirstripe $testdir/* |
26541 grep -c -P "^\s+$min_index\t")
26542 (( max - min > num * stripe_count / 10 )) ||
26543 error "stripes shouldn't be evenly distributed: $max - $min < $((num / 10)) * $stripe_count"
26555 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26556 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26557 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26559 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26561 for ((i = 1; i < ${#ffree[@]}; i++)); do
26562 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26563 (( tmp < min )) && min=$tmp && min_index=$i
26570 [ $MDSCOUNT -lt 2 ] &&
26571 skip "We need at least 2 MDTs for this test"
26573 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
26574 skip "Need server version at least 2.12.52"
26578 generate_uneven_mdts 100
26579 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
26580 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
26581 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
26582 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
26583 error "mkdir failed"
26584 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
26587 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
26590 [ $MDSCOUNT -lt 2 ] &&
26591 skip "We need at least 2 MDTs for this test"
26593 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
26594 skip "Need server version at least 2.12.52"
26599 generate_uneven_mdts 100
26600 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
26601 testdir=$DIR/$tdir-s$stripe_count
26602 mkdir $testdir || error "mkdir $testdir failed"
26603 mkdir $testdir/rr || error "mkdir rr failed"
26604 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
26605 error "mkdir qos failed"
26606 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
26607 $testdir/rr || error "setdirstripe rr failed"
26608 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
26609 error "setdirstripe failed"
26610 test_qos_mkdir "mkdir" $stripe_count
26613 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
26616 (( $MDSCOUNT >= 2 )) ||
26617 skip "We need at least 2 MDTs for this test"
26619 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
26620 skip "Need server version at least 2.14.51"
26626 testdir=$DIR/${tdir}-s1
26627 mkdir $testdir || error "mkdir $testdir failed"
26628 mkdir $testdir/rr || error "mkdir rr failed"
26629 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
26630 # default max_inherit is -1, default max_inherit_rr is 0
26631 $LFS setdirstripe -D -c 1 $testdir/rr ||
26632 error "setdirstripe rr failed"
26633 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
26634 error "setdirstripe qos failed"
26635 test_qos_mkdir "mkdir" 1
26637 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
26638 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
26639 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
26640 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
26641 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
26643 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
26644 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
26645 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
26646 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
26647 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
26648 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
26649 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
26650 error "level2 shouldn't have default LMV" || true
26652 run_test 413c "mkdir with default LMV max inherit rr"
26655 (( MDSCOUNT >= 2 )) ||
26656 skip "We need at least 2 MDTs for this test"
26658 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
26659 skip "Need server version at least 2.14.51"
26661 local lmv_qos_threshold_rr
26663 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
26665 stack_trap "$LCTL set_param \
26666 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
26668 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
26669 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
26670 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
26671 error "$tdir shouldn't have default LMV"
26672 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
26673 error "mkdir sub failed"
26675 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
26677 (( count == 100 )) || error "$count subdirs on MDT0"
26679 run_test 413d "inherit ROOT default LMV"
26682 (( MDSCOUNT >= 2 )) ||
26683 skip "We need at least 2 MDTs for this test"
26684 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26685 skip "Need server version at least 2.14.55"
26687 local testdir=$DIR/$tdir
26688 local tmpfile=$TMP/temp.setdirstripe.stderr.$$
26690 local sub_max_inherit
26692 mkdir -p $testdir || error "failed to create $testdir"
26694 # set default max-inherit to -1 if stripe count is 0 or 1
26695 $LFS setdirstripe -D -c 1 $testdir ||
26696 error "failed to set default LMV"
26697 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26698 (( max_inherit == -1 )) ||
26699 error "wrong max_inherit value $max_inherit"
26701 # set default max_inherit to a fixed value if stripe count is not 0 or 1
26702 $LFS setdirstripe -D -c -1 $testdir ||
26703 error "failed to set default LMV"
26704 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26705 (( max_inherit > 0 )) ||
26706 error "wrong max_inherit value $max_inherit"
26708 # and the subdir will decrease the max_inherit by 1
26709 mkdir -p $testdir/subdir-1 || error "failed to make subdir"
26710 sub_max_inherit=$($LFS getdirstripe -D --max-inherit $testdir/subdir-1)
26711 (( sub_max_inherit == max_inherit - 1)) ||
26712 error "wrong max-inherit of subdir $sub_max_inherit"
26714 # check specified --max-inherit and warning message
26715 stack_trap "rm -f $tmpfile"
26716 $LFS setdirstripe -D -c 2 --max-inherit=-1 $testdir 2> $tmpfile ||
26717 error "failed to set default LMV"
26718 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26719 (( max_inherit == -1 )) ||
26720 error "wrong max_inherit value $max_inherit"
26722 # check the warning messages
26723 if ! [[ $(cat $tmpfile) =~ "max-inherit=" ]]; then
26724 error "failed to detect warning string"
26727 run_test 413e "check default max-inherit value"
26729 test_fs_dmv_inherit()
26731 local testdir=$DIR/$tdir
26738 mkdir $testdir || error "mkdir $testdir failed"
26739 count=$($LFS getdirstripe -D -c $testdir)
26740 (( count == 1 )) ||
26741 error "$testdir default LMV count mismatch $count != 1"
26742 inherit=$($LFS getdirstripe -D -X $testdir)
26743 (( inherit == 3 - i )) ||
26744 error "$testdir default LMV max-inherit $inherit != $((3 - i))"
26745 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir)
26746 (( inherit_rr == 3 - i )) ||
26747 error "$testdir default LMV max-inherit-rr $inherit_rr != $((3 - i))"
26748 testdir=$testdir/sub
26751 mkdir $testdir || error "mkdir $testdir failed"
26752 count=$($LFS getdirstripe -D -c $testdir)
26753 (( count == 0 )) ||
26754 error "$testdir default LMV count not zero: $count"
26758 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26760 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26761 skip "Need server version at least 2.14.55"
26763 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26764 error "dump $DIR default LMV failed"
26765 stack_trap "setfattr --restore=$TMP/dmv.ea"
26767 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26768 error "set $DIR default LMV failed"
26770 test_fs_dmv_inherit
26772 run_test 413f "lfs getdirstripe -D list ROOT default LMV if it's not set on dir"
26775 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26777 mkdir -p $DIR/$tdir/l2/l3/l4 || error "mkdir $tdir/l1/l2/l3 failed"
26778 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26779 error "dump $DIR default LMV failed"
26780 stack_trap "setfattr --restore=$TMP/dmv.ea"
26782 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26783 error "set $DIR default LMV failed"
26785 FILESET="$FILESET/$tdir/l2/l3/l4" mount_client $MOUNT2 ||
26786 error "mount $MOUNT2 failed"
26787 stack_trap "umount_client $MOUNT2"
26789 local saved_DIR=$DIR
26793 stack_trap "export DIR=$saved_DIR"
26795 # first check filesystem-wide default LMV inheritance
26796 test_fs_dmv_inherit || error "incorrect fs default LMV inheritance"
26798 # then check subdirs are spread to all MDTs
26799 createmany -d $DIR/s $((MDSCOUNT * 100)) || error "createmany failed"
26801 local count=$($LFS getstripe -m $DIR/s* | sort -u | wc -l)
26803 (( $count == $MDSCOUNT )) || error "dirs are spread to $count MDTs"
26805 run_test 413g "enforce ROOT default LMV on subdir mount"
26808 (( MDSCOUNT >= 2 )) ||
26809 skip "We need at least 2 MDTs for this test"
26811 (( MDS1_VERSION >= $(version_code 2.15.50.6) )) ||
26812 skip "Need server version at least 2.15.50.6"
26814 local lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
26816 stack_trap "$LCTL set_param \
26817 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
26818 $LCTL set_param lmv.*.qos_maxage=1
26822 local dir=$DIR/$tdir/l1/l2/l3/l4/l5
26823 local count=$((MDSCOUNT * 20))
26825 generate_uneven_mdts 50
26827 mkdir -p $dir || error "mkdir $dir failed"
26828 stack_trap "rm -rf $dir"
26829 $LFS setdirstripe -D -c 1 -i -1 --max-inherit=$depth \
26830 --max-inherit-rr=$rr_depth $dir
26832 for ((d=0; d < depth + 2; d++)); do
26834 for ((sub=0; sub < count; sub++)); do
26837 $LFS getdirstripe -i $dir/d* | sort | uniq -c | sort -nr
26838 local num=($($LFS getdirstripe -i $dir/d* | sort | uniq -c))
26839 # subdirs within $rr_depth should be created round-robin
26840 if (( d < rr_depth )); then
26841 (( ${num[0]} != count )) ||
26842 error "all objects created on MDT ${num[1]}"
26848 run_test 413h "don't stick to parent for round-robin dirs"
26855 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
26856 unlinkmany $subdir/f. $TEST413_COUNT &
26860 for pid in $pids; do
26864 run_test 413z "413 test cleanup"
26867 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
26868 $LCTL set_param fail_loc=0x80000521
26869 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
26872 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
26875 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
26876 (( $MDS1_VERSION >= $(version_code 2.11.52) )) ||
26877 skip "Need server version at least 2.11.52"
26883 # this test may be slow on ZFS
26884 [[ "$mds1_FSTYPE" == "zfs" ]] && total=50
26886 # though this test is designed for striped directory, let's test normal
26887 # directory too since lock is always saved as CoS lock.
26888 test_mkdir $DIR/$tdir || error "mkdir $tdir"
26889 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
26890 stack_trap "unlinkmany $DIR/$tdir/$tfile. $total || true"
26891 # if looping with ONLY_REPEAT, wait for previous deletions to finish
26892 wait_delete_completed_mds
26894 # run a loop without concurrent touch to measure rename duration.
26895 # only for test debug/robustness, NOT part of COS functional test.
26896 local start_time=$SECONDS
26897 for ((i = 0; i < total; i++)); do
26898 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
26901 local baseline=$((SECONDS - start_time))
26902 echo "rename $total files without 'touch' took $baseline sec"
26909 local setattr_pid=$!
26911 # rename files back to original name so unlinkmany works
26912 start_time=$SECONDS
26913 for ((i = 0; i < total; i++)); do
26914 mrename $DIR/$tdir/$tfile-new.$i $DIR/$tdir/$tfile.$i\
26917 local duration=$((SECONDS - start_time))
26919 kill -9 $setattr_pid
26921 echo "rename $total files with 'touch' took $duration sec"
26922 (( max > 2 * baseline )) || max=$((2 * baseline + 5))
26923 (( duration <= max )) || error "rename took $duration > $max sec"
26925 run_test 415 "lock revoke is not missing"
26928 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
26929 skip "Need server version at least 2.11.55"
26931 # define OBD_FAIL_OSD_TXN_START 0x19a
26932 do_facet mds1 lctl set_param fail_loc=0x19a
26934 lfs mkdir -c $MDSCOUNT $DIR/$tdir
26938 run_test 416 "transaction start failure won't cause system hung"
26942 do_nodes $(comma_list $(mdts_nodes)) \
26943 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
26944 do_nodes $(comma_list $(mdts_nodes)) \
26945 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
26946 do_nodes $(comma_list $(mdts_nodes)) \
26947 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
26951 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26952 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
26953 skip "Need MDS version at least 2.11.56"
26955 trap cleanup_417 RETURN EXIT
26957 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
26958 do_nodes $(comma_list $(mdts_nodes)) \
26959 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
26960 $LFS migrate -m 0 $DIR/$tdir.1 &&
26961 error "migrate dir $tdir.1 should fail"
26963 do_nodes $(comma_list $(mdts_nodes)) \
26964 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
26965 $LFS mkdir -i 1 $DIR/$tdir.2 &&
26966 error "create remote dir $tdir.2 should fail"
26968 do_nodes $(comma_list $(mdts_nodes)) \
26969 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
26970 $LFS mkdir -c 2 $DIR/$tdir.3 &&
26971 error "create striped dir $tdir.3 should fail"
26974 run_test 417 "disable remote dir, striped dir and dir migration"
26976 # Checks that the outputs of df [-i] and lfs df [-i] match
26978 # usage: check_lfs_df <blocks | inodes> <mountpoint>
26988 [ "$1" == "blocks" ] && inodes= || inodes="-i"
26990 for count in {1..100}; do
26991 do_nodes "$CLIENTS" \
26992 $LCTL set_param ldlm.namespaces.*.lru_size=clear
26995 # read the lines of interest
26996 df_out=($(df -P $inodes $dir | tail -n +2)) ||
26997 error "df $inodes $dir | tail -n +2 failed"
26998 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
26999 error "lfs df $inodes $dir | grep summary: failed"
27001 # skip first substrings of each output as they are different
27002 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
27003 # compare the two outputs
27005 # skip "available" on MDT until LU-13997 is fixed.
27006 #for i in {1..5}; do
27007 for i in 1 2 4 5; do
27008 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
27016 lfs df $inodes $dir
27017 error "df and lfs df $1 output mismatch: " \
27018 "df ${inodes}: ${df_out[*]}, " \
27019 "lfs df ${inodes}: ${lfs_df_out[*]}"
27024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27026 local dir=$DIR/$tdir
27027 local numfiles=$((RANDOM % 4096 + 2))
27028 local numblocks=$((RANDOM % 256 + 1))
27030 wait_delete_completed
27033 # check block output
27034 check_lfs_df blocks $dir
27035 # check inode output
27036 check_lfs_df inodes $dir
27038 # create a single file and retest
27039 echo "Creating a single file and testing"
27040 createmany -o $dir/$tfile- 1 &>/dev/null ||
27041 error "creating 1 file in $dir failed"
27042 check_lfs_df blocks $dir
27043 check_lfs_df inodes $dir
27045 # create a random number of files
27046 echo "Creating $((numfiles - 1)) files and testing"
27047 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
27048 error "creating $((numfiles - 1)) files in $dir failed"
27050 # write a random number of blocks to the first test file
27051 echo "Writing $numblocks 4K blocks and testing"
27052 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
27053 count=$numblocks &>/dev/null ||
27054 error "dd to $dir/${tfile}-0 failed"
27057 check_lfs_df blocks $dir
27058 check_lfs_df inodes $dir
27060 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
27061 error "unlinking $numfiles files in $dir failed"
27063 run_test 418 "df and lfs df outputs match"
27067 local dir=$DIR/$tdir
27072 cancel_lru_locks mdc
27074 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
27075 $LCTL set_param fail_loc=0x1410
27077 $LCTL set_param fail_loc=0
27080 run_test 419 "Verify open file by name doesn't crash kernel"
27084 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
27085 skip "Need MDS version at least 2.12.53"
27087 local SAVE_UMASK=$(umask)
27088 local dir=$DIR/$tdir
27089 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
27093 mkdir -m03777 $dir/testdir
27094 ls -dn $dir/testdir
27095 # Need to remove trailing '.' when SELinux is enabled
27096 local dirperms=$(ls -dn $dir/testdir |
27097 awk '{ sub(/\.$/, "", $1); print $1}')
27098 [ $dirperms == "drwxrwsrwt" ] ||
27099 error "incorrect perms on $dir/testdir"
27101 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
27102 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
27103 ls -n $dir/testdir/testfile
27104 local fileperms=$(ls -n $dir/testdir/testfile |
27105 awk '{ sub(/\.$/, "", $1); print $1}')
27106 [ $fileperms == "-rwxr-xr-x" ] ||
27107 error "incorrect perms on $dir/testdir/testfile"
27111 run_test 420 "clear SGID bit on non-directories for non-members"
27118 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27119 skip "Need MDS version at least 2.12.54"
27121 test_mkdir $DIR/$tdir
27122 createmany -o $DIR/$tdir/f 3
27123 cnt=$(ls -1 $DIR/$tdir | wc -l)
27124 [ $cnt != 3 ] && error "unexpected #files: $cnt"
27126 fid1=$(lfs path2fid $DIR/$tdir/f1)
27127 fid2=$(lfs path2fid $DIR/$tdir/f2)
27128 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
27130 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
27131 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
27133 cnt=$(ls -1 $DIR/$tdir | wc -l)
27134 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
27136 rm -f $DIR/$tdir/f3 || error "can't remove f3"
27137 createmany -o $DIR/$tdir/f 3
27138 cnt=$(ls -1 $DIR/$tdir | wc -l)
27139 [ $cnt != 3 ] && error "unexpected #files: $cnt"
27141 fid1=$(lfs path2fid $DIR/$tdir/f1)
27142 fid2=$(lfs path2fid $DIR/$tdir/f2)
27143 echo "remove using fsname $FSNAME"
27144 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
27146 cnt=$(ls -1 $DIR/$tdir | wc -l)
27147 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
27149 run_test 421a "simple rm by fid"
27156 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27157 skip "Need MDS version at least 2.12.54"
27159 test_mkdir $DIR/$tdir
27160 createmany -o $DIR/$tdir/f 3
27161 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
27164 FID1=$(lfs path2fid $DIR/$tdir/f1)
27165 FID2=$(lfs path2fid $DIR/$tdir/f2)
27166 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
27168 kill -USR1 $MULTIPID
27171 cnt=$(ls $DIR/$tdir | wc -l)
27172 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
27174 run_test 421b "rm by fid on open file"
27180 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27181 skip "Need MDS version at least 2.12.54"
27183 test_mkdir $DIR/$tdir
27184 createmany -o $DIR/$tdir/f 3
27185 touch $DIR/$tdir/$tfile
27186 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
27187 cnt=$(ls -1 $DIR/$tdir | wc -l)
27188 [ $cnt != 184 ] && error "unexpected #files: $cnt"
27190 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
27191 $LFS rmfid $DIR $FID1 || error "rmfid failed"
27193 cnt=$(ls $DIR/$tdir | wc -l)
27194 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
27196 run_test 421c "rm by fid against hardlinked files"
27202 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27203 skip "Need MDS version at least 2.12.54"
27205 test_mkdir $DIR/$tdir
27206 createmany -o $DIR/$tdir/f 4097
27207 cnt=$(ls -1 $DIR/$tdir | wc -l)
27208 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
27210 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
27211 $LFS rmfid $DIR $FIDS || error "rmfid failed"
27213 cnt=$(ls $DIR/$tdir | wc -l)
27215 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
27217 run_test 421d "rmfid en masse"
27223 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
27224 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27225 skip "Need MDS version at least 2.12.54"
27227 mkdir -p $DIR/$tdir
27228 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
27229 createmany -o $DIR/$tdir/striped_dir/f 512
27230 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
27231 [ $cnt != 512 ] && error "unexpected #files: $cnt"
27233 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
27234 sed "s/[/][^:]*://g")
27235 $LFS rmfid $DIR $FIDS || error "rmfid failed"
27237 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
27239 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
27241 run_test 421e "rmfid in DNE"
27247 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27248 skip "Need MDS version at least 2.12.54"
27250 test_mkdir $DIR/$tdir
27252 cnt=$(ls -1 $DIR/$tdir | wc -l)
27253 [ $cnt != 1 ] && error "unexpected #files: $cnt"
27255 FID=$(lfs path2fid $DIR/$tdir/f)
27256 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
27257 # rmfid should fail
27258 cnt=$(ls -1 $DIR/$tdir | wc -l)
27259 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
27261 chmod a+rw $DIR/$tdir
27263 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
27264 # rmfid should fail
27265 cnt=$(ls -1 $DIR/$tdir | wc -l)
27266 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
27269 $RUNAS touch $DIR/$tdir/f
27270 FID=$(lfs path2fid $DIR/$tdir/f)
27271 echo "rmfid as root"
27272 $LFS rmfid $DIR $FID || error "rmfid as root failed"
27273 cnt=$(ls -1 $DIR/$tdir | wc -l)
27274 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
27277 $RUNAS touch $DIR/$tdir/f
27278 cnt=$(ls -1 $DIR/$tdir | wc -l)
27279 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
27280 FID=$(lfs path2fid $DIR/$tdir/f)
27281 # rmfid w/o user_fid2path mount option should fail
27282 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
27283 cnt=$(ls -1 $DIR/$tdir | wc -l)
27284 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
27286 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
27287 stack_trap "rmdir $tmpdir"
27288 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
27289 error "failed to mount client'"
27290 stack_trap "umount_client $tmpdir"
27292 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
27293 # rmfid should succeed
27294 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
27295 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
27297 # rmfid shouldn't allow to remove files due to dir's permission
27298 chmod a+rwx $tmpdir/$tdir
27299 touch $tmpdir/$tdir/f
27300 ls -la $tmpdir/$tdir
27301 FID=$(lfs path2fid $tmpdir/$tdir/f)
27302 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
27305 run_test 421f "rmfid checks permissions"
27311 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
27312 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
27313 skip "Need MDS version at least 2.12.54"
27315 mkdir -p $DIR/$tdir
27316 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
27317 createmany -o $DIR/$tdir/striped_dir/f 512
27318 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
27319 [ $cnt != 512 ] && error "unexpected #files: $cnt"
27321 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
27322 sed "s/[/][^:]*://g")
27324 rm -f $DIR/$tdir/striped_dir/f1*
27325 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
27326 removed=$((512 - cnt))
27328 # few files have been just removed, so we expect
27329 # rmfid to fail on their fids
27330 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
27331 [ $removed != $errors ] && error "$errors != $removed"
27333 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
27335 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
27337 run_test 421g "rmfid to return errors properly"
27340 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
27341 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
27342 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
27343 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
27344 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
27346 local amc=$(at_max_get client)
27347 local amo=$(at_max_get mds1)
27348 local timeout=`lctl get_param -n timeout`
27350 at_max_set 0 client
27353 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
27354 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
27355 fail_val=$(((2*timeout + 10)*1000))
27356 touch $DIR/$tdir/d3/file &
27358 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
27359 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
27360 fail_val=$((2*timeout + 5))
27361 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
27365 sleep $((2 * timeout))
27369 touch $DIR/$tdir/d2/file3
27370 touch $DIR/$tdir/d2/file4
27371 touch $DIR/$tdir/d2/file5
27374 at_max_set $amc client
27375 at_max_set $amo mds1
27377 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
27378 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
27379 error "Watchdog is always throttled"
27381 run_test 422 "kill a process with RPC in progress"
27394 # ensure statfs cache is expired
27397 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
27398 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
27402 run_test 423 "statfs should return a right data"
27405 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
27406 $LCTL set_param fail_loc=0x80000522
27407 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
27410 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
27413 test_mkdir -c -1 $DIR/$tdir
27414 $LFS setstripe -c -1 $DIR/$tdir
27416 lru_resize_disable "" 100
27417 stack_trap "lru_resize_enable" EXIT
27421 for i in $(seq $((MDSCOUNT * 125))); do
27422 local t=$DIR/$tdir/$tfile_$i
27424 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
27425 error_noexit "Create file $t"
27427 stack_trap "rm -rf $DIR/$tdir" EXIT
27429 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
27430 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
27431 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
27433 [ $lock_count -le $lru_size ] ||
27434 error "osc lock count $lock_count > lru size $lru_size"
27437 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
27438 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
27439 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
27441 [ $lock_count -le $lru_size ] ||
27442 error "mdc lock count $lock_count > lru size $lru_size"
27445 run_test 425 "lock count should not exceed lru size"
27448 splice-test -r $DIR/$tfile
27449 splice-test -rd $DIR/$tfile
27450 splice-test $DIR/$tfile
27451 splice-test -d $DIR/$tfile
27453 run_test 426 "splice test on Lustre"
27456 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
27457 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
27458 skip "Need MDS version at least 2.12.4"
27464 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
27465 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
27467 $LFS getdirstripe $DIR/$tdir/1/dir
27469 #first setfattr for creating updatelog
27470 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
27472 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
27473 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
27474 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
27475 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
27479 wait_recovery_complete mds2 $((2*TIMEOUT))
27481 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
27482 echo $log | grep "get update log failed" &&
27483 error "update log corruption is detected" || true
27485 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
27488 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27489 local cache_limit=$CACHE_MAX
27491 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$cache_limit"
27492 $LCTL set_param -n llite.*.max_cached_mb=64
27495 $LFS setstripe -c 1 $DIR/$tdir
27496 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
27497 stack_trap "rm -f $DIR/$tdir/$tfile.*"
27499 for f in $(seq 4); do
27500 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
27504 cancel_lru_locks osc
27506 for f in $(seq 4); do
27507 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
27511 run_test 428 "large block size IO should not hang"
27513 test_429() { # LU-7915 / LU-10948
27514 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
27515 local testfile=$DIR/$tfile
27516 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
27522 $LCTL get_param $ll_opencache_threshold_count ||
27523 skip "client does not have opencache parameter"
27525 set_opencache $new_flag
27526 stack_trap "restore_opencache"
27527 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
27528 error "enable opencache failed"
27530 # drop MDC DLM locks
27531 cancel_lru_locks mdc
27532 # clear MDC RPC stats counters
27533 $LCTL set_param $mdc_rpcstats=clear
27535 # According to the current implementation, we need to run 3 times
27536 # open & close file to verify if opencache is enabled correctly.
27537 # 1st, RPCs are sent for lookup/open and open handle is released on
27539 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
27540 # so open handle won't be released thereafter.
27541 # 3rd, No RPC is sent out.
27542 $MULTIOP $testfile oc || error "multiop failed"
27543 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27544 echo "1st: $first_rpc RPCs in flight"
27546 $MULTIOP $testfile oc || error "multiop failed"
27547 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27548 echo "2nd: $second_rpc RPCs in flight"
27550 $MULTIOP $testfile oc || error "multiop failed"
27551 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27552 echo "3rd: $third_rpc RPCs in flight"
27554 #verify no MDC RPC is sent
27555 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
27557 run_test 429 "verify if opencache flag on client side does work"
27563 # data at [200K, 400K)
27564 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
27565 error "256K->512K dd fails"
27567 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
27568 error "2M->3M dd fails"
27570 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
27571 error "4M->5M dd fails"
27572 echo "Data at 256K...512K, 2M...3M and 4M...5M"
27573 # start at first component hole #1
27574 printf "Seeking hole from 1000 ... "
27575 offset=$(lseek_test -l 1000 $file)
27577 [[ $offset == 1000 ]] || error "offset $offset != 1000"
27578 printf "Seeking data from 1000 ... "
27579 offset=$(lseek_test -d 1000 $file)
27581 [[ $offset == 262144 ]] || error "offset $offset != 262144"
27583 # start at first component data block
27584 printf "Seeking hole from 300000 ... "
27585 offset=$(lseek_test -l 300000 $file)
27587 [[ $offset == 524288 ]] || error "offset $offset != 524288"
27588 printf "Seeking data from 300000 ... "
27589 offset=$(lseek_test -d 300000 $file)
27591 [[ $offset == 300000 ]] || error "offset $offset != 300000"
27593 # start at the first component but beyond end of object size
27594 printf "Seeking hole from 1000000 ... "
27595 offset=$(lseek_test -l 1000000 $file)
27597 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27598 printf "Seeking data from 1000000 ... "
27599 offset=$(lseek_test -d 1000000 $file)
27601 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
27603 # start at second component stripe 2 (empty file)
27604 printf "Seeking hole from 1500000 ... "
27605 offset=$(lseek_test -l 1500000 $file)
27607 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
27608 printf "Seeking data from 1500000 ... "
27609 offset=$(lseek_test -d 1500000 $file)
27611 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
27613 # start at second component stripe 1 (all data)
27614 printf "Seeking hole from 3000000 ... "
27615 offset=$(lseek_test -l 3000000 $file)
27617 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
27618 printf "Seeking data from 3000000 ... "
27619 offset=$(lseek_test -d 3000000 $file)
27621 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
27623 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
27624 error "2nd dd fails"
27625 echo "Add data block at 640K...1280K"
27627 # start at before new data block, in hole
27628 printf "Seeking hole from 600000 ... "
27629 offset=$(lseek_test -l 600000 $file)
27631 [[ $offset == 600000 ]] || error "offset $offset != 600000"
27632 printf "Seeking data from 600000 ... "
27633 offset=$(lseek_test -d 600000 $file)
27635 [[ $offset == 655360 ]] || error "offset $offset != 655360"
27637 # start at the first component new data block
27638 printf "Seeking hole from 1000000 ... "
27639 offset=$(lseek_test -l 1000000 $file)
27641 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
27642 printf "Seeking data from 1000000 ... "
27643 offset=$(lseek_test -d 1000000 $file)
27645 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27647 # start at second component stripe 2, new data
27648 printf "Seeking hole from 1200000 ... "
27649 offset=$(lseek_test -l 1200000 $file)
27651 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
27652 printf "Seeking data from 1200000 ... "
27653 offset=$(lseek_test -d 1200000 $file)
27655 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
27657 # start beyond file end
27658 printf "Using offset > filesize ... "
27659 lseek_test -l 4000000 $file && error "lseek should fail"
27660 printf "Using offset > filesize ... "
27661 lseek_test -d 4000000 $file && error "lseek should fail"
27667 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
27668 skip "MDT does not support SEEK_HOLE"
27670 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27671 skip "OST does not support SEEK_HOLE"
27673 local file=$DIR/$tdir/$tfile
27675 mkdir -p $DIR/$tdir
27677 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
27678 # OST stripe #1 will have continuous data at [1M, 3M)
27679 # OST stripe #2 is empty
27680 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
27681 lseek_test_430 $file
27683 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
27684 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
27685 lseek_test_430 $file
27687 $LFS setstripe -c2 -S 512K $file
27688 echo "Two stripes, stripe size 512K"
27689 lseek_test_430 $file
27691 # FLR with stale mirror
27692 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
27694 echo "Mirrored file:"
27695 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
27696 echo "Plain 2 stripes 1M"
27697 lseek_test_430 $file
27700 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
27703 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27704 skip "OST does not support SEEK_HOLE"
27707 local file=$DIR/$tdir/$tfile
27709 mkdir -p $DIR/$tdir
27710 # Empty layout lseek should fail
27713 printf "Seeking hole from 0 ... "
27714 lseek_test -l 0 $file && error "lseek should fail"
27715 printf "Seeking data from 0 ... "
27716 lseek_test -d 0 $file && error "lseek should fail"
27720 $LFS setstripe -E 1M -c2 -E eof $file
27721 $TRUNCATE $file 1048576
27722 printf "Seeking hole from 1000000 ... "
27723 offset=$(lseek_test -l 1000000 $file)
27725 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27726 printf "Seeking data from 1000000 ... "
27727 lseek_test -d 1000000 $file && error "lseek should fail"
27730 # full component followed by non-inited one
27731 $LFS setstripe -E 1M -c2 -E eof $file
27732 dd if=/dev/urandom of=$file bs=1M count=1
27733 printf "Seeking hole from 1000000 ... "
27734 offset=$(lseek_test -l 1000000 $file)
27736 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27737 printf "Seeking hole from 1048576 ... "
27738 lseek_test -l 1048576 $file && error "lseek should fail"
27739 # init second component and truncate back
27740 echo "123" >> $file
27741 $TRUNCATE $file 1048576
27742 printf "Seeking hole from 1000000 ... "
27743 offset=$(lseek_test -l 1000000 $file)
27745 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27746 printf "Seeking hole from 1048576 ... "
27747 lseek_test -l 1048576 $file && error "lseek should fail"
27748 # boundary checks for big values
27749 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
27750 offset=$(lseek_test -d 0 $file.10g)
27751 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
27752 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
27753 offset=$(lseek_test -d 0 $file.100g)
27754 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
27757 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
27760 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27761 skip "OST does not support SEEK_HOLE"
27763 local file=$DIR/$tdir/$tfile
27766 mkdir -p $DIR/$tdir
27767 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M
27769 # cp version 8.33+ prefers lseek over fiemap
27770 if [[ $(cp --version | head -n1 | sed "s/[^0-9]//g") -ge 833 ]]; then
27772 time cp $file /dev/null
27773 (( SECONDS - start < 5 )) ||
27774 error "cp: too long runtime $((SECONDS - start))"
27777 # tar version 1.29+ supports SEEK_HOLE/DATA
27778 if [[ $(tar --version | head -n1 | sed "s/[^0-9]//g") -ge 129 ]]; then
27780 time tar cS $file - | cat > /dev/null
27781 (( SECONDS - start < 5 )) ||
27782 error "tar: too long runtime $((SECONDS - start))"
27785 run_test 430c "lseek: external tools check"
27787 test_431() { # LU-14187
27788 local file=$DIR/$tdir/$tfile
27790 mkdir -p $DIR/$tdir
27791 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
27792 dd if=/dev/urandom of=$file bs=4k count=1
27793 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
27794 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
27795 #define OBD_FAIL_OST_RESTART_IO 0x251
27796 do_facet ost1 "$LCTL set_param fail_loc=0x251"
27797 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
27801 echo 3 > /proc/sys/vm/drop_caches
27802 diff $file $file.0 || error "data diff"
27804 run_test 431 "Restart transaction for IO"
27806 cleanup_test_432() {
27807 do_facet mgs $LCTL nodemap_activate 0
27808 wait_nm_sync active
27812 local tmpdir=$TMP/dir432
27814 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
27815 skip "Need MDS version at least 2.14.52"
27817 stack_trap cleanup_test_432 EXIT
27821 do_facet mgs $LCTL nodemap_activate 1
27822 wait_nm_sync active
27823 do_facet mgs $LCTL nodemap_modify --name default \
27824 --property admin --value 1
27825 do_facet mgs $LCTL nodemap_modify --name default \
27826 --property trusted --value 1
27827 cancel_lru_locks mdc
27828 wait_nm_sync default admin_nodemap
27829 wait_nm_sync default trusted_nodemap
27831 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
27832 grep -ci "Operation not permitted") -ne 0 ]; then
27833 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
27836 run_test 432 "mv dir from outside Lustre"
27839 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27841 [[ -n "$($LCTL list_param llite.*.inode_cache 2>/dev/null)" ]] ||
27842 skip "inode cache not supported"
27844 $LCTL set_param llite.*.inode_cache=0
27845 stack_trap "$LCTL set_param llite.*.inode_cache=1"
27851 cancel_lru_locks mdc
27852 test_mkdir $DIR/$tdir || error "mkdir $tdir"
27853 createmany -m $DIR/$tdir/f $count
27854 createmany -d $DIR/$tdir/d $count
27855 ls -l $DIR/$tdir > /dev/null
27856 stack_trap "rm -rf $DIR/$tdir"
27858 before=$(num_objects)
27859 cancel_lru_locks mdc
27860 after=$(num_objects)
27862 # sometimes even @before is less than 2 * count
27863 while (( before - after < count )); do
27865 after=$(num_objects)
27867 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
27868 if (( wait > 60 )); then
27869 error "inode slab grew from $before to $after"
27873 echo "lustre_inode_cache $before objs before lock cancel, $after after"
27875 run_test 433 "ldlm lock cancel releases dentries and inodes"
27879 local getxattr_count
27880 local mdc_stat_param="mdc.$FSNAME-MDT0000*.md_stats"
27881 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
27883 [[ $(getenforce) == "Disabled" ]] ||
27884 skip "lsm selinux module have to be disabled for this test"
27886 test_mkdir -i 0 -c1 $DIR/$tdir/ ||
27887 error "fail to create $DIR/$tdir/ on MDT0000"
27889 touch $DIR/$tdir/$tfile-{001..100}
27891 # disable the xattr cache
27892 save_lustre_params client "llite.*.xattr_cache" > $p
27893 lctl set_param llite.*.xattr_cache=0
27894 stack_trap "restore_lustre_params < $p; rm -f $p" EXIT
27896 # clear clients mdc stats
27897 clear_stats $mdc_stat_param ||
27898 error "fail to clear stats on mdc MDT0000"
27900 for file in $DIR/$tdir/$tfile-{001..100}; do
27901 getfattr -n security.selinux $file |&
27902 grep -q "Operation not supported" ||
27903 error "getxattr on security.selinux should return EOPNOTSUPP"
27906 getxattr_count=$(calc_stats $mdc_stat_param "getxattr")
27907 (( getxattr_count < 100 )) ||
27908 error "client sent $getxattr_count getxattr RPCs to the MDS"
27910 run_test 434 "Client should not send RPCs for security.selinux with SElinux disabled"
27913 if [[ -f $LUSTRE/scripts/bash-completion/lustre ]]; then
27914 source $LUSTRE/scripts/bash-completion/lustre
27915 elif [[ -f /usr/share/bash-completion/completions/lustre ]]; then
27916 source /usr/share/bash-completion/completions/lustre
27918 skip "bash completion scripts not found"
27921 local lctl_completions
27922 local lfs_completions
27924 lctl_completions=$(_lustre_cmds lctl)
27925 if [[ ! $lctl_completions =~ "get_param" ]]; then
27926 error "lctl bash completion failed"
27929 lfs_completions=$(_lustre_cmds lfs)
27930 if [[ ! $lfs_completions =~ "setstripe" ]]; then
27931 error "lfs bash completion failed"
27934 run_test 440 "bash completion for lfs, lctl"
27937 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
27938 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
27939 skip "Need server version at least 2.9.55"
27941 start_full_debug_logging
27945 stop_full_debug_logging
27949 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27950 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27951 awk '/The barrier for/ { print $7 }')
27954 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
27959 barrier_expired() {
27962 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27963 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27964 awk '/will be expired/ { print $7 }')
27966 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
27975 echo "Start barrier_freeze at: $(date)"
27976 #define OBD_FAIL_BARRIER_DELAY 0x2202
27977 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
27978 # Do not reduce barrier time - See LU-11873
27979 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
27982 local b_status=$(barrier_stat)
27983 echo "Got barrier status at: $(date)"
27984 [ "$b_status" = "'freezing_p1'" ] ||
27985 error "(1) unexpected barrier status $b_status"
27987 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
27989 b_status=$(barrier_stat)
27990 [ "$b_status" = "'frozen'" ] ||
27991 error "(2) unexpected barrier status $b_status"
27993 local expired=$(barrier_expired)
27994 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
27995 sleep $((expired + 3))
27997 b_status=$(barrier_stat)
27998 [ "$b_status" = "'expired'" ] ||
27999 error "(3) unexpected barrier status $b_status"
28001 # Do not reduce barrier time - See LU-11873
28002 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
28003 error "(4) fail to freeze barrier"
28005 b_status=$(barrier_stat)
28006 [ "$b_status" = "'frozen'" ] ||
28007 error "(5) unexpected barrier status $b_status"
28009 echo "Start barrier_thaw at: $(date)"
28010 #define OBD_FAIL_BARRIER_DELAY 0x2202
28011 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
28012 do_facet mgs $LCTL barrier_thaw $FSNAME &
28015 b_status=$(barrier_stat)
28016 echo "Got barrier status at: $(date)"
28017 [ "$b_status" = "'thawing'" ] ||
28018 error "(6) 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" = "'thawed'" ] ||
28024 error "(7) unexpected barrier status $b_status"
28026 #define OBD_FAIL_BARRIER_FAILURE 0x2203
28027 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
28028 do_facet mgs $LCTL barrier_freeze $FSNAME
28030 b_status=$(barrier_stat)
28031 [ "$b_status" = "'failed'" ] ||
28032 error "(8) unexpected barrier status $b_status"
28034 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
28035 do_facet mgs $LCTL barrier_thaw $FSNAME
28039 run_test 801a "write barrier user interfaces and stat machine"
28044 mkdir $DIR/$tdir || error "(1) fail to mkdir"
28045 createmany -d $DIR/$tdir/d 6 || error "(2) fail to mkdir"
28046 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
28047 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
28048 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
28050 cancel_lru_locks mdc
28052 # 180 seconds should be long enough
28053 do_facet mgs $LCTL barrier_freeze $FSNAME 180
28055 local b_status=$(barrier_stat)
28056 [ "$b_status" = "'frozen'" ] ||
28057 error "(6) unexpected barrier status $b_status"
28059 mkdir $DIR/$tdir/d0/d10 &
28062 touch $DIR/$tdir/d1/f13 &
28065 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
28068 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
28071 rm -f $DIR/$tdir/d4/f12 &
28074 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
28076 # To guarantee taht the 'stat' is not blocked
28077 b_status=$(barrier_stat)
28078 [ "$b_status" = "'frozen'" ] ||
28079 error "(8) unexpected barrier status $b_status"
28081 # let above commands to run at background
28084 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
28085 ps -p $touch_pid || error "(10) touch should be blocked"
28086 ps -p $ln_pid || error "(11) link should be blocked"
28087 ps -p $mv_pid || error "(12) rename should be blocked"
28088 ps -p $rm_pid || error "(13) unlink should be blocked"
28090 b_status=$(barrier_stat)
28091 [ "$b_status" = "'frozen'" ] ||
28092 error "(14) unexpected barrier status $b_status"
28094 do_facet mgs $LCTL barrier_thaw $FSNAME
28095 b_status=$(barrier_stat)
28096 [ "$b_status" = "'thawed'" ] ||
28097 error "(15) unexpected barrier status $b_status"
28099 wait $mkdir_pid || error "(16) mkdir should succeed"
28100 wait $touch_pid || error "(17) touch should succeed"
28101 wait $ln_pid || error "(18) link should succeed"
28102 wait $mv_pid || error "(19) rename should succeed"
28103 wait $rm_pid || error "(20) unlink should succeed"
28107 run_test 801b "modification will be blocked by write barrier"
28110 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28114 stop mds2 || error "(1) Fail to stop mds2"
28116 do_facet mgs $LCTL barrier_freeze $FSNAME 30
28118 local b_status=$(barrier_stat)
28119 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
28120 do_facet mgs $LCTL barrier_thaw $FSNAME
28121 error "(2) unexpected barrier status $b_status"
28124 do_facet mgs $LCTL barrier_rescan $FSNAME ||
28125 error "(3) Fail to rescan barrier bitmap"
28127 # Do not reduce barrier time - See LU-11873
28128 do_facet mgs $LCTL barrier_freeze $FSNAME 20
28130 b_status=$(barrier_stat)
28131 [ "$b_status" = "'frozen'" ] ||
28132 error "(4) unexpected barrier status $b_status"
28134 do_facet mgs $LCTL barrier_thaw $FSNAME
28135 b_status=$(barrier_stat)
28136 [ "$b_status" = "'thawed'" ] ||
28137 error "(5) unexpected barrier status $b_status"
28139 local devname=$(mdsdevname 2)
28141 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
28143 do_facet mgs $LCTL barrier_rescan $FSNAME ||
28144 error "(7) Fail to rescan barrier bitmap"
28148 run_test 801c "rescan barrier bitmap"
28151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28152 remote_mds_nodsh && skip "remote MDS with nodsh"
28154 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
28155 skip "readonly option not available"
28157 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
28159 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
28160 error "(2) Fail to copy"
28162 # write back all cached data before setting MDT to readonly
28166 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
28167 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
28169 echo "Modify should be refused"
28170 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
28172 echo "Read should be allowed"
28173 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
28174 error "(7) Read should succeed under ro mode"
28177 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
28179 run_test 802b "be able to set MDTs to readonly"
28182 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28183 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
28184 skip "MDS needs to be newer than 2.10.54"
28186 mkdir_on_mdt0 $DIR/$tdir
28187 # Create some objects on all MDTs to trigger related logs objects
28188 for idx in $(seq $MDSCOUNT); do
28189 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
28190 $DIR/$tdir/dir${idx} ||
28191 error "Fail to create $DIR/$tdir/dir${idx}"
28194 wait_delete_completed # ensure old test cleanups are finished
28196 echo "before create:"
28198 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
28200 for i in {1..10}; do
28201 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
28202 error "Fail to create $DIR/$tdir/foo$i"
28205 # sync ZFS-on-MDS to refresh statfs data
28206 wait_zfs_commit mds1
28208 echo "after create:"
28210 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
28212 # allow for an llog to be cleaned up during the test
28213 [ $after_used -ge $((before_used + 10 - 1)) ] ||
28214 error "before ($before_used) + 10 > after ($after_used)"
28216 for i in {1..10}; do
28217 rm -rf $DIR/$tdir/foo$i ||
28218 error "Fail to remove $DIR/$tdir/foo$i"
28221 # sync ZFS-on-MDS to refresh statfs data
28222 wait_zfs_commit mds1
28223 wait_delete_completed
28224 sleep 3 # avoid MDT return cached statfs
28225 echo "after unlink:"
28227 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
28229 # allow for an llog to be created during the test
28230 [ $after_used -le $((before_used + 1)) ] ||
28231 error "after ($after_used) > before ($before_used) + 1"
28233 run_test 803a "verify agent object for remote object"
28236 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28237 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
28238 skip "MDS needs to be newer than 2.13.56"
28239 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28241 for i in $(seq 0 $((MDSCOUNT - 1))); do
28242 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
28250 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
28251 for i in $(seq 0 $((MDSCOUNT - 1))); do
28252 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
28253 awk '/getattr/ { print $2 }')
28254 before=$((before + tmp))
28256 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
28257 for i in $(seq 0 $((MDSCOUNT - 1))); do
28258 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
28259 awk '/getattr/ { print $2 }')
28260 after=$((after + tmp))
28263 [ $before -eq $after ] || error "getattr count $before != $after"
28265 run_test 803b "remote object can getattr from cache"
28268 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28269 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
28270 skip "MDS needs to be newer than 2.10.54"
28271 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
28273 mkdir -p $DIR/$tdir
28274 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
28275 error "Fail to create $DIR/$tdir/dir0"
28277 local fid=$($LFS path2fid $DIR/$tdir/dir0)
28278 local dev=$(mdsdevname 2)
28280 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
28281 grep ${fid} || error "NOT found agent entry for dir0"
28283 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
28284 error "Fail to create $DIR/$tdir/dir1"
28286 touch $DIR/$tdir/dir1/foo0 ||
28287 error "Fail to create $DIR/$tdir/dir1/foo0"
28288 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
28291 for idx in $(seq $MDSCOUNT); do
28292 dev=$(mdsdevname $idx)
28293 do_facet mds${idx} \
28294 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
28295 grep ${fid} && rc=$idx
28298 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
28299 error "Fail to rename foo0 to foo1"
28300 if [ $rc -eq 0 ]; then
28301 for idx in $(seq $MDSCOUNT); do
28302 dev=$(mdsdevname $idx)
28303 do_facet mds${idx} \
28304 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
28305 grep ${fid} && rc=$idx
28309 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
28310 error "Fail to rename foo1 to foo2"
28311 if [ $rc -eq 0 ]; then
28312 for idx in $(seq $MDSCOUNT); do
28313 dev=$(mdsdevname $idx)
28314 do_facet mds${idx} \
28315 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
28316 grep ${fid} && rc=$idx
28320 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
28322 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
28323 error "Fail to link to $DIR/$tdir/dir1/foo2"
28324 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
28325 error "Fail to rename foo2 to foo0"
28326 unlink $DIR/$tdir/dir1/foo0 ||
28327 error "Fail to unlink $DIR/$tdir/dir1/foo0"
28328 rm -rf $DIR/$tdir/dir0 ||
28329 error "Fail to rm $DIR/$tdir/dir0"
28331 for idx in $(seq $MDSCOUNT); do
28335 dev=$(mdsdevname $idx)
28336 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
28338 start mds${idx} $dev $MDS_MOUNT_OPTS ||
28339 error "mount mds$idx failed"
28340 df $MOUNT > /dev/null 2>&1
28342 # e2fsck should not return error
28344 error "e2fsck detected error on MDT${idx}: rc=$rc"
28347 run_test 804 "verify agent entry for remote entry"
28350 do_facet $SINGLEMDS zfs set quota=$old $fsset
28351 unlinkmany $DIR/$tdir/f- 1000000
28356 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
28357 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
28358 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
28359 skip "netfree not implemented before 0.7"
28360 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
28361 skip "Need MDS version at least 2.10.57"
28368 local pref="osd-zfs.$FSNAME-MDT0000."
28370 # limit available space on MDS dataset to meet nospace issue
28371 # quickly. then ZFS 0.7.2 can use reserved space if asked
28372 # properly (using netfree flag in osd_declare_destroy()
28373 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
28374 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
28376 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
28377 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
28378 let "usedkb=usedkb-freekb"
28379 let "freekb=freekb/2"
28380 if let "freekb > 5000"; then
28383 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
28384 trap cleanup_805 EXIT
28385 mkdir_on_mdt0 $DIR/$tdir
28386 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
28387 error "Can't set PFL layout"
28388 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
28389 rm -rf $DIR/$tdir || error "not able to remove"
28390 do_facet $SINGLEMDS zfs set quota=$old $fsset
28393 run_test 805 "ZFS can remove from full fs"
28399 local expect=$(stat -c %s $file)
28401 check_lsom_size $1 $expect
28403 local blocks=$($LFS getsom -b $file)
28404 expect=$(stat -c %b $file)
28405 [[ $blocks == $expect ]] ||
28406 error "$file expected blocks: $expect, got: $blocks"
28414 cancel_lru_locks mdc
28416 size=$($LFS getsom -s $1)
28417 [[ $size == $expect ]] ||
28418 error "$file expected size: $expect, got: $size"
28422 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
28423 skip "Need MDS version at least 2.11.52"
28427 touch $DIR/$tfile || error "touch $tfile failed"
28429 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
28430 save_lustre_params client "llite.*.xattr_cache" > $save
28431 lctl set_param llite.*.xattr_cache=0
28432 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
28434 # single-threaded write
28435 echo "Test SOM for single-threaded write"
28436 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
28437 error "write $tfile failed"
28438 check_lsom_size $DIR/$tfile $bs
28441 local size=$(($num * $bs))
28445 echo "Test SOM for single client multi-threaded($num) write"
28446 $TRUNCATE $DIR/$tfile 0
28447 for ((i = 0; i < $num; i++)); do
28448 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28450 offset=$((offset + $bs))
28452 for (( i=0; i < $num; i++ )); do
28455 check_lsom_size $DIR/$tfile $size
28457 $TRUNCATE $DIR/$tfile 0
28458 for ((i = 0; i < $num; i++)); do
28459 offset=$((offset - $bs))
28460 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28463 for (( i=0; i < $num; i++ )); do
28466 check_lsom_size $DIR/$tfile $size
28468 # multi-client writes
28469 num=$(get_node_count ${CLIENTS//,/ })
28470 size=$(($num * $bs))
28474 echo "Test SOM for multi-client ($num) writes"
28475 $TRUNCATE $DIR/$tfile 0
28476 for client in ${CLIENTS//,/ }; do
28477 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28480 offset=$((offset + $bs))
28482 for (( i=0; i < $num; i++ )); do
28485 check_lsom_size $DIR/$tfile $offset
28488 $TRUNCATE $DIR/$tfile 0
28489 for client in ${CLIENTS//,/ }; do
28490 offset=$((offset - $bs))
28491 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28495 for (( i=0; i < $num; i++ )); do
28498 check_lsom_size $DIR/$tfile $size
28501 echo "Test SOM for truncate"
28502 $TRUNCATE $DIR/$tfile 1048576
28503 check_lsom_size $DIR/$tfile 1048576
28504 $TRUNCATE $DIR/$tfile 1234
28505 check_lsom_size $DIR/$tfile 1234
28507 # verify SOM blocks count
28508 echo "Verify SOM block count"
28509 $TRUNCATE $DIR/$tfile 0
28510 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
28511 error "failed to write file $tfile"
28512 check_lsom_data $DIR/$tfile
28514 run_test 806 "Verify Lazy Size on MDS"
28517 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
28518 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
28519 skip "Need MDS version at least 2.11.52"
28521 # Registration step
28522 changelog_register || error "changelog_register failed"
28523 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
28524 changelog_users $SINGLEMDS | grep -q $cl_user ||
28525 error "User $cl_user not found in changelog_users"
28527 rm -rf $DIR/$tdir || error "rm $tdir failed"
28528 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
28529 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
28530 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
28531 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
28532 error "truncate $tdir/trunc failed"
28535 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
28536 error "write $tfile failed"
28538 # multi-client wirtes
28539 local num=$(get_node_count ${CLIENTS//,/ })
28543 echo "Test SOM for multi-client ($num) writes"
28544 touch $DIR/$tfile || error "touch $tfile failed"
28545 $TRUNCATE $DIR/$tfile 0
28546 for client in ${CLIENTS//,/ }; do
28547 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28550 offset=$((offset + $bs))
28552 for (( i=0; i < $num; i++ )); do
28556 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
28557 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
28558 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
28559 check_lsom_data $DIR/$tdir/trunc
28560 check_lsom_data $DIR/$tdir/single_dd
28561 check_lsom_data $DIR/$tfile
28564 # Deregistration step
28565 changelog_deregister || error "changelog_deregister failed"
28567 run_test 807 "verify LSOM syncing tool"
28569 check_som_nologged()
28571 local lines=$($LFS changelog $FSNAME-MDT0000 |
28572 grep 'x=trusted.som' | wc -l)
28573 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
28577 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
28578 skip "Need MDS version at least 2.11.55"
28580 # Registration step
28581 changelog_register || error "changelog_register failed"
28583 touch $DIR/$tfile || error "touch $tfile failed"
28586 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
28587 error "write $tfile failed"
28590 $TRUNCATE $DIR/$tfile 1234
28593 $TRUNCATE $DIR/$tfile 1048576
28596 # Deregistration step
28597 changelog_deregister || error "changelog_deregister failed"
28599 run_test 808 "Check trusted.som xattr not logged in Changelogs"
28604 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
28608 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
28609 skip "Need MDS version at least 2.11.56"
28611 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
28612 error "failed to create DoM-only file $DIR/$tfile"
28613 touch $DIR/$tfile || error "touch $tfile failed"
28614 check_som_nodata $DIR/$tfile
28616 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
28617 error "write $tfile failed"
28618 check_som_nodata $DIR/$tfile
28620 $TRUNCATE $DIR/$tfile 1234
28621 check_som_nodata $DIR/$tfile
28623 $TRUNCATE $DIR/$tfile 4097
28624 check_som_nodata $DIR/$file
28626 run_test 809 "Verify no SOM xattr store for DoM-only files"
28629 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28630 $GSS && skip_env "could not run with gss"
28631 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
28632 skip "OST < 2.12.58 doesn't align checksum"
28635 stack_trap "set_checksums $ORIG_CSUM" EXIT
28636 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
28641 for csum in $CKSUM_TYPES; do
28642 #define OBD_FAIL_OSC_NO_GRANT 0x411
28643 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
28644 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
28646 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
28647 before=$(md5sum $DIR/$tfile)
28648 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
28649 after=$(md5sum $DIR/$tfile)
28650 [ "$before" == "$after" ] ||
28651 error "$csum: $before != $after bs=$1 seek=$2"
28655 run_test 810 "partial page writes on ZFS (LU-11663)"
28658 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
28659 skip "OST < 2.12.51 doesn't support this fail_loc"
28661 $LFS setstripe -c 1 -i 0 $DIR/$tfile
28662 # ensure ost1 is connected
28663 stat $DIR/$tfile >/dev/null || error "can't stat"
28664 wait_osc_import_state client ost1 FULL
28665 # no locks, no reqs to let the connection idle
28666 cancel_lru_locks osc
28668 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
28669 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
28670 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
28671 wait_osc_import_state client ost1 CONNECTING
28672 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
28674 stat $DIR/$tfile >/dev/null || error "can't stat file"
28676 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
28678 test_812b() { # LU-12378
28679 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
28680 skip "OST < 2.12.51 doesn't support this fail_loc"
28682 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
28683 # ensure ost1 is connected
28684 stat $DIR/$tfile >/dev/null || error "can't stat"
28685 wait_osc_import_state client ost1 FULL
28686 # no locks, no reqs to let the connection idle
28687 cancel_lru_locks osc
28689 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
28690 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
28691 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
28692 wait_osc_import_state client ost1 CONNECTING
28693 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
28695 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
28696 wait_osc_import_state client ost1 IDLE
28698 run_test 812b "do not drop no resend request for idle connect"
28703 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
28705 $LFS setstripe -c 1 -o 0 $DIR/$tfile
28706 $LFS getstripe $DIR/$tfile
28707 $LCTL set_param osc.*.idle_timeout=10
28708 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
28709 # ensure ost1 is connected
28710 stat $DIR/$tfile >/dev/null || error "can't stat"
28711 wait_osc_import_state client ost1 FULL
28712 # no locks, no reqs to let the connection idle
28713 cancel_lru_locks osc
28715 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
28716 $LCTL set_param fail_loc=0x80000533
28718 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
28720 run_test 812c "idle import vs lock enqueue race"
28723 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
28724 [ -z "$file_heat_sav" ] && skip "no file heat support"
28735 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
28736 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
28738 $LCTL set_param -n llite.*.file_heat=1
28739 echo "Turn on file heat"
28740 echo "Period second: $period_second, Decay percentage: $decay_pct"
28742 echo "QQQQ" > $DIR/$tfile
28743 echo "QQQQ" > $DIR/$tfile
28744 echo "QQQQ" > $DIR/$tfile
28745 cat $DIR/$tfile > /dev/null
28746 cat $DIR/$tfile > /dev/null
28747 cat $DIR/$tfile > /dev/null
28748 cat $DIR/$tfile > /dev/null
28750 local out=$($LFS heat_get $DIR/$tfile)
28752 $LFS heat_get $DIR/$tfile
28753 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28754 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28755 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28756 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28758 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
28759 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
28760 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
28761 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
28763 sleep $((period_second + 3))
28764 echo "Sleep $((period_second + 3)) seconds..."
28765 # The recursion formula to calculate the heat of the file f is as
28767 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
28768 # Where Hi is the heat value in the period between time points i*I and
28769 # (i+1)*I; Ci is the access count in the period; the symbol P refers
28770 # to the weight of Ci.
28771 out=$($LFS heat_get $DIR/$tfile)
28772 $LFS heat_get $DIR/$tfile
28773 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28774 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28775 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28776 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28778 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
28779 error "read sample ($readsample) is wrong"
28780 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
28781 error "write sample ($writesample) is wrong"
28782 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
28783 error "read bytes ($readbyte) is wrong"
28784 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
28785 error "write bytes ($writebyte) is wrong"
28787 echo "QQQQ" > $DIR/$tfile
28788 echo "QQQQ" > $DIR/$tfile
28789 echo "QQQQ" > $DIR/$tfile
28790 cat $DIR/$tfile > /dev/null
28791 cat $DIR/$tfile > /dev/null
28792 cat $DIR/$tfile > /dev/null
28793 cat $DIR/$tfile > /dev/null
28795 sleep $((period_second + 3))
28796 echo "Sleep $((period_second + 3)) seconds..."
28798 out=$($LFS heat_get $DIR/$tfile)
28799 $LFS heat_get $DIR/$tfile
28800 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28801 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28802 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28803 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28805 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
28806 4 * $decay_pct) / 100") -eq 1 ] ||
28807 error "read sample ($readsample1) is wrong"
28808 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
28809 3 * $decay_pct) / 100") -eq 1 ] ||
28810 error "write sample ($writesample1) is wrong"
28811 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
28812 20 * $decay_pct) / 100") -eq 1 ] ||
28813 error "read bytes ($readbyte1) is wrong"
28814 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
28815 15 * $decay_pct) / 100") -eq 1 ] ||
28816 error "write bytes ($writebyte1) is wrong"
28818 echo "Turn off file heat for the file $DIR/$tfile"
28819 $LFS heat_set -o $DIR/$tfile
28821 echo "QQQQ" > $DIR/$tfile
28822 echo "QQQQ" > $DIR/$tfile
28823 echo "QQQQ" > $DIR/$tfile
28824 cat $DIR/$tfile > /dev/null
28825 cat $DIR/$tfile > /dev/null
28826 cat $DIR/$tfile > /dev/null
28827 cat $DIR/$tfile > /dev/null
28829 out=$($LFS heat_get $DIR/$tfile)
28830 $LFS heat_get $DIR/$tfile
28831 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28832 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28833 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28834 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28836 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28837 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28838 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28839 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28841 echo "Trun on file heat for the file $DIR/$tfile"
28842 $LFS heat_set -O $DIR/$tfile
28844 echo "QQQQ" > $DIR/$tfile
28845 echo "QQQQ" > $DIR/$tfile
28846 echo "QQQQ" > $DIR/$tfile
28847 cat $DIR/$tfile > /dev/null
28848 cat $DIR/$tfile > /dev/null
28849 cat $DIR/$tfile > /dev/null
28850 cat $DIR/$tfile > /dev/null
28852 out=$($LFS heat_get $DIR/$tfile)
28853 $LFS heat_get $DIR/$tfile
28854 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28855 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28856 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28857 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28859 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
28860 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
28861 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
28862 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
28864 $LFS heat_set -c $DIR/$tfile
28865 $LCTL set_param -n llite.*.file_heat=0
28866 echo "Turn off file heat support for the Lustre filesystem"
28868 echo "QQQQ" > $DIR/$tfile
28869 echo "QQQQ" > $DIR/$tfile
28870 echo "QQQQ" > $DIR/$tfile
28871 cat $DIR/$tfile > /dev/null
28872 cat $DIR/$tfile > /dev/null
28873 cat $DIR/$tfile > /dev/null
28874 cat $DIR/$tfile > /dev/null
28876 out=$($LFS heat_get $DIR/$tfile)
28877 $LFS heat_get $DIR/$tfile
28878 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28879 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28880 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28881 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28883 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28884 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28885 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28886 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28888 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
28891 run_test 813 "File heat verfication"
28895 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
28896 echo -n y >> $DIR/$tfile
28897 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
28898 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
28900 run_test 814 "sparse cp works as expected (LU-12361)"
28904 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
28905 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
28907 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
28910 local ost1_imp=$(get_osc_import_name client ost1)
28911 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
28914 $LFS setstripe -c 1 -i 0 $DIR/$tfile
28915 # ensure ost1 is connected
28917 stat $DIR/$tfile >/dev/null || error "can't stat"
28918 wait_osc_import_state client ost1 FULL
28919 # no locks, no reqs to let the connection idle
28920 cancel_lru_locks osc
28921 lru_resize_disable osc
28924 before=$($LCTL get_param -n \
28925 ldlm.namespaces.$imp_name.lru_size)
28927 wait_osc_import_state client ost1 IDLE
28928 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
28929 now=$($LCTL get_param -n \
28930 ldlm.namespaces.$imp_name.lru_size)
28931 [ $before == $now ] || error "lru_size changed $before != $now"
28933 run_test 816 "do not reset lru_resize on idle reconnect"
28937 exportfs -u localhost:$DIR/nfsexp
28942 systemctl restart nfs-server.service || skip "failed to restart nfsd"
28944 mkdir -p $DIR/nfsexp
28945 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
28946 error "failed to export nfs"
28948 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
28949 stack_trap cleanup_817 EXIT
28951 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
28952 error "failed to mount nfs to $tmpdir"
28954 cp /bin/true $tmpdir
28955 $DIR/nfsexp/true || error "failed to execute 'true' command"
28957 run_test 817 "nfsd won't cache write lock for exec file"
28960 test_mkdir -i0 -c1 $DIR/$tdir
28961 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
28962 $LFS setstripe -c1 -i1 $DIR/$tdir/$tfile
28965 # restore osp-syn threads
28966 stack_trap "fail $SINGLEMDS"
28968 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
28969 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
28970 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
28971 error "start $SINGLEMDS failed"
28974 local testid=$(echo $TESTNAME | tr '_' ' ')
28976 do_facet mds1 dmesg | tac | sed "/$testid/,$ d" |
28977 grep "run LFSCK" || error "run LFSCK is not suggested"
28979 run_test 818 "unlink with failed llog"
28982 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28983 cancel_lru_locks osc
28984 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
28985 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
28986 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
28989 run_test 819a "too big niobuf in read"
28992 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
28993 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
28994 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28995 cancel_lru_locks osc
28999 run_test 819b "too big niobuf in write"
29002 function test_820_start_ost() {
29005 for num in $(seq $OSTCOUNT); do
29006 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
29011 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
29014 umount_client $MOUNT || error "umount failed"
29015 for num in $(seq $OSTCOUNT); do
29019 # mount client with no active OSTs
29020 # so that the client can't initialize max LOV EA size
29021 # from OSC notifications
29022 mount_client $MOUNT || error "mount failed"
29023 # delay OST starting to keep this 0 max EA size for a while
29024 test_820_start_ost &
29026 # create a directory on MDS2
29027 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
29028 error "Failed to create directory"
29029 # open intent should update default EA size
29030 # see mdc_update_max_ea_from_body()
29031 # notice this is the very first RPC to MDS2
29032 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
29035 # With SSK, this situation can lead to -EPERM being returned.
29036 # In that case, simply retry.
29037 if [ $ret -ne 0 ] && $SHARED_KEY; then
29038 if echo "$out" | grep -q "not permitted"; then
29039 cp /etc/services $DIR/$tdir/mds2
29043 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
29045 run_test 820 "update max EA from open intent"
29048 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
29049 local OST_MAX_PRECREATE=20000
29051 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
29052 skip "Need MDS version at least 2.14.56"
29054 save_lustre_params mds1 \
29055 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
29056 do_facet $SINGLEMDS "$LCTL set_param -n \
29057 osp.$FSNAME-OST*MDT0000.max_create_count=0"
29058 do_facet $SINGLEMDS "$LCTL set_param -n \
29059 osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE"
29061 stack_trap "restore_lustre_params < $p; rm $p"
29063 do_facet $SINGLEMDS "$LCTL set_param -n \
29064 osp.$FSNAME-OST*-osc-MDT*.create_count=100200"
29066 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
29067 osp.$FSNAME-OST0000*MDT0000.create_count")
29068 local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \
29069 osp.$FSNAME-OST0000*MDT0000.max_create_count")
29070 local expect_count=$(((($max/2)/256) * 256))
29072 log "setting create_count to 100200:"
29073 log " -result- count: $count with max: $max, expecting: $expect_count"
29075 [[ $count -eq expect_count ]] ||
29076 error "Create count not set to max precreate."
29078 run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum"
29081 [[ $MDS1_VERSION -lt $(version_code 2.14.56) ]] &&
29082 skip "Need MDS version 2.14.56"
29084 local sync_changes=$(do_facet $SINGLEMDS \
29085 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
29087 [ "$sync_changes" -gt 100 ] &&
29088 skip "Sync changes $sync_changes > 100 already"
29090 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
29092 $LFS mkdir -i 0 $DIR/$tdir
29093 $LFS setstripe -c 1 -i 0 $DIR/$tdir
29095 save_lustre_params mds1 \
29096 "osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes" > $p
29097 save_lustre_params mds1 \
29098 "osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress" >> $p
29100 do_facet mds1 "$LCTL set_param -n \
29101 osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes=100 \
29102 osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress=128"
29103 stack_trap "restore_lustre_params < $p" EXIT
29105 createmany -o $DIR/$tdir/f- 1000
29106 unlinkmany $DIR/$tdir/f- 1000 &
29107 local UNLINK_PID=$!
29110 sync_changes=$(do_facet mds1 \
29111 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
29112 # the check in the code is racy, fail the test
29113 # if the value above the limit by 10.
29114 [ $sync_changes -gt 110 ] && {
29115 kill -2 $UNLINK_PID
29117 error "osp changes throttling failed, $sync_changes>110"
29119 kill -0 $UNLINK_PID 2> /dev/null || break
29123 run_test 831 "throttling unlink/setattr queuing on OSP"
29126 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
29127 (( $MDS1_VERSION >= $(version_code 2.15.52) )) ||
29128 skip "Need MDS version 2.15.52+"
29129 is_rmentry_supported || skip "rm_entry not supported"
29131 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
29132 mkdir $DIR/$tdir/local_dir || error "mkdir local_dir failed"
29133 mkdir_on_mdt -i 1 $DIR/$tdir/remote_dir ||
29134 error "mkdir remote_dir failed"
29135 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/striped_dir ||
29136 error "mkdir striped_dir failed"
29137 touch $DIR/$tdir/file || error "touch file failed"
29138 $LFS rm_entry $DIR/$tdir/* || error "lfs rm_entry $tdir/* failed"
29139 [ -z "$(ls -A $DIR/$tdir)" ] || error "$tdir not empty"
29141 run_test 832 "lfs rm_entry"
29144 # tests that do cleanup/setup should be run at the end
29148 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29151 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
29152 $LCTL set_param fail_loc=0x903
29154 cancel_lru_locks MGC
29156 FAIL_ON_ERROR=true cleanup
29157 FAIL_ON_ERROR=true setup
29159 run_test 900 "umount should not race with any mgc requeue thread"
29161 # LUS-6253/LU-11185
29169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29171 # some get_param have a bug to handle dot in param name
29172 cancel_lru_locks MGC
29173 old=$(mount -t lustre | wc -l)
29181 while [ $old -ne $oldc ]; do
29182 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
29185 if [ $count -ge $TIMEOUT ]; then
29186 error "too large timeout"
29189 umount_client $MOUNT || error "umount failed"
29190 mount_client $MOUNT || error "mount failed"
29191 cancel_lru_locks MGC
29192 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
29194 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
29198 run_test 901 "don't leak a mgc lock on client umount"
29202 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
29203 skip "client does not have LU-13377 fix"
29204 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
29205 $LCTL set_param fail_loc=0x1415
29206 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
29207 cancel_lru_locks osc
29210 run_test 902 "test short write doesn't hang lustre"
29214 $LFS setstripe -i 0 -c 1 $DIR/$tfile $DIR/${tfile}-2
29215 echo "blah" > $DIR/${tfile}-2
29216 dd if=/dev/zero of=$DIR/$tfile bs=1M count=6 conv=fsync
29217 #define OBD_FAIL_OSC_SLOW_PAGE_EVICT 0x417
29218 $LCTL set_param fail_loc=0x417 fail_val=20
29220 mv $DIR/${tfile}-2 $DIR/$tfile # Destroys the big object
29221 sleep 1 # To start the destroy
29222 wait_destroy_complete 150 || error "Destroy taking too long"
29223 cat $DIR/$tfile > /dev/null || error "Evicted"
29225 run_test 903 "Test long page discard does not cause evictions"
29228 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
29229 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
29230 grep -q project || skip "skip project quota not supported"
29232 local testfile="$DIR/$tdir/$tfile"
29233 local xattr="trusted.projid"
29235 local mdts=$(comma_list $(mdts_nodes))
29236 local saved=$(do_facet mds1 $LCTL get_param -n \
29237 osd-ldiskfs.*MDT0000.enable_projid_xattr)
29239 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=0
29240 stack_trap "do_nodes $mdts $LCTL set_param \
29241 osd-ldiskfs.*MDT*.enable_projid_xattr=$saved"
29243 mkdir -p $DIR/$tdir
29245 #hide projid xattr on server
29246 $LFS project -p 1 $testfile ||
29247 error "set $testfile project id failed"
29248 getfattr -m - $testfile | grep $xattr &&
29249 error "do not show trusted.projid when disabled on server"
29250 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=1
29251 #should be hidden when projid is 0
29252 $LFS project -p 0 $testfile ||
29253 error "set $testfile project id failed"
29254 getfattr -m - $testfile | grep $xattr &&
29255 error "do not show trusted.projid with project ID 0"
29257 #still can getxattr explicitly
29258 projid=$(getfattr -n $xattr $testfile |
29259 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
29260 [ $projid == "0" ] ||
29261 error "projid expected 0 not $projid"
29263 #set the projid via setxattr
29264 setfattr -n $xattr -v "1000" $testfile ||
29265 error "setattr failed with $?"
29266 projid=($($LFS project $testfile))
29267 [ ${projid[0]} == "1000" ] ||
29268 error "projid expected 1000 not $projid"
29270 #check the new projid via getxattr
29271 $LFS project -p 1001 $testfile ||
29272 error "set $testfile project id failed"
29273 getfattr -m - $testfile | grep $xattr ||
29274 error "should show trusted.projid when project ID != 0"
29275 projid=$(getfattr -n $xattr $testfile |
29276 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
29277 [ $projid == "1001" ] ||
29278 error "projid expected 1001 not $projid"
29280 #try to set invalid projid
29281 setfattr -n $xattr -v "4294967295" $testfile &&
29282 error "set invalid projid should fail"
29284 #remove the xattr means setting projid to 0
29285 setfattr -x $xattr $testfile ||
29286 error "setfattr failed with $?"
29287 projid=($($LFS project $testfile))
29288 [ ${projid[0]} == "0" ] ||
29289 error "projid expected 0 not $projid"
29291 #should be hidden when parent has inherit flag and same projid
29292 $LFS project -srp 1002 $DIR/$tdir ||
29293 error "set $tdir project id failed"
29294 getfattr -m - $testfile | grep $xattr &&
29295 error "do not show trusted.projid with inherit flag"
29297 #still can getxattr explicitly
29298 projid=$(getfattr -n $xattr $testfile |
29299 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
29300 [ $projid == "1002" ] ||
29301 error "projid expected 1002 not $projid"
29303 run_test 904 "virtual project ID xattr"
29307 (( $OST1_VERSION >= $(version_code 2.8.54) )) ||
29308 skip "lustre < 2.8.54 does not support ladvise"
29310 remote_ost_nodsh && skip "remote OST with nodsh"
29311 $LFS setstripe -c -1 -i 0 $DIR/$tfile || error "setstripe failed"
29313 $LFS ladvise -a willread $DIR/$tfile || error "ladvise does not work"
29315 #define OBD_FAIL_OST_OPCODE 0x253
29317 do_facet ost1 "$LCTL set_param fail_val=21 fail_loc=0x0253"
29318 $LFS ladvise -a willread $DIR/$tfile &&
29319 error "unexpected success of ladvise with fault injection"
29320 $LFS ladvise -a willread $DIR/$tfile |&
29321 grep -q "Operation not supported"
29322 (( $? == 0 )) || error "unexpected stderr of ladvise with fault injection"
29324 run_test 905 "bad or new opcode should not stuck client"
29327 grep -q io_uring_setup /proc/kallsyms ||
29328 skip "Client OS does not support io_uring I/O engine"
29329 io_uring_probe || skip "kernel does not support io_uring fully"
29330 which fio || skip_env "no fio installed"
29331 fio --enghelp | grep -q io_uring ||
29332 skip_env "fio does not support io_uring I/O engine"
29334 local file=$DIR/$tfile
29335 local ioengine="io_uring"
29339 fio --name=seqwrite --ioengine=$ioengine \
29340 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
29341 --iodepth=64 --size=$size --filename=$file --rw=write ||
29342 error "fio seqwrite $file failed"
29344 fio --name=seqread --ioengine=$ioengine \
29345 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
29346 --iodepth=64 --size=$size --filename=$file --rw=read ||
29347 error "fio seqread $file failed"
29349 rm -f $file || error "rm -f $file failed"
29351 run_test 906 "Simple test for io_uring I/O engine via fio"
29355 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
29356 check_and_cleanup_lustre
29357 if [ "$I_MOUNTED" != "yes" ]; then
29358 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true