3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
17 CREATETEST=${CREATETEST:-createtest}
18 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
19 OPENFILE=${OPENFILE:-openfile}
20 OPENUNLINK=${OPENUNLINK:-openunlink}
21 READS=${READS:-"reads"}
22 MUNLINK=${MUNLINK:-munlink}
23 SOCKETSERVER=${SOCKETSERVER:-socketserver}
24 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
25 MEMHOG=${MEMHOG:-memhog}
26 DIRECTIO=${DIRECTIO:-directio}
27 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
33 LUSTRE=${LUSTRE:-$(dirname $0)/..}
34 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
35 . $LUSTRE/tests/test-framework.sh
40 ALWAYS_EXCEPT="$SANITY_EXCEPT "
41 always_except LU-9693 42a 42c
42 always_except LU-6493 42b
43 always_except LU-14541 277
44 always_except LU-9054 312
45 always_except LU-8411 407
48 always_except LU-14181 64e 64f
51 # skip the grant tests for ARM until they are fixed
52 if [[ $(uname -m) = aarch64 ]]; then
53 always_except LU-11671 45
56 # skip nfs tests on kernels >= 4.12.0 until they are fixed
57 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
58 always_except LU-12661 817
60 # skip cgroup tests on RHEL8.1 kernels until they are fixed
61 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
62 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
63 always_except LU-13063 411
67 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 60i 64b 68 71 115 135 136 230d 300o"
69 if [ "$mds1_FSTYPE" = "zfs" ]; then
71 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
74 if [ "$ost1_FSTYPE" = "zfs" ]; then
75 always_except LU-1941 130b 130c 130d 130e 130f 130g
78 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
80 # Get the SLES distro version
82 # Returns a version string that should only be used in comparing
83 # strings returned by version_code()
86 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
88 # All SuSE Linux versions have one decimal. version_code expects two
89 local sles_version=$version.0
90 version_code $sles_version
93 # Check if we are running on Ubuntu or SLES so we can make decisions on
95 if [ -r /etc/SuSE-release ]; then
96 sles_version=$(sles_version_code)
97 [ $sles_version -lt $(version_code 11.4.0) ] &&
98 always_except LU-4341 170
100 [ $sles_version -lt $(version_code 12.0.0) ] &&
101 always_except LU-3703 234
102 elif [ -r /etc/os-release ]; then
103 if grep -qi ubuntu /etc/os-release; then
104 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
105 -e 's/^VERSION=//p' \
109 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
110 always_except LU-10366 410
120 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
121 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
130 check_swap_layouts_support()
132 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
133 skip "Does not support layout lock."
136 check_swap_layout_no_dom()
139 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
140 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
143 check_and_setup_lustre
147 MAXFREE=${MAXFREE:-$((300000 * $OSTCOUNT))}
149 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
150 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
151 rm -rf $DIR/[Rdfs][0-9]*
153 # $RUNAS_ID may get set incorrectly somewhere else
154 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
155 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
157 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
159 if [ "${ONLY}" = "MOUNT" ] ; then
160 echo "Lustre is up, please go on"
164 echo "preparing for tests involving mounts"
165 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
167 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
168 echo # add a newline after mke2fs.
172 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
173 lctl set_param debug=-1 2> /dev/null || true
176 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
178 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
180 run_test 0a "touch; rm ====================="
183 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
184 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
186 run_test 0b "chmod 0755 $DIR ============================="
189 $LCTL get_param mdc.*.import | grep "state: FULL" ||
190 error "import not FULL"
191 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
194 run_test 0c "check import proc"
196 test_0d() { # LU-3397
197 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
198 skip "proc exports not supported before 2.10.57"
200 local mgs_exp="mgs.MGS.exports"
201 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
203 local exp_client_version
206 local temp_imp=$DIR/$tfile.import
207 local temp_exp=$DIR/$tfile.export
209 # save mgc import file to $temp_imp
210 $LCTL get_param mgc.*.import | tee $temp_imp
211 # Check if client uuid is found in MGS export
212 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
213 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
217 # save mgs export file to $temp_exp
218 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
220 # Compare the value of field "connect_flags"
221 imp_val=$(grep "connect_flags" $temp_imp)
222 exp_val=$(grep "connect_flags" $temp_exp)
223 [ "$exp_val" == "$imp_val" ] ||
224 error "export flags '$exp_val' != import flags '$imp_val'"
226 # Compare client versions. Only compare top-3 fields for compatibility
227 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
228 exp_val=$(version_code $(cut -d. -f1,2,3 <<<$exp_client_version))
229 imp_val=$(version_code $(lustre_build_version client | cut -d. -f1,2,3))
230 [ "$exp_val" == "$imp_val" ] ||
231 error "exp version '$exp_client_version'($exp_val) != " \
232 "'$(lustre_build_version client)'($imp_val)"
234 run_test 0d "check export proc ============================="
236 test_0e() { # LU-13417
237 (( $MDSCOUNT > 1 )) ||
238 skip "We need at least 2 MDTs for this test"
240 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
241 skip "Need server version at least 2.14.51"
243 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
244 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
246 [ $default_lmv_count -eq 1 ] ||
247 error "$MOUNT default stripe count $default_lmv_count"
249 [ $default_lmv_index -eq -1 ] ||
250 error "$MOUNT default stripe index $default_lmv_index"
252 mkdir $MOUNT/$tdir.1 || error "mkdir $MOUNT/$tdir.1 failed"
253 mkdir $MOUNT/$tdir.2 || error "mkdir $MOUNT/$tdir.2 failed"
255 local mdt_index1=$($LFS getdirstripe -i $MOUNT/$tdir.1)
256 local mdt_index2=$($LFS getdirstripe -i $MOUNT/$tdir.2)
258 [ $mdt_index1 -eq $mdt_index2 ] &&
259 error "directories are on the same MDT $mdt_index1=$mdt_index2"
261 rmdir $MOUNT/$tdir.1 $MOUNT/$tdir.2
263 run_test 0e "Enable DNE MDT balancing for mkdir in the ROOT"
266 test_mkdir $DIR/$tdir
267 test_mkdir $DIR/$tdir/d2
268 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
269 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
272 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
274 run_test 1 "mkdir; remkdir; rmdir"
277 test_mkdir $DIR/$tdir
278 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
279 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
281 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
283 run_test 2 "mkdir; touch; rmdir; check file"
286 test_mkdir $DIR/$tdir
287 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
288 touch $DIR/$tdir/$tfile
289 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
291 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
293 run_test 3 "mkdir; touch; rmdir; check dir"
295 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
297 test_mkdir -i 1 $DIR/$tdir
299 touch $DIR/$tdir/$tfile ||
300 error "Create file under remote directory failed"
303 error "Expect error removing in-use dir $DIR/$tdir"
305 test -d $DIR/$tdir || error "Remote directory disappeared"
307 rm -rf $DIR/$tdir || error "remove remote dir error"
309 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
312 test_mkdir $DIR/$tdir
313 test_mkdir $DIR/$tdir/d2
314 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
315 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
316 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
318 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
321 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
322 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
323 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
324 error "$tfile does not have perm 0666 or UID $UID"
325 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
326 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
327 error "$tfile should be 0666 and owned by UID $UID"
329 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
332 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
335 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
336 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
337 error "$tfile should be owned by UID $RUNAS_ID"
338 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
339 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
340 error "$tfile should be owned by UID $RUNAS_ID"
342 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
345 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
348 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
349 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
350 error "$tfile should be owned by GID $UID"
351 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
352 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
353 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
355 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
358 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
360 test_mkdir $DIR/$tdir
361 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
362 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
363 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
364 test_mkdir $DIR/$tdir/d/subdir
365 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
366 error "$tdir/d/subdir should be GID $RUNAS_GID"
367 if [[ $MDSCOUNT -gt 1 ]]; then
368 # check remote dir sgid inherite
369 $LFS mkdir -i 0 $DIR/$tdir.local ||
370 error "mkdir $tdir.local failed"
371 chmod g+s $DIR/$tdir.local ||
372 error "chmod $tdir.local failed"
373 chgrp $RUNAS_GID $DIR/$tdir.local ||
374 error "chgrp $tdir.local failed"
375 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
376 error "mkdir $tdir.remote failed"
377 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
378 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
379 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
380 error "$tdir.remote should be mode 02755"
383 run_test 6g "verify new dir in sgid dir inherits group"
385 test_6h() { # bug 7331
386 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
388 touch $DIR/$tfile || error "touch failed"
389 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
390 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
391 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
392 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
393 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
395 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
398 test_mkdir $DIR/$tdir
399 $MCREATE $DIR/$tdir/$tfile
400 chmod 0666 $DIR/$tdir/$tfile
401 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
402 error "$tdir/$tfile should be mode 0666"
404 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
407 if [ ! -d $DIR/$tdir ]; then
408 test_mkdir $DIR/$tdir
410 $MCREATE $DIR/$tdir/$tfile
411 echo -n foo > $DIR/$tdir/$tfile
412 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
413 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
415 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
418 test_mkdir $DIR/$tdir
419 touch $DIR/$tdir/$tfile
420 chmod 0666 $DIR/$tdir/$tfile
421 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
422 error "$tfile mode not 0666"
424 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
427 test_mkdir $DIR/$tdir
428 test_mkdir $DIR/$tdir/d2
429 test_mkdir $DIR/$tdir/d2/d3
430 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
432 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
435 test_mkdir $DIR/$tdir
436 test_mkdir $DIR/$tdir/d2
437 touch $DIR/$tdir/d2/$tfile
438 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
439 error "$tdir/d2/$tfile not a file"
441 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
444 test_mkdir $DIR/$tdir
445 test_mkdir $DIR/$tdir/d2
446 chmod 0666 $DIR/$tdir/d2
447 chmod 0705 $DIR/$tdir/d2
448 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
449 error "$tdir/d2 mode not 0705"
451 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
454 test_mkdir $DIR/$tdir
455 touch $DIR/$tdir/$tfile
456 chmod 0666 $DIR/$tdir/$tfile
457 chmod 0654 $DIR/$tdir/$tfile
458 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
459 error "$tdir/d2 mode not 0654"
461 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
464 test_mkdir $DIR/$tdir
465 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
467 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
468 error "$tdir/$tfile size not 0 after truncate"
470 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
473 test_mkdir $DIR/$tdir
474 touch $DIR/$tdir/$tfile
476 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
478 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
481 test_mkdir $DIR/$tdir
482 touch $DIR/$tdir/$tfile
483 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
484 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
485 error "$tdir/${tfile_2} not a file after rename"
486 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
488 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
491 test_mkdir $DIR/$tdir
492 touch $DIR/$tdir/$tfile
493 rm -rf $DIR/$tdir/$tfile
494 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
496 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
499 test_mkdir $DIR/$tdir
500 touch $DIR/$tdir/$tfile
501 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
503 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
504 error "$tdir/l-exist not a symlink"
505 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
506 error "$tdir/l-exist not referencing a file"
507 rm -f $DIR/$tdir/l-exist
508 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
510 run_test 17a "symlinks: create, remove (real)"
513 test_mkdir $DIR/$tdir
514 ln -s no-such-file $DIR/$tdir/l-dangle
516 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
517 error "$tdir/l-dangle not referencing no-such-file"
518 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
519 error "$tdir/l-dangle not referencing non-existent file"
520 rm -f $DIR/$tdir/l-dangle
521 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
523 run_test 17b "symlinks: create, remove (dangling)"
525 test_17c() { # bug 3440 - don't save failed open RPC for replay
526 test_mkdir $DIR/$tdir
527 ln -s foo $DIR/$tdir/$tfile
528 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
530 run_test 17c "symlinks: open dangling (should return error)"
533 test_mkdir $DIR/$tdir
534 ln -s foo $DIR/$tdir/$tfile
535 touch $DIR/$tdir/$tfile || error "creating to new symlink"
537 run_test 17d "symlinks: create dangling"
540 test_mkdir $DIR/$tdir
541 local foo=$DIR/$tdir/$tfile
542 ln -s $foo $foo || error "create symlink failed"
543 ls -l $foo || error "ls -l failed"
544 ls $foo && error "ls not failed" || true
546 run_test 17e "symlinks: create recursive symlink (should return error)"
549 test_mkdir $DIR/$tdir
550 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
551 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
552 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
553 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
554 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
555 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
558 run_test 17f "symlinks: long and very long symlink name"
560 # str_repeat(S, N) generate a string that is string S repeated N times
565 while [ $((n -= 1)) -ge 0 ]; do
571 # Long symlinks and LU-2241
573 test_mkdir $DIR/$tdir
574 local TESTS="59 60 61 4094 4095"
576 # Fix for inode size boundary in 2.1.4
577 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
580 # Patch not applied to 2.2 or 2.3 branches
581 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
582 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
586 local SYMNAME=$(str_repeat 'x' $i)
587 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
588 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
591 run_test 17g "symlinks: really long symlink name and inode boundaries"
593 test_17h() { #bug 17378
594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
595 remote_mds_nodsh && skip "remote MDS with nodsh"
599 test_mkdir $DIR/$tdir
600 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
601 $LFS setstripe -c -1 $DIR/$tdir
602 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
603 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
604 touch $DIR/$tdir/$tfile || true
606 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
608 test_17i() { #bug 20018
609 [ $PARALLEL == "yes" ] && skip "skip parallel run"
610 remote_mds_nodsh && skip "remote MDS with nodsh"
612 local foo=$DIR/$tdir/$tfile
615 test_mkdir -c1 $DIR/$tdir
616 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
617 ln -s $foo $foo || error "create symlink failed"
618 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
619 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
620 ls -l $foo && error "error not detected"
623 run_test 17i "don't panic on short symlink (should return error)"
625 test_17k() { #bug 22301
626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
627 [[ -z "$(which rsync 2>/dev/null)" ]] &&
628 skip "no rsync command"
629 rsync --help | grep -q xattr ||
630 skip_env "$(rsync --version | head -n1) does not support xattrs"
631 test_mkdir $DIR/$tdir
632 test_mkdir $DIR/$tdir.new
633 touch $DIR/$tdir/$tfile
634 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
635 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
636 error "rsync failed with xattrs enabled"
638 run_test 17k "symlinks: rsync with xattrs enabled"
640 test_17l() { # LU-279
641 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
642 skip "no getfattr command"
644 test_mkdir $DIR/$tdir
645 touch $DIR/$tdir/$tfile
646 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
647 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
648 # -h to not follow symlinks. -m '' to list all the xattrs.
649 # grep to remove first line: '# file: $path'.
650 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
652 lgetxattr_size_check $path $xattr ||
653 error "lgetxattr_size_check $path $xattr failed"
657 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
662 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
663 remote_mds_nodsh && skip "remote MDS with nodsh"
664 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
665 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
666 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
668 local short_sym="0123456789"
669 local wdir=$DIR/$tdir
674 # create a long symlink file
675 for ((i = 0; i < 4; ++i)); do
676 long_sym=${long_sym}${long_sym}
679 echo "create 512 short and long symlink files under $wdir"
680 for ((i = 0; i < 256; ++i)); do
681 ln -sf ${long_sym}"a5a5" $wdir/long-$i
682 ln -sf ${short_sym}"a5a5" $wdir/short-$i
688 wait_delete_completed
690 echo "recreate the 512 symlink files with a shorter string"
691 for ((i = 0; i < 512; ++i)); do
692 # rewrite the symlink file with a shorter string
693 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
694 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
697 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
699 echo "stop and checking mds${mds_index}:"
700 # e2fsck should not return error
702 local devname=$(mdsdevname $mds_index)
703 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
706 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
707 error "start mds${mds_index} failed"
708 df $MOUNT > /dev/null 2>&1
710 error "e2fsck detected error for short/long symlink: rc=$rc"
713 run_test 17m "run e2fsck against MDT which contains short/long symlink"
715 check_fs_consistency_17n() {
719 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
720 # so it only check MDT1/MDT2 instead of all of MDTs.
721 for mdt_index in 1 2; do
722 # e2fsck should not return error
724 local devname=$(mdsdevname $mdt_index)
725 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
728 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
729 error "mount mds$mdt_index failed"
730 df $MOUNT > /dev/null 2>&1
736 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
737 [ $PARALLEL == "yes" ] && skip "skip parallel run"
738 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
739 remote_mds_nodsh && skip "remote MDS with nodsh"
740 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
741 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
742 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
746 test_mkdir $DIR/$tdir
747 for ((i=0; i<10; i++)); do
748 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
749 error "create remote dir error $i"
750 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
751 error "create files under remote dir failed $i"
754 check_fs_consistency_17n ||
755 error "e2fsck report error after create files under remote dir"
757 for ((i = 0; i < 10; i++)); do
758 rm -rf $DIR/$tdir/remote_dir_${i} ||
759 error "destroy remote dir error $i"
762 check_fs_consistency_17n ||
763 error "e2fsck report error after unlink files under remote dir"
765 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
766 skip "lustre < 2.4.50 does not support migrate mv"
768 for ((i = 0; i < 10; i++)); do
769 mkdir -p $DIR/$tdir/remote_dir_${i}
770 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
771 error "create files under remote dir failed $i"
772 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
773 error "migrate remote dir error $i"
775 check_fs_consistency_17n || error "e2fsck report error after migration"
777 for ((i = 0; i < 10; i++)); do
778 rm -rf $DIR/$tdir/remote_dir_${i} ||
779 error "destroy remote dir error $i"
782 check_fs_consistency_17n || error "e2fsck report error after unlink"
784 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
787 remote_mds_nodsh && skip "remote MDS with nodsh"
788 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
789 skip "Need MDS version at least 2.3.64"
791 local wdir=$DIR/${tdir}o
797 mdt_index=$($LFS getstripe -m $wdir/$tfile)
798 mdt_index=$((mdt_index + 1))
801 #fail mds will wait the failover finish then set
802 #following fail_loc to avoid interfer the recovery process.
805 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
806 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
807 ls -l $wdir/$tfile && rc=1
808 do_facet mds${mdt_index} lctl set_param fail_loc=0
809 [[ $rc -eq 0 ]] || error "stat file should fail"
811 run_test 17o "stat file with incompat LMA feature"
814 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
815 ls $DIR || error "Failed to ls $DIR: $?"
817 run_test 18 "touch .../f ; ls ... =============================="
823 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
825 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
828 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
830 run_test 19b "ls -l .../f19 (should return error) =============="
833 [ $RUNAS_ID -eq $UID ] &&
834 skip_env "RUNAS_ID = UID = $UID -- skipping"
836 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
838 run_test 19c "$RUNAS touch .../f19 (should return error) =="
841 cat $DIR/f19 && error || true
843 run_test 19d "cat .../f19 (should return error) =============="
852 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
854 run_test 20 "touch .../f ; ls -l ..."
857 test_mkdir $DIR/$tdir
858 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
859 ln -s dangle $DIR/$tdir/link
860 echo foo >> $DIR/$tdir/link
861 cat $DIR/$tdir/dangle
862 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
863 $CHECKSTAT -f -t file $DIR/$tdir/link ||
864 error "$tdir/link not linked to a file"
866 run_test 21 "write to dangling link"
869 local wdir=$DIR/$tdir
871 chown $RUNAS_ID:$RUNAS_GID $wdir
872 (cd $wdir || error "cd $wdir failed";
873 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
875 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
876 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
877 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
878 error "checkstat -u failed"
880 run_test 22 "unpack tar archive as non-root user"
884 test_mkdir $DIR/$tdir
885 local file=$DIR/$tdir/$tfile
887 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
888 openfile -f O_CREAT:O_EXCL $file &&
889 error "$file recreate succeeded" || true
891 run_test 23a "O_CREAT|O_EXCL in subdir"
893 test_23b() { # bug 18988
894 test_mkdir $DIR/$tdir
895 local file=$DIR/$tdir/$tfile
898 echo foo > $file || error "write filed"
899 echo bar >> $file || error "append filed"
900 $CHECKSTAT -s 8 $file || error "wrong size"
903 run_test 23b "O_APPEND check"
905 # LU-9409, size with O_APPEND and tiny writes
907 local file=$DIR/$tfile
910 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
911 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
915 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
916 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
918 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
921 #racing tiny & normal writes
922 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
923 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
925 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
928 #racing tiny & normal writes 2, ugly numbers
929 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
930 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
932 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
935 run_test 23c "O_APPEND size checks for tiny writes"
937 # LU-11069 file offset is correct after appending writes
939 local file=$DIR/$tfile
942 echo CentaurHauls > $file
943 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
944 if ((offset != 26)); then
945 error "wrong offset, expected 26, got '$offset'"
948 run_test 23d "file offset is correct after appending writes"
952 echo '-- same directory rename'
953 test_mkdir $DIR/$tdir
954 touch $DIR/$tdir/$tfile.1
955 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
956 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
958 run_test 24a "rename file to non-existent target"
961 test_mkdir $DIR/$tdir
962 touch $DIR/$tdir/$tfile.{1,2}
963 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
964 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
965 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
967 run_test 24b "rename file to existing target"
970 test_mkdir $DIR/$tdir
971 test_mkdir $DIR/$tdir/d$testnum.1
972 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
973 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
974 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
976 run_test 24c "rename directory to non-existent target"
979 test_mkdir -c1 $DIR/$tdir
980 test_mkdir -c1 $DIR/$tdir/d$testnum.1
981 test_mkdir -c1 $DIR/$tdir/d$testnum.2
982 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
983 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
984 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
986 run_test 24d "rename directory to existing target"
989 echo '-- cross directory renames --'
993 mv $DIR/R5a/f $DIR/R5b/g
994 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
995 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
997 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
1002 touch $DIR/R6a/f $DIR/R6b/g
1003 mv $DIR/R6a/f $DIR/R6b/g
1004 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
1005 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
1007 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
1012 test_mkdir $DIR/R7a/d
1013 mv $DIR/R7a/d $DIR/R7b/e
1014 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
1015 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
1017 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1020 test_mkdir -c1 $DIR/R8a
1021 test_mkdir -c1 $DIR/R8b
1022 test_mkdir -c1 $DIR/R8a/d
1023 test_mkdir -c1 $DIR/R8b/e
1024 mrename $DIR/R8a/d $DIR/R8b/e
1025 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1026 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1028 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1031 echo "-- rename error cases"
1033 test_mkdir $DIR/R9/a
1035 mrename $DIR/R9/f $DIR/R9/a
1036 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1037 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1038 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1040 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1044 mrename $DIR/R10/f $DIR/R10/g
1045 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1046 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1047 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1049 run_test 24j "source does not exist ============================"
1052 test_mkdir $DIR/R11a
1053 test_mkdir $DIR/R11a/d
1055 mv $DIR/R11a/f $DIR/R11a/d
1056 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1057 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1059 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1061 # bug 2429 - rename foo foo foo creates invalid file
1064 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1066 run_test 24l "Renaming a file to itself ========================"
1070 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1071 # on ext3 this does not remove either the source or target files
1072 # though the "expected" operation would be to remove the source
1073 $CHECKSTAT -t file ${f} || error "${f} missing"
1074 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1076 run_test 24m "Renaming a file to a hard link to itself ========="
1080 # this stats the old file after it was renamed, so it should fail
1082 $CHECKSTAT ${f} || error "${f} missing"
1084 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1085 $CHECKSTAT -a ${f} || error "${f} exists"
1087 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1090 test_mkdir $DIR/$tdir
1091 rename_many -s random -v -n 10 $DIR/$tdir
1093 run_test 24o "rename of files during htree split"
1096 test_mkdir $DIR/R12a
1097 test_mkdir $DIR/R12b
1098 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1099 mrename $DIR/R12a $DIR/R12b
1100 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1101 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1102 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1103 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1105 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1107 cleanup_multiop_pause() {
1109 kill -USR1 $MULTIPID
1113 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1115 test_mkdir $DIR/R13a
1116 test_mkdir $DIR/R13b
1117 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1118 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1121 trap cleanup_multiop_pause EXIT
1122 mrename $DIR/R13a $DIR/R13b
1123 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1124 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1125 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1126 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1127 cleanup_multiop_pause
1128 wait $MULTIPID || error "multiop close failed"
1130 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1132 test_24r() { #bug 3789
1133 test_mkdir $DIR/R14a
1134 test_mkdir $DIR/R14a/b
1135 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1136 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1137 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1139 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1142 test_mkdir $DIR/R15a
1143 test_mkdir $DIR/R15a/b
1144 test_mkdir $DIR/R15a/b/c
1145 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1146 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1147 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1149 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1151 test_mkdir $DIR/R16a
1152 test_mkdir $DIR/R16a/b
1153 test_mkdir $DIR/R16a/b/c
1154 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1155 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1156 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1158 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1160 test_24u() { # bug12192
1161 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1162 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1164 run_test 24u "create stripe file"
1166 simple_cleanup_common() {
1170 [[ -z "$DIR" || -z "$tdir" || ! -d "$DIR/$tdir" ]] && return 0
1172 local start=$SECONDS
1174 [[ -n "$createmany" ]] && unlinkmany $DIR/$tdir/$tfile $createmany
1175 rm -rf $DIR/$tdir || error "cleanup $DIR/$tdir failed"
1177 wait_delete_completed
1178 echo "cleanup time $((SECONDS - start))"
1182 max_pages_per_rpc() {
1183 local mdtname="$(printf "MDT%04x" ${1:-0})"
1184 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1190 local nrfiles=${COUNT:-100000}
1191 local fname="$DIR/$tdir/$tfile"
1193 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1194 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1196 test_mkdir "$(dirname $fname)"
1197 # assume MDT0000 has the fewest inodes
1198 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1199 local free_inodes=$(($(mdt_free_inodes 0) * ${stripes/#0/1}))
1200 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1202 stack_trap "simple_cleanup_common $nrfiles"
1204 createmany -m "$fname" $nrfiles
1206 cancel_lru_locks mdc
1207 lctl set_param mdc.*.stats clear
1209 # was previously test_24D: LU-6101
1210 # readdir() returns correct number of entries after cursor reload
1211 local num_ls=$(ls $DIR/$tdir | wc -l)
1212 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1213 local num_all=$(ls -a $DIR/$tdir | wc -l)
1214 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1215 [ $num_all -ne $((nrfiles + 2)) ]; then
1216 error "Expected $nrfiles files, got $num_ls " \
1217 "($num_uniq unique $num_all .&..)"
1219 # LU-5 large readdir
1220 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1221 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1222 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1223 # take into account of overhead in lu_dirpage header and end mark in
1224 # each page, plus one in rpc_num calculation.
1225 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1226 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1227 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1228 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1229 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1230 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1231 echo "readpages: $mds_readpage rpc_max: $rpc_max-2/+1"
1232 (( $mds_readpage >= $rpc_max - 2 && $mds_readpage <= $rpc_max + 1)) ||
1233 error "large readdir doesn't take effect: " \
1234 "$mds_readpage should be about $rpc_max"
1236 run_test 24v "list large directory (test hash collision, b=17560)"
1238 test_24w() { # bug21506
1240 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1241 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1242 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1243 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1244 [[ "$SZ1" -eq "$SZ2" ]] ||
1245 error "Error reading at the end of the file $tfile"
1247 run_test 24w "Reading a file larger than 4Gb"
1250 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1251 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1252 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1253 skip "Need MDS version at least 2.7.56"
1256 local remote_dir=$DIR/$tdir/remote_dir
1258 test_mkdir $DIR/$tdir
1259 $LFS mkdir -i $MDTIDX $remote_dir ||
1260 error "create remote directory failed"
1262 test_mkdir $DIR/$tdir/src_dir
1263 touch $DIR/$tdir/src_file
1264 test_mkdir $remote_dir/tgt_dir
1265 touch $remote_dir/tgt_file
1267 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1268 error "rename dir cross MDT failed!"
1270 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1271 error "rename file cross MDT failed!"
1273 touch $DIR/$tdir/ln_file
1274 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1275 error "ln file cross MDT failed"
1277 rm -rf $DIR/$tdir || error "Can not delete directories"
1279 run_test 24x "cross MDT rename/link"
1282 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1283 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1285 local remote_dir=$DIR/$tdir/remote_dir
1288 test_mkdir $DIR/$tdir
1289 $LFS mkdir -i $mdtidx $remote_dir ||
1290 error "create remote directory failed"
1292 test_mkdir $remote_dir/src_dir
1293 touch $remote_dir/src_file
1294 test_mkdir $remote_dir/tgt_dir
1295 touch $remote_dir/tgt_file
1297 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1298 error "rename subdir in the same remote dir failed!"
1300 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1301 error "rename files in the same remote dir failed!"
1303 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1304 error "link files in the same remote dir failed!"
1306 rm -rf $DIR/$tdir || error "Can not delete directories"
1308 run_test 24y "rename/link on the same dir should succeed"
1311 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1312 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1313 skip "Need MDS version at least 2.12.51"
1317 for index in 0 1; do
1318 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1319 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1322 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1324 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1325 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1327 local mdts=$(comma_list $(mdts_nodes))
1329 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1330 stack_trap "do_nodes $mdts $LCTL \
1331 set_param mdt.*.enable_remote_rename=1" EXIT
1333 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1335 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1336 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1338 run_test 24z "cross-MDT rename is done as cp"
1340 test_24A() { # LU-3182
1343 test_mkdir $DIR/$tdir
1344 stack_trap "simple_cleanup_common $NFILES"
1345 createmany -m $DIR/$tdir/$tfile $NFILES
1346 local t=$(ls $DIR/$tdir | wc -l)
1347 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1348 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1350 (( $t == $NFILES && $u == $NFILES && $v == NFILES + 2 )) ||
1351 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1353 run_test 24A "readdir() returns correct number of entries."
1355 test_24B() { # LU-4805
1356 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1360 test_mkdir $DIR/$tdir
1361 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1362 error "create striped dir failed"
1364 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1365 [ $count -eq 2 ] || error "Expected 2, got $count"
1367 touch $DIR/$tdir/striped_dir/a
1369 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1370 [ $count -eq 3 ] || error "Expected 3, got $count"
1372 touch $DIR/$tdir/striped_dir/.f
1374 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1375 [ $count -eq 4 ] || error "Expected 4, got $count"
1377 rm -rf $DIR/$tdir || error "Can not delete directories"
1379 run_test 24B "readdir for striped dir return correct number of entries"
1382 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1388 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1389 error "create striped dir failed"
1391 cd $DIR/$tdir/d0/striped_dir
1393 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1394 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1395 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1397 [ "$d0_ino" = "$parent_ino" ] ||
1398 error ".. wrong, expect $d0_ino, get $parent_ino"
1400 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1401 error "mv striped dir failed"
1403 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1405 [ "$d1_ino" = "$parent_ino" ] ||
1406 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1408 run_test 24C "check .. in striped dir"
1411 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1412 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1415 mkdir $DIR/$tdir/src_dir
1416 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1417 error "create remote source failed"
1419 touch $DIR/$tdir/src_dir/src_child/a
1421 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1422 error "create remote target dir failed"
1424 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1425 error "create remote target child failed"
1427 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1428 error "rename dir cross MDT failed!"
1432 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1433 error "src_child still exists after rename"
1435 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1436 error "missing file(a) after rename"
1438 rm -rf $DIR/$tdir || error "Can not delete directories"
1440 run_test 24E "cross MDT rename/link"
1443 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1446 [ "$SLOW" = "no" ] && repeats=100
1450 echo "$repeats repeats"
1451 for ((i = 0; i < repeats; i++)); do
1452 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1453 touch $DIR/$tdir/test/a || error "touch fails"
1454 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1455 rm -rf $DIR/$tdir/test || error "rmdir fails"
1460 run_test 24F "hash order vs readdir (LU-11330)"
1463 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1468 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1469 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1470 touch $DIR/$tdir-0/f1 || error "touch f1"
1471 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1472 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1473 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1474 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1475 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1477 run_test 24G "migrate symlink in rename"
1480 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1481 [[ $(hostname) != $(facet_active_host mds2) ]] ||
1482 skip "MDT1 should be on another node"
1484 test_mkdir -i 1 -c 1 $DIR/$tdir
1485 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
1486 do_facet mds2 $LCTL set_param fail_loc=0x80001103
1487 touch $DIR/$tdir/$tfile || error "touch failed"
1489 run_test 24H "repeat FLD_QUERY rpc"
1492 echo '== symlink sanity ============================================='
1496 touch $DIR/s25/foo ||
1497 error "File creation in symlinked directory failed"
1499 run_test 25a "create file in symlinked directory ==============="
1502 [ ! -d $DIR/d25 ] && test_25a
1503 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1505 run_test 25b "lookup file in symlinked directory ==============="
1509 test_mkdir $DIR/d26/d26-2
1510 ln -s d26/d26-2 $DIR/s26
1511 touch $DIR/s26/foo || error "File creation failed"
1513 run_test 26a "multiple component symlink ======================="
1516 test_mkdir -p $DIR/$tdir/d26-2
1517 ln -s $tdir/d26-2/foo $DIR/s26-2
1518 touch $DIR/s26-2 || error "File creation failed"
1520 run_test 26b "multiple component symlink at end of lookup ======"
1523 test_mkdir $DIR/d26.2
1524 touch $DIR/d26.2/foo
1525 ln -s d26.2 $DIR/s26.2-1
1526 ln -s s26.2-1 $DIR/s26.2-2
1527 ln -s s26.2-2 $DIR/s26.2-3
1528 chmod 0666 $DIR/s26.2-3/foo
1530 run_test 26c "chain of symlinks"
1532 # recursive symlinks (bug 439)
1534 ln -s d26-3/foo $DIR/d26-3
1536 run_test 26d "create multiple component recursive symlink"
1539 [ ! -h $DIR/d26-3 ] && test_26d
1542 run_test 26e "unlink multiple component recursive symlink"
1544 # recursive symlinks (bug 7022)
1546 test_mkdir $DIR/$tdir
1547 test_mkdir $DIR/$tdir/$tfile
1548 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1549 test_mkdir -p lndir/bar1
1550 test_mkdir $DIR/$tdir/$tfile/$tfile
1551 cd $tfile || error "cd $tfile failed"
1552 ln -s .. dotdot || error "ln dotdot failed"
1553 ln -s dotdot/lndir lndir || error "ln lndir failed"
1554 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1555 output=`ls $tfile/$tfile/lndir/bar1`
1556 [ "$output" = bar1 ] && error "unexpected output"
1557 rm -r $tfile || error "rm $tfile failed"
1558 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1560 run_test 26f "rm -r of a directory which has recursive symlink"
1563 test_mkdir $DIR/$tdir
1564 $LFS getstripe $DIR/$tdir
1565 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1566 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1567 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1569 run_test 27a "one stripe file"
1572 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1574 test_mkdir $DIR/$tdir
1575 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1576 $LFS getstripe -c $DIR/$tdir/$tfile
1577 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1578 error "two-stripe file doesn't have two stripes"
1580 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1582 run_test 27b "create and write to two stripe file"
1584 # 27c family tests specific striping, setstripe -o
1586 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1587 test_mkdir -p $DIR/$tdir
1590 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1591 $LFS getstripe -i $DIR/$tdir/$tfile
1592 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1593 error "stripe not on specified OST"
1595 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1597 run_test 27ca "one stripe on specified OST"
1600 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1601 test_mkdir -p $DIR/$tdir
1603 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1604 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1607 # Strip getstripe output to a space separated list of OSTs
1608 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1609 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1610 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1611 error "stripes not on specified OSTs"
1613 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1615 run_test 27cb "two stripes on specified OSTs"
1618 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1619 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1620 skip "server does not support overstriping"
1622 test_mkdir -p $DIR/$tdir
1624 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1625 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1628 # Strip getstripe output to a space separated list of OSTs
1629 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1630 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1631 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1632 error "stripes not on specified OSTs"
1634 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1636 run_test 27cc "two stripes on the same OST"
1639 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1640 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1641 skip "server does not support overstriping"
1642 test_mkdir -p $DIR/$tdir
1643 local osts="0,1,1,0"
1644 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1645 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1648 # Strip getstripe output to a space separated list of OSTs
1649 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1650 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1651 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1652 error "stripes not on specified OSTs"
1654 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1656 run_test 27cd "four stripes on two OSTs"
1659 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1660 skip_env "too many osts, skipping"
1661 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1662 skip "server does not support overstriping"
1663 # We do one more stripe than we have OSTs
1664 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1665 skip_env "ea_inode feature disabled"
1667 test_mkdir -p $DIR/$tdir
1669 for i in $(seq 0 $OSTCOUNT);
1672 if [ $i -ne $OSTCOUNT ]; then
1676 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1677 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1680 # Strip getstripe output to a space separated list of OSTs
1681 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1682 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1683 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1684 error "stripes not on specified OSTs"
1686 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1688 run_test 27ce "more stripes than OSTs with -o"
1691 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1694 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1695 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1696 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1697 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1698 error "failed to set $osp_proc=0"
1700 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1703 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1704 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1705 error "failed to set $osp_proc=1"
1708 error "should return error due to $osp_proc=0"
1710 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1713 test_mkdir $DIR/$tdir
1714 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1715 error "setstripe failed"
1716 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1717 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1719 run_test 27d "create file with default settings"
1722 # LU-5839 adds check for existed layout before setting it
1723 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1724 skip "Need MDS version at least 2.7.56"
1726 test_mkdir $DIR/$tdir
1727 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1728 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1729 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1731 run_test 27e "setstripe existing file (should return error)"
1734 test_mkdir $DIR/$tdir
1735 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1736 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1737 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1738 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1739 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1740 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1742 run_test 27f "setstripe with bad stripe size (should return error)"
1745 test_mkdir $DIR/$tdir
1746 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1747 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1748 error "$DIR/$tdir/$tfile has object"
1750 run_test 27g "$LFS getstripe with no objects"
1753 test_mkdir $DIR/$tdir
1754 touch $DIR/$tdir/$tfile || error "touch failed"
1755 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1756 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1758 (( rc == 2 )) || error "getstripe did not return ENOENT"
1760 run_test 27ga "$LFS getstripe with missing file (should return error)"
1763 test_mkdir $DIR/$tdir
1764 touch $DIR/$tdir/$tfile || error "touch failed"
1765 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1766 error "missing objects"
1768 run_test 27i "$LFS getstripe with some objects"
1771 test_mkdir $DIR/$tdir
1772 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1773 error "setstripe failed" || true
1775 run_test 27j "setstripe with bad stripe offset (should return error)"
1777 test_27k() { # bug 2844
1778 test_mkdir $DIR/$tdir
1779 local file=$DIR/$tdir/$tfile
1780 local ll_max_blksize=$((4 * 1024 * 1024))
1781 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1782 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1783 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1784 dd if=/dev/zero of=$file bs=4k count=1
1785 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1786 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1788 run_test 27k "limit i_blksize for broken user apps"
1791 mcreate $DIR/$tfile || error "creating file"
1792 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1793 error "setstripe should have failed" || true
1795 run_test 27l "check setstripe permissions (should return error)"
1798 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1800 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1801 skip_env "multiple clients -- skipping"
1803 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1805 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1806 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1808 stack_trap simple_cleanup_common
1809 test_mkdir $DIR/$tdir
1810 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1811 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1812 error "dd should fill OST0"
1814 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1816 [ $i -gt 256 ] && break
1819 touch $DIR/$tdir/$tfile.$i
1820 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1821 awk '{print $1}'| grep -w "0") ] &&
1822 error "OST0 was full but new created file still use it"
1824 touch $DIR/$tdir/$tfile.$i
1825 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1826 awk '{print $1}'| grep -w "0") ] &&
1827 error "OST0 was full but new created file still use it" || true
1829 run_test 27m "create file while OST0 was full"
1831 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1832 # if the OST isn't full anymore.
1834 local ostidx=${1:-""}
1839 local list=$(comma_list $(osts_nodes))
1840 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1842 do_nodes $list lctl set_param fail_loc=0
1843 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1844 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1845 awk '{print $1 * 2;exit;}')
1846 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1848 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1852 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1854 remote_mds_nodsh && skip "remote MDS with nodsh"
1855 remote_ost_nodsh && skip "remote OST with nodsh"
1858 rm -f $DIR/$tdir/$tfile
1859 exhaust_precreations 0 0x80000215
1860 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1861 touch $DIR/$tdir/$tfile || error "touch failed"
1862 $LFS getstripe $DIR/$tdir/$tfile
1865 run_test 27n "create file with some full OSTs"
1868 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1870 remote_mds_nodsh && skip "remote MDS with nodsh"
1871 remote_ost_nodsh && skip "remote OST with nodsh"
1874 rm -f $DIR/$tdir/$tfile
1875 exhaust_all_precreations 0x215
1877 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1882 run_test 27o "create file with all full OSTs (should error)"
1884 function create_and_checktime() {
1889 for ((i=0; i < $loops; i++)); do
1890 local start=$SECONDS
1891 multiop $fname-$i Oc
1892 ((SECONDS-start < TIMEOUT)) ||
1893 error "creation took " $((SECONDS-$start)) && return 1
1898 local mdts=$(comma_list $(mdts_nodes))
1900 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1901 skip "Need MDS version at least 2.13.57"
1903 local f0=$DIR/${tfile}-0
1904 local f1=$DIR/${tfile}-1
1906 wait_delete_completed
1908 # refill precreated objects
1909 $LFS setstripe -i0 -c1 $f0
1911 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1912 # force QoS allocation policy
1913 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1914 stack_trap "do_nodes $mdts $LCTL set_param \
1915 lov.*.qos_threshold_rr=$saved" EXIT
1918 # one OST is unavailable, but still have few objects preallocated
1920 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1921 rm -rf $f1 $DIR/$tdir*" EXIT
1923 for ((i=0; i < 7; i++)); do
1924 mkdir $DIR/$tdir$i || error "can't create dir"
1925 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1926 error "can't set striping"
1928 for ((i=0; i < 7; i++)); do
1929 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1933 run_test 27oo "don't let few threads to reserve too many objects"
1936 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1937 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1938 remote_mds_nodsh && skip "remote MDS with nodsh"
1939 remote_ost_nodsh && skip "remote OST with nodsh"
1942 rm -f $DIR/$tdir/$tfile
1943 test_mkdir $DIR/$tdir
1945 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1946 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1947 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1949 exhaust_precreations 0 0x80000215
1950 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1951 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1952 $LFS getstripe $DIR/$tdir/$tfile
1956 run_test 27p "append to a truncated file with some full OSTs"
1959 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1961 remote_mds_nodsh && skip "remote MDS with nodsh"
1962 remote_ost_nodsh && skip "remote OST with nodsh"
1965 rm -f $DIR/$tdir/$tfile
1967 mkdir_on_mdt0 $DIR/$tdir
1968 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1969 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1970 error "truncate $DIR/$tdir/$tfile failed"
1971 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1973 exhaust_all_precreations 0x215
1975 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1976 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1980 run_test 27q "append to truncated file with all OSTs full (should error)"
1983 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1984 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1985 remote_mds_nodsh && skip "remote MDS with nodsh"
1986 remote_ost_nodsh && skip "remote OST with nodsh"
1989 rm -f $DIR/$tdir/$tfile
1990 exhaust_precreations 0 0x80000215
1992 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1996 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1998 test_27s() { # bug 10725
1999 test_mkdir $DIR/$tdir
2000 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2001 local stripe_count=0
2002 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2003 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2004 error "stripe width >= 2^32 succeeded" || true
2007 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2009 test_27t() { # bug 10864
2014 $WLFS getstripe $tfile
2017 run_test 27t "check that utils parse path correctly"
2019 test_27u() { # bug 4900
2020 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2021 remote_mds_nodsh && skip "remote MDS with nodsh"
2024 local list=$(comma_list $(mdts_nodes))
2026 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2027 do_nodes $list $LCTL set_param fail_loc=0x139
2028 test_mkdir -p $DIR/$tdir
2029 stack_trap "simple_cleanup_common 1000"
2030 createmany -o $DIR/$tdir/$tfile 1000
2031 do_nodes $list $LCTL set_param fail_loc=0
2033 TLOG=$TMP/$tfile.getstripe
2034 $LFS getstripe $DIR/$tdir > $TLOG
2035 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2036 [[ $OBJS -gt 0 ]] &&
2037 error "$OBJS objects created on OST-0. See $TLOG" ||
2040 run_test 27u "skip object creation on OSC w/o objects"
2042 test_27v() { # bug 4900
2043 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2044 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2045 remote_mds_nodsh && skip "remote MDS with nodsh"
2046 remote_ost_nodsh && skip "remote OST with nodsh"
2048 exhaust_all_precreations 0x215
2051 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2053 touch $DIR/$tdir/$tfile
2054 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2056 for (( i=1; i < OSTCOUNT; i++ )); do
2057 do_facet ost$i lctl set_param fail_loc=0x705
2059 local START=`date +%s`
2060 createmany -o $DIR/$tdir/$tfile 32
2062 local FINISH=`date +%s`
2063 local TIMEOUT=`lctl get_param -n timeout`
2064 local PROCESS=$((FINISH - START))
2065 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2066 error "$FINISH - $START >= $TIMEOUT / 2"
2067 sleep $((TIMEOUT / 2 - PROCESS))
2070 run_test 27v "skip object creation on slow OST"
2072 test_27w() { # bug 10997
2073 test_mkdir $DIR/$tdir
2074 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2075 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2076 error "stripe size $size != 65536" || true
2077 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2078 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2080 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2083 [[ $OSTCOUNT -lt 2 ]] &&
2084 skip_env "skipping multiple stripe count/offset test"
2086 test_mkdir $DIR/$tdir
2087 for i in $(seq 1 $OSTCOUNT); do
2089 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2090 error "setstripe -c $i -i $offset failed"
2091 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2092 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2093 [ $count -ne $i ] && error "stripe count $count != $i" || true
2094 [ $index -ne $offset ] &&
2095 error "stripe offset $index != $offset" || true
2098 run_test 27wa "check $LFS setstripe -c -i options"
2101 remote_ost_nodsh && skip "remote OST with nodsh"
2102 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2103 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2105 OFFSET=$(($OSTCOUNT - 1))
2107 local OST=$(ostname_from_index $OSTIDX)
2109 test_mkdir $DIR/$tdir
2110 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2111 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2113 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2114 for i in $(seq 0 $OFFSET); do
2115 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2116 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2117 error "OST0 was degraded but new created file still use it"
2119 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2121 run_test 27x "create files while OST0 is degraded"
2124 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2125 remote_mds_nodsh && skip "remote MDS with nodsh"
2126 remote_ost_nodsh && skip "remote OST with nodsh"
2127 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2129 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2130 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2131 osp.$mdtosc.prealloc_last_id)
2132 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2133 osp.$mdtosc.prealloc_next_id)
2134 local fcount=$((last_id - next_id))
2135 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2136 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2138 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2139 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2140 local OST_DEACTIVE_IDX=-1
2145 for OSC in $MDS_OSCS; do
2146 OST=$(osc_to_ost $OSC)
2147 OSTIDX=$(index_from_ostuuid $OST)
2148 if [ $OST_DEACTIVE_IDX == -1 ]; then
2149 OST_DEACTIVE_IDX=$OSTIDX
2151 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2152 echo $OSC "is Deactivated:"
2153 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2157 OSTIDX=$(index_from_ostuuid $OST)
2158 test_mkdir $DIR/$tdir
2159 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2161 for OSC in $MDS_OSCS; do
2162 OST=$(osc_to_ost $OSC)
2163 OSTIDX=$(index_from_ostuuid $OST)
2164 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2165 echo $OST "is degraded:"
2166 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2167 obdfilter.$OST.degraded=1
2172 createmany -o $DIR/$tdir/$tfile $fcount
2174 for OSC in $MDS_OSCS; do
2175 OST=$(osc_to_ost $OSC)
2176 OSTIDX=$(index_from_ostuuid $OST)
2177 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2178 echo $OST "is recovered from degraded:"
2179 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2180 obdfilter.$OST.degraded=0
2182 do_facet $SINGLEMDS lctl --device %$OSC activate
2186 # all osp devices get activated, hence -1 stripe count restored
2187 local stripe_count=0
2189 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2190 # devices get activated.
2192 $LFS setstripe -c -1 $DIR/$tfile
2193 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2195 [ $stripe_count -ne $OSTCOUNT ] &&
2196 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2199 run_test 27y "create files while OST0 is degraded and the rest inactive"
2205 lmm_count=$($LFS getstripe -c $1)
2206 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2207 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2209 local old_ifs="$IFS"
2211 fid=($($LFS path2fid $1))
2214 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2215 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2217 # compare lmm_seq and lu_fid->f_seq
2218 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2219 # compare lmm_object_id and lu_fid->oid
2220 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2222 # check the trusted.fid attribute of the OST objects of the file
2223 local have_obdidx=false
2225 $LFS getstripe $1 | while read obdidx oid hex seq; do
2226 # skip lines up to and including "obdidx"
2227 [ -z "$obdidx" ] && break
2228 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2229 $have_obdidx || continue
2231 local ost=$((obdidx + 1))
2232 local dev=$(ostdevname $ost)
2235 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2237 seq=$(echo $seq | sed -e "s/^0x//g")
2238 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2239 oid_hex=$(echo $oid)
2241 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2243 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2247 # Don't unmount/remount the OSTs if we don't need to do that.
2248 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2249 # update too, until that use mount/ll_decode_filter_fid/mount.
2250 # Re-enable when debugfs will understand new filter_fid.
2252 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2253 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2254 $dev 2>/dev/null" | grep "parent=")
2256 if [ -z "$ff" ]; then
2258 mount_fstype ost$ost
2259 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2260 $(facet_mntpt ost$ost)/$obj_file)
2261 unmount_fstype ost$ost
2262 start ost$ost $dev $OST_MOUNT_OPTS
2266 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2268 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2270 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2271 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2273 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2274 # stripe_size=1048576 component_id=1 component_start=0 \
2275 # component_end=33554432
2276 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2277 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2278 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2280 if grep -q 'stripe=' <<<$ff; then
2281 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2283 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2284 # into f_ver in this case. See comment on ff_parent.
2285 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2288 # compare lmm_seq and filter_fid->ff_parent.f_seq
2289 [ $ff_pseq = $lmm_seq ] ||
2290 error "FF parent SEQ $ff_pseq != $lmm_seq"
2291 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2292 [ $ff_poid = $lmm_oid ] ||
2293 error "FF parent OID $ff_poid != $lmm_oid"
2294 (($ff_pstripe == $stripe_nr)) ||
2295 error "FF stripe $ff_pstripe != $stripe_nr"
2297 stripe_nr=$((stripe_nr + 1))
2298 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2300 if grep -q 'stripe_count=' <<<$ff; then
2301 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2302 -e 's/ .*//' <<<$ff)
2303 [ $lmm_count = $ff_scnt ] ||
2304 error "FF stripe count $lmm_count != $ff_scnt"
2310 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2311 remote_ost_nodsh && skip "remote OST with nodsh"
2313 test_mkdir $DIR/$tdir
2314 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2315 { error "setstripe -c -1 failed"; return 1; }
2316 # We need to send a write to every object to get parent FID info set.
2317 # This _should_ also work for setattr, but does not currently.
2318 # touch $DIR/$tdir/$tfile-1 ||
2319 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2320 { error "dd $tfile-1 failed"; return 2; }
2321 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2322 { error "setstripe -c -1 failed"; return 3; }
2323 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2324 { error "dd $tfile-2 failed"; return 4; }
2326 # make sure write RPCs have been sent to OSTs
2329 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2330 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2332 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2334 test_27A() { # b=19102
2335 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2337 save_layout_restore_at_exit $MOUNT
2338 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2339 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2340 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2341 local default_size=$($LFS getstripe -S $MOUNT)
2342 local default_offset=$($LFS getstripe -i $MOUNT)
2343 local dsize=$(do_facet $SINGLEMDS \
2344 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2345 [ $default_size -eq $dsize ] ||
2346 error "stripe size $default_size != $dsize"
2347 [ $default_offset -eq -1 ] ||
2348 error "stripe offset $default_offset != -1"
2350 run_test 27A "check filesystem-wide default LOV EA values"
2352 test_27B() { # LU-2523
2353 test_mkdir $DIR/$tdir
2354 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2356 # open f1 with O_LOV_DELAY_CREATE
2358 # call setstripe ioctl on open file descriptor for f1
2360 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2364 # open f1 with O_LOV_DELAY_CREATE
2366 # call setstripe ioctl on open file descriptor for f1
2368 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2370 # Allow multiop to fail in imitation of NFS's busted semantics.
2373 run_test 27B "call setstripe on open unlinked file/rename victim"
2375 # 27C family tests full striping and overstriping
2376 test_27Ca() { #LU-2871
2377 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2385 test_mkdir $DIR/$tdir
2387 for i in $(seq 0 $((OSTCOUNT - 1))); do
2388 # set stripe across all OSTs starting from OST$i
2389 $LFS setstripe -i $i -c -1 $tfile$i
2390 # get striping information
2391 ost_idx=($($LFS getstripe $tfile$i |
2392 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2393 echo "OST Index: ${ost_idx[*]}"
2396 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2397 error "${#ost_idx[@]} != $OSTCOUNT"
2399 for index in $(seq 0 $((OSTCOUNT - 1))); do
2401 for j in "${ost_idx[@]}"; do
2402 if [ $index -eq $j ]; then
2408 error "Can not find $index in ${ost_idx[*]}"
2412 run_test 27Ca "check full striping across all OSTs"
2415 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2416 skip "server does not support overstriping"
2417 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2418 skip_env "too many osts, skipping"
2420 test_mkdir -p $DIR/$tdir
2421 local setcount=$(($OSTCOUNT * 2))
2422 [ $setcount -lt 160 ] || large_xattr_enabled ||
2423 skip_env "ea_inode feature disabled"
2425 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2426 error "setstripe failed"
2428 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2429 [ $count -eq $setcount ] ||
2430 error "stripe count $count, should be $setcount"
2432 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2433 error "overstriped should be set in pattern"
2435 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2438 run_test 27Cb "more stripes than OSTs with -C"
2441 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2442 skip "server does not support overstriping"
2443 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2445 test_mkdir -p $DIR/$tdir
2446 local setcount=$(($OSTCOUNT - 1))
2448 [ $setcount -lt 160 ] || large_xattr_enabled ||
2449 skip_env "ea_inode feature disabled"
2451 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2452 error "setstripe failed"
2454 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2455 [ $count -eq $setcount ] ||
2456 error "stripe count $count, should be $setcount"
2458 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2459 error "overstriped should not be set in pattern"
2461 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2464 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2467 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2468 skip "server does not support overstriping"
2469 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2470 large_xattr_enabled || skip_env "ea_inode feature disabled"
2472 test_mkdir -p $DIR/$tdir
2473 local setcount=$LOV_MAX_STRIPE_COUNT
2475 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2476 error "setstripe failed"
2478 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2479 [ $count -eq $setcount ] ||
2480 error "stripe count $count, should be $setcount"
2482 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2483 error "overstriped should be set in pattern"
2485 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2488 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2490 run_test 27Cd "test maximum stripe count"
2493 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2494 skip "server does not support overstriping"
2495 test_mkdir -p $DIR/$tdir
2497 pool_add $TESTNAME || error "Pool creation failed"
2498 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2502 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2503 error "setstripe failed"
2505 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2506 [ $count -eq $setcount ] ||
2507 error "stripe count $count, should be $setcount"
2509 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2510 error "overstriped should be set in pattern"
2512 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2515 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2517 run_test 27Ce "test pool with overstriping"
2520 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2521 skip "server does not support overstriping"
2522 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2523 skip_env "too many osts, skipping"
2525 test_mkdir -p $DIR/$tdir
2527 local setcount=$(($OSTCOUNT * 2))
2528 [ $setcount -lt 160 ] || large_xattr_enabled ||
2529 skip_env "ea_inode feature disabled"
2531 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2532 error "setstripe failed"
2534 echo 1 > $DIR/$tdir/$tfile
2536 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2537 [ $count -eq $setcount ] ||
2538 error "stripe count $count, should be $setcount"
2540 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2541 error "overstriped should be set in pattern"
2543 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2546 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2548 run_test 27Cf "test default inheritance with overstriping"
2551 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2552 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2553 remote_mds_nodsh && skip "remote MDS with nodsh"
2555 local POOL=${POOL:-testpool}
2557 local last_ost=$(($OSTCOUNT - 1))
2559 local ost_list=$(seq $first_ost $ost_step $last_ost)
2560 local ost_range="$first_ost $last_ost $ost_step"
2562 test_mkdir $DIR/$tdir
2563 pool_add $POOL || error "pool_add failed"
2564 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2567 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2569 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2570 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2571 skip27D+=" -s 30,31"
2572 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2573 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2574 skip27D+=" -s 32,33"
2575 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2577 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2578 error "llapi_layout_test failed"
2580 destroy_test_pools || error "destroy test pools failed"
2582 run_test 27D "validate llapi_layout API"
2584 # Verify that default_easize is increased from its initial value after
2585 # accessing a widely striped file.
2587 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2588 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2589 skip "client does not have LU-3338 fix"
2591 # 72 bytes is the minimum space required to store striping
2592 # information for a file striped across one OST:
2593 # (sizeof(struct lov_user_md_v3) +
2594 # sizeof(struct lov_user_ost_data_v1))
2596 $LCTL set_param -n llite.*.default_easize $min_easize ||
2597 error "lctl set_param failed"
2598 local easize=$($LCTL get_param -n llite.*.default_easize)
2600 [ $easize -eq $min_easize ] ||
2601 error "failed to set default_easize"
2603 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2604 error "setstripe failed"
2605 # In order to ensure stat() call actually talks to MDS we need to
2606 # do something drastic to this file to shake off all lock, e.g.
2607 # rename it (kills lookup lock forcing cache cleaning)
2608 mv $DIR/$tfile $DIR/${tfile}-1
2609 ls -l $DIR/${tfile}-1
2612 easize=$($LCTL get_param -n llite.*.default_easize)
2614 [ $easize -gt $min_easize ] ||
2615 error "default_easize not updated"
2617 run_test 27E "check that default extended attribute size properly increases"
2619 test_27F() { # LU-5346/LU-7975
2620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2621 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2622 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2623 skip "Need MDS version at least 2.8.51"
2624 remote_ost_nodsh && skip "remote OST with nodsh"
2626 test_mkdir $DIR/$tdir
2628 $LFS setstripe -c 2 $DIR/$tdir
2630 # stop all OSTs to reproduce situation for LU-7975 ticket
2631 for num in $(seq $OSTCOUNT); do
2635 # open/create f0 with O_LOV_DELAY_CREATE
2636 # truncate f0 to a non-0 size
2638 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2640 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2641 # open/write it again to force delayed layout creation
2642 cat /etc/hosts > $DIR/$tdir/f0 &
2646 for num in $(seq $OSTCOUNT); do
2647 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2648 error "ost$num failed to start"
2651 wait $catpid || error "cat failed"
2653 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2654 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2655 error "wrong stripecount"
2658 run_test 27F "Client resend delayed layout creation with non-zero size"
2660 test_27G() { #LU-10629
2661 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2662 skip "Need MDS version at least 2.11.51"
2663 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2664 remote_mds_nodsh && skip "remote MDS with nodsh"
2665 local POOL=${POOL:-testpool}
2666 local ostrange="0 0 1"
2668 test_mkdir $DIR/$tdir
2669 touch $DIR/$tdir/$tfile.nopool
2670 pool_add $POOL || error "pool_add failed"
2671 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2672 $LFS setstripe -p $POOL $DIR/$tdir
2674 local pool=$($LFS getstripe -p $DIR/$tdir)
2676 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2677 touch $DIR/$tdir/$tfile.default
2678 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2679 $LFS find $DIR/$tdir -type f --pool $POOL
2680 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2681 [[ "$found" == "2" ]] ||
2682 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2684 $LFS setstripe -d $DIR/$tdir
2686 pool=$($LFS getstripe -p -d $DIR/$tdir)
2688 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2690 run_test 27G "Clear OST pool from stripe"
2693 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2694 skip "Need MDS version newer than 2.11.54"
2695 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2696 test_mkdir $DIR/$tdir
2697 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2698 touch $DIR/$tdir/$tfile
2699 $LFS getstripe -c $DIR/$tdir/$tfile
2700 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2701 error "two-stripe file doesn't have two stripes"
2703 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2704 $LFS getstripe -y $DIR/$tdir/$tfile
2705 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2706 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2707 error "expected l_ost_idx: [02]$ not matched"
2709 # make sure ost list has been cleared
2710 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2711 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2712 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2714 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2716 run_test 27H "Set specific OSTs stripe"
2719 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2720 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2721 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2722 skip "Need MDS version newer than 2.12.52"
2723 local pool=$TESTNAME
2724 local ostrange="1 1 1"
2726 save_layout_restore_at_exit $MOUNT
2727 $LFS setstripe -c 2 -i 0 $MOUNT
2728 pool_add $pool || error "pool_add failed"
2729 pool_add_targets $pool $ostrange ||
2730 error "pool_add_targets failed"
2731 test_mkdir $DIR/$tdir
2732 $LFS setstripe -p $pool $DIR/$tdir
2733 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2734 $LFS getstripe $DIR/$tdir/$tfile
2736 run_test 27I "check that root dir striping does not break parent dir one"
2739 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2740 skip "Need MDS version newer than 2.12.51"
2742 test_mkdir $DIR/$tdir
2743 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2744 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2746 # create foreign file (raw way)
2747 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2748 error "creating $tfile w/ hex flags w/o --foreign should fail"
2750 ! $LFS setstripe --foreign --flags foo \
2751 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2752 error "creating $tfile with '--flags foo' should fail"
2754 ! $LFS setstripe --foreign --flags 0xffffffff \
2755 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2756 error "creating $tfile w/ 0xffffffff flags should fail"
2758 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2759 -t 1 -F 0xda08 || error "create_foreign_file failed"
2761 # verify foreign file (raw way)
2762 parse_foreign_file -f $DIR/$tdir/$tfile |
2763 grep "lov_foreign_magic: 0x0BD70BD0" ||
2764 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2765 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2766 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2767 parse_foreign_file -f $DIR/$tdir/$tfile |
2768 grep "lov_foreign_size: 73" ||
2769 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2770 parse_foreign_file -f $DIR/$tdir/$tfile |
2771 grep "lov_foreign_type: 1" ||
2772 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2773 parse_foreign_file -f $DIR/$tdir/$tfile |
2774 grep "lov_foreign_flags: 0x0000DA08" ||
2775 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2776 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2777 grep "lov_foreign_value: 0x" |
2778 sed -e 's/lov_foreign_value: 0x//')
2779 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2780 [[ $lov = ${lov2// /} ]] ||
2781 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2783 # create foreign file (lfs + API)
2784 $LFS setstripe --foreign=none --flags 0xda08 \
2785 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2786 error "$DIR/$tdir/${tfile}2: create failed"
2788 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2789 grep "lfm_magic:.*0x0BD70BD0" ||
2790 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2791 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2792 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2793 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2794 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2795 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2796 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2797 grep "lfm_flags:.*0x0000DA08" ||
2798 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2799 $LFS getstripe $DIR/$tdir/${tfile}2 |
2800 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2801 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2803 # modify striping should fail
2804 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2805 error "$DIR/$tdir/$tfile: setstripe should fail"
2806 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2807 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2810 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2811 cat $DIR/$tdir/${tfile}2 &&
2812 error "$DIR/$tdir/${tfile}2: read should fail"
2813 cat /etc/passwd > $DIR/$tdir/$tfile &&
2814 error "$DIR/$tdir/$tfile: write should fail"
2815 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2816 error "$DIR/$tdir/${tfile}2: write should fail"
2819 chmod 222 $DIR/$tdir/$tfile ||
2820 error "$DIR/$tdir/$tfile: chmod failed"
2821 chmod 222 $DIR/$tdir/${tfile}2 ||
2822 error "$DIR/$tdir/${tfile}2: chmod failed"
2825 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2826 error "$DIR/$tdir/$tfile: chown failed"
2827 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2828 error "$DIR/$tdir/${tfile}2: chown failed"
2830 # rename should work
2831 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2832 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2833 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2834 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2836 #remove foreign file
2837 rm $DIR/$tdir/${tfile}.new ||
2838 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2839 rm $DIR/$tdir/${tfile}2.new ||
2840 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2842 run_test 27J "basic ops on file with foreign LOV"
2845 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2846 skip "Need MDS version newer than 2.12.49"
2848 test_mkdir $DIR/$tdir
2849 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2850 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2852 # create foreign dir (raw way)
2853 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2854 error "creating $tdir w/ hex flags w/o --foreign should fail"
2856 ! $LFS setdirstripe --foreign --flags foo \
2857 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2858 error "creating $tdir with '--flags foo' should fail"
2860 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2861 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2862 error "creating $tdir w/ 0xffffffff flags should fail"
2864 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2865 error "create_foreign_dir FAILED"
2867 # verify foreign dir (raw way)
2868 parse_foreign_dir -d $DIR/$tdir/$tdir |
2869 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2870 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2871 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2872 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2873 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2874 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2875 parse_foreign_dir -d $DIR/$tdir/$tdir |
2876 grep "lmv_foreign_flags: 55813$" ||
2877 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2878 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2879 grep "lmv_foreign_value: 0x" |
2880 sed 's/lmv_foreign_value: 0x//')
2881 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2883 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2885 # create foreign dir (lfs + API)
2886 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2887 $DIR/$tdir/${tdir}2 ||
2888 error "$DIR/$tdir/${tdir}2: create failed"
2890 $LFS getdirstripe -v $DIR/$tdir/${tdir}2
2892 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2893 grep "lfm_magic:.*0x0CD50CD0" ||
2894 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2895 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2896 # - sizeof(lfm_type) - sizeof(lfm_flags)
2897 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2898 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2899 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2900 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2901 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2902 grep "lfm_flags:.*0x0000DA05" ||
2903 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2904 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2905 grep "lfm_value.*${uuid1}@${uuid2}" ||
2906 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2908 # file create in dir should fail
2909 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
2910 touch $DIR/$tdir/${tdir}2/$tfile &&
2911 error "$DIR/${tdir}2: file create should fail"
2914 chmod 777 $DIR/$tdir/$tdir ||
2915 error "$DIR/$tdir: chmod failed"
2916 chmod 777 $DIR/$tdir/${tdir}2 ||
2917 error "$DIR/${tdir}2: chmod failed"
2920 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2921 error "$DIR/$tdir: chown failed"
2922 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2923 error "$DIR/${tdir}2: chown failed"
2925 # rename should work
2926 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2927 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2928 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2929 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2932 rmdir $DIR/$tdir/${tdir}.new ||
2933 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2934 rmdir $DIR/$tdir/${tdir}2.new ||
2935 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2937 run_test 27K "basic ops on dir with foreign LMV"
2940 remote_mds_nodsh && skip "remote MDS with nodsh"
2942 local POOL=${POOL:-$TESTNAME}
2944 pool_add $POOL || error "pool_add failed"
2946 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2947 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2948 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2950 run_test 27L "lfs pool_list gives correct pool name"
2953 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2954 skip "Need MDS version >= than 2.12.57"
2955 remote_mds_nodsh && skip "remote MDS with nodsh"
2956 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2958 # Set default striping on directory
2961 local mdts=$(comma_list $(mdts_nodes))
2963 # if we run against a 2.12 server which lacks overstring support
2964 # then the connect_flag will not report overstriping, even if client
2966 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
2967 stripe_opt="-C $setcount"
2968 elif (( $OSTCOUNT >= $setcount )); then
2969 stripe_opt="-c $setcount"
2971 skip "server does not support overstriping"
2974 test_mkdir $DIR/$tdir
2976 # Validate existing append_* params and ensure restore
2977 local pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
2978 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
2979 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
2981 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2982 ((orig_count == 1)) || error "expected append_stripe_count == 1, got $orig_count"
2983 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1"
2985 $LFS setstripe $stripe_opt $DIR/$tdir
2987 echo 1 > $DIR/$tdir/${tfile}.1
2988 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2989 [ $count -eq $setcount ] ||
2990 error "(1) stripe count $count, should be $setcount"
2992 local appendcount=$orig_count
2993 echo 1 >> $DIR/$tdir/${tfile}.2_append
2994 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2995 [ $count -eq $appendcount ] ||
2996 error "(2)stripe count $count, should be $appendcount for append"
2998 # Disable O_APPEND striping, verify it works
2999 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3001 # Should now get the default striping, which is 4
3003 echo 1 >> $DIR/$tdir/${tfile}.3_append
3004 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3005 [ $count -eq $setcount ] ||
3006 error "(3) stripe count $count, should be $setcount"
3008 # Try changing the stripe count for append files
3009 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3011 # Append striping is now 2 (directory default is still 4)
3013 echo 1 >> $DIR/$tdir/${tfile}.4_append
3014 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3015 [ $count -eq $appendcount ] ||
3016 error "(4) stripe count $count, should be $appendcount for append"
3018 # Test append stripe count of -1
3019 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3020 appendcount=$OSTCOUNT
3021 echo 1 >> $DIR/$tdir/${tfile}.5
3022 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3023 [ $count -eq $appendcount ] ||
3024 error "(5) stripe count $count, should be $appendcount for append"
3026 # Set append striping back to default of 1
3027 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3029 # Try a new default striping, PFL + DOM
3030 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3032 # Create normal DOM file, DOM returns stripe count == 0
3034 touch $DIR/$tdir/${tfile}.6
3035 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3036 [ $count -eq $setcount ] ||
3037 error "(6) stripe count $count, should be $setcount"
3041 echo 1 >> $DIR/$tdir/${tfile}.7_append
3042 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3043 [ $count -eq $appendcount ] ||
3044 error "(7) stripe count $count, should be $appendcount for append"
3046 # Clean up DOM layout
3047 $LFS setstripe -d $DIR/$tdir
3049 save_layout_restore_at_exit $MOUNT
3050 # Now test that append striping works when layout is from root
3051 $LFS setstripe -c 2 $MOUNT
3052 # Make a special directory for this
3053 mkdir $DIR/${tdir}/${tdir}.2
3055 # Verify for normal file
3057 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3058 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3059 [ $count -eq $setcount ] ||
3060 error "(8) stripe count $count, should be $setcount"
3063 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3064 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3065 [ $count -eq $appendcount ] ||
3066 error "(9) stripe count $count, should be $appendcount for append"
3068 # Now test O_APPEND striping with pools
3069 pool_add $TESTNAME || error "pool creation failed"
3070 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3071 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3073 echo 1 >> $DIR/$tdir/${tfile}.10_append
3075 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3076 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3078 # Check that count is still correct
3080 echo 1 >> $DIR/$tdir/${tfile}.11_append
3081 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3082 [ $count -eq $appendcount ] ||
3083 error "(11) stripe count $count, should be $appendcount for append"
3085 # Disable O_APPEND stripe count, verify pool works separately
3086 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3088 echo 1 >> $DIR/$tdir/${tfile}.12_append
3090 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3091 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3093 # Remove pool setting, verify it's not applied
3094 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3096 echo 1 >> $DIR/$tdir/${tfile}.13_append
3098 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3099 [ "$pool" = "" ] || error "(13) pool found: $pool"
3101 run_test 27M "test O_APPEND striping"
3104 combined_mgs_mds && skip "needs separate MGS/MDT"
3106 pool_add $TESTNAME || error "pool_add failed"
3107 do_facet mgs "$LCTL pool_list $FSNAME" |
3108 grep -Fx "${FSNAME}.${TESTNAME}" ||
3109 error "lctl pool_list on MGS failed"
3111 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3113 clean_foreign_symlink() {
3115 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3116 for i in $DIR/$tdir/* ; do
3117 $LFS unlink_foreign $i || true
3122 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3123 skip "Need MDS version newer than 2.12.51"
3125 test_mkdir $DIR/$tdir
3126 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3127 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3129 trap clean_foreign_symlink EXIT
3131 # enable foreign_symlink behaviour
3132 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3134 # foreign symlink LOV format is a partial path by default
3136 # create foreign file (lfs + API)
3137 $LFS setstripe --foreign=symlink --flags 0xda05 \
3138 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3139 error "$DIR/$tdir/${tfile}: create failed"
3141 $LFS getstripe -v $DIR/$tdir/${tfile} |
3142 grep "lfm_magic:.*0x0BD70BD0" ||
3143 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3144 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3145 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3146 $LFS getstripe -v $DIR/$tdir/${tfile} |
3147 grep "lfm_flags:.*0x0000DA05" ||
3148 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3149 $LFS getstripe $DIR/$tdir/${tfile} |
3150 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3151 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3153 # modify striping should fail
3154 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3155 error "$DIR/$tdir/$tfile: setstripe should fail"
3157 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3158 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3159 cat /etc/passwd > $DIR/$tdir/$tfile &&
3160 error "$DIR/$tdir/$tfile: write should fail"
3162 # rename should succeed
3163 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3164 error "$DIR/$tdir/$tfile: rename has failed"
3166 #remove foreign_symlink file should fail
3167 rm $DIR/$tdir/${tfile}.new &&
3168 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3171 mkdir /tmp/${uuid1} ||
3172 error "/tmp/${uuid1}: mkdir has failed"
3173 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3174 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3175 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3176 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3177 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3178 #read should succeed now
3179 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3180 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3181 #write should succeed now
3182 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3183 error "$DIR/$tdir/${tfile}.new: write should succeed"
3184 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3185 error "$DIR/$tdir/${tfile}.new: diff has failed"
3186 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3187 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3189 #check that getstripe still works
3190 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3191 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3193 # chmod should still succeed
3194 chmod 644 $DIR/$tdir/${tfile}.new ||
3195 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3197 # chown should still succeed
3198 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3199 error "$DIR/$tdir/${tfile}.new: chown has failed"
3201 # rename should still succeed
3202 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3203 error "$DIR/$tdir/${tfile}.new: rename has failed"
3205 #remove foreign_symlink file should still fail
3206 rm $DIR/$tdir/${tfile} &&
3207 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3209 #use special ioctl() to unlink foreign_symlink file
3210 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3211 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3214 run_test 27O "basic ops on foreign file of symlink type"
3217 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3218 skip "Need MDS version newer than 2.12.49"
3220 test_mkdir $DIR/$tdir
3221 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3222 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3224 trap clean_foreign_symlink EXIT
3226 # enable foreign_symlink behaviour
3227 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3229 # foreign symlink LMV format is a partial path by default
3231 # create foreign dir (lfs + API)
3232 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3233 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3234 error "$DIR/$tdir/${tdir}: create failed"
3236 $LFS getdirstripe -v $DIR/$tdir/${tdir}
3238 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3239 grep "lfm_magic:.*0x0CD50CD0" ||
3240 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3241 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3242 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3243 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3244 grep "lfm_flags:.*0x0000DA05" ||
3245 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3246 $LFS getdirstripe $DIR/$tdir/${tdir} |
3247 grep "lfm_value.*${uuid1}/${uuid2}" ||
3248 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3250 # file create in dir should fail
3251 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3252 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
3254 # rename should succeed
3255 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3256 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3258 #remove foreign_symlink dir should fail
3259 rmdir $DIR/$tdir/${tdir}.new &&
3260 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3263 mkdir -p /tmp/${uuid1}/${uuid2} ||
3264 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3265 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3266 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3267 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3268 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3269 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3270 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3271 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3273 #check that getstripe fails now that foreign_symlink enabled
3274 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3275 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3277 # file create in dir should work now
3278 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3279 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3280 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3281 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3282 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3283 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3285 # chmod should still succeed
3286 chmod 755 $DIR/$tdir/${tdir}.new ||
3287 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3289 # chown should still succeed
3290 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3291 error "$DIR/$tdir/${tdir}.new: chown has failed"
3293 # rename should still succeed
3294 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3295 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3297 #remove foreign_symlink dir should still fail
3298 rmdir $DIR/$tdir/${tdir} &&
3299 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3301 #use special ioctl() to unlink foreign_symlink file
3302 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3303 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3305 #created file should still exist
3306 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3307 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3308 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3309 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3311 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3314 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3315 stack_trap "rm -f $TMP/$tfile*"
3317 test_mkdir $DIR/$tdir-1
3318 test_mkdir $DIR/$tdir-2
3320 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3321 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3323 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3324 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3326 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3327 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3329 # Create some bad symlinks and ensure that we don't loop
3330 # forever or something. These should return ELOOP (40) and
3331 # ENOENT (2) but I don't want to test for that because there's
3332 # always some weirdo architecture that needs to ruin
3333 # everything by defining these error numbers differently.
3335 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3336 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3338 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3339 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3343 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3346 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
3347 skip "need MDS 2.14.55 or later"
3348 (( $OSTCOUNT >= 2 )) || skip_env "needs at least 2 OSTs"
3350 local testdir="$DIR/$tdir"
3351 test_mkdir -p $testdir
3352 stack_trap "rm -rf $testdir"
3353 $LFS setstripe -c -1 $testdir || error "setstripe failed"
3355 local f1="$testdir/f1"
3356 touch $f1 || error "failed to touch $f1"
3357 local count=$($LFS getstripe -c $f1)
3358 (( $count == $OSTCOUNT )) || error "wrong stripe count"
3360 do_facet $SINGLEMDS $LCTL set_param lod.*.max_stripecount=-1
3361 (( $? == 34 )) || error "setting max_stripecount to -1 should fail and return ERANGE"
3363 local maxcount=$(($OSTCOUNT - 1))
3364 local mdts=$(comma_list $(mdts_nodes))
3365 do_nodes $mdts $LCTL set_param lod.*.max_stripecount=$maxcount
3366 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_stripecount=0"
3368 local f2="$testdir/f2"
3369 touch $f2 || error "failed to touch $f2"
3370 local count=$($LFS getstripe -c $f2)
3371 (( $count == $maxcount )) || error "wrong stripe count"
3373 run_test 27R "test max_stripecount limitation when stripe count is set to -1"
3376 [ $(facet_host client) == $(facet_host ost1) ] &&
3377 skip "need ost1 and client on different nodes"
3379 #define OBD_FAIL_OSC_NO_GRANT 0x411
3380 $LCTL set_param fail_loc=0x20000411 fail_val=1
3381 #define OBD_FAIL_OST_ENOSPC 0x215
3382 do_facet ost1 "$LCTL set_param fail_loc=0x80000215"
3383 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3384 $MULTIOP $DIR/$tfile oO_WRONLY:P$((4 * 1024 * 1024 + 10 * 4096))c ||
3385 error "multiop failed"
3387 run_test 27T "no eio on close on partial write due to enosp"
3390 local dir=$DIR/$tdir
3391 local file=$dir/$tfile
3392 local append_pool=${TESTNAME}-append
3393 local normal_pool=${TESTNAME}-normal
3397 local mdts=$(comma_list $(mdts_nodes))
3400 # (( $MDS1_VERSION >= $(version_code 2.15.42) )) ||
3401 # skip "Need MDS version at least 2.15.42"
3403 # Validate existing append_* params and ensure restore
3404 pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3405 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3406 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3408 stripe_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3409 ((stripe_count == 1)) || error "expected append_stripe_count != 0, got $stripe_count"
3410 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$stripe_count"
3412 pool_add $append_pool || error "pool creation failed"
3413 pool_add_targets $append_pool 0 1 || error "Pool add targets failed"
3415 pool_add $normal_pool || error "pool creation failed"
3416 pool_add_targets $normal_pool 0 1 || error "Pool add targets failed"
3419 $LFS setstripe -E 1M -c 1 -p $normal_pool -E 2M -c 2 -p $normal_pool -E eof -c -1 $dir
3422 $LFS getstripe $file.1
3424 pool=$($LFS getstripe -p $file.1)
3425 [[ "$pool" == "$normal_pool" ]] || error "got pool '$pool', expected '$normal_pool'"
3427 stripe_count2=$($LFS getstripe -c $file.1)
3428 ((stripe_count2 == stripe_count)) ||
3429 error "got stripe_count '$stripe_count2', expected '$stripe_count'"
3431 do_nodes $mdts $LCTL set_param mdd.*.append_pool=$append_pool
3434 $LFS getstripe $file.2
3436 pool=$($LFS getstripe -p $file.2)
3437 [[ "$pool" == "$append_pool" ]] || error "got pool '$pool', expected '$append_pool'"
3439 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3442 $LFS getstripe $file.3
3444 stripe_count2=$($LFS getstripe -c $file.3)
3445 ((stripe_count2 == 2)) || error "got stripe_count '$stripe_count2', expected 2"
3447 run_test 27U "append pool and stripe count work with composite default layout"
3449 # createtest also checks that device nodes are created and
3450 # then visible correctly (#2091)
3451 test_28() { # bug 2091
3453 $CREATETEST $DIR/d28/ct || error "createtest failed"
3455 run_test 28 "create/mknod/mkdir with bad file types ============"
3458 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3460 [ $MDS1_VERSION -ge $(version_code 2.14.51) ] && {
3462 stack_trap "restore_opencache"
3465 sync; sleep 1; sync # flush out any dirty pages from previous tests
3472 declare -i LOCKCOUNTORIG=0
3473 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3474 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3476 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3478 declare -i LOCKUNUSEDCOUNTORIG=0
3479 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3480 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3487 declare -i LOCKCOUNTCURRENT=0
3488 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3489 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3492 declare -i LOCKUNUSEDCOUNTCURRENT=0
3493 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3494 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3497 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3498 $LCTL set_param -n ldlm.dump_namespaces ""
3499 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3500 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3501 log "dumped log to $TMP/test_29.dk (bug 5793)"
3504 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3505 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3506 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3507 log "dumped log to $TMP/test_29.dk (bug 5793)"
3511 run_test 29 "IT_GETATTR regression ============================"
3513 test_30a() { # was test_30
3514 cp $(which ls) $DIR || cp /bin/ls $DIR
3515 $DIR/ls / || error "Can't execute binary from lustre"
3518 run_test 30a "execute binary from Lustre (execve) =============="
3521 cp `which ls` $DIR || cp /bin/ls $DIR
3523 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3526 run_test 30b "execute binary from Lustre as non-root ==========="
3528 test_30c() { # b=22376
3529 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3531 cp $(which ls) $DIR || cp /bin/ls $DIR
3533 cancel_lru_locks mdc
3534 cancel_lru_locks osc
3535 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3538 run_test 30c "execute binary from Lustre without read perms ===="
3541 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3543 for i in {1..10}; do
3544 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3547 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3548 wait $PID || error "executing dd from Lustre failed"
3554 run_test 30d "execute binary from Lustre while clear locks"
3557 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3558 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3560 run_test 31a "open-unlink file =================================="
3563 touch $DIR/f31 || error "touch $DIR/f31 failed"
3564 ln $DIR/f31 $DIR/f31b || error "ln failed"
3565 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3566 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3568 run_test 31b "unlink file with multiple links while open ======="
3571 touch $DIR/f31 || error "touch $DIR/f31 failed"
3572 ln $DIR/f31 $DIR/f31c || error "ln failed"
3573 multiop_bg_pause $DIR/f31 O_uc ||
3574 error "multiop_bg_pause for $DIR/f31 failed"
3576 $MULTIOP $DIR/f31c Ouc
3577 kill -USR1 $MULTIPID
3580 run_test 31c "open-unlink file with multiple links ============="
3583 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3584 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3586 run_test 31d "remove of open directory ========================="
3588 test_31e() { # bug 2904
3589 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3591 run_test 31e "remove of open non-empty directory ==============="
3593 test_31f() { # bug 4554
3594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3597 test_mkdir $DIR/d31f
3598 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3599 cp /etc/hosts $DIR/d31f
3601 $LFS getstripe $DIR/d31f/hosts
3602 multiop_bg_pause $DIR/d31f D_c || return 1
3605 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3606 test_mkdir $DIR/d31f
3607 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3608 cp /etc/hosts $DIR/d31f
3610 $LFS getstripe $DIR/d31f/hosts
3611 multiop_bg_pause $DIR/d31f D_c || return 1
3614 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3615 wait $MULTIPID || error "first opendir $MULTIPID failed"
3619 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3620 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3623 run_test 31f "remove of open directory with open-unlink file ==="
3626 echo "-- cross directory link --"
3627 test_mkdir -c1 $DIR/${tdir}ga
3628 test_mkdir -c1 $DIR/${tdir}gb
3629 touch $DIR/${tdir}ga/f
3630 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3631 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3632 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3633 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3634 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3636 run_test 31g "cross directory link==============="
3639 echo "-- cross directory link --"
3640 test_mkdir -c1 $DIR/${tdir}
3641 test_mkdir -c1 $DIR/${tdir}/dir
3642 touch $DIR/${tdir}/f
3643 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3644 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3645 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3646 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3647 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3649 run_test 31h "cross directory link under child==============="
3652 echo "-- cross directory link --"
3653 test_mkdir -c1 $DIR/$tdir
3654 test_mkdir -c1 $DIR/$tdir/dir
3655 touch $DIR/$tdir/dir/f
3656 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3657 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3658 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3659 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3660 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3662 run_test 31i "cross directory link under parent==============="
3665 test_mkdir -c1 -p $DIR/$tdir
3666 test_mkdir -c1 -p $DIR/$tdir/dir1
3667 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3668 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3669 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3670 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3673 run_test 31j "link for directory==============="
3676 test_mkdir -c1 -p $DIR/$tdir
3678 touch $DIR/$tdir/exist
3679 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3680 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3681 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3682 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3683 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3684 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3685 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3688 run_test 31k "link to file: the same, non-existing, dir==============="
3694 touch $DIR/d31m2/exist
3695 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3696 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3697 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3698 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3699 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3700 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3703 run_test 31m "link to file: the same, non-existing, dir==============="
3706 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3707 nlink=$(stat --format=%h $DIR/$tfile)
3708 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3710 local cmd="exec $fd<$DIR/$tfile"
3713 trap "eval $cmd" EXIT
3714 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3715 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3716 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3717 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3718 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3721 run_test 31n "check link count of unlinked file"
3724 local tempfile=$(mktemp $1_XXXXXX)
3725 mlink $tempfile $1 2> /dev/null &&
3726 echo "$BASHPID: link $tempfile to $1 succeeded"
3730 test_31o() { # LU-2901
3731 test_mkdir $DIR/$tdir
3732 for LOOP in $(seq 100); do
3733 rm -f $DIR/$tdir/$tfile*
3734 for THREAD in $(seq 8); do
3735 link_one $DIR/$tdir/$tfile.$LOOP &
3738 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3739 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3740 error "$LINKS duplicate links to $tfile.$LOOP" &&
3744 run_test 31o "duplicate hard links with same filename"
3747 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3749 test_mkdir $DIR/$tdir
3750 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3751 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3753 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3754 error "open unlink test1 failed"
3755 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3756 error "open unlink test2 failed"
3758 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3759 error "test1 still exists"
3760 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3761 error "test2 still exists"
3763 run_test 31p "remove of open striped directory"
3766 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3768 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3769 index=$($LFS getdirstripe -i $DIR/$tdir)
3770 [ $index -eq 3 ] || error "first stripe index $index != 3"
3771 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3772 [ $index -eq 1 ] || error "second stripe index $index != 1"
3774 # when "-c <stripe_count>" is set, the number of MDTs specified after
3775 # "-i" should equal to the stripe count
3776 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3778 run_test 31q "create striped directory on specific MDTs"
3782 touch $DIR/$tfile.target
3783 touch $DIR/$tfile.source
3785 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
3786 $LCTL set_param fail_loc=0x1419 fail_val=3
3787 cat $DIR/$tfile.target &
3790 # Guarantee open is waiting before we get here
3792 mv $DIR/$tfile.source $DIR/$tfile.target
3796 if [[ $RC -ne 0 ]]; then
3797 error "open with cat failed, rc=$RC"
3800 run_test 31r "open-rename(replace) race"
3802 cleanup_test32_mount() {
3805 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3806 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3807 losetup -d $loopdev || true
3813 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3815 echo "== more mountpoints and symlinks ================="
3816 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3817 trap cleanup_test32_mount EXIT
3818 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3819 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3820 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3821 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3822 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3823 cleanup_test32_mount
3825 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3828 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3830 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3831 trap cleanup_test32_mount EXIT
3832 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3833 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3834 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3835 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3836 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3837 cleanup_test32_mount
3839 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3844 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3845 trap cleanup_test32_mount EXIT
3846 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3847 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3848 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3849 test_mkdir -p $DIR/$tdir/d2/test_dir
3850 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3851 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3852 cleanup_test32_mount
3854 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3857 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3859 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3860 trap cleanup_test32_mount EXIT
3861 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3862 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3863 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3864 test_mkdir -p $DIR/$tdir/d2/test_dir
3865 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3866 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3867 cleanup_test32_mount
3869 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3873 test_mkdir -p $DIR/$tdir/tmp
3874 local tmp_dir=$DIR/$tdir/tmp
3875 ln -s $DIR/$tdir $tmp_dir/symlink11
3876 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3877 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3878 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3880 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3884 test_mkdir -p $DIR/$tdir/tmp
3885 local tmp_dir=$DIR/$tdir/tmp
3886 ln -s $DIR/$tdir $tmp_dir/symlink11
3887 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3888 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3889 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3891 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3894 local tmp_dir=$DIR/$tdir/tmp
3895 test_mkdir -p $tmp_dir
3896 test_mkdir $DIR/${tdir}2
3897 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3898 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3899 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3900 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3901 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3902 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3904 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3907 rm -fr $DIR/$tdir $DIR/${tdir}2
3908 tmp_dir=$DIR/$tdir/tmp
3909 test_mkdir -p $tmp_dir
3910 test_mkdir $DIR/${tdir}2
3911 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3912 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3913 ls $tmp_dir/symlink12 || error "listing symlink12"
3914 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3916 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3921 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3922 trap cleanup_test32_mount EXIT
3923 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3924 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3925 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3926 touch $DIR/$tdir/test_file
3927 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3928 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3929 cleanup_test32_mount
3931 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3934 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3936 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3937 trap cleanup_test32_mount EXIT
3938 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3939 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3940 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3941 touch $DIR/$tdir/test_file
3942 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3943 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3944 cleanup_test32_mount
3946 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3949 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3952 trap cleanup_test32_mount EXIT
3953 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3954 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3955 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3956 test_mkdir -p $DIR/$tdir/d2
3957 touch $DIR/$tdir/d2/test_file || error "touch failed"
3958 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3959 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3960 cleanup_test32_mount
3962 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3965 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3968 trap cleanup_test32_mount EXIT
3969 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3970 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3971 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3972 test_mkdir -p $DIR/$tdir/d2
3973 touch $DIR/$tdir/d2/test_file || error "touch failed"
3974 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3975 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3976 cleanup_test32_mount
3978 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3982 test_mkdir -p $DIR/d32m/tmp
3983 TMP_DIR=$DIR/d32m/tmp
3984 ln -s $DIR $TMP_DIR/symlink11
3985 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3986 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3987 error "symlink11 not a link"
3988 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3989 error "symlink01 not a link"
3991 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3995 test_mkdir -p $DIR/d32n/tmp
3996 TMP_DIR=$DIR/d32n/tmp
3997 ln -s $DIR $TMP_DIR/symlink11
3998 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3999 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
4000 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
4002 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
4006 test_mkdir -p $DIR/d32o/tmp
4007 TMP_DIR=$DIR/d32o/tmp
4008 ln -s $DIR/$tfile $TMP_DIR/symlink12
4009 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4010 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
4011 error "symlink12 not a link"
4012 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
4013 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
4014 error "$DIR/d32o/tmp/symlink12 not file type"
4015 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
4016 error "$DIR/d32o/symlink02 not file type"
4018 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
4028 test_mkdir -p $DIR/d32p/tmp
4030 TMP_DIR=$DIR/d32p/tmp
4032 ln -s $DIR/$tfile $TMP_DIR/symlink12
4034 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4036 cat $DIR/d32p/tmp/symlink12 ||
4037 error "Can't open $DIR/d32p/tmp/symlink12"
4039 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
4042 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
4045 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4047 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4048 trap cleanup_test32_mount EXIT
4049 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4050 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4051 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4052 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4053 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
4054 cleanup_test32_mount
4056 run_test 32q "stat follows mountpoints in Lustre (should return error)"
4059 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4061 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4062 trap cleanup_test32_mount EXIT
4063 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4064 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4065 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4066 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4067 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
4068 cleanup_test32_mount
4070 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
4075 chmod 444 $DIR/$tfile
4076 chown $RUNAS_ID $DIR/$tfile
4078 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4081 run_test 33aa "write file with mode 444 (should return error)"
4085 test_mkdir $DIR/$tdir
4086 chown $RUNAS_ID $DIR/$tdir
4087 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
4088 error "$RUNAS create $tdir/$tfile failed"
4089 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4090 error "open RDWR" || true
4092 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4096 test_mkdir $DIR/$tdir
4097 chown $RUNAS_ID $DIR/$tdir
4098 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4100 run_test 33b "test open file with malformed flags (No panic)"
4103 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4104 remote_ost_nodsh && skip "remote OST with nodsh"
4112 test_mkdir $DIR/$tdir
4113 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4116 for ostnum in $(seq $OSTCOUNT); do
4117 # test-framework's OST numbering is one-based, while Lustre's
4119 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4120 # check if at least some write_bytes stats are counted
4121 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4122 obdfilter.$ostname.stats |
4123 awk '/^write_bytes/ {print $7}' )
4124 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4125 if (( ${write_bytes:-0} > 0 )); then
4131 $all_zeros || return 0
4134 echo foo > $DIR/$tdir/bar
4138 # Total up write_bytes after writing. We'd better find non-zeros.
4139 for ostnum in $(seq $OSTCOUNT); do
4140 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4141 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4142 obdfilter/$ostname/stats |
4143 awk '/^write_bytes/ {print $7}' )
4144 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4145 if (( ${write_bytes:-0} > 0 )); then
4152 for ostnum in $(seq $OSTCOUNT); do
4153 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4154 echo "Check write_bytes is in obdfilter.*.stats:"
4155 do_facet ost$ostnum lctl get_param -n \
4156 obdfilter.$ostname.stats
4158 error "OST not keeping write_bytes stats (b=22312)"
4161 run_test 33c "test write_bytes stats"
4164 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4165 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4168 local remote_dir=$DIR/$tdir/remote_dir
4170 test_mkdir $DIR/$tdir
4171 $LFS mkdir -i $MDTIDX $remote_dir ||
4172 error "create remote directory failed"
4174 touch $remote_dir/$tfile
4175 chmod 444 $remote_dir/$tfile
4176 chown $RUNAS_ID $remote_dir/$tfile
4178 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4180 chown $RUNAS_ID $remote_dir
4181 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4182 error "create" || true
4183 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4184 error "open RDWR" || true
4185 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4187 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4190 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4194 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4195 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4196 mkdir $DIR/$tdir/local_dir
4198 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4199 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4200 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4202 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4203 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4205 rmdir $DIR/$tdir/* || error "rmdir failed"
4208 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4209 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4210 mkdir $DIR/$tdir/local_dir
4212 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4213 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4214 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4216 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4217 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4219 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4222 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4223 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4224 mkdir $DIR/$tdir/local_dir
4226 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4227 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4228 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4230 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4231 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4233 run_test 33e "mkdir and striped directory should have same mode"
4237 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4241 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4242 remote_mds_nodsh && skip "remote MDS with nodsh"
4245 chmod go+rwx $DIR/$tdir
4246 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4247 trap cleanup_33f EXIT
4249 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4250 error "cannot create striped directory"
4252 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4253 error "cannot create files in striped directory"
4255 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4256 error "cannot remove files in striped directory"
4258 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4259 error "cannot remove striped directory"
4263 run_test 33f "nonroot user can create, access, and remove a striped directory"
4266 mkdir -p $DIR/$tdir/dir2
4268 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4270 [[ $err =~ "exists" ]] || error "Not exists error"
4272 run_test 33g "nonroot user create already existing root created file"
4278 test_mkdir -c $MDSCOUNT -H $hash_type $DIR/$tdir ||
4279 error "lfs mkdir -H $hash_type $tdir failed"
4280 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4282 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4286 for fname in $DIR/$tdir/$tfile.bak \
4287 $DIR/$tdir/$tfile.SAV \
4288 $DIR/$tdir/$tfile.orig \
4289 $DIR/$tdir/$tfile~; do
4290 touch $fname || error "touch $fname failed"
4291 index2=$($LFS getstripe -m $fname)
4292 (( $index == $index2 )) ||
4293 error "$fname MDT index mismatch $index != $index2"
4297 local patterns=(".$tfile.XXXXXX" "$tfile.XXXXXXXX")
4300 for pattern in ${patterns[*]}; do
4301 echo "pattern $pattern"
4302 fname=$DIR/$tdir/$pattern
4303 for (( i = 0; i < $count; i++ )); do
4304 fname=$(mktemp $DIR/$tdir/$pattern) ||
4305 error "mktemp $DIR/$tdir/$pattern failed"
4306 index2=$($LFS getstripe -m $fname)
4307 (( $index == $index2 )) && continue
4309 failed=$((failed + 1))
4310 echo "$fname MDT index mismatch $index != $index2"
4314 echo "$failed/$count MDT index mismatches, expect ~2-4"
4315 (( failed < 10 )) || error "MDT index mismatch $failed/$count times"
4320 # verify that "crush" is still broken with all files on same MDT,
4321 # crush2 should have about 1/MDSCOUNT files on each MDT, with margin
4322 [[ "$hash_type" == "crush" ]] && expect=$count ||
4323 expect=$((count / MDSCOUNT))
4325 # crush2 doesn't put all-numeric suffixes on the same MDT,
4326 # filename like $tfile.12345678 should *not* be considered temp
4327 for pattern in ${patterns[*]}; do
4328 local base=${pattern%%X*}
4329 local suff=${pattern#$base}
4331 echo "pattern $pattern"
4332 for (( i = 0; i < $count; i++ )); do
4333 fname=$DIR/$tdir/$base$((${suff//X/1} + i))
4334 touch $fname || error "touch $fname failed"
4335 index2=$($LFS getstripe -m $fname)
4336 (( $index != $index2 )) && continue
4342 # the number of "bad" hashes is random, as it depends on the random
4343 # filenames generated by "mktemp". Allow some margin in the results.
4344 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4345 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4346 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4347 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4350 # crush2 doesn't put suffixes with special characters on the same MDT
4351 # filename like $tfile.txt.1234 should *not* be considered temp
4352 for pattern in ${patterns[*]}; do
4353 local base=${pattern%%X*}
4354 local suff=${pattern#$base}
4356 pattern=$base...${suff/XXX}
4357 echo "pattern=$pattern"
4358 for (( i = 0; i < $count; i++ )); do
4359 fname=$(mktemp $DIR/$tdir/$pattern) ||
4360 error "touch $fname failed"
4361 index2=$($LFS getstripe -m $fname)
4362 (( $index != $index2 )) && continue
4368 # the number of "bad" hashes is random, as it depends on the random
4369 # filenames generated by "mktemp". Allow some margin in the results.
4370 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4371 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4372 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4373 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4377 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4378 (( $MDS1_VERSION >= $(version_code 2.13.50) )) ||
4379 skip "Need MDS version at least 2.13.50"
4383 run_test 33h "temp file is located on the same MDT as target (crush)"
4386 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4387 echo "MDS1_VERSION=$MDS1_VERSION version_code=$(version_code 2.15.0)"
4388 (( $MDS1_VERSION > $(version_code 2.15.0) )) ||
4389 skip "Need MDS version at least 2.15.0 for crush2"
4393 run_test 33hh "temp file is located on the same MDT as target (crush2)"
4397 (( MDSCOUNT < 2 )) && skip "needs >= 2 MDTs"
4399 local FNAME=$(str_repeat 'f' 250)
4401 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
4402 createmany -o $DIR/$tdir/$FNAME 1000 || error "createmany failed"
4407 count=$($LFS getstripe -m $DIR/$tdir/* | grep -cw 1)
4409 local MDC=$(lctl dl | awk '/MDT0001-mdc-[^M]/ { print $4 }')
4411 lctl --device %$MDC deactivate
4412 stack_trap "lctl --device %$MDC activate"
4413 ls $DIR/$tdir > /dev/null && error "ls should return an error"
4414 total=$(\ls -l $DIR/$tdir | wc -l)
4415 # "ls -l" will list total in the first line
4416 total=$((total - 1))
4417 (( total + count == 1000 )) ||
4418 error "ls list $total files, $count files on MDT1"
4420 run_test 33i "striped directory can be accessed when one MDT is down"
4422 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4425 $MCREATE $DIR/f34 || error "mcreate failed"
4426 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4427 error "getstripe failed"
4428 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4429 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4430 error "getstripe failed"
4431 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4432 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4434 run_test 34a "truncate file that has not been opened ==========="
4437 [ ! -f $DIR/f34 ] && test_34a
4438 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4439 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4440 $OPENFILE -f O_RDONLY $DIR/f34
4441 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4442 error "getstripe failed"
4443 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4444 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4446 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4449 [ ! -f $DIR/f34 ] && test_34a
4450 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4451 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4452 $OPENFILE -f O_RDWR $DIR/f34
4453 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4454 error "$LFS getstripe failed"
4455 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4456 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4458 run_test 34c "O_RDWR opening file-with-size works =============="
4461 [ ! -f $DIR/f34 ] && test_34a
4462 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4464 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4465 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4468 run_test 34d "write to sparse file ============================="
4472 $MCREATE $DIR/f34e || error "mcreate failed"
4473 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4474 $CHECKSTAT -s 1000 $DIR/f34e ||
4475 error "Size of $DIR/f34e not equal to 1000 bytes"
4476 $OPENFILE -f O_RDWR $DIR/f34e
4477 $CHECKSTAT -s 1000 $DIR/f34e ||
4478 error "Size of $DIR/f34e not equal to 1000 bytes"
4480 run_test 34e "create objects, some with size and some without =="
4482 test_34f() { # bug 6242, 6243
4483 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4487 $MCREATE $DIR/f34f || error "mcreate failed"
4488 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4489 dd if=$DIR/f34f of=$TMP/f34f
4490 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4491 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4492 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4493 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4494 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4496 run_test 34f "read from a file with no objects until EOF ======="
4499 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4501 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4503 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4504 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4505 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4506 cancel_lru_locks osc
4507 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4508 error "wrong size after lock cancel"
4510 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4511 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4512 error "expanding truncate failed"
4513 cancel_lru_locks osc
4514 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4515 error "wrong expanded size after lock cancel"
4517 run_test 34g "truncate long file ==============================="
4520 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4525 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4526 sync # Flush the cache so that multiop below does not block on cache
4527 # flush when getting the group lock
4528 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4531 # Since just timed wait is not good enough, let's do a sync write
4532 # that way we are sure enough time for a roundtrip + processing
4533 # passed + 2 seconds of extra margin.
4534 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4538 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4539 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4543 local nsz=`stat -c %s $DIR/$tfile`
4544 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4546 run_test 34h "ftruncate file under grouplock should not block"
4549 cp /bin/sh $DIR/f35a
4551 chown $RUNAS_ID $DIR/f35a
4552 $RUNAS $DIR/f35a && error || true
4555 run_test 35a "exec file with mode 444 (should return and not leak)"
4559 utime $DIR/f36 || error "utime failed for MDS"
4561 run_test 36a "MDS utime check (mknod, utime)"
4565 utime $DIR/f36 || error "utime failed for OST"
4567 run_test 36b "OST utime check (open, utime)"
4572 chown $RUNAS_ID $DIR/d36
4573 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4575 run_test 36c "non-root MDS utime check (mknod, utime)"
4578 [ ! -d $DIR/d36 ] && test_36c
4579 echo "" > $DIR/d36/f36
4580 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4582 run_test 36d "non-root OST utime check (open, utime)"
4585 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4587 test_mkdir $DIR/$tdir
4588 touch $DIR/$tdir/$tfile
4589 $RUNAS utime $DIR/$tdir/$tfile &&
4590 error "utime worked, expected failure" || true
4592 run_test 36e "utime on non-owned file (should return error)"
4596 local LANG_SAVE=$LANG
4597 local LC_LANG_SAVE=$LC_LANG
4598 export LANG=C LC_LANG=C # for date language
4600 DATESTR="Dec 20 2000"
4601 test_mkdir $DIR/$tdir
4602 lctl set_param fail_loc=$fl
4604 cp /etc/hosts $DIR/$tdir/$tfile
4605 sync & # write RPC generated with "current" inode timestamp, but delayed
4607 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4608 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4609 cancel_lru_locks $OSC
4610 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4612 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4613 echo "BEFORE: $LS_BEFORE" && \
4614 echo "AFTER : $LS_AFTER" && \
4615 echo "WANT : $DATESTR" && \
4616 error "$DIR/$tdir/$tfile timestamps changed" || true
4618 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4622 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4624 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4625 subr_36fh "0x80000214"
4627 run_test 36f "utime on file racing with OST BRW write =========="
4630 remote_ost_nodsh && skip "remote OST with nodsh"
4631 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4632 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4633 skip "Need MDS version at least 2.12.51"
4638 local tgt="obdfilter"
4640 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4642 test_mkdir $DIR/$tdir
4643 fmd_max_age=$(do_facet $facet \
4644 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4647 echo "FMD max age: ${fmd_max_age}s"
4648 touch $DIR/$tdir/$tfile
4649 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4650 gawk '{cnt=cnt+$1} END{print cnt}')
4651 echo "FMD before: $fmd"
4653 error "FMD wasn't create by touch"
4654 sleep $((fmd_max_age + 12))
4655 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4656 gawk '{cnt=cnt+$1} END{print cnt}')
4657 echo "FMD after: $fmd"
4659 error "FMD wasn't expired by ping"
4661 run_test 36g "FMD cache expiry ====================="
4664 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4666 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4667 subr_36fh "0x80000227"
4669 run_test 36h "utime on file racing with OST BRW write =========="
4672 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4674 test_mkdir $DIR/$tdir
4675 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4677 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4678 local new_mtime=$((mtime + 200))
4680 #change Modify time of striped dir
4681 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4682 error "change mtime failed"
4684 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4686 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4688 run_test 36i "change mtime on striped directory"
4690 # test_37 - duplicate with tests 32q 32r
4693 local file=$DIR/$tfile
4695 openfile -f O_DIRECTORY $file
4698 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4699 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4701 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4703 test_39a() { # was test_39
4705 touch $DIR/${tfile}2
4706 # ls -l $DIR/$tfile $DIR/${tfile}2
4707 # ls -lu $DIR/$tfile $DIR/${tfile}2
4708 # ls -lc $DIR/$tfile $DIR/${tfile}2
4710 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4711 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4713 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4715 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4717 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4718 error "O_TRUNC didn't change timestamps"
4721 run_test 39a "mtime changed on create"
4724 test_mkdir -c1 $DIR/$tdir
4725 cp -p /etc/passwd $DIR/$tdir/fopen
4726 cp -p /etc/passwd $DIR/$tdir/flink
4727 cp -p /etc/passwd $DIR/$tdir/funlink
4728 cp -p /etc/passwd $DIR/$tdir/frename
4729 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4732 echo "aaaaaa" >> $DIR/$tdir/fopen
4733 echo "aaaaaa" >> $DIR/$tdir/flink
4734 echo "aaaaaa" >> $DIR/$tdir/funlink
4735 echo "aaaaaa" >> $DIR/$tdir/frename
4737 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4738 local link_new=`stat -c %Y $DIR/$tdir/flink`
4739 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4740 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4742 cat $DIR/$tdir/fopen > /dev/null
4743 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4744 rm -f $DIR/$tdir/funlink2
4745 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4747 for (( i=0; i < 2; i++ )) ; do
4748 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4749 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4750 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4751 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4753 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4754 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4755 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4756 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4758 cancel_lru_locks $OSC
4759 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4762 run_test 39b "mtime change on open, link, unlink, rename ======"
4764 # this should be set to past
4765 TEST_39_MTIME=`date -d "1 year ago" +%s`
4771 local mtime0=`stat -c %Y $DIR1/$tfile`
4773 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4774 local mtime1=`stat -c %Y $DIR1/$tfile`
4775 [ "$mtime1" = $TEST_39_MTIME ] || \
4776 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4779 echo hello >> $DIR1/$tfile
4781 local mtime2=`stat -c %Y $DIR1/$tfile`
4782 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4783 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4785 mv $DIR1/$tfile $DIR1/$tfile-1
4787 for (( i=0; i < 2; i++ )) ; do
4788 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4789 [ "$mtime2" = "$mtime3" ] || \
4790 error "mtime ($mtime2) changed (to $mtime3) on rename"
4792 cancel_lru_locks $OSC
4793 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4796 run_test 39c "mtime change on rename ==========================="
4800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4803 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4805 for (( i=0; i < 2; i++ )) ; do
4806 local mtime=`stat -c %Y $DIR1/$tfile`
4807 [ $mtime = $TEST_39_MTIME ] || \
4808 error "mtime($mtime) is not set to $TEST_39_MTIME"
4810 cancel_lru_locks $OSC
4811 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4814 run_test 39d "create, utime, stat =============================="
4818 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4821 local mtime1=`stat -c %Y $DIR1/$tfile`
4823 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4825 for (( i=0; i < 2; i++ )) ; do
4826 local mtime2=`stat -c %Y $DIR1/$tfile`
4827 [ $mtime2 = $TEST_39_MTIME ] || \
4828 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4830 cancel_lru_locks $OSC
4831 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4834 run_test 39e "create, stat, utime, stat ========================"
4838 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4841 mtime1=`stat -c %Y $DIR1/$tfile`
4844 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4846 for (( i=0; i < 2; i++ )) ; do
4847 local mtime2=`stat -c %Y $DIR1/$tfile`
4848 [ $mtime2 = $TEST_39_MTIME ] || \
4849 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4851 cancel_lru_locks $OSC
4852 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4855 run_test 39f "create, stat, sleep, utime, stat ================="
4859 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4861 echo hello >> $DIR1/$tfile
4862 local mtime1=`stat -c %Y $DIR1/$tfile`
4865 chmod o+r $DIR1/$tfile
4867 for (( i=0; i < 2; i++ )) ; do
4868 local mtime2=`stat -c %Y $DIR1/$tfile`
4869 [ "$mtime1" = "$mtime2" ] || \
4870 error "lost mtime: $mtime2, should be $mtime1"
4872 cancel_lru_locks $OSC
4873 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4876 run_test 39g "write, chmod, stat ==============================="
4880 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4886 echo hello >> $DIR1/$tfile
4887 local mtime1=`stat -c %Y $DIR1/$tfile`
4889 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4891 if [ "$d1" != "$d2" ]; then
4892 echo "write and touch not within one second"
4894 for (( i=0; i < 2; i++ )) ; do
4895 local mtime2=`stat -c %Y $DIR1/$tfile`
4896 [ "$mtime2" = $TEST_39_MTIME ] || \
4897 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4899 cancel_lru_locks $OSC
4900 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4904 run_test 39h "write, utime within one second, stat ============="
4907 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4912 echo hello >> $DIR1/$tfile
4913 local mtime1=`stat -c %Y $DIR1/$tfile`
4915 mv $DIR1/$tfile $DIR1/$tfile-1
4917 for (( i=0; i < 2; i++ )) ; do
4918 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4920 [ "$mtime1" = "$mtime2" ] || \
4921 error "lost mtime: $mtime2, should be $mtime1"
4923 cancel_lru_locks $OSC
4924 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4927 run_test 39i "write, rename, stat =============================="
4930 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4932 start_full_debug_logging
4936 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4937 lctl set_param fail_loc=0x80000412
4938 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4939 error "multiop failed"
4941 local mtime1=`stat -c %Y $DIR1/$tfile`
4943 mv $DIR1/$tfile $DIR1/$tfile-1
4945 kill -USR1 $multipid
4946 wait $multipid || error "multiop close failed"
4948 for (( i=0; i < 2; i++ )) ; do
4949 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4950 [ "$mtime1" = "$mtime2" ] ||
4951 error "mtime is lost on close: $mtime2, " \
4955 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4957 lctl set_param fail_loc=0
4958 stop_full_debug_logging
4960 run_test 39j "write, rename, close, stat ======================="
4963 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4968 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4970 local mtime1=`stat -c %Y $DIR1/$tfile`
4972 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4974 kill -USR1 $multipid
4975 wait $multipid || error "multiop close failed"
4977 for (( i=0; i < 2; i++ )) ; do
4978 local mtime2=`stat -c %Y $DIR1/$tfile`
4980 [ "$mtime2" = $TEST_39_MTIME ] || \
4981 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4984 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4987 run_test 39k "write, utime, close, stat ========================"
4989 # this should be set to future
4990 TEST_39_ATIME=`date -d "1 year" +%s`
4993 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4994 remote_mds_nodsh && skip "remote MDS with nodsh"
4996 local atime_diff=$(do_facet $SINGLEMDS \
4997 lctl get_param -n mdd.*MDT0000*.atime_diff)
4999 mkdir_on_mdt0 $DIR/$tdir
5001 # test setting directory atime to future
5002 touch -a -d @$TEST_39_ATIME $DIR/$tdir
5003 local atime=$(stat -c %X $DIR/$tdir)
5004 [ "$atime" = $TEST_39_ATIME ] ||
5005 error "atime is not set to future: $atime, $TEST_39_ATIME"
5007 # test setting directory atime from future to now
5008 local now=$(date +%s)
5009 touch -a -d @$now $DIR/$tdir
5011 atime=$(stat -c %X $DIR/$tdir)
5012 [ "$atime" -eq "$now" ] ||
5013 error "atime is not updated from future: $atime, $now"
5015 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
5018 # test setting directory atime when now > dir atime + atime_diff
5019 local d1=$(date +%s)
5021 local d2=$(date +%s)
5022 cancel_lru_locks mdc
5023 atime=$(stat -c %X $DIR/$tdir)
5024 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5025 error "atime is not updated : $atime, should be $d2"
5027 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
5030 # test not setting directory atime when now < dir atime + atime_diff
5032 cancel_lru_locks mdc
5033 atime=$(stat -c %X $DIR/$tdir)
5034 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5035 error "atime is updated to $atime, should remain $d1<atime<$d2"
5037 do_facet $SINGLEMDS \
5038 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5040 run_test 39l "directory atime update ==========================="
5043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5047 local far_past_mtime=$(date -d "May 29 1953" +%s)
5048 local far_past_atime=$(date -d "Dec 17 1903" +%s)
5050 touch -m -d @$far_past_mtime $DIR1/$tfile
5051 touch -a -d @$far_past_atime $DIR1/$tfile
5053 for (( i=0; i < 2; i++ )) ; do
5054 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
5055 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
5056 error "atime or mtime set incorrectly"
5058 cancel_lru_locks $OSC
5059 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5062 run_test 39m "test atime and mtime before 1970"
5064 test_39n() { # LU-3832
5065 remote_mds_nodsh && skip "remote MDS with nodsh"
5067 local atime_diff=$(do_facet $SINGLEMDS \
5068 lctl get_param -n mdd.*MDT0000*.atime_diff)
5073 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
5076 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
5077 atime0=$(stat -c %X $DIR/$tfile)
5080 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5081 atime1=$(stat -c %X $DIR/$tfile)
5084 cancel_lru_locks mdc
5085 cancel_lru_locks osc
5086 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5087 atime2=$(stat -c %X $DIR/$tfile)
5089 do_facet $SINGLEMDS \
5090 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5092 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
5093 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
5095 run_test 39n "check that O_NOATIME is honored"
5098 TESTDIR=$DIR/$tdir/$tfile
5099 [ -e $TESTDIR ] && rm -rf $TESTDIR
5106 links2=$(stat -c %h .)
5107 [ $(($links1 + 2)) != $links2 ] &&
5108 error "wrong links count $(($links1 + 2)) != $links2"
5110 links3=$(stat -c %h .)
5111 [ $(($links1 + 1)) != $links3 ] &&
5112 error "wrong links count $links1 != $links3"
5115 run_test 39o "directory cached attributes updated after create"
5118 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
5121 TESTDIR=$DIR/$tdir/$tdir
5122 [ -e $TESTDIR ] && rm -rf $TESTDIR
5123 test_mkdir -p $TESTDIR
5127 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
5128 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
5130 links2=$(stat -c %h .)
5131 [ $(($links1 + 2)) != $links2 ] &&
5132 error "wrong links count $(($links1 + 2)) != $links2"
5134 links3=$(stat -c %h .)
5135 [ $(($links1 + 1)) != $links3 ] &&
5136 error "wrong links count $links1 != $links3"
5139 run_test 39p "remote directory cached attributes updated after create ========"
5142 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
5143 skip "no atime update on old OST"
5144 if [ "$ost1_FSTYPE" != ldiskfs ]; then
5145 skip_env "ldiskfs only test"
5149 saved_adiff=$(do_facet ost1 \
5150 lctl get_param -n obdfilter.*OST0000.atime_diff)
5151 stack_trap "do_facet ost1 \
5152 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
5154 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
5156 $LFS setstripe -i 0 $DIR/$tfile
5157 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
5158 error "can't write initial file"
5159 cancel_lru_locks osc
5161 # exceed atime_diff and access file
5163 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
5164 error "can't udpate atime"
5166 local atime_cli=$(stat -c %X $DIR/$tfile)
5167 echo "client atime: $atime_cli"
5168 # allow atime update to be written to device
5169 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
5172 local ostdev=$(ostdevname 1)
5173 local fid=($(lfs getstripe -y $DIR/$tfile |
5174 awk '/l_fid:/ { print $2 }' | tr ':' ' '))
5175 local objpath="O/0/d$((${fid[1]} % 32))/$((${fid[1]}))"
5176 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
5178 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
5179 local atime_ost=$(do_facet ost1 "$cmd" |&
5180 awk -F'[: ]' '/atime:/ { print $4 }')
5181 (( atime_cli == atime_ost )) ||
5182 error "atime on client $atime_cli != ost $atime_ost"
5184 run_test 39r "lazy atime update on OST"
5186 test_39q() { # LU-8041
5187 local testdir=$DIR/$tdir
5189 multiop_bg_pause $testdir D_c || error "multiop failed"
5191 cancel_lru_locks mdc
5192 kill -USR1 $multipid
5193 local atime=$(stat -c %X $testdir)
5194 [ "$atime" -ne 0 ] || error "atime is zero"
5196 run_test 39q "close won't zero out atime"
5199 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5200 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5201 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5202 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5203 error "$tfile is not 4096 bytes in size"
5205 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5209 small_write $DIR/f41 18
5211 run_test 41 "test small file write + fstat ====================="
5213 count_ost_writes() {
5214 lctl get_param -n ${OSC}.*.stats |
5215 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5216 END { printf("%0.0f", writes) }'
5223 BG_DIRTY_RATIO_SAVE=10
5224 MAX_BG_DIRTY_RATIO=25
5228 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5229 # dirty_ratio, dirty_background_ratio
5230 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5231 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5232 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5233 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5235 # if file not here, we are a 2.4 kernel
5236 kill -CONT `pidof kupdated`
5241 # setup the trap first, so someone cannot exit the test at the
5242 # exact wrong time and mess up a machine
5243 trap start_writeback EXIT
5244 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5245 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5246 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5247 sysctl -w vm.dirty_writeback_centisecs=0
5248 sysctl -w vm.dirty_writeback_centisecs=0
5249 # save and increase /proc/sys/vm/dirty_ratio
5250 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5251 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5252 # save and increase /proc/sys/vm/dirty_background_ratio
5253 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5254 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5256 # if file not here, we are a 2.4 kernel
5257 kill -STOP `pidof kupdated`
5261 # ensure that all stripes have some grant before we test client-side cache
5263 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5264 dd if=/dev/zero of=$i bs=4k count=1
5269 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5270 # file truncation, and file removal.
5272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5275 cancel_lru_locks $OSC
5277 sync; sleep 1; sync # just to be safe
5278 BEFOREWRITES=`count_ost_writes`
5279 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5280 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5281 AFTERWRITES=`count_ost_writes`
5282 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5283 error "$BEFOREWRITES < $AFTERWRITES"
5286 run_test 42a "ensure that we don't flush on close"
5289 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5292 cancel_lru_locks $OSC
5295 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5296 BEFOREWRITES=$(count_ost_writes)
5297 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
5298 AFTERWRITES=$(count_ost_writes)
5299 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5300 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5302 BEFOREWRITES=$(count_ost_writes)
5303 sync || error "sync: $?"
5304 AFTERWRITES=$(count_ost_writes)
5305 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5306 error "$BEFOREWRITES < $AFTERWRITES on sync"
5308 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5312 run_test 42b "test destroy of file with cached dirty data ======"
5314 # if these tests just want to test the effect of truncation,
5315 # they have to be very careful. consider:
5316 # - the first open gets a {0,EOF}PR lock
5317 # - the first write conflicts and gets a {0, count-1}PW
5318 # - the rest of the writes are under {count,EOF}PW
5319 # - the open for truncate tries to match a {0,EOF}PR
5320 # for the filesize and cancels the PWs.
5321 # any number of fixes (don't get {0,EOF} on open, match
5322 # composite locks, do smarter file size management) fix
5323 # this, but for now we want these tests to verify that
5324 # the cancellation with truncate intent works, so we
5325 # start the file with a full-file pw lock to match against
5326 # until the truncate.
5331 cancel_lru_locks $OSC
5333 # prime the file with 0,EOF PW to match
5337 # now the real test..
5338 dd if=/dev/zero of=$file bs=1024 count=100
5339 BEFOREWRITES=`count_ost_writes`
5340 $TRUNCATE $file $offset
5341 cancel_lru_locks $OSC
5342 AFTERWRITES=`count_ost_writes`
5347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5350 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5351 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5354 run_test 42c "test partial truncate of file with cached dirty data"
5357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5359 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
5360 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
5361 $LCTL set_param debug=+cache
5364 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5365 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5368 run_test 42d "test complete truncate of file with cached dirty data"
5370 test_42e() { # bug22074
5371 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5373 local TDIR=$DIR/${tdir}e
5374 local pages=16 # hardcoded 16 pages, don't change it.
5375 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5376 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5380 test_mkdir $DIR/${tdir}e
5381 $LFS setstripe -c 1 $TDIR
5382 createmany -o $TDIR/f $files
5384 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5386 # we assume that with $OSTCOUNT files, at least one of them will
5387 # be allocated on OST0.
5388 warmup_files=$((OSTCOUNT * max_dirty_mb))
5389 createmany -o $TDIR/w $warmup_files
5391 # write a large amount of data into one file and sync, to get good
5392 # avail_grant number from OST.
5393 for ((i=0; i<$warmup_files; i++)); do
5394 idx=$($LFS getstripe -i $TDIR/w$i)
5395 [ $idx -ne 0 ] && continue
5396 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5399 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5401 $LCTL get_param $proc_osc0/cur_dirty_bytes
5402 $LCTL get_param $proc_osc0/cur_grant_bytes
5404 # create as much dirty pages as we can while not to trigger the actual
5405 # RPCs directly. but depends on the env, VFS may trigger flush during this
5406 # period, hopefully we are good.
5407 for ((i=0; i<$warmup_files; i++)); do
5408 idx=$($LFS getstripe -i $TDIR/w$i)
5409 [ $idx -ne 0 ] && continue
5410 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5412 $LCTL get_param $proc_osc0/cur_dirty_bytes
5413 $LCTL get_param $proc_osc0/cur_grant_bytes
5415 # perform the real test
5416 $LCTL set_param $proc_osc0/rpc_stats 0
5417 for ((;i<$files; i++)); do
5418 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5419 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5422 $LCTL get_param $proc_osc0/rpc_stats
5425 local have_ppr=false
5426 $LCTL get_param $proc_osc0/rpc_stats |
5427 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5428 # skip lines until we are at the RPC histogram data
5429 [ "$PPR" == "pages" ] && have_ppr=true && continue
5430 $have_ppr || continue
5432 # we only want the percent stat for < 16 pages
5433 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5435 percent=$((percent + WPCT))
5436 if [[ $percent -gt 15 ]]; then
5437 error "less than 16-pages write RPCs" \
5444 run_test 42e "verify sub-RPC writes are not done synchronously"
5446 test_43A() { # was test_43
5447 test_mkdir $DIR/$tdir
5448 cp -p /bin/ls $DIR/$tdir/$tfile
5449 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5451 # give multiop a chance to open
5454 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5456 # Wait for multiop to exit
5459 run_test 43A "execution of file opened for write should return -ETXTBSY"
5462 test_mkdir $DIR/$tdir
5463 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5464 $DIR/$tdir/sleep 60 &
5466 # Make sure exec of $tdir/sleep wins race with truncate
5468 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5471 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5476 test_mkdir $DIR/$tdir
5477 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5478 $DIR/$tdir/sleep 60 &
5480 # Make sure exec of $tdir/sleep wins race with truncate
5482 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5485 run_test 43b "truncate of file being executed should return -ETXTBSY"
5488 local testdir="$DIR/$tdir"
5491 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5492 ( cd $testdir && md5sum -c )
5494 run_test 43c "md5sum of copy into lustre"
5496 test_44A() { # was test_44
5497 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5499 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5500 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5502 run_test 44A "zero length read from a sparse stripe"
5505 local nstripe=$($LFS getstripe -c -d $DIR)
5506 [ -z "$nstripe" ] && skip "can't get stripe info"
5507 [[ $nstripe -gt $OSTCOUNT ]] &&
5508 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5510 local stride=$($LFS getstripe -S -d $DIR)
5511 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5512 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5515 OFFSETS="0 $((stride/2)) $((stride-1))"
5516 for offset in $OFFSETS; do
5517 for i in $(seq 0 $((nstripe-1))); do
5518 local GLOBALOFFSETS=""
5520 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5521 local myfn=$DIR/d44a-$size
5522 echo "--------writing $myfn at $size"
5523 ll_sparseness_write $myfn $size ||
5524 error "ll_sparseness_write"
5525 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5526 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5527 error "ll_sparseness_verify $GLOBALOFFSETS"
5529 for j in $(seq 0 $((nstripe-1))); do
5531 size=$((((j + $nstripe )*$stride + $offset)))
5532 ll_sparseness_write $myfn $size ||
5533 error "ll_sparseness_write"
5534 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5536 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5537 error "ll_sparseness_verify $GLOBALOFFSETS"
5542 run_test 44a "test sparse pwrite ==============================="
5546 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5552 before=`dirty_osc_total`
5553 echo executing "\"$*\""
5555 after=`dirty_osc_total`
5556 echo before $before, after $after
5559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5562 # Obtain grants from OST if it supports it
5563 echo blah > ${f}_grant
5566 do_dirty_record "echo blah > $f"
5567 [[ $before -eq $after ]] && error "write wasn't cached"
5568 do_dirty_record "> $f"
5569 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5570 do_dirty_record "echo blah > $f"
5571 [[ $before -eq $after ]] && error "write wasn't cached"
5572 do_dirty_record "sync"
5573 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5574 do_dirty_record "echo blah > $f"
5575 [[ $before -eq $after ]] && error "write wasn't cached"
5576 do_dirty_record "cancel_lru_locks osc"
5577 [[ $before -gt $after ]] ||
5578 error "lock cancellation didn't lower dirty count"
5581 run_test 45 "osc io page accounting ============================"
5583 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5584 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5585 # objects offset and an assert hit when an rpc was built with 1023's mapped
5586 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5593 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5595 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5596 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5600 run_test 46 "dirtying a previously written page ================"
5602 # test_47 is removed "Device nodes check" is moved to test_28
5604 test_48a() { # bug 2399
5605 [ "$mds1_FSTYPE" = "zfs" ] &&
5606 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5607 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5609 test_mkdir $DIR/$tdir
5611 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5612 test_mkdir $DIR/$tdir
5613 touch foo || error "'touch foo' failed after recreating cwd"
5615 touch .foo || error "'touch .foo' failed after recreating cwd"
5617 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5618 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5619 cd . || error "'cd .' failed after recreating cwd"
5620 mkdir . && error "'mkdir .' worked after recreating cwd"
5621 rmdir . && error "'rmdir .' worked after recreating cwd"
5622 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5623 cd .. || error "'cd ..' failed after recreating cwd"
5625 run_test 48a "Access renamed working dir (should return errors)="
5627 test_48b() { # bug 2399
5629 test_mkdir $DIR/$tdir
5631 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5632 touch foo && error "'touch foo' worked after removing cwd"
5633 mkdir foo && error "'mkdir foo' worked after removing cwd"
5634 touch .foo && error "'touch .foo' worked after removing cwd"
5635 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5636 ls . > /dev/null && error "'ls .' worked after removing cwd"
5637 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5638 mkdir . && error "'mkdir .' worked after removing cwd"
5639 rmdir . && error "'rmdir .' worked after removing cwd"
5640 ln -s . foo && error "'ln -s .' worked after removing cwd"
5641 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5643 run_test 48b "Access removed working dir (should return errors)="
5645 test_48c() { # bug 2350
5646 #lctl set_param debug=-1
5649 test_mkdir -p $DIR/$tdir/dir
5651 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5652 $TRACE touch foo && error "touch foo worked after removing cwd"
5653 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5654 touch .foo && error "touch .foo worked after removing cwd"
5655 mkdir .foo && error "mkdir .foo worked after removing cwd"
5656 $TRACE ls . && error "'ls .' worked after removing cwd"
5657 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5658 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5659 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5660 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5661 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5663 run_test 48c "Access removed working subdir (should return errors)"
5665 test_48d() { # bug 2350
5666 #lctl set_param debug=-1
5669 test_mkdir -p $DIR/$tdir/dir
5671 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5672 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5673 $TRACE touch foo && error "'touch foo' worked after removing parent"
5674 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5675 touch .foo && error "'touch .foo' worked after removing parent"
5676 mkdir .foo && error "mkdir .foo worked after removing parent"
5677 $TRACE ls . && error "'ls .' worked after removing parent"
5678 $TRACE ls .. && error "'ls ..' worked after removing parent"
5679 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5680 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5681 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5684 run_test 48d "Access removed parent subdir (should return errors)"
5686 test_48e() { # bug 4134
5687 #lctl set_param debug=-1
5690 test_mkdir -p $DIR/$tdir/dir
5692 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5693 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5694 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5695 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5696 # On a buggy kernel addition of "touch foo" after cd .. will
5697 # produce kernel oops in lookup_hash_it
5698 touch ../foo && error "'cd ..' worked after recreate parent"
5700 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5702 run_test 48e "Access to recreated parent subdir (should return errors)"
5705 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5706 skip "need MDS >= 2.13.55"
5707 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5708 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5709 skip "needs different host for mdt1 mdt2"
5710 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5712 $LFS mkdir -i0 $DIR/$tdir
5713 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5715 for d in sub1 sub2 sub3; do
5716 #define OBD_FAIL_OSD_REF_DEL 0x19c
5717 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5718 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5721 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5723 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5725 test_49() { # LU-1030
5726 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5727 remote_ost_nodsh && skip "remote OST with nodsh"
5729 # get ost1 size - $FSNAME-OST0000
5730 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5732 # write 800M at maximum
5733 [[ $ost1_size -lt 2 ]] && ost1_size=2
5734 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5736 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5737 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5740 # change max_pages_per_rpc while writing the file
5741 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5742 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5743 # loop until dd process exits
5744 while ps ax -opid | grep -wq $dd_pid; do
5745 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5746 sleep $((RANDOM % 5 + 1))
5748 # restore original max_pages_per_rpc
5749 $LCTL set_param $osc1_mppc=$orig_mppc
5750 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5752 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5756 test_mkdir $DIR/$tdir
5758 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5760 run_test 50 "special situations: /proc symlinks ==============="
5762 test_51a() { # was test_51
5763 # bug 1516 - create an empty entry right after ".." then split dir
5764 test_mkdir -c1 $DIR/$tdir
5765 touch $DIR/$tdir/foo
5766 $MCREATE $DIR/$tdir/bar
5768 createmany -m $DIR/$tdir/longfile 201
5770 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5771 $MCREATE $DIR/$tdir/longfile$FNUM
5776 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5778 run_test 51a "special situations: split htree with empty entry =="
5780 cleanup_print_lfs_df () {
5787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5789 local dir=$DIR/$tdir
5790 local nrdirs=$((65536 + 100))
5792 # cleanup the directory
5795 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5799 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5800 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5801 [[ $numfree -lt $nrdirs ]] &&
5802 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5804 # need to check free space for the directories as well
5805 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5806 numfree=$(( blkfree / $(fs_inode_ksize) ))
5807 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5809 trap cleanup_print_lfs_df EXIT
5812 createmany -d $dir/d $nrdirs || {
5813 unlinkmany $dir/d $nrdirs
5814 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5818 nrdirs=$(ls -U $dir | wc -l)
5820 # unlink all but 100 subdirectories, then check it still works
5822 local delete=$((nrdirs - left))
5827 # for ldiskfs the nlink count should be 1, but this is OSD specific
5828 # and so this is listed for informational purposes only
5829 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5830 unlinkmany -d $dir/d $delete ||
5831 error "unlink of first $delete subdirs failed"
5833 echo "nlink between: $(stat -c %h $dir)"
5834 local found=$(ls -U $dir | wc -l)
5835 [ $found -ne $left ] &&
5836 error "can't find subdirs: found only $found, expected $left"
5838 unlinkmany -d $dir/d $delete $left ||
5839 error "unlink of second $left subdirs failed"
5840 # regardless of whether the backing filesystem tracks nlink accurately
5841 # or not, the nlink count shouldn't be more than "." and ".." here
5842 local after=$(stat -c %h $dir)
5843 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5844 echo "nlink after: $after"
5846 cleanup_print_lfs_df
5848 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5851 local stripecount=$1
5854 log "create files with stripecount=$stripecount"
5855 $LFS setstripe -C $stripecount $DIR/$tdir
5856 createmany -o $DIR/$tdir/t- $nfiles
5857 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5858 for ((n = 0; n < $OSTCOUNT; n++)); do
5859 objs[$n]=$(awk -vobjs=0 '($1 == '$n') { objs += 1 } \
5860 END { printf("%0.0f", objs) }' $TMP/$tfile)
5861 objs0[$n]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5862 '($1 == '$n') { objs += 1 } \
5863 END { printf("%0.0f", objs) }')
5864 log "OST$n has ${objs[$n]} objects, ${objs0[$n]} are index 0"
5866 unlinkmany $DIR/$tdir/t- $nfiles
5871 local max=6 # allow variance of (1 - $min/$max) = 33% by default
5873 # For some combinations of stripecount and OSTCOUNT current code
5874 # is not ideal, and allocates 50% fewer *first* objects to some OSTs
5875 # than others. Rather than skipping this test entirely, check that
5876 # and keep testing to ensure imbalance does not get worse. LU-15282
5877 (( (OSTCOUNT == 6 && stripecount == 4) ||
5878 (OSTCOUNT == 10 && (stripecount == 4 || stripecount == 8)) ||
5879 (OSTCOUNT == 12 && (stripecount == 8 || stripecount == 9)))) && max=9
5880 for ((nlast=0, n = 1; n < $OSTCOUNT; nlast=n,n++)); do
5881 (( ${objs[$n]} > ${objs[$nlast]} * 4 / 5 )) ||
5882 { $LFS df && $LFS df -i &&
5883 error "stripecount=$stripecount: " \
5884 "OST $n has fewer objects vs. OST $nlast " \
5885 "(${objs[$n]} < ${objs[$nlast]} x 4/5)"; }
5886 (( ${objs[$n]} < ${objs[$nlast]} * 5 / 4 )) ||
5887 { $LFS df && $LFS df -i &&
5888 error "stripecount=$stripecount: " \
5889 "OST $n has more objects vs. OST $nlast " \
5890 "(${objs[$n]} > ${objs[$nlast]} x 5/4)"; }
5892 (( ${objs0[$n]} > ${objs0[$nlast]} * $min / $max )) ||
5893 { $LFS df && $LFS df -i &&
5894 error "stripecount=$stripecount: " \
5895 "OST $n has fewer #0 objects vs. OST $nlast " \
5896 "(${objs0[$n]} < ${objs0[$nlast]} x $min/$max)"; }
5897 (( ${objs0[$n]} < ${objs0[$nlast]} * $max / $min )) ||
5898 { $LFS df && $LFS df -i &&
5899 error "stripecount=$stripecount: " \
5900 "OST $n has more #0 objects vs. OST $nlast " \
5901 "(${objs0[$n]} > ${objs0[$nlast]} x $max/$min)"; }
5906 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5907 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5911 local nfiles=$((per_ost * OSTCOUNT))
5912 local mdts=$(comma_list $(mdts_nodes))
5913 local param="osp.*.create_count"
5914 local qos_old=$(do_facet mds1 \
5915 "$LCTL get_param -n lod.$FSNAME-*.qos_threshold_rr" | head -n 1)
5918 "$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=100"
5919 stack_trap "do_nodes $mdts \
5920 '$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=${qos_old%%%}'"
5922 test_mkdir $DIR/$tdir
5923 local dirstripes=$(lfs getdirstripe -c $DIR/$tdir)
5924 (( dirstripes > 0 )) || dirstripes=1
5926 # Ensure enough OST objects precreated for tests to pass without
5927 # running out of objects. This is an LOV r-r OST algorithm test,
5928 # not an OST object precreation test.
5929 local old=$(do_facet mds1 "$LCTL get_param -n $param" | head -n 1)
5930 (( old >= nfiles )) ||
5932 local create_count=$((nfiles * OSTCOUNT / dirstripes))
5934 do_nodes $mdts "$LCTL set_param $param=$create_count"
5935 stack_trap "do_nodes $mdts $LCTL set_param $param=$old"
5937 # trigger precreation from all MDTs for all OSTs
5938 for ((i = 0; i < $MDSCOUNT * 2; i++ )); do
5939 $LFS setstripe -c -1 $DIR/$tdir/wide.$i
5943 for ((stripecount = 3; stripecount <= $OSTCOUNT; stripecount++)); do
5944 sleep 8 # allow object precreation to catch up
5945 test_51d_sub $stripecount $nfiles
5948 run_test 51d "check LOV round-robin OST object distribution"
5951 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5952 skip_env "ldiskfs only test"
5955 test_mkdir -c1 $DIR/$tdir
5956 test_mkdir -c1 $DIR/$tdir/d0
5958 touch $DIR/$tdir/d0/foo
5959 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5960 error "file exceed 65000 nlink limit!"
5961 unlinkmany $DIR/$tdir/d0/f- 65001
5964 run_test 51e "check file nlink limit"
5967 test_mkdir $DIR/$tdir
5970 local ulimit_old=$(ulimit -n)
5971 local spare=20 # number of spare fd's for scripts/libraries, etc.
5972 local mdt=$($LFS getstripe -m $DIR/$tdir)
5973 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5975 echo "MDT$mdt numfree=$numfree, max=$max"
5976 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5977 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5978 while ! ulimit -n $((numfree + spare)); do
5979 numfree=$((numfree * 3 / 4))
5981 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5983 echo "left ulimit at $ulimit_old"
5986 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5987 unlinkmany $DIR/$tdir/f $numfree
5988 error "create+open $numfree files in $DIR/$tdir failed"
5990 ulimit -n $ulimit_old
5992 # if createmany exits at 120s there will be fewer than $numfree files
5993 unlinkmany $DIR/$tdir/f $numfree || true
5995 run_test 51f "check many open files limit"
5998 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5999 test_mkdir $DIR/$tdir
6000 touch $DIR/$tdir/foo
6001 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
6002 echo bar >> $DIR/$tdir/foo || error "append bar failed"
6003 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6004 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6005 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6007 echo foo >> $DIR/$tdir/foo || error "append foo failed"
6008 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6009 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
6011 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
6012 cp -r $DIR/$tdir $TMP/
6013 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
6015 run_test 52a "append-only flag test (should return errors)"
6018 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
6019 test_mkdir $DIR/$tdir
6020 touch $DIR/$tdir/foo
6021 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
6022 cat test > $DIR/$tdir/foo && error "cat test worked"
6023 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6024 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6025 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6027 echo foo >> $DIR/$tdir/foo && error "echo worked"
6028 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6029 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
6030 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
6031 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
6033 chattr -i $DIR/$tdir/foo || error "chattr failed"
6035 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
6037 run_test 52b "immutable flag test (should return errors) ======="
6040 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6041 remote_mds_nodsh && skip "remote MDS with nodsh"
6042 remote_ost_nodsh && skip "remote OST with nodsh"
6055 local support_last_seq=true
6057 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
6058 support_last_seq=false
6061 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
6063 for value in $(do_facet $SINGLEMDS \
6064 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
6065 param=$(echo ${value[0]} | cut -d "=" -f1)
6066 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
6068 if $support_last_seq; then
6069 param_seq=$(echo $param |
6070 sed -e s/prealloc_last_id/prealloc_last_seq/g)
6071 mds_last_seq=$(do_facet $SINGLEMDS \
6072 $LCTL get_param -n $param_seq)
6074 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
6076 ostnum=$(index_from_ostuuid ${ostname}_UUID)
6077 node=$(facet_active_host ost$((ostnum+1)))
6078 param="obdfilter.$ostname.last_id"
6079 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
6080 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
6081 ost_last_id=$ost_last
6083 if $support_last_seq; then
6084 ost_last_id=$(echo $ost_last |
6085 awk -F':' '{print $2}' |
6087 ost_last_seq=$(echo $ost_last |
6088 awk -F':' '{print $1}')
6089 [[ $ost_last_seq = $mds_last_seq ]] || continue
6092 if [[ $ost_last_id != $mds_last ]]; then
6093 error "$ost_last_id != $mds_last"
6100 $found || error "can not match last_seq/last_id for $mdtosc"
6103 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
6106 perl -MSocket -e ';' || skip "no Socket perl module installed"
6108 $SOCKETSERVER $DIR/socket ||
6109 error "$SOCKETSERVER $DIR/socket failed: $?"
6110 $SOCKETCLIENT $DIR/socket ||
6111 error "$SOCKETCLIENT $DIR/socket failed: $?"
6112 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
6114 run_test 54a "unix domain socket test =========================="
6120 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
6122 run_test 54b "char device works in lustre ======================"
6125 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
6126 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
6127 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
6129 for i in $(seq 3 7); do
6130 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
6139 loopdev="$DIR/loop54c"
6142 $UMOUNT $DIR/$tdir || rc=$?
6143 losetup -d $loopdev || true
6144 losetup -d $LOOPDEV || true
6145 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
6150 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6152 loopdev="$DIR/loop54c"
6155 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
6156 trap cleanup_54c EXIT
6157 mknod $loopdev b 7 $LOOPNUM
6158 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
6159 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
6160 losetup $loopdev $DIR/$tfile ||
6161 error "can't set up $loopdev for $DIR/$tfile"
6162 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
6163 test_mkdir $DIR/$tdir
6164 mount -t ext2 $loopdev $DIR/$tdir ||
6165 error "error mounting $loopdev on $DIR/$tdir"
6166 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
6169 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
6173 run_test 54c "block device works in lustre ====================="
6176 local pipe="$DIR/$tfile.pipe"
6177 local string="aaaaaa"
6180 echo -n "$string" > $pipe &
6181 local result=$(cat $pipe)
6182 [[ "$result" == "$string" ]] || error "$result != $string"
6184 run_test 54d "fifo device works in lustre ======================"
6189 cp -aL /dev/console $f
6190 echo $string > $f || error "echo $string to $f failed"
6192 run_test 54e "console/tty device works in lustre ======================"
6197 local dir=$DIR/$tdir
6200 test_mkdir -p $dir/dir
6201 for i in $(seq $numfiles); do
6203 touch $dir/dir/file$i
6206 local numcomp=$($LFS getstripe --component-count $dir)
6208 [[ $numcomp == 0 ]] && numcomp=1
6210 # test lfs getstripe with --recursive
6211 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
6213 [[ $filenum -eq $((numfiles * 2)) ]] ||
6214 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
6215 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
6216 [[ $filenum -eq $numfiles ]] ||
6217 error "$LFS getstripe $dir: found $filenum, not $numfiles"
6218 echo "$LFS getstripe showed obdidx or l_ost_idx"
6220 # test lfs getstripe with file instead of dir
6221 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
6222 [[ $filenum -eq 1 ]] ||
6223 error "$LFS getstripe $dir/file1: found $filenum, not 1"
6224 echo "$LFS getstripe file1 passed"
6226 #test lfs getstripe with --verbose
6227 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
6228 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
6229 error "$LFS getstripe --verbose $dir: "\
6230 "got $filenum want $((numfiles * numcomp)) lmm_magic"
6231 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
6232 error "$LFS getstripe $dir: showed lmm_magic"
6234 #test lfs getstripe with -v prints lmm_fid
6235 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
6236 local countfids=$((numdirs + numfiles * numcomp))
6237 [[ $filenum -eq $countfids ]] ||
6238 error "$LFS getstripe -v $dir: "\
6239 "got $filenum want $countfids lmm_fid"
6240 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
6241 error "$LFS getstripe $dir: showed lmm_fid by default"
6242 echo "$LFS getstripe --verbose passed"
6244 #check for FID information
6245 local fid1=$($LFS getstripe --fid $dir/file1)
6246 local fid2=$($LFS getstripe --verbose $dir/file1 |
6247 awk '/lmm_fid: / { print $2; exit; }')
6248 local fid3=$($LFS path2fid $dir/file1)
6250 [ "$fid1" != "$fid2" ] &&
6251 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
6252 [ "$fid1" != "$fid3" ] &&
6253 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
6254 echo "$LFS getstripe --fid passed"
6256 #test lfs getstripe with --obd
6257 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6258 error "$LFS getstripe --obd wrong_uuid: should return error"
6260 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6263 local obduuid=$(ostuuid_from_index $ostidx)
6264 local found=$($LFS getstripe -r --obd $obduuid $dir |
6265 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6267 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6268 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6270 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6273 [[ $found -eq $filenum ]] ||
6274 error "$LFS getstripe --obd: found $found expect $filenum"
6275 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6276 sed '/^[ ]*'${ostidx}'[ ]/d' |
6277 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6278 error "$LFS getstripe --obd: should not show file on other obd"
6279 echo "$LFS getstripe --obd passed"
6281 run_test 56a "check $LFS getstripe"
6284 local dir=$DIR/$tdir
6288 for i in $(seq $numdirs); do
6289 test_mkdir $dir/dir$i
6292 # test lfs getdirstripe default mode is non-recursion, which is
6293 # different from lfs getstripe
6294 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6296 [[ $dircnt -eq 1 ]] ||
6297 error "$LFS getdirstripe: found $dircnt, not 1"
6298 dircnt=$($LFS getdirstripe --recursive $dir |
6299 grep -c lmv_stripe_count)
6300 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6301 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6303 run_test 56b "check $LFS getdirstripe"
6306 remote_ost_nodsh && skip "remote OST with nodsh"
6309 local ost_name=$(ostname_from_index $ost_idx)
6310 local old_status=$(ost_dev_status $ost_idx)
6311 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6313 [[ -z "$old_status" ]] ||
6314 skip_env "OST $ost_name is in $old_status status"
6316 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6317 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6318 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6319 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6320 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6321 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6324 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6325 error "$LFS df -v showing inactive devices"
6328 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6330 [[ "$new_status" =~ "D" ]] ||
6331 error "$ost_name status is '$new_status', missing 'D'"
6332 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6333 [[ "$new_status" =~ "N" ]] ||
6334 error "$ost_name status is '$new_status', missing 'N'"
6336 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6337 [[ "$new_status" =~ "f" ]] ||
6338 error "$ost_name status is '$new_status', missing 'f'"
6341 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6342 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6343 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6344 [[ -z "$p" ]] && restore_lustre_params < $p || true
6347 new_status=$(ost_dev_status $ost_idx)
6348 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6349 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6350 # can't check 'f' as devices may actually be on flash
6352 run_test 56c "check 'lfs df' showing device status"
6355 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6356 local osts=$($LFS df -v $MOUNT | grep -c OST)
6360 (( mdts == MDSCOUNT )) ||
6361 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6362 (( osts == OSTCOUNT )) ||
6363 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6365 run_test 56d "'lfs df -v' prints only configured devices"
6368 err_enoent=2 # No such file or directory
6369 err_eopnotsupp=95 # Operation not supported
6371 enoent_mnt=/pmt1 # Invalid dentry. Path not present
6372 notsup_mnt=/tmp # Valid dentry, but Not a lustreFS
6374 # Check for handling of path not exists
6375 output=$($LFS df $enoent_mnt 2>&1)
6378 fs=$(echo $output | awk -F: '{print $2}' | awk '{print $3}' | tr -d \')
6379 [[ $fs = $enoent_mnt && $ret -eq $err_enoent ]] ||
6380 error "expect failure $err_enoent, not $ret"
6382 # Check for handling of non-Lustre FS
6383 output=$($LFS df $notsup_mnt)
6386 fs=$(echo $output | awk '{print $1}' | awk -F: '{print $2}')
6387 [[ $fs = $notsup_mnt && $ret -eq $err_eopnotsupp ]] ||
6388 error "expect success $err_eopnotsupp, not $ret"
6390 # Check for multiple LustreFS argument
6391 output=$($LFS df $MOUNT $MOUNT $MOUNT | grep -c "filesystem_summary:")
6394 [[ $output -eq 3 && $ret -eq 0 ]] ||
6395 error "expect success 3, not $output, rc = $ret"
6397 # Check for correct non-Lustre FS handling among multiple
6399 output=$($LFS df $MOUNT $notsup_mnt $MOUNT |
6400 grep -c "filesystem_summary:"; exit ${PIPESTATUS[0]})
6403 [[ $output -eq 2 && $ret -eq $err_eopnotsupp ]] ||
6404 error "expect success 2, not $output, rc = $ret"
6406 run_test 56e "'lfs df' Handle non LustreFS & multiple LustreFS"
6411 local local_tdir="$1"
6412 local local_numfiles="$2"
6413 local local_numdirs="$3"
6414 local dir_params="$4"
6415 local dir_stripe_params="$5"
6417 if [ ! -d "$local_tdir" ] ; then
6418 test_mkdir -p $dir_stripe_params $local_tdir
6419 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6420 for i in $(seq $local_numfiles) ; do
6421 touch $local_tdir/file$i
6423 for i in $(seq $local_numdirs) ; do
6424 test_mkdir $dir_stripe_params $local_tdir/dir$i
6425 for j in $(seq $local_numfiles) ; do
6426 touch $local_tdir/dir$i/file$j
6432 setup_56_special() {
6434 local local_numfiles=$2
6435 local local_numdirs=$3
6437 setup_56 $local_tdir $local_numfiles $local_numdirs
6439 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6440 for i in $(seq $local_numfiles) ; do
6441 mknod $local_tdir/loop${i}b b 7 $i
6442 mknod $local_tdir/null${i}c c 1 3
6443 ln -s $local_tdir/file1 $local_tdir/link${i}
6445 for i in $(seq $local_numdirs) ; do
6446 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6447 mknod $local_tdir/dir$i/null${i}c c 1 3
6448 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6454 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6455 local expected=$(($NUMDIRS + 2))
6457 setup_56 $dir $NUMFILES $NUMDIRS
6459 # test lfs find with -name
6460 for i in $(seq $NUMFILES) ; do
6461 local nums=$($LFS find -name "*$i" $dir | wc -l)
6463 [ $nums -eq $expected ] ||
6464 error "lfs find -name '*$i' $dir wrong: "\
6465 "found $nums, expected $expected"
6468 run_test 56g "check lfs find -name"
6471 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6472 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6474 setup_56 $dir $NUMFILES $NUMDIRS
6476 # test lfs find with ! -name
6477 for i in $(seq $NUMFILES) ; do
6478 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6480 [ $nums -eq $expected ] ||
6481 error "lfs find ! -name '*$i' $dir wrong: "\
6482 "found $nums, expected $expected"
6485 run_test 56h "check lfs find ! -name"
6488 local dir=$DIR/$tdir
6492 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6495 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6497 run_test 56i "check 'lfs find -ost UUID' skips directories"
6500 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6502 setup_56_special $dir $NUMFILES $NUMDIRS
6504 local expected=$((NUMDIRS + 1))
6505 local cmd="$LFS find -type d $dir"
6506 local nums=$($cmd | wc -l)
6508 [ $nums -eq $expected ] ||
6509 error "'$cmd' wrong: found $nums, expected $expected"
6511 run_test 56j "check lfs find -type d"
6514 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6516 setup_56_special $dir $NUMFILES $NUMDIRS
6518 local expected=$(((NUMDIRS + 1) * NUMFILES))
6519 local cmd="$LFS find -type f $dir"
6520 local nums=$($cmd | wc -l)
6522 [ $nums -eq $expected ] ||
6523 error "'$cmd' wrong: found $nums, expected $expected"
6525 run_test 56k "check lfs find -type f"
6528 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6530 setup_56_special $dir $NUMFILES $NUMDIRS
6532 local expected=$((NUMDIRS + NUMFILES))
6533 local cmd="$LFS find -type b $dir"
6534 local nums=$($cmd | wc -l)
6536 [ $nums -eq $expected ] ||
6537 error "'$cmd' wrong: found $nums, expected $expected"
6539 run_test 56l "check lfs find -type b"
6542 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6544 setup_56_special $dir $NUMFILES $NUMDIRS
6546 local expected=$((NUMDIRS + NUMFILES))
6547 local cmd="$LFS find -type c $dir"
6548 local nums=$($cmd | wc -l)
6549 [ $nums -eq $expected ] ||
6550 error "'$cmd' wrong: found $nums, expected $expected"
6552 run_test 56m "check lfs find -type c"
6555 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6556 setup_56_special $dir $NUMFILES $NUMDIRS
6558 local expected=$((NUMDIRS + NUMFILES))
6559 local cmd="$LFS find -type l $dir"
6560 local nums=$($cmd | wc -l)
6562 [ $nums -eq $expected ] ||
6563 error "'$cmd' wrong: found $nums, expected $expected"
6565 run_test 56n "check lfs find -type l"
6568 local dir=$DIR/$tdir
6570 setup_56 $dir $NUMFILES $NUMDIRS
6571 utime $dir/file1 > /dev/null || error "utime (1)"
6572 utime $dir/file2 > /dev/null || error "utime (2)"
6573 utime $dir/dir1 > /dev/null || error "utime (3)"
6574 utime $dir/dir2 > /dev/null || error "utime (4)"
6575 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6576 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6579 local nums=$($LFS find -mtime +0 $dir | wc -l)
6581 [ $nums -eq $expected ] ||
6582 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6585 cmd="$LFS find -mtime 0 $dir"
6586 nums=$($cmd | wc -l)
6587 [ $nums -eq $expected ] ||
6588 error "'$cmd' wrong: found $nums, expected $expected"
6590 run_test 56o "check lfs find -mtime for old files"
6593 local dir=$DIR/$tdir
6597 # just to make sure there is something that won't be found
6599 touch $dir/$tfile.now
6601 for age in year week day hour min; do
6602 count=$((count + 1))
6604 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6605 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6606 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6608 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6609 local nums=$($cmd | wc -l)
6610 [ $nums -eq $expected ] ||
6611 error "'$cmd' wrong: found $nums, expected $expected"
6613 cmd="$LFS find $dir -atime $count${age:0:1}"
6614 nums=$($cmd | wc -l)
6615 [ $nums -eq $expected ] ||
6616 error "'$cmd' wrong: found $nums, expected $expected"
6620 cmd="$LFS find $dir -ctime +1s -type f"
6621 nums=$($cmd | wc -l)
6622 (( $nums == $count * 2 + 1)) ||
6623 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6625 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6627 test_newerXY_base() {
6630 local dir=$DIR/$tdir
6634 if [ $y == "t" ]; then
6635 if [ $x == "b" ]; then
6636 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6638 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6641 ref=$DIR/$tfile.newer.$x$y
6642 touch $ref || error "touch $ref failed"
6645 echo "before = $ref"
6647 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6649 if [ $y == "t" ]; then
6650 if [ $x == "b" ]; then
6651 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6653 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6656 negref=$DIR/$tfile.negnewer.$x$y
6657 touch $negref || error "touch $negref failed"
6660 echo "after = $negref"
6661 local cmd="$LFS find $dir -newer$x$y $ref"
6662 local nums=$(eval $cmd | wc -l)
6663 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6665 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6666 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6668 cmd="$LFS find $dir ! -newer$x$y $negref"
6669 nums=$(eval $cmd | wc -l)
6670 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6671 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6673 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6674 nums=$(eval $cmd | wc -l)
6675 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6676 error "'$cmd' wrong: found $nums between, expected $expected"; }
6682 test_newerXY_base "a" "a"
6683 test_newerXY_base "a" "m"
6684 test_newerXY_base "a" "c"
6685 test_newerXY_base "m" "a"
6686 test_newerXY_base "m" "m"
6687 test_newerXY_base "m" "c"
6688 test_newerXY_base "c" "a"
6689 test_newerXY_base "c" "m"
6690 test_newerXY_base "c" "c"
6692 [[ -n "$sles_version" ]] &&
6693 echo "skip timestamp tests on SLES, LU-13665" && return 0
6695 test_newerXY_base "a" "t"
6696 test_newerXY_base "m" "t"
6697 test_newerXY_base "c" "t"
6699 [[ $MDS1_VERSION -lt $(version_code 2.13.54) ||
6700 $CLIENT_VERSION -lt $(version_code 2.13.54) ]] &&
6701 ! btime_supported && echo "btime unsupported" && return 0
6703 test_newerXY_base "b" "b"
6704 test_newerXY_base "b" "t"
6706 run_test 56oc "check lfs find -newerXY work"
6709 local dir=$DIR/$tdir
6714 $LFS find $dir -btime -1d -type f
6721 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
6722 ! btime_supported && skip "btime unsupported on MDS"
6724 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6725 ! btime_supported && skip "btime unsupported on clients"
6727 local dir=$DIR/$tdir
6728 local ref=$DIR/$tfile.ref
6729 local negref=$DIR/$tfile.negref
6731 mkdir $dir || error "mkdir $dir failed"
6732 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6733 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6734 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6735 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6736 touch $ref || error "touch $ref failed"
6737 # sleep 3 seconds at least
6740 local before=$(do_facet mds1 date +%s)
6741 local skew=$(($(date +%s) - before + 1))
6743 if (( skew < 0 && skew > -5 )); then
6744 sleep $((0 - skew + 1))
6748 # Set the dir stripe params to limit files all on MDT0,
6749 # otherwise we need to calc the max clock skew between
6750 # the client and MDTs.
6751 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6753 touch $negref || error "touch $negref failed"
6755 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6756 local nums=$($cmd | wc -l)
6757 local expected=$(((NUMFILES + 1) * NUMDIRS))
6759 [ $nums -eq $expected ] ||
6760 error "'$cmd' wrong: found $nums, expected $expected"
6762 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6763 nums=$($cmd | wc -l)
6764 expected=$((NUMFILES + 1))
6765 [ $nums -eq $expected ] ||
6766 error "'$cmd' wrong: found $nums, expected $expected"
6768 [ $skew -lt 0 ] && return
6770 local after=$(do_facet mds1 date +%s)
6771 local age=$((after - before + 1 + skew))
6773 cmd="$LFS find $dir -btime -${age}s -type f"
6774 nums=$($cmd | wc -l)
6775 expected=$(((NUMFILES + 1) * NUMDIRS))
6777 echo "Clock skew between client and server: $skew, age:$age"
6778 [ $nums -eq $expected ] ||
6779 error "'$cmd' wrong: found $nums, expected $expected"
6781 expected=$(($NUMDIRS + 1))
6782 cmd="$LFS find $dir -btime -${age}s -type d"
6783 nums=$($cmd | wc -l)
6784 [ $nums -eq $expected ] ||
6785 error "'$cmd' wrong: found $nums, expected $expected"
6786 rm -f $ref $negref || error "Failed to remove $ref $negref"
6788 run_test 56od "check lfs find -btime with units"
6791 [ $RUNAS_ID -eq $UID ] &&
6792 skip_env "RUNAS_ID = UID = $UID -- skipping"
6794 local dir=$DIR/$tdir
6796 setup_56 $dir $NUMFILES $NUMDIRS
6797 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6799 local expected=$NUMFILES
6800 local cmd="$LFS find -uid $RUNAS_ID $dir"
6801 local nums=$($cmd | wc -l)
6803 [ $nums -eq $expected ] ||
6804 error "'$cmd' wrong: found $nums, expected $expected"
6806 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6807 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6808 nums=$($cmd | wc -l)
6809 [ $nums -eq $expected ] ||
6810 error "'$cmd' wrong: found $nums, expected $expected"
6812 run_test 56p "check lfs find -uid and ! -uid"
6815 [ $RUNAS_ID -eq $UID ] &&
6816 skip_env "RUNAS_ID = UID = $UID -- skipping"
6818 local dir=$DIR/$tdir
6820 setup_56 $dir $NUMFILES $NUMDIRS
6821 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6823 local expected=$NUMFILES
6824 local cmd="$LFS find -gid $RUNAS_GID $dir"
6825 local nums=$($cmd | wc -l)
6827 [ $nums -eq $expected ] ||
6828 error "'$cmd' wrong: found $nums, expected $expected"
6830 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6831 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6832 nums=$($cmd | wc -l)
6833 [ $nums -eq $expected ] ||
6834 error "'$cmd' wrong: found $nums, expected $expected"
6836 run_test 56q "check lfs find -gid and ! -gid"
6839 local dir=$DIR/$tdir
6841 setup_56 $dir $NUMFILES $NUMDIRS
6844 local cmd="$LFS find -size 0 -type f -lazy $dir"
6845 local nums=$($cmd | wc -l)
6847 [ $nums -eq $expected ] ||
6848 error "'$cmd' wrong: found $nums, expected $expected"
6849 cmd="$LFS find -size 0 -type f $dir"
6850 nums=$($cmd | wc -l)
6851 [ $nums -eq $expected ] ||
6852 error "'$cmd' wrong: found $nums, expected $expected"
6855 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6856 nums=$($cmd | wc -l)
6857 [ $nums -eq $expected ] ||
6858 error "'$cmd' wrong: found $nums, expected $expected"
6859 cmd="$LFS find ! -size 0 -type f $dir"
6860 nums=$($cmd | wc -l)
6861 [ $nums -eq $expected ] ||
6862 error "'$cmd' wrong: found $nums, expected $expected"
6864 echo "test" > $dir/$tfile
6865 echo "test2" > $dir/$tfile.2 && sync
6867 cmd="$LFS find -size 5 -type f -lazy $dir"
6868 nums=$($cmd | wc -l)
6869 [ $nums -eq $expected ] ||
6870 error "'$cmd' wrong: found $nums, expected $expected"
6871 cmd="$LFS find -size 5 -type f $dir"
6872 nums=$($cmd | wc -l)
6873 [ $nums -eq $expected ] ||
6874 error "'$cmd' wrong: found $nums, expected $expected"
6877 cmd="$LFS find -size +5 -type f -lazy $dir"
6878 nums=$($cmd | wc -l)
6879 [ $nums -eq $expected ] ||
6880 error "'$cmd' wrong: found $nums, expected $expected"
6881 cmd="$LFS find -size +5 -type f $dir"
6882 nums=$($cmd | wc -l)
6883 [ $nums -eq $expected ] ||
6884 error "'$cmd' wrong: found $nums, expected $expected"
6887 cmd="$LFS find -size +0 -type f -lazy $dir"
6888 nums=$($cmd | wc -l)
6889 [ $nums -eq $expected ] ||
6890 error "'$cmd' wrong: found $nums, expected $expected"
6891 cmd="$LFS find -size +0 -type f $dir"
6892 nums=$($cmd | wc -l)
6893 [ $nums -eq $expected ] ||
6894 error "'$cmd' wrong: found $nums, expected $expected"
6897 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6898 nums=$($cmd | wc -l)
6899 [ $nums -eq $expected ] ||
6900 error "'$cmd' wrong: found $nums, expected $expected"
6901 cmd="$LFS find ! -size -5 -type f $dir"
6902 nums=$($cmd | wc -l)
6903 [ $nums -eq $expected ] ||
6904 error "'$cmd' wrong: found $nums, expected $expected"
6907 cmd="$LFS find -size -5 -type f -lazy $dir"
6908 nums=$($cmd | wc -l)
6909 [ $nums -eq $expected ] ||
6910 error "'$cmd' wrong: found $nums, expected $expected"
6911 cmd="$LFS find -size -5 -type f $dir"
6912 nums=$($cmd | wc -l)
6913 [ $nums -eq $expected ] ||
6914 error "'$cmd' wrong: found $nums, expected $expected"
6916 run_test 56r "check lfs find -size works"
6923 cancel_lru_locks $OSC
6925 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6926 local nums=$($cmd | wc -l)
6928 [ $nums -eq $expected ] ||
6929 error "'$cmd' wrong: found $nums, expected $expected"
6931 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6933 if (( rpcs_before + glimpses != rpcs_after )); then
6934 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6935 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
6937 if [[ $glimpses == 0 ]]; then
6938 error "'$cmd' should not send glimpse RPCs to OST"
6940 error "'$cmd' should send $glimpses glimpse RPCs to OST"
6946 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
6947 skip "MDS < 2.12.58 doesn't return LSOM data"
6948 local dir=$DIR/$tdir
6949 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
6951 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
6953 # statahead_agl may cause extra glimpse which confuses results. LU-13017
6954 $LCTL set_param -n llite.*.statahead_agl=0
6955 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
6957 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6958 # open and close all files to ensure LSOM is updated
6959 cancel_lru_locks $OSC
6960 find $dir -type f | xargs cat > /dev/null
6962 # expect_found glimpse_rpcs command_to_run
6963 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
6964 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
6965 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
6966 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
6968 echo "test" > $dir/$tfile
6969 echo "test2" > $dir/$tfile.2 && sync
6970 cancel_lru_locks $OSC
6971 cat $dir/$tfile $dir/$tfile.2 > /dev/null
6973 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
6974 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
6975 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
6976 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
6978 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
6979 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
6980 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
6981 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
6982 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
6983 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
6985 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6988 local dir=$DIR/$tdir
6989 local tmp=$TMP/$tfile.log
6992 test_mkdir -p $dir || error "failed to mkdir $dir"
6993 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
6994 error "failed to setstripe $dir/$tfile"
6995 mdt_idx=$($LFS getdirstripe -i $dir)
6996 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
6998 stack_trap "rm -f $tmp" EXIT
6999 $LFS find --size +100K --ost 0 $dir |& tee $tmp
7000 ! grep -q obd_uuid $tmp ||
7001 error "failed to find --size +100K --ost 0 $dir"
7002 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
7003 ! grep -q obd_uuid $tmp ||
7004 error "failed to find --size +100K --mdt $mdt_idx $dir"
7006 run_test 56rb "check lfs find --size --ost/--mdt works"
7009 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
7010 local dir=$DIR/$tdir
7013 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
7014 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
7015 (( $MDSCOUNT > 2 )) &&
7016 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
7017 mkdir $dir/$tdir-{1..10}
7018 touch $dir/$tfile-{1..10}
7020 found=$($LFS find $dir --mdt-count 2 | wc -l)
7022 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
7024 found=$($LFS find $dir -T +1 | wc -l)
7025 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
7026 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
7028 found=$($LFS find $dir --mdt-hash all_char | wc -l)
7030 (( $found == $expect )) || error "found $found all_char, expect $expect"
7032 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
7033 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
7034 (( $found == $expect )) || error "found $found all_char, expect $expect"
7036 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
7038 test_56s() { # LU-611 #LU-9369
7039 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
7041 local dir=$DIR/$tdir
7042 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
7044 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7045 for i in $(seq $NUMDIRS); do
7046 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
7049 local expected=$NUMDIRS
7050 local cmd="$LFS find -c $OSTCOUNT $dir"
7051 local nums=$($cmd | wc -l)
7053 [ $nums -eq $expected ] || {
7054 $LFS getstripe -R $dir
7055 error "'$cmd' wrong: found $nums, expected $expected"
7058 expected=$((NUMDIRS + onestripe))
7059 cmd="$LFS find -stripe-count +0 -type f $dir"
7060 nums=$($cmd | wc -l)
7061 [ $nums -eq $expected ] || {
7062 $LFS getstripe -R $dir
7063 error "'$cmd' wrong: found $nums, expected $expected"
7067 cmd="$LFS find -stripe-count 1 -type f $dir"
7068 nums=$($cmd | wc -l)
7069 [ $nums -eq $expected ] || {
7070 $LFS getstripe -R $dir
7071 error "'$cmd' wrong: found $nums, expected $expected"
7074 cmd="$LFS find -stripe-count -2 -type f $dir"
7075 nums=$($cmd | wc -l)
7076 [ $nums -eq $expected ] || {
7077 $LFS getstripe -R $dir
7078 error "'$cmd' wrong: found $nums, expected $expected"
7082 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
7083 nums=$($cmd | wc -l)
7084 [ $nums -eq $expected ] || {
7085 $LFS getstripe -R $dir
7086 error "'$cmd' wrong: found $nums, expected $expected"
7089 run_test 56s "check lfs find -stripe-count works"
7091 test_56t() { # LU-611 #LU-9369
7092 local dir=$DIR/$tdir
7094 setup_56 $dir 0 $NUMDIRS
7095 for i in $(seq $NUMDIRS); do
7096 $LFS setstripe -S 8M $dir/dir$i/$tfile
7099 local expected=$NUMDIRS
7100 local cmd="$LFS find -S 8M $dir"
7101 local nums=$($cmd | wc -l)
7103 [ $nums -eq $expected ] || {
7104 $LFS getstripe -R $dir
7105 error "'$cmd' wrong: found $nums, expected $expected"
7109 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
7111 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
7113 expected=$(((NUMDIRS + 1) * NUMFILES))
7114 cmd="$LFS find -stripe-size 512k -type f $dir"
7115 nums=$($cmd | wc -l)
7116 [ $nums -eq $expected ] ||
7117 error "'$cmd' wrong: found $nums, expected $expected"
7119 cmd="$LFS find -stripe-size +320k -type f $dir"
7120 nums=$($cmd | wc -l)
7121 [ $nums -eq $expected ] ||
7122 error "'$cmd' wrong: found $nums, expected $expected"
7124 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
7125 cmd="$LFS find -stripe-size +200k -type f $dir"
7126 nums=$($cmd | wc -l)
7127 [ $nums -eq $expected ] ||
7128 error "'$cmd' wrong: found $nums, expected $expected"
7130 cmd="$LFS find -stripe-size -640k -type f $dir"
7131 nums=$($cmd | wc -l)
7132 [ $nums -eq $expected ] ||
7133 error "'$cmd' wrong: found $nums, expected $expected"
7136 cmd="$LFS find -stripe-size 256k -type f $dir"
7137 nums=$($cmd | wc -l)
7138 [ $nums -eq $expected ] ||
7139 error "'$cmd' wrong: found $nums, expected $expected"
7141 cmd="$LFS find -stripe-size -320k -type f $dir"
7142 nums=$($cmd | wc -l)
7143 [ $nums -eq $expected ] ||
7144 error "'$cmd' wrong: found $nums, expected $expected"
7147 cmd="$LFS find -stripe-size 1024k -type f $dir"
7148 nums=$($cmd | wc -l)
7149 [ $nums -eq $expected ] ||
7150 error "'$cmd' wrong: found $nums, expected $expected"
7152 run_test 56t "check lfs find -stripe-size works"
7154 test_56u() { # LU-611
7155 local dir=$DIR/$tdir
7157 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
7159 if [[ $OSTCOUNT -gt 1 ]]; then
7160 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
7166 local expected=$(((NUMDIRS + 1) * NUMFILES))
7167 local cmd="$LFS find -stripe-index 0 -type f $dir"
7168 local nums=$($cmd | wc -l)
7170 [ $nums -eq $expected ] ||
7171 error "'$cmd' wrong: found $nums, expected $expected"
7174 cmd="$LFS find -stripe-index 1 -type f $dir"
7175 nums=$($cmd | wc -l)
7176 [ $nums -eq $expected ] ||
7177 error "'$cmd' wrong: found $nums, expected $expected"
7179 cmd="$LFS find ! -stripe-index 0 -type f $dir"
7180 nums=$($cmd | wc -l)
7181 [ $nums -eq $expected ] ||
7182 error "'$cmd' wrong: found $nums, expected $expected"
7185 # This should produce an error and not return any files
7186 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
7187 nums=$($cmd 2>/dev/null | wc -l)
7188 [ $nums -eq $expected ] ||
7189 error "'$cmd' wrong: found $nums, expected $expected"
7191 if [[ $OSTCOUNT -gt 1 ]]; then
7192 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
7193 cmd="$LFS find -stripe-index 0,1 -type f $dir"
7194 nums=$($cmd | wc -l)
7195 [ $nums -eq $expected ] ||
7196 error "'$cmd' wrong: found $nums, expected $expected"
7199 run_test 56u "check lfs find -stripe-index works"
7203 local dir=$DIR/$tdir
7205 setup_56 $dir $NUMFILES $NUMDIRS
7207 UUID=$(mdtuuid_from_index $mdt_idx $dir)
7208 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
7210 for file in $($LFS find -m $UUID $dir); do
7211 file_midx=$($LFS getstripe -m $file)
7212 [ $file_midx -eq $mdt_idx ] ||
7213 error "lfs find -m $UUID != getstripe -m $file_midx"
7216 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
7219 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7220 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7222 local dir=$DIR/$tdir
7224 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
7226 local stripe_size=$($LFS getstripe -S -d $dir) ||
7227 error "$LFS getstripe -S -d $dir failed"
7228 stripe_size=${stripe_size%% *}
7230 local file_size=$((stripe_size * OSTCOUNT))
7231 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
7232 local required_space=$((file_num * file_size))
7233 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
7235 [[ $free_space -le $((required_space / 1024)) ]] &&
7236 skip_env "need $required_space, have $free_space kbytes"
7239 local dd_count=$((file_size / dd_bs))
7241 # write data into the files
7246 for i in $(seq $NUMFILES); do
7248 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7249 error "write data into $file failed"
7251 for i in $(seq $NUMDIRS); do
7252 for j in $(seq $NUMFILES); do
7253 file=$dir/dir$i/file$j
7254 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7255 error "write data into $file failed"
7259 # $LFS_MIGRATE will fail if hard link migration is unsupported
7260 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
7261 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
7262 error "creating links to $dir/dir1/file1 failed"
7267 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
7270 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
7273 eval $cmd || error "$cmd failed"
7275 check_stripe_count $dir/file1 $expected
7277 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
7279 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
7280 # OST 1 if it is on OST 0. This file is small enough to
7281 # be on only one stripe.
7282 file=$dir/migr_1_ost
7283 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
7284 error "write data into $file failed"
7285 local obdidx=$($LFS getstripe -i $file)
7286 local oldmd5=$(md5sum $file)
7289 [[ $obdidx -eq 0 ]] && newobdidx=1
7290 cmd="$LFS migrate -i $newobdidx $file"
7292 eval $cmd || error "$cmd failed"
7294 local realobdix=$($LFS getstripe -i $file)
7295 local newmd5=$(md5sum $file)
7297 [[ $newobdidx -ne $realobdix ]] &&
7298 error "new OST is different (was=$obdidx, "\
7299 "wanted=$newobdidx, got=$realobdix)"
7300 [[ "$oldmd5" != "$newmd5" ]] &&
7301 error "md5sum differ: $oldmd5, $newmd5"
7305 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7307 eval $cmd || error "$cmd failed"
7309 for j in $(seq $NUMFILES); do
7310 check_stripe_count $dir/dir1/file$j $expected
7313 # lfs_migrate works with lfs find
7314 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7315 $LFS_MIGRATE -y -c $expected"
7317 eval $cmd || error "$cmd failed"
7319 for i in $(seq 2 $NUMFILES); do
7320 check_stripe_count $dir/file$i $expected
7322 for i in $(seq 2 $NUMDIRS); do
7323 for j in $(seq $NUMFILES); do
7324 check_stripe_count $dir/dir$i/file$j $expected
7328 run_test 56w "check lfs_migrate -c stripe_count works"
7331 local file1=$DIR/$tdir/file1
7332 local create_pool=false
7333 local initial_pool=$($LFS getstripe -p $DIR)
7337 echo -n "Creating test dir..."
7338 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7341 echo -n "Creating test file..."
7342 touch $file1 || error "cannot create file"
7345 echo -n "Detecting existing pools..."
7346 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7348 if [ ${#pool_list[@]} -gt 0 ]; then
7349 echo "${pool_list[@]}"
7350 for thispool in "${pool_list[@]}"; do
7351 if [[ -z "$initial_pool" ||
7352 "$initial_pool" != "$thispool" ]]; then
7354 echo "Using existing pool '$pool'"
7359 echo "none detected."
7361 if [ -z "$pool" ]; then
7362 pool=${POOL:-testpool}
7363 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7364 echo -n "Creating pool '$pool'..."
7366 pool_add $pool &> /dev/null ||
7367 error "pool_add failed"
7370 echo -n "Adding target to pool..."
7371 pool_add_targets $pool 0 0 1 &> /dev/null ||
7372 error "pool_add_targets failed"
7376 echo -n "Setting pool using -p option..."
7377 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7378 error "migrate failed rc = $?"
7381 echo -n "Verifying test file is in pool after migrating..."
7382 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7383 error "file was not migrated to pool $pool"
7386 echo -n "Removing test file from pool '$pool'..."
7387 # "lfs migrate $file" won't remove the file from the pool
7388 # until some striping information is changed.
7389 $LFS migrate -c 1 $file1 &> /dev/null ||
7390 error "cannot remove from pool"
7391 [ "$($LFS getstripe -p $file1)" ] &&
7392 error "pool still set"
7395 echo -n "Setting pool using --pool option..."
7396 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7397 error "migrate failed rc = $?"
7402 if $create_pool; then
7403 destroy_test_pools 2> /dev/null ||
7404 error "destroy test pools failed"
7407 run_test 56wb "check lfs_migrate pool support"
7410 local file1="$DIR/$tdir/file1"
7417 echo -n "Creating test dir..."
7418 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7419 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7420 error "cannot set stripe by '-S 1M -c 1'"
7423 echo -n "Setting initial stripe for test file..."
7424 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7425 error "cannot set stripe"
7426 cur_ssize=$($LFS getstripe -S "$file1")
7427 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
7430 # File currently set to -S 512K -c 1
7432 # Ensure -c and -S options are rejected when -R is set
7433 echo -n "Verifying incompatible options are detected..."
7434 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
7435 error "incompatible -c and -R options not detected"
7436 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
7437 error "incompatible -S and -R options not detected"
7440 # Ensure unrecognized options are passed through to 'lfs migrate'
7441 echo -n "Verifying -S option is passed through to lfs migrate..."
7442 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
7443 error "migration failed"
7444 cur_ssize=$($LFS getstripe -S "$file1")
7445 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
7448 # File currently set to -S 1M -c 1
7450 # Ensure long options are supported
7451 echo -n "Verifying long options supported..."
7452 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
7453 error "long option without argument not supported"
7454 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
7455 error "long option with argument not supported"
7456 cur_ssize=$($LFS getstripe -S "$file1")
7457 [ $cur_ssize -eq 524288 ] ||
7458 error "migrate --stripe-size $cur_ssize != 524288"
7461 # File currently set to -S 512K -c 1
7463 if [ "$OSTCOUNT" -gt 1 ]; then
7464 echo -n "Verifying explicit stripe count can be set..."
7465 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
7466 error "migrate failed"
7467 cur_scount=$($LFS getstripe -c "$file1")
7468 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
7472 # File currently set to -S 512K -c 1 or -S 512K -c 2
7474 # Ensure parent striping is used if -R is set, and no stripe
7475 # count or size is specified
7476 echo -n "Setting stripe for parent directory..."
7477 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7478 error "cannot set stripe '-S 2M -c 1'"
7481 echo -n "Verifying restripe option uses parent stripe settings..."
7482 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7483 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7484 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
7485 error "migrate failed"
7486 cur_ssize=$($LFS getstripe -S "$file1")
7487 [ $cur_ssize -eq $parent_ssize ] ||
7488 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7489 cur_scount=$($LFS getstripe -c "$file1")
7490 [ $cur_scount -eq $parent_scount ] ||
7491 error "migrate -R stripe_count $cur_scount != $parent_scount"
7494 # File currently set to -S 1M -c 1
7496 # Ensure striping is preserved if -R is not set, and no stripe
7497 # count or size is specified
7498 echo -n "Verifying striping size preserved when not specified..."
7499 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7500 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7501 error "cannot set stripe on parent directory"
7502 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7503 error "migrate failed"
7504 cur_ssize=$($LFS getstripe -S "$file1")
7505 [ $cur_ssize -eq $orig_ssize ] ||
7506 error "migrate by default $cur_ssize != $orig_ssize"
7509 # Ensure file name properly detected when final option has no argument
7510 echo -n "Verifying file name properly detected..."
7511 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7512 error "file name interpreted as option argument"
7518 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7521 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7523 local file1=$DIR/$tdir/file1
7525 echo -n "Creating test dir..."
7526 test_mkdir $DIR/$tdir || error "cannot create dir"
7529 echo -n "Creating test file..."
7533 # Ensure 'lfs migrate' will fail by using a non-existent option,
7534 # and make sure rsync is not called to recover
7535 echo -n "Make sure --no-rsync option works..."
7536 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7537 grep -q 'refusing to fall back to rsync' ||
7538 error "rsync was called with --no-rsync set"
7541 # Ensure rsync is called without trying 'lfs migrate' first
7542 echo -n "Make sure --rsync option works..."
7543 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7544 grep -q 'falling back to rsync' &&
7545 error "lfs migrate was called with --rsync set"
7548 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
7549 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
7550 grep -q 'at the same time' ||
7551 error "--rsync and --no-rsync accepted concurrently"
7557 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7563 test_mkdir $td || error "cannot create $td"
7564 touch $tf || error "cannot touch $tf"
7566 echo -n "Make sure --non-direct|-D works..."
7567 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7568 grep -q "lfs migrate --non-direct" ||
7569 error "--non-direct option cannot work correctly"
7570 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7571 grep -q "lfs migrate -D" ||
7572 error "-D option cannot work correctly"
7575 run_test 56we "check lfs_migrate --non-direct|-D support"
7578 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7579 check_swap_layouts_support
7581 local dir=$DIR/$tdir
7582 local ref1=/etc/passwd
7583 local file1=$dir/file1
7585 test_mkdir $dir || error "creating dir $dir"
7586 $LFS setstripe -c 2 $file1
7588 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7589 stripe=$($LFS getstripe -c $file1)
7590 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7591 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7596 run_test 56x "lfs migration support"
7599 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7600 check_swap_layouts_support
7602 local dir=$DIR/$tdir/$testnum
7606 local ref1=/etc/passwd
7607 local file1=$dir/file1
7609 $LFS setstripe -c 2 $file1
7611 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7613 local stripe=$($LFS getstripe -c $file1)
7615 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7616 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7621 run_test 56xa "lfs migration --block support"
7623 check_migrate_links() {
7625 local file1="$dir/file1"
7629 local total_count=$(($begin + $count - 1))
7630 local symlink_count=10
7633 if [ ! -f "$file1" ]; then
7634 echo -n "creating initial file..."
7635 $LFS setstripe -c 1 -S "512k" "$file1" ||
7636 error "cannot setstripe initial file"
7639 echo -n "creating symlinks..."
7640 for s in $(seq 1 $symlink_count); do
7641 ln -s "$file1" "$dir/slink$s" ||
7642 error "cannot create symlinks"
7646 echo -n "creating nonlinked files..."
7647 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7648 error "cannot create nonlinked files"
7653 if [ ! -f "$dir/file$total_count" ]; then
7654 echo -n "creating hard links $begin:$total_count..."
7655 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7656 /dev/null || error "cannot create hard links"
7660 echo -n "checking number of hard links listed in xattrs..."
7661 local fid=$($LFS getstripe -F "$file1")
7662 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7665 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7666 skip "hard link list has unexpected size, skipping test"
7668 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7669 error "link names should exceed xattrs size"
7672 echo -n "migrating files..."
7673 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
7675 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7678 # make sure all links have been properly migrated
7679 echo -n "verifying files..."
7680 fid=$($LFS getstripe -F "$file1") ||
7681 error "cannot get fid for file $file1"
7682 for i in $(seq 2 $total_count); do
7683 local fid2=$($LFS getstripe -F $dir/file$i)
7685 [ "$fid2" == "$fid" ] ||
7686 error "migrated hard link has mismatched FID"
7689 # make sure hard links were properly detected, and migration was
7690 # performed only once for the entire link set; nonlinked files should
7692 local actual=$(grep -c 'done' <<< "$migrate_out")
7693 local expected=$(($uniq_count + 1))
7695 [ "$actual" -eq "$expected" ] ||
7696 error "hard links individually migrated ($actual != $expected)"
7698 # make sure the correct number of hard links are present
7699 local hardlinks=$(stat -c '%h' "$file1")
7701 [ $hardlinks -eq $total_count ] ||
7702 error "num hard links $hardlinks != $total_count"
7709 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7710 skip "Need MDS version at least 2.10.55"
7712 local dir="$DIR/$tdir"
7714 test_mkdir "$dir" || error "cannot create dir $dir"
7716 echo "testing lfs migrate mode when all links fit within xattrs"
7717 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
7719 echo "testing rsync mode when all links fit within xattrs"
7720 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
7722 echo "testing lfs migrate mode when all links do not fit within xattrs"
7723 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
7725 echo "testing rsync mode when all links do not fit within xattrs"
7726 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
7728 chown -R $RUNAS_ID $dir
7729 echo "testing non-root lfs migrate mode when not all links are in xattr"
7730 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
7735 run_test 56xb "lfs migration hard link support"
7738 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7740 local dir="$DIR/$tdir"
7742 test_mkdir "$dir" || error "cannot create dir $dir"
7744 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7745 echo -n "Setting initial stripe for 20MB test file..."
7746 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7747 error "cannot setstripe 20MB file"
7749 echo -n "Sizing 20MB test file..."
7750 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
7752 echo -n "Verifying small file autostripe count is 1..."
7753 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
7754 error "cannot migrate 20MB file"
7755 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7756 error "cannot get stripe for $dir/20mb"
7757 [ $stripe_count -eq 1 ] ||
7758 error "unexpected stripe count $stripe_count for 20MB file"
7762 # Test 2: File is small enough to fit within the available space on
7763 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7764 # have at least an additional 1KB for each desired stripe for test 3
7765 echo -n "Setting stripe for 1GB test file..."
7766 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7768 echo -n "Sizing 1GB test file..."
7769 # File size is 1GB + 3KB
7770 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7773 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7774 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7775 if (( avail > 524288 * OSTCOUNT )); then
7776 echo -n "Migrating 1GB file..."
7777 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7778 error "cannot migrate 1GB file"
7780 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7781 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7782 error "cannot getstripe for 1GB file"
7783 [ $stripe_count -eq 2 ] ||
7784 error "unexpected stripe count $stripe_count != 2"
7788 # Test 3: File is too large to fit within the available space on
7789 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7790 if [ $OSTCOUNT -ge 3 ]; then
7791 # The required available space is calculated as
7792 # file size (1GB + 3KB) / OST count (3).
7793 local kb_per_ost=349526
7795 echo -n "Migrating 1GB file with limit..."
7796 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7797 error "cannot migrate 1GB file with limit"
7800 stripe_count=$($LFS getstripe -c "$dir/1gb")
7801 echo -n "Verifying 1GB autostripe count with limited space..."
7802 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7803 error "unexpected stripe count $stripe_count (min 3)"
7810 run_test 56xc "lfs migration autostripe"
7813 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7815 local dir=$DIR/$tdir
7816 local f_mgrt=$dir/$tfile.mgrt
7817 local f_yaml=$dir/$tfile.yaml
7818 local f_copy=$dir/$tfile.copy
7819 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7820 local layout_copy="-c 2 -S 2M -i 1"
7821 local yamlfile=$dir/yamlfile
7822 local layout_before;
7825 test_mkdir "$dir" || error "cannot create dir $dir"
7826 $LFS setstripe $layout_yaml $f_yaml ||
7827 error "cannot setstripe $f_yaml with layout $layout_yaml"
7828 $LFS getstripe --yaml $f_yaml > $yamlfile
7829 $LFS setstripe $layout_copy $f_copy ||
7830 error "cannot setstripe $f_copy with layout $layout_copy"
7832 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7834 # 1. test option --yaml
7835 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7836 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7837 layout_before=$(get_layout_param $f_yaml)
7838 layout_after=$(get_layout_param $f_mgrt)
7839 [ "$layout_after" == "$layout_before" ] ||
7840 error "lfs_migrate --yaml: $layout_after != $layout_before"
7842 # 2. test option --copy
7843 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7844 error "cannot migrate $f_mgrt with --copy $f_copy"
7845 layout_before=$(get_layout_param $f_copy)
7846 layout_after=$(get_layout_param $f_mgrt)
7847 [ "$layout_after" == "$layout_before" ] ||
7848 error "lfs_migrate --copy: $layout_after != $layout_before"
7850 run_test 56xd "check lfs_migrate --yaml and --copy support"
7853 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7855 local dir=$DIR/$tdir
7856 local f_comp=$dir/$tfile
7857 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7858 local layout_before=""
7859 local layout_after=""
7861 test_mkdir "$dir" || error "cannot create dir $dir"
7862 $LFS setstripe $layout $f_comp ||
7863 error "cannot setstripe $f_comp with layout $layout"
7864 layout_before=$(get_layout_param $f_comp)
7865 dd if=/dev/zero of=$f_comp bs=1M count=4
7867 # 1. migrate a comp layout file by lfs_migrate
7868 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7869 layout_after=$(get_layout_param $f_comp)
7870 [ "$layout_before" == "$layout_after" ] ||
7871 error "lfs_migrate: $layout_before != $layout_after"
7873 # 2. migrate a comp layout file by lfs migrate
7874 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7875 layout_after=$(get_layout_param $f_comp)
7876 [ "$layout_before" == "$layout_after" ] ||
7877 error "lfs migrate: $layout_before != $layout_after"
7879 run_test 56xe "migrate a composite layout file"
7882 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7884 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7885 skip "Need server version at least 2.13.53"
7887 local dir=$DIR/$tdir
7888 local f_comp=$dir/$tfile
7889 local layout="-E 1M -c1 -E -1 -c2"
7893 test_mkdir "$dir" || error "cannot create dir $dir"
7894 $LFS setstripe $layout $f_comp ||
7895 error "cannot setstripe $f_comp with layout $layout"
7896 fid_before=$($LFS getstripe --fid $f_comp)
7897 dd if=/dev/zero of=$f_comp bs=1M count=4
7899 # 1. migrate a comp layout file to a comp layout
7900 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7901 fid_after=$($LFS getstripe --fid $f_comp)
7902 [ "$fid_before" == "$fid_after" ] ||
7903 error "comp-to-comp migrate: $fid_before != $fid_after"
7905 # 2. migrate a comp layout file to a plain layout
7906 $LFS migrate -c2 $f_comp ||
7907 error "cannot migrate $f_comp by lfs migrate"
7908 fid_after=$($LFS getstripe --fid $f_comp)
7909 [ "$fid_before" == "$fid_after" ] ||
7910 error "comp-to-plain migrate: $fid_before != $fid_after"
7912 # 3. migrate a plain layout file to a comp layout
7913 $LFS migrate $layout $f_comp ||
7914 error "cannot migrate $f_comp by lfs migrate"
7915 fid_after=$($LFS getstripe --fid $f_comp)
7916 [ "$fid_before" == "$fid_after" ] ||
7917 error "plain-to-comp migrate: $fid_before != $fid_after"
7919 run_test 56xf "FID is not lost during migration of a composite layout file"
7921 check_file_ost_range() {
7928 file_range=($($LFS getstripe -y "$file" |
7929 awk '/l_ost_idx:/ { print $NF }'))
7931 if [[ "${#file_range[@]}" = 0 ]]; then
7932 echo "No osts found for $file"
7936 for idx in "${file_range[@]}"; do
7937 [[ " $range " =~ " $idx " ]] ||
7945 local stripe_opt="$1"
7948 local pool_ostidx="$(seq $* | tr '\n' ' ')"
7950 $LFS migrate $stripe_opt -p $pool $DIR/$tfile ||
7951 error "Fail to migrate $tfile on $pool"
7952 [[ "$($LFS getstripe -p $DIR/$tfile)" = "$pool" ]] ||
7953 error "$tfile is not in pool $pool"
7954 check_file_ost_range "$DIR/$tfile" $pool_ostidx ||
7955 error "$tfile osts mismatch with pool $pool (osts $pool_ostidx)"
7959 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7960 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
7961 [[ $MDS1_VERSION -gt $(version_code 2.14.52) ]] ||
7962 skip "Need MDS version newer than 2.14.52"
7964 local -a pool_names=("${TESTNAME}_0" "${TESTNAME}_1" "${TESTNAME}_2")
7965 local -a pool_ranges=("0 0" "1 1" "0 1")
7968 for i in "${!pool_names[@]}"; do
7969 pool_add ${pool_names[$i]} ||
7970 error "pool_add failed (pool: ${pool_names[$i]})"
7971 pool_add_targets ${pool_names[$i]} ${pool_ranges[$i]} ||
7972 error "pool_add_targets failed (pool: ${pool_names[$i]})"
7975 # init the file to migrate
7976 $LFS setstripe -c1 -i1 $DIR/$tfile ||
7977 error "Unable to create $tfile on OST1"
7978 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=4 status=none ||
7979 error "Unable to write on $tfile"
7981 echo "1. migrate $tfile on pool ${pool_names[0]}"
7982 sub_test_56xg "-c-1" "${pool_names[0]}" ${pool_ranges[0]}
7984 echo "2. migrate $tfile on pool ${pool_names[2]}"
7985 sub_test_56xg "-c-1 -S2M" "${pool_names[2]}" ${pool_ranges[2]}
7987 echo "3. migrate $tfile on pool ${pool_names[1]}"
7988 sub_test_56xg "-n -c-1" "${pool_names[1]}" ${pool_ranges[1]}
7990 echo "4. migrate $tfile on pool ${pool_names[2]} with default stripe parameters"
7991 sub_test_56xg "" "${pool_names[2]}" ${pool_ranges[2]}
7995 destroy_test_pools ||
7996 error "pool_destroy failed"
7998 run_test 56xg "lfs migrate pool support"
8001 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
8002 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
8005 local dir=$DIR/$tdir
8009 test_mkdir -p $dir || error "creating dir $dir"
8010 touch $f1 || error "creating std file $f1"
8011 $MULTIOP $f2 H2c || error "creating released file $f2"
8013 # a directory can be raid0, so ask only for files
8014 res=$($LFS find $dir -L raid0 -type f | wc -l)
8015 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
8017 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
8018 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
8020 # only files can be released, so no need to force file search
8021 res=$($LFS find $dir -L released)
8022 [[ $res == $f2 ]] || error "search released: found $res != $f2"
8024 res=$($LFS find $dir -type f \! -L released)
8025 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
8027 run_test 56y "lfs find -L raid0|released"
8029 test_56z() { # LU-4824
8030 # This checks to make sure 'lfs find' continues after errors
8031 # There are two classes of errors that should be caught:
8032 # - If multiple paths are provided, all should be searched even if one
8034 # - If errors are encountered during the search, it should not terminate
8036 local dir=$DIR/$tdir
8040 for i in d{0..9}; do
8042 touch $dir/$i/$tfile
8044 $LFS find $DIR/non_existent_dir $dir &&
8045 error "$LFS find did not return an error"
8046 # Make a directory unsearchable. This should NOT be the last entry in
8047 # directory order. Arbitrarily pick the 6th entry
8048 chmod 700 $($LFS find $dir -type d | sed '6!d')
8050 $RUNAS $LFS find $DIR/non_existent $dir
8051 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
8053 # The user should be able to see 10 directories and 9 files
8054 (( count == 19 )) ||
8055 error "$LFS find found $count != 19 entries after error"
8057 run_test 56z "lfs find should continue after an error"
8059 test_56aa() { # LU-5937
8060 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
8062 local dir=$DIR/$tdir
8065 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
8067 createmany -o $dir/striped_dir/${tfile}- 1024
8068 local dirs=$($LFS find --size +8k $dir/)
8070 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
8072 run_test 56aa "lfs find --size under striped dir"
8074 test_56ab() { # LU-10705
8075 test_mkdir $DIR/$tdir
8076 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
8077 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
8078 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
8079 # Flush writes to ensure valid blocks. Need to be more thorough for
8080 # ZFS, since blocks are not allocated/returned to client immediately.
8082 wait_zfs_commit ost1 2
8083 cancel_lru_locks osc
8086 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
8088 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
8090 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
8091 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
8093 rm -f $DIR/$tdir/$tfile.[123]
8095 run_test 56ab "lfs find --blocks"
8099 local dir="$DIR/$tdir"
8100 local perms=(001 002 003 004 005 006 007
8101 010 020 030 040 050 060 070
8102 100 200 300 400 500 600 700
8103 111 222 333 444 555 666 777)
8104 local perm_minus=(8 8 4 8 4 4 2
8108 local perm_slash=(8 8 12 8 12 12 14
8111 16 16 24 16 24 24 28)
8114 for perm in ${perms[*]}; do
8115 touch "$dir/$tfile.$perm"
8116 chmod $perm "$dir/$tfile.$perm"
8119 for ((i = 0; i < ${#perms[*]}; i++)); do
8120 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
8122 error "lfs find -perm ${perms[i]}:"\
8125 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
8126 (( $num == ${perm_minus[i]} )) ||
8127 error "lfs find -perm -${perms[i]}:"\
8128 "$num != ${perm_minus[i]}"
8130 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
8131 (( $num == ${perm_slash[i]} )) ||
8132 error "lfs find -perm /${perms[i]}:"\
8133 "$num != ${perm_slash[i]}"
8136 run_test 56aca "check lfs find -perm with octal representation"
8139 local dir=$DIR/$tdir
8140 # p is the permission of write and execute for user, group and other
8141 # without the umask. It is used to test +wx.
8142 local p=$(printf "%o" "$((0333 & ~$(umask)))")
8143 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
8144 local symbolic=(+t a+t u+t g+t o+t
8150 o=r,ug+o,u+w u=r,a+u,u+w
8151 g=r,ugo=g,u+w u+x,+X +X
8152 u+x,u+X u+X u+x,g+X o+r,+X
8156 for perm in ${perms[*]}; do
8157 touch "$dir/$tfile.$perm"
8158 chmod $perm "$dir/$tfile.$perm"
8161 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
8162 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
8165 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
8168 run_test 56acb "check lfs find -perm with symbolic representation"
8171 local dir=$DIR/$tdir
8172 local tests="17777 787 789 abcd
8173 ug=uu ug=a ug=gu uo=ou urw
8177 for err in $tests; do
8178 if $LFS find $dir -perm $err 2>/dev/null; then
8179 error "lfs find -perm $err: parsing should have failed"
8183 run_test 56acc "check parsing error for lfs find -perm"
8186 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
8187 skip "Need MDS version at least 2.10.50"
8189 # Create composite files with one component
8190 local dir=$DIR/$tdir
8192 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
8193 # Create composite files with three components
8194 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
8195 # Create non-composite files
8196 createmany -o $dir/${tfile}- 10
8198 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
8200 [[ $nfiles == 10 ]] ||
8201 error "lfs find -E 1M found $nfiles != 10 files"
8203 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
8204 [[ $nfiles == 25 ]] ||
8205 error "lfs find ! -E 1M found $nfiles != 25 files"
8207 # All files have a component that starts at 0
8208 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
8209 [[ $nfiles == 35 ]] ||
8210 error "lfs find --component-start 0 - $nfiles != 35 files"
8212 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
8213 [[ $nfiles == 15 ]] ||
8214 error "lfs find --component-start 2M - $nfiles != 15 files"
8216 # All files created here have a componenet that does not starts at 2M
8217 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
8218 [[ $nfiles == 35 ]] ||
8219 error "lfs find ! --component-start 2M - $nfiles != 35 files"
8221 # Find files with a specified number of components
8222 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
8223 [[ $nfiles == 15 ]] ||
8224 error "lfs find --component-count 3 - $nfiles != 15 files"
8226 # Remember non-composite files have a component count of zero
8227 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
8228 [[ $nfiles == 10 ]] ||
8229 error "lfs find --component-count 0 - $nfiles != 10 files"
8231 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
8232 [[ $nfiles == 20 ]] ||
8233 error "lfs find ! --component-count 3 - $nfiles != 20 files"
8235 # All files have a flag called "init"
8236 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
8237 [[ $nfiles == 35 ]] ||
8238 error "lfs find --component-flags init - $nfiles != 35 files"
8240 # Multi-component files will have a component not initialized
8241 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
8242 [[ $nfiles == 15 ]] ||
8243 error "lfs find !--component-flags init - $nfiles != 15 files"
8248 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
8251 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
8252 skip "Need MDS version at least 2.10.57"
8262 # create mirrored directories and mirrored files
8263 mkdir $td || error "mkdir $td failed"
8264 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
8265 createmany -o $tf- 10 || error "create $tf- failed"
8267 for i in $(seq 2); do
8269 mkdir $dir || error "mkdir $dir failed"
8270 $LFS mirror create -N$((3 + i)) $dir ||
8271 error "create mirrored dir $dir failed"
8272 createmany -o $dir/$tfile- 10 ||
8273 error "create $dir/$tfile- failed"
8276 # change the states of some mirrored files
8278 for i in $(seq 2); do
8280 for j in $(seq 4 9); do
8281 echo foo > $dir/$tfile-$j
8285 # find mirrored files with specific mirror count
8286 cmd="$LFS find --mirror-count 3 --type f $td"
8287 nfiles=$($cmd | wc -l)
8288 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
8290 cmd="$LFS find ! --mirror-count 3 --type f $td"
8291 nfiles=$($cmd | wc -l)
8292 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
8294 cmd="$LFS find --mirror-count +2 --type f $td"
8295 nfiles=$($cmd | wc -l)
8296 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8298 cmd="$LFS find --mirror-count -6 --type f $td"
8299 nfiles=$($cmd | wc -l)
8300 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8302 # find mirrored files with specific file state
8303 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
8304 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
8306 cmd="$LFS find --mirror-state=ro --type f $td"
8307 nfiles=$($cmd | wc -l)
8308 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
8310 cmd="$LFS find ! --mirror-state=ro --type f $td"
8311 nfiles=$($cmd | wc -l)
8312 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8314 cmd="$LFS find --mirror-state=wp --type f $td"
8315 nfiles=$($cmd | wc -l)
8316 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8318 cmd="$LFS find ! --mirror-state=sp --type f $td"
8319 nfiles=$($cmd | wc -l)
8320 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8322 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
8324 test_56da() { # LU-14179
8325 local path=$DIR/$tdir
8330 local longdir=$(str_repeat 'a' 255)
8332 for i in {1..15}; do
8339 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
8344 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
8347 touch $(str_repeat 'f' 255)
8349 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
8350 error "lfs find reported an error"
8354 run_test 56da "test lfs find with long paths"
8356 test_56ea() { #LU-10378
8357 local path=$DIR/$tdir
8358 local pool=$TESTNAME
8361 pool_add $pool || error "pool_add $pool failed"
8362 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8363 error "adding targets to $pool failed"
8365 # Set default pool on directory before creating file
8366 mkdir $path || error "mkdir $path failed"
8367 $LFS setstripe -p $pool $path ||
8368 error "set OST pool on $pool failed"
8369 touch $path/$tfile || error "touch $path/$tfile failed"
8371 # Compare basic file attributes from -printf and stat
8372 local attr_printf=$($LFS find $path/$tfile -printf "%A@ %T@ %C@ %U %G")
8373 local attr_stat=$(stat -c "%X %Y %Z %u %g" $path/$tfile)
8375 [[ "${attr_printf}" == "${attr_stat}" ]] ||
8376 error "Attrs from lfs find and stat don't match"
8378 # Compare Lustre attributes from lfs find and lfs getstripe
8379 local lattr_printf=$($LFS find $path/$tfile -printf "%Lc %LS %Li %Lp")
8380 local str_cnt=$($LFS getstripe --stripe-count $path/$tfile)
8381 local str_size=$($LFS getstripe --stripe-size $path/$tfile)
8382 local str_idx=$($LFS getstripe --stripe-index $path/$tfile)
8383 local fpool=$($LFS getstripe --pool $path/$tfile)
8384 local lattr_getstr="${str_cnt} ${str_size} ${str_idx} ${fpool}"
8386 [[ "${lattr_printf}" == "${lattr_getstr}" ]] ||
8387 error "Attrs from lfs find and lfs getstripe don't match"
8389 # Verify behavior for unknown escape/format sequences
8390 local esc_printf=$($LFS find $path/$tfile -printf '\\ %% \Q %Q')
8392 [[ "${esc_printf}" == '\ % \Q %Q' ]] ||
8393 error "Escape/format codes don't match"
8395 run_test 56ea "test lfs find -printf option"
8398 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8399 # note test will not do anything if MDS is not local
8400 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8401 skip_env "ldiskfs only test"
8403 remote_mds_nodsh && skip "remote MDS with nodsh"
8405 local MNTDEV="osd*.*MDT*.mntdev"
8406 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
8407 [ -z "$DEV" ] && error "can't access $MNTDEV"
8408 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
8409 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
8410 error "can't access $DEV"
8411 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
8412 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
8416 run_test 57a "verify MDS filesystem created with large inodes =="
8419 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8420 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8421 skip_env "ldiskfs only test"
8423 remote_mds_nodsh && skip "remote MDS with nodsh"
8425 local dir=$DIR/$tdir
8428 local fileN=$dir/f$filecount
8430 rm -rf $dir || error "removing $dir"
8432 local mdtidx=$($LFS getstripe -m $dir)
8433 local mdtname=MDT$(printf %04x $mdtidx)
8434 local facet=mds$((mdtidx + 1))
8436 echo "mcreating $filecount files"
8437 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
8439 # verify that files do not have EAs yet
8440 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
8441 error "$file1 has an EA"
8442 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
8443 error "$fileN has an EA"
8447 df $dir #make sure we get new statfs data
8448 local mdsfree=$(do_facet $facet \
8449 lctl get_param -n osd*.*$mdtname.kbytesfree)
8450 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8453 echo "opening files to create objects/EAs"
8454 for file in $(seq -f $dir/f%g 1 $filecount); do
8455 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
8456 error "opening $file"
8459 # verify that files have EAs now
8460 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
8461 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
8463 sleep 1 #make sure we get new statfs data
8465 local mdsfree2=$(do_facet $facet \
8466 lctl get_param -n osd*.*$mdtname.kbytesfree)
8467 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8469 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
8470 if [ "$mdsfree" != "$mdsfree2" ]; then
8471 error "MDC before $mdcfree != after $mdcfree2"
8473 echo "MDC before $mdcfree != after $mdcfree2"
8474 echo "unable to confirm if MDS has large inodes"
8479 run_test 57b "default LOV EAs are stored inside large inodes ==="
8482 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8483 [ -z "$(which wiretest 2>/dev/null)" ] &&
8484 skip_env "could not find wiretest"
8488 run_test 58 "verify cross-platform wire constants =============="
8491 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8493 echo "touch 130 files"
8494 createmany -o $DIR/f59- 130
8496 unlinkmany $DIR/f59- 130
8498 # wait for commitment of removal
8499 wait_delete_completed
8501 run_test 59 "verify cancellation of llog records async ========="
8503 TEST60_HEAD="test_60 run $RANDOM"
8505 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8506 remote_mgs_nodsh && skip "remote MGS with nodsh"
8507 do_facet mgs "! which run-llog.sh &> /dev/null" &&
8508 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
8509 skip_env "missing subtest run-llog.sh"
8511 log "$TEST60_HEAD - from kernel mode"
8512 do_facet mgs "$LCTL dk > /dev/null"
8513 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
8514 do_facet mgs $LCTL dk > $TMP/$tfile
8516 # LU-6388: test llog_reader
8517 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
8518 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
8519 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
8520 skip_env "missing llog_reader"
8521 local fstype=$(facet_fstype mgs)
8522 [ $fstype != ldiskfs -a $fstype != zfs ] &&
8523 skip_env "Only for ldiskfs or zfs type mgs"
8525 local mntpt=$(facet_mntpt mgs)
8526 local mgsdev=$(mgsdevname 1)
8538 #get fid and record list
8539 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
8541 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
8543 #remount mgs as ldiskfs or zfs type
8544 stop mgs || error "stop mgs failed"
8545 mount_fstype mgs || error "remount mgs failed"
8546 for ((i = 0; i < ${#fid_list[@]}; i++)); do
8549 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
8550 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
8555 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
8557 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
8559 echo "obj_file is $obj_file"
8560 do_facet mgs $llog_reader $obj_file
8562 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
8563 awk '{ print $3 }' | sed -e "s/^type=//g")
8564 if [ $rec_type != $rec ]; then
8565 echo "FAILED test_60a wrong record type $rec_type," \
8571 #check obj path if record type is LLOG_LOGID_MAGIC
8572 if [ "$rec" == "1064553b" ]; then
8573 path=$(do_facet mgs $llog_reader $obj_file |
8574 grep "path=" | awk '{ print $NF }' |
8575 sed -e "s/^path=//g")
8576 if [ $obj_file != $mntpt/$path ]; then
8577 echo "FAILED test_60a wrong obj path" \
8578 "$montpt/$path, should be $obj_file"
8585 #restart mgs before "error", otherwise it will block the next test
8586 stop mgs || error "stop mgs failed"
8587 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
8588 $pass || error "test failed, see FAILED test_60a messages for specifics"
8590 run_test 60a "llog_test run from kernel module and test llog_reader"
8592 test_60b() { # bug 6411
8593 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8596 LLOG_COUNT=$(do_facet mgs dmesg |
8597 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
8598 /llog_[a-z]*.c:[0-9]/ {
8610 [[ $LLOG_COUNT -gt 120 ]] &&
8611 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
8613 run_test 60b "limit repeated messages from CERROR/CWARN"
8616 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8618 echo "create 5000 files"
8619 createmany -o $DIR/f60c- 5000
8620 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
8621 lctl set_param fail_loc=0x80000137
8622 unlinkmany $DIR/f60c- 5000
8623 lctl set_param fail_loc=0
8625 run_test 60c "unlink file when mds full"
8628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8630 SAVEPRINTK=$(lctl get_param -n printk)
8631 # verify "lctl mark" is even working"
8632 MESSAGE="test message ID $RANDOM $$"
8633 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8634 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
8636 lctl set_param printk=0 || error "set lnet.printk failed"
8637 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
8638 MESSAGE="new test message ID $RANDOM $$"
8639 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
8640 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8641 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
8643 lctl set_param -n printk="$SAVEPRINTK"
8645 run_test 60d "test printk console message masking"
8648 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8649 remote_mds_nodsh && skip "remote MDS with nodsh"
8652 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
8653 do_facet mds1 lctl set_param fail_loc=0x15b
8656 run_test 60e "no space while new llog is being created"
8659 local old_path=$($LCTL get_param -n debug_path)
8661 stack_trap "$LCTL set_param debug_path=$old_path"
8662 stack_trap "rm -f $TMP/$tfile*"
8663 rm -f $TMP/$tfile* 2> /dev/null
8664 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8665 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
8666 test_mkdir $DIR/$tdir
8667 # retry in case the open is cached and not released
8668 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
8669 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
8673 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
8675 run_test 60f "change debug_path works"
8681 test_mkdir -c $MDSCOUNT $DIR/$tdir
8686 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
8687 -c $MDSCOUNT $DIR/$tdir/subdir$index \
8689 mkdir $DIR/$tdir/subdir$index 2>/dev/null
8690 rmdir $DIR/$tdir/subdir$index 2>/dev/null
8691 index=$((index + 1))
8697 for i in {0..100}; do
8698 # define OBD_FAIL_OSD_TXN_START 0x19a
8699 local index=$((i % MDSCOUNT + 1))
8701 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
8708 for i in $(seq $MDSCOUNT); do
8709 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
8712 mkdir $DIR/$tdir/new || error "mkdir failed"
8713 rmdir $DIR/$tdir/new || error "rmdir failed"
8715 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
8717 for i in $(seq $MDSCOUNT); do
8718 wait_update_facet mds$i "$LCTL get_param -n \
8719 mdd.$(facet_svc mds$i).lfsck_namespace |
8720 awk '/^status/ { print \\\$2 }'" "completed"
8724 rm -rf $DIR/$tdir || error "rmdir failed"
8726 run_test 60g "transaction abort won't cause MDT hung"
8729 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
8730 skip "Need MDS version at least 2.12.52"
8731 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
8735 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
8736 #define OBD_FAIL_MDS_STRIPE_FID 0x189
8737 for fail_loc in 0x80000188 0x80000189; do
8738 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
8739 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
8740 error "mkdir $dir-$fail_loc failed"
8741 for i in {0..10}; do
8742 # create may fail on missing stripe
8743 echo $i > $DIR/$tdir-$fail_loc/$i
8745 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8746 error "getdirstripe $tdir-$fail_loc failed"
8747 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
8748 error "migrate $tdir-$fail_loc failed"
8749 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8750 error "getdirstripe $tdir-$fail_loc failed"
8751 pushd $DIR/$tdir-$fail_loc
8753 echo $f | cmp $f - || error "$f data mismatch"
8756 rm -rf $DIR/$tdir-$fail_loc
8759 run_test 60h "striped directory with missing stripes can be accessed"
8761 function t60i_load() {
8763 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
8764 $LCTL set_param fail_loc=0x131c fail_val=1
8765 for ((i=0; i<5000; i++)); do
8766 touch $DIR/$tdir/f$i
8771 changelog_register || error "changelog_register failed"
8772 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
8773 changelog_users $SINGLEMDS | grep -q $cl_user ||
8774 error "User $cl_user not found in changelog_users"
8775 changelog_chmask "ALL"
8778 for((i=0; i<100; i++)); do
8779 changelog_dump >/dev/null ||
8780 error "can't read changelog"
8784 changelog_deregister || error "changelog_deregister failed"
8785 $LCTL set_param fail_loc=0
8787 run_test 60i "llog: new record vs reader race"
8790 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8793 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
8794 cancel_lru_locks osc
8795 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
8798 run_test 61a "mmap() writes don't make sync hang ================"
8801 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
8803 run_test 61b "mmap() of unstriped file is successful"
8805 # bug 2330 - insufficient obd_match error checking causes LBUG
8807 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8811 cancel_lru_locks osc
8812 lctl set_param fail_loc=0x405
8813 cat $f && error "cat succeeded, expect -EIO"
8814 lctl set_param fail_loc=0
8816 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
8817 # match every page all of the time.
8818 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
8820 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
8821 # Though this test is irrelevant anymore, it helped to reveal some
8822 # other grant bugs (LU-4482), let's keep it.
8823 test_63a() { # was test_63
8824 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8826 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
8828 for i in `seq 10` ; do
8829 dd if=/dev/zero of=$DIR/f63 bs=8k &
8835 rm -f $DIR/f63 || true
8837 run_test 63a "Verify oig_wait interruption does not crash ======="
8839 # bug 2248 - async write errors didn't return to application on sync
8840 # bug 3677 - async write errors left page locked
8842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8845 lctl set_param debug=-1
8847 # ensure we have a grant to do async writes
8848 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
8851 sync # sync lest earlier test intercept the fail_loc
8853 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8854 lctl set_param fail_loc=0x80000406
8855 $MULTIOP $DIR/$tfile Owy && \
8856 error "sync didn't return ENOMEM"
8857 sync; sleep 2; sync # do a real sync this time to flush page
8858 lctl get_param -n llite.*.dump_page_cache | grep locked && \
8859 error "locked page left in cache after async error" || true
8862 run_test 63b "async write errors should be returned to fsync ==="
8865 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8868 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
8870 run_test 64a "verify filter grant calculations (in kernel) ====="
8873 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8875 bash oos.sh $MOUNT || error "oos.sh failed: $?"
8877 run_test 64b "check out-of-space detection on client"
8880 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
8882 run_test 64c "verify grant shrink"
8888 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
8891 # this does exactly what osc_request.c:osc_announce_cached() does in
8892 # order to calculate max amount of grants to ask from server
8896 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
8897 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
8899 ((rpc_in_flight++));
8900 nrpages=$((nrpages * rpc_in_flight))
8902 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
8904 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
8906 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
8907 local undirty=$((nrpages * PAGE_SIZE))
8909 local max_extent_pages
8910 max_extent_pages=$(import_param $tgt grant_max_extent_size)
8911 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
8912 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
8913 local grant_extent_tax
8914 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8916 undirty=$((undirty + nrextents * grant_extent_tax))
8921 # this is size of unit for grant allocation. It should be equal to
8922 # what tgt_grant.c:tgt_grant_chunk() calculates
8926 local grant_extent_tax
8928 max_brw_size=$(import_param $tgt max_brw_size)
8930 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8932 echo $(((max_brw_size + grant_extent_tax) * 2))
8936 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
8937 skip "OST < 2.10.55 doesn't limit grants enough"
8939 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
8941 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
8942 skip "no grant_param connect flag"
8944 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
8946 $LCTL set_param -n -n debug="$OLDDEBUG" || true
8947 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
8950 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
8951 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
8953 $LFS setstripe $DIR/$tfile -i 0 -c 1
8954 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
8957 while kill -0 $ddpid; do
8958 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8960 if [[ $cur_grant -gt $max_cur_granted ]]; then
8962 error "cur_grant $cur_grant > $max_cur_granted"
8968 run_test 64d "check grant limit exceed"
8974 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8976 ((cur_grants == expected)) ||
8977 error "$msg: grants mismatch: $cur_grants, expected $expected"
8981 echo $((($1 + $2 - 1) & ~($2 - 1)))
8985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8986 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
8987 skip "Need OSS version at least 2.11.56"
8989 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
8990 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
8991 $LCTL set_param debug=+cache
8993 # Remount client to reset grant
8994 remount_client $MOUNT || error "failed to remount client"
8995 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8997 local init_grants=$(import_param $osc_tgt initial_grant)
8999 check_grants $osc_tgt $init_grants "init grants"
9001 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9002 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9003 local gbs=$(import_param $osc_tgt grant_block_size)
9005 # write random number of bytes from max_brw_size / 4 to max_brw_size
9006 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9007 # align for direct io
9008 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9009 # round to grant consumption unit
9010 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9012 local grants=$((wb_round_up + extent_tax))
9014 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9016 # define OBD_FAIL_TGT_NO_GRANT 0x725
9017 # make the server not grant more back
9018 do_facet ost1 $LCTL set_param fail_loc=0x725
9019 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
9021 do_facet ost1 $LCTL set_param fail_loc=0
9023 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
9025 rm -f $DIR/$tfile || error "rm failed"
9027 # Remount client to reset grant
9028 remount_client $MOUNT || error "failed to remount client"
9029 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9031 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9033 # define OBD_FAIL_TGT_NO_GRANT 0x725
9034 # make the server not grant more back
9035 do_facet ost1 $LCTL set_param fail_loc=0x725
9036 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
9037 do_facet ost1 $LCTL set_param fail_loc=0
9039 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
9041 run_test 64e "check grant consumption (no grant allocation)"
9044 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9046 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9047 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9048 $LCTL set_param debug=+cache
9050 # Remount client to reset grant
9051 remount_client $MOUNT || error "failed to remount client"
9052 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9054 local init_grants=$(import_param $osc_tgt initial_grant)
9055 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9056 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9057 local gbs=$(import_param $osc_tgt grant_block_size)
9058 local chunk=$(grant_chunk $osc_tgt)
9060 # write random number of bytes from max_brw_size / 4 to max_brw_size
9061 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9062 # align for direct io
9063 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9064 # round to grant consumption unit
9065 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9067 local grants=$((wb_round_up + extent_tax))
9069 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9070 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
9071 error "error writing to $DIR/$tfile"
9073 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9074 "direct io with grant allocation"
9076 rm -f $DIR/$tfile || error "rm failed"
9078 # Remount client to reset grant
9079 remount_client $MOUNT || error "failed to remount client"
9080 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9082 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9084 local cmd="oO_WRONLY:w${write_bytes}_yc"
9086 $MULTIOP $DIR/$tfile $cmd &
9090 check_grants $osc_tgt $((init_grants - grants)) \
9091 "buffered io, not write rpc"
9093 kill -USR1 $MULTIPID
9096 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9097 "buffered io, one RPC"
9099 run_test 64f "check grant consumption (with grant allocation)"
9102 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
9103 skip "Need MDS version at least 2.14.56"
9105 local mdts=$(comma_list $(mdts_nodes))
9107 local old=$($LCTL get_param mdc.$FSNAME-*.grant_shrink_interval |
9109 stack_trap "$LCTL set_param $old"
9111 # generate dirty pages and increase dirty granted on MDT
9112 stack_trap "rm -f $DIR/$tfile-*"
9113 for (( i = 0; i < 10; i++)); do
9114 $LFS setstripe -E 1M -L mdt $DIR/$tfile-$i ||
9115 error "can't set stripe"
9116 dd if=/dev/zero of=$DIR/$tfile-$i bs=128k count=1 ||
9118 $LFS getstripe $DIR/$tfile-$i | grep -q pattern.*mdt || {
9119 $LFS getstripe $DIR/$tfile-$i
9120 error "not DoM file"
9127 # wait until grant shrink reset grant dirty on MDTs
9128 for ((i = 0; i < 120; i++)); do
9129 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9130 awk '{sum=sum+$1} END {print sum}')
9131 vm_dirty=$(awk '/Dirty:/{print $2}' /proc/meminfo)
9132 echo "$grant_dirty grants, $vm_dirty pages"
9133 (( grant_dirty + vm_dirty == 0 )) && break
9134 (( i == 3 )) && sync &&
9135 $LCTL set_param mdc.$FSNAME-*.grant_shrink_interval=5
9139 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9140 awk '{sum=sum+$1} END {print sum}')
9141 (( grant_dirty == 0 )) || error "$grant_dirty on MDT"
9143 run_test 64g "grant shrink on MDT"
9146 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9147 skip "need OST at least 2.14.56 to avoid grant shrink on read"
9149 local instance=$($LFS getname -i $DIR)
9150 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9151 local num_exps=$(do_facet ost1 \
9152 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
9153 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9154 local avail=$($LCTL get_param -n osc.*OST0000-osc-$instance.kbytesavail)
9155 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9157 # 10MiB is for file to be written, max_brw_size * 16 *
9158 # num_exps is space reserve so that tgt_grant_shrink() decided
9160 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
9161 (( avail * 1024 < expect )) &&
9162 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
9164 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
9165 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
9166 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
9167 $LCTL set_param osc.*OST0000*.grant_shrink=1
9168 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
9170 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9171 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
9173 # drop cache so that coming read would do rpc
9174 cancel_lru_locks osc
9176 # shrink interval is set to 10, pause for 7 seconds so that
9177 # grant thread did not wake up yet but coming read entered
9178 # shrink mode for rpc (osc_should_shrink_grant())
9181 declare -a cur_grant_bytes
9182 declare -a tot_granted
9183 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9184 tot_granted[0]=$(do_facet ost1 \
9185 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9187 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
9189 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9190 tot_granted[1]=$(do_facet ost1 \
9191 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9193 # grant change should be equal on both sides
9194 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
9195 tot_granted[0] - tot_granted[1])) ||
9196 error "grant change mismatch, " \
9197 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
9198 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
9200 run_test 64h "grant shrink on read"
9203 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9204 skip "need OST at least 2.14.56 to avoid grant shrink on replay"
9206 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9207 remote_ost_nodsh && skip "remote OSTs with nodsh"
9209 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9211 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
9213 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
9214 local instance=$($LFS getname -i $DIR)
9216 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9217 local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
9219 # shrink grants and simulate rpc loss
9220 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
9221 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
9222 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
9226 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
9228 local testid=$(echo $TESTNAME | tr '_' ' ')
9230 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
9231 grep "GRANT, real grant" &&
9232 error "client has more grants then it owns" || true
9234 run_test 64i "shrink on reconnect"
9236 # bug 1414 - set/get directories' stripe info
9238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9240 test_mkdir $DIR/$tdir
9242 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
9244 run_test 65a "directory with no stripe info"
9247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9249 test_mkdir $DIR/$tdir
9250 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9252 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9255 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
9257 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
9260 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9261 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
9263 test_mkdir $DIR/$tdir
9264 local stripesize=$($LFS getstripe -S $DIR/$tdir)
9266 $LFS setstripe -S $((stripesize * 4)) -i 1 \
9267 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
9269 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
9271 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
9274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9276 test_mkdir $DIR/$tdir
9277 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
9278 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9280 if [[ $STRIPECOUNT -le 0 ]]; then
9282 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
9283 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
9284 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
9286 sc=$(($STRIPECOUNT - 1))
9288 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
9289 touch $DIR/$tdir/f4 $DIR/$tdir/f5
9290 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
9291 error "lverify failed"
9293 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
9296 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9298 test_mkdir $DIR/$tdir
9300 $LFS setstripe $DIR/$tdir || error "setstripe"
9301 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9302 error "no stripe info failed"
9304 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
9306 run_test 65e "directory setstripe defaults"
9309 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9311 test_mkdir $DIR/${tdir}f
9312 $RUNAS $LFS setstripe $DIR/${tdir}f &&
9313 error "setstripe succeeded" || true
9315 run_test 65f "dir setstripe permission (should return error) ==="
9318 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9320 test_mkdir $DIR/$tdir
9321 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9323 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9324 error "setstripe -S failed"
9325 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
9326 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9327 error "delete default stripe failed"
9329 run_test 65g "directory setstripe -d"
9332 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9334 test_mkdir $DIR/$tdir
9335 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9337 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9338 error "setstripe -S failed"
9339 test_mkdir $DIR/$tdir/dd1
9340 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
9341 error "stripe info inherit failed"
9343 run_test 65h "directory stripe info inherit ===================="
9346 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9348 save_layout_restore_at_exit $MOUNT
9350 # bug6367: set non-default striping on root directory
9351 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
9353 # bug12836: getstripe on -1 default directory striping
9354 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
9356 # bug12836: getstripe -v on -1 default directory striping
9357 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
9359 # bug12836: new find on -1 default directory striping
9360 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
9362 run_test 65i "various tests to set root directory striping"
9364 test_65j() { # bug6367
9365 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9369 # if we aren't already remounting for each test, do so for this test
9370 if [ "$I_MOUNTED" = "yes" ]; then
9371 cleanup || error "failed to unmount"
9375 save_layout_restore_at_exit $MOUNT
9377 $LFS setstripe -d $MOUNT || error "setstripe failed"
9379 run_test 65j "set default striping on root directory (bug 6367)="
9383 wait_delete_completed
9384 do_facet $SINGLEMDS "lctl set_param -n \
9385 osp.$ost*MDT0000.max_create_count=$max_count"
9386 do_facet $SINGLEMDS "lctl set_param -n \
9387 osp.$ost*MDT0000.create_count=$count"
9388 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9389 echo $INACTIVE_OSC "is Activate"
9391 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9394 test_65k() { # bug11679
9395 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9396 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9397 remote_mds_nodsh && skip "remote MDS with nodsh"
9399 local disable_precreate=true
9400 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
9401 disable_precreate=false
9403 echo "Check OST status: "
9404 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
9405 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
9407 for OSC in $MDS_OSCS; do
9408 echo $OSC "is active"
9409 do_facet $SINGLEMDS lctl --device %$OSC activate
9412 for INACTIVE_OSC in $MDS_OSCS; do
9413 local ost=$(osc_to_ost $INACTIVE_OSC)
9414 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
9415 lov.*md*.target_obd |
9416 awk -F: /$ost/'{ print $1 }' | head -n 1)
9419 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
9420 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
9422 echo "Deactivate: " $INACTIVE_OSC
9423 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
9425 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
9426 osp.$ost*MDT0000.create_count")
9427 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
9428 osp.$ost*MDT0000.max_create_count")
9429 $disable_precreate &&
9430 do_facet $SINGLEMDS "lctl set_param -n \
9431 osp.$ost*MDT0000.max_create_count=0"
9433 for idx in $(seq 0 $((OSTCOUNT - 1))); do
9434 [ -f $DIR/$tdir/$idx ] && continue
9435 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
9436 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
9438 error "setstripe $idx should succeed"; }
9439 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
9441 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
9444 do_facet $SINGLEMDS "lctl set_param -n \
9445 osp.$ost*MDT0000.max_create_count=$max_count"
9446 do_facet $SINGLEMDS "lctl set_param -n \
9447 osp.$ost*MDT0000.create_count=$count"
9448 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9449 echo $INACTIVE_OSC "is Activate"
9451 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9454 run_test 65k "validate manual striping works properly with deactivated OSCs"
9456 test_65l() { # bug 12836
9457 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9459 test_mkdir -p $DIR/$tdir/test_dir
9460 $LFS setstripe -c -1 $DIR/$tdir/test_dir
9461 $LFS find -mtime -1 $DIR/$tdir >/dev/null
9463 run_test 65l "lfs find on -1 stripe dir ========================"
9466 local layout=$(save_layout $MOUNT)
9467 $RUNAS $LFS setstripe -c 2 $MOUNT && {
9468 restore_layout $MOUNT $layout
9469 error "setstripe should fail by non-root users"
9473 run_test 65m "normal user can't set filesystem default stripe"
9476 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
9477 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
9478 skip "Need MDS version at least 2.12.50"
9479 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9481 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
9482 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
9483 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
9485 save_layout_restore_at_exit $MOUNT
9487 # new subdirectory under root directory should not inherit
9488 # the default layout from root
9489 local dir1=$MOUNT/$tdir-1
9490 mkdir $dir1 || error "mkdir $dir1 failed"
9491 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
9492 error "$dir1 shouldn't have LOV EA"
9494 # delete the default layout on root directory
9495 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
9497 local dir2=$MOUNT/$tdir-2
9498 mkdir $dir2 || error "mkdir $dir2 failed"
9499 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
9500 error "$dir2 shouldn't have LOV EA"
9502 # set a new striping pattern on root directory
9503 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9504 local new_def_stripe_size=$((def_stripe_size * 2))
9505 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
9506 error "set stripe size on $MOUNT failed"
9508 # new file created in $dir2 should inherit the new stripe size from
9509 # the filesystem default
9510 local file2=$dir2/$tfile-2
9511 touch $file2 || error "touch $file2 failed"
9513 local file2_stripe_size=$($LFS getstripe -S $file2)
9514 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
9516 echo "file2_stripe_size: '$file2_stripe_size'"
9517 echo "new_def_stripe_size: '$new_def_stripe_size'"
9518 error "$file2 didn't inherit stripe size $new_def_stripe_size"
9521 local dir3=$MOUNT/$tdir-3
9522 mkdir $dir3 || error "mkdir $dir3 failed"
9523 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
9524 # the root layout, which is the actual default layout that will be used
9525 # when new files are created in $dir3.
9526 local dir3_layout=$(get_layout_param $dir3)
9527 local root_dir_layout=$(get_layout_param $MOUNT)
9528 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
9530 echo "dir3_layout: '$dir3_layout'"
9531 echo "root_dir_layout: '$root_dir_layout'"
9532 error "$dir3 should show the default layout from $MOUNT"
9535 # set OST pool on root directory
9536 local pool=$TESTNAME
9537 pool_add $pool || error "add $pool failed"
9538 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9539 error "add targets to $pool failed"
9541 $LFS setstripe -p $pool $MOUNT ||
9542 error "set OST pool on $MOUNT failed"
9544 # new file created in $dir3 should inherit the pool from
9545 # the filesystem default
9546 local file3=$dir3/$tfile-3
9547 touch $file3 || error "touch $file3 failed"
9549 local file3_pool=$($LFS getstripe -p $file3)
9550 [[ "$file3_pool" = "$pool" ]] ||
9551 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
9553 local dir4=$MOUNT/$tdir-4
9554 mkdir $dir4 || error "mkdir $dir4 failed"
9555 local dir4_layout=$(get_layout_param $dir4)
9556 root_dir_layout=$(get_layout_param $MOUNT)
9557 echo "$LFS getstripe -d $dir4"
9558 $LFS getstripe -d $dir4
9559 echo "$LFS getstripe -d $MOUNT"
9560 $LFS getstripe -d $MOUNT
9561 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
9563 echo "dir4_layout: '$dir4_layout'"
9564 echo "root_dir_layout: '$root_dir_layout'"
9565 error "$dir4 should show the default layout from $MOUNT"
9568 # new file created in $dir4 should inherit the pool from
9569 # the filesystem default
9570 local file4=$dir4/$tfile-4
9571 touch $file4 || error "touch $file4 failed"
9573 local file4_pool=$($LFS getstripe -p $file4)
9574 [[ "$file4_pool" = "$pool" ]] ||
9575 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
9577 # new subdirectory under non-root directory should inherit
9578 # the default layout from its parent directory
9579 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
9580 error "set directory layout on $dir4 failed"
9582 local dir5=$dir4/$tdir-5
9583 mkdir $dir5 || error "mkdir $dir5 failed"
9585 dir4_layout=$(get_layout_param $dir4)
9586 local dir5_layout=$(get_layout_param $dir5)
9587 [[ "$dir4_layout" = "$dir5_layout" ]] ||
9589 echo "dir4_layout: '$dir4_layout'"
9590 echo "dir5_layout: '$dir5_layout'"
9591 error "$dir5 should inherit the default layout from $dir4"
9594 # though subdir under ROOT doesn't inherit default layout, but
9595 # its sub dir/file should be created with default layout.
9596 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
9597 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
9598 skip "Need MDS version at least 2.12.59"
9600 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
9601 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
9602 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
9604 if [ $default_lmv_hash == "none" ]; then
9605 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
9607 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
9608 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
9611 $LFS setdirstripe -D -c 2 $MOUNT ||
9612 error "setdirstripe -D -c 2 failed"
9613 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
9614 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
9615 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
9617 # $dir4 layout includes pool
9618 $LFS setstripe -S $((new_def_stripe_size * 2)) $dir4
9619 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9620 error "pool lost on setstripe"
9621 $LFS setstripe -E -1 -S $new_def_stripe_size $dir4
9622 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9623 error "pool lost on compound layout setstripe"
9625 run_test 65n "don't inherit default layout from root for new subdirectories"
9628 (( $MDS1_VERSION >= $(version_code 2.14.57) )) ||
9629 skip "need MDS version at least 2.14.57"
9631 # set OST pool on root directory
9632 local pool=$TESTNAME
9634 pool_add $pool || error "add $pool failed"
9635 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9636 error "add targets to $pool failed"
9638 local dir1=$MOUNT/$tdir
9640 mkdir $dir1 || error "mkdir $dir1 failed"
9642 # set a new striping pattern on root directory
9643 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9645 $LFS setstripe -p $pool $dir1 ||
9646 error "set directory layout on $dir1 failed"
9648 # $dir1 layout includes pool
9649 $LFS setstripe -S $((def_stripe_size * 2)) $dir1
9650 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9651 error "pool lost on setstripe"
9652 $LFS setstripe -E 1M -L mdt -E -1 -c 1 $dir1
9653 $LFS getstripe $dir1
9654 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9655 error "pool lost on compound layout setstripe"
9657 $LFS setdirstripe -i 0 -c 2 $dir1/dir2 ||
9658 error "setdirstripe failed on sub-dir with inherited pool"
9659 $LFS getstripe $dir1/dir2
9660 [[ "$pool" = $($LFS getstripe -p -d $dir1/dir2) ]] ||
9661 error "pool lost on compound layout setdirstripe"
9663 $LFS setstripe -E -1 -c 1 $dir1
9664 $LFS getstripe -d $dir1
9665 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9666 error "pool lost on setstripe"
9668 run_test 65o "pool inheritance for mdt component"
9670 # bug 2543 - update blocks count on client
9672 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9674 local COUNT=${COUNT:-8}
9675 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
9676 sync; sync_all_data; sync; sync_all_data
9677 cancel_lru_locks osc
9678 local BLOCKS=$(ls -s --block-size=1k $DIR/f66 | awk '{ print $1 }')
9679 (( BLOCKS >= COUNT )) || error "$DIR/f66 blocks $BLOCKS < $COUNT"
9681 run_test 66 "update inode blocks count on client ==============="
9684 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
9688 swapon -s | awk '($1 == "'$1'") { print $4 }'
9691 # bug5265, obdfilter oa2dentry return -ENOENT
9692 # #define OBD_FAIL_SRV_ENOENT 0x217
9694 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9695 remote_ost_nodsh && skip "remote OST with nodsh"
9698 $LFS setstripe -c 1 -i 0 $f
9700 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
9702 do_facet ost1 lctl set_param fail_loc=0x217
9703 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
9704 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
9706 do_facet ost1 lctl set_param fail_loc=0
9707 $DIRECTIO write $f 0 2 || error "write error"
9709 cancel_lru_locks osc
9710 $DIRECTIO read $f 0 1 || error "read error"
9712 do_facet ost1 lctl set_param fail_loc=0x217
9713 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
9715 do_facet ost1 lctl set_param fail_loc=0
9718 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
9721 test_mkdir $DIR/$tdir
9722 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
9723 bash rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
9725 run_test 71 "Running dbench on lustre (don't segment fault) ===="
9727 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
9728 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9729 [ "$RUNAS_ID" = "$UID" ] &&
9730 skip_env "RUNAS_ID = UID = $UID -- skipping"
9731 # Check that testing environment is properly set up. Skip if not
9732 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
9733 skip_env "User $RUNAS_ID does not exist - skipping"
9736 chmod 777 $DIR/$tfile
9737 chmod ug+s $DIR/$tfile
9738 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
9739 error "$RUNAS dd $DIR/$tfile failed"
9740 # See if we are still setuid/sgid
9741 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9742 error "S/gid is not dropped on write"
9743 # Now test that MDS is updated too
9744 cancel_lru_locks mdc
9745 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9746 error "S/gid is not dropped on MDS"
9749 run_test 72a "Test that remove suid works properly (bug5695) ===="
9751 test_72b() { # bug 24226 -- keep mode setting when size is not changing
9754 [ "$RUNAS_ID" = "$UID" ] &&
9755 skip_env "RUNAS_ID = UID = $UID -- skipping"
9756 [ "$RUNAS_ID" -eq 0 ] &&
9757 skip_env "RUNAS_ID = 0 -- skipping"
9758 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9759 # Check that testing environment is properly set up. Skip if not
9760 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
9761 skip_env "User $RUNAS_ID does not exist - skipping"
9763 touch $DIR/${tfile}-f{g,u}
9764 test_mkdir $DIR/${tfile}-dg
9765 test_mkdir $DIR/${tfile}-du
9766 chmod 770 $DIR/${tfile}-{f,d}{g,u}
9767 chmod g+s $DIR/${tfile}-{f,d}g
9768 chmod u+s $DIR/${tfile}-{f,d}u
9769 for perm in 777 2777 4777; do
9770 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
9771 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
9772 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
9773 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
9777 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
9779 # bug 3462 - multiple simultaneous MDC requests
9781 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9783 test_mkdir $DIR/d73-1
9784 test_mkdir $DIR/d73-2
9785 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
9788 lctl set_param fail_loc=0x80000129
9789 $MULTIOP $DIR/d73-1/f73-2 Oc &
9791 lctl set_param fail_loc=0
9793 $MULTIOP $DIR/d73-2/f73-3 Oc &
9797 wait $pid1 || return 1
9801 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
9802 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
9803 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
9807 run_test 73 "multiple MDC requests (should not deadlock)"
9809 test_74a() { # bug 6149, 6184
9810 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9813 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9815 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9816 # will spin in a tight reconnection loop
9817 $LCTL set_param fail_loc=0x8000030e
9818 # get any lock that won't be difficult - lookup works.
9820 $LCTL set_param fail_loc=0
9824 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
9826 test_74b() { # bug 13310
9827 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9829 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9831 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9832 # will spin in a tight reconnection loop
9833 $LCTL set_param fail_loc=0x8000030e
9834 # get a "difficult" lock
9836 $LCTL set_param fail_loc=0
9840 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
9843 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9845 #define OBD_FAIL_LDLM_NEW_LOCK
9846 $LCTL set_param fail_loc=0x319
9847 touch $DIR/$tfile && error "touch successful"
9848 $LCTL set_param fail_loc=0
9851 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
9853 slab_lic=/sys/kernel/slab/lustre_inode_cache
9855 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
9856 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
9857 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
9860 test_76a() { # Now for b=20433, added originally in b=1443
9861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9863 cancel_lru_locks osc
9864 # there may be some slab objects cached per core
9865 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
9866 local before=$(num_objects)
9867 local count=$((512 * cpus))
9868 [ "$SLOW" = "no" ] && count=$((128 * cpus))
9869 local margin=$((count / 10))
9870 if [[ -f $slab_lic/aliases ]]; then
9871 local aliases=$(cat $slab_lic/aliases)
9872 (( aliases > 0 )) && margin=$((margin * aliases))
9875 echo "before slab objects: $before"
9876 for i in $(seq $count); do
9880 cancel_lru_locks osc
9881 local after=$(num_objects)
9882 echo "created: $count, after slab objects: $after"
9883 # shared slab counts are not very accurate, allow significant margin
9884 # the main goal is that the cache growth is not permanently > $count
9885 while (( after > before + margin )); do
9887 after=$(num_objects)
9889 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9890 if (( wait > 60 )); then
9891 error "inode slab grew from $before+$margin to $after"
9895 run_test 76a "confirm clients recycle inodes properly ===="
9898 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9899 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
9902 local before=$(num_objects)
9904 for i in $(seq $count); do
9909 local after=$(num_objects)
9912 while (( after > before )); do
9914 after=$(num_objects)
9916 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9917 if (( wait > 60 )); then
9918 error "inode slab grew from $before to $after"
9922 echo "slab objects before: $before, after: $after"
9924 run_test 76b "confirm clients recycle directory inodes properly ===="
9929 # Note: in sptlrpc modes which enable its own bulk checksum, the
9930 # original crc32_le bulk checksum will be automatically disabled,
9931 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
9932 # will be checked by sptlrpc code against sptlrpc bulk checksum.
9933 # In this case set_checksums() will not be no-op, because sptlrpc
9934 # bulk checksum will be enabled all through the test.
9936 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
9937 lctl set_param -n osc.*.checksums $1
9941 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9942 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
9943 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9944 tr -d [] | head -n1)}
9947 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
9949 log "set checksum type to $1, rc = $rc"
9953 get_osc_checksum_type()
9955 # arugment 1: OST name, like OST0000
9957 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
9958 sed 's/.*\[\(.*\)\].*/\1/g')
9960 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
9964 F77_TMP=$TMP/f77-temp
9967 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
9968 error "error writing to $F77_TMP"
9971 test_77a() { # bug 10889
9972 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9973 $GSS && skip_env "could not run with gss"
9975 [ ! -f $F77_TMP ] && setup_f77
9977 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
9981 run_test 77a "normal checksum read/write operation"
9983 test_77b() { # bug 10889
9984 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9985 $GSS && skip_env "could not run with gss"
9987 [ ! -f $F77_TMP ] && setup_f77
9988 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9989 $LCTL set_param fail_loc=0x80000409
9992 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9993 error "dd error: $?"
9994 $LCTL set_param fail_loc=0
9996 for algo in $CKSUM_TYPES; do
9997 cancel_lru_locks osc
9998 set_checksum_type $algo
9999 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10000 $LCTL set_param fail_loc=0x80000408
10001 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
10002 $LCTL set_param fail_loc=0
10005 set_checksum_type $ORIG_CSUM_TYPE
10008 run_test 77b "checksum error on client write, read"
10013 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
10015 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
10016 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
10017 $check_ost && [ -n "$ost_file_prefix" ] &&
10018 do_facet ost1 rm -f ${ost_file_prefix}\*
10022 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10023 $GSS && skip_env "could not run with gss"
10024 remote_ost_nodsh && skip "remote OST with nodsh"
10027 local osc_file_prefix
10029 local check_ost=false
10030 local ost_file_prefix
10036 # ensure corruption will occur on first OSS/OST
10037 $LFS setstripe -i 0 $DIR/$tfile
10039 [ ! -f $F77_TMP ] && setup_f77
10040 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10041 error "dd write error: $?"
10042 fid=$($LFS path2fid $DIR/$tfile)
10044 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
10047 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
10048 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
10050 echo "OSS do not support bulk pages dump upon error"
10053 osc_file_prefix=$($LCTL get_param -n debug_path)
10054 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
10056 trap cleanup_77c EXIT
10059 # enable bulk pages dump upon error on Client
10060 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
10061 # enable bulk pages dump upon error on OSS
10063 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
10065 # flush Client cache to allow next read to reach OSS
10066 cancel_lru_locks osc
10068 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10069 $LCTL set_param fail_loc=0x80000408
10070 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
10071 $LCTL set_param fail_loc=0
10075 # check cksum dump on Client
10076 osc_file=$(ls ${osc_file_prefix}*)
10077 [ -n "$osc_file" ] || error "no checksum dump file on Client"
10078 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
10079 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
10080 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
10081 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
10083 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
10084 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10085 error "dump content does not match on Client"
10087 $check_ost || skip "No need to check cksum dump on OSS"
10089 # check cksum dump on OSS
10090 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
10091 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
10092 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
10093 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
10094 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10095 error "dump content does not match on OSS"
10099 run_test 77c "checksum error on client read with debug"
10101 test_77d() { # bug 10889
10102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10103 $GSS && skip_env "could not run with gss"
10105 stack_trap "rm -f $DIR/$tfile"
10106 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10107 $LCTL set_param fail_loc=0x80000409
10109 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10110 error "direct write: rc=$?"
10111 $LCTL set_param fail_loc=0
10114 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10115 $LCTL set_param fail_loc=0x80000408
10117 cancel_lru_locks osc
10118 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10119 error "direct read: rc=$?"
10120 $LCTL set_param fail_loc=0
10123 run_test 77d "checksum error on OST direct write, read"
10125 test_77f() { # bug 10889
10126 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10127 $GSS && skip_env "could not run with gss"
10130 stack_trap "rm -f $DIR/$tfile"
10131 for algo in $CKSUM_TYPES; do
10132 cancel_lru_locks osc
10133 set_checksum_type $algo
10134 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10135 $LCTL set_param fail_loc=0x409
10136 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
10137 error "direct write succeeded"
10138 $LCTL set_param fail_loc=0
10140 set_checksum_type $ORIG_CSUM_TYPE
10143 run_test 77f "repeat checksum error on write (expect error)"
10145 test_77g() { # bug 10889
10146 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10147 $GSS && skip_env "could not run with gss"
10148 remote_ost_nodsh && skip "remote OST with nodsh"
10150 [ ! -f $F77_TMP ] && setup_f77
10152 local file=$DIR/$tfile
10153 stack_trap "rm -f $file" EXIT
10155 $LFS setstripe -c 1 -i 0 $file
10156 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
10157 do_facet ost1 lctl set_param fail_loc=0x8000021a
10159 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
10160 error "write error: rc=$?"
10161 do_facet ost1 lctl set_param fail_loc=0
10164 cancel_lru_locks osc
10165 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
10166 do_facet ost1 lctl set_param fail_loc=0x8000021b
10168 cmp $F77_TMP $file || error "file compare failed"
10169 do_facet ost1 lctl set_param fail_loc=0
10172 run_test 77g "checksum error on OST write, read"
10174 test_77k() { # LU-10906
10175 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10176 $GSS && skip_env "could not run with gss"
10178 local cksum_param="osc.$FSNAME*.checksums"
10179 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
10183 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
10184 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
10185 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
10188 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
10189 error "failed to set checksum=$i on MGS"
10190 wait_update $HOSTNAME "$get_checksum" $i
10192 echo "remount client, checksum should be $i"
10193 remount_client $MOUNT || error "failed to remount client"
10194 checksum=$(eval $get_checksum)
10195 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10197 # remove persistent param to avoid races with checksum mountopt below
10198 do_facet mgs $LCTL set_param -P -d $cksum_param ||
10199 error "failed to delete checksum on MGS"
10201 for opt in "checksum" "nochecksum"; do
10202 #remount with mount option
10203 echo "remount client with option $opt, checksum should be $i"
10204 umount_client $MOUNT || error "failed to umount client"
10205 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
10206 error "failed to mount client with option '$opt'"
10207 checksum=$(eval $get_checksum)
10208 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10212 remount_client $MOUNT || error "failed to remount client"
10214 run_test 77k "enable/disable checksum correctly"
10217 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10218 $GSS && skip_env "could not run with gss"
10221 stack_trap "set_checksums $ORIG_CSUM" EXIT
10222 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10224 set_checksum_type invalid && error "unexpected success of invalid checksum type"
10226 $LFS setstripe -c 1 -i 0 $DIR/$tfile
10227 for algo in $CKSUM_TYPES; do
10228 set_checksum_type $algo || error "fail to set checksum type $algo"
10229 osc_algo=$(get_osc_checksum_type OST0000)
10230 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
10232 # no locks, no reqs to let the connection idle
10233 cancel_lru_locks osc
10234 lru_resize_disable osc
10235 wait_osc_import_state client ost1 IDLE
10237 # ensure ost1 is connected
10238 stat $DIR/$tfile >/dev/null || error "can't stat"
10239 wait_osc_import_state client ost1 FULL
10241 osc_algo=$(get_osc_checksum_type OST0000)
10242 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
10246 run_test 77l "preferred checksum type is remembered after reconnected"
10248 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
10253 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
10254 skip "Need at least version 2.14.52"
10255 local param=checksum_speed
10257 $LCTL get_param $param || error "reading $param failed"
10259 csum_speeds=$($LCTL get_param -n $param)
10261 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
10262 error "known checksum types are missing"
10264 run_test 77m "Verify checksum_speed is correctly read"
10266 check_filefrag_77n() {
10271 while read extidx a b start end rest; do
10272 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
10273 nr_ext=$(( $nr_ext + 1 ))
10274 starts+=( ${start%..} )
10277 done < <( filefrag -sv $1 )
10279 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
10284 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
10287 $TRUNCATE $DIR/$tfile 0
10288 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
10289 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
10290 check_filefrag_77n $DIR/$tfile ||
10291 skip "$tfile blocks not contiguous around hole"
10294 stack_trap "set_checksums $ORIG_CSUM" EXIT
10295 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10296 stack_trap "rm -f $DIR/$tfile"
10298 for algo in $CKSUM_TYPES; do
10299 if [[ "$algo" =~ ^t10 ]]; then
10300 set_checksum_type $algo ||
10301 error "fail to set checksum type $algo"
10302 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
10303 error "fail to read $tfile with $algo"
10309 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
10312 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
10313 skip "Need MDS version at least 2.14.55"
10314 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
10315 skip "Need OST version at least 2.14.55"
10316 local ofd=obdfilter
10319 # print OST checksum_type
10320 echo "$ofd.$FSNAME-*.checksum_type:"
10321 do_nodes $(comma_list $(osts_nodes)) \
10322 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type
10324 # print MDT checksum_type
10325 echo "$mdt.$FSNAME-*.checksum_type:"
10326 do_nodes $(comma_list $(mdts_nodes)) \
10327 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type
10329 local o_count=$(do_nodes $(comma_list $(osts_nodes)) \
10330 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l)
10332 (( $o_count == $OSTCOUNT )) ||
10333 error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT"
10335 local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \
10336 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l)
10338 (( $m_count == $MDSCOUNT )) ||
10339 error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT"
10341 run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))"
10343 cleanup_test_78() {
10348 test_78() { # bug 10901
10349 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10350 remote_ost || skip_env "local OST"
10353 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
10354 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
10355 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
10356 echo "MemTotal: $MEMTOTAL"
10358 # reserve 256MB of memory for the kernel and other running processes,
10359 # and then take 1/2 of the remaining memory for the read/write buffers.
10360 if [ $MEMTOTAL -gt 512 ] ;then
10361 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
10363 # for those poor memory-starved high-end clusters...
10364 MEMTOTAL=$((MEMTOTAL / 2))
10366 echo "Mem to use for directio: $MEMTOTAL"
10368 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
10369 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
10370 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
10371 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
10373 echo "Smallest OST: $SMALLESTOST"
10374 [[ $SMALLESTOST -lt 10240 ]] &&
10375 skip "too small OSTSIZE, useless to run large O_DIRECT test"
10377 trap cleanup_test_78 EXIT
10379 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
10380 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
10382 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
10383 echo "File size: $F78SIZE"
10384 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
10385 for i in $(seq 1 $NSEQ); do
10386 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
10387 echo directIO rdwr round $i of $NSEQ
10388 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
10393 run_test 78 "handle large O_DIRECT writes correctly ============"
10395 test_79() { # bug 12743
10396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10398 wait_delete_completed
10400 BKTOTAL=$(calc_osc_kbytes kbytestotal)
10401 BKFREE=$(calc_osc_kbytes kbytesfree)
10402 BKAVAIL=$(calc_osc_kbytes kbytesavail)
10404 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
10405 DFTOTAL=`echo $STRING | cut -d, -f1`
10406 DFUSED=`echo $STRING | cut -d, -f2`
10407 DFAVAIL=`echo $STRING | cut -d, -f3`
10408 DFFREE=$(($DFTOTAL - $DFUSED))
10410 ALLOWANCE=$((64 * $OSTCOUNT))
10412 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
10413 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
10414 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
10416 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
10417 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
10418 error "df free($DFFREE) mismatch OST free($BKFREE)"
10420 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
10421 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
10422 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
10425 run_test 79 "df report consistency check ======================="
10427 test_80() { # bug 10718
10428 remote_ost_nodsh && skip "remote OST with nodsh"
10429 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10431 # relax strong synchronous semantics for slow backends like ZFS
10432 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
10433 local soc="obdfilter.*.sync_lock_cancel"
10434 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10436 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
10437 if [ -z "$save" ]; then
10438 soc="obdfilter.*.sync_on_lock_cancel"
10439 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10442 if [ "$save" != "never" ]; then
10443 local hosts=$(comma_list $(osts_nodes))
10445 do_nodes $hosts $LCTL set_param $soc=never
10446 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
10450 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
10451 sync; sleep 1; sync
10452 local before=$(date +%s)
10453 cancel_lru_locks osc
10454 local after=$(date +%s)
10455 local diff=$((after - before))
10456 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
10460 run_test 80 "Page eviction is equally fast at high offsets too"
10462 test_81a() { # LU-456
10463 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10464 remote_ost_nodsh && skip "remote OST with nodsh"
10466 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10467 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
10468 do_facet ost1 lctl set_param fail_loc=0x80000228
10470 # write should trigger a retry and success
10471 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10472 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10474 if [ $RC -ne 0 ] ; then
10475 error "write should success, but failed for $RC"
10478 run_test 81a "OST should retry write when get -ENOSPC ==============="
10480 test_81b() { # LU-456
10481 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10482 remote_ost_nodsh && skip "remote OST with nodsh"
10484 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10485 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
10486 do_facet ost1 lctl set_param fail_loc=0x228
10488 # write should retry several times and return -ENOSPC finally
10489 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10490 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10493 if [ $RC -ne $ENOSPC ] ; then
10494 error "dd should fail for -ENOSPC, but succeed."
10497 run_test 81b "OST should return -ENOSPC when retry still fails ======="
10500 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
10502 test_mkdir $DIR/$tdir.cvsroot
10503 chown $RUNAS_ID $DIR/$tdir.cvsroot
10506 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
10509 # some versions of cvs import exit(1) when asked to import links or
10510 # files they can't read. ignore those files.
10511 local toignore=$(find . -type l -printf '-I %f\n' -o \
10512 ! -perm /4 -printf '-I %f\n')
10513 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
10514 $tdir.reposname vtag rtag
10517 test_mkdir $DIR/$tdir.reposname
10518 chown $RUNAS_ID $DIR/$tdir.reposname
10519 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
10521 cd $DIR/$tdir.reposname
10523 $RUNAS cvs add -m 'addmsg' foo99
10525 $RUNAS cvs commit -m 'nomsg' foo99
10526 rm -fr $DIR/$tdir.cvsroot
10528 run_test 99 "cvs strange file/directory operations"
10531 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10532 [[ "$NETTYPE" =~ tcp ]] ||
10533 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
10534 remote_ost_nodsh && skip "remote OST with nodsh"
10535 remote_mds_nodsh && skip "remote MDS with nodsh"
10537 skip "useless for local single node setup"
10539 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
10540 [ "$PROT" != "tcp" ] && continue
10541 RPORT=$(echo $REMOTE | cut -d: -f2)
10542 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
10545 LPORT=`echo $LOCAL | cut -d: -f2`
10546 if [ $LPORT -ge 1024 ]; then
10547 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
10549 error_exit "local: $LPORT > 1024, remote: $RPORT"
10552 [ "$rc" = 0 ] || error_exit "privileged port not found" )
10554 run_test 100 "check local port using privileged port ==========="
10556 function get_named_value()
10560 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
10563 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
10564 awk '/^max_cached_mb/ { print $2 }')
10567 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
10572 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10577 local cache_limit=32
10579 $LCTL set_param -n osc.*-osc*.rpc_stats=0
10580 trap cleanup_101a EXIT
10581 $LCTL set_param -n llite.*.read_ahead_stats=0
10582 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
10585 # randomly read 10000 of 64K chunks from file 3x 32MB in size
10587 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
10588 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
10591 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
10592 get_named_value 'read.but.discarded'); do
10593 discard=$(($discard + $s))
10597 $LCTL get_param osc.*-osc*.rpc_stats
10598 $LCTL get_param llite.*.read_ahead_stats
10600 # Discard is generally zero, but sometimes a few random reads line up
10601 # and trigger larger readahead, which is wasted & leads to discards.
10602 if [[ $(($discard)) -gt $nreads ]]; then
10603 error "too many ($discard) discarded pages"
10605 rm -f $DIR/$tfile || true
10607 run_test 101a "check read-ahead for random reads"
10609 setup_test101bc() {
10610 test_mkdir $DIR/$tdir
10612 local FILE_LENGTH=$2
10615 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
10617 local list=$(comma_list $(osts_nodes))
10618 set_osd_param $list '' read_cache_enable 0
10619 set_osd_param $list '' writethrough_cache_enable 0
10621 trap cleanup_test101bc EXIT
10622 # prepare the read-ahead file
10623 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
10625 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
10626 count=$FILE_SIZE_MB 2> /dev/null
10630 cleanup_test101bc() {
10635 local list=$(comma_list $(osts_nodes))
10636 set_osd_param $list '' read_cache_enable 1
10637 set_osd_param $list '' writethrough_cache_enable 1
10641 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
10646 local stripe_size=$2
10647 local stride_length=$((stripe_size / read_size))
10648 local stride_width=$((stride_length * OSTCOUNT))
10649 local discard_limit=$(( ((stride_length - 1) * 3 / stride_width) *
10650 (stride_width - stride_length) ))
10651 local discard=$($LCTL get_param -n llite.*.read_ahead_stats |
10652 get_named_value 'read.but.discarded' | calc_total)
10654 if [[ $discard -gt $discard_limit ]]; then
10655 $LCTL get_param llite.*.read_ahead_stats
10656 error "($discard limit ${discard_limit}) discarded pages with size (${read_size})"
10658 echo "Read-ahead success for size ${read_size}"
10663 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10664 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10666 local STRIPE_SIZE=1048576
10667 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
10669 if [ $SLOW == "yes" ]; then
10670 local FILE_LENGTH=$((STRIDE_SIZE * 64))
10672 local FILE_LENGTH=$((STRIDE_SIZE * 8))
10675 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
10677 # prepare the read-ahead file
10678 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10679 cancel_lru_locks osc
10680 for BIDX in 2 4 8 16 32 64 128 256
10682 local BSIZE=$((BIDX*4096))
10683 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
10684 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
10685 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
10686 $LCTL set_param -n llite.*.read_ahead_stats=0
10687 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
10688 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
10689 cancel_lru_locks osc
10690 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
10695 run_test 101b "check stride-io mode read-ahead ================="
10698 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10700 local STRIPE_SIZE=1048576
10701 local FILE_LENGTH=$((STRIPE_SIZE*100))
10704 local osc_rpc_stats
10706 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10708 cancel_lru_locks osc
10709 $LCTL set_param osc.*.rpc_stats=0
10710 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
10711 $LCTL get_param osc.*.rpc_stats
10712 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
10713 local stats=$($LCTL get_param -n $osc_rpc_stats)
10714 local lines=$(echo "$stats" | awk 'END {print NR;}')
10717 if [ $lines -le 20 ]; then
10718 echo "continue debug"
10721 for size in 1 2 4 8; do
10722 local rpc=$(echo "$stats" |
10723 awk '($1 == "'$size':") {print $2; exit; }')
10724 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
10725 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
10727 echo "$osc_rpc_stats check passed!"
10732 run_test 101c "check stripe_size aligned read-ahead"
10735 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10737 local file=$DIR/$tfile
10738 local sz_MB=${FILESIZE_101d:-80}
10739 local ra_MB=${READAHEAD_MB:-40}
10741 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
10742 [ $free_MB -lt $sz_MB ] &&
10743 skip "Need free space ${sz_MB}M, have ${free_MB}M"
10745 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
10746 $LFS setstripe -c -1 $file || error "setstripe failed"
10748 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
10749 echo Cancel LRU locks on lustre client to flush the client cache
10750 cancel_lru_locks osc
10752 echo Disable read-ahead
10753 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10754 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10755 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
10756 $LCTL get_param -n llite.*.max_read_ahead_mb
10758 echo "Reading the test file $file with read-ahead disabled"
10759 local sz_KB=$((sz_MB * 1024 / 4))
10760 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
10761 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
10762 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10763 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10765 echo "Cancel LRU locks on lustre client to flush the client cache"
10766 cancel_lru_locks osc
10767 echo Enable read-ahead with ${ra_MB}MB
10768 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
10770 echo "Reading the test file $file with read-ahead enabled"
10771 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10772 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10774 echo "read-ahead disabled time read $raOFF"
10775 echo "read-ahead enabled time read $raON"
10778 wait_delete_completed
10780 # use awk for this check instead of bash because it handles decimals
10781 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
10782 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
10784 run_test 101d "file read with and without read-ahead enabled"
10787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10789 local file=$DIR/$tfile
10790 local size_KB=500 #KB
10794 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
10795 local need_KB=$((count * size_KB))
10796 [[ $free_KB -le $need_KB ]] &&
10797 skip_env "Need free space $need_KB, have $free_KB"
10799 echo "Creating $count ${size_KB}K test files"
10800 for ((i = 0; i < $count; i++)); do
10801 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
10804 echo "Cancel LRU locks on lustre client to flush the client cache"
10805 cancel_lru_locks $OSC
10807 echo "Reset readahead stats"
10808 $LCTL set_param -n llite.*.read_ahead_stats=0
10810 for ((i = 0; i < $count; i++)); do
10811 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
10814 $LCTL get_param llite.*.max_cached_mb
10815 $LCTL get_param llite.*.read_ahead_stats
10816 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10817 get_named_value 'misses' | calc_total)
10819 for ((i = 0; i < $count; i++)); do
10820 rm -rf $file.$i 2>/dev/null
10823 #10000 means 20% reads are missing in readahead
10824 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
10826 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
10829 which iozone || skip_env "no iozone installed"
10831 local old_debug=$($LCTL get_param debug)
10832 old_debug=${old_debug#*=}
10833 $LCTL set_param debug="reada mmap"
10835 # create a test file
10836 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
10838 echo Cancel LRU locks on lustre client to flush the client cache
10839 cancel_lru_locks osc
10841 echo Reset readahead stats
10842 $LCTL set_param -n llite.*.read_ahead_stats=0
10844 echo mmap read the file with small block size
10845 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
10848 echo checking missing pages
10849 $LCTL get_param llite.*.read_ahead_stats
10850 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10851 get_named_value 'misses' | calc_total)
10853 $LCTL set_param debug="$old_debug"
10854 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
10857 run_test 101f "check mmap read performance"
10859 test_101g_brw_size_test() {
10861 local pages=$((mb * 1048576 / PAGE_SIZE))
10862 local file=$DIR/$tfile
10864 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
10865 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
10866 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
10867 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
10871 stack_trap "rm -f $file" EXIT
10872 $LCTL set_param -n osc.*.rpc_stats=0
10874 # 10 RPCs should be enough for the test
10876 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
10877 { error "dd write ${mb} MB blocks failed"; return 3; }
10878 cancel_lru_locks osc
10879 dd of=/dev/null if=$file bs=${mb}M count=$count ||
10880 { error "dd write ${mb} MB blocks failed"; return 4; }
10882 # calculate number of full-sized read and write RPCs
10883 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
10884 sed -n '/pages per rpc/,/^$/p' |
10885 awk '/'$pages':/ { reads += $2; writes += $6 }; \
10886 END { print reads,writes }'))
10887 # allow one extra full-sized read RPC for async readahead
10888 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
10889 { error "${rpcs[0]} != $count read RPCs"; return 5; }
10890 [[ ${rpcs[1]} == $count ]] ||
10891 { error "${rpcs[1]} != $count write RPCs"; return 6; }
10895 remote_ost_nodsh && skip "remote OST with nodsh"
10898 local osts=$(get_facets OST)
10899 local list=$(comma_list $(osts_nodes))
10900 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10901 local brw_size="obdfilter.*.brw_size"
10903 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10905 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
10907 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
10908 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
10909 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
10910 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
10911 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
10912 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
10914 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
10917 if [[ $orig_mb -lt 16 ]]; then
10918 save_lustre_params $osts "$brw_size" > $p
10919 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
10920 error "set 16MB RPC size failed"
10922 echo "remount client to enable new RPC size"
10923 remount_client $MOUNT || error "remount_client failed"
10926 test_101g_brw_size_test 16 || error "16MB RPC test failed"
10927 # should be able to set brw_size=12, but no rpc_stats for that
10928 test_101g_brw_size_test 8 || error "8MB RPC test failed"
10931 test_101g_brw_size_test 4 || error "4MB RPC test failed"
10933 if [[ $orig_mb -lt 16 ]]; then
10934 restore_lustre_params < $p
10935 remount_client $MOUNT || error "remount_client restore failed"
10938 rm -f $p $DIR/$tfile
10940 run_test 101g "Big bulk(4/16 MiB) readahead"
10943 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10945 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
10946 error "dd 70M file failed"
10947 echo Cancel LRU locks on lustre client to flush the client cache
10948 cancel_lru_locks osc
10950 echo "Reset readahead stats"
10951 $LCTL set_param -n llite.*.read_ahead_stats 0
10953 echo "Read 10M of data but cross 64M bundary"
10954 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
10955 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10956 get_named_value 'misses' | calc_total)
10957 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
10958 rm -f $p $DIR/$tfile
10960 run_test 101h "Readahead should cover current read window"
10963 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
10964 error "dd 10M file failed"
10966 local max_per_file_mb=$($LCTL get_param -n \
10967 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
10968 cancel_lru_locks osc
10969 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
10970 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
10971 error "set max_read_ahead_per_file_mb to 1 failed"
10973 echo "Reset readahead stats"
10974 $LCTL set_param llite.*.read_ahead_stats=0
10976 dd if=$DIR/$tfile of=/dev/null bs=2M
10978 $LCTL get_param llite.*.read_ahead_stats
10979 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10980 awk '/misses/ { print $2 }')
10981 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
10984 run_test 101i "allow current readahead to exceed reservation"
10987 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
10988 error "setstripe $DIR/$tfile failed"
10989 local file_size=$((1048576 * 16))
10990 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10991 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
10993 echo Disable read-ahead
10994 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10996 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
10997 for blk in $PAGE_SIZE 1048576 $file_size; do
10998 cancel_lru_locks osc
10999 echo "Reset readahead stats"
11000 $LCTL set_param -n llite.*.read_ahead_stats=0
11001 local count=$(($file_size / $blk))
11002 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
11003 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11004 get_named_value 'failed.to.fast.read' | calc_total)
11005 $LCTL get_param -n llite.*.read_ahead_stats
11006 [ $miss -eq $count ] || error "expected $count got $miss"
11009 rm -f $p $DIR/$tfile
11011 run_test 101j "A complete read block should be submitted when no RA"
11014 test_mkdir $DIR/$tdir
11015 chown $RUNAS_ID $DIR/$tdir
11018 STRIPE_COUNT=$OSTCOUNT
11019 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
11021 trap cleanup_test102 EXIT
11023 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
11025 for num in 1 2 3 4; do
11026 for count in $(seq 1 $STRIPE_COUNT); do
11027 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
11028 local size=`expr $STRIPE_SIZE \* $num`
11029 local file=file"$num-$idx-$count"
11030 $1 $LFS setstripe -S $size -i $idx -c $count $file
11036 $1 tar cf $TMP/f102.tar $tdir --xattrs
11039 cleanup_test102() {
11041 rm -f $TMP/f102.tar
11042 rm -rf $DIR/d0.sanity/d102
11046 [ "$UID" != 0 ] && skip "must run as root"
11047 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
11048 skip_env "must have user_xattr"
11050 [ -z "$(which setfattr 2>/dev/null)" ] &&
11051 skip_env "could not find setfattr"
11053 local testfile=$DIR/$tfile
11056 echo "set/get xattr..."
11057 setfattr -n trusted.name1 -v value1 $testfile ||
11058 error "setfattr -n trusted.name1=value1 $testfile failed"
11059 getfattr -n trusted.name1 $testfile 2> /dev/null |
11060 grep "trusted.name1=.value1" ||
11061 error "$testfile missing trusted.name1=value1"
11063 setfattr -n user.author1 -v author1 $testfile ||
11064 error "setfattr -n user.author1=author1 $testfile failed"
11065 getfattr -n user.author1 $testfile 2> /dev/null |
11066 grep "user.author1=.author1" ||
11067 error "$testfile missing trusted.author1=author1"
11069 echo "listxattr..."
11070 setfattr -n trusted.name2 -v value2 $testfile ||
11071 error "$testfile unable to set trusted.name2"
11072 setfattr -n trusted.name3 -v value3 $testfile ||
11073 error "$testfile unable to set trusted.name3"
11074 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
11075 grep "trusted.name" | wc -l) -eq 3 ] ||
11076 error "$testfile missing 3 trusted.name xattrs"
11078 setfattr -n user.author2 -v author2 $testfile ||
11079 error "$testfile unable to set user.author2"
11080 setfattr -n user.author3 -v author3 $testfile ||
11081 error "$testfile unable to set user.author3"
11082 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
11083 grep "user.author" | wc -l) -eq 3 ] ||
11084 error "$testfile missing 3 user.author xattrs"
11086 echo "remove xattr..."
11087 setfattr -x trusted.name1 $testfile ||
11088 error "$testfile error deleting trusted.name1"
11089 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
11090 error "$testfile did not delete trusted.name1 xattr"
11092 setfattr -x user.author1 $testfile ||
11093 error "$testfile error deleting user.author1"
11094 echo "set lustre special xattr ..."
11095 $LFS setstripe -c1 $testfile
11096 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
11097 awk -F "=" '/trusted.lov/ { print $2 }' )
11098 setfattr -n "trusted.lov" -v $lovea $testfile ||
11099 error "$testfile doesn't ignore setting trusted.lov again"
11100 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
11101 error "$testfile allow setting invalid trusted.lov"
11104 run_test 102a "user xattr test =================================="
11106 check_102b_layout() {
11108 local testfile=$DIR/$tfile
11110 echo "test layout '$layout'"
11111 $LFS setstripe $layout $testfile || error "setstripe failed"
11112 $LFS getstripe -y $testfile
11114 echo "get/set/list trusted.lov xattr ..." # b=10930
11115 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
11116 [[ "$value" =~ "trusted.lov" ]] ||
11117 error "can't get trusted.lov from $testfile"
11118 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
11119 error "getstripe failed"
11121 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
11123 value=$(cut -d= -f2 <<<$value)
11124 # LU-13168: truncated xattr should fail if short lov_user_md header
11125 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
11126 lens="${#value}" || lens="$(seq 4 2 ${#value})"
11127 for len in $lens; do
11128 echo "setfattr $len $testfile.2"
11129 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
11130 [ $len -lt 66 ] && error "short xattr len=$len worked"
11132 local stripe_size=$($LFS getstripe -S $testfile.2)
11133 local stripe_count=$($LFS getstripe -c $testfile.2)
11134 [[ $stripe_size -eq 65536 ]] ||
11135 error "stripe size $stripe_size != 65536"
11136 [[ $stripe_count -eq $stripe_count_orig ]] ||
11137 error "stripe count $stripe_count != $stripe_count_orig"
11138 rm $testfile $testfile.2
11142 [ -z "$(which setfattr 2>/dev/null)" ] &&
11143 skip_env "could not find setfattr"
11144 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11146 # check plain layout
11147 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
11149 # and also check composite layout
11150 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
11153 run_test 102b "getfattr/setfattr for trusted.lov EAs"
11156 [ -z "$(which setfattr 2>/dev/null)" ] &&
11157 skip_env "could not find setfattr"
11158 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11160 # b10930: get/set/list lustre.lov xattr
11161 echo "get/set/list lustre.lov xattr ..."
11162 test_mkdir $DIR/$tdir
11163 chown $RUNAS_ID $DIR/$tdir
11164 local testfile=$DIR/$tdir/$tfile
11165 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
11166 error "setstripe failed"
11167 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
11168 error "getstripe failed"
11169 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
11170 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
11172 local testfile2=${testfile}2
11173 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
11174 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
11176 $RUNAS $MCREATE $testfile2
11177 $RUNAS setfattr -n lustre.lov -v $value $testfile2
11178 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
11179 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
11180 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
11181 [ $stripe_count -eq $STRIPECOUNT ] ||
11182 error "stripe count $stripe_count != $STRIPECOUNT"
11184 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
11186 compare_stripe_info1() {
11187 local stripe_index_all_zero=true
11189 for num in 1 2 3 4; do
11190 for count in $(seq 1 $STRIPE_COUNT); do
11191 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
11192 local size=$((STRIPE_SIZE * num))
11193 local file=file"$num-$offset-$count"
11194 stripe_size=$($LFS getstripe -S $PWD/$file)
11195 [[ $stripe_size -ne $size ]] &&
11196 error "$file: size $stripe_size != $size"
11197 stripe_count=$($LFS getstripe -c $PWD/$file)
11198 # allow fewer stripes to be created, ORI-601
11199 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
11200 error "$file: count $stripe_count != $count"
11201 stripe_index=$($LFS getstripe -i $PWD/$file)
11202 [[ $stripe_index -ne 0 ]] &&
11203 stripe_index_all_zero=false
11207 $stripe_index_all_zero &&
11208 error "all files are being extracted starting from OST index 0"
11212 have_xattrs_include() {
11213 tar --help | grep -q xattrs-include &&
11214 echo --xattrs-include="lustre.*"
11218 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11219 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11221 XINC=$(have_xattrs_include)
11223 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11224 cd $DIR/$tdir/$tdir
11225 compare_stripe_info1
11227 run_test 102d "tar restore stripe info from tarfile,not keep osts"
11230 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11231 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11233 XINC=$(have_xattrs_include)
11235 test_mkdir $DIR/$tdir.restore
11237 tar cf - --xattrs $tdir | tar xf - \
11238 -C $DIR/$tdir.restore --xattrs $XINC
11239 cd $DIR/$tdir.restore/$tdir
11240 compare_stripe_info1
11242 run_test 102f "tar copy files, not keep osts"
11245 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
11246 skip "must have user_xattr"
11247 [ -z "$(which setfattr 2>/dev/null)" ] &&
11248 skip_env "could not find setfattr"
11249 [ -z "$(which getfattr 2>/dev/null)" ] &&
11250 skip_env "could not find getfattr"
11252 local xsize=${1:-1024} # in bytes
11253 local file=$DIR/$tfile
11254 local value="$(generate_string $xsize)"
11255 local xbig=trusted.big
11259 log "save $xbig on $file"
11260 if [ -z "$toobig" ]
11262 setfattr -n $xbig -v $value $file ||
11263 error "saving $xbig on $file failed"
11265 setfattr -n $xbig -v $value $file &&
11266 error "saving $xbig on $file succeeded"
11270 local orig=$(get_xattr_value $xbig $file)
11271 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
11273 local xsml=trusted.sml
11274 log "save $xsml on $file"
11275 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
11277 local new=$(get_xattr_value $xbig $file)
11278 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
11280 log "grow $xsml on $file"
11281 setfattr -n $xsml -v "$value" $file ||
11282 error "growing $xsml on $file failed"
11284 new=$(get_xattr_value $xbig $file)
11285 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
11286 log "$xbig still valid after growing $xsml"
11291 test_102h() { # bug 15777
11294 run_test 102h "grow xattr from inside inode to external block"
11297 large_xattr_enabled || skip_env "ea_inode feature disabled"
11299 echo "setting xattr of max xattr size: $(max_xattr_size)"
11300 grow_xattr $(max_xattr_size)
11302 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
11303 echo "This should fail:"
11304 grow_xattr $(($(max_xattr_size) + 10)) 1
11306 run_test 102ha "grow xattr from inside inode to external inode"
11308 test_102i() { # bug 17038
11309 [ -z "$(which getfattr 2>/dev/null)" ] &&
11310 skip "could not find getfattr"
11313 ln -s $DIR/$tfile $DIR/${tfile}link
11314 getfattr -n trusted.lov $DIR/$tfile ||
11315 error "lgetxattr on $DIR/$tfile failed"
11316 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
11317 grep -i "no such attr" ||
11318 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
11319 rm -f $DIR/$tfile $DIR/${tfile}link
11321 run_test 102i "lgetxattr test on symbolic link ============"
11324 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11325 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11327 XINC=$(have_xattrs_include)
11328 setup_test102 "$RUNAS"
11329 chown $RUNAS_ID $DIR/$tdir
11330 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11331 cd $DIR/$tdir/$tdir
11332 compare_stripe_info1 "$RUNAS"
11334 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
11337 [ -z "$(which setfattr 2>/dev/null)" ] &&
11338 skip "could not find setfattr"
11341 # b22187 just check that does not crash for regular file.
11342 setfattr -n trusted.lov $DIR/$tfile
11343 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
11344 local test_kdir=$DIR/$tdir
11345 test_mkdir $test_kdir
11346 local default_size=$($LFS getstripe -S $test_kdir)
11347 local default_count=$($LFS getstripe -c $test_kdir)
11348 local default_offset=$($LFS getstripe -i $test_kdir)
11349 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
11350 error 'dir setstripe failed'
11351 setfattr -n trusted.lov $test_kdir
11352 local stripe_size=$($LFS getstripe -S $test_kdir)
11353 local stripe_count=$($LFS getstripe -c $test_kdir)
11354 local stripe_offset=$($LFS getstripe -i $test_kdir)
11355 [ $stripe_size -eq $default_size ] ||
11356 error "stripe size $stripe_size != $default_size"
11357 [ $stripe_count -eq $default_count ] ||
11358 error "stripe count $stripe_count != $default_count"
11359 [ $stripe_offset -eq $default_offset ] ||
11360 error "stripe offset $stripe_offset != $default_offset"
11361 rm -rf $DIR/$tfile $test_kdir
11363 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
11366 [ -z "$(which getfattr 2>/dev/null)" ] &&
11367 skip "could not find getfattr"
11369 # LU-532 trusted. xattr is invisible to non-root
11370 local testfile=$DIR/$tfile
11374 echo "listxattr as user..."
11375 chown $RUNAS_ID $testfile
11376 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
11377 grep -q "trusted" &&
11378 error "$testfile trusted xattrs are user visible"
11382 run_test 102l "listxattr size test =================================="
11384 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
11385 local path=$DIR/$tfile
11388 listxattr_size_check $path || error "listattr_size_check $path failed"
11390 run_test 102m "Ensure listxattr fails on small bufffer ========"
11394 getxattr() { # getxattr path name
11395 # Return the base64 encoding of the value of xattr name on path.
11399 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
11401 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11403 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11405 getfattr --absolute-names --encoding=base64 --name=$name $path |
11406 awk -F= -v name=$name '$1 == name {
11407 print substr($0, index($0, "=") + 1);
11411 test_102n() { # LU-4101 mdt: protect internal xattrs
11412 [ -z "$(which setfattr 2>/dev/null)" ] &&
11413 skip "could not find setfattr"
11414 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
11416 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
11419 local file0=$DIR/$tfile.0
11420 local file1=$DIR/$tfile.1
11421 local xattr0=$TMP/$tfile.0
11422 local xattr1=$TMP/$tfile.1
11423 local namelist="lov lma lmv link fid version som hsm"
11427 rm -rf $file0 $file1 $xattr0 $xattr1
11428 touch $file0 $file1
11430 # Get 'before' xattrs of $file1.
11431 getfattr --absolute-names --dump --match=- $file1 > $xattr0
11433 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
11434 namelist+=" lfsck_namespace"
11435 for name in $namelist; do
11436 # Try to copy xattr from $file0 to $file1.
11437 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11439 setfattr --name=trusted.$name --value="$value" $file1 ||
11440 error "setxattr 'trusted.$name' failed"
11442 # Try to set a garbage xattr.
11443 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11445 if [[ x$name == "xlov" ]]; then
11446 setfattr --name=trusted.lov --value="$value" $file1 &&
11447 error "setxattr invalid 'trusted.lov' success"
11449 setfattr --name=trusted.$name --value="$value" $file1 ||
11450 error "setxattr invalid 'trusted.$name' failed"
11453 # Try to remove the xattr from $file1. We don't care if this
11454 # appears to succeed or fail, we just don't want there to be
11455 # any changes or crashes.
11456 setfattr --remove=$trusted.$name $file1 2> /dev/null
11459 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
11462 # Try to copy xattr from $file0 to $file1.
11463 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11465 setfattr --name=trusted.$name --value="$value" $file1 ||
11466 error "setxattr 'trusted.$name' failed"
11468 # Try to set a garbage xattr.
11469 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11471 setfattr --name=trusted.$name --value="$value" $file1 ||
11472 error "setxattr 'trusted.$name' failed"
11474 # Try to remove the xattr from $file1. We don't care if this
11475 # appears to succeed or fail, we just don't want there to be
11476 # any changes or crashes.
11477 setfattr --remove=$trusted.$name $file1 2> /dev/null
11480 # Get 'after' xattrs of file1.
11481 getfattr --absolute-names --dump --match=- $file1 > $xattr1
11483 if ! diff $xattr0 $xattr1; then
11484 error "before and after xattrs of '$file1' differ"
11487 rm -rf $file0 $file1 $xattr0 $xattr1
11491 run_test 102n "silently ignore setxattr on internal trusted xattrs"
11493 test_102p() { # LU-4703 setxattr did not check ownership
11494 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
11495 skip "MDS needs to be at least 2.5.56"
11497 local testfile=$DIR/$tfile
11501 echo "setfacl as user..."
11502 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
11503 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
11505 echo "setfattr as user..."
11506 setfacl -m "u:$RUNAS_ID:---" $testfile
11507 $RUNAS setfattr -x system.posix_acl_access $testfile
11508 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
11510 run_test 102p "check setxattr(2) correctly fails without permission"
11513 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
11514 skip "MDS needs to be at least 2.6.92"
11516 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
11518 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
11521 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
11522 skip "MDS needs to be at least 2.6.93"
11524 touch $DIR/$tfile || error "touch"
11525 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
11526 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
11527 rm $DIR/$tfile || error "rm"
11530 mkdir -p $DIR/$tdir || error "mkdir"
11531 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11532 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11533 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11534 error "$testfile error deleting user.author1"
11535 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11536 grep "user.$(basename $tdir)" &&
11537 error "$tdir did not delete user.$(basename $tdir)"
11538 rmdir $DIR/$tdir || error "rmdir"
11541 test_mkdir $DIR/$tdir
11542 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11543 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11544 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11545 error "$testfile error deleting user.author1"
11546 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11547 grep "user.$(basename $tdir)" &&
11548 error "$tdir did not delete user.$(basename $tdir)"
11549 rmdir $DIR/$tdir || error "rm striped dir"
11551 run_test 102r "set EAs with empty values"
11554 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11555 skip "MDS needs to be at least 2.11.52"
11557 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11559 save_lustre_params client "llite.*.xattr_cache" > $save
11561 for cache in 0 1; do
11562 lctl set_param llite.*.xattr_cache=$cache
11565 touch $DIR/$tfile || error "touch"
11566 for prefix in lustre security system trusted user; do
11567 # Note getxattr() may fail with 'Operation not
11568 # supported' or 'No such attribute' depending
11569 # on prefix and cache.
11570 getfattr -n $prefix.n102s $DIR/$tfile &&
11571 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
11575 restore_lustre_params < $save
11577 run_test 102s "getting nonexistent xattrs should fail"
11580 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11581 skip "MDS needs to be at least 2.11.52"
11583 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11585 save_lustre_params client "llite.*.xattr_cache" > $save
11587 for cache in 0 1; do
11588 lctl set_param llite.*.xattr_cache=$cache
11590 for buf_size in 0 256; do
11592 touch $DIR/$tfile || error "touch"
11593 setfattr -n user.multiop $DIR/$tfile
11594 $MULTIOP $DIR/$tfile oa$buf_size ||
11595 error "cannot get zero length xattr value (buf_size = $buf_size)"
11599 restore_lustre_params < $save
11601 run_test 102t "zero length xattr values handled correctly"
11605 local test=$LUSTRE/tests/acl/$1.test
11606 local tmp=$(mktemp -t $1-XXXXXX).test
11614 local sedusers="-e s/bin/$bin/g -e s/daemon/$dmn/g"
11615 local sedgroups="-e s/:users/:$grp/g"
11616 [[ -z "$nbd" ]] || sedusers+=" -e s/nobody/$nbd/g"
11618 sed $sedusers $sedgroups < $test > $tmp
11619 stack_trap "rm -f $tmp"
11620 [[ -s $tmp ]] || error "sed failed to create test script"
11622 echo "performing $1 with bin='$bin' daemon='$dmn' users='$grp'..."
11623 $LUSTRE/tests/acl/run $tmp || error "run_acl_subtest '$1' failed"
11627 [ "$UID" != 0 ] && skip "must run as root"
11628 $GSS && skip_env "could not run under gss"
11629 [[ "$(lctl get_param -n mdc.*-mdc-*.connect_flags)" =~ "acl" ]] ||
11630 skip_env "must have acl enabled"
11631 which setfacl || skip_env "could not find setfacl"
11632 remote_mds_nodsh && skip "remote MDS with nodsh"
11634 ACLBIN=${ACLBIN:-"bin"}
11635 ACLDMN=${ACLDMN:-"daemon"}
11636 ACLGRP=${ACLGRP:-"users"}
11637 ACLNBD=${ACLNBD:-"nobody"}
11640 [[ "$(id -u $ACLBIN)" != "$(do_facet mds1 id -u $ACLBIN)" ]]; then
11641 echo "bad 'bin' user '$ACLBIN', using '$USER0'"
11643 if ! id $ACLBIN ; then
11645 skip_env "can't find suitable ACL 'bin' $ACLBIN"
11648 if ! id $ACLDMN || (( $(id -u $ACLDMN) < $(id -u $ACLBIN) )) ||
11649 [[ "$(id -u $ACLDMN)" != "$(do_facet mds1 id -u $ACLDMN)" ]]; then
11650 echo "bad 'daemon' user '$ACLDMN', using '$USER1'"
11652 if ! id $ACLDMN ; then
11654 skip_env "can't find suitable ACL 'daemon' $ACLDMN"
11657 if ! getent group $ACLGRP; then
11658 echo "missing 'users' group '$ACLGRP', using '$TSTUSR'"
11660 if ! getent group $ACLGRP; then
11661 echo "cannot find group '$ACLGRP', adding it"
11663 add_group 60000 $ACLGRP
11667 local bingid=$(getent group $ACLBIN | cut -d: -f 3)
11668 local dmngid=$(getent group $ACLDMN | cut -d: -f 3)
11669 local grpgid=$(getent group $ACLGRP | cut -d: -f 3)
11671 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
11672 echo "group '$ACLGRP' has low gid=$grpgid, use '$TSTUSR'"
11674 if ! getent group $ACLGRP; then
11675 echo "cannot find group '$ACLGRP', adding it"
11677 add_group 60000 $ACLGRP
11679 grpgid=$(getent group $ACLGRP | cut -d: -f 3)
11680 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
11682 skip_env "$ACLGRP gid=$grpgid less than $bingid|$dmngid"
11686 gpasswd -a $ACLDMN $ACLBIN ||
11687 error "setting client group failed" # LU-5641
11688 do_facet mds1 gpasswd -a $ACLDMN $ACLBIN ||
11689 error "setting MDS group failed" # LU-5641
11691 declare -a identity_old
11693 for num in $(seq $MDSCOUNT); do
11694 switch_identity $num true || identity_old[$num]=$?
11697 SAVE_UMASK=$(umask)
11699 mkdir -p $DIR/$tdir
11702 run_acl_subtest cp $ACLBIN $ACLDMN $ACLGRP
11703 run_acl_subtest getfacl-noacl $ACLBIN $ACLDMN $ACLGRP
11704 run_acl_subtest misc $ACLBIN $ACLDMN $ACLGRP
11705 run_acl_subtest permissions $ACLBIN $ACLDMN $ACLGRP
11706 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
11707 # CentOS7- uses nobody=99, while newer distros use nobody=65534
11708 if ! id -u $ACLNBD ||
11709 (( $(id -u nobody) != $(do_facet mds1 id -u nobody) )); then
11711 if ! id -u $ACLNBD; then
11715 if [[ -n "$ACLNBD" ]] && ! getent group $ACLNBD; then
11716 add_group $(id -u $ACLNBD) $ACLNBD
11717 if ! getent group $ACLNBD; then
11721 if (( $MDS1_VERSION > $(version_code 2.8.55) )) &&
11722 [[ -n "$ACLNBD" ]] && which setfattr; then
11723 run_acl_subtest permissions_xattr \
11724 $ACLBIN $ACLDMN $ACLGRP $ACLNBD
11725 elif [[ -z "$ACLNBD" ]]; then
11726 echo "skip 'permission_xattr' test - missing 'nobody' user/grp"
11728 echo "skip 'permission_xattr' test - missing setfattr command"
11730 run_acl_subtest setfacl $ACLBIN $ACLDMN $ACLGRP
11732 # inheritance test got from HP
11733 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
11734 chmod +x make-tree || error "chmod +x failed"
11735 run_acl_subtest inheritance $ACLBIN $ACLDMN $ACLGRP
11738 echo "LU-974 ignore umask when acl is enabled..."
11739 run_acl_subtest 974 $ACLBIN $ACLDMN $ACLGRP
11740 if [ $MDSCOUNT -ge 2 ]; then
11741 run_acl_subtest 974_remote $ACLBIN $ACLDMN $ACLGRP
11744 echo "LU-2561 newly created file is same size as directory..."
11745 if [ "$mds1_FSTYPE" != "zfs" ]; then
11746 run_acl_subtest 2561 $ACLBIN $ACLDMN $ACLGRP
11748 run_acl_subtest 2561_zfs $ACLBIN $ACLDMN $ACLGRP
11751 run_acl_subtest 4924 $ACLBIN $ACLDMN $ACLGRP
11756 for num in $(seq $MDSCOUNT); do
11757 if [ "${identity_old[$num]}" = 1 ]; then
11758 switch_identity $num false || identity_old[$num]=$?
11762 run_test 103a "acl test"
11768 for U in {0..511}; do
11770 local O=$(printf "%04o" $U)
11772 umask $(printf "%04o" $((511 ^ $O)))
11773 $LFS setstripe -c 1 $DIR/$tfile.s$O
11774 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
11776 (( $S == ($O & 0666) )) ||
11777 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
11779 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
11780 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
11781 (( $S == ($O & 0666) )) ||
11782 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
11784 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
11785 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
11786 (( $S == ($O & 0666) )) ||
11787 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
11788 rm -f $DIR/$tfile.[smp]$0
11792 # limit the concurrently running threads to 64. LU-11878
11793 local idx=$((U % 64))
11794 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
11799 run_test 103b "umask lfs setstripe"
11802 mkdir -p $DIR/$tdir
11803 cp -rp $DIR/$tdir $DIR/$tdir.bak
11805 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
11806 error "$DIR/$tdir shouldn't contain default ACL"
11807 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
11808 error "$DIR/$tdir.bak shouldn't contain default ACL"
11811 run_test 103c "'cp -rp' won't set empty acl"
11816 local saved_debug=$($LCTL get_param -n debug)
11818 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
11819 skip "MDS needs to be at least 2.14.52"
11821 large_xattr_enabled || skip_env "ea_inode feature disabled"
11823 mkdir -p $DIR/$tdir
11824 # add big LOV EA to cause reply buffer overflow earlier
11825 $LFS setstripe -C 1000 $DIR/$tdir
11826 lctl set_param mdc.*-mdc*.stats=clear
11828 $LCTL set_param debug=0
11829 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
11830 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
11832 # add a large number of default ACLs (expect 8000+ for 2.13+)
11833 for U in {2..7000}; do
11834 setfacl -d -m user:$U:rwx $DIR/$tdir ||
11835 error "Able to add just $U default ACLs"
11837 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
11838 echo "$numacl default ACLs created"
11840 stat $DIR/$tdir || error "Cannot stat directory"
11841 # check file creation
11842 touch $DIR/$tdir/$tfile ||
11843 error "failed to create $tfile with $numacl default ACLs"
11844 stat $DIR/$tdir/$tfile || error "Cannot stat file"
11845 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11846 echo "$fileacl ACLs were inherited"
11847 (( $fileacl == $numacl )) ||
11848 error "Not all default ACLs were inherited: $numacl != $fileacl"
11849 # check that new ACLs creation adds new ACLs to inherited ACLs
11850 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
11851 error "Cannot set new ACL"
11852 numacl=$((numacl + 1))
11853 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11854 (( $fileacl == $numacl )) ||
11855 error "failed to add new ACL: $fileacl != $numacl as expected"
11856 # adds more ACLs to a file to reach their maximum at 8000+
11858 for U in {20000..25000}; do
11859 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
11860 numacl=$((numacl + 1))
11862 echo "Added $numacl more ACLs to the file"
11863 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11864 echo "Total $fileacl ACLs in file"
11865 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
11866 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
11867 rmdir $DIR/$tdir || error "Cannot remove directory"
11869 run_test 103e "inheritance of big amount of default ACLs"
11872 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
11873 skip "MDS needs to be at least 2.14.51"
11875 large_xattr_enabled || skip_env "ea_inode feature disabled"
11877 # enable changelog to consume more internal MDD buffers
11880 mkdir -p $DIR/$tdir
11882 $LFS setstripe -C 1000 $DIR/$tdir
11883 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
11884 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
11885 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
11886 rmdir $DIR/$tdir || error "Cannot remove directory"
11888 run_test 103f "changelog doesn't interfere with default ACLs buffers"
11891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11894 lfs df || error "lfs df failed"
11895 lfs df -ih || error "lfs df -ih failed"
11896 lfs df -h $DIR || error "lfs df -h $DIR failed"
11897 lfs df -i $DIR || error "lfs df -i $DIR failed"
11898 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
11899 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
11901 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
11902 lctl --device %$OSC deactivate
11903 lfs df || error "lfs df with deactivated OSC failed"
11904 lctl --device %$OSC activate
11905 # wait the osc back to normal
11906 wait_osc_import_ready client ost
11908 lfs df || error "lfs df with reactivated OSC failed"
11911 run_test 104a "lfs df [-ih] [path] test ========================="
11914 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11915 [ $RUNAS_ID -eq $UID ] &&
11916 skip_env "RUNAS_ID = UID = $UID -- skipping"
11918 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
11919 grep "Permission denied" | wc -l)))
11920 if [ $denied_cnt -ne 0 ]; then
11921 error "lfs check servers test failed"
11924 run_test 104b "$RUNAS lfs check servers test ===================="
11927 # Verify $1 is within range of $2.
11928 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
11929 # $1 is <= 2% of $2. Else Fail.
11932 # Strip all units (M, G, T)
11933 actual=$(echo $1 | tr -d A-Z)
11934 expect=$(echo $2 | tr -d A-Z)
11936 expect_lo=$(($expect * 98 / 100)) # 2% below
11937 expect_hi=$(($expect * 102 / 100)) # 2% above
11939 # permit 2% drift above and below
11940 (( $actual >= $expect_lo && $actual <= $expect_hi ))
11944 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11945 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
11947 local ost_param="osd-zfs.$FSNAME-OST0000."
11948 local mdt_param="osd-zfs.$FSNAME-MDT0000."
11949 local ofacets=$(get_facets OST)
11950 local mfacets=$(get_facets MDS)
11951 local saved_ost_blocks=
11952 local saved_mdt_blocks=
11954 echo "Before recordsize change"
11955 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
11956 df=($(df -h | grep "$MOUNT"$))
11959 echo "lfs output : ${lfs_df[*]}"
11960 echo "df output : ${df[*]}"
11962 for facet in ${ofacets//,/ }; do
11963 if [ -z $saved_ost_blocks ]; then
11964 saved_ost_blocks=$(do_facet $facet \
11965 lctl get_param -n $ost_param.blocksize)
11966 echo "OST Blocksize: $saved_ost_blocks"
11968 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11969 do_facet $facet zfs set recordsize=32768 $ost
11972 # BS too small. Sufficient for functional testing.
11973 for facet in ${mfacets//,/ }; do
11974 if [ -z $saved_mdt_blocks ]; then
11975 saved_mdt_blocks=$(do_facet $facet \
11976 lctl get_param -n $mdt_param.blocksize)
11977 echo "MDT Blocksize: $saved_mdt_blocks"
11979 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11980 do_facet $facet zfs set recordsize=32768 $mdt
11983 # Give new values chance to reflect change
11986 echo "After recordsize change"
11987 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
11988 df_after=($(df -h | grep "$MOUNT"$))
11991 echo "lfs output : ${lfs_df_after[*]}"
11992 echo "df output : ${df_after[*]}"
11995 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
11996 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
11997 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
11998 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
11999 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
12000 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
12003 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
12004 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
12005 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
12006 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
12007 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
12008 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
12010 # Restore MDT recordize back to original
12011 for facet in ${mfacets//,/ }; do
12012 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12013 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
12016 # Restore OST recordize back to original
12017 for facet in ${ofacets//,/ }; do
12018 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12019 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
12024 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
12027 (( $RUNAS_ID != $UID )) ||
12028 skip_env "RUNAS_ID = UID = $UID -- skipping"
12030 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
12031 skip "lustre version doesn't support lctl dl with non-root"
12033 # debugfs only allows root users to access files, so the
12034 # previous move of the "devices" file to debugfs broke
12035 # "lctl dl" for non-root users. The LU-9680 Netlink
12036 # interface again allows non-root users to list devices.
12037 [ "$($RUNAS $LCTL dl | wc -l)" -ge 3 ] ||
12038 error "lctl dl doesn't work for non root"
12040 ost_count="$($RUNAS $LCTL dl | grep $FSNAME-OST* | wc -l)"
12041 [ "$ost_count" -eq $OSTCOUNT ] ||
12042 error "lctl dl reports wrong number of OST devices"
12044 mdt_count="$($RUNAS $LCTL dl | grep $FSNAME-MDT* | wc -l)"
12045 [ "$mdt_count" -eq $MDSCOUNT ] ||
12046 error "lctl dl reports wrong number of MDT devices"
12048 run_test 104d "$RUNAS lctl dl test"
12051 # doesn't work on 2.4 kernels
12053 if $(flock_is_enabled); then
12054 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
12056 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
12060 run_test 105a "flock when mounted without -o flock test ========"
12064 if $(flock_is_enabled); then
12065 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
12067 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
12071 run_test 105b "fcntl when mounted without -o flock test ========"
12075 if $(flock_is_enabled); then
12076 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
12078 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
12082 run_test 105c "lockf when mounted without -o flock test"
12084 test_105d() { # bug 15924
12085 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12087 test_mkdir $DIR/$tdir
12088 flock_is_enabled || skip_env "mount w/o flock enabled"
12089 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
12090 $LCTL set_param fail_loc=0x80000315
12091 flocks_test 2 $DIR/$tdir
12093 run_test 105d "flock race (should not freeze) ========"
12095 test_105e() { # bug 22660 && 22040
12096 flock_is_enabled || skip_env "mount w/o flock enabled"
12099 flocks_test 3 $DIR/$tfile
12101 run_test 105e "Two conflicting flocks from same process"
12103 test_106() { #bug 10921
12104 test_mkdir $DIR/$tdir
12105 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
12106 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
12108 run_test 106 "attempt exec of dir followed by chown of that dir"
12111 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12119 local save_pattern=$(sysctl -n kernel.core_pattern)
12120 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
12121 sysctl -w kernel.core_pattern=$file
12122 sysctl -w kernel.core_uses_pid=0
12124 ulimit -c unlimited
12130 kill -s 11 $SLEEPPID
12132 if [ -e $file ]; then
12133 size=`stat -c%s $file`
12134 [ $size -eq 0 ] && error "Fail to create core file $file"
12136 error "Fail to create core file $file"
12139 sysctl -w kernel.core_pattern=$save_pattern
12140 sysctl -w kernel.core_uses_pid=$save_uses_pid
12143 run_test 107 "Coredump on SIG"
12146 test_mkdir $DIR/$tdir
12147 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
12148 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
12149 error "mkdir with 256 char should fail, but did not"
12150 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
12151 error "create with 255 char failed"
12152 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
12153 error "create with 256 char should fail, but did not"
12158 run_test 110 "filename length checking"
12161 # Purpose: To verify dynamic thread (OSS) creation.
12164 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12165 remote_ost_nodsh && skip "remote OST with nodsh"
12167 # Lustre does not stop service threads once they are started.
12168 # Reset number of running threads to default.
12173 local save_params="$TMP/sanity-$TESTNAME.parameters"
12175 # Get ll_ost_io count before I/O
12176 OSTIO_pre=$(do_facet ost1 \
12177 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
12178 # Exit if lustre is not running (ll_ost_io not running).
12179 [ -z "$OSTIO_pre" ] && error "no OSS threads"
12181 echo "Starting with $OSTIO_pre threads"
12182 local thread_max=$((OSTIO_pre * 2))
12183 local rpc_in_flight=$((thread_max * 2))
12184 # this is limited to OSC_MAX_RIF_MAX (256)
12185 [ $rpc_in_flight -gt 256 ] && rpc_in_flight=256
12186 thread_max=$((rpc_in_flight / 2))
12187 [ $thread_max -le $OSTIO_pre ] && skip "Too many ost_io threads" &&
12190 # Number of I/O Process proposed to be started.
12192 local facets=$(get_facets OST)
12194 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
12195 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
12197 # Set in_flight to $rpc_in_flight
12198 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
12199 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
12200 nfiles=${rpc_in_flight}
12201 # Set ost thread_max to $thread_max
12202 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
12204 # 5 Minutes should be sufficient for max number of OSS
12205 # threads(thread_max) to be created.
12209 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
12210 test_mkdir $DIR/$tdir
12211 for i in $(seq $nfiles); do
12212 local file=$DIR/$tdir/${tfile}-$i
12213 $LFS setstripe -c -1 -i 0 $file
12214 ($WTL $file $timeout)&
12217 # I/O Started - Wait for thread_started to reach thread_max or report
12218 # error if thread_started is more than thread_max.
12219 echo "Waiting for thread_started to reach thread_max"
12220 local thread_started=0
12221 local end_time=$((SECONDS + timeout))
12223 while [ $SECONDS -le $end_time ] ; do
12225 # Get ost i/o thread_started count.
12226 thread_started=$(do_facet ost1 \
12228 ost.OSS.ost_io.threads_started | cut -d= -f2")
12229 # Break out if thread_started is equal/greater than thread_max
12230 if [[ $thread_started -ge $thread_max ]]; then
12231 echo ll_ost_io thread_started $thread_started, \
12232 equal/greater than thread_max $thread_max
12238 # Cleanup - We have the numbers, Kill i/o jobs if running.
12239 jobcount=($(jobs -p))
12240 for i in $(seq 0 $((${#jobcount[@]}-1)))
12242 kill -9 ${jobcount[$i]}
12243 if [ $? -ne 0 ] ; then
12245 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
12249 # Cleanup files left by WTL binary.
12250 for i in $(seq $nfiles); do
12251 local file=$DIR/$tdir/${tfile}-$i
12253 if [ $? -ne 0 ] ; then
12254 echo "Warning: Failed to delete file $file"
12258 restore_lustre_params <$save_params
12259 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
12261 # Error out if no new thread has started or Thread started is greater
12263 if [[ $thread_started -le $OSTIO_pre ||
12264 $thread_started -gt $thread_max ]]; then
12265 error "ll_ost_io: thread_started $thread_started" \
12266 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
12267 "No new thread started or thread started greater " \
12271 run_test 115 "verify dynamic thread creation===================="
12273 test_116a() { # was previously test_116()
12274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12275 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12276 remote_mds_nodsh && skip "remote MDS with nodsh"
12278 echo -n "Free space priority "
12279 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
12284 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
12285 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
12286 stack_trap simple_cleanup_common
12288 # Check if we need to generate uneven OSTs
12289 test_mkdir -p $DIR/$tdir/OST${MINI}
12290 local FILL=$((MINV / 4))
12291 local DIFF=$((MAXV - MINV))
12292 local DIFF2=$((DIFF * 100 / MINV))
12294 local threshold=$(do_facet $SINGLEMDS \
12295 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
12296 threshold=${threshold%%%}
12297 echo -n "Check for uneven OSTs: "
12298 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
12300 if [[ $DIFF2 -gt $threshold ]]; then
12302 echo "Don't need to fill OST$MINI"
12304 # generate uneven OSTs. Write 2% over the QOS threshold value
12306 DIFF=$((threshold - DIFF2 + 2))
12307 DIFF2=$((MINV * DIFF / 100))
12308 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
12309 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
12310 error "setstripe failed"
12311 DIFF=$((DIFF2 / 2048))
12313 while [ $i -lt $DIFF ]; do
12315 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
12316 bs=2M count=1 2>/dev/null
12325 DIFF=$((MAXV - MINV))
12326 DIFF2=$((DIFF * 100 / MINV))
12327 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
12328 if [ $DIFF2 -gt $threshold ]; then
12331 skip "QOS imbalance criteria not met"
12339 # now fill using QOS
12340 $LFS setstripe -c 1 $DIR/$tdir
12341 FILL=$((FILL / 200))
12342 if [ $FILL -gt 600 ]; then
12345 echo "writing $FILL files to QOS-assigned OSTs"
12347 while [ $i -lt $FILL ]; do
12349 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
12350 count=1 2>/dev/null
12353 echo "wrote $i 200k files"
12357 echo "Note: free space may not be updated, so measurements might be off"
12359 DIFF2=$((MAXV - MINV))
12360 echo "free space delta: orig $DIFF final $DIFF2"
12361 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
12362 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
12363 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
12364 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
12365 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
12366 if [[ $DIFF -gt 0 ]]; then
12367 FILL=$((DIFF2 * 100 / DIFF - 100))
12368 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
12371 # Figure out which files were written where
12372 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12373 awk '/'$MINI1': / {print $2; exit}')
12375 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12376 echo "$MINC files created on smaller OST $MINI1"
12377 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12378 awk '/'$MAXI1': / {print $2; exit}')
12380 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12381 echo "$MAXC files created on larger OST $MAXI1"
12382 if [[ $MINC -gt 0 ]]; then
12383 FILL=$((MAXC * 100 / MINC - 100))
12384 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
12386 [[ $MAXC -gt $MINC ]] ||
12387 error_ignore LU-9 "stripe QOS didn't balance free space"
12389 run_test 116a "stripe QOS: free space balance ==================="
12391 test_116b() { # LU-2093
12392 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12393 remote_mds_nodsh && skip "remote MDS with nodsh"
12395 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
12396 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
12397 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
12398 [ -z "$old_rr" ] && skip "no QOS"
12399 do_facet $SINGLEMDS lctl set_param \
12400 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
12401 mkdir -p $DIR/$tdir
12402 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
12403 createmany -o $DIR/$tdir/f- 20 || error "can't create"
12404 do_facet $SINGLEMDS lctl set_param fail_loc=0
12406 do_facet $SINGLEMDS lctl set_param \
12407 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
12409 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
12411 test_117() # bug 10891
12413 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12415 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
12416 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
12417 lctl set_param fail_loc=0x21e
12418 > $DIR/$tfile || error "truncate failed"
12419 lctl set_param fail_loc=0
12420 echo "Truncate succeeded."
12423 run_test 117 "verify osd extend =========="
12425 NO_SLOW_RESENDCOUNT=4
12426 export OLD_RESENDCOUNT=""
12427 set_resend_count () {
12428 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
12429 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
12430 lctl set_param -n $PROC_RESENDCOUNT $1
12431 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
12434 # for reduce test_118* time (b=14842)
12435 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12437 # Reset async IO behavior after error case
12439 FILE=$DIR/reset_async
12441 # Ensure all OSCs are cleared
12442 $LFS setstripe -c -1 $FILE
12443 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
12448 test_118a() #bug 11710
12450 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12454 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12455 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12456 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12458 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12459 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12464 run_test 118a "verify O_SYNC works =========="
12468 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12469 remote_ost_nodsh && skip "remote OST with nodsh"
12473 #define OBD_FAIL_SRV_ENOENT 0x217
12474 set_nodes_failloc "$(osts_nodes)" 0x217
12475 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12477 set_nodes_failloc "$(osts_nodes)" 0
12478 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12479 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12482 if [[ $RC -eq 0 ]]; then
12483 error "Must return error due to dropped pages, rc=$RC"
12487 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12488 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12492 echo "Dirty pages not leaked on ENOENT"
12494 # Due to the above error the OSC will issue all RPCs syncronously
12495 # until a subsequent RPC completes successfully without error.
12496 $MULTIOP $DIR/$tfile Ow4096yc
12501 run_test 118b "Reclaim dirty pages on fatal error =========="
12505 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12507 # for 118c, restore the original resend count, LU-1940
12508 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
12509 set_resend_count $OLD_RESENDCOUNT
12510 remote_ost_nodsh && skip "remote OST with nodsh"
12514 #define OBD_FAIL_OST_EROFS 0x216
12515 set_nodes_failloc "$(osts_nodes)" 0x216
12517 # multiop should block due to fsync until pages are written
12518 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12522 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12523 error "Multiop failed to block on fsync, pid=$MULTIPID"
12526 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12528 if [[ $WRITEBACK -eq 0 ]]; then
12529 error "No page in writeback, writeback=$WRITEBACK"
12532 set_nodes_failloc "$(osts_nodes)" 0
12535 if [[ $RC -ne 0 ]]; then
12536 error "Multiop fsync failed, rc=$RC"
12539 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12540 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12542 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12543 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12547 echo "Dirty pages flushed via fsync on EROFS"
12550 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
12552 # continue to use small resend count to reduce test_118* time (b=14842)
12553 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12557 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12558 remote_ost_nodsh && skip "remote OST with nodsh"
12562 #define OBD_FAIL_OST_BRW_PAUSE_BULK
12563 set_nodes_failloc "$(osts_nodes)" 0x214
12564 # multiop should block due to fsync until pages are written
12565 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12569 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12570 error "Multiop failed to block on fsync, pid=$MULTIPID"
12573 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12575 if [[ $WRITEBACK -eq 0 ]]; then
12576 error "No page in writeback, writeback=$WRITEBACK"
12579 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
12580 set_nodes_failloc "$(osts_nodes)" 0
12582 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12583 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12585 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12586 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12590 echo "Dirty pages gaurenteed flushed via fsync"
12593 run_test 118d "Fsync validation inject a delay of the bulk =========="
12596 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12600 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
12601 lctl set_param fail_loc=0x8000040a
12603 # Should simulate EINVAL error which is fatal
12604 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12606 if [[ $RC -eq 0 ]]; then
12607 error "Must return error due to dropped pages, rc=$RC"
12610 lctl set_param fail_loc=0x0
12612 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12613 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12614 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12616 if [[ $LOCKED -ne 0 ]]; then
12617 error "Locked pages remain in cache, locked=$LOCKED"
12620 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12621 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12625 echo "No pages locked after fsync"
12630 run_test 118f "Simulate unrecoverable OSC side error =========="
12633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12637 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
12638 lctl set_param fail_loc=0x406
12640 # simulate local -ENOMEM
12641 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12644 lctl set_param fail_loc=0
12645 if [[ $RC -eq 0 ]]; then
12646 error "Must return error due to dropped pages, rc=$RC"
12649 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12650 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12651 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12653 if [[ $LOCKED -ne 0 ]]; then
12654 error "Locked pages remain in cache, locked=$LOCKED"
12657 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12658 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12662 echo "No pages locked after fsync"
12667 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
12670 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12671 remote_ost_nodsh && skip "remote OST with nodsh"
12675 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12676 set_nodes_failloc "$(osts_nodes)" 0x20e
12677 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12678 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12681 set_nodes_failloc "$(osts_nodes)" 0
12682 if [[ $RC -eq 0 ]]; then
12683 error "Must return error due to dropped pages, rc=$RC"
12686 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12687 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12688 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12690 if [[ $LOCKED -ne 0 ]]; then
12691 error "Locked pages remain in cache, locked=$LOCKED"
12694 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12695 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12699 echo "No pages locked after fsync"
12703 run_test 118h "Verify timeout in handling recoverables errors =========="
12705 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12708 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12709 remote_ost_nodsh && skip "remote OST with nodsh"
12713 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12714 set_nodes_failloc "$(osts_nodes)" 0x20e
12716 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12717 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12720 set_nodes_failloc "$(osts_nodes)" 0
12724 if [[ $RC -ne 0 ]]; then
12725 error "got error, but should be not, rc=$RC"
12728 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12729 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12730 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12731 if [[ $LOCKED -ne 0 ]]; then
12732 error "Locked pages remain in cache, locked=$LOCKED"
12735 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12736 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12740 echo "No pages locked after fsync"
12744 run_test 118i "Fix error before timeout in recoverable error =========="
12746 [ "$SLOW" = "no" ] && set_resend_count 4
12749 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12750 remote_ost_nodsh && skip "remote OST with nodsh"
12754 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
12755 set_nodes_failloc "$(osts_nodes)" 0x220
12757 # return -EIO from OST
12758 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12760 set_nodes_failloc "$(osts_nodes)" 0x0
12761 if [[ $RC -eq 0 ]]; then
12762 error "Must return error due to dropped pages, rc=$RC"
12765 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12766 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12767 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12768 if [[ $LOCKED -ne 0 ]]; then
12769 error "Locked pages remain in cache, locked=$LOCKED"
12772 # in recoverable error on OST we want resend and stay until it finished
12773 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12774 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12778 echo "No pages locked after fsync"
12782 run_test 118j "Simulate unrecoverable OST side error =========="
12786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12787 remote_ost_nodsh && skip "remote OSTs with nodsh"
12789 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12790 set_nodes_failloc "$(osts_nodes)" 0x20e
12791 test_mkdir $DIR/$tdir
12793 for ((i=0;i<10;i++)); do
12794 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
12795 error "dd to $DIR/$tdir/$tfile-$i failed" )&
12802 set_nodes_failloc "$(osts_nodes)" 0
12805 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
12807 test_118l() # LU-646
12809 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12811 test_mkdir $DIR/$tdir
12812 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
12815 run_test 118l "fsync dir"
12817 test_118m() # LU-3066
12819 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12821 test_mkdir $DIR/$tdir
12822 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
12825 run_test 118m "fdatasync dir ========="
12827 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12834 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12835 remote_ost_nodsh && skip "remote OSTs with nodsh"
12837 # Sleep to avoid a cached response.
12838 #define OBD_STATFS_CACHE_SECONDS 1
12841 # Inject a 10 second delay in the OST_STATFS handler.
12842 #define OBD_FAIL_OST_STATFS_DELAY 0x242
12843 set_nodes_failloc "$(osts_nodes)" 0x242
12846 stat --file-system $MOUNT > /dev/null
12849 set_nodes_failloc "$(osts_nodes)" 0
12851 if ((end - begin > 20)); then
12852 error "statfs took $((end - begin)) seconds, expected 10"
12855 run_test 118n "statfs() sends OST_STATFS requests in parallel"
12857 test_119a() # bug 11737
12859 BSIZE=$((512 * 1024))
12860 directio write $DIR/$tfile 0 1 $BSIZE
12861 # We ask to read two blocks, which is more than a file size.
12862 # directio will indicate an error when requested and actual
12863 # sizes aren't equeal (a normal situation in this case) and
12864 # print actual read amount.
12865 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
12866 if [ "$NOB" != "$BSIZE" ]; then
12867 error "read $NOB bytes instead of $BSIZE"
12871 run_test 119a "Short directIO read must return actual read amount"
12873 test_119b() # bug 11737
12875 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12877 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
12878 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
12880 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
12881 error "direct read failed"
12884 run_test 119b "Sparse directIO read must return actual read amount"
12886 test_119c() # bug 13099
12889 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
12890 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
12893 run_test 119c "Testing for direct read hitting hole"
12895 test_119d() # bug 15950
12897 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12899 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
12900 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
12902 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
12903 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
12904 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
12905 lctl set_param fail_loc=0x40d
12906 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
12909 cat $DIR/$tfile > /dev/null &
12910 lctl set_param fail_loc=0
12913 log "the DIO writes have completed, now wait for the reads (should not block very long)"
12915 [ -n "`ps h -p $pid_reads -o comm`" ] && \
12916 error "the read rpcs have not completed in 2s"
12918 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
12920 run_test 119d "The DIO path should try to send a new rpc once one is completed"
12923 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12924 remote_mds_nodsh && skip "remote MDS with nodsh"
12925 test_mkdir -i0 -c1 $DIR/$tdir
12926 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12927 skip_env "no early lock cancel on server"
12929 lru_resize_disable mdc
12930 lru_resize_disable osc
12931 cancel_lru_locks mdc
12932 # asynchronous object destroy at MDT could cause bl ast to client
12933 cancel_lru_locks osc
12935 stat $DIR/$tdir > /dev/null
12936 can1=$(do_facet mds1 \
12937 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12938 awk '/ldlm_cancel/ {print $2}')
12939 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12940 awk '/ldlm_bl_callback/ {print $2}')
12941 test_mkdir -i0 -c1 $DIR/$tdir/d1
12942 can2=$(do_facet mds1 \
12943 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12944 awk '/ldlm_cancel/ {print $2}')
12945 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12946 awk '/ldlm_bl_callback/ {print $2}')
12947 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12948 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12949 lru_resize_enable mdc
12950 lru_resize_enable osc
12952 run_test 120a "Early Lock Cancel: mkdir test"
12955 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12956 remote_mds_nodsh && skip "remote MDS with nodsh"
12957 test_mkdir $DIR/$tdir
12958 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12959 skip_env "no early lock cancel on server"
12961 lru_resize_disable mdc
12962 lru_resize_disable osc
12963 cancel_lru_locks mdc
12964 stat $DIR/$tdir > /dev/null
12965 can1=$(do_facet $SINGLEMDS \
12966 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12967 awk '/ldlm_cancel/ {print $2}')
12968 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12969 awk '/ldlm_bl_callback/ {print $2}')
12970 touch $DIR/$tdir/f1
12971 can2=$(do_facet $SINGLEMDS \
12972 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12973 awk '/ldlm_cancel/ {print $2}')
12974 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12975 awk '/ldlm_bl_callback/ {print $2}')
12976 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12977 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12978 lru_resize_enable mdc
12979 lru_resize_enable osc
12981 run_test 120b "Early Lock Cancel: create test"
12984 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12985 remote_mds_nodsh && skip "remote MDS with nodsh"
12986 test_mkdir -i0 -c1 $DIR/$tdir
12987 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12988 skip "no early lock cancel on server"
12990 lru_resize_disable mdc
12991 lru_resize_disable osc
12992 test_mkdir -i0 -c1 $DIR/$tdir/d1
12993 test_mkdir -i0 -c1 $DIR/$tdir/d2
12994 touch $DIR/$tdir/d1/f1
12995 cancel_lru_locks mdc
12996 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
12997 can1=$(do_facet mds1 \
12998 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12999 awk '/ldlm_cancel/ {print $2}')
13000 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13001 awk '/ldlm_bl_callback/ {print $2}')
13002 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13003 can2=$(do_facet mds1 \
13004 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13005 awk '/ldlm_cancel/ {print $2}')
13006 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13007 awk '/ldlm_bl_callback/ {print $2}')
13008 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13009 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13010 lru_resize_enable mdc
13011 lru_resize_enable osc
13013 run_test 120c "Early Lock Cancel: link test"
13016 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13017 remote_mds_nodsh && skip "remote MDS with nodsh"
13018 test_mkdir -i0 -c1 $DIR/$tdir
13019 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13020 skip_env "no early lock cancel on server"
13022 lru_resize_disable mdc
13023 lru_resize_disable osc
13025 cancel_lru_locks mdc
13026 stat $DIR/$tdir > /dev/null
13027 can1=$(do_facet mds1 \
13028 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13029 awk '/ldlm_cancel/ {print $2}')
13030 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13031 awk '/ldlm_bl_callback/ {print $2}')
13032 chmod a+x $DIR/$tdir
13033 can2=$(do_facet mds1 \
13034 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13035 awk '/ldlm_cancel/ {print $2}')
13036 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13037 awk '/ldlm_bl_callback/ {print $2}')
13038 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13039 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13040 lru_resize_enable mdc
13041 lru_resize_enable osc
13043 run_test 120d "Early Lock Cancel: setattr test"
13046 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13047 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13048 skip_env "no early lock cancel on server"
13049 remote_mds_nodsh && skip "remote MDS with nodsh"
13051 local dlmtrace_set=false
13053 test_mkdir -i0 -c1 $DIR/$tdir
13054 lru_resize_disable mdc
13055 lru_resize_disable osc
13056 ! $LCTL get_param debug | grep -q dlmtrace &&
13057 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
13058 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
13059 cancel_lru_locks mdc
13060 cancel_lru_locks osc
13061 dd if=$DIR/$tdir/f1 of=/dev/null
13062 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
13063 # XXX client can not do early lock cancel of OST lock
13064 # during unlink (LU-4206), so cancel osc lock now.
13066 cancel_lru_locks osc
13067 can1=$(do_facet mds1 \
13068 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13069 awk '/ldlm_cancel/ {print $2}')
13070 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13071 awk '/ldlm_bl_callback/ {print $2}')
13072 unlink $DIR/$tdir/f1
13074 can2=$(do_facet mds1 \
13075 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13076 awk '/ldlm_cancel/ {print $2}')
13077 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13078 awk '/ldlm_bl_callback/ {print $2}')
13079 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
13080 $LCTL dk $TMP/cancel.debug.txt
13081 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
13082 $LCTL dk $TMP/blocking.debug.txt
13083 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
13084 lru_resize_enable mdc
13085 lru_resize_enable osc
13087 run_test 120e "Early Lock Cancel: unlink test"
13090 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13091 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13092 skip_env "no early lock cancel on server"
13093 remote_mds_nodsh && skip "remote MDS with nodsh"
13095 test_mkdir -i0 -c1 $DIR/$tdir
13096 lru_resize_disable mdc
13097 lru_resize_disable osc
13098 test_mkdir -i0 -c1 $DIR/$tdir/d1
13099 test_mkdir -i0 -c1 $DIR/$tdir/d2
13100 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
13101 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
13102 cancel_lru_locks mdc
13103 cancel_lru_locks osc
13104 dd if=$DIR/$tdir/d1/f1 of=/dev/null
13105 dd if=$DIR/$tdir/d2/f2 of=/dev/null
13106 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
13107 # XXX client can not do early lock cancel of OST lock
13108 # during rename (LU-4206), so cancel osc lock now.
13110 cancel_lru_locks osc
13111 can1=$(do_facet mds1 \
13112 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13113 awk '/ldlm_cancel/ {print $2}')
13114 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13115 awk '/ldlm_bl_callback/ {print $2}')
13116 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13118 can2=$(do_facet mds1 \
13119 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13120 awk '/ldlm_cancel/ {print $2}')
13121 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13122 awk '/ldlm_bl_callback/ {print $2}')
13123 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13124 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13125 lru_resize_enable mdc
13126 lru_resize_enable osc
13128 run_test 120f "Early Lock Cancel: rename test"
13131 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13132 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13133 skip_env "no early lock cancel on server"
13134 remote_mds_nodsh && skip "remote MDS with nodsh"
13136 lru_resize_disable mdc
13137 lru_resize_disable osc
13139 echo create $count files
13140 test_mkdir $DIR/$tdir
13141 cancel_lru_locks mdc
13142 cancel_lru_locks osc
13145 can0=$(do_facet $SINGLEMDS \
13146 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13147 awk '/ldlm_cancel/ {print $2}')
13148 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13149 awk '/ldlm_bl_callback/ {print $2}')
13150 createmany -o $DIR/$tdir/f $count
13152 can1=$(do_facet $SINGLEMDS \
13153 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13154 awk '/ldlm_cancel/ {print $2}')
13155 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13156 awk '/ldlm_bl_callback/ {print $2}')
13158 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
13159 echo rm $count files
13162 can2=$(do_facet $SINGLEMDS \
13163 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13164 awk '/ldlm_cancel/ {print $2}')
13165 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13166 awk '/ldlm_bl_callback/ {print $2}')
13168 echo total: $count removes in $((t2-t1))
13169 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
13171 # wait for commitment of removal
13172 lru_resize_enable mdc
13173 lru_resize_enable osc
13175 run_test 120g "Early Lock Cancel: performance test"
13177 test_121() { #bug #10589
13178 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13181 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
13182 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
13183 lctl set_param fail_loc=0x310
13184 cancel_lru_locks osc > /dev/null
13185 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
13186 lctl set_param fail_loc=0
13187 [[ $reads -eq $writes ]] ||
13188 error "read $reads blocks, must be $writes blocks"
13190 run_test 121 "read cancel race ========="
13192 test_123a_base() { # was test 123, statahead(bug 11401)
13196 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
13197 log "testing UP system. Performance may be lower than expected."
13200 running_in_vm && SLOWOK=1
13203 test_mkdir $DIR/$tdir
13204 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
13205 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
13207 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
13208 createmany -o $DIR/$tdir/$tfile $j $((i - j))
13210 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
13211 lctl set_param -n llite.*.statahead_max 0
13212 lctl get_param llite.*.statahead_max
13213 cancel_lru_locks mdc
13214 cancel_lru_locks osc
13216 time $lsx $DIR/$tdir | wc -l
13218 delta=$((etime - stime))
13219 log "$lsx $i files without statahead: $delta sec"
13220 lctl set_param llite.*.statahead_max=$max
13222 swrong=$(lctl get_param -n llite.*.statahead_stats |
13223 awk '/statahead.wrong:/ { print $NF }')
13224 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
13225 cancel_lru_locks mdc
13226 cancel_lru_locks osc
13228 time $lsx $DIR/$tdir | wc -l
13230 delta_sa=$((etime - stime))
13231 log "$lsx $i files with statahead: $delta_sa sec"
13232 lctl get_param -n llite.*.statahead_stats
13233 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13234 awk '/statahead.wrong:/ { print $NF }')
13236 [[ $swrong -lt $ewrong ]] &&
13237 log "statahead was stopped, maybe too many locks held!"
13238 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
13240 if (( $delta_sa*100 > $delta*105 && $delta_sa > $delta+2)); then
13241 max=$(lctl get_param -n llite.*.statahead_max |
13243 lctl set_param -n llite.*.statahead_max 0
13244 lctl get_param llite.*.statahead_max
13245 cancel_lru_locks mdc
13246 cancel_lru_locks osc
13248 time $lsx $DIR/$tdir | wc -l
13250 delta=$((etime - stime))
13251 log "$lsx $i files again without statahead: $delta sec"
13252 lctl set_param llite.*.statahead_max=$max
13253 if (( $delta_sa*100 > delta*105 && delta_sa > delta+2 )); then
13254 if [ $SLOWOK -eq 0 ]; then
13255 error "$lsx $i files is slower with statahead!"
13257 log "$lsx $i files is slower with statahead!"
13263 [ $delta -gt 20 ] && break
13264 [ $delta -gt 8 ] && MULT=$((50 / delta))
13265 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
13273 delta=$((etime - stime))
13274 log "rm -r $DIR/$tdir/: $delta seconds"
13276 lctl get_param -n llite.*.statahead_stats
13280 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13282 test_123a_base "ls -l"
13284 run_test 123aa "verify statahead work"
13287 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13289 statx_supported || skip_env "Test must be statx() syscall supported"
13291 test_123a_base "$STATX -l"
13293 run_test 123ab "verify statahead work by using statx"
13296 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13298 statx_supported || skip_env "Test must be statx() syscall supported"
13305 cancel_lru_locks $OSC
13306 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13307 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
13308 awk '/agl.total:/ { print $NF }')
13309 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
13310 test_123a_base "$STATX --cached=always -D"
13311 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
13312 awk '/agl.total:/ { print $NF }')
13313 [ $agl_before -eq $agl_after ] ||
13314 error "Should not trigger AGL thread - $agl_before:$agl_after"
13315 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13316 [ $rpcs_after -eq $rpcs_before ] ||
13317 error "$STATX should not send glimpse RPCs to $OSC"
13319 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
13321 test_123b () { # statahead(bug 15027)
13322 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13324 test_mkdir $DIR/$tdir
13325 createmany -o $DIR/$tdir/$tfile-%d 1000
13327 cancel_lru_locks mdc
13328 cancel_lru_locks osc
13330 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
13331 lctl set_param fail_loc=0x80000803
13332 ls -lR $DIR/$tdir > /dev/null
13334 lctl set_param fail_loc=0x0
13335 lctl get_param -n llite.*.statahead_stats
13340 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
13343 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
13345 test_mkdir -i 0 -c 1 $DIR/$tdir.0
13346 test_mkdir -i 1 -c 1 $DIR/$tdir.1
13347 touch $DIR/$tdir.1/{1..3}
13348 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
13350 remount_client $MOUNT
13352 $MULTIOP $DIR/$tdir.0 Q
13354 # let statahead to complete
13355 ls -l $DIR/$tdir.0 > /dev/null
13357 testid=$(echo $TESTNAME | tr '_' ' ')
13358 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
13359 error "statahead warning" || true
13361 run_test 123c "Can not initialize inode warning on DNE statahead"
13368 test_mkdir -c -1 $DIR/$tdir || error "test_mkdir $DIR/$tdir failed"
13369 $LFS setdirstripe -D -c $MDSCOUNT $DIR/$tdir ||
13370 error "setdirstripe $DIR/$tdir failed"
13371 createmany -d $DIR/$tdir/$tfile $num || error "createmany $num failed"
13372 remount_client $MOUNT
13373 $LCTL get_param llite.*.statahead_max
13374 $LCTL set_param llite.*.statahead_stats=0 ||
13375 error "clear statahead_stats failed"
13376 swrong=$(lctl get_param -n llite.*.statahead_stats |
13377 awk '/statahead.wrong:/ { print $NF }')
13378 ls -l $DIR/$tdir || error "ls -l $DIR/$tdir failed"
13379 # wait for statahead thread finished to update hit/miss stats.
13381 $LCTL get_param -n llite.*.statahead_stats
13382 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13383 awk '/statahead.wrong:/ { print $NF }')
13384 (( $swrong == $ewrong )) ||
13385 log "statahead was stopped, maybe too many locks held!"
13387 run_test 123d "Statahead on striped directories works correctly"
13390 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13391 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13392 skip_env "no lru resize on server"
13396 test_mkdir $DIR/$tdir
13398 log "create $NR files at $DIR/$tdir"
13399 createmany -o $DIR/$tdir/f $NR ||
13400 error "failed to create $NR files in $DIR/$tdir"
13402 cancel_lru_locks mdc
13403 ls -l $DIR/$tdir > /dev/null
13407 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
13408 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
13409 LRU_SIZE=$($LCTL get_param -n $PARAM)
13410 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
13411 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
13413 log "NS=$(basename $NSDIR)"
13418 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
13419 skip "Not enough cached locks created!"
13421 log "LRU=$LRU_SIZE"
13425 # We know that lru resize allows one client to hold $LIMIT locks
13426 # for 10h. After that locks begin to be killed by client.
13428 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
13430 if [ $LIMIT -lt $LRU_SIZE ]; then
13431 skip "Limit is too small $LIMIT"
13434 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
13435 # killing locks. Some time was spent for creating locks. This means
13436 # that up to the moment of sleep finish we must have killed some of
13437 # them (10-100 locks). This depends on how fast ther were created.
13438 # Many of them were touched in almost the same moment and thus will
13439 # be killed in groups.
13440 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
13442 # Use $LRU_SIZE_B here to take into account real number of locks
13443 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
13444 local LRU_SIZE_B=$LRU_SIZE
13446 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
13447 log "OLD_LVF=$OLD_LVF"
13448 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
13450 # Let's make sure that we really have some margin. Client checks
13451 # cached locks every 10 sec.
13452 SLEEP=$((SLEEP+20))
13453 log "Sleep ${SLEEP} sec"
13455 while ((SEC<$SLEEP)); do
13459 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
13460 echo -n "$LRU_SIZE"
13463 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
13464 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
13466 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
13467 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
13468 unlinkmany $DIR/$tdir/f $NR
13472 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
13473 log "unlink $NR files at $DIR/$tdir"
13474 unlinkmany $DIR/$tdir/f $NR
13476 run_test 124a "lru resize ======================================="
13478 get_max_pool_limit()
13480 local limit=$($LCTL get_param \
13481 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
13483 for l in $limit; do
13484 if [[ $l -gt $max ]]; then
13492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13493 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13494 skip_env "no lru resize on server"
13496 LIMIT=$(get_max_pool_limit)
13498 NR=$(($(default_lru_size)*20))
13499 if [[ $NR -gt $LIMIT ]]; then
13500 log "Limit lock number by $LIMIT locks"
13504 IFree=$(mdsrate_inodes_available)
13505 if [ $IFree -lt $NR ]; then
13506 log "Limit lock number by $IFree inodes"
13510 lru_resize_disable mdc
13511 test_mkdir -p $DIR/$tdir/disable_lru_resize
13513 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
13514 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
13515 cancel_lru_locks mdc
13518 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13521 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13524 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13528 nolruresize_delta=$((etime-stime))
13529 log "ls -la time: $nolruresize_delta seconds"
13530 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13531 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
13533 lru_resize_enable mdc
13534 test_mkdir -p $DIR/$tdir/enable_lru_resize
13536 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
13537 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
13538 cancel_lru_locks mdc
13541 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13544 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13547 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13551 lruresize_delta=$((etime-stime))
13552 log "ls -la time: $lruresize_delta seconds"
13553 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13555 if [ $lruresize_delta -gt $nolruresize_delta ]; then
13556 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
13557 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
13558 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
13560 log "lru resize performs the same with no lru resize"
13562 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
13564 run_test 124b "lru resize (performance test) ======================="
13567 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13568 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13569 skip_env "no lru resize on server"
13571 # cache ununsed locks on client
13573 cancel_lru_locks mdc
13574 test_mkdir $DIR/$tdir
13575 createmany -o $DIR/$tdir/f $nr ||
13576 error "failed to create $nr files in $DIR/$tdir"
13577 ls -l $DIR/$tdir > /dev/null
13579 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13580 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13581 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13582 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13583 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13585 # set lru_max_age to 1 sec
13586 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13587 echo "sleep $((recalc_p * 2)) seconds..."
13588 sleep $((recalc_p * 2))
13590 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13591 # restore lru_max_age
13592 $LCTL set_param -n $nsdir.lru_max_age $max_age
13593 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13594 unlinkmany $DIR/$tdir/f $nr
13596 run_test 124c "LRUR cancel very aged locks"
13599 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13600 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13601 skip_env "no lru resize on server"
13603 # cache ununsed locks on client
13606 lru_resize_disable mdc
13607 stack_trap "lru_resize_enable mdc" EXIT
13609 cancel_lru_locks mdc
13611 # asynchronous object destroy at MDT could cause bl ast to client
13612 test_mkdir $DIR/$tdir
13613 createmany -o $DIR/$tdir/f $nr ||
13614 error "failed to create $nr files in $DIR/$tdir"
13615 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
13617 ls -l $DIR/$tdir > /dev/null
13619 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13620 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13621 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13622 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13624 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13626 # set lru_max_age to 1 sec
13627 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13628 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
13630 echo "sleep $((recalc_p * 2)) seconds..."
13631 sleep $((recalc_p * 2))
13633 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13635 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13637 run_test 124d "cancel very aged locks if lru-resize diasbaled"
13639 test_125() { # 13358
13640 $LCTL get_param -n llite.*.client_type | grep -q local ||
13641 skip "must run as local client"
13642 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
13643 skip_env "must have acl enabled"
13644 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13646 test_mkdir $DIR/$tdir
13647 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
13648 setfacl -R -m u:$USER0:rwx $DIR/$tdir ||
13649 error "setfacl $DIR/$tdir failed"
13650 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
13652 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
13654 test_126() { # bug 12829/13455
13655 $GSS && skip_env "must run as gss disabled"
13656 $LCTL get_param -n llite.*.client_type | grep -q local ||
13657 skip "must run as local client"
13658 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
13660 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
13661 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
13663 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
13665 run_test 126 "check that the fsgid provided by the client is taken into account"
13667 test_127a() { # bug 15521
13668 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13669 local name count samp unit min max sum sumsq
13671 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
13672 echo "stats before reset"
13673 $LCTL get_param osc.*.stats
13674 $LCTL set_param osc.*.stats=0
13675 local fsize=$((2048 * 1024))
13677 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
13678 cancel_lru_locks osc
13679 dd if=$DIR/$tfile of=/dev/null bs=$fsize
13681 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
13682 stack_trap "rm -f $TMP/$tfile.tmp"
13683 while read name count samp unit min max sum sumsq; do
13684 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13685 [ ! $min ] && error "Missing min value for $name proc entry"
13686 eval $name=$count || error "Wrong proc format"
13689 read_bytes|write_bytes)
13690 [[ "$unit" =~ "bytes" ]] ||
13691 error "unit is not 'bytes': $unit"
13692 (( $min >= 4096 )) || error "min is too small: $min"
13693 (( $min <= $fsize )) || error "min is too big: $min"
13694 (( $max >= 4096 )) || error "max is too small: $max"
13695 (( $max <= $fsize )) || error "max is too big: $max"
13696 (( $sum == $fsize )) || error "sum is wrong: $sum"
13697 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
13698 error "sumsquare is too small: $sumsq"
13699 (( $sumsq <= $fsize * $fsize )) ||
13700 error "sumsquare is too big: $sumsq"
13702 ost_read|ost_write)
13703 [[ "$unit" =~ "usec" ]] ||
13704 error "unit is not 'usec': $unit"
13708 done < $DIR/$tfile.tmp
13710 #check that we actually got some stats
13711 [ "$read_bytes" ] || error "Missing read_bytes stats"
13712 [ "$write_bytes" ] || error "Missing write_bytes stats"
13713 [ "$read_bytes" != 0 ] || error "no read done"
13714 [ "$write_bytes" != 0 ] || error "no write done"
13716 run_test 127a "verify the client stats are sane"
13718 test_127b() { # bug LU-333
13719 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13720 local name count samp unit min max sum sumsq
13722 echo "stats before reset"
13723 $LCTL get_param llite.*.stats
13724 $LCTL set_param llite.*.stats=0
13726 # perform 2 reads and writes so MAX is different from SUM.
13727 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13728 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13729 cancel_lru_locks osc
13730 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13731 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13733 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
13734 stack_trap "rm -f $TMP/$tfile.tmp"
13735 while read name count samp unit min max sum sumsq; do
13736 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13737 eval $name=$count || error "Wrong proc format"
13740 read_bytes|write_bytes)
13741 [[ "$unit" =~ "bytes" ]] ||
13742 error "unit is not 'bytes': $unit"
13743 (( $count == 2 )) || error "count is not 2: $count"
13744 (( $min == $PAGE_SIZE )) ||
13745 error "min is not $PAGE_SIZE: $min"
13746 (( $max == $PAGE_SIZE )) ||
13747 error "max is not $PAGE_SIZE: $max"
13748 (( $sum == $PAGE_SIZE * 2 )) ||
13749 error "sum is not $((PAGE_SIZE * 2)): $sum"
13752 [[ "$unit" =~ "usec" ]] ||
13753 error "unit is not 'usec': $unit"
13757 done < $TMP/$tfile.tmp
13759 #check that we actually got some stats
13760 [ "$read_bytes" ] || error "Missing read_bytes stats"
13761 [ "$write_bytes" ] || error "Missing write_bytes stats"
13762 [ "$read_bytes" != 0 ] || error "no read done"
13763 [ "$write_bytes" != 0 ] || error "no write done"
13765 run_test 127b "verify the llite client stats are sane"
13767 test_127c() { # LU-12394
13768 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13775 $LCTL set_param llite.*.extents_stats=1
13776 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
13778 # Use two stripes so there is enough space in default config
13779 $LFS setstripe -c 2 $DIR/$tfile
13781 # Extent stats start at 0-4K and go in power of two buckets
13782 # LL_HIST_START = 12 --> 2^12 = 4K
13783 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
13784 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
13786 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
13788 # Write and read, 2x each, second time at a non-zero offset
13789 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
13790 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
13791 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
13792 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
13796 $LCTL get_param llite.*.extents_stats
13799 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
13801 local bucket=$($LCTL get_param -n llite.*.extents_stats |
13803 reads=$(echo $bucket | awk '{print $5}')
13804 writes=$(echo $bucket | awk '{print $9}')
13805 [ "$reads" -eq $count ] ||
13806 error "$reads reads in < $bsize bucket, expect $count"
13807 [ "$writes" -eq $count ] ||
13808 error "$writes writes in < $bsize bucket, expect $count"
13811 # Test mmap write and read
13812 $LCTL set_param llite.*.extents_stats=c
13814 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
13815 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
13816 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
13818 $LCTL get_param llite.*.extents_stats
13820 count=$(((size*1024) / PAGE_SIZE))
13822 bsize=$((2 * PAGE_SIZE / 1024))K
13824 bucket=$($LCTL get_param -n llite.*.extents_stats |
13826 reads=$(echo $bucket | awk '{print $5}')
13827 writes=$(echo $bucket | awk '{print $9}')
13828 # mmap writes fault in the page first, creating an additonal read
13829 [ "$reads" -eq $((2 * count)) ] ||
13830 error "$reads reads in < $bsize bucket, expect $count"
13831 [ "$writes" -eq $count ] ||
13832 error "$writes writes in < $bsize bucket, expect $count"
13834 run_test 127c "test llite extent stats with regular & mmap i/o"
13836 test_128() { # bug 15212
13838 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
13843 result=$(grep error $TMP/$tfile.log)
13844 rm -f $DIR/$tfile $TMP/$tfile.log
13845 [ -z "$result" ] ||
13846 error "consecutive find's under interactive lfs failed"
13848 run_test 128 "interactive lfs for 2 consecutive find's"
13850 set_dir_limits () {
13855 local ldproc=/proc/fs/ldiskfs
13856 local facets=$(get_facets MDS)
13858 for facet in ${facets//,/ }; do
13859 canondev=$(ldiskfs_canon \
13860 *.$(convert_facet2label $facet).mntdev $facet)
13861 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
13862 ldproc=/sys/fs/ldiskfs
13863 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
13864 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
13868 check_mds_dmesg() {
13869 local facets=$(get_facets MDS)
13870 for facet in ${facets//,/ }; do
13871 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
13877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13878 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
13879 skip "Need MDS version with at least 2.5.56"
13880 if [ "$mds1_FSTYPE" != ldiskfs ]; then
13881 skip_env "ldiskfs only test"
13883 remote_mds_nodsh && skip "remote MDS with nodsh"
13886 local has_warning=false
13889 mkdir -p $DIR/$tdir
13891 # block size of mds1
13892 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
13893 set_dir_limits $maxsize $((maxsize * 6 / 8))
13894 stack_trap "set_dir_limits 0 0"
13895 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
13896 local dirsize=$(stat -c%s "$DIR/$tdir")
13898 while (( $dirsize <= $maxsize )); do
13899 $MCREATE $DIR/$tdir/file_base_$nfiles
13901 # check two errors:
13902 # ENOSPC for ext4 max_dir_size, which has been used since
13903 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
13904 if (( rc == ENOSPC )); then
13906 echo "rc=$rc returned as expected after $nfiles files"
13908 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
13909 error "create failed w/o dir size limit"
13911 # messages may be rate limited if test is run repeatedly
13912 check_mds_dmesg '"is approaching max"' ||
13913 echo "warning message should be output"
13914 check_mds_dmesg '"has reached max"' ||
13915 echo "reached message should be output"
13917 dirsize=$(stat -c%s "$DIR/$tdir")
13919 [[ $dirsize -ge $maxsize ]] && return 0
13920 error "dirsize $dirsize < $maxsize after $nfiles files"
13921 elif (( rc != 0 )); then
13924 nfiles=$((nfiles + 1))
13925 dirsize=$(stat -c%s "$DIR/$tdir")
13928 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
13930 run_test 129 "test directory size limit ========================"
13939 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13940 [[ -z "$filefrag_op" ]] || skip_env "filefrag does not support FIEMAP"
13942 trap cleanup_130 EXIT RETURN
13944 local fm_file=$DIR/$tfile
13945 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
13946 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
13947 error "dd failed for $fm_file"
13949 # LU-1795: test filefrag/FIEMAP once, even if unsupported on ZFS
13950 filefrag -ves $fm_file
13952 [[ "$ost1_FSTYPE" != "zfs" ]] ||
13953 skip "LU-1941: FIEMAP unimplemented on ZFS"
13954 (( $rc == 0 )) || error "filefrag $fm_file failed"
13956 filefrag_op=$(filefrag -ve -k $fm_file |
13957 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13958 local lun=$($LFS getstripe -i $fm_file)
13960 local start_blk=$(echo $filefrag_op | cut -d: -f2 | cut -d. -f1)
13963 for line in $filefrag_op; do
13964 local frag_lun=$(echo $line | cut -d: -f5)
13965 local ext_len=$(echo $line | cut -d: -f4)
13967 if (( $frag_lun != $lun )); then
13968 error "FIEMAP on 1-stripe file($fm_file) failed"
13971 (( tot_len += ext_len ))
13974 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
13975 error "FIEMAP on 1-stripe file($fm_file) failed"
13979 echo "FIEMAP on single striped file succeeded"
13981 run_test 130a "FIEMAP (1-stripe file)"
13984 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13986 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
13987 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
13988 [[ "$ost1_FSTYPE" != "zfs" ]] ||
13989 skip "LU-1941: FIEMAP unimplemented on ZFS"
13991 trap cleanup_130 EXIT RETURN
13993 local fm_file=$DIR/$tfile
13994 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13995 error "setstripe on $fm_file"
13997 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
13998 error "dd failed on $fm_file"
14000 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14001 filefrag_op=$(filefrag -ve -k $fm_file |
14002 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14004 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14005 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14011 for line in $filefrag_op; do
14012 local frag_lun=$(echo $line | cut -d: -f5 |
14013 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14014 local ext_len=$(echo $line | cut -d: -f4)
14015 if (( $frag_lun != $last_lun )); then
14016 if (( tot_len != 1024 )); then
14017 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14020 (( num_luns += 1 ))
14024 (( tot_len += ext_len ))
14027 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
14028 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14032 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
14034 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
14037 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14039 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14040 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14041 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14042 skip "LU-1941: FIEMAP unimplemented on ZFS"
14044 trap cleanup_130 EXIT RETURN
14046 local fm_file=$DIR/$tfile
14047 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
14049 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
14050 error "dd failed on $fm_file"
14052 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14053 filefrag_op=$(filefrag -ve -k $fm_file |
14054 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14056 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14057 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14062 for line in $filefrag_op; do
14063 local frag_lun=$(echo $line | cut -d: -f5 |
14064 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14065 local ext_len=$(echo $line | cut -d: -f4)
14066 if (( $frag_lun != $last_lun )); then
14067 local logical=$(echo $line | cut -d: -f2 | cut -d. -f1)
14068 if (( logical != 512 )); then
14069 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
14072 if (( tot_len != 512 )); then
14073 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14076 (( num_luns += 1 ))
14080 (( tot_len += ext_len ))
14083 if (( num_luns != 2 || tot_len != 512 )); then
14084 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14088 echo "FIEMAP on 2-stripe file with hole succeeded"
14090 run_test 130c "FIEMAP (2-stripe file with hole)"
14093 (( $OSTCOUNT >= 3 )) || skip "needs >= 3 OSTs"
14095 filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14096 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14097 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14098 skip "LU-1941: FIEMAP unimplemented on ZFS"
14100 trap cleanup_130 EXIT RETURN
14102 local fm_file=$DIR/$tfile
14103 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
14104 error "setstripe on $fm_file"
14106 local actual_stripe_count=$($LFS getstripe -c $fm_file)
14107 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
14108 error "dd failed on $fm_file"
14110 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14111 filefrag_op=$(filefrag -ve -k $fm_file |
14112 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14114 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14115 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14120 for line in $filefrag_op; do
14121 local frag_lun=$(echo $line | cut -d: -f5 |
14122 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14123 local ext_len=$(echo $line | cut -d: -f4)
14124 if (( $frag_lun != $last_lun )); then
14125 if (( tot_len != 1024 )); then
14126 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14129 (( num_luns += 1 ))
14133 (( tot_len += ext_len ))
14136 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
14137 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14141 echo "FIEMAP on N-stripe file succeeded"
14143 run_test 130d "FIEMAP (N-stripe file)"
14146 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14148 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14149 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14150 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14151 skip "LU-1941: FIEMAP unimplemented on ZFS"
14153 trap cleanup_130 EXIT RETURN
14155 local fm_file=$DIR/$tfile
14156 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
14159 local expected_len=$(( (num_blks / 2) * 64 ))
14160 for ((i = 0; i < $num_blks; i++)); do
14161 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
14162 conv=notrunc > /dev/null 2>&1
14165 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14166 filefrag_op=$(filefrag -ve -k $fm_file |
14167 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14169 local last_lun=$(echo $filefrag_op | cut -d: -f5)
14174 for line in $filefrag_op; do
14175 local frag_lun=$(echo $line | cut -d: -f5)
14176 local ext_len=$(echo $line | cut -d: -f4)
14177 if (( $frag_lun != $last_lun )); then
14178 if (( tot_len != $expected_len )); then
14179 error "OST$last_lun $tot_len != $expected_len"
14181 (( num_luns += 1 ))
14185 (( tot_len += ext_len ))
14188 if (( num_luns != 2 || tot_len != $expected_len )); then
14189 error "OST$last_lun $num_luns != 2, $tot_len != $expected_len"
14192 echo "FIEMAP with continuation calls succeeded"
14194 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
14197 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14198 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14199 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14200 skip "LU-1941: FIEMAP unimplemented on ZFS"
14202 local fm_file=$DIR/$tfile
14203 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
14204 error "multiop create with lov_delay_create on $fm_file"
14206 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14207 filefrag_extents=$(filefrag -vek $fm_file |
14208 awk '/extents? found/ { print $2 }')
14209 if (( $filefrag_extents != 0 )); then
14210 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
14215 run_test 130f "FIEMAP (unstriped file)"
14218 (( $MDS1_VERSION >= $(version_code 2.12.53) )) ||
14219 skip "Need MDS version with at least 2.12.53 for overstriping"
14220 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14221 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14222 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14223 skip "LU-1941: FIEMAP unimplemented on ZFS"
14225 local file=$DIR/$tfile
14226 local nr=$((OSTCOUNT * 100))
14228 $LFS setstripe -C $nr $file || error "failed to setstripe -C $nr $file"
14230 stack_trap "rm -f $file"
14231 dd if=/dev/zero of=$file count=$nr bs=1M
14233 nr=$($LFS getstripe -c $file)
14235 local extents=$(filefrag -v $file |
14236 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
14238 echo "filefrag list $extents extents in file with stripecount $nr"
14239 if (( extents < nr )); then
14240 $LFS getstripe $file
14242 error "filefrag printed $extents < $nr extents"
14245 run_test 130g "FIEMAP (overstripe file)"
14247 # Test for writev/readv
14249 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
14250 error "writev test failed"
14251 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
14252 error "readv failed"
14255 run_test 131a "test iov's crossing stripe boundary for writev/readv"
14258 local fsize=$((524288 + 1048576 + 1572864))
14259 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
14260 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14261 error "append writev test failed"
14263 ((fsize += 1572864 + 1048576))
14264 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
14265 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14266 error "append writev test failed"
14269 run_test 131b "test append writev"
14272 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
14275 run_test 131c "test read/write on file w/o objects"
14278 rwv -f $DIR/$tfile -w -n 1 1572864
14279 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
14280 if [ "$NOB" != 1572864 ]; then
14281 error "Short read filed: read $NOB bytes instead of 1572864"
14285 run_test 131d "test short read"
14288 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
14289 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
14290 error "read hitting hole failed"
14293 run_test 131e "test read hitting hole"
14301 # open 11 samples [usecs] 468 4793 13658 35791898
14303 mds*) res=($(do_facet $facet \
14304 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op"))
14306 ost*) res=($(do_facet $facet \
14307 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op"))
14309 *) error "Wrong facet '$facet'" ;;
14311 [[ -n "$res" ]] || error "counter for $op on $facet not incremented"
14312 # if $want is zero, it means any stat increment is ok.
14313 if (( $want > 0 )); then
14314 local count=${res[1]}
14316 if (( $count != $want )); then
14317 if [[ $facet =~ "mds" ]]; then
14318 do_nodes $(comma_list $(mdts_nodes)) \
14319 $LCTL get_param mdt.*.md_stats
14321 do_nodes $(comma_list $(osts-nodes)) \
14322 $LCTL get_param obdfilter.*.stats
14324 error "The $op counter on $facet is $count, not $want"
14330 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14331 remote_ost_nodsh && skip "remote OST with nodsh"
14332 remote_mds_nodsh && skip "remote MDS with nodsh"
14333 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14334 skip_env "MDS doesn't support rename stats"
14336 local testdir=$DIR/${tdir}/stats_testdir
14338 mkdir -p $DIR/${tdir}
14341 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14342 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14344 # verify mdt stats first.
14345 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
14346 check_stats $SINGLEMDS "mkdir" 1
14348 # clear "open" from "lfs mkdir" above
14349 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14350 touch ${testdir}/${tfile} || error "touch failed"
14351 check_stats $SINGLEMDS "open" 1
14352 check_stats $SINGLEMDS "close" 1
14353 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
14354 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
14355 check_stats $SINGLEMDS "mknod" 2
14357 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
14358 check_stats $SINGLEMDS "unlink" 1
14359 rm -f ${testdir}/${tfile} || error "file remove failed"
14360 check_stats $SINGLEMDS "unlink" 2
14362 # remove working dir and check mdt stats again.
14363 rmdir ${testdir} || error "rmdir failed"
14364 check_stats $SINGLEMDS "rmdir" 1
14366 local testdir1=$DIR/${tdir}/stats_testdir1
14367 mkdir -p ${testdir}
14368 mkdir -p ${testdir1}
14369 touch ${testdir1}/test1
14370 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
14371 check_stats $SINGLEMDS "crossdir_rename" 1
14373 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
14374 check_stats $SINGLEMDS "samedir_rename" 1
14376 rm -rf $DIR/${tdir}
14378 run_test 133a "Verifying MDT stats ========================================"
14383 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14384 remote_ost_nodsh && skip "remote OST with nodsh"
14385 remote_mds_nodsh && skip "remote MDS with nodsh"
14387 local testdir=$DIR/${tdir}/stats_testdir
14389 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
14390 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
14391 touch ${testdir}/${tfile} || error "touch failed"
14392 cancel_lru_locks mdc
14395 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14396 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14398 # extra mdt stats verification.
14399 chmod 444 ${testdir}/${tfile} || error "chmod failed"
14400 check_stats $SINGLEMDS "setattr" 1
14401 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14402 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
14404 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
14405 check_stats $SINGLEMDS "getattr" 1
14407 rm -rf $DIR/${tdir}
14409 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
14410 # so the check below is not reliable
14411 [ $MDSCOUNT -eq 1 ] || return 0
14413 # Sleep to avoid a cached response.
14414 #define OBD_STATFS_CACHE_SECONDS 1
14416 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14417 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14418 $LFS df || error "lfs failed"
14419 check_stats $SINGLEMDS "statfs" 1
14421 # check aggregated statfs (LU-10018)
14422 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
14424 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
14427 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14428 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14430 check_stats $SINGLEMDS "statfs" 1
14432 # We want to check that the client didn't send OST_STATFS to
14433 # ost1 but the MDT also uses OST_STATFS for precreate. So some
14434 # extra care is needed here.
14435 if remote_mds; then
14436 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
14437 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
14439 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
14440 [ "$res" ] && error "OST got STATFS"
14445 run_test 133b "Verifying extra MDT stats =================================="
14448 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14449 remote_ost_nodsh && skip "remote OST with nodsh"
14450 remote_mds_nodsh && skip "remote MDS with nodsh"
14452 local testdir=$DIR/$tdir/stats_testdir
14454 test_mkdir -p $testdir
14456 # verify obdfilter stats.
14457 $LFS setstripe -c 1 -i 0 $testdir/$tfile
14459 cancel_lru_locks osc
14460 wait_delete_completed
14463 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14464 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14466 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
14469 cancel_lru_locks osc
14470 check_stats ost1 "write" 1
14472 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
14473 check_stats ost1 "read" 1
14475 > $testdir/$tfile || error "truncate failed"
14476 check_stats ost1 "punch" 1
14478 rm -f $testdir/$tfile || error "file remove failed"
14479 wait_delete_completed
14480 check_stats ost1 "destroy" 1
14484 run_test 133c "Verifying OST stats ========================================"
14491 while [ $value -ge 2 ]; do
14496 if [ $orig -gt $order ]; then
14504 local size=('K' 'M' 'G' 'T');
14506 local size_string=$value
14508 while [ $value -ge 1024 ]; do
14509 if [ $i -gt 3 ]; then
14510 #T is the biggest unit we get here, if that is bigger,
14512 size_string=${value}T
14515 value=$((value >> 10))
14516 if [ $value -lt 1024 ]; then
14517 size_string=${value}${size[$i]}
14526 get_rename_size() {
14528 local context=${2:-.}
14529 local sample=$(do_facet $SINGLEMDS $LCTL \
14530 get_param mdt.$FSNAME-MDT0000.rename_stats |
14531 grep -A1 $context |
14532 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
14537 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14538 remote_ost_nodsh && skip "remote OST with nodsh"
14539 remote_mds_nodsh && skip "remote MDS with nodsh"
14540 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14541 skip_env "MDS doesn't support rename stats"
14543 local testdir1=$DIR/${tdir}/stats_testdir1
14544 local testdir2=$DIR/${tdir}/stats_testdir2
14545 mkdir -p $DIR/${tdir} || error "mkdir $tdir failed"
14547 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14549 mkdir_on_mdt0 ${testdir1} || error "mkdir $testdir1 failed"
14550 mkdir_on_mdt0 ${testdir2} || error "mkdir $testdir2 failed"
14552 createmany -o $testdir1/test 512 || error "createmany failed"
14554 # check samedir rename size
14555 mv ${testdir1}/test0 ${testdir1}/test_0
14557 local testdir1_size=$(ls -l $DIR/${tdir} |
14558 awk '/stats_testdir1/ {print $5}')
14559 local testdir2_size=$(ls -l $DIR/${tdir} |
14560 awk '/stats_testdir2/ {print $5}')
14562 testdir1_size=$(order_2 $testdir1_size)
14563 testdir2_size=$(order_2 $testdir2_size)
14565 testdir1_size=$(size_in_KMGT $testdir1_size)
14566 testdir2_size=$(size_in_KMGT $testdir2_size)
14568 echo "source rename dir size: ${testdir1_size}"
14569 echo "target rename dir size: ${testdir2_size}"
14571 local cmd="do_facet $SINGLEMDS $LCTL "
14572 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
14574 eval $cmd || error "$cmd failed"
14575 local samedir=$($cmd | grep 'same_dir')
14576 local same_sample=$(get_rename_size $testdir1_size)
14577 [ -z "$samedir" ] && error "samedir_rename_size count error"
14578 [[ $same_sample -eq 1 ]] ||
14579 error "samedir_rename_size error $same_sample"
14580 echo "Check same dir rename stats success"
14582 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14584 # check crossdir rename size
14585 mv ${testdir1}/test_0 ${testdir2}/test_0
14587 testdir1_size=$(ls -l $DIR/${tdir} |
14588 awk '/stats_testdir1/ {print $5}')
14589 testdir2_size=$(ls -l $DIR/${tdir} |
14590 awk '/stats_testdir2/ {print $5}')
14592 testdir1_size=$(order_2 $testdir1_size)
14593 testdir2_size=$(order_2 $testdir2_size)
14595 testdir1_size=$(size_in_KMGT $testdir1_size)
14596 testdir2_size=$(size_in_KMGT $testdir2_size)
14598 echo "source rename dir size: ${testdir1_size}"
14599 echo "target rename dir size: ${testdir2_size}"
14601 eval $cmd || error "$cmd failed"
14602 local crossdir=$($cmd | grep 'crossdir')
14603 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
14604 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
14605 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
14606 [[ $src_sample -eq 1 ]] ||
14607 error "crossdir_rename_size error $src_sample"
14608 [[ $tgt_sample -eq 1 ]] ||
14609 error "crossdir_rename_size error $tgt_sample"
14610 echo "Check cross dir rename stats success"
14611 rm -rf $DIR/${tdir}
14613 run_test 133d "Verifying rename_stats ========================================"
14616 remote_mds_nodsh && skip "remote MDS with nodsh"
14617 remote_ost_nodsh && skip "remote OST with nodsh"
14618 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14620 local testdir=$DIR/${tdir}/stats_testdir
14621 local ctr f0 f1 bs=32768 count=42 sum
14623 mkdir -p ${testdir} || error "mkdir failed"
14625 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
14627 for ctr in {write,read}_bytes; do
14629 cancel_lru_locks osc
14631 do_facet ost1 $LCTL set_param -n \
14632 "obdfilter.*.exports.clear=clear"
14634 if [ $ctr = write_bytes ]; then
14636 f1=${testdir}/${tfile}
14638 f0=${testdir}/${tfile}
14642 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
14645 cancel_lru_locks osc
14647 sum=$(do_facet ost1 $LCTL get_param \
14648 "obdfilter.*.exports.*.stats" |
14649 awk -v ctr=$ctr 'BEGIN { sum = 0 }
14650 $1 == ctr { sum += $7 }
14651 END { printf("%0.0f", sum) }')
14653 if ((sum != bs * count)); then
14654 error "Bad $ctr sum, expected $((bs * count)), got $sum"
14658 rm -rf $DIR/${tdir}
14660 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
14663 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
14664 skip "too old lustre for get_param -R ($facet_ver)"
14666 # verifying readability.
14667 $LCTL get_param -R '*' &> /dev/null
14669 # Verifing writability with badarea_io.
14670 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14671 local skipped_params='force_lbug|changelog_mask|daemon_file'
14672 $LCTL list_param -FR '*' | grep '=' | tr -d = |
14673 egrep -v "$skipped_params" |
14674 xargs -n 1 find $proc_dirs -name |
14675 xargs -n 1 badarea_io ||
14676 error "client badarea_io failed"
14678 # remount the FS in case writes/reads /proc break the FS
14679 cleanup || error "failed to unmount"
14680 setup || error "failed to setup"
14682 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
14685 remote_mds_nodsh && skip "remote MDS with nodsh"
14686 remote_ost_nodsh && skip "remote OST with nodsh"
14688 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14689 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
14691 for facet in mds1 ost1; do
14692 local facet_ver=$(lustre_version_code $facet)
14693 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
14694 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
14696 log "$facet: too old lustre for get_param -R"
14698 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
14699 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
14700 tr -d = | egrep -v $skipped_params |
14701 xargs -n 1 find $proc_dirs -name |
14702 xargs -n 1 badarea_io" ||
14703 error "$facet badarea_io failed"
14705 skip_noexit "$facet: too old lustre for get_param -R"
14709 # remount the FS in case writes/reads /proc break the FS
14710 cleanup || error "failed to unmount"
14711 setup || error "failed to setup"
14713 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
14716 remote_mds_nodsh && skip "remote MDS with nodsh"
14717 remote_ost_nodsh && skip "remote OST with nodsh"
14718 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
14719 skip "Need MDS version at least 2.9.54"
14722 for facet in client mds1 ost1; do
14723 # Get the list of files that are missing the terminating newline
14724 local plist=$(do_facet $facet
14725 $LCTL list_param -FR '*' | grep '=' | tr -d =)
14727 for ent in $plist; do
14728 local missing=$(do_facet $facet $LCTL get_param $ent \|\
14729 awk -v FS='\v' -v RS='\v\v' \
14730 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
14731 print FILENAME}'" 2>/dev/null)
14732 [ -z $missing ] || {
14733 do_facet $facet $LCTL get_param $ent | od -An -tx1
14734 error "file does not end with newline: $facet-$ent"
14739 run_test 133h "Proc files should end with newlines"
14742 remote_mds_nodsh && skip "remote MDS with nodsh"
14743 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14744 skip "Need MDS version at least 2.7.54"
14746 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14747 cancel_lru_locks mdc
14749 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14750 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14751 [ $unused -eq 0 ] || error "$unused locks are not cleared"
14754 createmany -o $DIR/$tdir/f $nr ||
14755 error "failed to create $nr files in $DIR/$tdir"
14756 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14758 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
14759 do_facet mds1 $LCTL set_param fail_loc=0x327
14760 do_facet mds1 $LCTL set_param fail_val=500
14763 echo "sleep 10 seconds ..."
14765 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
14767 do_facet mds1 $LCTL set_param fail_loc=0
14768 do_facet mds1 $LCTL set_param fail_val=0
14769 [ $lck_cnt -lt $unused ] ||
14770 error "No locks reclaimed, before:$unused, after:$lck_cnt"
14773 unlinkmany $DIR/$tdir/f $nr
14775 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
14778 remote_mds_nodsh && skip "remote MDS with nodsh"
14779 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14780 skip "Need MDS version at least 2.7.54"
14782 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14783 cancel_lru_locks mdc
14785 local low_wm=$(do_facet mds1 $LCTL get_param -n \
14786 ldlm.lock_reclaim_threshold_mb)
14787 # disable reclaim temporarily
14788 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
14790 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
14791 do_facet mds1 $LCTL set_param fail_loc=0x328
14792 do_facet mds1 $LCTL set_param fail_val=500
14794 $LCTL set_param debug=+trace
14797 createmany -o $DIR/$tdir/f $nr &
14798 local create_pid=$!
14800 echo "Sleep $TIMEOUT seconds ..."
14802 if ! ps -p $create_pid > /dev/null 2>&1; then
14803 do_facet mds1 $LCTL set_param fail_loc=0
14804 do_facet mds1 $LCTL set_param fail_val=0
14805 do_facet mds1 $LCTL set_param \
14806 ldlm.lock_reclaim_threshold_mb=${low_wm}m
14807 error "createmany finished incorrectly!"
14809 do_facet mds1 $LCTL set_param fail_loc=0
14810 do_facet mds1 $LCTL set_param fail_val=0
14811 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
14812 wait $create_pid || return 1
14814 unlinkmany $DIR/$tdir/f $nr
14816 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
14819 remote_mds_nodsh && skip "remote MDS with nodsh"
14820 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14821 skip "Need MDS version at least 2.13.50"
14824 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14826 #define OBD_FAIL_PLAIN_RECORDS 0x1319
14827 #set only one record at plain llog
14828 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
14830 #fill already existed plain llog each 64767
14831 #wrapping whole catalog
14832 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14834 createmany -o $DIR/$tdir/$tfile_ 64700
14835 for (( i = 0; i < 64700; i = i + 2 ))
14837 rm $DIR/$tdir/$tfile_$i &
14838 rm $DIR/$tdir/$tfile_$((i + 1)) &
14843 #waiting osp synchronization
14844 wait_delete_completed
14846 run_test 135 "Race catalog processing"
14849 remote_mds_nodsh && skip "remote MDS with nodsh"
14850 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14851 skip "Need MDS version at least 2.13.50"
14854 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14855 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
14856 #set only one record at plain llog
14857 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
14858 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
14860 #fill already existed 2 plain llogs each 64767
14861 #wrapping whole catalog
14862 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14863 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
14864 wait_delete_completed
14866 createmany -o $DIR/$tdir/$tfile_ 10
14869 do_facet $SINGLEMDS $LCTL set_param fail_val=3
14870 for (( i = 0; i < 10; i = i + 3 ))
14872 rm $DIR/$tdir/$tfile_$i &
14873 rm $DIR/$tdir/$tfile_$((i + 1)) &
14877 rm $DIR/$tdir/$tfile_$((i + 2)) &
14880 #waiting osp synchronization
14881 wait_delete_completed
14883 run_test 136 "Race catalog processing 2"
14885 test_140() { #bug-17379
14886 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14888 test_mkdir $DIR/$tdir
14889 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
14890 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
14892 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
14893 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
14895 while i=$((i + 1)); do
14897 cd $i || error "Changing to $i"
14898 ln -s ../stat stat || error "Creating stat symlink"
14899 # Read the symlink until ELOOP present,
14900 # not LBUGing the system is considered success,
14901 # we didn't overrun the stack.
14902 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
14903 if [ $ret -ne 0 ]; then
14904 if [ $ret -eq 40 ]; then
14907 error "Open stat symlink"
14913 echo "The symlink depth = $i"
14914 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
14915 error "Invalid symlink depth"
14917 # Test recursive symlink
14918 ln -s symlink_self symlink_self
14919 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
14920 echo "open symlink_self returns $ret"
14921 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
14923 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
14926 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14928 local TF="$TMP/$tfile"
14930 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14931 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
14933 cancel_lru_locks $OSC
14934 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
14935 remount_client $MOUNT
14937 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
14940 $TRUNCATE $DIR/$tfile 6000
14941 cancel_lru_locks $OSC
14942 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
14945 echo "12345" >>$DIR/$tfile
14946 cancel_lru_locks $OSC
14947 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
14950 echo "12345" >>$DIR/$tfile
14951 cancel_lru_locks $OSC
14952 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
14954 run_test 150a "truncate/append tests"
14957 check_set_fallocate_or_skip
14960 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14961 check_fallocate $DIR/$tfile || skip_eopnotsupp "fallocate failed"
14963 run_test 150b "Verify fallocate (prealloc) functionality"
14966 check_set_fallocate_or_skip
14969 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14970 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
14972 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14973 # precomputed md5sum for 20MB of zeroes
14974 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
14975 local sum=($(md5sum $DIR/$tfile))
14977 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
14979 check_set_fallocate 1
14982 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14983 sum=($(md5sum $DIR/$tfile))
14985 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
14987 run_test 150bb "Verify fallocate modes both zero space"
14990 check_set_fallocate_or_skip
14991 local striping="-c2"
14993 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14994 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
14995 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
14996 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14997 local want=$((OSTCOUNT * 1048576))
14999 # Must allocate all requested space, not more than 5% extra
15000 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15001 error "bytes $bytes is not $want"
15005 echo "verify fallocate on PFL file"
15007 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
15009 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
15010 error "Create $DIR/$tfile failed"
15011 fallocate -l $((1048576 * 512)) $DIR/$tfile || error "fallocate failed"
15012 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
15013 want=$((512 * 1048576))
15015 # Must allocate all requested space, not more than 5% extra
15016 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15017 error "bytes $bytes is not $want"
15019 run_test 150c "Verify fallocate Size and Blocks"
15022 check_set_fallocate_or_skip
15023 local striping="-c2"
15025 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
15027 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15028 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
15029 error "setstripe failed"
15030 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
15031 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
15032 local want=$((OSTCOUNT * 1048576))
15034 # Must allocate all requested space, not more than 5% extra
15035 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15036 error "bytes $bytes is not $want"
15038 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
15041 check_set_fallocate_or_skip
15045 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15046 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15047 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15049 # Find OST with Minimum Size
15050 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15051 sort -un | head -1)
15053 # Get 100MB per OST of the available space to reduce run time
15054 # else 60% of the available space if we are running SLOW tests
15055 if [ $SLOW == "no" ]; then
15056 local space=$((1024 * 100 * OSTCOUNT))
15058 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
15061 fallocate -l${space}k $DIR/$tfile ||
15062 error "fallocate ${space}k $DIR/$tfile failed"
15063 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
15065 # get size immediately after fallocate. This should be correctly
15067 local size=$(stat -c '%s' $DIR/$tfile)
15068 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
15070 # Sleep for a while for statfs to get updated. And not pull from cache.
15073 echo "df after fallocate:"
15076 (( size / 1024 == space )) || error "size $size != requested $space"
15077 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
15078 error "used $used < space $space"
15080 rm $DIR/$tfile || error "rm failed"
15082 wait_delete_completed
15084 echo "df after unlink:"
15087 run_test 150e "Verify 60% of available OST space consumed by fallocate"
15092 local want_size_before=20480 # in bytes
15093 local want_blocks_before=40 # 512 sized blocks
15094 local want_blocks_after=24 # 512 sized blocks
15095 local length=$(((want_blocks_before - want_blocks_after) * 512))
15097 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
15098 skip "need at least 2.14.0 for fallocate punch"
15100 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
15101 skip "LU-14160: punch mode is not implemented on OSD ZFS"
15104 check_set_fallocate_or_skip
15105 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15107 [[ "x$DOM" == "xyes" ]] &&
15108 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
15110 echo "Verify fallocate punch: Range within the file range"
15111 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
15112 error "dd failed for bs 4096 and count 5"
15114 # Call fallocate with punch range which is within the file range
15115 out=$(fallocate -p --offset 4096 -l $length $DIR/$tfile 2>&1) ||
15116 skip_eopnotsupp "$out|fallocate: offset 4096 and length $length"
15117 # client must see changes immediately after fallocate
15118 size=$(stat -c '%s' $DIR/$tfile)
15119 blocks=$(stat -c '%b' $DIR/$tfile)
15121 # Verify punch worked.
15122 (( blocks == want_blocks_after )) ||
15123 error "punch failed: blocks $blocks != $want_blocks_after"
15125 (( size == want_size_before )) ||
15126 error "punch failed: size $size != $want_size_before"
15128 # Verify there is hole in file
15129 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
15130 # precomputed md5sum
15131 local expect="4a9a834a2db02452929c0a348273b4aa"
15133 cksum=($(md5sum $DIR/$tfile))
15134 [[ "${cksum[0]}" == "$expect" ]] ||
15135 error "unexpected MD5SUM after punch: ${cksum[0]}"
15137 # Start second sub-case for fallocate punch.
15138 echo "Verify fallocate punch: Range overlapping and less than blocksize"
15139 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
15140 error "dd failed for bs 4096 and count 5"
15142 # Punch range less than block size will have no change in block count
15143 want_blocks_after=40 # 512 sized blocks
15145 # Punch overlaps two blocks and less than blocksize
15146 out=$(fallocate -p --offset 4000 -l 3000 $DIR/$tfile 2>&1) ||
15147 skip_eopnotsupp "$out|fallocate: offset 4000 length 3000"
15148 size=$(stat -c '%s' $DIR/$tfile)
15149 blocks=$(stat -c '%b' $DIR/$tfile)
15151 # Verify punch worked.
15152 (( blocks == want_blocks_after )) ||
15153 error "punch failed: blocks $blocks != $want_blocks_after"
15155 (( size == want_size_before )) ||
15156 error "punch failed: size $size != $want_size_before"
15158 # Verify if range is really zero'ed out. We expect Zeros.
15159 # precomputed md5sum
15160 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
15161 cksum=($(md5sum $DIR/$tfile))
15162 [[ "${cksum[0]}" == "$expect" ]] ||
15163 error "unexpected MD5SUM after punch: ${cksum[0]}"
15165 run_test 150f "Verify fallocate punch functionality"
15173 local BS=4096 # Block size in bytes
15175 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
15176 skip "need at least 2.14.0 for fallocate punch"
15178 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
15179 skip "LU-14160: punch mode is not implemented on OSD ZFS"
15182 check_set_fallocate_or_skip
15183 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15185 if [[ "x$DOM" == "xyes" ]]; then
15186 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
15187 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
15189 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15190 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15193 # Get 100MB per OST of the available space to reduce run time
15194 # else 60% of the available space if we are running SLOW tests
15195 if [ $SLOW == "no" ]; then
15196 space=$((1024 * 100 * OSTCOUNT))
15198 # Find OST with Minimum Size
15199 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15200 sort -un | head -1)
15201 echo "min size OST: $space"
15202 space=$(((space * 60)/100 * OSTCOUNT))
15204 # space in 1k units, round to 4k blocks
15205 local blkcount=$((space * 1024 / $BS))
15207 echo "Verify fallocate punch: Very large Range"
15208 fallocate -l${space}k $DIR/$tfile ||
15209 error "fallocate ${space}k $DIR/$tfile failed"
15210 # write 1M at the end, start and in the middle
15211 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
15212 error "dd failed: bs $BS count 256"
15213 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
15214 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
15215 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
15216 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
15219 size=$(stat -c '%s' $DIR/$tfile)
15221 # gather punch length.
15222 local punch_size=$((size - (BS * 2)))
15224 echo "punch_size = $punch_size"
15225 echo "size - punch_size: $((size - punch_size))"
15226 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
15228 # Call fallocate to punch all except 2 blocks. We leave the
15229 # first and the last block
15230 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
15231 out=$(fallocate -p --offset $BS -l $punch_size $DIR/$tfile 2>&1) ||
15232 skip_eopnotsupp "$out|fallocate: offset $BS length $punch_size"
15234 size_after=$(stat -c '%s' $DIR/$tfile)
15235 blocks_after=$(stat -c '%b' $DIR/$tfile)
15237 # Verify punch worked.
15238 # Size should be kept
15239 (( size == size_after )) ||
15240 error "punch failed: size $size != $size_after"
15242 # two 4k data blocks to remain plus possible 1 extra extent block
15243 (( blocks_after <= ((BS / 512) * 3) )) ||
15244 error "too many blocks remains: $blocks_after"
15246 # Verify that file has hole between the first and the last blocks
15247 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
15248 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
15250 echo "Hole at [$hole_start, $hole_end)"
15251 (( hole_start == BS )) ||
15252 error "no hole at offset $BS after punch"
15254 (( hole_end == BS + punch_size )) ||
15255 error "data at offset $hole_end < $((BS + punch_size))"
15257 run_test 150g "Verify fallocate punch on large range"
15259 #LU-2902 roc_hit was not able to read all values from lproc
15260 function roc_hit_init() {
15261 local list=$(comma_list $(osts_nodes))
15262 local dir=$DIR/$tdir-check
15263 local file=$dir/$tfile
15269 #use setstripe to do a write to every ost
15270 for i in $(seq 0 $((OSTCOUNT-1))); do
15271 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
15272 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
15273 idx=$(printf %04x $i)
15274 BEFORE=$(get_osd_param $list *OST*$idx stats |
15275 awk '$1 == "cache_access" {sum += $7}
15276 END { printf("%0.0f", sum) }')
15278 cancel_lru_locks osc
15279 cat $file >/dev/null
15281 AFTER=$(get_osd_param $list *OST*$idx stats |
15282 awk '$1 == "cache_access" {sum += $7}
15283 END { printf("%0.0f", sum) }')
15285 echo BEFORE:$BEFORE AFTER:$AFTER
15286 if ! let "AFTER - BEFORE == 4"; then
15288 error "roc_hit is not safe to use"
15296 function roc_hit() {
15297 local list=$(comma_list $(osts_nodes))
15298 echo $(get_osd_param $list '' stats |
15299 awk '$1 == "cache_hit" {sum += $7}
15300 END { printf("%0.0f", sum) }')
15303 function set_cache() {
15306 if [ "$2" == "off" ]; then
15309 local list=$(comma_list $(osts_nodes))
15310 set_osd_param $list '' $1_cache_enable $on
15312 cancel_lru_locks osc
15316 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15317 remote_ost_nodsh && skip "remote OST with nodsh"
15320 local list=$(comma_list $(osts_nodes))
15322 # check whether obdfilter is cache capable at all
15323 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
15324 skip "not cache-capable obdfilter"
15327 # check cache is enabled on all obdfilters
15328 if get_osd_param $list '' read_cache_enable | grep 0; then
15329 skip "oss cache is disabled"
15332 set_osd_param $list '' writethrough_cache_enable 1
15334 # check write cache is enabled on all obdfilters
15335 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
15336 skip "oss write cache is NOT enabled"
15341 #define OBD_FAIL_OBD_NO_LRU 0x609
15342 do_nodes $list $LCTL set_param fail_loc=0x609
15344 # pages should be in the case right after write
15345 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
15348 local BEFORE=$(roc_hit)
15349 cancel_lru_locks osc
15350 cat $DIR/$tfile >/dev/null
15351 local AFTER=$(roc_hit)
15353 do_nodes $list $LCTL set_param fail_loc=0
15355 if ! let "AFTER - BEFORE == CPAGES"; then
15356 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
15359 cancel_lru_locks osc
15360 # invalidates OST cache
15361 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
15362 set_osd_param $list '' read_cache_enable 0
15363 cat $DIR/$tfile >/dev/null
15365 # now data shouldn't be found in the cache
15367 cancel_lru_locks osc
15368 cat $DIR/$tfile >/dev/null
15370 if let "AFTER - BEFORE != 0"; then
15371 error "IN CACHE: before: $BEFORE, after: $AFTER"
15374 set_osd_param $list '' read_cache_enable 1
15377 run_test 151 "test cache on oss and controls ==============================="
15380 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15382 local TF="$TMP/$tfile"
15384 # simulate ENOMEM during write
15385 #define OBD_FAIL_OST_NOMEM 0x226
15386 lctl set_param fail_loc=0x80000226
15387 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
15389 sync || error "sync failed"
15390 lctl set_param fail_loc=0
15392 # discard client's cache
15393 cancel_lru_locks osc
15395 # simulate ENOMEM during read
15396 lctl set_param fail_loc=0x80000226
15397 cmp $TF $DIR/$tfile || error "cmp failed"
15398 lctl set_param fail_loc=0
15402 run_test 152 "test read/write with enomem ============================"
15405 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
15407 run_test 153 "test if fdatasync does not crash ======================="
15409 dot_lustre_fid_permission_check() {
15411 local ffid=$MOUNT/.lustre/fid/$fid
15414 echo "stat fid $fid"
15415 stat $ffid || error "stat $ffid failed."
15416 echo "touch fid $fid"
15417 touch $ffid || error "touch $ffid failed."
15418 echo "write to fid $fid"
15419 cat /etc/hosts > $ffid || error "write $ffid failed."
15420 echo "read fid $fid"
15421 diff /etc/hosts $ffid || error "read $ffid failed."
15422 echo "append write to fid $fid"
15423 cat /etc/hosts >> $ffid || error "append write $ffid failed."
15424 echo "rename fid $fid"
15425 mv $ffid $test_dir/$tfile.1 &&
15426 error "rename $ffid to $tfile.1 should fail."
15427 touch $test_dir/$tfile.1
15428 mv $test_dir/$tfile.1 $ffid &&
15429 error "rename $tfile.1 to $ffid should fail."
15430 rm -f $test_dir/$tfile.1
15431 echo "truncate fid $fid"
15432 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
15433 echo "link fid $fid"
15434 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
15435 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
15436 echo "setfacl fid $fid"
15437 setfacl -R -m u:$USER0:rwx $ffid ||
15438 error "setfacl $ffid failed"
15439 echo "getfacl fid $fid"
15440 getfacl $ffid || error "getfacl $ffid failed."
15442 echo "unlink fid $fid"
15443 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
15444 echo "mknod fid $fid"
15445 mknod $ffid c 1 3 && error "mknod $ffid should fail."
15447 fid=[0xf00000400:0x1:0x0]
15448 ffid=$MOUNT/.lustre/fid/$fid
15450 echo "stat non-exist fid $fid"
15451 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
15452 echo "write to non-exist fid $fid"
15453 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
15454 echo "link new fid $fid"
15455 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
15457 mkdir -p $test_dir/$tdir
15458 touch $test_dir/$tdir/$tfile
15459 fid=$($LFS path2fid $test_dir/$tdir)
15462 error "error: could not get fid for $test_dir/$dir/$tfile."
15464 ffid=$MOUNT/.lustre/fid/$fid
15467 ls $ffid || error "ls $ffid failed."
15468 echo "touch $fid/$tfile.1"
15469 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
15471 echo "touch $MOUNT/.lustre/fid/$tfile"
15472 touch $MOUNT/.lustre/fid/$tfile && \
15473 error "touch $MOUNT/.lustre/fid/$tfile should fail."
15475 echo "setxattr to $MOUNT/.lustre/fid"
15476 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
15478 echo "listxattr for $MOUNT/.lustre/fid"
15479 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
15481 echo "delxattr from $MOUNT/.lustre/fid"
15482 setfattr -x trusted.name1 $MOUNT/.lustre/fid
15484 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
15485 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
15486 error "touch invalid fid should fail."
15488 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
15489 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
15490 error "touch non-normal fid should fail."
15492 echo "rename $tdir to $MOUNT/.lustre/fid"
15493 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
15494 error "rename to $MOUNT/.lustre/fid should fail."
15496 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
15498 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
15499 local new_obf_mode=777
15501 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
15502 chmod $new_obf_mode $DIR/.lustre/fid ||
15503 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
15505 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
15506 [ $obf_mode -eq $new_obf_mode ] ||
15507 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
15509 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
15510 chmod $old_obf_mode $DIR/.lustre/fid ||
15511 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
15514 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
15515 fid=$($LFS path2fid $test_dir/$tfile-2)
15517 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
15519 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
15520 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
15521 error "create lov data thru .lustre failed"
15523 echo "cp /etc/passwd $test_dir/$tfile-2"
15524 cp /etc/passwd $test_dir/$tfile-2 ||
15525 error "copy to $test_dir/$tfile-2 failed."
15526 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
15527 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
15528 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
15530 rm -rf $test_dir/tfile.lnk
15531 rm -rf $test_dir/$tfile-2
15535 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15536 skip "Need MDS version at least 2.4.1"
15538 local tf=$DIR/$tfile
15541 local fid=$($LFS path2fid $tf)
15542 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
15544 # check that we get the same pathname back
15547 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
15548 echo "$rootpath $fid"
15549 found=$($LFS fid2path $rootpath "$fid")
15550 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
15551 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
15554 # check wrong root path format
15555 rootpath=$MOUNT"_wrong"
15556 found=$($LFS fid2path $rootpath "$fid")
15557 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
15559 run_test 154A "lfs path2fid and fid2path basic checks"
15562 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15563 skip "Need MDS version at least 2.4.1"
15565 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
15566 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
15567 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
15568 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
15570 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
15571 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
15573 # check that we get the same pathname
15574 echo "PFID: $PFID, name: $name"
15575 local FOUND=$($LFS fid2path $MOUNT "$PFID")
15576 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
15577 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
15578 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
15580 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
15582 run_test 154B "verify the ll_decode_linkea tool"
15585 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15586 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15587 (( $MDS1_VERSION >= $(version_code 2.2.51) )) ||
15588 skip "Need MDS version at least 2.2.51"
15589 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
15591 cp /etc/hosts $DIR/$tfile
15593 fid=$($LFS path2fid $DIR/$tfile)
15595 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
15597 dot_lustre_fid_permission_check "$fid" $DIR ||
15598 error "dot lustre permission check $fid failed"
15600 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
15602 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
15604 touch $MOUNT/.lustre/file &&
15605 error "creation is not allowed under .lustre"
15607 mkdir $MOUNT/.lustre/dir &&
15608 error "mkdir is not allowed under .lustre"
15612 run_test 154a "Open-by-FID"
15615 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15616 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15617 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15618 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
15619 skip "Need MDS version at least 2.2.51"
15621 local remote_dir=$DIR/$tdir/remote_dir
15625 mkdir -p $DIR/$tdir
15626 $LFS mkdir -i $MDTIDX $remote_dir ||
15627 error "create remote directory failed"
15629 cp /etc/hosts $remote_dir/$tfile
15631 fid=$($LFS path2fid $remote_dir/$tfile)
15633 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
15635 dot_lustre_fid_permission_check "$fid" $remote_dir ||
15636 error "dot lustre permission check $fid failed"
15639 run_test 154b "Open-by-FID for remote directory"
15642 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15643 skip "Need MDS version at least 2.4.1"
15645 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
15646 local FID1=$($LFS path2fid $DIR/$tfile.1)
15647 local FID2=$($LFS path2fid $DIR/$tfile.2)
15648 local FID3=$($LFS path2fid $DIR/$tfile.3)
15651 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
15652 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
15653 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
15655 [ "$FID" = "${!want}" ] ||
15656 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
15660 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
15662 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
15663 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
15667 run_test 154c "lfs path2fid and fid2path multiple arguments"
15670 remote_mds_nodsh && skip "remote MDS with nodsh"
15671 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
15672 skip "Need MDS version at least 2.5.53"
15674 if remote_mds; then
15675 nid=$($LCTL list_nids | sed "s/\./\\\./g")
15679 local proc_ofile="mdt.*.exports.'$nid'.open_files"
15686 local fid=$($LFS path2fid $DIR/$tfile)
15689 cmd="exec $fd<$DIR/$tfile"
15691 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
15692 echo "$fid_list" | grep "$fid"
15695 cmd="exec $fd>/dev/null"
15697 if [ $rc -ne 0 ]; then
15698 error "FID $fid not found in open files list $fid_list"
15701 run_test 154d "Verify open file fid"
15705 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
15706 skip "Need MDS version at least 2.6.50"
15708 if ls -a $MOUNT | grep -q '^\.lustre$'; then
15709 error ".lustre returned by readdir"
15712 run_test 154e ".lustre is not returned by readdir"
15715 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15717 # create parent directory on a single MDT to avoid cross-MDT hardlinks
15718 mkdir_on_mdt0 $DIR/$tdir
15719 # test dirs inherit from its stripe
15720 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
15721 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
15722 cp /etc/hosts $DIR/$tdir/foo1/$tfile
15723 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
15726 # get fid of parents
15727 local FID0=$($LFS path2fid $DIR/$tdir)
15728 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
15729 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
15730 local FID3=$($LFS path2fid $DIR)
15732 # check that path2fid --parents returns expected <parent_fid>/name
15733 # 1) test for a directory (single parent)
15734 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
15735 [ "$parent" == "$FID0/foo1" ] ||
15736 error "expected parent: $FID0/foo1, got: $parent"
15738 # 2) test for a file with nlink > 1 (multiple parents)
15739 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
15740 echo "$parent" | grep -F "$FID1/$tfile" ||
15741 error "$FID1/$tfile not returned in parent list"
15742 echo "$parent" | grep -F "$FID2/link" ||
15743 error "$FID2/link not returned in parent list"
15745 # 3) get parent by fid
15746 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
15747 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15748 echo "$parent" | grep -F "$FID1/$tfile" ||
15749 error "$FID1/$tfile not returned in parent list (by fid)"
15750 echo "$parent" | grep -F "$FID2/link" ||
15751 error "$FID2/link not returned in parent list (by fid)"
15753 # 4) test for entry in root directory
15754 parent=$($LFS path2fid --parents $DIR/f)
15755 echo "$parent" | grep -F "$FID3/f" ||
15756 error "$FID3/f not returned in parent list"
15758 # 5) test it on root directory
15759 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
15760 error "$MOUNT should not have parents"
15762 # enable xattr caching and check that linkea is correctly updated
15763 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
15764 save_lustre_params client "llite.*.xattr_cache" > $save
15765 lctl set_param llite.*.xattr_cache 1
15767 # 6.1) linkea update on rename
15768 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
15770 # get parents by fid
15771 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15772 # foo1 should no longer be returned in parent list
15773 echo "$parent" | grep -F "$FID1" &&
15774 error "$FID1 should no longer be in parent list"
15775 # the new path should appear
15776 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
15777 error "$FID2/$tfile.moved is not in parent list"
15779 # 6.2) linkea update on unlink
15780 rm -f $DIR/$tdir/foo2/link
15781 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15782 # foo2/link should no longer be returned in parent list
15783 echo "$parent" | grep -F "$FID2/link" &&
15784 error "$FID2/link should no longer be in parent list"
15788 restore_lustre_params < $save
15791 run_test 154f "get parent fids by reading link ea"
15795 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15796 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
15797 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
15798 skip "Need MDS version at least 2.6.92"
15800 mkdir_on_mdt0 $DIR/$tdir
15801 llapi_fid_test -d $DIR/$tdir
15803 run_test 154g "various llapi FID tests"
15805 test_155_small_load() {
15806 local temp=$TMP/$tfile
15807 local file=$DIR/$tfile
15809 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
15810 error "dd of=$temp bs=6096 count=1 failed"
15812 cancel_lru_locks $OSC
15813 cmp $temp $file || error "$temp $file differ"
15815 $TRUNCATE $temp 6000
15816 $TRUNCATE $file 6000
15817 cmp $temp $file || error "$temp $file differ (truncate1)"
15819 echo "12345" >>$temp
15820 echo "12345" >>$file
15821 cmp $temp $file || error "$temp $file differ (append1)"
15823 echo "12345" >>$temp
15824 echo "12345" >>$file
15825 cmp $temp $file || error "$temp $file differ (append2)"
15831 test_155_big_load() {
15832 remote_ost_nodsh && skip "remote OST with nodsh"
15834 local temp=$TMP/$tfile
15835 local file=$DIR/$tfile
15838 local cache_size=$(do_facet ost$((MAXI+1)) \
15839 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
15841 # LU-16042: can not get the cache size on Arm64 VM here, fallback to a
15843 if [ -z "$cache_size" ]; then
15846 local large_file_size=$((cache_size * 2))
15848 echo "OSS cache size: $cache_size KB"
15849 echo "Large file size: $large_file_size KB"
15851 [ $MAXV -le $large_file_size ] &&
15852 skip_env "max available OST size needs > $large_file_size KB"
15854 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
15856 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
15857 error "dd of=$temp bs=$large_file_size count=1k failed"
15860 cancel_lru_locks osc
15861 cmp $temp $file || error "$temp $file differ"
15867 save_writethrough() {
15868 local facets=$(get_facets OST)
15870 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
15874 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15876 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15878 save_writethrough $p
15881 set_cache writethrough on
15882 test_155_small_load
15883 restore_lustre_params < $p
15886 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
15889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15891 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15893 save_writethrough $p
15896 set_cache writethrough off
15897 test_155_small_load
15898 restore_lustre_params < $p
15901 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
15904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15906 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15908 save_writethrough $p
15911 set_cache writethrough on
15912 test_155_small_load
15913 restore_lustre_params < $p
15916 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
15919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15921 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15923 save_writethrough $p
15926 set_cache writethrough off
15927 test_155_small_load
15928 restore_lustre_params < $p
15931 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
15934 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15936 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15938 save_writethrough $p
15941 set_cache writethrough on
15943 restore_lustre_params < $p
15946 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
15949 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15951 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15953 save_writethrough $p
15956 set_cache writethrough off
15958 restore_lustre_params < $p
15961 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
15964 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15966 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15968 save_writethrough $p
15971 set_cache writethrough on
15973 restore_lustre_params < $p
15976 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
15979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15981 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15983 save_writethrough $p
15986 set_cache writethrough off
15988 restore_lustre_params < $p
15991 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
15994 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15995 remote_ost_nodsh && skip "remote OST with nodsh"
15996 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
15997 skip "stats not implemented on old servers"
15998 [ "$ost1_FSTYPE" = "zfs" ] &&
15999 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
16004 local file="$DIR/$tfile"
16005 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16007 save_writethrough $p
16010 log "Turn on read and write cache"
16012 set_cache writethrough on
16014 log "Write data and read it back."
16015 log "Read should be satisfied from the cache."
16016 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16018 cancel_lru_locks osc
16019 cat $file >/dev/null
16021 if ! let "AFTER - BEFORE == CPAGES"; then
16022 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
16024 log "cache hits: before: $BEFORE, after: $AFTER"
16027 log "Read again; it should be satisfied from the cache."
16029 cancel_lru_locks osc
16030 cat $file >/dev/null
16032 if ! let "AFTER - BEFORE == CPAGES"; then
16033 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
16035 log "cache hits:: before: $BEFORE, after: $AFTER"
16038 log "Turn off the read cache and turn on the write cache"
16040 set_cache writethrough on
16042 log "Read again; it should be satisfied from the cache."
16044 cancel_lru_locks osc
16045 cat $file >/dev/null
16047 if ! let "AFTER - BEFORE == CPAGES"; then
16048 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
16050 log "cache hits:: before: $BEFORE, after: $AFTER"
16053 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
16054 # > 2.12.56 uses pagecache if cached
16055 log "Read again; it should not be satisfied from the cache."
16057 cancel_lru_locks osc
16058 cat $file >/dev/null
16060 if ! let "AFTER - BEFORE == 0"; then
16061 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
16063 log "cache hits:: before: $BEFORE, after: $AFTER"
16067 log "Write data and read it back."
16068 log "Read should be satisfied from the cache."
16069 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16071 cancel_lru_locks osc
16072 cat $file >/dev/null
16074 if ! let "AFTER - BEFORE == CPAGES"; then
16075 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
16077 log "cache hits:: before: $BEFORE, after: $AFTER"
16080 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
16081 # > 2.12.56 uses pagecache if cached
16082 log "Read again; it should not be satisfied from the cache."
16084 cancel_lru_locks osc
16085 cat $file >/dev/null
16087 if ! let "AFTER - BEFORE == 0"; then
16088 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
16090 log "cache hits:: before: $BEFORE, after: $AFTER"
16094 log "Turn off read and write cache"
16096 set_cache writethrough off
16098 log "Write data and read it back"
16099 log "It should not be satisfied from the cache."
16101 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16102 cancel_lru_locks osc
16104 cat $file >/dev/null
16106 if ! let "AFTER - BEFORE == 0"; then
16107 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
16109 log "cache hits:: before: $BEFORE, after: $AFTER"
16112 log "Turn on the read cache and turn off the write cache"
16114 set_cache writethrough off
16116 log "Write data and read it back"
16117 log "It should not be satisfied from the cache."
16119 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16121 cancel_lru_locks osc
16122 cat $file >/dev/null
16124 if ! let "AFTER - BEFORE == 0"; then
16125 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
16127 log "cache hits:: before: $BEFORE, after: $AFTER"
16130 log "Read again; it should be satisfied from the cache."
16132 cancel_lru_locks osc
16133 cat $file >/dev/null
16135 if ! let "AFTER - BEFORE == CPAGES"; then
16136 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
16138 log "cache hits:: before: $BEFORE, after: $AFTER"
16141 restore_lustre_params < $p
16144 run_test 156 "Verification of tunables"
16147 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16148 remote_mds_nodsh && skip "remote MDS with nodsh"
16149 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
16150 skip "Need MDS version at least 2.2.0"
16152 changelog_register || error "changelog_register failed"
16153 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16154 changelog_users $SINGLEMDS | grep -q $cl_user ||
16155 error "User $cl_user not found in changelog_users"
16157 mkdir_on_mdt0 $DIR/$tdir
16160 test_mkdir -p $DIR/$tdir/pics/2008/zachy
16161 changelog_clear 0 || error "changelog_clear failed"
16162 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
16163 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
16164 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
16165 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
16166 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
16167 rm $DIR/$tdir/pics/desktop.jpg
16169 echo "verifying changelog mask"
16170 changelog_chmask "-MKDIR"
16171 changelog_chmask "-CLOSE"
16173 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
16174 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
16176 changelog_chmask "+MKDIR"
16177 changelog_chmask "+CLOSE"
16179 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
16180 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
16182 MKDIRS=$(changelog_dump | grep -c "MKDIR")
16183 CLOSES=$(changelog_dump | grep -c "CLOSE")
16184 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
16185 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
16188 echo "verifying target fid"
16189 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
16190 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
16191 [ "$fidc" == "$fidf" ] ||
16192 error "changelog '$tfile' fid $fidc != file fid $fidf"
16193 echo "verifying parent fid"
16194 # The FID returned from the Changelog may be the directory shard on
16195 # a different MDT, and not the FID returned by path2fid on the parent.
16196 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
16197 # since this is what will matter when recreating this file in the tree.
16198 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
16199 local pathp=$($LFS fid2path $MOUNT "$fidp")
16200 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
16201 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
16203 echo "getting records for $cl_user"
16204 changelog_users $SINGLEMDS
16205 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
16207 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
16208 error "changelog_clear failed"
16209 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
16210 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
16211 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
16212 error "user index expect $user_rec1 + $nclr != $user_rec2"
16214 local min0_rec=$(changelog_users $SINGLEMDS |
16215 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
16216 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
16217 awk '{ print $1; exit; }')
16219 changelog_dump | tail -n 5
16220 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
16221 [ $first_rec == $((min0_rec + 1)) ] ||
16222 error "first index should be $min0_rec + 1 not $first_rec"
16224 # LU-3446 changelog index reset on MDT restart
16225 local cur_rec1=$(changelog_users $SINGLEMDS |
16226 awk '/^current.index:/ { print $NF }')
16227 changelog_clear 0 ||
16228 error "clear all changelog records for $cl_user failed"
16229 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
16230 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
16231 error "Fail to start $SINGLEMDS"
16232 local cur_rec2=$(changelog_users $SINGLEMDS |
16233 awk '/^current.index:/ { print $NF }')
16234 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
16235 [ $cur_rec1 == $cur_rec2 ] ||
16236 error "current index should be $cur_rec1 not $cur_rec2"
16238 echo "verifying users from this test are deregistered"
16239 changelog_deregister || error "changelog_deregister failed"
16240 changelog_users $SINGLEMDS | grep -q $cl_user &&
16241 error "User '$cl_user' still in changelog_users"
16243 # lctl get_param -n mdd.*.changelog_users
16244 # current_index: 144
16245 # ID index (idle seconds)
16246 # cl3 144 (2) mask=<list>
16247 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
16248 # this is the normal case where all users were deregistered
16249 # make sure no new records are added when no users are present
16250 local last_rec1=$(changelog_users $SINGLEMDS |
16251 awk '/^current.index:/ { print $NF }')
16252 touch $DIR/$tdir/chloe
16253 local last_rec2=$(changelog_users $SINGLEMDS |
16254 awk '/^current.index:/ { print $NF }')
16255 echo "verify changelogs are off: $last_rec1 == $last_rec2"
16256 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
16258 # any changelog users must be leftovers from a previous test
16259 changelog_users $SINGLEMDS
16260 echo "other changelog users; can't verify off"
16263 run_test 160a "changelog sanity"
16265 test_160b() { # LU-3587
16266 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16267 remote_mds_nodsh && skip "remote MDS with nodsh"
16268 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
16269 skip "Need MDS version at least 2.2.0"
16271 changelog_register || error "changelog_register failed"
16272 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16273 changelog_users $SINGLEMDS | grep -q $cl_user ||
16274 error "User '$cl_user' not found in changelog_users"
16276 local longname1=$(str_repeat a 255)
16277 local longname2=$(str_repeat b 255)
16280 echo "creating very long named file"
16281 touch $longname1 || error "create of '$longname1' failed"
16282 echo "renaming very long named file"
16283 mv $longname1 $longname2
16285 changelog_dump | grep RENME | tail -n 5
16288 run_test 160b "Verify that very long rename doesn't crash in changelog"
16291 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16292 remote_mds_nodsh && skip "remote MDS with nodsh"
16294 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
16295 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
16296 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
16297 skip "Need MDS version at least 2.5.58 or 2.5.2+"
16301 # Registration step
16302 changelog_register || error "changelog_register failed"
16305 mkdir -p $DIR/$tdir
16306 $MCREATE $DIR/$tdir/foo_160c
16307 changelog_chmask "-TRUNC"
16308 $TRUNCATE $DIR/$tdir/foo_160c 200
16309 changelog_chmask "+TRUNC"
16310 $TRUNCATE $DIR/$tdir/foo_160c 199
16311 changelog_dump | tail -n 5
16312 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
16313 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
16315 run_test 160c "verify that changelog log catch the truncate event"
16318 remote_mds_nodsh && skip "remote MDS with nodsh"
16319 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16320 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16321 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
16322 skip "Need MDS version at least 2.7.60"
16324 # Registration step
16325 changelog_register || error "changelog_register failed"
16327 mkdir -p $DIR/$tdir/migrate_dir
16328 changelog_clear 0 || error "changelog_clear failed"
16330 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
16331 changelog_dump | tail -n 5
16332 local migrates=$(changelog_dump | grep -c "MIGRT")
16333 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
16335 run_test 160d "verify that changelog log catch the migrate event"
16338 remote_mds_nodsh && skip "remote MDS with nodsh"
16341 changelog_register || error "changelog_register failed"
16343 local MDT0=$(facet_svc $SINGLEMDS)
16346 # No user (expect fail)
16347 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
16349 if [ $rc -eq 0 ]; then
16350 error "Should fail without user"
16351 elif [ $rc -ne 4 ]; then
16352 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
16355 # Delete a future user (expect fail)
16356 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
16358 if [ $rc -eq 0 ]; then
16359 error "Deleted non-existant user cl77"
16360 elif [ $rc -ne 2 ]; then
16361 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
16364 # Clear to a bad index (1 billion should be safe)
16365 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
16368 if [ $rc -eq 0 ]; then
16369 error "Successfully cleared to invalid CL index"
16370 elif [ $rc -ne 22 ]; then
16371 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
16374 run_test 160e "changelog negative testing (should return errors)"
16377 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16378 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16379 skip "Need MDS version at least 2.10.56"
16381 local mdts=$(comma_list $(mdts_nodes))
16384 changelog_register || error "first changelog_register failed"
16385 changelog_register || error "second changelog_register failed"
16387 declare -A cl_user1
16388 declare -A cl_user2
16393 # generate some changelog records to accumulate on each MDT
16394 # use all_char because created files should be evenly distributed
16395 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16396 error "test_mkdir $tdir failed"
16397 log "$(date +%s): creating first files"
16398 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16399 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
16400 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
16403 # check changelogs have been generated
16404 local start=$SECONDS
16405 local idle_time=$((MDSCOUNT * 5 + 5))
16406 local nbcl=$(changelog_dump | wc -l)
16407 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16409 for param in "changelog_max_idle_time=$idle_time" \
16411 "changelog_min_gc_interval=2" \
16412 "changelog_min_free_cat_entries=3"; do
16413 local MDT0=$(facet_svc $SINGLEMDS)
16414 local var="${param%=*}"
16415 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16417 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16418 do_nodes $mdts $LCTL set_param mdd.*.$param
16421 # force cl_user2 to be idle (1st part), but also cancel the
16422 # cl_user1 records so that it is not evicted later in the test.
16423 local sleep1=$((idle_time / 2))
16424 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
16427 # simulate changelog catalog almost full
16428 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
16429 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
16431 for i in $(seq $MDSCOUNT); do
16432 cl_users=(${CL_USERS[mds$i]})
16433 cl_user1[mds$i]="${cl_users[0]}"
16434 cl_user2[mds$i]="${cl_users[1]}"
16436 [ -n "${cl_user1[mds$i]}" ] ||
16437 error "mds$i: no user registered"
16438 [ -n "${cl_user2[mds$i]}" ] ||
16439 error "mds$i: only ${cl_user2[mds$i]} is registered"
16441 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16442 [ -n "$user_rec1" ] ||
16443 error "mds$i: User ${cl_user1[mds$i]} not registered"
16444 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16445 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16446 [ -n "$user_rec2" ] ||
16447 error "mds$i: User ${cl_user1[mds$i]} not registered"
16448 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16449 "$user_rec1 + 2 == $user_rec2"
16450 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16451 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16452 "$user_rec1 + 2, but is $user_rec2"
16453 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16454 [ -n "$user_rec2" ] ||
16455 error "mds$i: User ${cl_user2[mds$i]} not registered"
16456 [ $user_rec1 == $user_rec2 ] ||
16457 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16458 "$user_rec1, but is $user_rec2"
16461 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
16462 local sleep2=$((idle_time - (SECONDS - start) + 1))
16463 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
16466 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16467 # cl_user1 should be OK because it recently processed records.
16468 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
16469 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16470 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
16471 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
16474 # ensure gc thread is done
16475 for i in $(mdts_nodes); do
16476 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16477 error "$i: GC-thread not done"
16481 for (( i = 1; i <= MDSCOUNT; i++ )); do
16482 # check cl_user1 still registered
16483 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16484 error "mds$i: User ${cl_user1[mds$i]} not registered"
16485 # check cl_user2 unregistered
16486 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16487 error "mds$i: User ${cl_user2[mds$i]} still registered"
16489 # check changelogs are present and starting at $user_rec1 + 1
16490 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16491 [ -n "$user_rec1" ] ||
16492 error "mds$i: User ${cl_user1[mds$i]} not registered"
16493 first_rec=$($LFS changelog $(facet_svc mds$i) |
16494 awk '{ print $1; exit; }')
16496 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16497 [ $((user_rec1 + 1)) == $first_rec ] ||
16498 error "mds$i: rec $first_rec != $user_rec1 + 1"
16501 run_test 160f "changelog garbage collect (timestamped users)"
16504 remote_mds_nodsh && skip "remote MDS with nodsh"
16505 [[ $MDS1_VERSION -ge $(version_code 2.14.55) ]] ||
16506 skip "Need MDS version at least 2.14.55"
16508 local mdts=$(comma_list $(mdts_nodes))
16511 changelog_register || error "first changelog_register failed"
16512 changelog_register || error "second changelog_register failed"
16514 declare -A cl_user1
16515 declare -A cl_user2
16520 # generate some changelog records to accumulate on each MDT
16521 # use all_char because created files should be evenly distributed
16522 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16523 error "test_mkdir $tdir failed"
16524 for ((i = 0; i < MDSCOUNT; i++)); do
16525 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16526 error "create $DIR/$tdir/d$i.1 failed"
16529 # check changelogs have been generated
16530 local nbcl=$(changelog_dump | wc -l)
16531 (( $nbcl > 0 )) || error "no changelogs found"
16533 # reduce the max_idle_indexes value to make sure we exceed it
16534 for param in "changelog_max_idle_indexes=2" \
16536 "changelog_min_gc_interval=2"; do
16537 local MDT0=$(facet_svc $SINGLEMDS)
16538 local var="${param%=*}"
16539 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16541 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16542 do_nodes $mdts $LCTL set_param mdd.*.$param ||
16543 error "unable to set mdd.*.$param"
16546 local start=$SECONDS
16547 for i in $(seq $MDSCOUNT); do
16548 cl_users=(${CL_USERS[mds$i]})
16549 cl_user1[mds$i]="${cl_users[0]}"
16550 cl_user2[mds$i]="${cl_users[1]}"
16552 [ -n "${cl_user1[mds$i]}" ] ||
16553 error "mds$i: user1 is not registered"
16554 [ -n "${cl_user2[mds$i]}" ] ||
16555 error "mds$i: only ${cl_user1[mds$i]} is registered"
16557 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16558 [ -n "$user_rec1" ] ||
16559 error "mds$i: user1 ${cl_user1[mds$i]} not found"
16560 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16561 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16562 [ -n "$user_rec2" ] ||
16563 error "mds$i: user1 ${cl_user1[mds$i]} not found (2)"
16564 echo "mds$i: verifying user1 ${cl_user1[mds$i]} clear: " \
16565 "$user_rec1 + 2 == $user_rec2"
16566 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16567 error "mds$i: user1 ${cl_user1[mds$i]} index " \
16568 "expected $user_rec1 + 2, but is $user_rec2"
16569 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16570 [ -n "$user_rec2" ] ||
16571 error "mds$i: user2 ${cl_user2[mds$i]} not found"
16572 [ $user_rec1 == $user_rec2 ] ||
16573 error "mds$i: user2 ${cl_user2[mds$i]} index " \
16574 "expected $user_rec1, but is $user_rec2"
16577 # ensure we are past the previous changelog_min_gc_interval set above
16578 local sleep2=$((start + 2 - SECONDS))
16579 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
16580 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16581 # cl_user1 should be OK because it recently processed records.
16582 for ((i = 0; i < MDSCOUNT; i++)); do
16583 $LFS mkdir -i $i $DIR/$tdir/d$i.3 ||
16584 error "create $DIR/$tdir/d$i.3 failed"
16587 # ensure gc thread is done
16588 for i in $(mdts_nodes); do
16589 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16590 error "$i: GC-thread not done"
16594 for (( i = 1; i <= MDSCOUNT; i++ )); do
16595 # check cl_user1 still registered
16596 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16597 error "mds$i: user1 ${cl_user1[mds$i]} not found (3)"
16598 # check cl_user2 unregistered
16599 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16600 error "mds$i: user2 ${cl_user2[mds$i]} is registered"
16602 # check changelogs are present and starting at $user_rec1 + 1
16603 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16604 [ -n "$user_rec1" ] ||
16605 error "mds$i: user1 ${cl_user1[mds$i]} not found (4)"
16606 first_rec=$($LFS changelog $(facet_svc mds$i) |
16607 awk '{ print $1; exit; }')
16609 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16610 [ $((user_rec1 + 1)) == $first_rec ] ||
16611 error "mds$i: rec $first_rec != $user_rec1 + 1"
16614 run_test 160g "changelog garbage collect on idle records"
16617 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16618 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16619 skip "Need MDS version at least 2.10.56"
16621 local mdts=$(comma_list $(mdts_nodes))
16624 changelog_register || error "first changelog_register failed"
16625 changelog_register || error "second changelog_register failed"
16627 declare -A cl_user1
16628 declare -A cl_user2
16633 # generate some changelog records to accumulate on each MDT
16634 # use all_char because created files should be evenly distributed
16635 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16636 error "test_mkdir $tdir failed"
16637 for ((i = 0; i < MDSCOUNT; i++)); do
16638 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16639 error "create $DIR/$tdir/d$i.1 failed"
16642 # check changelogs have been generated
16643 local nbcl=$(changelog_dump | wc -l)
16644 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16646 for param in "changelog_max_idle_time=10" \
16648 "changelog_min_gc_interval=2"; do
16649 local MDT0=$(facet_svc $SINGLEMDS)
16650 local var="${param%=*}"
16651 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16653 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16654 do_nodes $mdts $LCTL set_param mdd.*.$param
16657 # force cl_user2 to be idle (1st part)
16660 for i in $(seq $MDSCOUNT); do
16661 cl_users=(${CL_USERS[mds$i]})
16662 cl_user1[mds$i]="${cl_users[0]}"
16663 cl_user2[mds$i]="${cl_users[1]}"
16665 [ -n "${cl_user1[mds$i]}" ] ||
16666 error "mds$i: no user registered"
16667 [ -n "${cl_user2[mds$i]}" ] ||
16668 error "mds$i: only ${cl_user2[mds$i]} is registered"
16670 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16671 [ -n "$user_rec1" ] ||
16672 error "mds$i: User ${cl_user1[mds$i]} not registered"
16673 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16674 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16675 [ -n "$user_rec2" ] ||
16676 error "mds$i: User ${cl_user1[mds$i]} not registered"
16677 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16678 "$user_rec1 + 2 == $user_rec2"
16679 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16680 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16681 "$user_rec1 + 2, but is $user_rec2"
16682 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16683 [ -n "$user_rec2" ] ||
16684 error "mds$i: User ${cl_user2[mds$i]} not registered"
16685 [ $user_rec1 == $user_rec2 ] ||
16686 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16687 "$user_rec1, but is $user_rec2"
16690 # force cl_user2 to be idle (2nd part) and to reach
16691 # changelog_max_idle_time
16694 # force each GC-thread start and block then
16695 # one per MDT/MDD, set fail_val accordingly
16696 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
16697 do_nodes $mdts $LCTL set_param fail_loc=0x1316
16699 # generate more changelogs to trigger fail_loc
16700 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16701 error "create $DIR/$tdir/${tfile}bis failed"
16703 # stop MDT to stop GC-thread, should be done in back-ground as it will
16704 # block waiting for the thread to be released and exit
16705 declare -A stop_pids
16706 for i in $(seq $MDSCOUNT); do
16708 stop_pids[mds$i]=$!
16711 for i in $(mdts_nodes); do
16714 local facets=$(facets_up_on_host $i)
16716 for facet in ${facets//,/ }; do
16717 if [[ $facet == mds* ]]; then
16721 # ensure each MDS's gc threads are still present and all in "R"
16722 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
16723 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
16724 error "$i: expected $nb GC-thread"
16726 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
16728 error "$i: GC-thread not found in R-state"
16729 # check umounts of each MDT on MDS have reached kthread_stop()
16730 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
16731 error "$i: expected $nb umount"
16733 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
16734 error "$i: umount not found in D-state"
16737 # release all GC-threads
16738 do_nodes $mdts $LCTL set_param fail_loc=0
16740 # wait for MDT stop to complete
16741 for i in $(seq $MDSCOUNT); do
16742 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
16746 # may try to check if any orphan changelog records are present
16747 # via ldiskfs/zfs and llog_reader...
16749 # re-start/mount MDTs
16750 for i in $(seq $MDSCOUNT); do
16751 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
16752 error "Fail to start mds$i"
16756 for i in $(seq $MDSCOUNT); do
16757 # check cl_user1 still registered
16758 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16759 error "mds$i: User ${cl_user1[mds$i]} not registered"
16760 # check cl_user2 unregistered
16761 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16762 error "mds$i: User ${cl_user2[mds$i]} still registered"
16764 # check changelogs are present and starting at $user_rec1 + 1
16765 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16766 [ -n "$user_rec1" ] ||
16767 error "mds$i: User ${cl_user1[mds$i]} not registered"
16768 first_rec=$($LFS changelog $(facet_svc mds$i) |
16769 awk '{ print $1; exit; }')
16771 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
16772 [ $((user_rec1 + 1)) == $first_rec ] ||
16773 error "mds$i: first index should be $user_rec1 + 1, " \
16774 "but is $first_rec"
16777 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
16782 local mdts=$(comma_list $(mdts_nodes))
16784 changelog_register || error "first changelog_register failed"
16786 # generate some changelog records to accumulate on each MDT
16787 # use all_char because created files should be evenly distributed
16788 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16789 error "test_mkdir $tdir failed"
16790 for ((i = 0; i < MDSCOUNT; i++)); do
16791 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16792 error "create $DIR/$tdir/d$i.1 failed"
16795 # check changelogs have been generated
16796 local nbcl=$(changelog_dump | wc -l)
16797 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16799 # simulate race between register and unregister
16800 # XXX as fail_loc is set per-MDS, with DNE configs the race
16801 # simulation will only occur for one MDT per MDS and for the
16802 # others the normal race scenario will take place
16803 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
16804 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
16805 do_nodes $mdts $LCTL set_param fail_val=1
16807 # unregister 1st user
16808 changelog_deregister &
16810 # wait some time for deregister work to reach race rdv
16812 # register 2nd user
16813 changelog_register || error "2nd user register failed"
16815 wait $pid1 || error "1st user deregister failed"
16819 declare -A LAST_REC
16820 for i in $(seq $MDSCOUNT); do
16821 if changelog_users mds$i | grep "^cl"; then
16822 # make sure new records are added with one user present
16823 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
16824 awk '/^current.index:/ { print $NF }')
16826 error "mds$i has no user registered"
16830 # generate more changelog records to accumulate on each MDT
16831 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16832 error "create $DIR/$tdir/${tfile}bis failed"
16834 for i in $(seq $MDSCOUNT); do
16835 last_rec=$(changelog_users $SINGLEMDS |
16836 awk '/^current.index:/ { print $NF }')
16837 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
16838 [ $last_rec != ${LAST_REC[mds$i]} ] ||
16839 error "changelogs are off on mds$i"
16842 run_test 160i "changelog user register/unregister race"
16845 remote_mds_nodsh && skip "remote MDS with nodsh"
16846 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
16847 skip "Need MDS version at least 2.12.56"
16849 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
16850 stack_trap "umount $MOUNT2" EXIT
16852 changelog_register || error "first changelog_register failed"
16853 stack_trap "changelog_deregister" EXIT
16855 # generate some changelog
16856 # use all_char because created files should be evenly distributed
16857 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16858 error "mkdir $tdir failed"
16859 for ((i = 0; i < MDSCOUNT; i++)); do
16860 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16861 error "create $DIR/$tdir/d$i.1 failed"
16864 # open the changelog device
16865 exec 3>/dev/changelog-$FSNAME-MDT0000
16866 stack_trap "exec 3>&-" EXIT
16867 exec 4</dev/changelog-$FSNAME-MDT0000
16868 stack_trap "exec 4<&-" EXIT
16870 # umount the first lustre mount
16872 stack_trap "mount_client $MOUNT" EXIT
16874 # read changelog, which may or may not fail, but should not crash
16878 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16879 changelog_users $SINGLEMDS | grep -q $cl_user ||
16880 error "User $cl_user not found in changelog_users"
16882 printf 'clear:'$cl_user':0' >&3
16884 run_test 160j "client can be umounted while its chanangelog is being used"
16887 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16888 remote_mds_nodsh && skip "remote MDS with nodsh"
16890 mkdir -p $DIR/$tdir/1/1
16892 changelog_register || error "changelog_register failed"
16893 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16895 changelog_users $SINGLEMDS | grep -q $cl_user ||
16896 error "User '$cl_user' not found in changelog_users"
16897 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
16898 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
16899 rmdir $DIR/$tdir/1/1 & sleep 1
16901 touch $DIR/$tdir/2/2
16902 rm -rf $DIR/$tdir/2
16907 changelog_dump | grep rmdir || error "rmdir not recorded"
16909 run_test 160k "Verify that changelog records are not lost"
16911 # Verifies that a file passed as a parameter has recently had an operation
16912 # performed on it that has generated an MTIME changelog which contains the
16913 # correct parent FID. As files might reside on a different MDT from the
16914 # parent directory in DNE configurations, the FIDs are translated to paths
16915 # before being compared, which should be identical
16916 compare_mtime_changelog() {
16924 mdtidx=$($LFS getstripe --mdt-index $file)
16925 mdtidx=$(printf "%04x" $mdtidx)
16927 # Obtain the parent FID from the MTIME changelog
16928 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
16929 [ -z "$mtime" ] && error "MTIME changelog not recorded"
16931 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
16932 [ -z "$cl_fid" ] && error "parent FID not present"
16934 # Verify that the path for the parent FID is the same as the path for
16935 # the test directory
16936 pdir=$($LFS fid2path $MOUNT "$cl_fid")
16940 [[ "${pdir%/}" == "$dir" ]] ||
16941 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
16945 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16947 remote_mds_nodsh && skip "remote MDS with nodsh"
16948 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
16949 skip "Need MDS version at least 2.13.55"
16953 changelog_register || error "changelog_register failed"
16954 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16956 changelog_users $SINGLEMDS | grep -q $cl_user ||
16957 error "User '$cl_user' not found in changelog_users"
16959 # Clear some types so that MTIME changelogs are generated
16960 changelog_chmask "-CREAT"
16961 changelog_chmask "-CLOSE"
16963 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
16965 # Test CL_MTIME during setattr
16966 touch $DIR/$tdir/$tfile
16967 compare_mtime_changelog $DIR/$tdir/$tfile
16969 # Test CL_MTIME during close
16970 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
16971 compare_mtime_changelog $DIR/$tdir/${tfile}_2
16973 run_test 160l "Verify that MTIME changelog records contain the parent FID"
16976 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16977 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16978 skip "Need MDS version at least 2.14.51"
16985 changelog_register || error "first changelog_register failed"
16986 changelog_register || error "second changelog_register failed"
16988 cl_users=(${CL_USERS[mds1]})
16989 cl_user1="${cl_users[0]}"
16990 cl_user2="${cl_users[1]}"
16991 # generate some changelog records to accumulate on MDT0
16992 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16993 createmany -m $DIR/$tdir/$tfile 50 ||
16994 error "create $DIR/$tdir/$tfile failed"
16995 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16998 # check changelogs have been generated
16999 local nbcl=$(changelog_dump | wc -l)
17000 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17002 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
17003 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
17005 __changelog_clear mds1 $cl_user1 +10
17006 __changelog_clear mds1 $cl_user2 0 &
17009 __changelog_clear mds1 $cl_user1 0 ||
17010 error "fail to cancel record for $cl_user1"
17012 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
17014 run_test 160m "Changelog clear race"
17017 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17018 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17019 skip "Need MDS version at least 2.14.51"
17028 changelog_register || error "first changelog_register failed"
17030 cl_users=(${CL_USERS[mds1]})
17031 cl_user1="${cl_users[0]}"
17033 # generate some changelog records to accumulate on MDT0
17034 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17035 first_rec=$(changelog_users $SINGLEMDS |
17036 awk '/^current.index:/ { print $NF }')
17037 while (( last_rec < (( first_rec + 65000)) )); do
17038 createmany -m $DIR/$tdir/$tfile 10000 ||
17039 error "create $DIR/$tdir/$tfile failed"
17041 for i in $(seq 0 10000); do
17042 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
17046 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
17047 error "unlinkmany failed unlink"
17048 last_rec=$(changelog_users $SINGLEMDS |
17049 awk '/^current.index:/ { print $NF }')
17050 echo last record $last_rec
17051 (( last_rec == 0 )) && error "no changelog found"
17054 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
17055 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
17057 __changelog_clear mds1 $cl_user1 0 &
17060 __changelog_clear mds1 $cl_user1 0 ||
17061 error "fail to cancel record for $cl_user1"
17063 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
17065 run_test 160n "Changelog destroy race"
17068 local mdt="$(facet_svc $SINGLEMDS)"
17070 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
17071 remote_mds_nodsh && skip "remote MDS with nodsh"
17072 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
17073 skip "Need MDS version at least 2.14.52"
17075 changelog_register --user test_160o -m unlnk+close+open ||
17076 error "changelog_register failed"
17078 do_facet $SINGLEMDS $LCTL --device $mdt \
17079 changelog_register -u "Tt3_-#" &&
17080 error "bad symbols in name should fail"
17082 do_facet $SINGLEMDS $LCTL --device $mdt \
17083 changelog_register -u test_160o &&
17084 error "the same name registration should fail"
17086 do_facet $SINGLEMDS $LCTL --device $mdt \
17087 changelog_register -u test_160toolongname &&
17088 error "too long name registration should fail"
17090 changelog_chmask "MARK+HSM"
17091 lctl get_param mdd.*.changelog*mask
17092 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17093 changelog_users $SINGLEMDS | grep -q $cl_user ||
17094 error "User $cl_user not found in changelog_users"
17096 echo $cl_user | grep -q test_160o ||
17097 error "User $cl_user has no specific name 'test160o'"
17100 changelog_clear 0 || error "changelog_clear failed"
17101 # generate some changelog records to accumulate on MDT0
17102 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17103 touch $DIR/$tdir/$tfile # open 1
17105 OPENS=$(changelog_dump | grep -c "OPEN")
17106 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
17108 # must be no MKDIR it wasn't set as user mask
17109 MKDIR=$(changelog_dump | grep -c "MKDIR")
17110 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
17112 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
17113 mdd.$mdt.changelog_current_mask -n)
17114 # register maskless user
17115 changelog_register || error "changelog_register failed"
17116 # effective mask should be not changed because it is not minimal
17117 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17118 mdd.$mdt.changelog_current_mask -n)
17119 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
17120 # set server mask to minimal value
17121 changelog_chmask "MARK"
17122 # check effective mask again, should be treated as DEFMASK now
17123 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17124 mdd.$mdt.changelog_current_mask -n)
17125 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
17127 do_facet $SINGLEMDS $LCTL --device $mdt \
17128 changelog_deregister -u test_160o ||
17129 error "cannot deregister by name"
17131 run_test 160o "changelog user name and mask"
17134 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17135 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17136 skip "Need MDS version at least 2.14.51"
17137 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
17143 changelog_register || error "first changelog_register failed"
17145 cl_users=(${CL_USERS[mds1]})
17146 cl_user1="${cl_users[0]}"
17148 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17149 createmany -m $DIR/$tdir/$tfile 50 ||
17150 error "create $DIR/$tdir/$tfile failed"
17151 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
17154 # check changelogs have been generated
17155 entry_count=$(changelog_dump | wc -l)
17156 ((entry_count != 0)) || error "no changelog entries found"
17158 # remove changelog_users and check that orphan entries are removed
17160 local dev=$(mdsdevname 1)
17161 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $dev"
17162 start mds1 $dev $MDS_MOUNT_OPTS || error "cannot start mds1"
17163 entry_count=$(changelog_dump | wc -l)
17164 ((entry_count == 0)) ||
17165 error "found $entry_count changelog entries, expected none"
17167 run_test 160p "Changelog orphan cleanup with no users"
17170 local mdt="$(facet_svc $SINGLEMDS)"
17173 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
17174 remote_mds_nodsh && skip "remote MDS with nodsh"
17175 [ $MDS1_VERSION -ge $(version_code 2.14.54) ] ||
17176 skip "Need MDS version at least 2.14.54"
17178 # set server mask to minimal value like server init does
17179 changelog_chmask "MARK"
17180 clu=$(do_facet $SINGLEMDS $LCTL --device $mdt changelog_register -n) ||
17181 error "changelog_register failed"
17182 # check effective mask again, should be treated as DEFMASK now
17183 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17184 mdd.$mdt.changelog_current_mask -n)
17185 do_facet $SINGLEMDS $LCTL --device $mdt changelog_deregister $clu ||
17186 error "changelog_deregister failed"
17187 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
17189 run_test 160q "changelog effective mask is DEFMASK if not set"
17192 remote_mds_nodsh && skip "remote MDS with nodsh"
17193 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
17194 skip "Need MDS version at least 2.14.55"
17196 local mdts=$(comma_list $(mdts_nodes))
17198 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
17199 do_nodes $mdts $LCTL set_param fail_loc=0x1314 \
17200 fail_val=$((24 * 3600 * 10))
17202 # Create a user which is 10 days old
17203 changelog_register || error "first changelog_register failed"
17205 declare -A cl_user1
17208 # generate some changelog records to accumulate on each MDT
17209 # use all_char because created files should be evenly distributed
17210 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17211 error "test_mkdir $tdir failed"
17212 for ((i = 0; i < MDSCOUNT; i++)); do
17213 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17214 error "create $DIR/$tdir/d$i.1 failed"
17217 # check changelogs have been generated
17218 local nbcl=$(changelog_dump | wc -l)
17219 (( nbcl > 0 )) || error "no changelogs found"
17221 # reduce the max_idle_indexes value to make sure we exceed it
17222 for param in "changelog_max_idle_indexes=2097446912" \
17223 "changelog_max_idle_time=2592000" \
17225 "changelog_min_gc_interval=2"; do
17226 local MDT0=$(facet_svc $SINGLEMDS)
17227 local var="${param%=*}"
17228 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17230 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17231 do_nodes $mdts $LCTL set_param mdd.*.$param ||
17232 error "unable to set mdd.*.$param"
17235 local start=$SECONDS
17236 for i in $(seq $MDSCOUNT); do
17237 cl_users=(${CL_USERS[mds$i]})
17238 cl_user1[mds$i]="${cl_users[0]}"
17240 [[ -n "${cl_user1[mds$i]}" ]] ||
17241 error "mds$i: no user registered"
17244 #define OBD_FAIL_MDS_CHANGELOG_IDX_PUMP 0x16d
17245 do_nodes $mdts $LCTL set_param fail_loc=0x16d fail_val=500000000
17247 # ensure we are past the previous changelog_min_gc_interval set above
17248 local sleep2=$((start + 2 - SECONDS))
17249 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17251 # Generate one more changelog to trigger GC
17252 for ((i = 0; i < MDSCOUNT; i++)); do
17253 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
17254 error "create $DIR/$tdir/d$i.3 failed"
17257 # ensure gc thread is done
17258 for node in $(mdts_nodes); do
17259 wait_update $node "pgrep chlg_gc_thread" "" 20 ||
17260 error "$node: GC-thread not done"
17263 do_nodes $mdts $LCTL set_param fail_loc=0
17265 for (( i = 1; i <= MDSCOUNT; i++ )); do
17266 # check cl_user1 is purged
17267 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" &&
17268 error "mds$i: User ${cl_user1[mds$i]} is registered"
17272 run_test 160s "changelog garbage collect on idle records * time"
17275 remote_mds_nodsh && skip "remote MDS with nodsh"
17276 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
17277 skip "Need MDS version at least 2.15.50"
17279 local MDT0=$(facet_svc $SINGLEMDS)
17285 changelog_register --user user1 -m all ||
17286 error "user1 failed to register"
17288 mkdir_on_mdt0 $DIR/$tdir
17289 # create default overstripe to maximize changelog size
17290 $LFS setstripe -C 8 $DIR/$tdir || error "setstripe failed"
17291 createmany -o $DIR/$tdir/u1_ 2000 || error "createmany for user1 failed"
17292 llog_size1=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
17294 # user2 consumes less records so less space
17295 changelog_register --user user2 || error "user2 failed to register"
17296 createmany -o $DIR/$tdir/u2_ 500 || error "createmany for user2 failed"
17297 llog_size2=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
17299 # check changelogs have been generated
17300 local nbcl=$(changelog_dump | wc -l)
17301 (( nbcl > 0 )) || error "no changelogs found"
17303 # reduce the changelog_min_gc_interval to force check
17304 for param in "changelog_gc=1" "changelog_min_gc_interval=2"; do
17305 local var="${param%=*}"
17306 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17308 stack_trap "do_facet mds1 $LCTL set_param mdd.$MDT0.$var=$old"
17309 do_facet mds1 $LCTL set_param mdd.$MDT0.$param ||
17310 error "unable to set mdd.*.$param"
17314 cl_users=(${CL_USERS[mds1]})
17315 cl_user1="${cl_users[0]}"
17316 cl_user2="${cl_users[1]}"
17318 [[ -n $cl_user1 ]] ||
17319 error "mds1: user #1 isn't registered"
17320 [[ -n $cl_user2 ]] ||
17321 error "mds1: user #2 isn't registered"
17323 # ensure we are past the previous changelog_min_gc_interval set above
17324 local sleep2=$((start + 2 - SECONDS))
17325 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17327 #define OBD_FAIL_MDS_CHANGELOG_ENOSPC 0x018c
17328 do_facet mds1 $LCTL set_param fail_loc=0x018c \
17329 fail_val=$(((llog_size1 + llog_size2) / 2))
17331 # Generate more changelog to trigger GC
17332 createmany -o $DIR/$tdir/u3_ 4 ||
17333 error "create failed for more files"
17335 # ensure gc thread is done
17336 wait_update_facet mds1 "pgrep chlg_gc_thread" "" 20 ||
17337 error "mds1: GC-thread not done"
17339 do_facet mds1 $LCTL set_param fail_loc=0
17341 # check cl_user1 is purged
17342 changelog_users mds1 | grep -q "$cl_user1" &&
17343 error "User $cl_user1 is registered"
17344 # check cl_user2 is not purged
17345 changelog_users mds1 | grep -q "$cl_user2" ||
17346 error "User $cl_user2 is not registered"
17348 run_test 160t "changelog garbage collect on lack of space"
17351 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17353 test_mkdir -c1 $DIR/$tdir
17354 cp /etc/hosts $DIR/$tdir/$tfile
17355 test_mkdir -c1 $DIR/$tdir/foo1
17356 test_mkdir -c1 $DIR/$tdir/foo2
17357 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
17358 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
17359 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
17360 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
17361 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
17362 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17363 $LFS fid2path $DIR $FID
17364 error "bad link ea"
17367 rm $DIR/$tdir/foo2/zachary
17369 rm $DIR/$tdir/foo2/thor
17371 rm $DIR/$tdir/$tfile
17373 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
17374 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
17375 { $LFS fid2path $DIR $FID; error "bad link rename"; }
17376 rm $DIR/$tdir/foo2/maggie
17379 local longname=$tfile.avg_len_is_thirty_two_
17380 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
17381 error_noexit 'failed to unlink many hardlinks'" EXIT
17382 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
17383 error "failed to hardlink many files"
17384 links=$($LFS fid2path $DIR $FID | wc -l)
17385 echo -n "${links}/1000 links in link EA"
17386 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
17388 run_test 161a "link ea sanity"
17391 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17392 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
17395 local remote_dir=$DIR/$tdir/remote_dir
17397 mkdir -p $DIR/$tdir
17398 $LFS mkdir -i $MDTIDX $remote_dir ||
17399 error "create remote directory failed"
17401 cp /etc/hosts $remote_dir/$tfile
17402 mkdir -p $remote_dir/foo1
17403 mkdir -p $remote_dir/foo2
17404 ln $remote_dir/$tfile $remote_dir/foo1/sofia
17405 ln $remote_dir/$tfile $remote_dir/foo2/zachary
17406 ln $remote_dir/$tfile $remote_dir/foo1/luna
17407 ln $remote_dir/$tfile $remote_dir/foo2/thor
17409 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
17411 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17412 $LFS fid2path $DIR $FID
17413 error "bad link ea"
17416 rm $remote_dir/foo2/zachary
17418 rm $remote_dir/foo2/thor
17420 rm $remote_dir/$tfile
17422 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
17423 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
17424 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
17425 $LFS fid2path $DIR $FID
17426 error "bad link rename"
17428 rm $remote_dir/foo2/maggie
17431 local longname=filename_avg_len_is_thirty_two_
17432 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
17433 error "failed to hardlink many files"
17434 links=$($LFS fid2path $DIR $FID | wc -l)
17435 echo -n "${links}/1000 links in link EA"
17436 [[ ${links} -gt 60 ]] ||
17437 error "expected at least 60 links in link EA"
17438 unlinkmany $remote_dir/foo2/$longname 1000 ||
17439 error "failed to unlink many hardlinks"
17441 run_test 161b "link ea sanity under remote directory"
17444 remote_mds_nodsh && skip "remote MDS with nodsh"
17445 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17446 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
17447 skip "Need MDS version at least 2.1.5"
17449 # define CLF_RENAME_LAST 0x0001
17450 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
17451 changelog_register || error "changelog_register failed"
17454 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
17455 touch $DIR/$tdir/foo_161c
17456 touch $DIR/$tdir/bar_161c
17457 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17458 changelog_dump | grep RENME | tail -n 5
17459 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17460 changelog_clear 0 || error "changelog_clear failed"
17461 if [ x$flags != "x0x1" ]; then
17462 error "flag $flags is not 0x1"
17465 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
17466 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
17467 touch $DIR/$tdir/foo_161c
17468 touch $DIR/$tdir/bar_161c
17469 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17470 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17471 changelog_dump | grep RENME | tail -n 5
17472 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17473 changelog_clear 0 || error "changelog_clear failed"
17474 if [ x$flags != "x0x0" ]; then
17475 error "flag $flags is not 0x0"
17477 echo "rename overwrite a target having nlink > 1," \
17478 "changelog record has flags of $flags"
17480 # rename doesn't overwrite a target (changelog flag 0x0)
17481 touch $DIR/$tdir/foo_161c
17482 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
17483 changelog_dump | grep RENME | tail -n 5
17484 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
17485 changelog_clear 0 || error "changelog_clear failed"
17486 if [ x$flags != "x0x0" ]; then
17487 error "flag $flags is not 0x0"
17489 echo "rename doesn't overwrite a target," \
17490 "changelog record has flags of $flags"
17492 # define CLF_UNLINK_LAST 0x0001
17493 # unlink a file having nlink = 1 (changelog flag 0x1)
17494 rm -f $DIR/$tdir/foo2_161c
17495 changelog_dump | grep UNLNK | tail -n 5
17496 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17497 changelog_clear 0 || error "changelog_clear failed"
17498 if [ x$flags != "x0x1" ]; then
17499 error "flag $flags is not 0x1"
17501 echo "unlink a file having nlink = 1," \
17502 "changelog record has flags of $flags"
17504 # unlink a file having nlink > 1 (changelog flag 0x0)
17505 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17506 rm -f $DIR/$tdir/foobar_161c
17507 changelog_dump | grep UNLNK | tail -n 5
17508 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17509 changelog_clear 0 || error "changelog_clear failed"
17510 if [ x$flags != "x0x0" ]; then
17511 error "flag $flags is not 0x0"
17513 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
17515 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
17518 remote_mds_nodsh && skip "remote MDS with nodsh"
17519 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
17524 changelog_register || error "changelog_register failed"
17526 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
17527 # interfer with $MOUNT/.lustre/fid/ access
17529 [[ $? -eq 0 ]] || error "mkdir failed"
17531 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
17532 $LCTL set_param fail_loc=0x8000140c
17534 $LCTL set_param fail_val=5
17537 echo foofoo > $DIR/$tdir/$tfile &
17540 # wait for create to be delayed
17544 [[ $? -eq 0 ]] || error "create should be blocked"
17546 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
17547 stack_trap "rm -f $tempfile"
17548 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
17549 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
17550 # some delay may occur during ChangeLog publishing and file read just
17551 # above, that could allow file write to happen finally
17552 [[ -s $tempfile ]] && echo "file should be empty"
17554 $LCTL set_param fail_loc=0
17557 [[ $? -eq 0 ]] || error "create failed"
17559 run_test 161d "create with concurrent .lustre/fid access"
17562 local expected="$1"
17567 path=$($LFS fid2path "$@")
17570 if [ $rc -ne 0 ]; then
17571 error "path looked up of '$expected' failed: rc=$rc"
17572 elif [ "$path" != "$expected" ]; then
17573 error "path looked up '$path' instead of '$expected'"
17575 echo "FID '$fid' resolves to path '$path' as expected"
17579 test_162a() { # was test_162
17580 test_mkdir -p -c1 $DIR/$tdir/d2
17581 touch $DIR/$tdir/d2/$tfile
17582 touch $DIR/$tdir/d2/x1
17583 touch $DIR/$tdir/d2/x2
17584 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
17585 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
17587 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
17588 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
17591 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
17592 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
17593 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
17595 # softlink to wrong file
17596 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
17597 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
17598 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
17601 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
17602 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
17603 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
17604 # fid2path dir/fsname should both work
17605 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
17606 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
17608 # hardlink count: check that there are 2 links
17609 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
17610 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
17612 # hardlink indexing: remove the first link
17613 rm $DIR/$tdir/d2/p/q/r/hlink
17614 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
17616 run_test 162a "path lookup sanity"
17619 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17620 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17623 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17624 error "create striped dir failed"
17626 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
17627 tail -n 1 | awk '{print $2}')
17628 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
17630 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
17631 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
17634 for ((i=0;i<5;i++)); do
17635 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
17636 error "get fid for f$i failed"
17637 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
17639 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
17640 error "get fid for d$i failed"
17641 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
17646 run_test 162b "striped directory path lookup sanity"
17648 # LU-4239: Verify fid2path works with paths 100 or more directories deep
17650 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
17651 skip "Need MDS version at least 2.7.51"
17653 local lpath=$tdir.local
17654 local rpath=$tdir.remote
17656 test_mkdir $DIR/$lpath
17657 test_mkdir $DIR/$rpath
17659 for ((i = 0; i <= 101; i++)); do
17662 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
17663 error "get fid for local directory $DIR/$lpath failed"
17664 check_path "$DIR/$lpath" $MOUNT $FID --link 0
17667 test_mkdir $DIR/$rpath
17668 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
17669 error "get fid for remote directory $DIR/$rpath failed"
17670 check_path "$DIR/$rpath" $MOUNT $FID --link 0
17675 run_test 162c "fid2path works with paths 100 or more directories deep"
17677 oalr_event_count() {
17681 awk -v name="${FSNAME}-OST0000" \
17682 -v event="${event}" \
17683 '$1 == "TRACE" && $2 == event && $3 == name' \
17688 oalr_expect_event_count() {
17691 local expect="${3}"
17694 count=$(oalr_event_count "${event}" "${trace}")
17695 if ((count == expect)); then
17699 error_noexit "${event} event count was '${count}', expected ${expect}"
17705 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
17707 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
17711 sync # Flush previous IOs so we can count log entries.
17712 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
17713 stack_trap cleanup_165 EXIT
17717 local trace="/tmp/${tfile}.trace"
17721 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17722 skip "OFD access log unsupported"
17725 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17728 do_facet ost1 ofd_access_log_reader --list
17731 do_facet ost1 killall -TERM ofd_access_log_reader
17735 if ((rc != 0)); then
17736 error "ofd_access_log_reader exited with rc = '${rc}'"
17739 # Parse trace file for discovery events:
17740 oalr_expect_event_count alr_log_add "${trace}" 1
17741 oalr_expect_event_count alr_log_eof "${trace}" 1
17742 oalr_expect_event_count alr_log_free "${trace}" 1
17744 run_test 165a "ofd access log discovery"
17747 local trace="/tmp/${tfile}.trace"
17748 local file="${DIR}/${tfile}"
17757 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17758 skip "OFD access log unsupported"
17761 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17764 do_facet ost1 ofd_access_log_reader --list
17766 lfs setstripe -c 1 -i 0 "${file}"
17767 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17768 error "cannot create '${file}'"
17771 do_facet ost1 killall -TERM ofd_access_log_reader
17775 if ((rc != 0)); then
17776 error "ofd_access_log_reader exited with rc = '${rc}'"
17779 oalr_expect_event_count alr_log_entry "${trace}" 1
17781 pfid1=$($LFS path2fid "${file}")
17783 # 1 2 3 4 5 6 7 8 9 10
17784 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
17785 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17787 echo "entry = '${entry[*]}'" >&2
17790 if [[ "${pfid1}" != "${pfid2}" ]]; then
17791 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17795 if ((size != 1048576)); then
17796 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
17800 if [[ "${flags}" != "w" ]]; then
17801 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
17804 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17807 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
17808 error "cannot read '${file}'"
17811 do_facet ost1 killall -TERM ofd_access_log_reader
17815 if ((rc != 0)); then
17816 error "ofd_access_log_reader exited with rc = '${rc}'"
17819 oalr_expect_event_count alr_log_entry "${trace}" 1
17821 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17822 echo "entry = '${entry[*]}'" >&2
17825 if [[ "${pfid1}" != "${pfid2}" ]]; then
17826 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17830 if ((size != 524288)); then
17831 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
17835 if [[ "${flags}" != "r" ]]; then
17836 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
17839 run_test 165b "ofd access log entries are produced and consumed"
17842 local trace="/tmp/${tfile}.trace"
17843 local file="${DIR}/${tdir}/${tfile}"
17845 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17846 skip "OFD access log unsupported"
17848 test_mkdir "${DIR}/${tdir}"
17851 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17854 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
17856 # 4096 / 64 = 64. Create twice as many entries.
17857 for ((i = 0; i < 128; i++)); do
17858 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
17859 error "cannot create file"
17864 do_facet ost1 killall -TERM ofd_access_log_reader
17867 if ((rc != 0)); then
17868 error "ofd_access_log_reader exited with rc = '${rc}'"
17871 unlinkmany "${file}-%d" 128
17873 run_test 165c "full ofd access logs do not block IOs"
17875 oal_get_read_count() {
17878 # STATS lustre-OST0001 alr_read_count 1
17880 do_facet ost1 cat "${stats}" |
17881 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
17882 END { print count; }'
17885 oal_expect_read_count() {
17890 # Ask ofd_access_log_reader to write stats.
17891 do_facet ost1 killall -USR1 ofd_access_log_reader
17893 # Allow some time for things to happen.
17896 count=$(oal_get_read_count "${stats}")
17897 if ((count == expect)); then
17901 error_noexit "bad read count, got ${count}, expected ${expect}"
17902 do_facet ost1 cat "${stats}" >&2
17907 local stats="/tmp/${tfile}.stats"
17908 local file="${DIR}/${tdir}/${tfile}"
17909 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
17911 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17912 skip "OFD access log unsupported"
17914 test_mkdir "${DIR}/${tdir}"
17917 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
17920 lfs setstripe -c 1 -i 0 "${file}"
17922 do_facet ost1 lctl set_param "${param}=rw"
17923 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17924 error "cannot create '${file}'"
17925 oal_expect_read_count "${stats}" 1
17927 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17928 error "cannot read '${file}'"
17929 oal_expect_read_count "${stats}" 2
17931 do_facet ost1 lctl set_param "${param}=r"
17932 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17933 error "cannot create '${file}'"
17934 oal_expect_read_count "${stats}" 2
17936 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17937 error "cannot read '${file}'"
17938 oal_expect_read_count "${stats}" 3
17940 do_facet ost1 lctl set_param "${param}=w"
17941 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17942 error "cannot create '${file}'"
17943 oal_expect_read_count "${stats}" 4
17945 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17946 error "cannot read '${file}'"
17947 oal_expect_read_count "${stats}" 4
17949 do_facet ost1 lctl set_param "${param}=0"
17950 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17951 error "cannot create '${file}'"
17952 oal_expect_read_count "${stats}" 4
17954 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17955 error "cannot read '${file}'"
17956 oal_expect_read_count "${stats}" 4
17958 do_facet ost1 killall -TERM ofd_access_log_reader
17961 if ((rc != 0)); then
17962 error "ofd_access_log_reader exited with rc = '${rc}'"
17965 run_test 165d "ofd_access_log mask works"
17968 local stats="/tmp/${tfile}.stats"
17969 local file0="${DIR}/${tdir}-0/${tfile}"
17970 local file1="${DIR}/${tdir}-1/${tfile}"
17972 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17973 skip "OFD access log unsupported"
17975 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
17977 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
17978 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
17980 lfs setstripe -c 1 -i 0 "${file0}"
17981 lfs setstripe -c 1 -i 0 "${file1}"
17984 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
17987 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
17988 error "cannot create '${file0}'"
17990 oal_expect_read_count "${stats}" 0
17992 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
17993 error "cannot create '${file1}'"
17995 oal_expect_read_count "${stats}" 1
17997 do_facet ost1 killall -TERM ofd_access_log_reader
18000 if ((rc != 0)); then
18001 error "ofd_access_log_reader exited with rc = '${rc}'"
18004 run_test 165e "ofd_access_log MDT index filter works"
18007 local trace="/tmp/${tfile}.trace"
18012 do_facet ost1 timeout 60 ofd_access_log_reader \
18013 --exit-on-close --debug=- --trace=- > "${trace}" &
18020 if ((rc != 0)); then
18021 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
18026 run_test 165f "ofd_access_log_reader --exit-on-close works"
18029 # do directio so as not to populate the page cache
18030 log "creating a 10 Mb file"
18031 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
18032 error "multiop failed while creating a file"
18033 log "starting reads"
18034 dd if=$DIR/$tfile of=/dev/null bs=4096 &
18035 log "truncating the file"
18036 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
18037 error "multiop failed while truncating the file"
18039 kill %+ || true # reads might have finished
18040 echo "wait until dd is finished"
18042 log "removing the temporary file"
18043 rm -rf $DIR/$tfile || error "tmp file removal failed"
18045 run_test 169 "parallel read and truncate should not deadlock"
18048 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18050 $LCTL clear # bug 18514
18051 $LCTL debug_daemon start $TMP/${tfile}_log_good
18053 $LCTL debug_daemon stop
18054 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
18055 error "sed failed to read log_good"
18057 $LCTL debug_daemon start $TMP/${tfile}_log_good
18059 $LCTL debug_daemon stop
18061 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
18062 error "lctl df log_bad failed"
18064 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
18065 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
18067 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
18068 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
18070 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
18071 error "bad_line good_line1 good_line2 are empty"
18073 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
18074 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
18075 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
18077 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
18078 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
18079 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
18081 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
18082 error "bad_line_new good_line_new are empty"
18084 local expected_good=$((good_line1 + good_line2*2))
18086 rm -f $TMP/${tfile}*
18087 # LU-231, short malformed line may not be counted into bad lines
18088 if [ $bad_line -ne $bad_line_new ] &&
18089 [ $bad_line -ne $((bad_line_new - 1)) ]; then
18090 error "expected $bad_line bad lines, but got $bad_line_new"
18094 if [ $expected_good -ne $good_line_new ]; then
18095 error "expected $expected_good good lines, but got $good_line_new"
18100 run_test 170 "test lctl df to handle corrupted log ====================="
18102 test_171() { # bug20592
18103 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18105 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
18106 $LCTL set_param fail_loc=0x50e
18107 $LCTL set_param fail_val=3000
18108 multiop_bg_pause $DIR/$tfile O_s || true
18110 kill -USR1 $MULTIPID
18114 if dmesg | grep "recursive fault"; then
18115 error "caught a recursive fault"
18117 $LCTL set_param fail_loc=0
18120 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
18124 #define OBD_FAIL_OBD_CLEANUP 0x60e
18125 $LCTL set_param fail_loc=0x60e
18126 umount $MOUNT || error "umount $MOUNT failed"
18127 stack_trap "mount_client $MOUNT"
18129 (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )) ||
18130 error "no client OBDs are remained"
18132 $LCTL dl | while read devno state type name foo; do
18135 $LCTL --device $name cleanup
18136 $LCTL --device $name detach
18139 # skip server devices
18144 if (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )); then
18145 $LCTL dl | egrep " osc | lov | lmv | mdc "
18146 error "some client OBDs are still remained"
18150 run_test 172 "manual device removal with lctl cleanup/detach ======"
18152 # it would be good to share it with obdfilter-survey/iokit-libecho code
18153 setup_obdecho_osc () {
18156 local obdfilter_name=$2
18157 echo "Creating new osc for $obdfilter_name on $ost_nid"
18158 # make sure we can find loopback nid
18159 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
18161 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
18162 ${obdfilter_name}_osc_UUID || rc=2; }
18163 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
18164 ${obdfilter_name}_UUID $ost_nid || rc=3; }
18168 cleanup_obdecho_osc () {
18169 local obdfilter_name=$1
18170 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
18171 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
18178 local pages=${3:-64}
18183 local obd_size=$(get_obd_size $node $OBD)
18184 local page_size=$(get_page_size $node)
18185 if [[ -n "$obd_size" ]]; then
18186 local new_count=$((obd_size / (pages * page_size / 1024)))
18187 [[ $new_count -ge $count ]] || count=$new_count
18190 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
18191 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
18193 if [ $rc -eq 0 ]; then
18194 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
18195 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
18197 echo "New object id is $id"
18198 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
18200 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
18201 "test_brw $count w v $pages $id" || rc=4; }
18202 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
18204 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
18205 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
18206 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
18207 { do_facet $node "$LCTL --device ec detach" || rc=6; }
18208 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
18213 skip "obdecho on osc is no longer supported"
18215 run_test 180a "test obdecho on osc"
18218 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18219 remote_ost_nodsh && skip "remote OST with nodsh"
18221 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
18222 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
18223 error "failed to load module obdecho"
18225 local target=$(do_facet ost1 $LCTL dl |
18226 awk '/obdfilter/ { print $4; exit; }')
18228 if [ -n "$target" ]; then
18229 obdecho_test $target ost1 || error "obdecho_test failed with $?"
18231 do_facet ost1 $LCTL dl
18232 error "there is no obdfilter target on ost1"
18235 run_test 180b "test obdecho directly on obdfilter"
18237 test_180c() { # LU-2598
18238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18239 remote_ost_nodsh && skip "remote OST with nodsh"
18240 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
18241 skip "Need MDS version at least 2.4.0"
18243 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
18244 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
18245 error "failed to load module obdecho"
18247 local target=$(do_facet ost1 $LCTL dl |
18248 awk '/obdfilter/ { print $4; exit; }')
18250 if [ -n "$target" ]; then
18251 local pages=16384 # 64MB bulk I/O RPC size
18253 obdecho_test "$target" ost1 "$pages" ||
18254 error "obdecho_test with pages=$pages failed with $?"
18256 do_facet ost1 $LCTL dl
18257 error "there is no obdfilter target on ost1"
18260 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
18262 test_181() { # bug 22177
18263 test_mkdir $DIR/$tdir
18264 # create enough files to index the directory
18265 createmany -o $DIR/$tdir/foobar 4000
18266 # print attributes for debug purpose
18269 multiop_bg_pause $DIR/$tdir D_Sc || return 1
18271 # remove the files & current working dir
18272 unlinkmany $DIR/$tdir/foobar 4000
18274 kill -USR1 $MULTIPID
18276 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
18279 run_test 181 "Test open-unlinked dir ========================"
18285 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18287 $LCTL set_param mdc.*.rpc_stats=clear
18289 for (( i = 0; i < $tcount; i++ )) ; do
18290 mkdir $DIR/$tdir/$i
18293 for (( i = 0; i < $tcount; i++ )) ; do
18294 createmany -o $DIR/$tdir/$i/f- $fcount &
18298 for (( i = 0; i < $tcount; i++ )) ; do
18299 unlinkmany $DIR/$tdir/$i/f- $fcount &
18303 $LCTL get_param mdc.*.rpc_stats
18307 run_test 182a "Test parallel modify metadata operations from mdc"
18310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18311 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
18318 do_facet mds1 $LCTL list_param \
18319 osp.$FSNAME-MDT*-osp-MDT*.rpc_stats ||
18320 skip "MDS lacks parallel RPC handling"
18322 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18324 rpc_count=$(do_facet mds1 $LCTL get_param -n \
18325 osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight)
18328 createmany -i 0 -d $DIR/$tdir/t- $tcount
18330 for (( i = 0; i < $tcount; i++ )) ; do
18331 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18335 delta=$((etime - stime))
18336 echo "Time for file creation $delta sec for $rpc_count parallel RPCs"
18339 for (( i = 0; i < $tcount; i++ )) ; do
18340 unlinkmany -d $DIR/$tdir/$i/d- $dcount &
18344 delta=$((etime - stime))
18345 echo "Time for file removal $delta sec for $rpc_count parallel RPCs"
18349 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18351 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=1
18354 createmany -i 0 -d $DIR/$tdir/t- $tcount
18356 for (( i = 0; i < $tcount; i++ )) ; do
18357 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18361 delta=$((etime - stime))
18362 echo "Time for file creation $delta sec for 1 RPC sent at a time"
18365 for (( i = 0; i < $tcount; i++ )) ; do
18366 unlinkmany -d $DIR/$tdir/t-$i/d- $dcount &
18370 delta=$((etime - stime))
18371 echo "Time for file removal $delta sec for 1 RPC sent at a time"
18373 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=$rpc_count
18375 run_test 182b "Test parallel modify metadata operations from osp"
18377 test_183() { # LU-2275
18378 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18379 remote_mds_nodsh && skip "remote MDS with nodsh"
18380 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
18381 skip "Need MDS version at least 2.3.56"
18383 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18384 echo aaa > $DIR/$tdir/$tfile
18386 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
18387 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
18389 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
18390 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
18392 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
18394 # Flush negative dentry cache
18395 touch $DIR/$tdir/$tfile
18397 # We are not checking for any leaked references here, they'll
18398 # become evident next time we do cleanup with module unload.
18401 run_test 183 "No crash or request leak in case of strange dispositions ========"
18403 # test suite 184 is for LU-2016, LU-2017
18405 check_swap_layouts_support
18407 dir0=$DIR/$tdir/$testnum
18408 test_mkdir -p -c1 $dir0
18413 $LFS setstripe -c1 $file1
18415 $LFS setstripe -c2 $file2
18417 gen1=$($LFS getstripe -g $file1)
18418 gen2=$($LFS getstripe -g $file2)
18420 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
18421 gen=$($LFS getstripe -g $file1)
18422 [[ $gen1 != $gen ]] ||
18423 error "Layout generation on $file1 does not change"
18424 gen=$($LFS getstripe -g $file2)
18425 [[ $gen2 != $gen ]] ||
18426 error "Layout generation on $file2 does not change"
18428 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
18429 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
18431 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
18433 run_test 184a "Basic layout swap"
18436 check_swap_layouts_support
18438 dir0=$DIR/$tdir/$testnum
18439 mkdir -p $dir0 || error "creating dir $dir0"
18446 $LFS setstripe -c1 $file1
18447 $LFS setstripe -c2 $file2
18448 $LFS setstripe -c1 $file3
18449 chown $RUNAS_ID $file3
18450 gen1=$($LFS getstripe -g $file1)
18451 gen2=$($LFS getstripe -g $file2)
18453 $LFS swap_layouts $dir1 $dir2 &&
18454 error "swap of directories layouts should fail"
18455 $LFS swap_layouts $dir1 $file1 &&
18456 error "swap of directory and file layouts should fail"
18457 $RUNAS $LFS swap_layouts $file1 $file2 &&
18458 error "swap of file we cannot write should fail"
18459 $LFS swap_layouts $file1 $file3 &&
18460 error "swap of file with different owner should fail"
18461 /bin/true # to clear error code
18463 run_test 184b "Forbidden layout swap (will generate errors)"
18466 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
18467 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
18468 check_swap_layouts_support
18469 check_swap_layout_no_dom $DIR
18471 local dir0=$DIR/$tdir/$testnum
18472 mkdir -p $dir0 || error "creating dir $dir0"
18474 local ref1=$dir0/ref1
18475 local ref2=$dir0/ref2
18476 local file1=$dir0/file1
18477 local file2=$dir0/file2
18478 # create a file large enough for the concurrent test
18479 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
18480 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
18481 echo "ref file size: ref1($(stat -c %s $ref1))," \
18482 "ref2($(stat -c %s $ref2))"
18485 dd if=$ref1 of=$file1 bs=16k &
18488 # Make sure dd starts to copy file, but wait at most 5 seconds
18490 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
18492 $LFS swap_layouts $file1 $file2
18495 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
18496 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
18498 # how many bytes copied before swapping layout
18499 local copied=$(stat -c %s $file2)
18500 local remaining=$(stat -c %s $ref1)
18501 remaining=$((remaining - copied))
18502 echo "Copied $copied bytes before swapping layout..."
18504 cmp -n $copied $file1 $ref2 | grep differ &&
18505 error "Content mismatch [0, $copied) of ref2 and file1"
18506 cmp -n $copied $file2 $ref1 ||
18507 error "Content mismatch [0, $copied) of ref1 and file2"
18508 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
18509 error "Content mismatch [$copied, EOF) of ref1 and file1"
18512 rm -f $ref1 $ref2 $file1 $file2
18514 run_test 184c "Concurrent write and layout swap"
18517 check_swap_layouts_support
18518 check_swap_layout_no_dom $DIR
18519 [ -z "$(which getfattr 2>/dev/null)" ] &&
18520 skip_env "no getfattr command"
18522 local file1=$DIR/$tdir/$tfile-1
18523 local file2=$DIR/$tdir/$tfile-2
18524 local file3=$DIR/$tdir/$tfile-3
18528 mkdir -p $DIR/$tdir
18529 touch $file1 || error "create $file1 failed"
18530 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18531 error "create $file2 failed"
18532 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18533 error "create $file3 failed"
18534 lovea1=$(get_layout_param $file1)
18536 $LFS swap_layouts $file2 $file3 ||
18537 error "swap $file2 $file3 layouts failed"
18538 $LFS swap_layouts $file1 $file2 ||
18539 error "swap $file1 $file2 layouts failed"
18541 lovea2=$(get_layout_param $file2)
18544 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
18546 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18547 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
18549 run_test 184d "allow stripeless layouts swap"
18552 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
18553 skip "Need MDS version at least 2.6.94"
18554 check_swap_layouts_support
18555 check_swap_layout_no_dom $DIR
18556 [ -z "$(which getfattr 2>/dev/null)" ] &&
18557 skip_env "no getfattr command"
18559 local file1=$DIR/$tdir/$tfile-1
18560 local file2=$DIR/$tdir/$tfile-2
18561 local file3=$DIR/$tdir/$tfile-3
18564 mkdir -p $DIR/$tdir
18565 touch $file1 || error "create $file1 failed"
18566 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18567 error "create $file2 failed"
18568 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18569 error "create $file3 failed"
18571 $LFS swap_layouts $file1 $file2 ||
18572 error "swap $file1 $file2 layouts failed"
18574 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18575 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
18577 echo 123 > $file1 || error "Should be able to write into $file1"
18579 $LFS swap_layouts $file1 $file3 ||
18580 error "swap $file1 $file3 layouts failed"
18582 echo 123 > $file1 || error "Should be able to write into $file1"
18584 rm -rf $file1 $file2 $file3
18586 run_test 184e "Recreate layout after stripeless layout swaps"
18589 # Create a file with name longer than sizeof(struct stat) ==
18590 # 144 to see if we can get chars from the file name to appear
18591 # in the returned striping. Note that 'f' == 0x66.
18592 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
18594 mkdir -p $DIR/$tdir
18595 mcreate $DIR/$tdir/$file
18596 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
18597 error "IOC_MDC_GETFILEINFO returned garbage striping"
18600 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
18602 test_185() { # LU-2441
18603 # LU-3553 - no volatile file support in old servers
18604 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
18605 skip "Need MDS version at least 2.3.60"
18607 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18608 touch $DIR/$tdir/spoo
18609 local mtime1=$(stat -c "%Y" $DIR/$tdir)
18610 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
18611 error "cannot create/write a volatile file"
18612 [ "$FILESET" == "" ] &&
18613 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
18614 error "FID is still valid after close"
18616 multiop_bg_pause $DIR/$tdir vVw4096_c
18623 # assume that the next FID for this client is sequential, since stdout
18624 # is unfortunately eaten by multiop_bg_pause
18625 local n=$((${fidv[1]} + 1))
18626 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
18627 if [ "$FILESET" == "" ]; then
18628 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
18629 error "FID is missing before close"
18631 kill -USR1 $multi_pid
18632 # 1 second delay, so if mtime change we will see it
18634 local mtime2=$(stat -c "%Y" $DIR/$tdir)
18635 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
18637 run_test 185 "Volatile file support"
18639 function create_check_volatile() {
18643 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
18646 local FID=$(cat /tmp/${tfile}.fid)
18647 [ "$FID" == "" ] && error "can't get FID for volatile"
18648 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
18649 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
18650 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
18654 cancel_lru_locks mdc # flush opencache
18655 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
18660 # LU-12516 - volatile creation via .lustre
18661 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
18662 skip "Need MDS version at least 2.3.55"
18664 create_check_volatile 0
18665 [ $MDSCOUNT -lt 2 ] && return 0
18668 create_check_volatile 1
18672 run_test 185a "Volatile file creation in .lustre/fid/"
18675 remote_mds_nodsh && skip "remote MDS with nodsh"
18676 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18677 skip "Need MDS version at least 2.3.0"
18679 local dir0=$DIR/$tdir/$testnum
18680 mkdir -p $dir0 || error "creating dir $dir0"
18682 local file=$dir0/file1
18683 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
18684 local dv1=$($LFS data_version $file)
18685 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
18686 local dv2=$($LFS data_version $file)
18687 [[ $dv1 != $dv2 ]] ||
18688 error "data version did not change on write $dv1 == $dv2"
18693 run_test 187a "Test data version change"
18696 remote_mds_nodsh && skip "remote MDS with nodsh"
18697 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18698 skip "Need MDS version at least 2.3.0"
18700 local dir0=$DIR/$tdir/$testnum
18701 mkdir -p $dir0 || error "creating dir $dir0"
18703 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
18704 [[ ${DV[0]} != ${DV[1]} ]] ||
18705 error "data version did not change on write"\
18706 " ${DV[0]} == ${DV[1]}"
18711 run_test 187b "Test data version change on volatile file"
18714 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18715 remote_mgs_nodsh && skip "remote MGS with nodsh"
18716 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
18718 local POOL=${POOL:-cea1}
18719 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
18720 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
18723 local last_ost=$(($OSTCOUNT - 1))
18725 local ost_list=$(seq $first_ost $ost_step $last_ost)
18726 local ost_range="$first_ost $last_ost $ost_step"
18727 local test_path=$POOL_ROOT/$POOL_DIR_NAME
18728 local file_dir=$POOL_ROOT/file_tst
18729 local subdir=$test_path/subdir
18733 # former test_200a test_200b
18734 pool_add $POOL || { rc=$? ; break; }
18735 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
18736 # former test_200c test_200d
18737 mkdir -p $test_path
18738 pool_set_dir $POOL $test_path || { rc=$? ; break; }
18739 pool_check_dir $POOL $test_path || { rc=$? ; break; }
18741 pool_check_dir $POOL $subdir || { rc=$? ; break; }
18742 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
18743 || { rc=$? ; break; }
18744 # former test_200e test_200f
18745 local files=$((OSTCOUNT*3))
18746 pool_alloc_files $POOL $test_path $files "$ost_list" \
18747 || { rc=$? ; break; }
18748 pool_create_files $POOL $file_dir $files "$ost_list" \
18749 || { rc=$? ; break; }
18750 # former test_200g test_200h
18751 pool_lfs_df $POOL || { rc=$? ; break; }
18752 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
18754 # former test_201a test_201b test_201c
18755 pool_remove_first_target $POOL || { rc=$? ; break; }
18757 local f=$test_path/$tfile
18758 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
18759 pool_remove $POOL $f || { rc=$? ; break; }
18767 run_test 200 "OST pools"
18769 # usage: default_attr <count | size | offset>
18771 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
18774 # usage: check_default_stripe_attr
18775 check_default_stripe_attr() {
18776 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
18779 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
18781 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
18785 error "unknown getstripe attr '$1'"
18788 [ $ACTUAL == $EXPECTED ] ||
18789 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
18793 test_mkdir $DIR/$tdir
18794 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
18796 check_default_stripe_attr --stripe-count
18797 check_default_stripe_attr --stripe-size
18798 check_default_stripe_attr --stripe-index
18800 run_test 204a "Print default stripe attributes"
18803 test_mkdir $DIR/$tdir
18804 $LFS setstripe --stripe-count 1 $DIR/$tdir
18806 check_default_stripe_attr --stripe-size
18807 check_default_stripe_attr --stripe-index
18809 run_test 204b "Print default stripe size and offset"
18812 test_mkdir $DIR/$tdir
18813 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18815 check_default_stripe_attr --stripe-count
18816 check_default_stripe_attr --stripe-index
18818 run_test 204c "Print default stripe count and offset"
18821 test_mkdir $DIR/$tdir
18822 $LFS setstripe --stripe-index 0 $DIR/$tdir
18824 check_default_stripe_attr --stripe-count
18825 check_default_stripe_attr --stripe-size
18827 run_test 204d "Print default stripe count and size"
18830 test_mkdir $DIR/$tdir
18831 $LFS setstripe -d $DIR/$tdir
18833 check_default_stripe_attr --stripe-count --raw
18834 check_default_stripe_attr --stripe-size --raw
18835 check_default_stripe_attr --stripe-index --raw
18837 run_test 204e "Print raw stripe attributes"
18840 test_mkdir $DIR/$tdir
18841 $LFS setstripe --stripe-count 1 $DIR/$tdir
18843 check_default_stripe_attr --stripe-size --raw
18844 check_default_stripe_attr --stripe-index --raw
18846 run_test 204f "Print raw stripe size and offset"
18849 test_mkdir $DIR/$tdir
18850 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18852 check_default_stripe_attr --stripe-count --raw
18853 check_default_stripe_attr --stripe-index --raw
18855 run_test 204g "Print raw stripe count and offset"
18858 test_mkdir $DIR/$tdir
18859 $LFS setstripe --stripe-index 0 $DIR/$tdir
18861 check_default_stripe_attr --stripe-count --raw
18862 check_default_stripe_attr --stripe-size --raw
18864 run_test 204h "Print raw stripe count and size"
18866 # Figure out which job scheduler is being used, if any,
18867 # or use a fake one
18868 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
18869 JOBENV=SLURM_JOB_ID
18870 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
18872 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
18874 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
18875 JOBENV=LOADL_STEP_ID
18876 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
18879 $LCTL list_param jobid_name > /dev/null 2>&1
18880 if [ $? -eq 0 ]; then
18886 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
18888 verify_jobstats() {
18893 # we don't really need to clear the stats for this test to work, since each
18894 # command has a unique jobid, but it makes debugging easier if needed.
18895 # for facet in $facets; do
18896 # local dev=$(convert_facet2label $facet)
18897 # # clear old jobstats
18898 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
18901 # use a new JobID for each test, or we might see an old one
18902 [ "$JOBENV" = "FAKE_JOBID" ] &&
18903 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
18905 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
18907 [ "$JOBENV" = "nodelocal" ] && {
18908 FAKE_JOBID=id.$testnum.%e.$RANDOM
18909 $LCTL set_param jobid_name=$FAKE_JOBID
18910 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
18913 log "Test: ${cmd[*]}"
18914 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
18916 if [ $JOBENV = "FAKE_JOBID" ]; then
18917 FAKE_JOBID=$JOBVAL ${cmd[*]}
18922 # all files are created on OST0000
18923 for facet in $facets; do
18924 local stats="*.$(convert_facet2label $facet).job_stats"
18926 # strip out libtool wrappers for in-tree executables
18927 if (( $(do_facet $facet lctl get_param $stats |
18928 sed -e 's/\.lt-/./' | grep -cw $JOBVAL) != 1 )); then
18929 do_facet $facet lctl get_param $stats
18930 error "No jobstats for $JOBVAL found on $facet::$stats"
18936 local new_jobenv=$1
18938 set_persistent_param_and_check client "jobid_var" \
18939 "$FSNAME.sys.jobid_var" $new_jobenv
18942 test_205a() { # Job stats
18943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18944 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
18945 skip "Need MDS version with at least 2.7.1"
18946 remote_mgs_nodsh && skip "remote MGS with nodsh"
18947 remote_mds_nodsh && skip "remote MDS with nodsh"
18948 remote_ost_nodsh && skip "remote OST with nodsh"
18949 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
18950 skip "Server doesn't support jobstats"
18951 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
18953 local old_jobenv=$($LCTL get_param -n jobid_var)
18954 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
18956 if [[ $PERM_CMD == *"set_param -P"* ]]; then
18957 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
18959 stack_trap "do_facet mgs $PERM_CMD \
18960 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
18964 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
18965 mdt.*.job_cleanup_interval | head -n 1)
18966 local new_interval=5
18967 do_facet $SINGLEMDS \
18968 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
18969 stack_trap "do_facet $SINGLEMDS \
18970 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
18971 local start=$SECONDS
18975 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
18976 verify_jobstats "$cmd" "$SINGLEMDS"
18978 cmd="rmdir $DIR/$tdir"
18979 verify_jobstats "$cmd" "$SINGLEMDS"
18980 # mkdir on secondary MDT
18981 if [ $MDSCOUNT -gt 1 ]; then
18982 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
18983 verify_jobstats "$cmd" "mds2"
18986 cmd="mknod $DIR/$tfile c 1 3"
18987 verify_jobstats "$cmd" "$SINGLEMDS"
18989 cmd="rm -f $DIR/$tfile"
18990 verify_jobstats "$cmd" "$SINGLEMDS"
18991 # create all files on OST0000 so verify_jobstats can find OST stats
18993 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
18994 verify_jobstats "$cmd" "$SINGLEMDS"
18996 cmd="touch $DIR/$tfile"
18997 verify_jobstats "$cmd" "$SINGLEMDS ost1"
18999 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
19000 verify_jobstats "$cmd" "ost1"
19002 cancel_lru_locks osc
19003 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
19004 verify_jobstats "$cmd" "ost1"
19006 cmd="$TRUNCATE $DIR/$tfile 0"
19007 verify_jobstats "$cmd" "$SINGLEMDS ost1"
19009 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
19010 verify_jobstats "$cmd" "$SINGLEMDS"
19011 # jobstats expiry - sleep until old stats should be expired
19012 local left=$((new_interval + 5 - (SECONDS - start)))
19013 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
19014 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
19016 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
19017 verify_jobstats "$cmd" "$SINGLEMDS"
19018 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
19019 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
19021 # Ensure that jobid are present in changelog (if supported by MDS)
19022 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
19023 changelog_dump | tail -10
19024 jobids=$(changelog_dump | tail -9 | grep -c "j=")
19025 [ $jobids -eq 9 ] ||
19026 error "Wrong changelog jobid count $jobids != 9"
19030 jobstats_set $JOBENV
19032 changelog_dump | grep $tfile
19033 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
19034 [ $jobids -eq 0 ] ||
19035 error "Unexpected jobids when jobid_var=$JOBENV"
19038 # test '%j' access to environment variable - if supported
19039 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
19040 JOBENV="JOBCOMPLEX"
19041 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
19043 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19046 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
19047 JOBENV="JOBCOMPLEX"
19048 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
19050 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19053 # test '%j' access to per-session jobid - if supported
19054 if lctl list_param jobid_this_session > /dev/null 2>&1
19056 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
19057 lctl set_param jobid_this_session=$USER
19059 JOBENV="JOBCOMPLEX"
19060 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
19062 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19065 run_test 205a "Verify job stats"
19067 # LU-13117, LU-13597
19069 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
19070 skip "Need MDS version at least 2.13.54.91"
19072 local job_stats="mdt.*.job_stats"
19073 local old_jobid=$(do_facet mds1 $LCTL get_param jobid_var)
19075 do_facet mds1 $LCTL set_param $job_stats=clear
19077 # Setting jobid_var to USER might not be supported
19078 [[ -n "$old_jobid" ]] && stack_trap "$LCTL set_param $old_jobid"
19079 $LCTL set_param jobid_var=USER || true
19080 stack_trap "$LCTL set_param $($LCTL get_param jobid_name)"
19081 $LCTL set_param jobid_name="%j.%e.%u"
19083 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
19084 do_facet mds1 $LCTL get_param $job_stats | grep "job_id:.*foolish" &&
19085 { do_facet mds1 $LCTL get_param $job_stats;
19086 error "Unexpected jobid found"; }
19087 do_facet mds1 $LCTL get_param $job_stats | grep "open:.*min.*max.*sum"||
19088 { do_facet mds1 $LCTL get_param $job_stats;
19089 error "wrong job_stats format found"; }
19091 (( $MDS1_VERSION <= $(version_code 2.15.0) )) &&
19092 echo "MDS does not yet escape jobid" && return 0
19093 $LCTL set_param jobid_var=TEST205b
19094 env -i TEST205b="has sp" touch $DIR/$tfile.2
19095 do_facet mds1 $LCTL get_param $job_stats | grep "has.*x20sp" ||
19096 { do_facet mds1 $LCTL get_param $job_stats;
19097 error "jobid not escaped"; }
19099 run_test 205b "Verify job stats jobid and output format"
19103 $LCTL set_param llite.*.stats=0
19104 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
19105 $LCTL get_param llite.*.stats
19106 $LCTL get_param llite.*.stats | grep \
19107 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
19108 error "wrong client stats format found"
19110 run_test 205c "Verify client stats format"
19112 # LU-1480, LU-1773 and LU-1657
19114 mkdir -p $DIR/$tdir
19115 $LFS setstripe -c -1 $DIR/$tdir
19116 #define OBD_FAIL_LOV_INIT 0x1403
19117 $LCTL set_param fail_loc=0xa0001403
19118 $LCTL set_param fail_val=1
19119 touch $DIR/$tdir/$tfile || true
19121 run_test 206 "fail lov_init_raid0() doesn't lbug"
19124 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
19125 local fsz=`stat -c %s $DIR/$tfile`
19126 cancel_lru_locks mdc
19128 # do not return layout in getattr intent
19129 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
19130 $LCTL set_param fail_loc=0x170
19131 local sz=`stat -c %s $DIR/$tfile`
19133 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
19137 run_test 207a "can refresh layout at glimpse"
19140 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
19141 local cksum=`md5sum $DIR/$tfile`
19142 local fsz=`stat -c %s $DIR/$tfile`
19143 cancel_lru_locks mdc
19144 cancel_lru_locks osc
19146 # do not return layout in getattr intent
19147 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
19148 $LCTL set_param fail_loc=0x171
19150 # it will refresh layout after the file is opened but before read issues
19151 echo checksum is "$cksum"
19152 echo "$cksum" |md5sum -c --quiet || error "file differs"
19156 run_test 207b "can refresh layout at open"
19159 # FIXME: in this test suite, only RD lease is used. This is okay
19160 # for now as only exclusive open is supported. After generic lease
19161 # is done, this test suite should be revised. - Jinshan
19163 remote_mds_nodsh && skip "remote MDS with nodsh"
19164 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
19165 skip "Need MDS version at least 2.4.52"
19167 echo "==== test 1: verify get lease work"
19168 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
19170 echo "==== test 2: verify lease can be broken by upcoming open"
19171 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
19175 $MULTIOP $DIR/$tfile oO_RDWR:c
19176 kill -USR1 $PID && wait $PID || error "break lease error"
19178 echo "==== test 3: verify lease can't be granted if an open already exists"
19179 $MULTIOP $DIR/$tfile oO_RDWR:_c &
19183 $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
19184 kill -USR1 $PID && wait $PID || error "open file error"
19186 echo "==== test 4: lease can sustain over recovery"
19187 $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
19193 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
19195 echo "==== test 5: lease broken can't be regained by replay"
19196 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
19200 # open file to break lease and then recovery
19201 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
19204 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
19208 run_test 208 "Exclusive open"
19211 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
19212 skip_env "must have disp_stripe"
19215 sync; sleep 5; sync;
19217 echo 3 > /proc/sys/vm/drop_caches
19218 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
19219 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
19220 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
19222 # open/close 500 times
19223 for i in $(seq 500); do
19227 echo 3 > /proc/sys/vm/drop_caches
19228 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
19229 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
19230 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
19232 echo "before: $req_before, after: $req_after"
19233 [ $((req_after - req_before)) -ge 300 ] &&
19234 error "open/close requests are not freed"
19237 run_test 209 "read-only open/close requests should be freed promptly"
19242 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
19246 $LFS getstripe $DIR/$tfile
19248 wait $pid || error "multiop failed"
19250 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
19254 $LFS getstripe $DIR/$tfile
19256 wait $pid || error "multiop failed"
19258 run_test 210 "lfs getstripe does not break leases"
19262 size=$((size % 8192 + 1))
19263 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
19264 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
19265 rm -f $DIR/f212 $DIR/f212.xyz
19267 run_test 212 "Sendfile test ============================================"
19270 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
19271 cancel_lru_locks osc
19272 lctl set_param fail_loc=0x8000040f
19273 # generate a read lock
19274 cat $DIR/$tfile > /dev/null
19275 # write to the file, it will try to cancel the above read lock.
19276 cat /etc/hosts >> $DIR/$tfile
19278 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
19280 test_214() { # for bug 20133
19281 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
19282 for (( i=0; i < 340; i++ )) ; do
19283 touch $DIR/$tdir/d214c/a$i
19286 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
19287 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
19288 ls $DIR/d214c || error "ls $DIR/d214c failed"
19289 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
19290 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
19292 run_test 214 "hash-indexed directory test - bug 20133"
19294 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
19295 create_lnet_proc_files() {
19296 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
19299 # counterpart of create_lnet_proc_files
19300 remove_lnet_proc_files() {
19301 rm -f $TMP/lnet_$1.sys
19304 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19305 # 3rd arg as regexp for body
19306 check_lnet_proc_stats() {
19307 local l=$(cat "$TMP/lnet_$1" |wc -l)
19308 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
19310 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
19313 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19314 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
19315 # optional and can be regexp for 2nd line (lnet.routes case)
19316 check_lnet_proc_entry() {
19317 local blp=2 # blp stands for 'position of 1st line of body'
19318 [ -z "$5" ] || blp=3 # lnet.routes case
19320 local l=$(cat "$TMP/lnet_$1" |wc -l)
19321 # subtracting one from $blp because the body can be empty
19322 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
19324 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
19325 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
19327 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
19328 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
19330 # bail out if any unexpected line happened
19331 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
19332 [ "$?" != 0 ] || error "$2 misformatted"
19335 test_215() { # for bugs 18102, 21079, 21517
19336 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19338 local N='(0|[1-9][0-9]*)' # non-negative numeric
19339 local P='[1-9][0-9]*' # positive numeric
19340 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
19341 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
19342 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
19343 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
19345 local L1 # regexp for 1st line
19346 local L2 # regexp for 2nd line (optional)
19347 local BR # regexp for the rest (body)
19349 # lnet.stats should look as 11 space-separated non-negative numerics
19350 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
19351 create_lnet_proc_files "stats"
19352 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
19353 remove_lnet_proc_files "stats"
19355 # lnet.routes should look like this:
19356 # Routing disabled/enabled
19357 # net hops priority state router
19358 # where net is a string like tcp0, hops > 0, priority >= 0,
19359 # state is up/down,
19360 # router is a string like 192.168.1.1@tcp2
19361 L1="^Routing (disabled|enabled)$"
19362 L2="^net +hops +priority +state +router$"
19363 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
19364 create_lnet_proc_files "routes"
19365 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
19366 remove_lnet_proc_files "routes"
19368 # lnet.routers should look like this:
19369 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
19370 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
19371 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
19372 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
19373 L1="^ref +rtr_ref +alive +router$"
19374 BR="^$P +$P +(up|down) +$NID$"
19375 create_lnet_proc_files "routers"
19376 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
19377 remove_lnet_proc_files "routers"
19379 # lnet.peers should look like this:
19380 # nid refs state last max rtr min tx min queue
19381 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
19382 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
19383 # numeric (0 or >0 or <0), queue >= 0.
19384 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
19385 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
19386 create_lnet_proc_files "peers"
19387 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
19388 remove_lnet_proc_files "peers"
19390 # lnet.buffers should look like this:
19391 # pages count credits min
19392 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
19393 L1="^pages +count +credits +min$"
19394 BR="^ +$N +$N +$I +$I$"
19395 create_lnet_proc_files "buffers"
19396 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
19397 remove_lnet_proc_files "buffers"
19399 # lnet.nis should look like this:
19400 # nid status alive refs peer rtr max tx min
19401 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
19402 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
19403 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
19404 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
19405 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
19406 create_lnet_proc_files "nis"
19407 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
19408 remove_lnet_proc_files "nis"
19410 # can we successfully write to lnet.stats?
19411 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
19413 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
19415 test_216() { # bug 20317
19416 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19417 remote_ost_nodsh && skip "remote OST with nodsh"
19420 local facets=$(get_facets OST)
19421 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19423 save_lustre_params client "osc.*.contention_seconds" > $p
19424 save_lustre_params $facets \
19425 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
19426 save_lustre_params $facets \
19427 "ldlm.namespaces.filter-*.contended_locks" >> $p
19428 save_lustre_params $facets \
19429 "ldlm.namespaces.filter-*.contention_seconds" >> $p
19430 clear_stats osc.*.osc_stats
19432 # agressive lockless i/o settings
19433 do_nodes $(comma_list $(osts_nodes)) \
19434 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
19435 ldlm.namespaces.filter-*.contended_locks=0 \
19436 ldlm.namespaces.filter-*.contention_seconds=60"
19437 lctl set_param -n osc.*.contention_seconds=60
19439 $DIRECTIO write $DIR/$tfile 0 10 4096
19440 $CHECKSTAT -s 40960 $DIR/$tfile
19442 # disable lockless i/o
19443 do_nodes $(comma_list $(osts_nodes)) \
19444 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
19445 ldlm.namespaces.filter-*.contended_locks=32 \
19446 ldlm.namespaces.filter-*.contention_seconds=0"
19447 lctl set_param -n osc.*.contention_seconds=0
19448 clear_stats osc.*.osc_stats
19450 dd if=/dev/zero of=$DIR/$tfile count=0
19451 $CHECKSTAT -s 0 $DIR/$tfile
19453 restore_lustre_params <$p
19457 run_test 216 "check lockless direct write updates file size and kms correctly"
19459 test_217() { # bug 22430
19460 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19465 for node in $(nodes_list); do
19466 nid=$(host_nids_address $node $NETTYPE)
19467 if [[ $nid = *-* ]] ; then
19468 echo "lctl ping $(h2nettype $nid)"
19469 lctl ping $(h2nettype $nid)
19471 echo "skipping $node (no hyphen detected)"
19475 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
19478 # do directio so as not to populate the page cache
19479 log "creating a 10 Mb file"
19480 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
19481 log "starting reads"
19482 dd if=$DIR/$tfile of=/dev/null bs=4096 &
19483 log "truncating the file"
19484 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
19486 kill %+ || true # reads might have finished
19487 echo "wait until dd is finished"
19489 log "removing the temporary file"
19490 rm -rf $DIR/$tfile || error "tmp file removal failed"
19492 run_test 218 "parallel read and truncate should not deadlock"
19495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19497 # write one partial page
19498 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
19499 # set no grant so vvp_io_commit_write will do sync write
19500 $LCTL set_param fail_loc=0x411
19501 # write a full page at the end of file
19502 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
19504 $LCTL set_param fail_loc=0
19505 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
19506 $LCTL set_param fail_loc=0x411
19507 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
19510 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
19511 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
19513 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
19515 test_220() { #LU-325
19516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19517 remote_ost_nodsh && skip "remote OST with nodsh"
19518 remote_mds_nodsh && skip "remote MDS with nodsh"
19519 remote_mgs_nodsh && skip "remote MGS with nodsh"
19523 # create on MDT0000 so the last_id and next_id are correct
19524 mkdir_on_mdt0 $DIR/$tdir
19525 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
19529 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
19530 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
19531 osp.$mdtosc_proc1.prealloc_last_id)
19532 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
19533 osp.$mdtosc_proc1.prealloc_next_id)
19537 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
19538 #define OBD_FAIL_OST_ENOINO 0x229
19539 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
19540 create_pool $FSNAME.$TESTNAME || return 1
19541 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
19543 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
19545 MDSOBJS=$((last_id - next_id))
19546 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
19548 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
19549 echo "OST still has $count kbytes free"
19551 echo "create $MDSOBJS files @next_id..."
19552 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
19554 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19555 osp.$mdtosc_proc1.prealloc_last_id)
19556 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19557 osp.$mdtosc_proc1.prealloc_next_id)
19559 echo "after creation, last_id=$last_id2, next_id=$next_id2"
19564 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
19565 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
19567 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
19568 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
19569 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
19570 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
19571 echo "unlink $MDSOBJS files @$next_id..."
19572 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
19574 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
19577 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19579 dd if=`which date` of=$MOUNT/date oflag=sync
19580 chmod +x $MOUNT/date
19582 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
19583 $LCTL set_param fail_loc=0x80001401
19585 $MOUNT/date > /dev/null
19588 run_test 221 "make sure fault and truncate race to not cause OOM"
19591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19594 test_mkdir $DIR/$tdir
19595 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19596 createmany -o $DIR/$tdir/$tfile 10
19597 cancel_lru_locks mdc
19598 cancel_lru_locks osc
19599 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19600 $LCTL set_param fail_loc=0x31a
19601 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
19602 $LCTL set_param fail_loc=0
19605 run_test 222a "AGL for ls should not trigger CLIO lock failure"
19608 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19611 test_mkdir $DIR/$tdir
19612 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19613 createmany -o $DIR/$tdir/$tfile 10
19614 cancel_lru_locks mdc
19615 cancel_lru_locks osc
19616 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19617 $LCTL set_param fail_loc=0x31a
19618 rm -r $DIR/$tdir || error "AGL for rmdir failed"
19619 $LCTL set_param fail_loc=0
19621 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
19624 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19627 test_mkdir $DIR/$tdir
19628 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19629 createmany -o $DIR/$tdir/$tfile 10
19630 cancel_lru_locks mdc
19631 cancel_lru_locks osc
19632 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
19633 $LCTL set_param fail_loc=0x31b
19634 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
19635 $LCTL set_param fail_loc=0
19638 run_test 223 "osc reenqueue if without AGL lock granted ======================="
19640 test_224a() { # LU-1039, MRP-303
19641 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19642 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
19643 $LCTL set_param fail_loc=0x508
19644 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fsync
19645 $LCTL set_param fail_loc=0
19648 run_test 224a "Don't panic on bulk IO failure"
19650 test_224bd_sub() { # LU-1039, MRP-303
19651 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19655 dd if=/dev/urandom of=$TMP/$tfile bs=1M count=1
19657 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19659 dd if=$TMP/$tfile of=$DIR/$tfile bs=1M count=1
19660 cancel_lru_locks osc
19662 stack_trap "set_checksums $ORIG_CSUM" EXIT
19663 local at_max_saved=0
19665 # adaptive timeouts may prevent seeing the issue
19666 if at_is_enabled; then
19667 at_max_saved=$(at_max_get mds)
19668 at_max_set 0 mds client
19669 stack_trap "at_max_set $at_max_saved mds client" EXIT
19672 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
19673 do_facet ost1 $LCTL set_param fail_val=$timeout fail_loc=0x80000515
19674 dd of=$TMP/$tfile.new if=$DIR/$tfile bs=1M count=1 || "$@"
19676 do_facet ost1 $LCTL set_param fail_loc=0
19677 cmp $TMP/$tfile $TMP/$tfile.new || error "file contents wrong"
19682 test_224bd_sub 3 error "dd failed"
19684 run_test 224b "Don't panic on bulk IO failure"
19686 test_224c() { # LU-6441
19687 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19688 remote_mds_nodsh && skip "remote MDS with nodsh"
19690 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19691 save_writethrough $p
19692 set_cache writethrough on
19694 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
19695 local at_max=$($LCTL get_param -n at_max)
19696 local timeout=$($LCTL get_param -n timeout)
19697 local test_at="at_max"
19698 local param_at="$FSNAME.sys.at_max"
19699 local test_timeout="timeout"
19700 local param_timeout="$FSNAME.sys.timeout"
19702 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
19704 set_persistent_param_and_check client "$test_at" "$param_at" 0
19705 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
19707 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
19708 do_facet ost1 "$LCTL set_param fail_loc=0x520"
19709 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19710 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
19712 do_facet ost1 "$LCTL set_param fail_loc=0"
19714 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
19715 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
19718 $LCTL set_param -n $pages_per_rpc
19719 restore_lustre_params < $p
19722 run_test 224c "Don't hang if one of md lost during large bulk RPC"
19724 test_224d() { # LU-11169
19725 test_224bd_sub $((TIMEOUT + 2)) error "dd failed"
19727 run_test 224d "Don't corrupt data on bulk IO timeout"
19729 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
19731 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19732 if [ -z ${MDSSURVEY} ]; then
19733 skip_env "mds-survey not found"
19735 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19736 skip "Need MDS version at least 2.2.51"
19738 local mds=$(facet_host $SINGLEMDS)
19739 local target=$(do_nodes $mds 'lctl dl' |
19740 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19742 local cmd1="file_count=1000 thrhi=4"
19743 local cmd2="dir_count=2 layer=mdd stripe_count=0"
19744 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19745 local cmd="$cmd1 $cmd2 $cmd3"
19747 rm -f ${TMP}/mds_survey*
19749 eval $cmd || error "mds-survey with zero-stripe failed"
19750 cat ${TMP}/mds_survey*
19751 rm -f ${TMP}/mds_survey*
19753 run_test 225a "Metadata survey sanity with zero-stripe"
19756 if [ -z ${MDSSURVEY} ]; then
19757 skip_env "mds-survey not found"
19759 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19760 skip "Need MDS version at least 2.2.51"
19761 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19762 remote_mds_nodsh && skip "remote MDS with nodsh"
19763 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
19764 skip_env "Need to mount OST to test"
19767 local mds=$(facet_host $SINGLEMDS)
19768 local target=$(do_nodes $mds 'lctl dl' |
19769 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19771 local cmd1="file_count=1000 thrhi=4"
19772 local cmd2="dir_count=2 layer=mdd stripe_count=1"
19773 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19774 local cmd="$cmd1 $cmd2 $cmd3"
19776 rm -f ${TMP}/mds_survey*
19778 eval $cmd || error "mds-survey with stripe_count failed"
19779 cat ${TMP}/mds_survey*
19780 rm -f ${TMP}/mds_survey*
19782 run_test 225b "Metadata survey sanity with stripe_count = 1"
19784 mcreate_path2fid () {
19790 local path=$DIR/$tdir/$name
19795 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
19796 error "cannot create $desc"
19798 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
19800 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
19802 fid_path=$($LFS fid2path $MOUNT $fid)
19804 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
19806 [ "$path" == "$fid_path" ] ||
19807 error "fid2path returned $fid_path, expected $path"
19809 echo "pass with $path and $fid"
19814 mkdir -p $DIR/$tdir
19816 mcreate_path2fid 0010666 0 0 fifo "FIFO"
19817 mcreate_path2fid 0020666 1 3 null "character special file (null)"
19818 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
19819 mcreate_path2fid 0040666 0 0 dir "directory"
19820 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
19821 mcreate_path2fid 0100666 0 0 file "regular file"
19822 mcreate_path2fid 0120666 0 0 link "symbolic link"
19823 mcreate_path2fid 0140666 0 0 sock "socket"
19825 run_test 226a "call path2fid and fid2path on files of all type"
19828 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19833 mkdir -p $DIR/$tdir
19834 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
19835 error "create remote directory failed"
19836 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
19837 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
19838 "character special file (null)"
19839 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
19840 "character special file (no device)"
19841 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
19842 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
19843 "block special file (loop)"
19844 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
19845 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
19846 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
19848 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
19851 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19852 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
19853 skip "Need MDS version at least 2.13.55"
19855 local submnt=/mnt/submnt
19856 local srcfile=/etc/passwd
19857 local dstfile=$submnt/passwd
19863 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
19864 error "create remote directory failed"
19865 mkdir -p $submnt || error "create $submnt failed"
19866 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
19867 error "mount $submnt failed"
19868 stack_trap "umount $submnt" EXIT
19870 cp $srcfile $dstfile
19871 fid=$($LFS path2fid $dstfile)
19872 path=$($LFS fid2path $submnt "$fid")
19873 [ "$path" = "$dstfile" ] ||
19874 error "fid2path $submnt $fid failed ($path != $dstfile)"
19876 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
19878 # LU-1299 Executing or running ldd on a truncated executable does not
19879 # cause an out-of-memory condition.
19881 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19882 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
19884 dd if=$(which date) of=$MOUNT/date bs=1k count=1
19885 chmod +x $MOUNT/date
19887 $MOUNT/date > /dev/null
19888 ldd $MOUNT/date > /dev/null
19891 run_test 227 "running truncated executable does not cause OOM"
19893 # LU-1512 try to reuse idle OI blocks
19895 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19896 remote_mds_nodsh && skip "remote MDS with nodsh"
19897 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19899 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19900 local myDIR=$DIR/$tdir
19903 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19904 $LCTL set_param fail_loc=0x80001002
19905 createmany -o $myDIR/t- 10000
19906 $LCTL set_param fail_loc=0
19907 # The guard is current the largest FID holder
19909 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19911 local IDX=$(($SEQ % 64))
19913 do_facet $SINGLEMDS sync
19914 # Make sure journal flushed.
19916 local blk1=$(do_facet $SINGLEMDS \
19917 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19918 grep Blockcount | awk '{print $4}')
19920 # Remove old files, some OI blocks will become idle.
19921 unlinkmany $myDIR/t- 10000
19922 # Create new files, idle OI blocks should be reused.
19923 createmany -o $myDIR/t- 2000
19924 do_facet $SINGLEMDS sync
19925 # Make sure journal flushed.
19927 local blk2=$(do_facet $SINGLEMDS \
19928 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19929 grep Blockcount | awk '{print $4}')
19931 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19933 run_test 228a "try to reuse idle OI blocks"
19936 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19937 remote_mds_nodsh && skip "remote MDS with nodsh"
19938 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19940 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19941 local myDIR=$DIR/$tdir
19944 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19945 $LCTL set_param fail_loc=0x80001002
19946 createmany -o $myDIR/t- 10000
19947 $LCTL set_param fail_loc=0
19948 # The guard is current the largest FID holder
19950 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19952 local IDX=$(($SEQ % 64))
19954 do_facet $SINGLEMDS sync
19955 # Make sure journal flushed.
19957 local blk1=$(do_facet $SINGLEMDS \
19958 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19959 grep Blockcount | awk '{print $4}')
19961 # Remove old files, some OI blocks will become idle.
19962 unlinkmany $myDIR/t- 10000
19965 stop $SINGLEMDS || error "Fail to stop MDT."
19967 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
19968 error "Fail to start MDT."
19970 df $MOUNT || error "Fail to df."
19971 # Create new files, idle OI blocks should be reused.
19972 createmany -o $myDIR/t- 2000
19973 do_facet $SINGLEMDS sync
19974 # Make sure journal flushed.
19976 local blk2=$(do_facet $SINGLEMDS \
19977 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19978 grep Blockcount | awk '{print $4}')
19980 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19982 run_test 228b "idle OI blocks can be reused after MDT restart"
19986 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19987 remote_mds_nodsh && skip "remote MDS with nodsh"
19988 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19990 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19991 local myDIR=$DIR/$tdir
19994 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19995 $LCTL set_param fail_loc=0x80001002
19996 # 20000 files can guarantee there are index nodes in the OI file
19997 createmany -o $myDIR/t- 20000
19998 $LCTL set_param fail_loc=0
19999 # The guard is current the largest FID holder
20001 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
20003 local IDX=$(($SEQ % 64))
20005 do_facet $SINGLEMDS sync
20006 # Make sure journal flushed.
20008 local blk1=$(do_facet $SINGLEMDS \
20009 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20010 grep Blockcount | awk '{print $4}')
20012 # Remove old files, some OI blocks will become idle.
20013 unlinkmany $myDIR/t- 20000
20015 # The OI file should become empty now
20017 # Create new files, idle OI blocks should be reused.
20018 createmany -o $myDIR/t- 2000
20019 do_facet $SINGLEMDS sync
20020 # Make sure journal flushed.
20022 local blk2=$(do_facet $SINGLEMDS \
20023 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20024 grep Blockcount | awk '{print $4}')
20026 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
20028 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
20030 test_229() { # LU-2482, LU-3448
20031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20032 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
20033 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
20034 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
20038 # Create a file with a released layout and stripe count 2.
20039 $MULTIOP $DIR/$tfile H2c ||
20040 error "failed to create file with released layout"
20042 $LFS getstripe -v $DIR/$tfile
20044 local pattern=$($LFS getstripe -L $DIR/$tfile)
20045 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
20047 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
20049 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
20050 stat $DIR/$tfile || error "failed to stat released file"
20052 chown $RUNAS_ID $DIR/$tfile ||
20053 error "chown $RUNAS_ID $DIR/$tfile failed"
20055 chgrp $RUNAS_ID $DIR/$tfile ||
20056 error "chgrp $RUNAS_ID $DIR/$tfile failed"
20058 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
20059 rm $DIR/$tfile || error "failed to remove released file"
20061 run_test 229 "getstripe/stat/rm/attr changes work on released files"
20064 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20065 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20066 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20067 skip "Need MDS version at least 2.11.52"
20071 test_mkdir $DIR/$tdir
20072 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
20073 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
20074 [ $mdt_idx -ne 0 ] &&
20075 error "create local directory on wrong MDT $mdt_idx"
20077 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
20078 error "create remote directory failed"
20079 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
20080 [ $mdt_idx -ne $MDTIDX ] &&
20081 error "create remote directory on wrong MDT $mdt_idx"
20083 createmany -o $DIR/$tdir/test_230/t- 10 ||
20084 error "create files on remote directory failed"
20085 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
20086 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
20087 rm -r $DIR/$tdir || error "unlink remote directory failed"
20089 run_test 230a "Create remote directory and files under the remote directory"
20092 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20093 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20094 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20095 skip "Need MDS version at least 2.11.52"
20103 local migrate_dir=$DIR/$tdir/migrate_dir
20104 local other_dir=$DIR/$tdir/other_dir
20106 test_mkdir $DIR/$tdir
20107 test_mkdir -i0 -c1 $migrate_dir
20108 test_mkdir -i0 -c1 $other_dir
20109 for ((i=0; i<10; i++)); do
20110 mkdir -p $migrate_dir/dir_${i}
20111 createmany -o $migrate_dir/dir_${i}/f 10 ||
20112 error "create files under remote dir failed $i"
20115 cp /etc/passwd $migrate_dir/$tfile
20116 cp /etc/passwd $other_dir/$tfile
20117 chattr +SAD $migrate_dir
20118 chattr +SAD $migrate_dir/$tfile
20120 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20121 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20122 local old_dir_mode=$(stat -c%f $migrate_dir)
20123 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
20125 mkdir -p $migrate_dir/dir_default_stripe2
20126 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
20127 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
20129 mkdir -p $other_dir
20130 ln $migrate_dir/$tfile $other_dir/luna
20131 ln $migrate_dir/$tfile $migrate_dir/sofia
20132 ln $other_dir/$tfile $migrate_dir/david
20133 ln -s $migrate_dir/$tfile $other_dir/zachary
20134 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
20135 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
20141 for len in 58 59 60; do
20142 lnktgt=$(str_repeat 'l' $len)
20143 touch $migrate_dir/$lnktgt
20144 ln -s $lnktgt $migrate_dir/${len}char_ln
20148 for len in 4094 4095; do
20149 lnktgt=$(str_repeat 'l' $len)
20150 ln -s $lnktgt $migrate_dir/${len}char_ln
20154 for len in 254 255; do
20155 touch $migrate_dir/$(str_repeat 'l' $len)
20158 $LFS migrate -m $MDTIDX $migrate_dir ||
20159 error "fails on migrating remote dir to MDT1"
20161 echo "migratate to MDT1, then checking.."
20162 for ((i = 0; i < 10; i++)); do
20163 for file in $(find $migrate_dir/dir_${i}); do
20164 mdt_index=$($LFS getstripe -m $file)
20165 # broken symlink getstripe will fail
20166 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
20167 error "$file is not on MDT${MDTIDX}"
20171 # the multiple link file should still in MDT0
20172 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
20173 [ $mdt_index == 0 ] ||
20174 error "$file is not on MDT${MDTIDX}"
20176 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20177 [ "$old_dir_flag" = "$new_dir_flag" ] ||
20178 error " expect $old_dir_flag get $new_dir_flag"
20180 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20181 [ "$old_file_flag" = "$new_file_flag" ] ||
20182 error " expect $old_file_flag get $new_file_flag"
20184 local new_dir_mode=$(stat -c%f $migrate_dir)
20185 [ "$old_dir_mode" = "$new_dir_mode" ] ||
20186 error "expect mode $old_dir_mode get $new_dir_mode"
20188 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
20189 [ "$old_file_mode" = "$new_file_mode" ] ||
20190 error "expect mode $old_file_mode get $new_file_mode"
20192 diff /etc/passwd $migrate_dir/$tfile ||
20193 error "$tfile different after migration"
20195 diff /etc/passwd $other_dir/luna ||
20196 error "luna different after migration"
20198 diff /etc/passwd $migrate_dir/sofia ||
20199 error "sofia different after migration"
20201 diff /etc/passwd $migrate_dir/david ||
20202 error "david different after migration"
20204 diff /etc/passwd $other_dir/zachary ||
20205 error "zachary different after migration"
20207 diff /etc/passwd $migrate_dir/${tfile}_ln ||
20208 error "${tfile}_ln different after migration"
20210 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
20211 error "${tfile}_ln_other different after migration"
20213 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
20214 [ $stripe_count = 2 ] ||
20215 error "dir strpe_count $d != 2 after migration."
20217 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
20218 [ $stripe_count = 2 ] ||
20219 error "file strpe_count $d != 2 after migration."
20221 #migrate back to MDT0
20224 $LFS migrate -m $MDTIDX $migrate_dir ||
20225 error "fails on migrating remote dir to MDT0"
20227 echo "migrate back to MDT0, checking.."
20228 for file in $(find $migrate_dir); do
20229 mdt_index=$($LFS getstripe -m $file)
20230 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
20231 error "$file is not on MDT${MDTIDX}"
20234 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20235 [ "$old_dir_flag" = "$new_dir_flag" ] ||
20236 error " expect $old_dir_flag get $new_dir_flag"
20238 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20239 [ "$old_file_flag" = "$new_file_flag" ] ||
20240 error " expect $old_file_flag get $new_file_flag"
20242 local new_dir_mode=$(stat -c%f $migrate_dir)
20243 [ "$old_dir_mode" = "$new_dir_mode" ] ||
20244 error "expect mode $old_dir_mode get $new_dir_mode"
20246 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
20247 [ "$old_file_mode" = "$new_file_mode" ] ||
20248 error "expect mode $old_file_mode get $new_file_mode"
20250 diff /etc/passwd ${migrate_dir}/$tfile ||
20251 error "$tfile different after migration"
20253 diff /etc/passwd ${other_dir}/luna ||
20254 error "luna different after migration"
20256 diff /etc/passwd ${migrate_dir}/sofia ||
20257 error "sofia different after migration"
20259 diff /etc/passwd ${other_dir}/zachary ||
20260 error "zachary different after migration"
20262 diff /etc/passwd $migrate_dir/${tfile}_ln ||
20263 error "${tfile}_ln different after migration"
20265 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
20266 error "${tfile}_ln_other different after migration"
20268 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
20269 [ $stripe_count = 2 ] ||
20270 error "dir strpe_count $d != 2 after migration."
20272 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
20273 [ $stripe_count = 2 ] ||
20274 error "file strpe_count $d != 2 after migration."
20276 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20278 run_test 230b "migrate directory"
20281 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20282 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20283 remote_mds_nodsh && skip "remote MDS with nodsh"
20284 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20285 skip "Need MDS version at least 2.11.52"
20291 local migrate_dir=$DIR/$tdir/migrate_dir
20293 #If migrating directory fails in the middle, all entries of
20294 #the directory is still accessiable.
20295 test_mkdir $DIR/$tdir
20296 test_mkdir -i0 -c1 $migrate_dir
20297 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
20299 createmany -o $migrate_dir/f $total ||
20300 error "create files under ${migrate_dir} failed"
20302 # fail after migrating top dir, and this will fail only once, so the
20303 # first sub file migration will fail (currently f3), others succeed.
20304 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
20305 do_facet mds1 lctl set_param fail_loc=0x1801
20306 local t=$(ls $migrate_dir | wc -l)
20307 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
20308 error "migrate should fail"
20309 local u=$(ls $migrate_dir | wc -l)
20310 [ "$u" == "$t" ] || error "$u != $t during migration"
20312 # add new dir/file should succeed
20313 mkdir $migrate_dir/dir ||
20314 error "mkdir failed under migrating directory"
20315 touch $migrate_dir/file ||
20316 error "create file failed under migrating directory"
20318 # add file with existing name should fail
20319 for file in $migrate_dir/f*; do
20320 stat $file > /dev/null || error "stat $file failed"
20321 $OPENFILE -f O_CREAT:O_EXCL $file &&
20322 error "open(O_CREAT|O_EXCL) $file should fail"
20323 $MULTIOP $file m && error "create $file should fail"
20324 touch $DIR/$tdir/remote_dir/$tfile ||
20325 error "touch $tfile failed"
20326 ln $DIR/$tdir/remote_dir/$tfile $file &&
20327 error "link $file should fail"
20328 mdt_index=$($LFS getstripe -m $file)
20329 if [ $mdt_index == 0 ]; then
20330 # file failed to migrate is not allowed to rename to
20331 mv $DIR/$tdir/remote_dir/$tfile $file &&
20332 error "rename to $file should fail"
20334 mv $DIR/$tdir/remote_dir/$tfile $file ||
20335 error "rename to $file failed"
20337 echo hello >> $file || error "write $file failed"
20340 # resume migration with different options should fail
20341 $LFS migrate -m 0 $migrate_dir &&
20342 error "migrate -m 0 $migrate_dir should fail"
20344 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
20345 error "migrate -c 2 $migrate_dir should fail"
20347 # resume migration should succeed
20348 $LFS migrate -m $MDTIDX $migrate_dir ||
20349 error "migrate $migrate_dir failed"
20351 echo "Finish migration, then checking.."
20352 for file in $(find $migrate_dir); do
20353 mdt_index=$($LFS getstripe -m $file)
20354 [ $mdt_index == $MDTIDX ] ||
20355 error "$file is not on MDT${MDTIDX}"
20358 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20360 run_test 230c "check directory accessiblity if migration failed"
20363 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20364 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20365 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20366 skip "Need MDS version at least 2.11.52"
20368 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
20370 local migrate_dir=$DIR/$tdir/migrate_dir
20380 old_index=$((RANDOM % MDSCOUNT))
20381 old_count=$((MDSCOUNT - old_index))
20382 new_index=$((RANDOM % MDSCOUNT))
20383 new_count=$((MDSCOUNT - new_index))
20384 new_hash=1 # for all_char
20386 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
20387 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
20389 test_mkdir $DIR/$tdir
20390 test_mkdir -i $old_index -c $old_count $migrate_dir
20392 for ((i=0; i<100; i++)); do
20393 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
20394 createmany -o $migrate_dir/dir_${i}/f 100 ||
20395 error "create files under remote dir failed $i"
20398 echo -n "Migrate from MDT$old_index "
20399 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
20400 echo -n "to MDT$new_index"
20401 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
20404 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
20405 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
20406 error "migrate remote dir error"
20408 echo "Finish migration, then checking.."
20409 for file in $(find $migrate_dir -maxdepth 1); do
20410 mdt_index=$($LFS getstripe -m $file)
20411 if [ $mdt_index -lt $new_index ] ||
20412 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
20413 error "$file is on MDT$mdt_index"
20417 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20419 run_test 230d "check migrate big directory"
20422 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20423 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20424 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20425 skip "Need MDS version at least 2.11.52"
20432 mkdir_on_mdt0 $DIR/$tdir
20433 mkdir $DIR/$tdir/migrate_dir
20434 mkdir $DIR/$tdir/other_dir
20435 touch $DIR/$tdir/migrate_dir/a
20436 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
20437 ls $DIR/$tdir/other_dir
20439 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20440 error "migrate dir fails"
20442 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20443 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20445 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20446 [ $mdt_index == 0 ] || error "a is not on MDT0"
20448 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
20449 error "migrate dir fails"
20451 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
20452 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
20454 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20455 [ $mdt_index == 1 ] || error "a is not on MDT1"
20457 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
20458 [ $mdt_index == 1 ] || error "b is not on MDT1"
20460 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20461 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
20463 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
20465 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20467 run_test 230e "migrate mulitple local link files"
20470 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20471 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20472 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20473 skip "Need MDS version at least 2.11.52"
20478 mkdir -p $DIR/$tdir
20479 mkdir $DIR/$tdir/migrate_dir
20480 $LFS mkdir -i1 $DIR/$tdir/other_dir
20481 touch $DIR/$tdir/migrate_dir/a
20482 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
20483 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
20484 ls $DIR/$tdir/other_dir
20486 # a should be migrated to MDT1, since no other links on MDT0
20487 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20488 error "#1 migrate dir fails"
20489 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20490 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20491 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20492 [ $mdt_index == 1 ] || error "a is not on MDT1"
20494 # a should stay on MDT1, because it is a mulitple link file
20495 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20496 error "#2 migrate dir fails"
20497 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20498 [ $mdt_index == 1 ] || error "a is not on MDT1"
20500 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20501 error "#3 migrate dir fails"
20503 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20504 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
20505 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
20507 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
20508 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
20510 # a should be migrated to MDT0, since no other links on MDT1
20511 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20512 error "#4 migrate dir fails"
20513 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20514 [ $mdt_index == 0 ] || error "a is not on MDT0"
20516 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20518 run_test 230f "migrate mulitple remote link files"
20521 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20522 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20523 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20524 skip "Need MDS version at least 2.11.52"
20526 mkdir -p $DIR/$tdir/migrate_dir
20528 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
20529 error "migrating dir to non-exist MDT succeeds"
20532 run_test 230g "migrate dir to non-exist MDT"
20535 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20536 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20537 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20538 skip "Need MDS version at least 2.11.52"
20542 mkdir -p $DIR/$tdir/migrate_dir
20544 $LFS migrate -m1 $DIR &&
20545 error "migrating mountpoint1 should fail"
20547 $LFS migrate -m1 $DIR/$tdir/.. &&
20548 error "migrating mountpoint2 should fail"
20551 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
20552 error "migrating $tdir/migrate_dir/.. should fail"
20556 run_test 230h "migrate .. and root"
20559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20560 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20561 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20562 skip "Need MDS version at least 2.11.52"
20564 mkdir -p $DIR/$tdir/migrate_dir
20566 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
20567 error "migration fails with a tailing slash"
20569 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
20570 error "migration fails with two tailing slashes"
20572 run_test 230i "lfs migrate -m tolerates trailing slashes"
20575 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20576 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
20577 skip "Need MDS version at least 2.11.52"
20579 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20580 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
20581 error "create $tfile failed"
20582 cat /etc/passwd > $DIR/$tdir/$tfile
20584 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20586 cmp /etc/passwd $DIR/$tdir/$tfile ||
20587 error "DoM file mismatch after migration"
20589 run_test 230j "DoM file data not changed after dir migration"
20592 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
20593 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20594 skip "Need MDS version at least 2.11.56"
20597 local files_on_starting_mdt=0
20599 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
20600 $LFS getdirstripe $DIR/$tdir
20601 for i in $(seq $total); do
20602 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
20603 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20604 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20607 echo "$files_on_starting_mdt files on MDT0"
20609 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
20610 $LFS getdirstripe $DIR/$tdir
20612 files_on_starting_mdt=0
20613 for i in $(seq $total); do
20614 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20615 error "file $tfile.$i mismatch after migration"
20616 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
20617 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20620 echo "$files_on_starting_mdt files on MDT1 after migration"
20621 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
20623 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
20624 $LFS getdirstripe $DIR/$tdir
20626 files_on_starting_mdt=0
20627 for i in $(seq $total); do
20628 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20629 error "file $tfile.$i mismatch after 2nd migration"
20630 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20631 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20634 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
20635 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
20639 run_test 230k "file data not changed after dir migration"
20642 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20643 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20644 skip "Need MDS version at least 2.11.56"
20646 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
20647 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
20648 error "create files under remote dir failed $i"
20649 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20651 run_test 230l "readdir between MDTs won't crash"
20654 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20655 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20656 skip "Need MDS version at least 2.11.56"
20659 local mig_dir=$DIR/$tdir/migrate_dir
20660 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
20664 echo "Creating files and dirs with xattrs"
20665 test_mkdir $DIR/$tdir
20666 test_mkdir -i0 -c1 $mig_dir
20668 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
20669 error "cannot set xattr attr1 on dir"
20670 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
20671 error "cannot set xattr attr2 on dir"
20672 touch $mig_dir/dir/f0
20673 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
20674 error "cannot set xattr attr1 on file"
20675 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
20676 error "cannot set xattr attr2 on file"
20677 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20678 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20679 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
20680 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20681 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
20682 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20683 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
20684 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20685 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
20687 echo "Migrating to MDT1"
20688 $LFS migrate -m $MDTIDX $mig_dir ||
20689 error "fails on migrating dir to MDT1"
20691 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20692 echo "Checking xattrs"
20693 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20694 [ "$val" = $longstr ] ||
20695 error "expecting xattr1 $longstr on dir, found $val"
20696 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20697 [ "$val" = $shortstr ] ||
20698 error "expecting xattr2 $shortstr on dir, found $val"
20699 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20700 [ "$val" = $longstr ] ||
20701 error "expecting xattr1 $longstr on file, found $val"
20702 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20703 [ "$val" = $shortstr ] ||
20704 error "expecting xattr2 $shortstr on file, found $val"
20706 run_test 230m "xattrs not changed after dir migration"
20709 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20710 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
20711 skip "Need MDS version at least 2.13.53"
20713 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
20714 cat /etc/hosts > $DIR/$tdir/$tfile
20715 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
20716 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
20718 cmp /etc/hosts $DIR/$tdir/$tfile ||
20719 error "File data mismatch after migration"
20721 run_test 230n "Dir migration with mirrored file"
20724 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
20725 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
20726 skip "Need MDS version at least 2.13.52"
20728 local mdts=$(comma_list $(mdts_nodes))
20730 local restripe_status
20734 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20736 # in case "crush" hash type is not set
20737 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20739 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20740 mdt.*MDT0000.enable_dir_restripe)
20741 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20742 stack_trap "do_nodes $mdts $LCTL set_param \
20743 mdt.*.enable_dir_restripe=$restripe_status"
20746 createmany -m $DIR/$tdir/f 100 ||
20747 error "create files under remote dir failed $i"
20748 createmany -d $DIR/$tdir/d 100 ||
20749 error "create dirs under remote dir failed $i"
20751 for i in $(seq 2 $MDSCOUNT); do
20752 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20753 $LFS setdirstripe -c $i $DIR/$tdir ||
20754 error "split -c $i $tdir failed"
20755 wait_update $HOSTNAME \
20756 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
20757 error "dir split not finished"
20758 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20759 awk '/migrate/ {sum += $2} END { print sum }')
20760 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
20761 # delta is around total_files/stripe_count
20762 (( $delta < 200 / (i - 1) + 4 )) ||
20763 error "$delta files migrated >= $((200 / (i - 1) + 4))"
20766 run_test 230o "dir split"
20769 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
20770 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20771 skip "Need MDS version at least 2.13.52"
20773 local mdts=$(comma_list $(mdts_nodes))
20775 local restripe_status
20779 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20781 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20783 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20784 mdt.*MDT0000.enable_dir_restripe)
20785 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20786 stack_trap "do_nodes $mdts $LCTL set_param \
20787 mdt.*.enable_dir_restripe=$restripe_status"
20789 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
20790 createmany -m $DIR/$tdir/f 100 ||
20791 error "create files under remote dir failed"
20792 createmany -d $DIR/$tdir/d 100 ||
20793 error "create dirs under remote dir failed"
20795 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
20796 local mdt_hash="crush"
20798 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20799 $LFS setdirstripe -c $c $DIR/$tdir ||
20800 error "split -c $c $tdir failed"
20801 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
20802 mdt_hash="$mdt_hash,fixed"
20803 elif [ $c -eq 1 ]; then
20806 wait_update $HOSTNAME \
20807 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
20808 error "dir merge not finished"
20809 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20810 awk '/migrate/ {sum += $2} END { print sum }')
20811 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
20812 # delta is around total_files/stripe_count
20813 (( delta < 200 / c + 4 )) ||
20814 error "$delta files migrated >= $((200 / c + 4))"
20817 run_test 230p "dir merge"
20820 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
20821 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20822 skip "Need MDS version at least 2.13.52"
20824 local mdts=$(comma_list $(mdts_nodes))
20825 local saved_threshold=$(do_facet mds1 \
20826 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
20827 local saved_delta=$(do_facet mds1 \
20828 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
20829 local threshold=100
20832 local stripe_count=0
20837 # test with fewer files on ZFS
20838 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
20840 stack_trap "do_nodes $mdts $LCTL set_param \
20841 mdt.*.dir_split_count=$saved_threshold"
20842 stack_trap "do_nodes $mdts $LCTL set_param \
20843 mdt.*.dir_split_delta=$saved_delta"
20844 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
20845 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
20846 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
20847 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
20848 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
20849 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20851 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20852 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20854 create=$((threshold * 3 / 2))
20855 while [ $stripe_count -lt $MDSCOUNT ]; do
20856 createmany -m $DIR/$tdir/f $total $create ||
20857 error "create sub files failed"
20858 stat $DIR/$tdir > /dev/null
20859 total=$((total + create))
20860 stripe_count=$((stripe_count + delta))
20861 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
20863 wait_update $HOSTNAME \
20864 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
20865 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
20867 wait_update $HOSTNAME \
20868 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
20869 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
20871 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
20872 echo "$nr_files/$total files on MDT$stripe_index after split"
20873 # allow 10% margin of imbalance with crush hash
20874 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
20875 error "$nr_files files on MDT$stripe_index after split"
20877 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
20878 [ $nr_files -eq $total ] ||
20879 error "total sub files $nr_files != $total"
20882 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
20884 echo "fixed layout directory won't auto split"
20885 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
20886 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
20887 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
20888 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
20889 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
20891 run_test 230q "dir auto split"
20894 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
20895 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20896 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
20897 skip "Need MDS version at least 2.13.54"
20899 # maximum amount of local locks:
20900 # parent striped dir - 2 locks
20901 # new stripe in parent to migrate to - 1 lock
20902 # source and target - 2 locks
20903 # Total 5 locks for regular file
20904 mkdir -p $DIR/$tdir
20905 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
20906 touch $DIR/$tdir/dir1/eee
20908 # create 4 hardlink for 4 more locks
20909 # Total: 9 locks > RS_MAX_LOCKS (8)
20910 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
20911 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
20912 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
20913 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
20914 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
20915 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
20916 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
20917 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
20919 cancel_lru_locks mdc
20921 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
20922 error "migrate dir fails"
20924 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20926 run_test 230r "migrate with too many local locks"
20929 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
20930 skip "Need MDS version at least 2.14.52"
20932 local mdts=$(comma_list $(mdts_nodes))
20933 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
20934 mdt.*MDT0000.enable_dir_restripe)
20936 stack_trap "do_nodes $mdts $LCTL set_param \
20937 mdt.*.enable_dir_restripe=$restripe_status"
20941 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
20942 test_mkdir $DIR/$tdir
20943 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
20944 error "$LFS mkdir should return EEXIST if target exists"
20948 run_test 230s "lfs mkdir should return -EEXIST if target exists"
20952 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20953 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
20954 skip "Need MDS version at least 2.14.50"
20956 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
20957 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
20958 $LFS project -p 1 -s $DIR/$tdir ||
20959 error "set $tdir project id failed"
20960 $LFS project -p 2 -s $DIR/$tdir/subdir ||
20961 error "set subdir project id failed"
20962 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
20964 run_test 230t "migrate directory with project ID set"
20968 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
20969 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20970 skip "Need MDS version at least 2.14.53"
20974 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
20975 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
20976 $LFS migrate -m -1 $DIR/$tdir/sub{0..99} || error "migrate sub failed"
20977 for i in $(seq 0 $((MDSCOUNT - 1))); do
20978 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
20979 echo "$count dirs migrated to MDT$i"
20981 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
20982 (( count >= MDSCOUNT - 1 )) || error "dirs migrated to $count MDTs"
20984 run_test 230u "migrate directory by QOS"
20988 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
20989 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20990 skip "Need MDS version at least 2.14.53"
20994 mkdir $DIR/$tdir || error "mkdir $tdir failed"
20995 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
20996 $LFS migrate -m 0,2,1 $DIR/$tdir || error "migrate $tdir failed"
20997 for i in $(seq 0 $((MDSCOUNT - 1))); do
20998 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
20999 echo "$count subdirs migrated to MDT$i"
21000 (( i == 3 )) && (( count > 0 )) &&
21001 error "subdir shouldn't be migrated to MDT3"
21003 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
21004 (( count == 3 )) || error "dirs migrated to $count MDTs"
21006 run_test 230v "subdir migrated to the MDT where its parent is located"
21009 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
21010 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
21011 skip "Need MDS version at least 2.15.0"
21013 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
21014 createmany -o $DIR/$tdir/f 10 || error "create files failed"
21015 createmany -d $DIR/$tdir/d 10 || error "create dirs failed"
21017 $LFS migrate -m 1 -c $MDSCOUNT -d $DIR/$tdir ||
21018 error "migrate failed"
21020 (( $($LFS getdirstripe -c $DIR/$tdir) == MDSCOUNT )) ||
21021 error "$tdir stripe count mismatch"
21023 for i in $(seq 0 9); do
21024 (( $($LFS getdirstripe -c $DIR/$tdir/d$i) == 0 )) ||
21025 error "d$i is striped"
21028 run_test 230w "non-recursive mode dir migration"
21031 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
21032 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
21033 skip "Need MDS version at least 2.15.0"
21035 mkdir -p $DIR/$tdir || error "mkdir failed"
21036 createmany -d $DIR/$tdir/sub 100 || error "createmany failed"
21038 local mdt_name=$(mdtname_from_index 0)
21039 local low=$(do_facet mds2 $LCTL get_param -n \
21040 osp.*$mdt_name-osp-MDT0001.reserved_ino_low)
21041 local high=$(do_facet mds2 $LCTL get_param -n \
21042 osp.*$mdt_name-osp-MDT0001.reserved_ino_high)
21043 local ffree=$($LFS df -i $MOUNT | awk "/$mdt_name/ { print \$4 }")
21044 local maxage=$(do_facet mds2 $LCTL get_param -n \
21045 osp.*$mdt_name-osp-MDT0001.maxage)
21047 stack_trap "do_facet mds2 $LCTL set_param -n \
21048 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low \
21049 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high" EXIT
21050 stack_trap "do_facet mds2 $LCTL set_param -n \
21051 osp.*$mdt_name-osp-MDT0001.maxage=$maxage" EXIT
21053 do_facet mds2 $LCTL set_param -n \
21054 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$((ffree + 1))
21055 do_facet mds2 $LCTL set_param -n osp.*$mdt_name-osp-MDT0001.maxage=1
21057 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir &&
21058 error "migrate $tdir should fail"
21060 do_facet mds2 $LCTL set_param -n \
21061 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low
21062 do_facet mds2 $LCTL set_param -n \
21063 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high
21065 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir ||
21066 error "migrate failed"
21067 (( $($LFS getdirstripe -c $DIR/$tdir) == $MDSCOUNT )) ||
21068 error "$tdir stripe count mismatch"
21070 run_test 230x "dir migration check space"
21074 # For simplicity this test assumes that max_pages_per_rpc
21075 # is the same across all OSCs
21076 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
21077 local bulk_size=$((max_pages * PAGE_SIZE))
21078 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
21081 mkdir -p $DIR/$tdir
21082 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
21083 error "failed to set stripe with -S ${brw_size}M option"
21085 # clear the OSC stats
21086 $LCTL set_param osc.*.stats=0 &>/dev/null
21089 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
21090 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
21091 oflag=direct &>/dev/null || error "dd failed"
21093 sync; sleep 1; sync # just to be safe
21094 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
21095 if [ x$nrpcs != "x1" ]; then
21096 $LCTL get_param osc.*.stats
21097 error "found $nrpcs ost_write RPCs, not 1 as expected"
21101 # Drop the OSC cache, otherwise we will read from it
21102 cancel_lru_locks osc
21104 # clear the OSC stats
21105 $LCTL set_param osc.*.stats=0 &>/dev/null
21107 # Client reads $bulk_size.
21108 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
21109 iflag=direct &>/dev/null || error "dd failed"
21111 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
21112 if [ x$nrpcs != "x1" ]; then
21113 $LCTL get_param osc.*.stats
21114 error "found $nrpcs ost_read RPCs, not 1 as expected"
21117 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
21120 mkdir -p $DIR/$tdir
21122 for i in {0..1023}; do
21123 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
21124 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
21125 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
21129 run_test 231b "must not assert on fully utilized OST request buffer"
21132 mkdir -p $DIR/$tdir
21133 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
21135 #define OBD_FAIL_LDLM_OST_LVB 0x31c
21136 do_facet ost1 $LCTL set_param fail_loc=0x31c
21138 # ignore dd failure
21139 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
21141 do_facet ost1 $LCTL set_param fail_loc=0
21142 umount_client $MOUNT || error "umount failed"
21143 mount_client $MOUNT || error "mount failed"
21144 stop ost1 || error "cannot stop ost1"
21145 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21147 run_test 232a "failed lock should not block umount"
21150 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
21151 skip "Need MDS version at least 2.10.58"
21153 mkdir -p $DIR/$tdir
21154 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
21155 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
21157 cancel_lru_locks osc
21159 #define OBD_FAIL_LDLM_OST_LVB 0x31c
21160 do_facet ost1 $LCTL set_param fail_loc=0x31c
21163 $LFS data_version $DIR/$tdir/$tfile || true
21165 do_facet ost1 $LCTL set_param fail_loc=0
21166 umount_client $MOUNT || error "umount failed"
21167 mount_client $MOUNT || error "mount failed"
21168 stop ost1 || error "cannot stop ost1"
21169 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21171 run_test 232b "failed data version lock should not block umount"
21174 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
21175 skip "Need MDS version at least 2.3.64"
21176 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
21178 local fid=$($LFS path2fid $MOUNT)
21180 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21181 error "cannot access $MOUNT using its FID '$fid'"
21183 run_test 233a "checking that OBF of the FS root succeeds"
21186 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
21187 skip "Need MDS version at least 2.5.90"
21188 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
21190 local fid=$($LFS path2fid $MOUNT/.lustre)
21192 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21193 error "cannot access $MOUNT/.lustre using its FID '$fid'"
21195 fid=$($LFS path2fid $MOUNT/.lustre/fid)
21196 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21197 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
21199 run_test 233b "checking that OBF of the FS .lustre succeeds"
21202 local p="$TMP/sanityN-$TESTNAME.parameters"
21203 save_lustre_params client "llite.*.xattr_cache" > $p
21204 lctl set_param llite.*.xattr_cache 1 ||
21205 skip_env "xattr cache is not supported"
21207 mkdir -p $DIR/$tdir || error "mkdir failed"
21208 touch $DIR/$tdir/$tfile || error "touch failed"
21209 # OBD_FAIL_LLITE_XATTR_ENOMEM
21210 $LCTL set_param fail_loc=0x1405
21211 getfattr -n user.attr $DIR/$tdir/$tfile &&
21212 error "getfattr should have failed with ENOMEM"
21213 $LCTL set_param fail_loc=0x0
21216 restore_lustre_params < $p
21219 run_test 234 "xattr cache should not crash on ENOMEM"
21222 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
21223 skip "Need MDS version at least 2.4.52"
21225 flock_deadlock $DIR/$tfile
21230 124) error "process hangs on a deadlock"
21232 *) error "error executing flock_deadlock $DIR/$tfile"
21236 run_test 235 "LU-1715: flock deadlock detection does not work properly"
21240 check_swap_layouts_support
21242 local ref1=/etc/passwd
21243 local ref2=/etc/group
21244 local file1=$DIR/$tdir/f1
21245 local file2=$DIR/$tdir/f2
21247 test_mkdir -c1 $DIR/$tdir
21248 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
21249 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
21250 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
21251 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
21252 local fd=$(free_fd)
21253 local cmd="exec $fd<>$file2"
21256 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
21257 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
21260 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
21265 run_test 236 "Layout swap on open unlinked file"
21267 # LU-4659 linkea consistency
21269 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
21270 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
21271 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
21272 skip "Need MDS version at least 2.5.58 or 2.5.2+"
21275 ln $DIR/$tfile $DIR/$tfile.lnk
21276 touch $DIR/$tfile.new
21277 mv $DIR/$tfile.new $DIR/$tfile
21278 local fid1=$($LFS path2fid $DIR/$tfile)
21279 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
21280 local path1=$($LFS fid2path $FSNAME "$fid1")
21281 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
21282 local path2=$($LFS fid2path $FSNAME "$fid2")
21283 [ $tfile.lnk == $path2 ] ||
21284 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
21287 run_test 238 "Verify linkea consistency"
21289 test_239A() { # was test_239
21290 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
21291 skip "Need MDS version at least 2.5.60"
21293 local list=$(comma_list $(mdts_nodes))
21295 mkdir -p $DIR/$tdir
21296 createmany -o $DIR/$tdir/f- 5000
21297 unlinkmany $DIR/$tdir/f- 5000
21298 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
21299 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
21300 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
21301 osp.*MDT*.sync_in_flight" | calc_sum)
21302 [ "$changes" -eq 0 ] || error "$changes not synced"
21304 run_test 239A "osp_sync test"
21306 test_239a() { #LU-5297
21307 remote_mds_nodsh && skip "remote MDS with nodsh"
21310 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
21311 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
21312 chgrp $RUNAS_GID $DIR/$tfile
21313 wait_delete_completed
21315 run_test 239a "process invalid osp sync record correctly"
21317 test_239b() { #LU-5297
21318 remote_mds_nodsh && skip "remote MDS with nodsh"
21321 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
21322 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
21323 chgrp $RUNAS_GID $DIR/$tfile1
21324 wait_delete_completed
21325 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
21327 chgrp $RUNAS_GID $DIR/$tfile2
21328 wait_delete_completed
21330 run_test 239b "process osp sync record with ENOMEM error correctly"
21333 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21334 remote_mds_nodsh && skip "remote MDS with nodsh"
21336 mkdir -p $DIR/$tdir
21338 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
21339 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
21340 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
21341 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
21343 umount_client $MOUNT || error "umount failed"
21344 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
21345 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
21346 mount_client $MOUNT || error "failed to mount client"
21348 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
21349 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
21351 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
21357 for LOOP in $(seq $count); do
21358 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
21359 cancel_lru_locks $OSC || true
21367 for LOOP in $(seq $1); do
21368 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
21373 test_241a() { # was test_241
21374 local bsize=$PAGE_SIZE
21376 (( bsize < 40960 )) && bsize=40960
21377 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21379 cancel_lru_locks $OSC
21380 test_241_bio 1000 $bsize &
21382 test_241_dio 1000 $bsize
21385 run_test 241a "bio vs dio"
21388 local bsize=$PAGE_SIZE
21390 (( bsize < 40960 )) && bsize=40960
21391 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21393 test_241_dio 1000 $bsize &
21395 test_241_dio 1000 $bsize
21398 run_test 241b "dio vs dio"
21401 remote_mds_nodsh && skip "remote MDS with nodsh"
21403 mkdir_on_mdt0 $DIR/$tdir
21404 touch $DIR/$tdir/$tfile
21406 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
21407 do_facet mds1 lctl set_param fail_loc=0x105
21408 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
21410 do_facet mds1 lctl set_param fail_loc=0
21411 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
21413 run_test 242 "mdt_readpage failure should not cause directory unreadable"
21417 test_mkdir $DIR/$tdir
21418 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
21420 run_test 243 "various group lock tests"
21424 test_mkdir $DIR/$tdir
21425 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
21426 sendfile_grouplock $DIR/$tdir/$tfile || \
21427 error "sendfile+grouplock failed"
21430 run_test 244a "sendfile with group lock tests"
21434 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
21437 local size=$((1024*1024))
21439 test_mkdir $DIR/$tdir
21440 for i in $(seq 1 $threads); do
21441 local file=$DIR/$tdir/file_$((i / 10))
21442 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
21445 for i in $(seq 1 $threads); do
21449 run_test 244b "multi-threaded write with group lock"
21452 local flagname="multi_mod_rpcs"
21453 local connect_data_name="max_mod_rpcs"
21456 # check if multiple modify RPCs flag is set
21457 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
21458 grep "connect_flags:")
21461 echo "$out" | grep -qw $flagname
21462 if [ $? -ne 0 ]; then
21463 echo "connect flag $flagname is not set"
21467 # check if multiple modify RPCs data is set
21468 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
21471 echo "$out" | grep -qw $connect_data_name ||
21472 error "import should have connect data $connect_data_name"
21474 run_test 245a "check mdc connection flag/data: multiple modify RPCs"
21477 local flagname="multi_mod_rpcs"
21478 local connect_data_name="max_mod_rpcs"
21481 remote_mds_nodsh && skip "remote MDS with nodsh"
21482 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
21484 # check if multiple modify RPCs flag is set
21485 out=$(do_facet mds1 \
21486 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import |
21487 grep "connect_flags:")
21490 [[ "$out" =~ $flagname ]] || skip "connect flag $flagname is not set"
21492 # check if multiple modify RPCs data is set
21493 out=$(do_facet mds1 \
21494 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import)
21496 [[ "$out" =~ $connect_data_name ]] ||
21499 error "missing connect data $connect_data_name"
21502 run_test 245b "check osp connection flag/data: multiple modify RPCs"
21508 umount_client $submount
21513 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21515 skip_env "Fileset feature is not supported"
21517 local submount=${MOUNT}_$tdir
21520 mkdir -p $submount || error "mkdir $submount failed"
21521 FILESET="$FILESET/$tdir" mount_client $submount ||
21522 error "mount $submount failed"
21523 trap "cleanup_247 $submount" EXIT
21524 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
21525 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
21526 error "read $MOUNT/$tdir/$tfile failed"
21527 cleanup_247 $submount
21529 run_test 247a "mount subdir as fileset"
21532 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21533 skip_env "Fileset feature is not supported"
21535 local submount=${MOUNT}_$tdir
21537 rm -rf $MOUNT/$tdir
21538 mkdir -p $submount || error "mkdir $submount failed"
21540 FILESET="$FILESET/$tdir" mount_client $submount &&
21541 error "mount $submount should fail"
21544 run_test 247b "mount subdir that dose not exist"
21547 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21548 skip_env "Fileset feature is not supported"
21550 local submount=${MOUNT}_$tdir
21552 mkdir -p $MOUNT/$tdir/dir1
21553 mkdir -p $submount || error "mkdir $submount failed"
21554 trap "cleanup_247 $submount" EXIT
21555 FILESET="$FILESET/$tdir" mount_client $submount ||
21556 error "mount $submount failed"
21557 local fid=$($LFS path2fid $MOUNT/)
21558 $LFS fid2path $submount $fid && error "fid2path should fail"
21559 cleanup_247 $submount
21561 run_test 247c "running fid2path outside subdirectory root"
21564 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21565 skip "Fileset feature is not supported"
21567 local submount=${MOUNT}_$tdir
21569 mkdir -p $MOUNT/$tdir/dir1
21570 mkdir -p $submount || error "mkdir $submount failed"
21571 FILESET="$FILESET/$tdir" mount_client $submount ||
21572 error "mount $submount failed"
21573 trap "cleanup_247 $submount" EXIT
21575 local td=$submount/dir1
21576 local fid=$($LFS path2fid $td)
21577 [ -z "$fid" ] && error "path2fid unable to get $td FID"
21579 # check that we get the same pathname back
21582 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
21583 echo "$rootpath $fid"
21584 found=$($LFS fid2path $rootpath "$fid")
21585 [ -n "$found" ] || error "fid2path should succeed"
21586 [ "$found" == "$td" ] || error "fid2path $found != $td"
21588 # check wrong root path format
21589 rootpath=$submount"_wrong"
21590 found=$($LFS fid2path $rootpath "$fid")
21591 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
21593 cleanup_247 $submount
21595 run_test 247d "running fid2path inside subdirectory root"
21599 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21601 skip "Fileset feature is not supported"
21603 local submount=${MOUNT}_$tdir
21606 mkdir -p $submount || error "mkdir $submount failed"
21607 FILESET="$FILESET/.." mount_client $submount &&
21608 error "mount $submount should fail"
21611 run_test 247e "mount .. as fileset"
21614 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21615 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
21616 skip "Need at least version 2.13.52"
21617 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
21618 skip "Need at least version 2.14.50"
21619 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21621 skip "Fileset feature is not supported"
21623 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
21624 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
21625 error "mkdir remote failed"
21626 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
21627 error "mkdir remote/subdir failed"
21628 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
21629 error "mkdir striped failed"
21630 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
21632 local submount=${MOUNT}_$tdir
21634 mkdir -p $submount || error "mkdir $submount failed"
21635 stack_trap "rmdir $submount"
21639 local fileset=$FILESET
21640 local mdts=$(comma_list $(mdts_nodes))
21642 stat=$(do_facet mds1 $LCTL get_param -n \
21643 mdt.*MDT0000.enable_remote_subdir_mount)
21644 stack_trap "do_nodes $mdts $LCTL set_param \
21645 mdt.*.enable_remote_subdir_mount=$stat"
21647 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
21648 stack_trap "umount_client $submount"
21649 FILESET="$fileset/$tdir/remote" mount_client $submount &&
21650 error "mount remote dir $dir should fail"
21652 for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
21653 $tdir/striped/. ; do
21654 FILESET="$fileset/$dir" mount_client $submount ||
21655 error "mount $dir failed"
21656 umount_client $submount
21659 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
21660 FILESET="$fileset/$tdir/remote" mount_client $submount ||
21661 error "mount $tdir/remote failed"
21663 run_test 247f "mount striped or remote directory as fileset"
21666 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
21667 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
21668 skip "Need at least version 2.14.50"
21670 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
21671 error "mkdir $tdir failed"
21672 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
21674 local submount=${MOUNT}_$tdir
21676 mkdir -p $submount || error "mkdir $submount failed"
21677 stack_trap "rmdir $submount"
21679 FILESET="$fileset/$tdir" mount_client $submount ||
21680 error "mount $dir failed"
21681 stack_trap "umount $submount"
21683 local mdts=$(comma_list $(mdts_nodes))
21687 stat $submount > /dev/null
21688 cancel_lru_locks $MDC
21689 stat $submount > /dev/null
21690 stat $submount/$tfile > /dev/null
21691 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
21692 stat $submount/$tfile > /dev/null
21693 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
21694 awk '/getattr/ {sum += $2} END {print sum}')
21696 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
21698 run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
21701 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
21702 [ -z "$fast_read_sav" ] && skip "no fast read support"
21704 # create a large file for fast read verification
21705 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
21707 # make sure the file is created correctly
21708 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
21709 { rm -f $DIR/$tfile; skip "file creation error"; }
21711 echo "Test 1: verify that fast read is 4 times faster on cache read"
21713 # small read with fast read enabled
21714 $LCTL set_param -n llite.*.fast_read=1
21715 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
21716 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21717 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21718 # small read with fast read disabled
21719 $LCTL set_param -n llite.*.fast_read=0
21720 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
21721 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21722 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21724 # verify that fast read is 4 times faster for cache read
21725 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
21726 error_not_in_vm "fast read was not 4 times faster: " \
21727 "$t_fast vs $t_slow"
21729 echo "Test 2: verify the performance between big and small read"
21730 $LCTL set_param -n llite.*.fast_read=1
21732 # 1k non-cache read
21733 cancel_lru_locks osc
21734 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
21735 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21736 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21738 # 1M non-cache read
21739 cancel_lru_locks osc
21740 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
21741 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21742 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21744 # verify that big IO is not 4 times faster than small IO
21745 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
21746 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
21748 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
21751 run_test 248a "fast read verification"
21754 # Default short_io_bytes=16384, try both smaller and larger sizes.
21755 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
21756 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
21757 echo "bs=53248 count=113 normal buffered write"
21758 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
21759 error "dd of initial data file failed"
21760 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
21762 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
21763 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
21764 error "dd with sync normal writes failed"
21765 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
21767 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
21768 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
21769 error "dd with sync small writes failed"
21770 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
21772 cancel_lru_locks osc
21774 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
21775 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
21776 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
21777 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
21778 iflag=direct || error "dd with O_DIRECT small read failed"
21779 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
21780 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
21781 error "compare $TMP/$tfile.1 failed"
21783 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
21784 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
21786 # just to see what the maximum tunable value is, and test parsing
21787 echo "test invalid parameter 2MB"
21788 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
21789 error "too-large short_io_bytes allowed"
21790 echo "test maximum parameter 512KB"
21791 # if we can set a larger short_io_bytes, run test regardless of version
21792 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
21793 # older clients may not allow setting it this large, that's OK
21794 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
21795 skip "Need at least client version 2.13.50"
21796 error "medium short_io_bytes failed"
21798 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21799 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
21801 echo "test large parameter 64KB"
21802 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
21803 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21805 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
21806 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
21807 error "dd with sync large writes failed"
21808 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
21810 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
21811 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
21812 num=$((113 * 4096 / PAGE_SIZE))
21813 echo "bs=$size count=$num oflag=direct large write $tfile.3"
21814 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
21815 error "dd with O_DIRECT large writes failed"
21816 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
21817 error "compare $DIR/$tfile.3 failed"
21819 cancel_lru_locks osc
21821 echo "bs=$size count=$num iflag=direct large read $tfile.2"
21822 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
21823 error "dd with O_DIRECT large read failed"
21824 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
21825 error "compare $TMP/$tfile.2 failed"
21827 echo "bs=$size count=$num iflag=direct large read $tfile.3"
21828 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
21829 error "dd with O_DIRECT large read failed"
21830 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
21831 error "compare $TMP/$tfile.3 failed"
21833 run_test 248b "test short_io read and write for both small and large sizes"
21835 test_249() { # LU-7890
21836 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
21837 skip "Need at least version 2.8.54"
21840 $LFS setstripe -c 1 $DIR/$tfile
21841 # Offset 2T == 4k * 512M
21842 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
21843 error "dd to 2T offset failed"
21845 run_test 249 "Write above 2T file size"
21848 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
21849 && skip "no 16TB file size limit on ZFS"
21851 $LFS setstripe -c 1 $DIR/$tfile
21852 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
21853 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
21854 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
21855 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
21856 conv=notrunc,fsync && error "append succeeded"
21859 run_test 250 "Write above 16T limit"
21862 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
21864 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
21865 #Skip once - writing the first stripe will succeed
21866 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21867 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
21868 error "short write happened"
21870 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21871 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
21872 error "short read happened"
21876 run_test 251 "Handling short read and write correctly"
21879 remote_mds_nodsh && skip "remote MDS with nodsh"
21880 remote_ost_nodsh && skip "remote OST with nodsh"
21881 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
21882 skip_env "ldiskfs only test"
21892 # check lr_reader on OST0000
21894 dev=$(facet_device $tgt)
21895 out=$(do_facet $tgt $LR_READER $dev)
21896 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21898 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
21899 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
21900 error "Invalid uuid returned by $LR_READER on target $tgt"
21901 echo -e "uuid returned by $LR_READER is '$uuid'\n"
21903 # check lr_reader -c on MDT0000
21905 dev=$(facet_device $tgt)
21906 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
21907 skip "$LR_READER does not support additional options"
21909 out=$(do_facet $tgt $LR_READER -c $dev)
21910 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21912 num=$(echo "$out" | grep -c "mdtlov")
21913 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
21914 error "Invalid number of mdtlov clients returned by $LR_READER"
21915 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
21917 # check lr_reader -cr on MDT0000
21918 out=$(do_facet $tgt $LR_READER -cr $dev)
21919 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21921 echo "$out" | grep -q "^reply_data:$" ||
21922 error "$LR_READER should have returned 'reply_data' section"
21923 num=$(echo "$out" | grep -c "client_generation")
21924 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
21926 run_test 252 "check lr_reader tool"
21929 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21930 remote_mds_nodsh && skip "remote MDS with nodsh"
21931 remote_mgs_nodsh && skip "remote MGS with nodsh"
21935 local ost_name=$(ostname_from_index $ostidx)
21938 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
21939 do_facet $SINGLEMDS $LCTL get_param -n \
21940 osp.$mdtosc_proc1.reserved_mb_high ||
21941 skip "remote MDS does not support reserved_mb_high"
21945 wait_delete_completed
21948 pool_add $TESTNAME || error "Pool creation failed"
21949 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
21951 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
21952 error "Setstripe failed"
21954 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
21956 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
21958 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
21960 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
21961 osp.$mdtosc_proc1.prealloc_status)
21962 echo "prealloc_status $oa_status"
21964 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
21965 error "File creation should fail"
21967 #object allocation was stopped, but we still able to append files
21968 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
21969 oflag=append || error "Append failed"
21971 rm -f $DIR/$tdir/$tfile.0
21973 # For this test, we want to delete the files we created to go out of
21974 # space but leave the watermark, so we remain nearly out of space
21975 ost_watermarks_enospc_delete_files $tfile $ostidx
21977 wait_delete_completed
21981 for i in $(seq 10 12); do
21982 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
21983 2>/dev/null || error "File creation failed after rm"
21986 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
21987 osp.$mdtosc_proc1.prealloc_status)
21988 echo "prealloc_status $oa_status"
21990 if (( oa_status != 0 )); then
21991 error "Object allocation still disable after rm"
21994 run_test 253 "Check object allocation limit"
21997 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21998 remote_mds_nodsh && skip "remote MDS with nodsh"
22000 local mdt=$(facet_svc $SINGLEMDS)
22002 do_facet $SINGLEMDS $LCTL get_param -n mdd.$mdt.changelog_size ||
22003 skip "MDS does not support changelog_size"
22007 changelog_register || error "changelog_register failed"
22009 changelog_clear 0 || error "changelog_clear failed"
22011 local size1=$(do_facet $SINGLEMDS \
22012 $LCTL get_param -n mdd.$mdt.changelog_size)
22013 echo "Changelog size $size1"
22016 $LFS mkdir -i 0 $DIR/$tdir
22018 mkdir -p $DIR/$tdir/pics/2008/zachy
22019 touch $DIR/$tdir/pics/2008/zachy/timestamp
22020 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
22021 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
22022 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
22023 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
22024 rm $DIR/$tdir/pics/desktop.jpg
22026 local size2=$(do_facet $SINGLEMDS \
22027 $LCTL get_param -n mdd.$mdt.changelog_size)
22028 echo "Changelog size after work $size2"
22030 (( $size2 > $size1 )) ||
22031 error "new Changelog size=$size2 less than old size=$size1"
22033 run_test 254 "Check changelog size"
22040 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
22041 awk -F: '{print $2}' | grep $type > /dev/null
22042 if [ $? -ne 0 ]; then
22052 lfs ladvise -a willread $file > /dev/null 2>&1
22053 if [ $? -eq 0 ]; then
22057 lfs ladvise -a willread $file 2>&1 |
22058 grep "Inappropriate ioctl for device" > /dev/null
22059 if [ $? -eq 0 ]; then
22066 bc <<<"scale=2; ($1 - $2) * 100 / $2"
22069 # run a random read IO workload
22070 # usage: random_read_iops <filename> <filesize> <iosize>
22071 random_read_iops() {
22074 local iosize=${3:-4096}
22076 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
22077 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
22080 drop_file_oss_cache() {
22084 $LFS ladvise -a dontneed $file 2>/dev/null ||
22085 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
22088 ladvise_willread_performance()
22091 local average_origin=0
22092 local average_cache=0
22093 local average_ladvise=0
22095 for ((i = 1; i <= $repeat; i++)); do
22096 echo "Iter $i/$repeat: reading without willread hint"
22097 cancel_lru_locks osc
22098 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
22099 local speed_origin=$(random_read_iops $DIR/$tfile $size)
22100 echo "Iter $i/$repeat: uncached speed: $speed_origin"
22101 average_origin=$(bc <<<"$average_origin + $speed_origin")
22103 cancel_lru_locks osc
22104 local speed_cache=$(random_read_iops $DIR/$tfile $size)
22105 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
22106 average_cache=$(bc <<<"$average_cache + $speed_cache")
22108 cancel_lru_locks osc
22109 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
22110 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
22111 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
22112 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
22113 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
22115 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
22116 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
22117 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
22119 speedup_cache=$(percent $average_cache $average_origin)
22120 speedup_ladvise=$(percent $average_ladvise $average_origin)
22122 echo "Average uncached read: $average_origin"
22123 echo "Average speedup with OSS cached read: " \
22124 "$average_cache = +$speedup_cache%"
22125 echo "Average speedup with ladvise willread: " \
22126 "$average_ladvise = +$speedup_ladvise%"
22128 local lowest_speedup=20
22129 if (( ${average_cache%.*} < $lowest_speedup )); then
22130 echo "Speedup with OSS cached read less than $lowest_speedup%,"\
22131 " got $average_cache%. Skipping ladvise willread check."
22135 # the test won't work on ZFS until it supports 'ladvise dontneed', but
22136 # it is still good to run until then to exercise 'ladvise willread'
22137 ! $LFS ladvise -a dontneed $DIR/$tfile &&
22138 [ "$ost1_FSTYPE" = "zfs" ] &&
22139 echo "osd-zfs does not support dontneed or drop_caches" &&
22142 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
22143 (( ${average_ladvise%.*} > ${lowest_speedup%.*} )) ||
22144 error_not_in_vm "Speedup with willread is less than " \
22145 "$lowest_speedup%, got $average_ladvise%"
22149 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
22150 skip "lustre < 2.8.54 does not support ladvise "
22151 remote_ost_nodsh && skip "remote OST with nodsh"
22153 stack_trap "rm -f $DIR/$tfile"
22154 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
22156 ladvise_no_type willread $DIR/$tfile &&
22157 skip "willread ladvise is not supported"
22159 ladvise_no_ioctl $DIR/$tfile &&
22160 skip "ladvise ioctl is not supported"
22163 local size=$((size_mb * 1048576))
22164 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
22165 error "dd to $DIR/$tfile failed"
22167 lfs ladvise -a willread $DIR/$tfile ||
22168 error "Ladvise failed with no range argument"
22170 lfs ladvise -a willread -s 0 $DIR/$tfile ||
22171 error "Ladvise failed with no -l or -e argument"
22173 lfs ladvise -a willread -e 1 $DIR/$tfile ||
22174 error "Ladvise failed with only -e argument"
22176 lfs ladvise -a willread -l 1 $DIR/$tfile ||
22177 error "Ladvise failed with only -l argument"
22179 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
22180 error "End offset should not be smaller than start offset"
22182 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
22183 error "End offset should not be equal to start offset"
22185 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
22186 error "Ladvise failed with overflowing -s argument"
22188 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
22189 error "Ladvise failed with overflowing -e argument"
22191 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
22192 error "Ladvise failed with overflowing -l argument"
22194 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
22195 error "Ladvise succeeded with conflicting -l and -e arguments"
22197 echo "Synchronous ladvise should wait"
22199 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
22200 do_nodes $(comma_list $(osts_nodes)) \
22201 $LCTL set_param fail_val=$delay fail_loc=0x237
22203 local start_ts=$SECONDS
22204 lfs ladvise -a willread $DIR/$tfile ||
22205 error "Ladvise failed with no range argument"
22206 local end_ts=$SECONDS
22207 local inteval_ts=$((end_ts - start_ts))
22209 if [ $inteval_ts -lt $(($delay - 1)) ]; then
22210 error "Synchronous advice didn't wait reply"
22213 echo "Asynchronous ladvise shouldn't wait"
22214 local start_ts=$SECONDS
22215 lfs ladvise -a willread -b $DIR/$tfile ||
22216 error "Ladvise failed with no range argument"
22217 local end_ts=$SECONDS
22218 local inteval_ts=$((end_ts - start_ts))
22220 if [ $inteval_ts -gt $(($delay / 2)) ]; then
22221 error "Asynchronous advice blocked"
22224 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
22225 ladvise_willread_performance
22227 run_test 255a "check 'lfs ladvise -a willread'"
22233 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
22237 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
22238 skip "lustre < 2.8.54 does not support ladvise "
22239 remote_ost_nodsh && skip "remote OST with nodsh"
22241 stack_trap "rm -f $DIR/$tfile"
22242 lfs setstripe -c 1 -i 0 $DIR/$tfile
22244 ladvise_no_type dontneed $DIR/$tfile &&
22245 skip "dontneed ladvise is not supported"
22247 ladvise_no_ioctl $DIR/$tfile &&
22248 skip "ladvise ioctl is not supported"
22250 ! $LFS ladvise -a dontneed $DIR/$tfile &&
22251 [ "$ost1_FSTYPE" = "zfs" ] &&
22252 skip "zfs-osd does not support 'ladvise dontneed'"
22255 local size=$((size_mb * 1048576))
22256 # In order to prevent disturbance of other processes, only check 3/4
22257 # of the memory usage
22258 local kibibytes=$((size_mb * 1024 * 3 / 4))
22260 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
22261 error "dd to $DIR/$tfile failed"
22263 #force write to complete before dropping OST cache & checking memory
22266 local total=$(facet_meminfo ost1 MemTotal)
22267 echo "Total memory: $total KiB"
22269 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
22270 local before_read=$(facet_meminfo ost1 Cached)
22271 echo "Cache used before read: $before_read KiB"
22273 lfs ladvise -a willread $DIR/$tfile ||
22274 error "Ladvise willread failed"
22275 local after_read=$(facet_meminfo ost1 Cached)
22276 echo "Cache used after read: $after_read KiB"
22278 lfs ladvise -a dontneed $DIR/$tfile ||
22279 error "Ladvise dontneed again failed"
22280 local no_read=$(facet_meminfo ost1 Cached)
22281 echo "Cache used after dontneed ladvise: $no_read KiB"
22283 if [ $total -lt $((before_read + kibibytes)) ]; then
22284 echo "Memory is too small, abort checking"
22288 if [ $((before_read + kibibytes)) -gt $after_read ]; then
22289 error "Ladvise willread should use more memory" \
22290 "than $kibibytes KiB"
22293 if [ $((no_read + kibibytes)) -gt $after_read ]; then
22294 error "Ladvise dontneed should release more memory" \
22295 "than $kibibytes KiB"
22298 run_test 255b "check 'lfs ladvise -a dontneed'"
22301 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
22302 skip "lustre < 2.10.50 does not support lockahead"
22304 local ost1_imp=$(get_osc_import_name client ost1)
22305 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
22313 test_mkdir -p $DIR/$tdir
22314 $LFS setstripe -i 0 -c 1 $DIR/$tdir
22316 #test 10 returns only success/failure
22318 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22320 if [ $rc -eq 255 ]; then
22321 error "Ladvise test${i} failed, ${rc}"
22324 #test 11 counts lock enqueue requests, all others count new locks
22326 count=$(do_facet ost1 \
22327 $LCTL get_param -n ost.OSS.ost.stats)
22328 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
22330 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22332 if [ $rc -eq 255 ]; then
22333 error "Ladvise test${i} failed, ${rc}"
22336 new_count=$(do_facet ost1 \
22337 $LCTL get_param -n ost.OSS.ost.stats)
22338 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
22339 awk '{ print $2 }')
22341 difference="$((new_count - count))"
22342 if [ $difference -ne $rc ]; then
22343 error "Ladvise test${i}, bad enqueue count, returned " \
22344 "${rc}, actual ${difference}"
22347 for i in $(seq 12 21); do
22348 # If we do not do this, we run the risk of having too many
22349 # locks and starting lock cancellation while we are checking
22351 cancel_lru_locks osc
22353 count=$($LCTL get_param -n \
22354 ldlm.namespaces.$imp_name.lock_unused_count)
22356 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22358 if [ $rc -eq 255 ]; then
22359 error "Ladvise test ${i} failed, ${rc}"
22362 new_count=$($LCTL get_param -n \
22363 ldlm.namespaces.$imp_name.lock_unused_count)
22364 difference="$((new_count - count))"
22366 # Test 15 output is divided by 100 to map down to valid return
22367 if [ $i -eq 15 ]; then
22371 if [ $difference -ne $rc ]; then
22372 error "Ladvise test ${i}, bad lock count, returned " \
22373 "${rc}, actual ${difference}"
22377 #test 22 returns only success/failure
22379 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22381 if [ $rc -eq 255 ]; then
22382 error "Ladvise test${i} failed, ${rc}"
22385 run_test 255c "suite of ladvise lockahead tests"
22388 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22389 remote_mds_nodsh && skip "remote MDS with nodsh"
22390 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22391 changelog_users $SINGLEMDS | grep "^cl" &&
22392 skip "active changelog user"
22398 mdt_dev=$(facet_device $SINGLEMDS)
22401 changelog_register || error "changelog_register failed"
22404 mkdir_on_mdt -i$(($(facet_number $SINGLEMDS) - 1)) $DIR/$tdir
22406 changelog_clear 0 || error "changelog_clear failed"
22409 touch $DIR/$tdir/{1..10}
22412 stop $SINGLEMDS || error "Fail to stop MDT"
22415 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
22416 error "Fail to start MDT"
22418 #after mount new plainllog is used
22419 touch $DIR/$tdir/{11..19}
22420 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
22421 stack_trap "rm -f $tmpfile"
22422 cat_sl=$(do_facet $SINGLEMDS "sync; \
22423 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22424 llog_reader $tmpfile | grep -c type=1064553b")
22425 do_facet $SINGLEMDS llog_reader $tmpfile
22427 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
22429 changelog_clear 0 || error "changelog_clear failed"
22431 cat_sl=$(do_facet $SINGLEMDS "sync; \
22432 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22433 llog_reader $tmpfile | grep -c type=1064553b")
22435 if (( cat_sl == 2 )); then
22436 error "Empty plain llog was not deleted from changelog catalog"
22437 elif (( cat_sl != 1 )); then
22438 error "Active plain llog shouldn't be deleted from catalog"
22441 run_test 256 "Check llog delete for empty and not full state"
22444 remote_mds_nodsh && skip "remote MDS with nodsh"
22445 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
22446 skip "Need MDS version at least 2.8.55"
22448 test_mkdir $DIR/$tdir
22450 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
22451 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
22454 #define OBD_FAIL_MDS_XATTR_REP 0x161
22455 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
22456 local facet=mds$((mdtidx + 1))
22457 set_nodes_failloc $(facet_active_host $facet) 0x80000161
22458 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
22460 stop $facet || error "stop MDS failed"
22461 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
22462 error "start MDS fail"
22463 wait_recovery_complete $facet
22465 run_test 257 "xattr locks are not lost"
22467 # Verify we take the i_mutex when security requires it
22469 #define OBD_FAIL_IMUTEX_SEC 0x141c
22470 $LCTL set_param fail_loc=0x141c
22472 chmod u+s $DIR/$tfile
22473 chmod a+rwx $DIR/$tfile
22474 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22476 if [ $RC -ne 0 ]; then
22477 error "error, failed to take i_mutex, rc=$?"
22481 run_test 258a "verify i_mutex security behavior when suid attributes is set"
22483 # Verify we do NOT take the i_mutex in the normal case
22485 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
22486 $LCTL set_param fail_loc=0x141d
22489 chmod a+rw $DIR/$tfile
22490 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22492 if [ $RC -ne 0 ]; then
22493 error "error, took i_mutex unnecessarily, rc=$?"
22498 run_test 258b "verify i_mutex security behavior"
22501 local file=$DIR/$tfile
22505 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22507 stack_trap "rm -f $file" EXIT
22509 wait_delete_completed
22510 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22511 echo "before: $before"
22513 $LFS setstripe -i 0 -c 1 $file
22514 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
22516 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22517 echo "after write: $after"
22519 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
22520 do_facet ost1 $LCTL set_param fail_loc=0x2301
22522 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22523 echo "after truncate: $after"
22526 do_facet ost1 $LCTL set_param fail_loc=0
22527 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22529 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22530 echo "after restart: $after"
22531 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
22532 error "missing truncate?"
22536 run_test 259 "crash at delayed truncate"
22539 #define OBD_FAIL_MDC_CLOSE 0x806
22540 $LCTL set_param fail_loc=0x80000806
22544 run_test 260 "Check mdc_close fail"
22546 ### Data-on-MDT sanity tests ###
22548 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22549 skip "Need MDS version at least 2.10.55 for DoM"
22552 local dom=$DIR/$tdir/dom_file
22553 local tmp=$DIR/$tdir/tmp_file
22555 mkdir_on_mdt0 $DIR/$tdir
22557 # basic checks for DoM component creation
22558 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
22559 error "Can set MDT layout to non-first entry"
22561 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
22562 error "Can define multiple entries as MDT layout"
22564 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
22566 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
22567 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
22568 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
22570 local mdtidx=$($LFS getstripe -m $dom)
22571 local mdtname=MDT$(printf %04x $mdtidx)
22572 local facet=mds$((mdtidx + 1))
22573 local space_check=1
22575 # Skip free space checks with ZFS
22576 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
22580 local size_tmp=$((65536 * 3))
22581 local mdtfree1=$(do_facet $facet \
22582 lctl get_param -n osd*.*$mdtname.kbytesfree)
22584 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22585 # check also direct IO along write
22586 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
22587 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22589 cmp $tmp $dom || error "file data is different"
22590 [ $(stat -c%s $dom) == $size_tmp ] ||
22591 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22592 if [ $space_check == 1 ]; then
22593 local mdtfree2=$(do_facet $facet \
22594 lctl get_param -n osd*.*$mdtname.kbytesfree)
22596 # increase in usage from by $size_tmp
22597 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22598 error "MDT free space wrong after write: " \
22599 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22603 local size_dom=10000
22605 $TRUNCATE $dom $size_dom
22606 [ $(stat -c%s $dom) == $size_dom ] ||
22607 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
22608 if [ $space_check == 1 ]; then
22609 mdtfree1=$(do_facet $facet \
22610 lctl get_param -n osd*.*$mdtname.kbytesfree)
22611 # decrease in usage from $size_tmp to new $size_dom
22612 [ $(($mdtfree1 - $mdtfree2)) -ge \
22613 $(((size_tmp - size_dom) / 1024)) ] ||
22614 error "MDT free space is wrong after truncate: " \
22615 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
22621 size_dom=$((size_dom + size_tmp))
22622 [ $(stat -c%s $dom) == $size_dom ] ||
22623 error "bad size after append: $(stat -c%s $dom) != $size_dom"
22624 if [ $space_check == 1 ]; then
22625 mdtfree2=$(do_facet $facet \
22626 lctl get_param -n osd*.*$mdtname.kbytesfree)
22627 # increase in usage by $size_tmp from previous
22628 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22629 error "MDT free space is wrong after append: " \
22630 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22635 if [ $space_check == 1 ]; then
22636 mdtfree1=$(do_facet $facet \
22637 lctl get_param -n osd*.*$mdtname.kbytesfree)
22638 # decrease in usage by $size_dom from previous
22639 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
22640 error "MDT free space is wrong after removal: " \
22641 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
22644 # combined striping
22645 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
22646 error "Can't create DoM + OST striping"
22648 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
22649 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22650 # check also direct IO along write
22651 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22653 cmp $tmp $dom || error "file data is different"
22654 [ $(stat -c%s $dom) == $size_tmp ] ||
22655 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22660 run_test 270a "DoM: basic functionality tests"
22663 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22664 skip "Need MDS version at least 2.10.55"
22666 local dom=$DIR/$tdir/dom_file
22667 local max_size=1048576
22669 mkdir -p $DIR/$tdir
22670 $LFS setstripe -E $max_size -L mdt $dom
22672 # truncate over the limit
22673 $TRUNCATE $dom $(($max_size + 1)) &&
22674 error "successful truncate over the maximum size"
22675 # write over the limit
22676 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
22677 error "successful write over the maximum size"
22678 # append over the limit
22679 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
22680 echo "12345" >> $dom && error "successful append over the maximum size"
22685 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
22688 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22689 skip "Need MDS version at least 2.10.55"
22691 mkdir -p $DIR/$tdir
22692 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22694 # check files inherit DoM EA
22695 touch $DIR/$tdir/first
22696 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
22697 error "bad pattern"
22698 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
22699 error "bad stripe count"
22700 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
22701 error "bad stripe size"
22703 # check directory inherits DoM EA and uses it as default
22704 mkdir $DIR/$tdir/subdir
22705 touch $DIR/$tdir/subdir/second
22706 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
22707 error "bad pattern in sub-directory"
22708 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
22709 error "bad stripe count in sub-directory"
22710 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
22711 error "bad stripe size in sub-directory"
22714 run_test 270c "DoM: DoM EA inheritance tests"
22717 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22718 skip "Need MDS version at least 2.10.55"
22720 mkdir -p $DIR/$tdir
22721 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22723 # inherit default DoM striping
22724 mkdir $DIR/$tdir/subdir
22725 touch $DIR/$tdir/subdir/f1
22727 # change default directory striping
22728 $LFS setstripe -c 1 $DIR/$tdir/subdir
22729 touch $DIR/$tdir/subdir/f2
22730 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
22731 error "wrong default striping in file 2"
22732 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
22733 error "bad pattern in file 2"
22736 run_test 270d "DoM: change striping from DoM to RAID0"
22739 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22740 skip "Need MDS version at least 2.10.55"
22742 mkdir -p $DIR/$tdir/dom
22743 mkdir -p $DIR/$tdir/norm
22746 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
22747 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
22749 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
22750 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
22752 # find DoM files by layout
22753 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
22754 [ $NUM -eq $DOMFILES ] ||
22755 error "lfs find -L: found $NUM, expected $DOMFILES"
22756 echo "Test 1: lfs find 20 DOM files by layout: OK"
22758 # there should be 1 dir with default DOM striping
22759 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
22761 error "lfs find -L: found $NUM, expected 1 dir"
22762 echo "Test 2: lfs find 1 DOM dir by layout: OK"
22764 # find DoM files by stripe size
22765 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
22766 [ $NUM -eq $DOMFILES ] ||
22767 error "lfs find -S: found $NUM, expected $DOMFILES"
22768 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
22770 # find files by stripe offset except DoM files
22771 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
22772 [ $NUM -eq $NORMFILES ] ||
22773 error "lfs find -i: found $NUM, expected $NORMFILES"
22774 echo "Test 5: lfs find no DOM files by stripe index: OK"
22777 run_test 270e "DoM: lfs find with DoM files test"
22780 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22781 skip "Need MDS version at least 2.10.55"
22783 local mdtname=${FSNAME}-MDT0000-mdtlov
22784 local dom=$DIR/$tdir/dom_file
22785 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
22786 lod.$mdtname.dom_stripesize)
22787 local dom_limit=131072
22789 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
22790 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22791 lod.$mdtname.dom_stripesize)
22792 [ ${dom_limit} -eq ${dom_current} ] ||
22793 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
22795 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22796 $LFS setstripe -d $DIR/$tdir
22797 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
22798 error "Can't set directory default striping"
22800 # exceed maximum stripe size
22801 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22802 error "Can't create file with $((dom_limit * 2)) DoM stripe"
22803 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
22804 error "Able to create DoM component size more than LOD limit"
22806 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22807 dom_current=$(do_facet mds1 $LCTL get_param -n \
22808 lod.$mdtname.dom_stripesize)
22809 [ 0 -eq ${dom_current} ] ||
22810 error "Can't set zero DoM stripe limit"
22813 # attempt to create DoM file on server with disabled DoM should
22814 # remove DoM entry from layout and be succeed
22815 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
22816 error "Can't create DoM file (DoM is disabled)"
22817 [ $($LFS getstripe -L $dom) == "mdt" ] &&
22818 error "File has DoM component while DoM is disabled"
22821 # attempt to create DoM file with only DoM stripe should return error
22822 $LFS setstripe -E $dom_limit -L mdt $dom &&
22823 error "Able to create DoM-only file while DoM is disabled"
22825 # too low values to be aligned with smallest stripe size 64K
22826 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
22827 dom_current=$(do_facet mds1 $LCTL get_param -n \
22828 lod.$mdtname.dom_stripesize)
22829 [ 30000 -eq ${dom_current} ] &&
22830 error "Can set too small DoM stripe limit"
22832 # 64K is a minimal stripe size in Lustre, expect limit of that size
22833 [ 65536 -eq ${dom_current} ] ||
22834 error "Limit is not set to 64K but ${dom_current}"
22836 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
22837 dom_current=$(do_facet mds1 $LCTL get_param -n \
22838 lod.$mdtname.dom_stripesize)
22840 [ 2147483648 -eq ${dom_current} ] &&
22841 error "Can set too large DoM stripe limit"
22843 do_facet mds1 $LCTL set_param -n \
22844 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
22845 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22846 error "Can't create DoM component size after limit change"
22847 do_facet mds1 $LCTL set_param -n \
22848 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
22849 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
22850 error "Can't create DoM file after limit decrease"
22851 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
22852 error "Can create big DoM component after limit decrease"
22853 touch ${dom}_def ||
22854 error "Can't create file with old default layout"
22856 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
22859 run_test 270f "DoM: maximum DoM stripe size checks"
22862 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
22863 skip "Need MDS version at least 2.13.52"
22864 local dom=$DIR/$tdir/$tfile
22866 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22867 local lodname=${FSNAME}-MDT0000-mdtlov
22869 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22870 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
22871 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
22872 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22874 local dom_limit=1024
22875 local dom_threshold="50%"
22877 $LFS setstripe -d $DIR/$tdir
22878 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
22879 error "Can't set directory default striping"
22881 do_facet mds1 $LCTL set_param -n \
22882 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
22883 # set 0 threshold and create DOM file to change tunable stripesize
22884 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
22885 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22886 error "Failed to create $dom file"
22887 # now tunable dom_cur_stripesize should reach maximum
22888 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22889 lod.${lodname}.dom_stripesize_cur_kb)
22890 [[ $dom_current == $dom_limit ]] ||
22891 error "Current DOM stripesize is not maximum"
22894 # set threshold for further tests
22895 do_facet mds1 $LCTL set_param -n \
22896 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
22897 echo "DOM threshold is $dom_threshold free space"
22900 # Spoof bfree to exceed threshold
22901 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
22902 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
22903 for spfree in 40 20 0 15 30 55; do
22904 do_facet mds1 $LCTL set_param -n fail_val=$spfree
22905 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22906 error "Failed to create $dom file"
22907 dom_def=$(do_facet mds1 $LCTL get_param -n \
22908 lod.${lodname}.dom_stripesize_cur_kb)
22909 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
22910 [[ $dom_def != $dom_current ]] ||
22911 error "Default stripe size was not changed"
22912 if (( spfree > 0 )) ; then
22913 dom_set=$($LFS getstripe -S $dom)
22914 (( dom_set == dom_def * 1024 )) ||
22915 error "DOM component size is still old"
22917 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22918 error "DoM component is set with no free space"
22921 dom_current=$dom_def
22924 run_test 270g "DoM: default DoM stripe size depends on free space"
22927 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
22928 skip "Need MDS version at least 2.13.53"
22930 local mdtname=${FSNAME}-MDT0000-mdtlov
22931 local dom=$DIR/$tdir/$tfile
22932 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22934 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
22935 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22937 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22938 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
22939 error "can't create OST file"
22940 # mirrored file with DOM entry in the second mirror
22941 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
22942 error "can't create mirror with DoM component"
22944 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22946 # DOM component in the middle and has other enries in the same mirror,
22947 # should succeed but lost DoM component
22948 $LFS setstripe --copy=${dom}_1 $dom ||
22949 error "Can't create file from OST|DOM mirror layout"
22950 # check new file has no DoM layout after all
22951 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22952 error "File has DoM component while DoM is disabled"
22954 run_test 270h "DoM: DoM stripe removal when disabled on server"
22957 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
22958 skip "Need MDS version at least 2.14.54"
22961 # DoM with plain layout
22962 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir &&
22963 error "default plain layout with DoM must fail"
22964 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir/$tfile &&
22965 error "setstripe plain file layout with DoM must fail"
22966 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir &&
22967 error "default DoM layout with bad striping must fail"
22968 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir/$tfile &&
22969 error "setstripe to DoM layout with bad striping must fail"
22972 run_test 270i "DoM: setting invalid DoM striping should fail"
22975 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22976 skip "Need MDS version at least 2.10.55"
22978 local dom=$DIR/$tdir/dom
22980 mkdir -p $DIR/$tdir
22982 $LFS setstripe -E 1024K -L mdt $dom
22984 lctl set_param -n mdc.*.stats=clear
22985 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
22986 cat $dom > /dev/null
22987 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
22988 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
22992 run_test 271a "DoM: data is cached for read after write"
22995 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22996 skip "Need MDS version at least 2.10.55"
22998 local dom=$DIR/$tdir/dom
23000 mkdir -p $DIR/$tdir
23002 $LFS setstripe -E 1024K -L mdt -E EOF $dom
23004 lctl set_param -n mdc.*.stats=clear
23005 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
23006 cancel_lru_locks mdc
23007 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
23008 # second stat to check size is cached on client
23009 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
23010 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
23011 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
23014 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
23017 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23018 skip "Need MDS version at least 2.10.55"
23020 local dom=$DIR/$tdir/dom
23022 mkdir -p $DIR/$tdir
23024 $LFS setstripe -E 1024K -L mdt -E EOF $dom
23026 lctl set_param -n mdc.*.stats=clear
23027 lctl set_param -n osc.*.stats=clear
23028 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
23029 cancel_lru_locks mdc
23030 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
23031 # second stat to check size is cached on client
23032 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
23033 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
23034 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
23035 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
23036 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
23039 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
23045 local mdt=MDT$(printf %04x $mdtidx)
23047 if [ -z $param ]; then
23048 lctl get_param -n mdc.*$mdt*.stats
23050 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
23055 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23056 skip "Need MDS version at least 2.10.55"
23058 local dom=$DIR/$tdir/dom
23060 mkdir -p $DIR/$tdir
23062 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23064 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
23065 local facet=mds$((mdtidx + 1))
23067 cancel_lru_locks mdc
23068 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
23069 createmany -o $dom 1000
23070 lctl set_param -n mdc.*.stats=clear
23071 smalliomany -w $dom 1000 200
23072 get_mdc_stats $mdtidx
23073 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
23074 # Each file has 1 open, 1 IO enqueues, total 2000
23075 # but now we have also +1 getxattr for security.capability, total 3000
23076 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
23077 unlinkmany $dom 1000
23079 cancel_lru_locks mdc
23080 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
23081 createmany -o $dom 1000
23082 lctl set_param -n mdc.*.stats=clear
23083 smalliomany -w $dom 1000 200
23084 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
23085 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
23086 # for OPEN and IO lock.
23087 [ $((enq - enq_2)) -ge 1000 ] ||
23088 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
23089 unlinkmany $dom 1000
23092 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
23094 cleanup_271def_tests() {
23100 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
23101 skip "Need MDS version at least 2.10.57"
23103 local dom=$DIR/$tdir/dom
23104 local tmp=$TMP/$tfile
23105 trap "cleanup_271def_tests $tmp" EXIT
23107 mkdir -p $DIR/$tdir
23109 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23111 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
23113 cancel_lru_locks mdc
23114 dd if=/dev/urandom of=$tmp bs=1000 count=1
23115 dd if=$tmp of=$dom bs=1000 count=1
23116 cancel_lru_locks mdc
23118 cat /etc/hosts >> $tmp
23119 lctl set_param -n mdc.*.stats=clear
23121 # append data to the same file it should update local page
23122 echo "Append to the same page"
23123 cat /etc/hosts >> $dom
23124 local num=$(get_mdc_stats $mdtidx ost_read)
23125 local ra=$(get_mdc_stats $mdtidx req_active)
23126 local rw=$(get_mdc_stats $mdtidx req_waittime)
23128 [ -z $num ] || error "$num READ RPC occured"
23129 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23133 cmp $tmp $dom || error "file miscompare"
23135 cancel_lru_locks mdc
23136 lctl set_param -n mdc.*.stats=clear
23138 echo "Open and read file"
23139 cat $dom > /dev/null
23140 local num=$(get_mdc_stats $mdtidx ost_read)
23141 local ra=$(get_mdc_stats $mdtidx req_active)
23142 local rw=$(get_mdc_stats $mdtidx req_waittime)
23144 [ -z $num ] || error "$num READ RPC occured"
23145 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23149 cmp $tmp $dom || error "file miscompare"
23153 run_test 271d "DoM: read on open (1K file in reply buffer)"
23156 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
23157 skip "Need MDS version at least 2.10.57"
23159 local dom=$DIR/$tdir/dom
23160 local tmp=$TMP/$tfile
23161 trap "cleanup_271def_tests $tmp" EXIT
23163 mkdir -p $DIR/$tdir
23165 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23167 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
23169 cancel_lru_locks mdc
23170 dd if=/dev/urandom of=$tmp bs=265000 count=1
23171 dd if=$tmp of=$dom bs=265000 count=1
23172 cancel_lru_locks mdc
23173 cat /etc/hosts >> $tmp
23174 lctl set_param -n mdc.*.stats=clear
23176 echo "Append to the same page"
23177 cat /etc/hosts >> $dom
23178 local num=$(get_mdc_stats $mdtidx ost_read)
23179 local ra=$(get_mdc_stats $mdtidx req_active)
23180 local rw=$(get_mdc_stats $mdtidx req_waittime)
23182 [ -z $num ] || error "$num READ RPC occured"
23183 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23187 cmp $tmp $dom || error "file miscompare"
23189 cancel_lru_locks mdc
23190 lctl set_param -n mdc.*.stats=clear
23192 echo "Open and read file"
23193 cat $dom > /dev/null
23194 local num=$(get_mdc_stats $mdtidx ost_read)
23195 local ra=$(get_mdc_stats $mdtidx req_active)
23196 local rw=$(get_mdc_stats $mdtidx req_waittime)
23198 [ -z $num ] && num=0
23199 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
23200 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23204 cmp $tmp $dom || error "file miscompare"
23208 run_test 271f "DoM: read on open (200K file and read tail)"
23211 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
23212 skip "Skipping due to old client or server version"
23214 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
23216 $CHECKSTAT -t file $DIR1/$tfile
23218 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
23221 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
23222 $LCTL set_param fail_loc=0x80000314
23223 rm $DIR1/$tfile || error "Unlink fails"
23225 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
23226 [ $RC -eq 0 ] || error "Failed write to stale object"
23228 run_test 271g "Discard DoM data vs client flush race"
23231 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23232 skip "Need MDS version at least 2.11.50"
23234 local dom=$DIR/$tdir/dom
23235 mkdir -p $DIR/$tdir
23237 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
23238 dd if=/dev/urandom of=$dom bs=512K count=1 ||
23239 error "failed to write data into $dom"
23240 local old_md5=$(md5sum $dom)
23242 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
23243 error "failed to migrate to the same DoM component"
23245 local new_md5=$(md5sum $dom)
23247 [ "$old_md5" == "$new_md5" ] ||
23248 error "md5sum differ: $old_md5, $new_md5"
23250 [ $($LFS getstripe -c $dom) -eq 2 ] ||
23251 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
23253 run_test 272a "DoM migration: new layout with the same DOM component"
23256 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23257 skip "Need MDS version at least 2.11.50"
23259 local dom=$DIR/$tdir/dom
23260 mkdir -p $DIR/$tdir
23261 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23263 local mdtidx=$($LFS getstripe -m $dom)
23264 local mdtname=MDT$(printf %04x $mdtidx)
23265 local facet=mds$((mdtidx + 1))
23267 local mdtfree1=$(do_facet $facet \
23268 lctl get_param -n osd*.*$mdtname.kbytesfree)
23269 dd if=/dev/urandom of=$dom bs=2M count=1 ||
23270 error "failed to write data into $dom"
23271 local old_md5=$(md5sum $dom)
23272 cancel_lru_locks mdc
23273 local mdtfree1=$(do_facet $facet \
23274 lctl get_param -n osd*.*$mdtname.kbytesfree)
23276 $LFS migrate -c2 $dom ||
23277 error "failed to migrate to the new composite layout"
23278 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
23279 error "MDT stripe was not removed"
23281 cancel_lru_locks mdc
23282 local new_md5=$(md5sum $dom)
23283 [ "$old_md5" == "$new_md5" ] ||
23284 error "$old_md5 != $new_md5"
23286 # Skip free space checks with ZFS
23287 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23288 local mdtfree2=$(do_facet $facet \
23289 lctl get_param -n osd*.*$mdtname.kbytesfree)
23290 [ $mdtfree2 -gt $mdtfree1 ] ||
23291 error "MDT space is not freed after migration"
23295 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
23298 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23299 skip "Need MDS version at least 2.11.50"
23301 local dom=$DIR/$tdir/$tfile
23302 mkdir -p $DIR/$tdir
23303 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23305 local mdtidx=$($LFS getstripe -m $dom)
23306 local mdtname=MDT$(printf %04x $mdtidx)
23307 local facet=mds$((mdtidx + 1))
23309 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23310 error "failed to write data into $dom"
23311 local old_md5=$(md5sum $dom)
23312 cancel_lru_locks mdc
23313 local mdtfree1=$(do_facet $facet \
23314 lctl get_param -n osd*.*$mdtname.kbytesfree)
23316 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
23317 error "failed to migrate to the new composite layout"
23318 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
23319 error "MDT stripe was not removed"
23321 cancel_lru_locks mdc
23322 local new_md5=$(md5sum $dom)
23323 [ "$old_md5" == "$new_md5" ] ||
23324 error "$old_md5 != $new_md5"
23326 # Skip free space checks with ZFS
23327 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23328 local mdtfree2=$(do_facet $facet \
23329 lctl get_param -n osd*.*$mdtname.kbytesfree)
23330 [ $mdtfree2 -gt $mdtfree1 ] ||
23331 error "MDS space is not freed after migration"
23335 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
23338 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23339 skip "Need MDS version at least 2.12.55"
23341 local dom=$DIR/$tdir/$tfile
23342 mkdir -p $DIR/$tdir
23343 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23345 local mdtidx=$($LFS getstripe -m $dom)
23346 local mdtname=MDT$(printf %04x $mdtidx)
23347 local facet=mds$((mdtidx + 1))
23349 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23350 error "failed to write data into $dom"
23351 local old_md5=$(md5sum $dom)
23352 cancel_lru_locks mdc
23353 local mdtfree1=$(do_facet $facet \
23354 lctl get_param -n osd*.*$mdtname.kbytesfree)
23356 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
23357 error "failed mirroring to the new composite layout"
23358 $LFS mirror resync $dom ||
23359 error "failed mirror resync"
23360 $LFS mirror split --mirror-id 1 -d $dom ||
23361 error "failed mirror split"
23363 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
23364 error "MDT stripe was not removed"
23366 cancel_lru_locks mdc
23367 local new_md5=$(md5sum $dom)
23368 [ "$old_md5" == "$new_md5" ] ||
23369 error "$old_md5 != $new_md5"
23371 # Skip free space checks with ZFS
23372 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23373 local mdtfree2=$(do_facet $facet \
23374 lctl get_param -n osd*.*$mdtname.kbytesfree)
23375 [ $mdtfree2 -gt $mdtfree1 ] ||
23376 error "MDS space is not freed after DOM mirror deletion"
23380 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
23383 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23384 skip "Need MDS version at least 2.12.55"
23386 local dom=$DIR/$tdir/$tfile
23387 mkdir -p $DIR/$tdir
23388 $LFS setstripe -c 2 $dom
23390 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23391 error "failed to write data into $dom"
23392 local old_md5=$(md5sum $dom)
23395 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
23396 error "failed mirroring to the DOM layout"
23397 $LFS mirror resync $dom ||
23398 error "failed mirror resync"
23399 $LFS mirror split --mirror-id 1 -d $dom ||
23400 error "failed mirror split"
23402 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23403 error "MDT stripe wasn't set"
23406 local new_md5=$(md5sum $dom)
23407 [ "$old_md5" == "$new_md5" ] ||
23408 error "$old_md5 != $new_md5"
23412 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
23415 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23416 skip "Need MDS version at least 2.12.55"
23418 local dom=$DIR/$tdir/$tfile
23419 mkdir -p $DIR/$tdir
23420 $LFS setstripe -c 2 $dom
23422 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23423 error "failed to write data into $dom"
23424 local old_md5=$(md5sum $dom)
23427 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
23428 error "failed migrating to the DOM file"
23430 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23431 error "MDT stripe wasn't set"
23434 local new_md5=$(md5sum $dom)
23435 [ "$old_md5" != "$new_md5" ] &&
23436 error "$old_md5 != $new_md5"
23440 run_test 272f "DoM migration: OST-striped file to DOM file"
23443 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23444 skip "Need MDS version at least 2.11.50"
23446 # Layout swap cannot be done if either file has DOM component,
23447 # this will never be supported, migration should be used instead
23449 local dom=$DIR/$tdir/$tfile
23450 mkdir -p $DIR/$tdir
23452 $LFS setstripe -c2 ${dom}_plain
23453 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
23454 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
23455 error "can swap layout with DoM component"
23456 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
23457 error "can swap layout with DoM component"
23459 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
23460 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
23461 error "can swap layout with DoM component"
23462 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
23463 error "can swap layout with DoM component"
23466 run_test 273a "DoM: layout swapping should fail with DOM"
23469 mkdir -p $DIR/$tdir
23470 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
23472 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
23473 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
23475 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
23477 run_test 273b "DoM: race writeback and object destroy"
23480 remote_ost_nodsh && skip "remote OST with nodsh"
23481 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
23482 skip "Need OST version >= 2.10.57"
23484 local file=$DIR/$tfile
23487 oss=$(comma_list $(osts_nodes))
23489 dd if=/dev/urandom of=$file bs=1M count=2 ||
23490 error "failed to create a file"
23491 cancel_lru_locks osc
23494 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23495 error "failed to read a file"
23497 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
23498 $LCTL set_param fail_loc=0x8000031f
23500 cancel_lru_locks osc &
23503 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
23504 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
23505 #IO takes another lock, but matches the PENDING one
23506 #and places it to the IO RPC
23507 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23508 error "failed to read a file with PENDING lock"
23510 run_test 275 "Read on a canceled duplicate lock"
23513 remote_ost_nodsh && skip "remote OST with nodsh"
23516 do_facet ost1 "(while true; do \
23517 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
23518 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
23521 for LOOP in $(seq 20); do
23523 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
23526 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
23527 rm $TMP/sanity_276_pid"
23529 run_test 276 "Race between mount and obd_statfs"
23532 $LCTL set_param ldlm.namespaces.*.lru_size=0
23533 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23534 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23535 grep ^used_mb | awk '{print $2}')
23536 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
23537 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
23538 oflag=direct conv=notrunc
23539 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23540 grep ^used_mb | awk '{print $2}')
23541 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
23543 run_test 277 "Direct IO shall drop page cache"
23546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
23547 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23548 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
23549 skip "needs the same host for mdt1 mdt2" && return
23554 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
23555 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
23561 echo "Starting MDTs"
23562 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
23564 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
23566 do_facet mds2 $LCTL set_param fail_loc=0
23568 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
23569 wait_recovery_complete mds2
23571 run_test 278 "Race starting MDS between MDTs stop/start"
23574 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
23575 skip "Need MGS version at least 2.13.52"
23576 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23577 combined_mgs_mds || skip "needs combined MGS/MDT"
23579 umount_client $MOUNT
23580 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
23581 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
23583 mount_client $MOUNT &
23585 stop mgs || error "stop mgs failed"
23586 #for a race mgs would crash
23587 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
23588 # make sure we unmount client before remounting
23590 umount_client $MOUNT
23591 mount_client $MOUNT || error "mount client failed"
23593 run_test 280 "Race between MGS umount and client llog processing"
23595 cleanup_test_300() {
23599 test_striped_dir() {
23604 mkdir -p $DIR/$tdir
23606 SAVE_UMASK=$(umask)
23607 trap cleanup_test_300 RETURN EXIT
23609 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
23610 $DIR/$tdir/striped_dir ||
23611 error "set striped dir error"
23613 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
23614 [ "$mode" = "755" ] || error "expect 755 got $mode"
23616 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
23617 error "getdirstripe failed"
23618 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
23619 if [ "$stripe_count" != "2" ]; then
23620 error "1:stripe_count is $stripe_count, expect 2"
23622 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
23623 if [ "$stripe_count" != "2" ]; then
23624 error "2:stripe_count is $stripe_count, expect 2"
23627 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
23628 if [ "$stripe_index" != "$mdt_index" ]; then
23629 error "stripe_index is $stripe_index, expect $mdt_index"
23632 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23633 error "nlink error after create striped dir"
23635 mkdir $DIR/$tdir/striped_dir/a
23636 mkdir $DIR/$tdir/striped_dir/b
23638 stat $DIR/$tdir/striped_dir/a ||
23639 error "create dir under striped dir failed"
23640 stat $DIR/$tdir/striped_dir/b ||
23641 error "create dir under striped dir failed"
23643 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
23644 error "nlink error after mkdir"
23646 rmdir $DIR/$tdir/striped_dir/a
23647 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
23648 error "nlink error after rmdir"
23650 rmdir $DIR/$tdir/striped_dir/b
23651 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23652 error "nlink error after rmdir"
23654 chattr +i $DIR/$tdir/striped_dir
23655 createmany -o $DIR/$tdir/striped_dir/f 10 &&
23656 error "immutable flags not working under striped dir!"
23657 chattr -i $DIR/$tdir/striped_dir
23659 rmdir $DIR/$tdir/striped_dir ||
23660 error "rmdir striped dir error"
23668 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23669 skip "skipped for lustre < 2.7.0"
23670 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23671 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23673 test_striped_dir 0 || error "failed on striped dir on MDT0"
23674 test_striped_dir 1 || error "failed on striped dir on MDT0"
23676 run_test 300a "basic striped dir sanity test"
23679 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23680 skip "skipped for lustre < 2.7.0"
23681 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23682 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23689 test_mkdir $DIR/$tdir || error "mkdir fail"
23690 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23691 error "set striped dir error"
23692 for i in {0..9}; do
23693 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
23695 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
23696 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
23697 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
23699 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
23700 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
23701 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
23705 run_test 300b "check ctime/mtime for striped dir"
23708 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23709 skip "skipped for lustre < 2.7.0"
23710 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23711 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23715 mkdir_on_mdt0 $DIR/$tdir
23716 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
23717 error "set striped dir error"
23719 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
23720 error "chown striped dir failed"
23722 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
23723 error "create 5k files failed"
23725 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
23727 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
23731 run_test 300c "chown && check ls under striped directory"
23734 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23735 skip "skipped for lustre < 2.7.0"
23736 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23737 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23742 mkdir -p $DIR/$tdir
23743 $LFS setstripe -c 2 $DIR/$tdir
23745 #local striped directory
23746 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23747 error "set striped dir error"
23748 #look at the directories for debug purposes
23750 $LFS getdirstripe $DIR/$tdir
23751 ls -l $DIR/$tdir/striped_dir
23752 $LFS getdirstripe $DIR/$tdir/striped_dir
23753 createmany -o $DIR/$tdir/striped_dir/f 10 ||
23754 error "create 10 files failed"
23756 #remote striped directory
23757 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
23758 error "set striped dir error"
23759 #look at the directories for debug purposes
23761 $LFS getdirstripe $DIR/$tdir
23762 ls -l $DIR/$tdir/remote_striped_dir
23763 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
23764 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
23765 error "create 10 files failed"
23767 for file in $(find $DIR/$tdir); do
23768 stripe_count=$($LFS getstripe -c $file)
23769 [ $stripe_count -eq 2 ] ||
23770 error "wrong stripe $stripe_count for $file"
23775 run_test 300d "check default stripe under striped directory"
23778 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23779 skip "Need MDS version at least 2.7.55"
23780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23781 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23786 mkdir -p $DIR/$tdir
23788 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23789 error "set striped dir error"
23791 touch $DIR/$tdir/striped_dir/a
23792 touch $DIR/$tdir/striped_dir/b
23793 touch $DIR/$tdir/striped_dir/c
23795 mkdir $DIR/$tdir/striped_dir/dir_a
23796 mkdir $DIR/$tdir/striped_dir/dir_b
23797 mkdir $DIR/$tdir/striped_dir/dir_c
23799 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
23800 error "set striped adir under striped dir error"
23802 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
23803 error "set striped bdir under striped dir error"
23805 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
23806 error "set striped cdir under striped dir error"
23808 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
23809 error "rename dir under striped dir fails"
23811 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
23812 error "rename dir under different stripes fails"
23814 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
23815 error "rename file under striped dir should succeed"
23817 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
23818 error "rename dir under striped dir should succeed"
23822 run_test 300e "check rename under striped directory"
23825 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23826 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23827 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23828 skip "Need MDS version at least 2.7.55"
23834 mkdir -p $DIR/$tdir
23836 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23837 error "set striped dir error"
23839 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
23840 error "set striped dir error"
23842 touch $DIR/$tdir/striped_dir/a
23843 mkdir $DIR/$tdir/striped_dir/dir_a
23844 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
23845 error "create striped dir under striped dir fails"
23847 touch $DIR/$tdir/striped_dir1/b
23848 mkdir $DIR/$tdir/striped_dir1/dir_b
23849 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
23850 error "create striped dir under striped dir fails"
23852 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
23853 error "rename dir under different striped dir should fail"
23855 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
23856 error "rename striped dir under diff striped dir should fail"
23858 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
23859 error "rename file under diff striped dirs fails"
23863 run_test 300f "check rename cross striped directory"
23865 test_300_check_default_striped_dir()
23868 local default_count=$2
23869 local default_index=$3
23872 local dir_stripe_index
23875 echo "checking $dirname $default_count $default_index"
23876 $LFS setdirstripe -D -c $default_count -i $default_index \
23877 -H all_char $DIR/$tdir/$dirname ||
23878 error "set default stripe on striped dir error"
23879 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
23880 [ $stripe_count -eq $default_count ] ||
23881 error "expect $default_count get $stripe_count for $dirname"
23883 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
23884 [ $stripe_index -eq $default_index ] ||
23885 error "expect $default_index get $stripe_index for $dirname"
23887 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
23888 error "create dirs failed"
23890 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
23891 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
23892 for dir in $(find $DIR/$tdir/$dirname/*); do
23893 stripe_count=$($LFS getdirstripe -c $dir)
23894 (( $stripe_count == $default_count )) ||
23895 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
23896 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
23897 error "stripe count $default_count != $stripe_count for $dir"
23899 stripe_index=$($LFS getdirstripe -i $dir)
23900 [ $default_index -eq -1 ] ||
23901 [ $stripe_index -eq $default_index ] ||
23902 error "$stripe_index != $default_index for $dir"
23904 #check default stripe
23905 stripe_count=$($LFS getdirstripe -D -c $dir)
23906 [ $stripe_count -eq $default_count ] ||
23907 error "default count $default_count != $stripe_count for $dir"
23909 stripe_index=$($LFS getdirstripe -D -i $dir)
23910 [ $stripe_index -eq $default_index ] ||
23911 error "default index $default_index != $stripe_index for $dir"
23913 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
23917 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23918 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23919 skip "Need MDS version at least 2.7.55"
23925 mkdir_on_mdt0 $DIR/$tdir
23926 mkdir $DIR/$tdir/normal_dir
23928 #Checking when client cache stripe index
23929 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
23930 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
23931 error "create striped_dir failed"
23933 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
23934 error "create dir0 fails"
23935 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
23936 [ $stripe_index -eq 0 ] ||
23937 error "dir0 expect index 0 got $stripe_index"
23939 mkdir $DIR/$tdir/striped_dir/dir1 ||
23940 error "create dir1 fails"
23941 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
23942 [ $stripe_index -eq 1 ] ||
23943 error "dir1 expect index 1 got $stripe_index"
23945 #check default stripe count/stripe index
23946 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
23947 test_300_check_default_striped_dir normal_dir 1 0
23948 test_300_check_default_striped_dir normal_dir -1 1
23949 test_300_check_default_striped_dir normal_dir 2 -1
23951 #delete default stripe information
23952 echo "delete default stripeEA"
23953 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
23954 error "set default stripe on striped dir error"
23956 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
23957 for dir in $(find $DIR/$tdir/normal_dir/*); do
23958 stripe_count=$($LFS getdirstripe -c $dir)
23959 [ $stripe_count -eq 0 ] ||
23960 error "expect 1 get $stripe_count for $dir"
23963 run_test 300g "check default striped directory for normal directory"
23966 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23967 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23968 skip "Need MDS version at least 2.7.55"
23974 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23975 error "set striped dir error"
23977 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
23978 test_300_check_default_striped_dir striped_dir 1 0
23979 test_300_check_default_striped_dir striped_dir -1 1
23980 test_300_check_default_striped_dir striped_dir 2 -1
23982 #delete default stripe information
23983 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
23984 error "set default stripe on striped dir error"
23986 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
23987 for dir in $(find $DIR/$tdir/striped_dir/*); do
23988 stripe_count=$($LFS getdirstripe -c $dir)
23989 [ $stripe_count -eq 0 ] ||
23990 error "expect 1 get $stripe_count for $dir"
23993 run_test 300h "check default striped directory for striped directory"
23996 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
23997 (( $MDSCOUNT >= 2 )) || skip_env "needs >= 2 MDTs"
23998 (( $MDS1_VERSION >= $(version_code 2.7.55) )) ||
23999 skip "Need MDS version at least 2.7.55"
24006 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
24007 error "set striped dir error"
24009 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
24010 error "create files under striped dir failed"
24012 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
24013 error "set striped hashdir error"
24015 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
24016 error "create dir0 under hash dir failed"
24017 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
24018 error "create dir1 under hash dir failed"
24019 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
24020 error "create dir2 under hash dir failed"
24022 # unfortunately, we need to umount to clear dir layout cache for now
24023 # once we fully implement dir layout, we can drop this
24024 umount_client $MOUNT || error "umount failed"
24025 mount_client $MOUNT || error "mount failed"
24027 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
24028 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
24029 (( $dircnt == 2 )) || error "lfs find striped dir got $dircnt != 2"
24031 if (( $MDS1_VERSION > $(version_code 2.15.0) )); then
24032 $LFS mkdir -i0 -c$MDSCOUNT -H crush2 $DIR/$tdir/hashdir/d3 ||
24033 error "create crush2 dir $tdir/hashdir/d3 failed"
24034 $LFS find -H crush2 $DIR/$tdir/hashdir
24035 dircnt=$($LFS find -H crush2 $DIR/$tdir/hashdir | wc -l)
24036 (( $dircnt == 1 )) || error "find crush2 dir got $dircnt != 1"
24038 # mkdir with an invalid hash type (hash=fail_val) from client
24039 # should be replaced on MDS with a valid (default) hash type
24040 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
24041 $LCTL set_param fail_loc=0x1901 fail_val=99
24042 $LFS mkdir -c2 $DIR/$tdir/hashdir/d99
24044 local hash=$($LFS getdirstripe -H $DIR/$tdir/hashdir/d99)
24045 local expect=$(do_facet mds1 \
24046 $LCTL get_param -n lod.$FSNAME-MDT0000-mdtlov.mdt_hash)
24047 [[ $hash == $expect ]] ||
24048 error "d99 hash '$hash' != expected hash '$expect'"
24051 #set the stripe to be unknown hash type on read
24052 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
24053 $LCTL set_param fail_loc=0x1901 fail_val=99
24054 for ((i = 0; i < 10; i++)); do
24055 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
24056 error "stat f-$i failed"
24057 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
24060 touch $DIR/$tdir/striped_dir/f0 &&
24061 error "create under striped dir with unknown hash should fail"
24063 $LCTL set_param fail_loc=0
24065 umount_client $MOUNT || error "umount failed"
24066 mount_client $MOUNT || error "mount failed"
24070 run_test 300i "client handle unknown hash type striped directory"
24073 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24075 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24076 skip "Need MDS version at least 2.7.55"
24083 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
24084 $LCTL set_param fail_loc=0x1702
24085 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
24086 error "set striped dir error"
24088 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
24089 error "create files under striped dir failed"
24091 $LCTL set_param fail_loc=0
24093 rm -rf $DIR/$tdir || error "unlink striped dir fails"
24097 run_test 300j "test large update record"
24100 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24101 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24102 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24103 skip "Need MDS version at least 2.7.55"
24105 # this test needs a huge transaction
24107 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24108 osd*.$FSNAME-MDT0000.kbytestotal")
24109 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
24116 #define OBD_FAIL_LARGE_STRIPE 0x1703
24117 $LCTL set_param fail_loc=0x1703
24118 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
24119 error "set striped dir error"
24120 $LCTL set_param fail_loc=0
24122 $LFS getdirstripe $DIR/$tdir/striped_dir ||
24123 error "getstripeddir fails"
24124 rm -rf $DIR/$tdir/striped_dir ||
24125 error "unlink striped dir fails"
24129 run_test 300k "test large striped directory"
24132 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24133 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24134 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24135 skip "Need MDS version at least 2.7.55"
24139 test_mkdir -p $DIR/$tdir/striped_dir
24140 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
24141 error "chown $RUNAS_ID failed"
24142 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
24143 error "set default striped dir failed"
24145 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
24146 $LCTL set_param fail_loc=0x80000158
24147 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
24149 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
24150 [ $stripe_index -eq 1 ] ||
24151 error "expect 1 get $stripe_index for $dir"
24153 run_test 300l "non-root user to create dir under striped dir with stale layout"
24156 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24157 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
24158 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24159 skip "Need MDS version at least 2.7.55"
24161 mkdir -p $DIR/$tdir/striped_dir
24162 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
24163 error "set default stripes dir error"
24165 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
24167 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
24168 [ $stripe_count -eq 0 ] ||
24169 error "expect 0 get $stripe_count for a"
24171 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
24172 error "set default stripes dir error"
24174 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
24176 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
24177 [ $stripe_count -eq 0 ] ||
24178 error "expect 0 get $stripe_count for b"
24180 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
24181 error "set default stripes dir error"
24183 mkdir $DIR/$tdir/striped_dir/c &&
24184 error "default stripe_index is invalid, mkdir c should fails"
24186 rm -rf $DIR/$tdir || error "rmdir fails"
24188 run_test 300m "setstriped directory on single MDT FS"
24191 local list=$(comma_list $(mdts_nodes))
24194 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24198 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24199 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24200 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24201 skip "Need MDS version at least 2.7.55"
24202 remote_mds_nodsh && skip "remote MDS with nodsh"
24205 local list=$(comma_list $(mdts_nodes))
24207 trap cleanup_300n RETURN EXIT
24208 mkdir -p $DIR/$tdir
24209 chmod 777 $DIR/$tdir
24210 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
24211 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
24212 error "create striped dir succeeds with gid=0"
24214 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
24215 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
24216 error "create striped dir fails with gid=-1"
24218 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24219 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
24220 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
24221 error "set default striped dir succeeds with gid=0"
24224 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
24225 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
24226 error "set default striped dir fails with gid=-1"
24229 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24230 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
24231 error "create test_dir fails"
24232 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
24233 error "create test_dir1 fails"
24234 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
24235 error "create test_dir2 fails"
24238 run_test 300n "non-root user to create dir under striped dir with default EA"
24241 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24242 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24243 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24244 skip "Need MDS version at least 2.7.55"
24249 mkdir -p $DIR/$tdir
24251 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
24252 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
24253 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
24254 skip "not enough free inodes $numfree1 $numfree2"
24257 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
24258 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
24259 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
24260 skip "not enough free space $numfree1 $numfree2"
24263 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
24264 error "setdirstripe fails"
24266 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
24267 error "create dirs fails"
24269 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
24270 ls $DIR/$tdir/striped_dir > /dev/null ||
24271 error "ls striped dir fails"
24272 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
24273 error "unlink big striped dir fails"
24275 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
24278 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24279 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24280 remote_mds_nodsh && skip "remote MDS with nodsh"
24282 mkdir_on_mdt0 $DIR/$tdir
24284 #define OBD_FAIL_OUT_ENOSPC 0x1704
24285 do_facet mds2 lctl set_param fail_loc=0x80001704
24286 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
24287 && error "create striped directory should fail"
24289 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
24291 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
24294 run_test 300p "create striped directory without space"
24297 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24298 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24300 local fd=$(free_fd)
24301 local cmd="exec $fd<$tdir"
24303 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
24306 trap "eval $cmd" EXIT
24307 cd $tdir || error "cd $tdir fails"
24308 rmdir ../$tdir || error "rmdir $tdir fails"
24309 mkdir local_dir && error "create dir succeeds"
24310 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
24314 run_test 300q "create remote directory under orphan directory"
24317 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24318 skip "Need MDS version at least 2.7.55" && return
24319 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24323 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
24324 error "set striped dir error"
24326 $LFS getdirstripe $DIR/$tdir/striped_dir ||
24327 error "getstripeddir fails"
24330 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
24331 awk '/lmv_stripe_count:/ { print $2 }')
24333 [ $MDSCOUNT -ne $stripe_count ] &&
24334 error "wrong stripe count $stripe_count expected $MDSCOUNT"
24336 rm -rf $DIR/$tdir/striped_dir ||
24337 error "unlink striped dir fails"
24339 run_test 300r "test -1 striped directory"
24341 test_300s_helper() {
24344 local stripe_dir=$DIR/$tdir/striped_dir.$count
24346 $LFS mkdir -c $count $stripe_dir ||
24347 error "lfs mkdir -c error"
24349 $LFS getdirstripe $stripe_dir ||
24350 error "lfs getdirstripe fails"
24353 stripe_count=$($LFS getdirstripe $stripe_dir |
24354 awk '/lmv_stripe_count:/ { print $2 }')
24356 [ $count -ne $stripe_count ] &&
24357 error_noexit "bad stripe count $stripe_count expected $count"
24360 dupe_stripes=$($LFS getdirstripe $stripe_dir |
24361 awk '/0x/ {count[$1] += 1}; END {
24362 for (idx in count) {
24363 if (count[idx]>1) {
24364 print "index " idx " count " count[idx]
24369 if [[ -n "$dupe_stripes" ]] ; then
24370 lfs getdirstripe $stripe_dir
24371 error_noexit "Dupe MDT above: $dupe_stripes "
24374 rm -rf $stripe_dir ||
24375 error_noexit "unlink $stripe_dir fails"
24379 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24380 skip "Need MDS version at least 2.7.55" && return
24381 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24384 for count in $(seq 2 $MDSCOUNT); do
24385 test_300s_helper $count
24388 run_test 300s "test lfs mkdir -c without -i"
24391 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
24392 skip "need MDS 2.14.55 or later"
24393 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
24395 local testdir="$DIR/$tdir/striped_dir"
24396 local dir1=$testdir/dir1
24397 local dir2=$testdir/dir2
24401 $LFS setdirstripe -D -c -1 --max-inherit=3 $testdir ||
24402 error "failed to set default stripe count for $testdir"
24405 local stripe_count=$($LFS getdirstripe -c $dir1)
24407 (( $stripe_count == $MDSCOUNT )) || error "wrong stripe count"
24409 local max_count=$((MDSCOUNT - 1))
24410 local mdts=$(comma_list $(mdts_nodes))
24412 do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=$max_count
24413 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=0"
24416 stripe_count=$($LFS getdirstripe -c $dir2)
24418 (( $stripe_count == $max_count )) || error "wrong stripe count"
24420 run_test 300t "test max_mdt_stripecount"
24422 prepare_remote_file() {
24423 mkdir $DIR/$tdir/src_dir ||
24424 error "create remote source failed"
24426 cp /etc/hosts $DIR/$tdir/src_dir/a ||
24427 error "cp to remote source failed"
24428 touch $DIR/$tdir/src_dir/a
24430 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
24431 error "create remote target dir failed"
24433 touch $DIR/$tdir/tgt_dir/b
24435 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
24436 error "rename dir cross MDT failed!"
24438 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
24439 error "src_child still exists after rename"
24441 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
24442 error "missing file(a) after rename"
24444 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
24445 error "diff after rename"
24449 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24450 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24452 local remote_file=$DIR/$tdir/tgt_dir/b
24454 mkdir -p $DIR/$tdir
24456 prepare_remote_file || error "prepare remote file failed"
24459 $OPENUNLINK $remote_file $remote_file ||
24460 error "openunlink $remote_file failed"
24461 $CHECKSTAT -a $remote_file || error "$remote_file exists"
24463 run_test 310a "open unlink remote file"
24466 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24467 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24469 local remote_file=$DIR/$tdir/tgt_dir/b
24471 mkdir -p $DIR/$tdir
24473 prepare_remote_file || error "prepare remote file failed"
24475 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24476 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
24477 $CHECKSTAT -t file $remote_file || error "check file failed"
24479 run_test 310b "unlink remote file with multiple links while open"
24482 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24483 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
24485 local remote_file=$DIR/$tdir/tgt_dir/b
24487 mkdir -p $DIR/$tdir
24489 prepare_remote_file || error "prepare remote file failed"
24491 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24492 multiop_bg_pause $remote_file O_uc ||
24493 error "mulitop failed for remote file"
24495 $MULTIOP $DIR/$tfile Ouc
24496 kill -USR1 $MULTIPID
24499 run_test 310c "open-unlink remote file with multiple links"
24503 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24504 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
24505 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
24506 skip "lustre < 2.8.54 does not contain LU-4825 fix"
24507 remote_mds_nodsh && skip "remote MDS with nodsh"
24509 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24510 local mdts=$(comma_list $(mdts_nodes))
24512 mkdir -p $DIR/$tdir
24513 $LFS setstripe -i 0 -c 1 $DIR/$tdir
24514 createmany -o $DIR/$tdir/$tfile. 1000
24516 # statfs data is not real time, let's just calculate it
24517 old_iused=$((old_iused + 1000))
24519 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24520 osp.*OST0000*MDT0000.create_count")
24521 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24522 osp.*OST0000*MDT0000.max_create_count")
24523 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
24525 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
24526 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
24527 [ $index -ne 0 ] || error "$tfile stripe index is 0"
24529 unlinkmany $DIR/$tdir/$tfile. 1000
24531 do_nodes $mdts "$LCTL set_param -n \
24532 osp.*OST0000*.max_create_count=$max_count"
24533 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
24534 do_nodes $mdts "$LCTL set_param -n \
24535 osp.*OST0000*.create_count=$count"
24536 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
24537 grep "=0" && error "create_count is zero"
24540 for i in $(seq 120); do
24541 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24542 # system may be too busy to destroy all objs in time, use
24543 # a somewhat small value to not fail autotest
24544 [ $((old_iused - new_iused)) -gt 400 ] && break
24548 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
24549 [ $((old_iused - new_iused)) -gt 400 ] ||
24550 error "objs not destroyed after unlink"
24552 run_test 311 "disable OSP precreate, and unlink should destroy objs"
24559 local vdevdir=$(dirname $(facet_vdevice $ost))
24560 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
24561 local zfs_zapid=$(do_facet $ost $cmd |
24562 grep -w "/O/0/d$((objid%32))" -C 5 |
24563 awk '/Object/{getline; print $1}')
24564 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
24565 awk "/$objid = /"'{printf $3}')
24570 zfs_object_blksz() {
24574 local vdevdir=$(dirname $(facet_vdevice $ost))
24575 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
24576 local blksz=$(do_facet $ost $cmd $objid |
24577 awk '/dblk/{getline; printf $4}')
24579 case "${blksz: -1}" in
24580 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
24581 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
24588 test_312() { # LU-4856
24589 remote_ost_nodsh && skip "remote OST with nodsh"
24590 [ "$ost1_FSTYPE" = "zfs" ] ||
24591 skip_env "the test only applies to zfs"
24593 local max_blksz=$(do_facet ost1 \
24594 $ZFS get -p recordsize $(facet_device ost1) |
24595 awk '!/VALUE/{print $3}')
24597 # to make life a little bit easier
24598 $LFS mkdir -c 1 -i 0 $DIR/$tdir
24599 $LFS setstripe -c 1 -i 0 $DIR/$tdir
24601 local tf=$DIR/$tdir/$tfile
24603 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24605 # Get ZFS object id
24606 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24607 # block size change by sequential overwrite
24610 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
24611 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
24613 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
24614 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
24618 # block size change by sequential append write
24619 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
24620 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24621 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24624 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
24625 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
24626 oflag=sync conv=notrunc
24628 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24629 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
24630 error "blksz error, actual $blksz, " \
24631 "expected: 2 * $count * $PAGE_SIZE"
24637 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24638 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24640 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
24641 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24642 [ $blksz -eq $PAGE_SIZE ] ||
24643 error "blksz error: $blksz, expected: $PAGE_SIZE"
24645 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
24646 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24647 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
24649 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
24650 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24651 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
24653 run_test 312 "make sure ZFS adjusts its block size by write pattern"
24656 remote_ost_nodsh && skip "remote OST with nodsh"
24658 local file=$DIR/$tfile
24661 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
24663 # define OBD_FAIL_TGT_RCVD_EIO 0x720
24664 do_facet ost1 "$LCTL set_param fail_loc=0x720"
24665 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
24666 error "write should failed"
24667 do_facet ost1 "$LCTL set_param fail_loc=0"
24670 run_test 313 "io should fail after last_rcvd update fail"
24673 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
24675 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
24676 do_facet ost1 "$LCTL set_param fail_loc=0x720"
24678 wait_delete_completed
24679 do_facet ost1 "$LCTL set_param fail_loc=0"
24681 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
24683 test_315() { # LU-618
24684 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
24686 local file=$DIR/$tfile
24689 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
24690 error "multiop file write failed"
24691 $MULTIOP $file oO_RDONLY:r4063232_c &
24696 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
24699 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
24702 run_test 315 "read should be accounted"
24705 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
24706 large_xattr_enabled || skip "ea_inode feature disabled"
24708 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
24709 mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
24710 chown nobody $DIR/$tdir/d || error "chown $tdir/d failed"
24711 touch $DIR/$tdir/d/$tfile || error "touch $tdir/d/$tfile failed"
24713 $LFS migrate -m1 $DIR/$tdir/d || error "lfs migrate -m1 failed"
24715 run_test 316 "lfs migrate of file with large_xattr enabled"
24718 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
24719 skip "Need MDS version at least 2.11.53"
24720 if [ "$ost1_FSTYPE" == "zfs" ]; then
24721 skip "LU-10370: no implementation for ZFS"
24725 local grant_blk_size
24727 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
24728 awk '/grant_block_size:/ { print $2; exit; }')
24730 # Create File of size 5M. Truncate it to below size's and verify
24733 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
24734 error "Create file $DIR/$tfile failed"
24735 stack_trap "rm -f $DIR/$tfile" EXIT
24737 for trunc_sz in 2097152 4097 4000 509 0; do
24738 $TRUNCATE $DIR/$tfile $trunc_sz ||
24739 error "truncate $tfile to $trunc_sz failed"
24740 local sz=$(stat --format=%s $DIR/$tfile)
24741 local blk=$(stat --format=%b $DIR/$tfile)
24742 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
24743 grant_blk_size) * 8))
24745 if [[ $blk -ne $trunc_blk ]]; then
24746 $(which stat) $DIR/$tfile
24747 error "Expected Block $trunc_blk got $blk for $tfile"
24750 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
24751 error "Expected Size $trunc_sz got $sz for $tfile"
24756 # Create file with a hole and write actual 65536 bytes which aligned
24757 # with 4K and 64K PAGE_SIZE. Block count must be 128.
24760 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 seek=5 conv=fsync ||
24761 error "Create file : $DIR/$tfile"
24764 # Truncate to size $trunc_sz bytes. Strip tail blocks and leave only 8
24765 # blocks. The block count must drop to 8.
24767 trunc_sz=$(($(stat --format=%s $DIR/$tfile) -
24768 ((bs - grant_blk_size) + 1)))
24769 $TRUNCATE $DIR/$tfile $trunc_sz ||
24770 error "truncate $tfile to $trunc_sz failed"
24772 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
24773 sz=$(stat --format=%s $DIR/$tfile)
24774 blk=$(stat --format=%b $DIR/$tfile)
24776 if [[ $blk -ne $trunc_bsz ]]; then
24777 $(which stat) $DIR/$tfile
24778 error "Expected Block $trunc_bsz got $blk for $tfile"
24781 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
24782 error "Expected Size $trunc_sz got $sz for $tfile"
24784 run_test 317 "Verify blocks get correctly update after truncate"
24787 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
24788 local old_max_active=$($LCTL get_param -n \
24789 ${llite_name}.max_read_ahead_async_active \
24792 $LCTL set_param llite.*.max_read_ahead_async_active=256
24793 local max_active=$($LCTL get_param -n \
24794 ${llite_name}.max_read_ahead_async_active \
24796 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
24798 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
24799 error "set max_read_ahead_async_active should succeed"
24801 $LCTL set_param llite.*.max_read_ahead_async_active=512
24802 max_active=$($LCTL get_param -n \
24803 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
24804 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
24806 # restore @max_active
24807 [ $old_max_active -ne 0 ] && $LCTL set_param \
24808 llite.*.max_read_ahead_async_active=$old_max_active
24810 local old_threshold=$($LCTL get_param -n \
24811 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
24812 local max_per_file_mb=$($LCTL get_param -n \
24813 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
24815 local invalid=$(($max_per_file_mb + 1))
24817 llite.*.read_ahead_async_file_threshold_mb=$invalid\
24818 && error "set $invalid should fail"
24820 local valid=$(($invalid - 1))
24822 llite.*.read_ahead_async_file_threshold_mb=$valid ||
24823 error "set $valid should succeed"
24824 local threshold=$($LCTL get_param -n \
24825 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
24826 [ $threshold -eq $valid ] || error \
24827 "expect threshold $valid got $threshold"
24829 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
24831 run_test 318 "Verify async readahead tunables"
24834 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
24836 local before=$(date +%s)
24838 local mdir=$DIR/$tdir
24839 local file=$mdir/xxx
24841 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
24844 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
24845 $LCTL set_param fail_val=5 fail_loc=0x8000032c
24846 $LFS migrate -m1 $mdir &
24849 dd if=$file of=/dev/null
24851 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
24852 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
24854 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
24856 run_test 319 "lost lease lock on migrate error"
24858 test_398a() { # LU-4198
24859 local ost1_imp=$(get_osc_import_name client ost1)
24860 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24863 $LFS setstripe -c 1 -i 0 $DIR/$tfile
24864 $LCTL set_param ldlm.namespaces.*.lru_size=clear
24866 # Disabled: DIO does not push out buffered I/O pages, see LU-12587
24867 # request a new lock on client
24868 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24870 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
24871 #local lock_count=$($LCTL get_param -n \
24872 # ldlm.namespaces.$imp_name.lru_size)
24873 #[[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
24875 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
24877 # no lock cached, should use lockless DIO and not enqueue new lock
24878 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct \
24880 error "dio write failed"
24881 lock_count=$($LCTL get_param -n \
24882 ldlm.namespaces.$imp_name.lru_size)
24883 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
24885 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
24887 # no lock cached, should use locked DIO append
24888 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct oflag=append \
24889 conv=notrunc || error "DIO append failed"
24890 lock_count=$($LCTL get_param -n \
24891 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
24892 [[ $lock_count -ne 0 ]] || error "lock still must be held by DIO append"
24894 run_test 398a "direct IO should cancel lock otherwise lockless"
24896 test_398b() { # LU-4198
24897 which fio || skip_env "no fio installed"
24898 $LFS setstripe -c -1 -S 1M $DIR/$tfile
24901 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
24904 # Single page, multiple pages, stripe size, 4*stripe size
24905 for bsize in $(( $PAGE_SIZE )) $(( 4*$PAGE_SIZE )) 1048576 4194304; do
24906 echo "mix direct rw ${bsize} by fio with $njobs jobs..."
24907 fio --name=rand-rw --rw=randrw --bs=$bsize --direct=1 \
24908 --numjobs=$njobs --fallocate=none \
24909 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24910 --filename=$DIR/$tfile &
24913 echo "mix buffer rw ${bsize} by fio with $njobs jobs..."
24914 fio --name=rand-rw --rw=randrw --bs=$bsize \
24915 --numjobs=$njobs --fallocate=none \
24916 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24917 --filename=$DIR/$tfile || true
24921 evict=$(do_facet client $LCTL get_param \
24922 osc.$FSNAME-OST*-osc-*/state |
24923 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
24925 [ -z "$evict" ] || [[ $evict -le $before ]] ||
24926 (do_facet client $LCTL get_param \
24927 osc.$FSNAME-OST*-osc-*/state;
24928 error "eviction happened: $evict before:$before")
24932 run_test 398b "DIO and buffer IO race"
24934 test_398c() { # LU-4198
24935 local ost1_imp=$(get_osc_import_name client ost1)
24936 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24939 which fio || skip_env "no fio installed"
24941 saved_debug=$($LCTL get_param -n debug)
24942 $LCTL set_param debug=0
24944 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
24945 ((size /= 1024)) # by megabytes
24946 ((size /= 2)) # write half of the OST at most
24947 [ $size -gt 40 ] && size=40 #reduce test time anyway
24949 $LFS setstripe -c 1 $DIR/$tfile
24951 # it seems like ldiskfs reserves more space than necessary if the
24952 # writing blocks are not mapped, so it extends the file firstly
24953 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
24954 cancel_lru_locks osc
24956 # clear and verify rpc_stats later
24957 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
24960 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
24961 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
24962 --numjobs=$njobs --fallocate=none --ioengine=libaio \
24963 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24964 --filename=$DIR/$tfile
24965 [ $? -eq 0 ] || error "fio write error"
24967 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
24968 error "Locks were requested while doing AIO"
24970 # get the percentage of 1-page I/O
24971 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
24972 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
24974 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
24976 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
24977 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
24978 --numjobs=$njobs --fallocate=none --ioengine=libaio \
24979 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24980 --filename=$DIR/$tfile
24981 [ $? -eq 0 ] || error "fio mixed read write error"
24983 echo "AIO with large block size ${size}M"
24984 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
24985 --numjobs=1 --fallocate=none --ioengine=libaio \
24986 --iodepth=16 --allow_file_create=0 --size=${size}M \
24987 --filename=$DIR/$tfile
24988 [ $? -eq 0 ] || error "fio large block size failed"
24991 $LCTL set_param debug="$saved_debug"
24993 run_test 398c "run fio to test AIO"
24995 test_398d() { # LU-13846
24996 which aiocp || skip_env "no aiocp installed"
24997 local aio_file=$DIR/$tfile.aio
24999 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
25001 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
25002 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
25003 stack_trap "rm -f $DIR/$tfile $aio_file"
25005 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
25007 # make sure we don't crash and fail properly
25008 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
25009 error "aio not aligned with PAGE SIZE should fail"
25011 rm -f $DIR/$tfile $aio_file
25013 run_test 398d "run aiocp to verify block size > stripe size"
25016 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
25017 touch $DIR/$tfile.new
25018 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
25020 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
25022 test_398f() { # LU-14687
25023 which aiocp || skip_env "no aiocp installed"
25024 local aio_file=$DIR/$tfile.aio
25026 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
25028 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
25029 stack_trap "rm -f $DIR/$tfile $aio_file"
25031 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
25032 $LCTL set_param fail_loc=0x1418
25033 # make sure we don't crash and fail properly
25034 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
25035 error "aio with page allocation failure succeeded"
25036 $LCTL set_param fail_loc=0
25037 diff $DIR/$tfile $aio_file
25038 [[ $? != 0 ]] || error "no diff after failed aiocp"
25040 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
25042 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
25043 # stripe and i/o size must be > stripe size
25044 # Old style synchronous DIO waits after submitting each chunk, resulting in a
25045 # single RPC in flight. This test shows async DIO submission is working by
25046 # showing multiple RPCs in flight.
25047 test_398g() { # LU-13798
25048 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
25050 # We need to do some i/o first to acquire enough grant to put our RPCs
25051 # in flight; otherwise a new connection may not have enough grant
25053 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25054 error "parallel dio failed"
25055 stack_trap "rm -f $DIR/$tfile"
25057 # Reduce RPC size to 1M to avoid combination in to larger RPCs
25058 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
25059 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
25060 stack_trap "$LCTL set_param -n $pages_per_rpc"
25062 # Recreate file so it's empty
25064 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
25065 #Pause rpc completion to guarantee we see multiple rpcs in flight
25066 #define OBD_FAIL_OST_BRW_PAUSE_BULK
25067 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
25068 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25071 $LCTL set_param osc.*.rpc_stats=c
25073 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25074 error "parallel dio failed"
25075 stack_trap "rm -f $DIR/$tfile"
25077 $LCTL get_param osc.*-OST0000-*.rpc_stats
25078 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
25079 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
25080 grep "8:" | awk '{print $8}')
25081 # We look at the "8 rpcs in flight" field, and verify A) it is present
25082 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
25083 # as expected for an 8M DIO to a file with 1M stripes.
25084 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
25086 # Verify turning off parallel dio works as expected
25088 $LCTL set_param osc.*.rpc_stats=c
25089 $LCTL set_param llite.*.parallel_dio=0
25090 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
25092 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25093 error "dio with parallel dio disabled failed"
25095 # Ideally, we would see only one RPC in flight here, but there is an
25096 # unavoidable race between i/o completion and RPC in flight counting,
25097 # so while only 1 i/o is in flight at a time, the RPC in flight counter
25098 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
25099 # So instead we just verify it's always < 8.
25100 $LCTL get_param osc.*-OST0000-*.rpc_stats
25101 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
25102 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
25103 grep '^$' -B1 | grep . | awk '{print $1}')
25104 [ $ret != "8:" ] ||
25105 error "we should see fewer than 8 RPCs in flight (saw $ret)"
25107 run_test 398g "verify parallel dio async RPC submission"
25109 test_398h() { # LU-13798
25110 local dio_file=$DIR/$tfile.dio
25112 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
25114 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25115 stack_trap "rm -f $DIR/$tfile $dio_file"
25117 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
25118 error "parallel dio failed"
25119 diff $DIR/$tfile $dio_file
25120 [[ $? == 0 ]] || error "file diff after aiocp"
25122 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
25124 test_398i() { # LU-13798
25125 local dio_file=$DIR/$tfile.dio
25127 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
25129 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25130 stack_trap "rm -f $DIR/$tfile $dio_file"
25132 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
25133 $LCTL set_param fail_loc=0x1418
25134 # make sure we don't crash and fail properly
25135 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
25136 error "parallel dio page allocation failure succeeded"
25137 diff $DIR/$tfile $dio_file
25138 [[ $? != 0 ]] || error "no diff after failed aiocp"
25140 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
25142 test_398j() { # LU-13798
25143 # Stripe size > RPC size but less than i/o size tests split across
25144 # stripes and RPCs for individual i/o op
25145 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
25147 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
25148 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
25149 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
25150 stack_trap "$LCTL set_param -n $pages_per_rpc"
25152 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25153 error "parallel dio write failed"
25154 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
25156 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
25157 error "parallel dio read failed"
25158 diff $DIR/$tfile $DIR/$tfile.2
25159 [[ $? == 0 ]] || error "file diff after parallel dio read"
25161 run_test 398j "test parallel dio where stripe size > rpc_size"
25163 test_398k() { # LU-13798
25164 wait_delete_completed
25167 # 4 stripe file; we will cause out of space on OST0
25168 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
25170 # Fill OST0 (if it's not too large)
25171 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
25173 if [[ $ORIGFREE -gt $MAXFREE ]]; then
25174 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
25176 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
25177 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
25178 error "dd should fill OST0"
25179 stack_trap "rm -f $DIR/$tfile.1"
25181 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25185 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
25186 error "file is not 0 bytes in size"
25188 # dd above should not succeed, but don't error until here so we can
25189 # get debug info above
25191 error "parallel dio write with enospc succeeded"
25192 stack_trap "rm -f $DIR/$tfile"
25194 run_test 398k "test enospc on first stripe"
25196 test_398l() { # LU-13798
25197 wait_delete_completed
25200 # 4 stripe file; we will cause out of space on OST0
25201 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
25202 # happens on the second i/o chunk we issue
25203 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
25205 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
25206 stack_trap "rm -f $DIR/$tfile"
25208 # Fill OST0 (if it's not too large)
25209 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
25211 if [[ $ORIGFREE -gt $MAXFREE ]]; then
25212 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
25214 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
25215 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
25216 error "dd should fill OST0"
25217 stack_trap "rm -f $DIR/$tfile.1"
25219 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
25221 stack_trap "rm -f $DIR/$tfile.2"
25223 # Check that short write completed as expected
25224 ls -la $DIR/$tfile.2
25225 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
25226 error "file is not 1M in size"
25228 # dd above should not succeed, but don't error until here so we can
25229 # get debug info above
25231 error "parallel dio write with enospc succeeded"
25233 # Truncate source file to same length as output file and diff them
25234 $TRUNCATE $DIR/$tfile 1048576
25235 diff $DIR/$tfile $DIR/$tfile.2
25236 [[ $? == 0 ]] || error "data incorrect after short write"
25238 run_test 398l "test enospc on intermediate stripe/RPC"
25240 test_398m() { # LU-13798
25241 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
25243 # Set up failure on OST0, the first stripe:
25244 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
25245 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
25246 # So this fail_val specifies OST0
25247 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
25248 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25250 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
25251 error "parallel dio write with failure on first stripe succeeded"
25252 stack_trap "rm -f $DIR/$tfile"
25253 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25255 # Place data in file for read
25256 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25257 error "parallel dio write failed"
25259 # Fail read on OST0, first stripe
25260 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
25261 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
25262 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
25263 error "parallel dio read with error on first stripe succeeded"
25264 rm -f $DIR/$tfile.2
25265 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25267 # Switch to testing on OST1, second stripe
25268 # Clear file contents, maintain striping
25270 # Set up failure on OST1, second stripe:
25271 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=2
25272 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25274 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
25275 error "parallel dio write with failure on first stripe succeeded"
25276 stack_trap "rm -f $DIR/$tfile"
25277 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25279 # Place data in file for read
25280 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25281 error "parallel dio write failed"
25283 # Fail read on OST1, second stripe
25284 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
25285 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
25286 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
25287 error "parallel dio read with error on first stripe succeeded"
25288 rm -f $DIR/$tfile.2
25289 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
25291 run_test 398m "test RPC failures with parallel dio"
25293 # Parallel submission of DIO should not cause problems for append, but it's
25294 # important to verify.
25295 test_398n() { # LU-13798
25296 $LFS setstripe -C 2 -S 1M $DIR/$tfile
25298 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
25299 error "dd to create source file failed"
25300 stack_trap "rm -f $DIR/$tfile"
25302 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
25303 error "parallel dio write with failure on second stripe succeeded"
25304 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
25305 diff $DIR/$tfile $DIR/$tfile.1
25306 [[ $? == 0 ]] || error "data incorrect after append"
25309 run_test 398n "test append with parallel DIO"
25312 directio rdwr $DIR/$tfile 0 1 1 || error "bad KMS"
25314 run_test 398o "right kms with DIO"
25317 local read_write=$1
25318 if [ "$read_write" = "write" ]; then
25319 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
25320 elif [ "$read_write" = "read" ]; then
25321 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
25323 error "argument error"
25326 # turn off debug for performance testing
25327 local saved_debug=$($LCTL get_param -n debug)
25328 $LCTL set_param debug=0
25330 $LFS setstripe -c 1 -i 0 $DIR/$tfile
25332 # get ost1 size - $FSNAME-OST0000
25333 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
25334 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
25335 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
25337 if [ "$read_write" = "read" ]; then
25338 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
25341 local start_time=$(date +%s.%N)
25342 $dd_cmd bs=1M count=$blocks oflag=sync ||
25343 error "real dd $read_write error"
25344 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
25346 if [ "$read_write" = "write" ]; then
25350 # define OBD_FAIL_OST_FAKE_RW 0x238
25351 do_facet ost1 $LCTL set_param fail_loc=0x238
25353 local start_time=$(date +%s.%N)
25354 $dd_cmd bs=1M count=$blocks oflag=sync ||
25355 error "fake dd $read_write error"
25356 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
25358 if [ "$read_write" = "write" ]; then
25360 cancel_lru_locks osc
25361 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
25362 error "$tfile size not $blocks MB"
25364 do_facet ost1 $LCTL set_param fail_loc=0
25366 echo "fake $read_write $duration_fake vs. normal $read_write" \
25367 "$duration in seconds"
25368 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
25369 error_not_in_vm "fake write is slower"
25371 $LCTL set_param -n debug="$saved_debug"
25374 test_399a() { # LU-7655 for OST fake write
25375 remote_ost_nodsh && skip "remote OST with nodsh"
25379 run_test 399a "fake write should not be slower than normal write"
25381 test_399b() { # LU-8726 for OST fake read
25382 remote_ost_nodsh && skip "remote OST with nodsh"
25383 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
25384 skip_env "ldiskfs only test"
25389 run_test 399b "fake read should not be slower than normal read"
25391 test_400a() { # LU-1606, was conf-sanity test_74
25392 if ! which $CC > /dev/null 2>&1; then
25393 skip_env "$CC is not installed"
25396 local extra_flags=''
25397 local out=$TMP/$tfile
25398 local prefix=/usr/include/lustre
25401 # Oleg removes c files in his test rig so test if any c files exist
25402 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
25403 skip_env "Needed c test files are missing"
25405 if ! [[ -d $prefix ]]; then
25406 # Assume we're running in tree and fixup the include path.
25407 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
25408 extra_flags+=" -L$LUSTRE/utils/.lib"
25411 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
25412 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
25413 error "client api broken"
25417 run_test 400a "Lustre client api program can compile and link"
25419 test_400b() { # LU-1606, LU-5011
25421 local out=$TMP/$tfile
25422 local prefix=/usr/include/linux/lustre
25424 # We use a hard coded prefix so that this test will not fail
25425 # when run in tree. There are headers in lustre/include/lustre/
25426 # that are not packaged (like lustre_idl.h) and have more
25427 # complicated include dependencies (like config.h and lnet/types.h).
25428 # Since this test about correct packaging we just skip them when
25429 # they don't exist (see below) rather than try to fixup cppflags.
25431 if ! which $CC > /dev/null 2>&1; then
25432 skip_env "$CC is not installed"
25435 for header in $prefix/*.h; do
25436 if ! [[ -f "$header" ]]; then
25440 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
25441 continue # lustre_ioctl.h is internal header
25444 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
25445 error "cannot compile '$header'"
25449 run_test 400b "packaged headers can be compiled"
25451 test_401a() { #LU-7437
25452 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
25453 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
25455 #count the number of parameters by "list_param -R"
25456 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
25457 #count the number of parameters by listing proc files
25458 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
25459 echo "proc_dirs='$proc_dirs'"
25460 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
25461 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
25464 [ $params -eq $procs ] ||
25465 error "found $params parameters vs. $procs proc files"
25467 # test the list_param -D option only returns directories
25468 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
25469 #count the number of parameters by listing proc directories
25470 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
25473 [ $params -eq $procs ] ||
25474 error "found $params parameters vs. $procs proc files"
25476 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
25479 # jobid_var may not allow arbitrary values, so use jobid_name
25481 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25482 local testname=jobid_name tmp='testing%p'
25484 local testname=jobid_var tmp=testing
25487 local save=$($LCTL get_param -n $testname)
25489 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
25490 error "no error returned when setting bad parameters"
25492 local jobid_new=$($LCTL get_param -n foe $testname baz)
25493 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
25495 $LCTL set_param -n fog=bam $testname=$save bat=fog
25496 local jobid_old=$($LCTL get_param -n foe $testname bag)
25497 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
25499 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
25502 # jobid_var may not allow arbitrary values, so use jobid_name
25504 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25505 local testname=jobid_name
25507 local testname=jobid_var
25510 local jobid_var_old=$($LCTL get_param -n $testname)
25511 local jobid_var_new
25513 $LCTL set_param $testname= &&
25514 error "no error returned for 'set_param a='"
25516 jobid_var_new=$($LCTL get_param -n $testname)
25517 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25518 error "$testname was changed by setting without value"
25520 $LCTL set_param $testname &&
25521 error "no error returned for 'set_param a'"
25523 jobid_var_new=$($LCTL get_param -n $testname)
25524 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25525 error "$testname was changed by setting without value"
25527 run_test 401c "Verify 'lctl set_param' without value fails in either format."
25530 # jobid_var may not allow arbitrary values, so use jobid_name
25532 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25533 local testname=jobid_name new_value='foo=bar%p'
25535 local testname=jobid_var new_valuie=foo=bar
25538 local jobid_var_old=$($LCTL get_param -n $testname)
25539 local jobid_var_new
25541 $LCTL set_param $testname=$new_value ||
25542 error "'set_param a=b' did not accept a value containing '='"
25544 jobid_var_new=$($LCTL get_param -n $testname)
25545 [[ "$jobid_var_new" == "$new_value" ]] ||
25546 error "'set_param a=b' failed on a value containing '='"
25548 # Reset the $testname to test the other format
25549 $LCTL set_param $testname=$jobid_var_old
25550 jobid_var_new=$($LCTL get_param -n $testname)
25551 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25552 error "failed to reset $testname"
25554 $LCTL set_param $testname $new_value ||
25555 error "'set_param a b' did not accept a value containing '='"
25557 jobid_var_new=$($LCTL get_param -n $testname)
25558 [[ "$jobid_var_new" == "$new_value" ]] ||
25559 error "'set_param a b' failed on a value containing '='"
25561 $LCTL set_param $testname $jobid_var_old
25562 jobid_var_new=$($LCTL get_param -n $testname)
25563 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25564 error "failed to reset $testname"
25566 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
25568 test_401e() { # LU-14779
25569 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
25570 error "lctl list_param MGC* failed"
25571 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
25572 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
25573 error "lctl get_param lru_size failed"
25575 run_test 401e "verify 'lctl get_param' works with NID in parameter"
25578 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
25579 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
25580 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
25581 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
25582 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
25583 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
25584 remote_mds_nodsh && skip "remote MDS with nodsh"
25586 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
25587 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
25588 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
25589 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
25590 echo "Touch failed - OK"
25592 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
25595 local file1=$DIR/$tfile.1
25596 local file2=$DIR/$tfile.2
25597 local tfile=$TMP/$tfile
25599 rm -f $file1 $file2 $tfile
25604 # 30 sec OBD_TIMEOUT in ll_getattr()
25605 # right before populating st_nlink
25606 $LCTL set_param fail_loc=0x80001409
25607 stat -c %h $file1 > $tfile &
25609 # create an alias, drop all locks and reclaim the dentry
25611 cancel_lru_locks mdc
25612 cancel_lru_locks osc
25613 sysctl -w vm.drop_caches=2
25617 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
25619 rm -f $tfile $file1 $file2
25621 run_test 403 "i_nlink should not drop to zero due to aliasing"
25623 test_404() { # LU-6601
25624 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
25625 skip "Need server version newer than 2.8.52"
25626 remote_mds_nodsh && skip "remote MDS with nodsh"
25628 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
25629 awk '/osp .*-osc-MDT/ { print $4}')
25632 for osp in $mosps; do
25633 echo "Deactivate: " $osp
25634 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
25635 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25636 awk -vp=$osp '$4 == p { print $2 }')
25637 [ $stat = IN ] || {
25638 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25639 error "deactivate error"
25641 echo "Activate: " $osp
25642 do_facet $SINGLEMDS $LCTL --device %$osp activate
25643 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25644 awk -vp=$osp '$4 == p { print $2 }')
25645 [ $stat = UP ] || {
25646 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25647 error "activate error"
25651 run_test 404 "validate manual {de}activated works properly for OSPs"
25654 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
25655 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
25656 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
25657 skip "Layout swap lock is not supported"
25659 check_swap_layouts_support
25660 check_swap_layout_no_dom $DIR
25662 test_mkdir $DIR/$tdir
25663 swap_lock_test -d $DIR/$tdir ||
25664 error "One layout swap locked test failed"
25666 run_test 405 "Various layout swap lock tests"
25669 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25670 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
25671 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
25672 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25673 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
25674 skip "Need MDS version at least 2.8.50"
25676 local def_stripe_size=$($LFS getstripe -S $MOUNT)
25677 local test_pool=$TESTNAME
25679 pool_add $test_pool || error "pool_add failed"
25680 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
25681 error "pool_add_targets failed"
25683 save_layout_restore_at_exit $MOUNT
25685 # parent set default stripe count only, child will stripe from both
25686 # parent and fs default
25687 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
25688 error "setstripe $MOUNT failed"
25689 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
25690 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
25691 for i in $(seq 10); do
25692 local f=$DIR/$tdir/$tfile.$i
25693 touch $f || error "touch failed"
25694 local count=$($LFS getstripe -c $f)
25695 [ $count -eq $OSTCOUNT ] ||
25696 error "$f stripe count $count != $OSTCOUNT"
25697 local offset=$($LFS getstripe -i $f)
25698 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
25699 local size=$($LFS getstripe -S $f)
25700 [ $size -eq $((def_stripe_size * 2)) ] ||
25701 error "$f stripe size $size != $((def_stripe_size * 2))"
25702 local pool=$($LFS getstripe -p $f)
25703 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
25706 # change fs default striping, delete parent default striping, now child
25707 # will stripe from new fs default striping only
25708 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
25709 error "change $MOUNT default stripe failed"
25710 $LFS setstripe -c 0 $DIR/$tdir ||
25711 error "delete $tdir default stripe failed"
25712 for i in $(seq 11 20); do
25713 local f=$DIR/$tdir/$tfile.$i
25714 touch $f || error "touch $f failed"
25715 local count=$($LFS getstripe -c $f)
25716 [ $count -eq 1 ] || error "$f stripe count $count != 1"
25717 local offset=$($LFS getstripe -i $f)
25718 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
25719 local size=$($LFS getstripe -S $f)
25720 [ $size -eq $def_stripe_size ] ||
25721 error "$f stripe size $size != $def_stripe_size"
25722 local pool=$($LFS getstripe -p $f)
25723 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
25726 unlinkmany $DIR/$tdir/$tfile. 1 20
25728 local f=$DIR/$tdir/$tfile
25729 pool_remove_all_targets $test_pool $f
25730 pool_remove $test_pool $f
25732 run_test 406 "DNE support fs default striping"
25735 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25736 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
25737 skip "Need MDS version at least 2.8.55"
25738 remote_mds_nodsh && skip "remote MDS with nodsh"
25740 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
25741 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
25742 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
25743 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
25744 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
25746 #define OBD_FAIL_DT_TXN_STOP 0x2019
25747 for idx in $(seq $MDSCOUNT); do
25748 do_facet mds$idx "lctl set_param fail_loc=0x2019"
25750 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
25751 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
25752 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
25755 run_test 407 "transaction fail should cause operation fail"
25758 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
25760 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
25761 lctl set_param fail_loc=0x8000040a
25762 # let ll_prepare_partial_page() fail
25763 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
25767 # create at least 100 unused inodes so that
25768 # shrink_icache_memory(0) should not return 0
25769 touch $DIR/$tfile-{0..100}
25770 rm -f $DIR/$tfile-{0..100}
25773 echo 2 > /proc/sys/vm/drop_caches
25775 run_test 408 "drop_caches should not hang due to page leaks"
25779 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25781 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
25782 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
25783 touch $DIR/$tdir/guard || error "(2) Fail to create"
25785 local PREFIX=$(str_repeat 'A' 128)
25786 echo "Create 1K hard links start at $(date)"
25787 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
25788 error "(3) Fail to hard link"
25790 echo "Links count should be right although linkEA overflow"
25791 stat $DIR/$tdir/guard || error "(4) Fail to stat"
25792 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
25793 [ $linkcount -eq 1001 ] ||
25794 error "(5) Unexpected hard links count: $linkcount"
25796 echo "List all links start at $(date)"
25797 ls -l $DIR/$tdir/foo > /dev/null ||
25798 error "(6) Fail to list $DIR/$tdir/foo"
25800 echo "Unlink hard links start at $(date)"
25801 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
25802 error "(7) Fail to unlink"
25803 echo "Unlink hard links finished at $(date)"
25805 run_test 409 "Large amount of cross-MDTs hard links on the same file"
25809 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
25810 skip "Need client version at least 2.9.59"
25811 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
25812 skip "Need MODULES build"
25814 # Create a file, and stat it from the kernel
25815 local testfile=$DIR/$tfile
25818 local run_id=$RANDOM
25819 local my_ino=$(stat --format "%i" $testfile)
25821 # Try to insert the module. This will always fail as the
25822 # module is designed to not be inserted.
25823 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
25826 # Anything but success is a test failure
25828 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
25829 error "no inode match"
25831 run_test 410 "Test inode number returned from kernel thread"
25833 cleanup_test411_cgroup() {
25839 local cg_basedir=/sys/fs/cgroup/memory
25841 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
25842 skip "no setup for cgroup"
25844 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
25845 error "test file creation failed"
25846 cancel_lru_locks osc
25848 # Create a very small memory cgroup to force a slab allocation error
25849 local cgdir=$cg_basedir/osc_slab_alloc
25850 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
25851 trap "cleanup_test411_cgroup $cgdir" EXIT
25852 echo 2M > $cgdir/memory.kmem.limit_in_bytes
25853 echo 1M > $cgdir/memory.limit_in_bytes
25855 # Should not LBUG, just be killed by oom-killer
25856 # dd will return 0 even allocation failure in some environment.
25857 # So don't check return value
25858 bash -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
25859 cleanup_test411_cgroup $cgdir
25863 run_test 411 "Slab allocation error with cgroup does not LBUG"
25866 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
25867 (( $MDS1_VERSION >= $(version_code 2.10.55) )) ||
25868 skip "Need server version at least 2.10.55"
25870 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
25871 error "mkdir failed"
25872 $LFS getdirstripe $DIR/$tdir
25873 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
25874 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
25875 error "expect $((MDSCOUT - 1)) get $stripe_index"
25876 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
25877 [ $stripe_count -eq 2 ] ||
25878 error "expect 2 get $stripe_count"
25880 (( $MDS1_VERSION >= $(version_code 2.14.55) )) || return 0
25885 # subdirs should be on the same MDT as parent
25886 for i in $(seq 0 $((MDSCOUNT - 1))); do
25887 $LFS mkdir -i $i $DIR/$tdir/mdt$i || error "mkdir mdt$i failed"
25888 mkdir $DIR/$tdir/mdt$i/sub || error "mkdir sub failed"
25889 index=$($LFS getstripe -m $DIR/$tdir/mdt$i/sub)
25890 (( index == i )) || error "mdt$i/sub on MDT$index"
25893 # stripe offset -1, ditto
25894 for i in {1..10}; do
25895 $LFS mkdir -i -1 $DIR/$tdir/qos$i || error "mkdir qos$i failed"
25896 index=$($LFS getstripe -m $DIR/$tdir/qos$i)
25897 mkdir $DIR/$tdir/qos$i/sub || error "mkdir sub failed"
25898 index2=$($LFS getstripe -m $DIR/$tdir/qos$i/sub)
25899 (( index == index2 )) ||
25900 error "qos$i on MDT$index, sub on MDT$index2"
25903 local testdir=$DIR/$tdir/inherit
25905 $LFS mkdir -i 1 --max-inherit=3 $testdir || error "mkdir inherit failed"
25908 testdir=$testdir/s$i
25909 mkdir $testdir || error "mkdir $testdir failed"
25910 index=$($LFS getstripe -m $testdir)
25911 (( index == 1 )) ||
25912 error "$testdir on MDT$index"
25915 # not inherit any more
25916 testdir=$testdir/s3
25917 mkdir $testdir || error "mkdir $testdir failed"
25918 getfattr -d -m dmv $testdir | grep dmv &&
25919 error "default LMV set on $testdir" || true
25921 run_test 412 "mkdir on specific MDTs"
25923 TEST413_COUNT=${TEST413_COUNT:-200}
25924 generate_uneven_mdts() {
25926 local lmv_qos_maxage
25927 local lod_qos_maxage
25937 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
25938 $LCTL set_param lmv.*.qos_maxage=1
25939 stack_trap "$LCTL set_param \
25940 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
25941 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
25942 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
25943 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25944 lod.*.mdt_qos_maxage=1
25945 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25946 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
25949 echo "Check for uneven MDTs: "
25951 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25952 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25953 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25955 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25956 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25959 for ((i = 1; i < ${#ffree[@]}; i++)); do
25960 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25961 if [ $tmp -gt $max ]; then
25965 if [ $tmp -lt $min ]; then
25971 (( ${ffree[min_index]} > 0 )) ||
25972 skip "no free files in MDT$min_index"
25973 (( ${ffree[min_index]} < 10000000 )) ||
25974 skip "too many free files in MDT$min_index"
25976 # Check if we need to generate uneven MDTs
25977 local diff=$(((max - min) * 100 / min))
25978 local testdir=$DIR/$tdir-fillmdt
25982 while (( diff < threshold )); do
25984 # generate uneven MDTs, create till $threshold% diff
25985 echo -n "weight diff=$diff% must be > $threshold% ..."
25986 echo "Fill MDT$min_index with $TEST413_COUNT files: loop $i"
25987 testdir=$DIR/$tdir-fillmdt/$i
25988 [ -d $testdir ] && continue
25989 $LFS mkdir -i $min_index $testdir ||
25990 error "mkdir $testdir failed"
25991 $LFS setstripe -E 1M -L mdt $testdir ||
25992 error "setstripe $testdir failed"
25994 for ((F=0; F < TEST413_COUNT; F++)); do
25995 dd if=/dev/zero of=$testdir/f.$F bs=128K count=1 > \
25996 /dev/null 2>&1 || error "dd $F failed"
25998 sync; sleep 1; sync
26000 # wait for QOS to update
26001 (( SECONDS < start + 1 )) && sleep $((start + 1 - SECONDS))
26003 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
26004 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
26005 max=$(((${ffree[max_index]} >> 8) *
26006 (${bavail[max_index]} * bsize >> 16)))
26007 min=$(((${ffree[min_index]} >> 8) *
26008 (${bavail[min_index]} * bsize >> 16)))
26009 diff=$(((max - min) * 100 / min))
26013 echo "MDT filesfree available: ${ffree[*]}"
26014 echo "MDT blocks available: ${bavail[*]}"
26015 echo "weight diff=$diff%"
26020 local stripe_count=$2
26021 local mdts=$(comma_list $(mdts_nodes))
26024 local lmv_qos_prio_free
26025 local lmv_qos_threshold_rr
26026 local lmv_qos_maxage
26027 local lod_qos_prio_free
26028 local lod_qos_threshold_rr
26029 local lod_qos_maxage
26033 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
26034 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
26035 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
26037 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
26038 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
26039 stack_trap "$LCTL set_param \
26040 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
26041 stack_trap "$LCTL set_param \
26042 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
26043 stack_trap "$LCTL set_param \
26044 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
26046 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
26047 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
26048 lod_qos_prio_free=${lod_qos_prio_free%%%}
26049 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
26050 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
26051 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
26052 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
26053 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
26054 stack_trap "do_nodes $mdts $LCTL set_param \
26055 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
26056 stack_trap "do_nodes $mdts $LCTL set_param \
26057 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
26058 stack_trap "do_nodes $mdts $LCTL set_param \
26059 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
26061 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
26062 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
26064 testdir=$DIR/$tdir-s$stripe_count/rr
26066 local stripe_index=$($LFS getstripe -m $testdir)
26067 local test_mkdir_rr=true
26069 getfattr -d -m dmv -e hex $testdir | grep dmv
26070 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
26071 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
26072 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
26073 test_mkdir_rr=false
26078 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
26079 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
26081 stack_trap "unlinkmany -d $testdir/subdir $((100 * MDSCOUNT))"
26082 for (( i = 0; i < 100 * MDSCOUNT; i++ )); do
26083 eval $mkdir_cmd $testdir/subdir$i ||
26084 error "$mkdir_cmd subdir$i failed"
26087 for (( i = 0; i < $MDSCOUNT; i++ )); do
26088 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
26089 echo "$count directories created on MDT$i"
26090 if $test_mkdir_rr; then
26091 (( $count == 100 )) ||
26092 error "subdirs are not evenly distributed"
26093 elif (( $i == $stripe_index )); then
26094 (( $count == 100 * MDSCOUNT )) ||
26095 error "$count subdirs created on MDT$i"
26097 (( $count == 0 )) ||
26098 error "$count subdirs created on MDT$i"
26101 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
26102 count=$($LFS getdirstripe $testdir/* |
26103 grep -c -P "^\s+$i\t")
26104 echo "$count stripes created on MDT$i"
26105 # deviation should < 5% of average
26106 (( $count >= 95 * stripe_count &&
26107 $count <= 105 * stripe_count)) ||
26108 error "stripes are not evenly distributed"
26113 echo "Check for uneven MDTs: "
26123 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26124 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26125 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26127 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26128 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26131 for ((i = 1; i < ${#ffree[@]}; i++)); do
26132 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26133 if [ $tmp -gt $max ]; then
26137 if [ $tmp -lt $min ]; then
26143 (( ${ffree[min_index]} > 0 )) ||
26144 skip "no free files in MDT$min_index"
26145 (( ${ffree[min_index]} < 10000000 )) ||
26146 skip "too many free files in MDT$min_index"
26148 echo "MDT filesfree available: ${ffree[*]}"
26149 echo "MDT blocks available: ${bavail[*]}"
26150 echo "weight diff=$(((max - min) * 100 / min))%"
26152 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
26154 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
26155 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
26156 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
26157 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
26158 # decrease statfs age, so that it can be updated in time
26159 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
26160 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
26164 testdir=$DIR/$tdir-s$stripe_count/qos
26167 stack_trap "unlinkmany -d $testdir/subdir $((num * MDSCOUNT))"
26168 for (( i = 0; i < num * MDSCOUNT; i++ )); do
26169 eval $mkdir_cmd $testdir/subdir$i ||
26170 error "$mkdir_cmd subdir$i failed"
26174 for (( i = 0; i < $MDSCOUNT; i++ )); do
26175 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
26176 (( count > max )) && max=$count
26177 echo "$count directories created on MDT$i"
26180 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
26182 # D-value should > 10% of averge
26183 (( max - min > num / 10 )) ||
26184 error "subdirs shouldn't be evenly distributed: $max - $min < $((num / 10))"
26186 # ditto for stripes
26187 if (( stripe_count > 1 )); then
26189 for (( i = 0; i < $MDSCOUNT; i++ )); do
26190 count=$($LFS getdirstripe $testdir/* |
26191 grep -c -P "^\s+$i\t")
26192 (( count > max )) && max=$count
26193 echo "$count stripes created on MDT$i"
26196 min=$($LFS getdirstripe $testdir/* |
26197 grep -c -P "^\s+$min_index\t")
26198 (( max - min > num * stripe_count / 10 )) ||
26199 error "stripes shouldn't be evenly distributed: $max - $min < $((num / 10)) * $stripe_count"
26211 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26212 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26213 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26215 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26217 for ((i = 1; i < ${#ffree[@]}; i++)); do
26218 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26219 (( tmp < min )) && min=$tmp && min_index=$i
26226 [ $MDSCOUNT -lt 2 ] &&
26227 skip "We need at least 2 MDTs for this test"
26229 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
26230 skip "Need server version at least 2.12.52"
26234 generate_uneven_mdts 100
26235 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
26236 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
26237 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
26238 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
26239 error "mkdir failed"
26240 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
26243 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
26246 [ $MDSCOUNT -lt 2 ] &&
26247 skip "We need at least 2 MDTs for this test"
26249 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
26250 skip "Need server version at least 2.12.52"
26255 generate_uneven_mdts 100
26256 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
26257 testdir=$DIR/$tdir-s$stripe_count
26258 mkdir $testdir || error "mkdir $testdir failed"
26259 mkdir $testdir/rr || error "mkdir rr failed"
26260 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
26261 error "mkdir qos failed"
26262 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
26263 $testdir/rr || error "setdirstripe rr failed"
26264 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
26265 error "setdirstripe failed"
26266 test_qos_mkdir "mkdir" $stripe_count
26269 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
26272 (( $MDSCOUNT >= 2 )) ||
26273 skip "We need at least 2 MDTs for this test"
26275 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
26276 skip "Need server version at least 2.14.51"
26282 testdir=$DIR/${tdir}-s1
26283 mkdir $testdir || error "mkdir $testdir failed"
26284 mkdir $testdir/rr || error "mkdir rr failed"
26285 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
26286 # default max_inherit is -1, default max_inherit_rr is 0
26287 $LFS setdirstripe -D -c 1 $testdir/rr ||
26288 error "setdirstripe rr failed"
26289 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
26290 error "setdirstripe qos failed"
26291 test_qos_mkdir "mkdir" 1
26293 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
26294 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
26295 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
26296 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
26297 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
26299 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
26300 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
26301 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
26302 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
26303 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
26304 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
26305 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
26306 error "level2 shouldn't have default LMV" || true
26308 run_test 413c "mkdir with default LMV max inherit rr"
26311 (( MDSCOUNT >= 2 )) ||
26312 skip "We need at least 2 MDTs for this test"
26314 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
26315 skip "Need server version at least 2.14.51"
26317 local lmv_qos_threshold_rr
26319 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
26321 stack_trap "$LCTL set_param \
26322 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
26324 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
26325 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
26326 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
26327 error "$tdir shouldn't have default LMV"
26328 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
26329 error "mkdir sub failed"
26331 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
26333 (( count == 100 )) || error "$count subdirs on MDT0"
26335 run_test 413d "inherit ROOT default LMV"
26338 (( MDSCOUNT >= 2 )) ||
26339 skip "We need at least 2 MDTs for this test"
26340 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26341 skip "Need server version at least 2.14.55"
26343 local testdir=$DIR/$tdir
26344 local tmpfile=$TMP/temp.setdirstripe.stderr.$$
26346 local sub_max_inherit
26348 mkdir -p $testdir || error "failed to create $testdir"
26350 # set default max-inherit to -1 if stripe count is 0 or 1
26351 $LFS setdirstripe -D -c 1 $testdir ||
26352 error "failed to set default LMV"
26353 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26354 (( max_inherit == -1 )) ||
26355 error "wrong max_inherit value $max_inherit"
26357 # set default max_inherit to a fixed value if stripe count is not 0 or 1
26358 $LFS setdirstripe -D -c -1 $testdir ||
26359 error "failed to set default LMV"
26360 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26361 (( max_inherit > 0 )) ||
26362 error "wrong max_inherit value $max_inherit"
26364 # and the subdir will decrease the max_inherit by 1
26365 mkdir -p $testdir/subdir-1 || error "failed to make subdir"
26366 sub_max_inherit=$($LFS getdirstripe -D --max-inherit $testdir/subdir-1)
26367 (( sub_max_inherit == max_inherit - 1)) ||
26368 error "wrong max-inherit of subdir $sub_max_inherit"
26370 # check specified --max-inherit and warning message
26371 stack_trap "rm -f $tmpfile"
26372 $LFS setdirstripe -D -c 2 --max-inherit=-1 $testdir 2> $tmpfile ||
26373 error "failed to set default LMV"
26374 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26375 (( max_inherit == -1 )) ||
26376 error "wrong max_inherit value $max_inherit"
26378 # check the warning messages
26379 if ! [[ $(cat $tmpfile) =~ "max-inherit=" ]]; then
26380 error "failed to detect warning string"
26383 run_test 413e "check default max-inherit value"
26385 test_fs_dmv_inherit()
26387 local testdir=$DIR/$tdir
26394 mkdir $testdir || error "mkdir $testdir failed"
26395 count=$($LFS getdirstripe -D -c $testdir)
26396 (( count == 1 )) ||
26397 error "$testdir default LMV count mismatch $count != 1"
26398 inherit=$($LFS getdirstripe -D -X $testdir)
26399 (( inherit == 3 - i )) ||
26400 error "$testdir default LMV max-inherit $inherit != $((3 - i))"
26401 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir)
26402 (( inherit_rr == 3 - i )) ||
26403 error "$testdir default LMV max-inherit-rr $inherit_rr != $((3 - i))"
26404 testdir=$testdir/sub
26407 mkdir $testdir || error "mkdir $testdir failed"
26408 count=$($LFS getdirstripe -D -c $testdir)
26409 (( count == 0 )) ||
26410 error "$testdir default LMV count not zero: $count"
26414 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26416 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26417 skip "Need server version at least 2.14.55"
26419 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26420 error "dump $DIR default LMV failed"
26421 stack_trap "setfattr --restore=$TMP/dmv.ea"
26423 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26424 error "set $DIR default LMV failed"
26426 test_fs_dmv_inherit
26428 run_test 413f "lfs getdirstripe -D list ROOT default LMV if it's not set on dir"
26431 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26433 mkdir -p $DIR/$tdir/l2/l3/l4 || error "mkdir $tdir/l1/l2/l3 failed"
26434 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26435 error "dump $DIR default LMV failed"
26436 stack_trap "setfattr --restore=$TMP/dmv.ea"
26438 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26439 error "set $DIR default LMV failed"
26441 FILESET="$FILESET/$tdir/l2/l3/l4" mount_client $MOUNT2 ||
26442 error "mount $MOUNT2 failed"
26443 stack_trap "umount_client $MOUNT2"
26445 local saved_DIR=$DIR
26449 stack_trap "export DIR=$saved_DIR"
26451 # first check filesystem-wide default LMV inheritance
26452 test_fs_dmv_inherit || error "incorrect fs default LMV inheritance"
26454 # then check subdirs are spread to all MDTs
26455 createmany -d $DIR/s $((MDSCOUNT * 100)) || error "createmany failed"
26457 local count=$($LFS getstripe -m $DIR/s* | sort -u | wc -l)
26459 (( $count == $MDSCOUNT )) || error "dirs are spread to $count MDTs"
26461 run_test 413g "enforce ROOT default LMV on subdir mount"
26464 (( MDSCOUNT >= 2 )) ||
26465 skip "We need at least 2 MDTs for this test"
26467 (( MDS1_VERSION >= $(version_code 2.15.50.6) )) ||
26468 skip "Need server version at least 2.15.50.6"
26470 local lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
26472 stack_trap "$LCTL set_param \
26473 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
26474 $LCTL set_param lmv.*.qos_maxage=1
26478 local dir=$DIR/$tdir/l1/l2/l3/l4/l5
26479 local count=$((MDSCOUNT * 20))
26481 generate_uneven_mdts 50
26483 mkdir -p $dir || error "mkdir $dir failed"
26484 stack_trap "rm -rf $dir"
26485 $LFS setdirstripe -D -c 1 -i -1 --max-inherit=$depth \
26486 --max-inherit-rr=$rr_depth $dir
26488 for ((d=0; d < depth + 2; d++)); do
26490 for ((sub=0; sub < count; sub++)); do
26493 $LFS getdirstripe -i $dir/d* | sort | uniq -c | sort -nr
26494 local num=($($LFS getdirstripe -i $dir/d* | sort | uniq -c))
26495 # subdirs within $rr_depth should be created round-robin
26496 if (( d < rr_depth )); then
26497 (( ${num[0]} != count )) ||
26498 error "all objects created on MDT ${num[1]}"
26504 run_test 413h "don't stick to parent for round-robin dirs"
26511 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
26512 unlinkmany $subdir/f. $TEST413_COUNT &
26516 for pid in $pids; do
26520 run_test 413z "413 test cleanup"
26523 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
26524 $LCTL set_param fail_loc=0x80000521
26525 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
26528 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
26531 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26532 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
26533 skip "Need server version at least 2.11.52"
26543 # this test may be slow on ZFS
26544 [ "$mds1_FSTYPE" == "zfs" ] && total=50
26546 # though this test is designed for striped directory, let's test normal
26547 # directory too since lock is always saved as CoS lock.
26548 test_mkdir $DIR/$tdir || error "mkdir $tdir"
26549 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
26558 start_time=$(date +%s)
26559 for i in $(seq $total); do
26560 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
26563 end_time=$(date +%s)
26564 duration=$((end_time - start_time))
26566 kill -9 $setattr_pid
26568 echo "rename $total files took $duration sec"
26569 [ $duration -lt 100 ] || error "rename took $duration sec"
26571 run_test 415 "lock revoke is not missing"
26574 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
26575 skip "Need server version at least 2.11.55"
26577 # define OBD_FAIL_OSD_TXN_START 0x19a
26578 do_facet mds1 lctl set_param fail_loc=0x19a
26580 lfs mkdir -c $MDSCOUNT $DIR/$tdir
26584 run_test 416 "transaction start failure won't cause system hung"
26588 do_nodes $(comma_list $(mdts_nodes)) \
26589 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
26590 do_nodes $(comma_list $(mdts_nodes)) \
26591 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
26592 do_nodes $(comma_list $(mdts_nodes)) \
26593 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
26597 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26598 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
26599 skip "Need MDS version at least 2.11.56"
26601 trap cleanup_417 RETURN EXIT
26603 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
26604 do_nodes $(comma_list $(mdts_nodes)) \
26605 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
26606 $LFS migrate -m 0 $DIR/$tdir.1 &&
26607 error "migrate dir $tdir.1 should fail"
26609 do_nodes $(comma_list $(mdts_nodes)) \
26610 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
26611 $LFS mkdir -i 1 $DIR/$tdir.2 &&
26612 error "create remote dir $tdir.2 should fail"
26614 do_nodes $(comma_list $(mdts_nodes)) \
26615 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
26616 $LFS mkdir -c 2 $DIR/$tdir.3 &&
26617 error "create striped dir $tdir.3 should fail"
26620 run_test 417 "disable remote dir, striped dir and dir migration"
26622 # Checks that the outputs of df [-i] and lfs df [-i] match
26624 # usage: check_lfs_df <blocks | inodes> <mountpoint>
26634 [ "$1" == "blocks" ] && inodes= || inodes="-i"
26636 for count in {1..100}; do
26637 do_nodes "$CLIENTS" \
26638 $LCTL set_param ldlm.namespaces.*.lru_size=clear
26641 # read the lines of interest
26642 df_out=($(df -P $inodes $dir | tail -n +2)) ||
26643 error "df $inodes $dir | tail -n +2 failed"
26644 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
26645 error "lfs df $inodes $dir | grep summary: failed"
26647 # skip first substrings of each output as they are different
26648 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
26649 # compare the two outputs
26651 # skip "available" on MDT until LU-13997 is fixed.
26652 #for i in {1..5}; do
26653 for i in 1 2 4 5; do
26654 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
26662 lfs df $inodes $dir
26663 error "df and lfs df $1 output mismatch: " \
26664 "df ${inodes}: ${df_out[*]}, " \
26665 "lfs df ${inodes}: ${lfs_df_out[*]}"
26670 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26672 local dir=$DIR/$tdir
26673 local numfiles=$((RANDOM % 4096 + 2))
26674 local numblocks=$((RANDOM % 256 + 1))
26676 wait_delete_completed
26679 # check block output
26680 check_lfs_df blocks $dir
26681 # check inode output
26682 check_lfs_df inodes $dir
26684 # create a single file and retest
26685 echo "Creating a single file and testing"
26686 createmany -o $dir/$tfile- 1 &>/dev/null ||
26687 error "creating 1 file in $dir failed"
26688 check_lfs_df blocks $dir
26689 check_lfs_df inodes $dir
26691 # create a random number of files
26692 echo "Creating $((numfiles - 1)) files and testing"
26693 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
26694 error "creating $((numfiles - 1)) files in $dir failed"
26696 # write a random number of blocks to the first test file
26697 echo "Writing $numblocks 4K blocks and testing"
26698 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
26699 count=$numblocks &>/dev/null ||
26700 error "dd to $dir/${tfile}-0 failed"
26703 check_lfs_df blocks $dir
26704 check_lfs_df inodes $dir
26706 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
26707 error "unlinking $numfiles files in $dir failed"
26709 run_test 418 "df and lfs df outputs match"
26713 local dir=$DIR/$tdir
26718 cancel_lru_locks mdc
26720 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
26721 $LCTL set_param fail_loc=0x1410
26723 $LCTL set_param fail_loc=0
26726 run_test 419 "Verify open file by name doesn't crash kernel"
26730 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
26731 skip "Need MDS version at least 2.12.53"
26733 local SAVE_UMASK=$(umask)
26734 local dir=$DIR/$tdir
26735 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
26739 mkdir -m03777 $dir/testdir
26740 ls -dn $dir/testdir
26741 # Need to remove trailing '.' when SELinux is enabled
26742 local dirperms=$(ls -dn $dir/testdir |
26743 awk '{ sub(/\.$/, "", $1); print $1}')
26744 [ $dirperms == "drwxrwsrwt" ] ||
26745 error "incorrect perms on $dir/testdir"
26747 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
26748 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
26749 ls -n $dir/testdir/testfile
26750 local fileperms=$(ls -n $dir/testdir/testfile |
26751 awk '{ sub(/\.$/, "", $1); print $1}')
26752 [ $fileperms == "-rwxr-xr-x" ] ||
26753 error "incorrect perms on $dir/testdir/testfile"
26757 run_test 420 "clear SGID bit on non-directories for non-members"
26764 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26765 skip "Need MDS version at least 2.12.54"
26767 test_mkdir $DIR/$tdir
26768 createmany -o $DIR/$tdir/f 3
26769 cnt=$(ls -1 $DIR/$tdir | wc -l)
26770 [ $cnt != 3 ] && error "unexpected #files: $cnt"
26772 fid1=$(lfs path2fid $DIR/$tdir/f1)
26773 fid2=$(lfs path2fid $DIR/$tdir/f2)
26774 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
26776 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
26777 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
26779 cnt=$(ls -1 $DIR/$tdir | wc -l)
26780 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
26782 rm -f $DIR/$tdir/f3 || error "can't remove f3"
26783 createmany -o $DIR/$tdir/f 3
26784 cnt=$(ls -1 $DIR/$tdir | wc -l)
26785 [ $cnt != 3 ] && error "unexpected #files: $cnt"
26787 fid1=$(lfs path2fid $DIR/$tdir/f1)
26788 fid2=$(lfs path2fid $DIR/$tdir/f2)
26789 echo "remove using fsname $FSNAME"
26790 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
26792 cnt=$(ls -1 $DIR/$tdir | wc -l)
26793 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
26795 run_test 421a "simple rm by fid"
26802 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26803 skip "Need MDS version at least 2.12.54"
26805 test_mkdir $DIR/$tdir
26806 createmany -o $DIR/$tdir/f 3
26807 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
26810 FID1=$(lfs path2fid $DIR/$tdir/f1)
26811 FID2=$(lfs path2fid $DIR/$tdir/f2)
26812 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
26814 kill -USR1 $MULTIPID
26817 cnt=$(ls $DIR/$tdir | wc -l)
26818 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
26820 run_test 421b "rm by fid on open file"
26826 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26827 skip "Need MDS version at least 2.12.54"
26829 test_mkdir $DIR/$tdir
26830 createmany -o $DIR/$tdir/f 3
26831 touch $DIR/$tdir/$tfile
26832 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
26833 cnt=$(ls -1 $DIR/$tdir | wc -l)
26834 [ $cnt != 184 ] && error "unexpected #files: $cnt"
26836 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
26837 $LFS rmfid $DIR $FID1 || error "rmfid failed"
26839 cnt=$(ls $DIR/$tdir | wc -l)
26840 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
26842 run_test 421c "rm by fid against hardlinked files"
26848 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26849 skip "Need MDS version at least 2.12.54"
26851 test_mkdir $DIR/$tdir
26852 createmany -o $DIR/$tdir/f 4097
26853 cnt=$(ls -1 $DIR/$tdir | wc -l)
26854 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
26856 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
26857 $LFS rmfid $DIR $FIDS || error "rmfid failed"
26859 cnt=$(ls $DIR/$tdir | wc -l)
26861 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26863 run_test 421d "rmfid en masse"
26869 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26870 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26871 skip "Need MDS version at least 2.12.54"
26873 mkdir -p $DIR/$tdir
26874 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
26875 createmany -o $DIR/$tdir/striped_dir/f 512
26876 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26877 [ $cnt != 512 ] && error "unexpected #files: $cnt"
26879 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
26880 sed "s/[/][^:]*://g")
26881 $LFS rmfid $DIR $FIDS || error "rmfid failed"
26883 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
26885 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26887 run_test 421e "rmfid in DNE"
26893 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26894 skip "Need MDS version at least 2.12.54"
26896 test_mkdir $DIR/$tdir
26898 cnt=$(ls -1 $DIR/$tdir | wc -l)
26899 [ $cnt != 1 ] && error "unexpected #files: $cnt"
26901 FID=$(lfs path2fid $DIR/$tdir/f)
26902 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
26903 # rmfid should fail
26904 cnt=$(ls -1 $DIR/$tdir | wc -l)
26905 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
26907 chmod a+rw $DIR/$tdir
26909 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
26910 # rmfid should fail
26911 cnt=$(ls -1 $DIR/$tdir | wc -l)
26912 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
26915 $RUNAS touch $DIR/$tdir/f
26916 FID=$(lfs path2fid $DIR/$tdir/f)
26917 echo "rmfid as root"
26918 $LFS rmfid $DIR $FID || error "rmfid as root failed"
26919 cnt=$(ls -1 $DIR/$tdir | wc -l)
26920 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
26923 $RUNAS touch $DIR/$tdir/f
26924 cnt=$(ls -1 $DIR/$tdir | wc -l)
26925 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
26926 FID=$(lfs path2fid $DIR/$tdir/f)
26927 # rmfid w/o user_fid2path mount option should fail
26928 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
26929 cnt=$(ls -1 $DIR/$tdir | wc -l)
26930 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
26932 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
26933 stack_trap "rmdir $tmpdir"
26934 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
26935 error "failed to mount client'"
26936 stack_trap "umount_client $tmpdir"
26938 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
26939 # rmfid should succeed
26940 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
26941 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
26943 # rmfid shouldn't allow to remove files due to dir's permission
26944 chmod a+rwx $tmpdir/$tdir
26945 touch $tmpdir/$tdir/f
26946 ls -la $tmpdir/$tdir
26947 FID=$(lfs path2fid $tmpdir/$tdir/f)
26948 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
26951 run_test 421f "rmfid checks permissions"
26957 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26958 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26959 skip "Need MDS version at least 2.12.54"
26961 mkdir -p $DIR/$tdir
26962 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
26963 createmany -o $DIR/$tdir/striped_dir/f 512
26964 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26965 [ $cnt != 512 ] && error "unexpected #files: $cnt"
26967 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
26968 sed "s/[/][^:]*://g")
26970 rm -f $DIR/$tdir/striped_dir/f1*
26971 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26972 removed=$((512 - cnt))
26974 # few files have been just removed, so we expect
26975 # rmfid to fail on their fids
26976 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
26977 [ $removed != $errors ] && error "$errors != $removed"
26979 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
26981 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26983 run_test 421g "rmfid to return errors properly"
26986 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
26987 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
26988 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
26989 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
26990 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
26992 local amc=$(at_max_get client)
26993 local amo=$(at_max_get mds1)
26994 local timeout=`lctl get_param -n timeout`
26996 at_max_set 0 client
26999 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
27000 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
27001 fail_val=$(((2*timeout + 10)*1000))
27002 touch $DIR/$tdir/d3/file &
27004 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
27005 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
27006 fail_val=$((2*timeout + 5))
27007 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
27011 sleep $((2 * timeout))
27015 touch $DIR/$tdir/d2/file3
27016 touch $DIR/$tdir/d2/file4
27017 touch $DIR/$tdir/d2/file5
27020 at_max_set $amc client
27021 at_max_set $amo mds1
27023 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
27024 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
27025 error "Watchdog is always throttled"
27027 run_test 422 "kill a process with RPC in progress"
27040 # ensure statfs cache is expired
27043 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
27044 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
27048 run_test 423 "statfs should return a right data"
27051 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
27052 $LCTL set_param fail_loc=0x80000522
27053 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
27056 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
27059 test_mkdir -c -1 $DIR/$tdir
27060 $LFS setstripe -c -1 $DIR/$tdir
27062 lru_resize_disable "" 100
27063 stack_trap "lru_resize_enable" EXIT
27067 for i in $(seq $((MDSCOUNT * 125))); do
27068 local t=$DIR/$tdir/$tfile_$i
27070 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
27071 error_noexit "Create file $t"
27073 stack_trap "rm -rf $DIR/$tdir" EXIT
27075 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
27076 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
27077 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
27079 [ $lock_count -le $lru_size ] ||
27080 error "osc lock count $lock_count > lru size $lru_size"
27083 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
27084 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
27085 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
27087 [ $lock_count -le $lru_size ] ||
27088 error "mdc lock count $lock_count > lru size $lru_size"
27091 run_test 425 "lock count should not exceed lru size"
27094 splice-test -r $DIR/$tfile
27095 splice-test -rd $DIR/$tfile
27096 splice-test $DIR/$tfile
27097 splice-test -d $DIR/$tfile
27099 run_test 426 "splice test on Lustre"
27102 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
27103 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
27104 skip "Need MDS version at least 2.12.4"
27110 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
27111 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
27113 $LFS getdirstripe $DIR/$tdir/1/dir
27115 #first setfattr for creating updatelog
27116 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
27118 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
27119 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
27120 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
27121 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
27125 wait_recovery_complete mds2 $((2*TIMEOUT))
27127 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
27128 echo $log | grep "get update log failed" &&
27129 error "update log corruption is detected" || true
27131 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
27134 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27135 local cache_limit=$CACHE_MAX
27137 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$cache_limit"
27138 $LCTL set_param -n llite.*.max_cached_mb=64
27141 $LFS setstripe -c 1 $DIR/$tdir
27142 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
27143 stack_trap "rm -f $DIR/$tdir/$tfile.*"
27145 for f in $(seq 4); do
27146 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
27150 cancel_lru_locks osc
27152 for f in $(seq 4); do
27153 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
27157 run_test 428 "large block size IO should not hang"
27159 test_429() { # LU-7915 / LU-10948
27160 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
27161 local testfile=$DIR/$tfile
27162 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
27168 $LCTL get_param $ll_opencache_threshold_count ||
27169 skip "client does not have opencache parameter"
27171 set_opencache $new_flag
27172 stack_trap "restore_opencache"
27173 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
27174 error "enable opencache failed"
27176 # drop MDC DLM locks
27177 cancel_lru_locks mdc
27178 # clear MDC RPC stats counters
27179 $LCTL set_param $mdc_rpcstats=clear
27181 # According to the current implementation, we need to run 3 times
27182 # open & close file to verify if opencache is enabled correctly.
27183 # 1st, RPCs are sent for lookup/open and open handle is released on
27185 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
27186 # so open handle won't be released thereafter.
27187 # 3rd, No RPC is sent out.
27188 $MULTIOP $testfile oc || error "multiop failed"
27189 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27190 echo "1st: $first_rpc RPCs in flight"
27192 $MULTIOP $testfile oc || error "multiop failed"
27193 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27194 echo "2nd: $second_rpc RPCs in flight"
27196 $MULTIOP $testfile oc || error "multiop failed"
27197 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27198 echo "3rd: $third_rpc RPCs in flight"
27200 #verify no MDC RPC is sent
27201 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
27203 run_test 429 "verify if opencache flag on client side does work"
27209 # data at [200K, 400K)
27210 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
27211 error "256K->512K dd fails"
27213 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
27214 error "2M->3M dd fails"
27216 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
27217 error "4M->5M dd fails"
27218 echo "Data at 256K...512K, 2M...3M and 4M...5M"
27219 # start at first component hole #1
27220 printf "Seeking hole from 1000 ... "
27221 offset=$(lseek_test -l 1000 $file)
27223 [[ $offset == 1000 ]] || error "offset $offset != 1000"
27224 printf "Seeking data from 1000 ... "
27225 offset=$(lseek_test -d 1000 $file)
27227 [[ $offset == 262144 ]] || error "offset $offset != 262144"
27229 # start at first component data block
27230 printf "Seeking hole from 300000 ... "
27231 offset=$(lseek_test -l 300000 $file)
27233 [[ $offset == 524288 ]] || error "offset $offset != 524288"
27234 printf "Seeking data from 300000 ... "
27235 offset=$(lseek_test -d 300000 $file)
27237 [[ $offset == 300000 ]] || error "offset $offset != 300000"
27239 # start at the first component but beyond end of object size
27240 printf "Seeking hole from 1000000 ... "
27241 offset=$(lseek_test -l 1000000 $file)
27243 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27244 printf "Seeking data from 1000000 ... "
27245 offset=$(lseek_test -d 1000000 $file)
27247 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
27249 # start at second component stripe 2 (empty file)
27250 printf "Seeking hole from 1500000 ... "
27251 offset=$(lseek_test -l 1500000 $file)
27253 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
27254 printf "Seeking data from 1500000 ... "
27255 offset=$(lseek_test -d 1500000 $file)
27257 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
27259 # start at second component stripe 1 (all data)
27260 printf "Seeking hole from 3000000 ... "
27261 offset=$(lseek_test -l 3000000 $file)
27263 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
27264 printf "Seeking data from 3000000 ... "
27265 offset=$(lseek_test -d 3000000 $file)
27267 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
27269 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
27270 error "2nd dd fails"
27271 echo "Add data block at 640K...1280K"
27273 # start at before new data block, in hole
27274 printf "Seeking hole from 600000 ... "
27275 offset=$(lseek_test -l 600000 $file)
27277 [[ $offset == 600000 ]] || error "offset $offset != 600000"
27278 printf "Seeking data from 600000 ... "
27279 offset=$(lseek_test -d 600000 $file)
27281 [[ $offset == 655360 ]] || error "offset $offset != 655360"
27283 # start at the first component new data block
27284 printf "Seeking hole from 1000000 ... "
27285 offset=$(lseek_test -l 1000000 $file)
27287 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
27288 printf "Seeking data from 1000000 ... "
27289 offset=$(lseek_test -d 1000000 $file)
27291 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27293 # start at second component stripe 2, new data
27294 printf "Seeking hole from 1200000 ... "
27295 offset=$(lseek_test -l 1200000 $file)
27297 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
27298 printf "Seeking data from 1200000 ... "
27299 offset=$(lseek_test -d 1200000 $file)
27301 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
27303 # start beyond file end
27304 printf "Using offset > filesize ... "
27305 lseek_test -l 4000000 $file && error "lseek should fail"
27306 printf "Using offset > filesize ... "
27307 lseek_test -d 4000000 $file && error "lseek should fail"
27313 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
27314 skip "MDT does not support SEEK_HOLE"
27316 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27317 skip "OST does not support SEEK_HOLE"
27319 local file=$DIR/$tdir/$tfile
27321 mkdir -p $DIR/$tdir
27323 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
27324 # OST stripe #1 will have continuous data at [1M, 3M)
27325 # OST stripe #2 is empty
27326 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
27327 lseek_test_430 $file
27329 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
27330 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
27331 lseek_test_430 $file
27333 $LFS setstripe -c2 -S 512K $file
27334 echo "Two stripes, stripe size 512K"
27335 lseek_test_430 $file
27337 # FLR with stale mirror
27338 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
27340 echo "Mirrored file:"
27341 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
27342 echo "Plain 2 stripes 1M"
27343 lseek_test_430 $file
27346 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
27349 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27350 skip "OST does not support SEEK_HOLE"
27353 local file=$DIR/$tdir/$tfile
27355 mkdir -p $DIR/$tdir
27356 # Empty layout lseek should fail
27359 printf "Seeking hole from 0 ... "
27360 lseek_test -l 0 $file && error "lseek should fail"
27361 printf "Seeking data from 0 ... "
27362 lseek_test -d 0 $file && error "lseek should fail"
27366 $LFS setstripe -E 1M -c2 -E eof $file
27367 $TRUNCATE $file 1048576
27368 printf "Seeking hole from 1000000 ... "
27369 offset=$(lseek_test -l 1000000 $file)
27371 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27372 printf "Seeking data from 1000000 ... "
27373 lseek_test -d 1000000 $file && error "lseek should fail"
27376 # full component followed by non-inited one
27377 $LFS setstripe -E 1M -c2 -E eof $file
27378 dd if=/dev/urandom of=$file bs=1M count=1
27379 printf "Seeking hole from 1000000 ... "
27380 offset=$(lseek_test -l 1000000 $file)
27382 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27383 printf "Seeking hole from 1048576 ... "
27384 lseek_test -l 1048576 $file && error "lseek should fail"
27385 # init second component and truncate back
27386 echo "123" >> $file
27387 $TRUNCATE $file 1048576
27388 printf "Seeking hole from 1000000 ... "
27389 offset=$(lseek_test -l 1000000 $file)
27391 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27392 printf "Seeking hole from 1048576 ... "
27393 lseek_test -l 1048576 $file && error "lseek should fail"
27394 # boundary checks for big values
27395 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
27396 offset=$(lseek_test -d 0 $file.10g)
27397 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
27398 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
27399 offset=$(lseek_test -d 0 $file.100g)
27400 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
27403 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
27406 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27407 skip "OST does not support SEEK_HOLE"
27409 local file=$DIR/$tdir/$tfile
27412 mkdir -p $DIR/$tdir
27413 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M
27415 # cp version 8.33+ prefers lseek over fiemap
27416 if [[ $(cp --version | head -n1 | sed "s/[^0-9]//g") -ge 833 ]]; then
27418 time cp $file /dev/null
27419 (( SECONDS - start < 5 )) ||
27420 error "cp: too long runtime $((SECONDS - start))"
27423 # tar version 1.29+ supports SEEK_HOLE/DATA
27424 if [[ $(tar --version | head -n1 | sed "s/[^0-9]//g") -ge 129 ]]; then
27426 time tar cS $file - | cat > /dev/null
27427 (( SECONDS - start < 5 )) ||
27428 error "tar: too long runtime $((SECONDS - start))"
27431 run_test 430c "lseek: external tools check"
27433 test_431() { # LU-14187
27434 local file=$DIR/$tdir/$tfile
27436 mkdir -p $DIR/$tdir
27437 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
27438 dd if=/dev/urandom of=$file bs=4k count=1
27439 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
27440 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
27441 #define OBD_FAIL_OST_RESTART_IO 0x251
27442 do_facet ost1 "$LCTL set_param fail_loc=0x251"
27443 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
27447 echo 3 > /proc/sys/vm/drop_caches
27448 diff $file $file.0 || error "data diff"
27450 run_test 431 "Restart transaction for IO"
27452 cleanup_test_432() {
27453 do_facet mgs $LCTL nodemap_activate 0
27454 wait_nm_sync active
27458 local tmpdir=$TMP/dir432
27460 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
27461 skip "Need MDS version at least 2.14.52"
27463 stack_trap cleanup_test_432 EXIT
27467 do_facet mgs $LCTL nodemap_activate 1
27468 wait_nm_sync active
27469 do_facet mgs $LCTL nodemap_modify --name default \
27470 --property admin --value 1
27471 do_facet mgs $LCTL nodemap_modify --name default \
27472 --property trusted --value 1
27473 cancel_lru_locks mdc
27474 wait_nm_sync default admin_nodemap
27475 wait_nm_sync default trusted_nodemap
27477 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
27478 grep -ci "Operation not permitted") -ne 0 ]; then
27479 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
27482 run_test 432 "mv dir from outside Lustre"
27485 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27487 [[ -n "$($LCTL list_param llite.*.inode_cache 2>/dev/null)" ]] ||
27488 skip "inode cache not supported"
27490 $LCTL set_param llite.*.inode_cache=0
27491 stack_trap "$LCTL set_param llite.*.inode_cache=1"
27497 cancel_lru_locks mdc
27498 test_mkdir $DIR/$tdir || error "mkdir $tdir"
27499 createmany -m $DIR/$tdir/f $count
27500 createmany -d $DIR/$tdir/d $count
27501 ls -l $DIR/$tdir > /dev/null
27502 stack_trap "rm -rf $DIR/$tdir"
27504 before=$(num_objects)
27505 cancel_lru_locks mdc
27506 after=$(num_objects)
27508 # sometimes even @before is less than 2 * count
27509 while (( before - after < count )); do
27511 after=$(num_objects)
27513 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
27514 if (( wait > 60 )); then
27515 error "inode slab grew from $before to $after"
27519 echo "lustre_inode_cache $before objs before lock cancel, $after after"
27521 run_test 433 "ldlm lock cancel releases dentries and inodes"
27524 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
27525 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
27526 skip "Need server version at least 2.9.55"
27528 start_full_debug_logging
27532 stop_full_debug_logging
27536 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27537 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27538 awk '/The barrier for/ { print $7 }')
27541 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
27546 barrier_expired() {
27549 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27550 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27551 awk '/will be expired/ { print $7 }')
27553 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
27562 echo "Start barrier_freeze at: $(date)"
27563 #define OBD_FAIL_BARRIER_DELAY 0x2202
27564 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
27565 # Do not reduce barrier time - See LU-11873
27566 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
27569 local b_status=$(barrier_stat)
27570 echo "Got barrier status at: $(date)"
27571 [ "$b_status" = "'freezing_p1'" ] ||
27572 error "(1) unexpected barrier status $b_status"
27574 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
27576 b_status=$(barrier_stat)
27577 [ "$b_status" = "'frozen'" ] ||
27578 error "(2) unexpected barrier status $b_status"
27580 local expired=$(barrier_expired)
27581 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
27582 sleep $((expired + 3))
27584 b_status=$(barrier_stat)
27585 [ "$b_status" = "'expired'" ] ||
27586 error "(3) unexpected barrier status $b_status"
27588 # Do not reduce barrier time - See LU-11873
27589 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
27590 error "(4) fail to freeze barrier"
27592 b_status=$(barrier_stat)
27593 [ "$b_status" = "'frozen'" ] ||
27594 error "(5) unexpected barrier status $b_status"
27596 echo "Start barrier_thaw at: $(date)"
27597 #define OBD_FAIL_BARRIER_DELAY 0x2202
27598 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
27599 do_facet mgs $LCTL barrier_thaw $FSNAME &
27602 b_status=$(barrier_stat)
27603 echo "Got barrier status at: $(date)"
27604 [ "$b_status" = "'thawing'" ] ||
27605 error "(6) unexpected barrier status $b_status"
27607 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
27609 b_status=$(barrier_stat)
27610 [ "$b_status" = "'thawed'" ] ||
27611 error "(7) unexpected barrier status $b_status"
27613 #define OBD_FAIL_BARRIER_FAILURE 0x2203
27614 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
27615 do_facet mgs $LCTL barrier_freeze $FSNAME
27617 b_status=$(barrier_stat)
27618 [ "$b_status" = "'failed'" ] ||
27619 error "(8) unexpected barrier status $b_status"
27621 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
27622 do_facet mgs $LCTL barrier_thaw $FSNAME
27626 run_test 801a "write barrier user interfaces and stat machine"
27631 mkdir $DIR/$tdir || error "(1) fail to mkdir"
27632 createmany -d $DIR/$tdir/d 6 || error "(2) fail to mkdir"
27633 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
27634 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
27635 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
27637 cancel_lru_locks mdc
27639 # 180 seconds should be long enough
27640 do_facet mgs $LCTL barrier_freeze $FSNAME 180
27642 local b_status=$(barrier_stat)
27643 [ "$b_status" = "'frozen'" ] ||
27644 error "(6) unexpected barrier status $b_status"
27646 mkdir $DIR/$tdir/d0/d10 &
27649 touch $DIR/$tdir/d1/f13 &
27652 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
27655 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
27658 rm -f $DIR/$tdir/d4/f12 &
27661 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
27663 # To guarantee taht the 'stat' is not blocked
27664 b_status=$(barrier_stat)
27665 [ "$b_status" = "'frozen'" ] ||
27666 error "(8) unexpected barrier status $b_status"
27668 # let above commands to run at background
27671 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
27672 ps -p $touch_pid || error "(10) touch should be blocked"
27673 ps -p $ln_pid || error "(11) link should be blocked"
27674 ps -p $mv_pid || error "(12) rename should be blocked"
27675 ps -p $rm_pid || error "(13) unlink should be blocked"
27677 b_status=$(barrier_stat)
27678 [ "$b_status" = "'frozen'" ] ||
27679 error "(14) unexpected barrier status $b_status"
27681 do_facet mgs $LCTL barrier_thaw $FSNAME
27682 b_status=$(barrier_stat)
27683 [ "$b_status" = "'thawed'" ] ||
27684 error "(15) unexpected barrier status $b_status"
27686 wait $mkdir_pid || error "(16) mkdir should succeed"
27687 wait $touch_pid || error "(17) touch should succeed"
27688 wait $ln_pid || error "(18) link should succeed"
27689 wait $mv_pid || error "(19) rename should succeed"
27690 wait $rm_pid || error "(20) unlink should succeed"
27694 run_test 801b "modification will be blocked by write barrier"
27697 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27701 stop mds2 || error "(1) Fail to stop mds2"
27703 do_facet mgs $LCTL barrier_freeze $FSNAME 30
27705 local b_status=$(barrier_stat)
27706 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
27707 do_facet mgs $LCTL barrier_thaw $FSNAME
27708 error "(2) unexpected barrier status $b_status"
27711 do_facet mgs $LCTL barrier_rescan $FSNAME ||
27712 error "(3) Fail to rescan barrier bitmap"
27714 # Do not reduce barrier time - See LU-11873
27715 do_facet mgs $LCTL barrier_freeze $FSNAME 20
27717 b_status=$(barrier_stat)
27718 [ "$b_status" = "'frozen'" ] ||
27719 error "(4) unexpected barrier status $b_status"
27721 do_facet mgs $LCTL barrier_thaw $FSNAME
27722 b_status=$(barrier_stat)
27723 [ "$b_status" = "'thawed'" ] ||
27724 error "(5) unexpected barrier status $b_status"
27726 local devname=$(mdsdevname 2)
27728 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
27730 do_facet mgs $LCTL barrier_rescan $FSNAME ||
27731 error "(7) Fail to rescan barrier bitmap"
27735 run_test 801c "rescan barrier bitmap"
27737 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
27738 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
27739 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
27740 saved_MOUNT_OPTS=$MOUNT_OPTS
27746 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
27747 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
27748 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
27749 MOUNT_OPTS=$saved_MOUNT_OPTS
27754 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
27755 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
27756 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
27757 skip "Need server version at least 2.9.55"
27759 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
27761 mkdir $DIR/$tdir || error "(1) fail to mkdir"
27763 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
27764 error "(2) Fail to copy"
27766 trap cleanup_802a EXIT
27768 # sync by force before remount as readonly
27769 sync; sync_all_data; sleep 3; sync_all_data
27773 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
27774 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
27775 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
27777 echo "Mount the server as read only"
27778 setupall server_only || error "(3) Fail to start servers"
27780 echo "Mount client without ro should fail"
27781 mount_client $MOUNT &&
27782 error "(4) Mount client without 'ro' should fail"
27784 echo "Mount client with ro should succeed"
27785 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
27786 mount_client $MOUNT ||
27787 error "(5) Mount client with 'ro' should succeed"
27789 echo "Modify should be refused"
27790 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
27792 echo "Read should be allowed"
27793 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
27794 error "(7) Read should succeed under ro mode"
27798 run_test 802a "simulate readonly device"
27801 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27802 remote_mds_nodsh && skip "remote MDS with nodsh"
27804 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
27805 skip "readonly option not available"
27807 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
27809 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
27810 error "(2) Fail to copy"
27812 # write back all cached data before setting MDT to readonly
27816 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
27817 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
27819 echo "Modify should be refused"
27820 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
27822 echo "Read should be allowed"
27823 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
27824 error "(7) Read should succeed under ro mode"
27827 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
27829 run_test 802b "be able to set MDTs to readonly"
27832 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27833 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
27834 skip "MDS needs to be newer than 2.10.54"
27836 mkdir_on_mdt0 $DIR/$tdir
27837 # Create some objects on all MDTs to trigger related logs objects
27838 for idx in $(seq $MDSCOUNT); do
27839 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
27840 $DIR/$tdir/dir${idx} ||
27841 error "Fail to create $DIR/$tdir/dir${idx}"
27844 wait_delete_completed # ensure old test cleanups are finished
27846 echo "before create:"
27848 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27850 for i in {1..10}; do
27851 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
27852 error "Fail to create $DIR/$tdir/foo$i"
27855 # sync ZFS-on-MDS to refresh statfs data
27856 wait_zfs_commit mds1
27858 echo "after create:"
27860 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27862 # allow for an llog to be cleaned up during the test
27863 [ $after_used -ge $((before_used + 10 - 1)) ] ||
27864 error "before ($before_used) + 10 > after ($after_used)"
27866 for i in {1..10}; do
27867 rm -rf $DIR/$tdir/foo$i ||
27868 error "Fail to remove $DIR/$tdir/foo$i"
27871 # sync ZFS-on-MDS to refresh statfs data
27872 wait_zfs_commit mds1
27873 wait_delete_completed
27874 sleep 3 # avoid MDT return cached statfs
27875 echo "after unlink:"
27877 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27879 # allow for an llog to be created during the test
27880 [ $after_used -le $((before_used + 1)) ] ||
27881 error "after ($after_used) > before ($before_used) + 1"
27883 run_test 803a "verify agent object for remote object"
27886 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27887 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
27888 skip "MDS needs to be newer than 2.13.56"
27889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27891 for i in $(seq 0 $((MDSCOUNT - 1))); do
27892 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
27900 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
27901 for i in $(seq 0 $((MDSCOUNT - 1))); do
27902 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
27903 awk '/getattr/ { print $2 }')
27904 before=$((before + tmp))
27906 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
27907 for i in $(seq 0 $((MDSCOUNT - 1))); do
27908 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
27909 awk '/getattr/ { print $2 }')
27910 after=$((after + tmp))
27913 [ $before -eq $after ] || error "getattr count $before != $after"
27915 run_test 803b "remote object can getattr from cache"
27918 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27919 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
27920 skip "MDS needs to be newer than 2.10.54"
27921 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
27923 mkdir -p $DIR/$tdir
27924 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
27925 error "Fail to create $DIR/$tdir/dir0"
27927 local fid=$($LFS path2fid $DIR/$tdir/dir0)
27928 local dev=$(mdsdevname 2)
27930 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27931 grep ${fid} || error "NOT found agent entry for dir0"
27933 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
27934 error "Fail to create $DIR/$tdir/dir1"
27936 touch $DIR/$tdir/dir1/foo0 ||
27937 error "Fail to create $DIR/$tdir/dir1/foo0"
27938 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
27941 for idx in $(seq $MDSCOUNT); do
27942 dev=$(mdsdevname $idx)
27943 do_facet mds${idx} \
27944 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27945 grep ${fid} && rc=$idx
27948 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
27949 error "Fail to rename foo0 to foo1"
27950 if [ $rc -eq 0 ]; then
27951 for idx in $(seq $MDSCOUNT); do
27952 dev=$(mdsdevname $idx)
27953 do_facet mds${idx} \
27954 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27955 grep ${fid} && rc=$idx
27959 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
27960 error "Fail to rename foo1 to foo2"
27961 if [ $rc -eq 0 ]; then
27962 for idx in $(seq $MDSCOUNT); do
27963 dev=$(mdsdevname $idx)
27964 do_facet mds${idx} \
27965 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27966 grep ${fid} && rc=$idx
27970 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
27972 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
27973 error "Fail to link to $DIR/$tdir/dir1/foo2"
27974 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
27975 error "Fail to rename foo2 to foo0"
27976 unlink $DIR/$tdir/dir1/foo0 ||
27977 error "Fail to unlink $DIR/$tdir/dir1/foo0"
27978 rm -rf $DIR/$tdir/dir0 ||
27979 error "Fail to rm $DIR/$tdir/dir0"
27981 for idx in $(seq $MDSCOUNT); do
27985 dev=$(mdsdevname $idx)
27986 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
27988 start mds${idx} $dev $MDS_MOUNT_OPTS ||
27989 error "mount mds$idx failed"
27990 df $MOUNT > /dev/null 2>&1
27992 # e2fsck should not return error
27994 error "e2fsck detected error on MDT${idx}: rc=$rc"
27997 run_test 804 "verify agent entry for remote entry"
28000 do_facet $SINGLEMDS zfs set quota=$old $fsset
28001 unlinkmany $DIR/$tdir/f- 1000000
28006 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
28007 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
28008 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
28009 skip "netfree not implemented before 0.7"
28010 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
28011 skip "Need MDS version at least 2.10.57"
28018 local pref="osd-zfs.$FSNAME-MDT0000."
28020 # limit available space on MDS dataset to meet nospace issue
28021 # quickly. then ZFS 0.7.2 can use reserved space if asked
28022 # properly (using netfree flag in osd_declare_destroy()
28023 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
28024 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
28026 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
28027 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
28028 let "usedkb=usedkb-freekb"
28029 let "freekb=freekb/2"
28030 if let "freekb > 5000"; then
28033 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
28034 trap cleanup_805 EXIT
28035 mkdir_on_mdt0 $DIR/$tdir
28036 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
28037 error "Can't set PFL layout"
28038 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
28039 rm -rf $DIR/$tdir || error "not able to remove"
28040 do_facet $SINGLEMDS zfs set quota=$old $fsset
28043 run_test 805 "ZFS can remove from full fs"
28049 local expect=$(stat -c %s $file)
28051 check_lsom_size $1 $expect
28053 local blocks=$($LFS getsom -b $file)
28054 expect=$(stat -c %b $file)
28055 [[ $blocks == $expect ]] ||
28056 error "$file expected blocks: $expect, got: $blocks"
28064 cancel_lru_locks mdc
28066 size=$($LFS getsom -s $1)
28067 [[ $size == $expect ]] ||
28068 error "$file expected size: $expect, got: $size"
28072 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
28073 skip "Need MDS version at least 2.11.52"
28077 touch $DIR/$tfile || error "touch $tfile failed"
28079 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
28080 save_lustre_params client "llite.*.xattr_cache" > $save
28081 lctl set_param llite.*.xattr_cache=0
28082 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
28084 # single-threaded write
28085 echo "Test SOM for single-threaded write"
28086 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
28087 error "write $tfile failed"
28088 check_lsom_size $DIR/$tfile $bs
28091 local size=$(($num * $bs))
28095 echo "Test SOM for single client multi-threaded($num) write"
28096 $TRUNCATE $DIR/$tfile 0
28097 for ((i = 0; i < $num; i++)); do
28098 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28100 offset=$((offset + $bs))
28102 for (( i=0; i < $num; i++ )); do
28105 check_lsom_size $DIR/$tfile $size
28107 $TRUNCATE $DIR/$tfile 0
28108 for ((i = 0; i < $num; i++)); do
28109 offset=$((offset - $bs))
28110 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28113 for (( i=0; i < $num; i++ )); do
28116 check_lsom_size $DIR/$tfile $size
28118 # multi-client writes
28119 num=$(get_node_count ${CLIENTS//,/ })
28120 size=$(($num * $bs))
28124 echo "Test SOM for multi-client ($num) writes"
28125 $TRUNCATE $DIR/$tfile 0
28126 for client in ${CLIENTS//,/ }; do
28127 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28130 offset=$((offset + $bs))
28132 for (( i=0; i < $num; i++ )); do
28135 check_lsom_size $DIR/$tfile $offset
28138 $TRUNCATE $DIR/$tfile 0
28139 for client in ${CLIENTS//,/ }; do
28140 offset=$((offset - $bs))
28141 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28145 for (( i=0; i < $num; i++ )); do
28148 check_lsom_size $DIR/$tfile $size
28151 echo "Test SOM for truncate"
28152 $TRUNCATE $DIR/$tfile 1048576
28153 check_lsom_size $DIR/$tfile 1048576
28154 $TRUNCATE $DIR/$tfile 1234
28155 check_lsom_size $DIR/$tfile 1234
28157 # verify SOM blocks count
28158 echo "Verify SOM block count"
28159 $TRUNCATE $DIR/$tfile 0
28160 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
28161 error "failed to write file $tfile"
28162 check_lsom_data $DIR/$tfile
28164 run_test 806 "Verify Lazy Size on MDS"
28167 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
28168 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
28169 skip "Need MDS version at least 2.11.52"
28171 # Registration step
28172 changelog_register || error "changelog_register failed"
28173 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
28174 changelog_users $SINGLEMDS | grep -q $cl_user ||
28175 error "User $cl_user not found in changelog_users"
28177 rm -rf $DIR/$tdir || error "rm $tdir failed"
28178 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
28179 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
28180 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
28181 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
28182 error "truncate $tdir/trunc failed"
28185 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
28186 error "write $tfile failed"
28188 # multi-client wirtes
28189 local num=$(get_node_count ${CLIENTS//,/ })
28193 echo "Test SOM for multi-client ($num) writes"
28194 touch $DIR/$tfile || error "touch $tfile failed"
28195 $TRUNCATE $DIR/$tfile 0
28196 for client in ${CLIENTS//,/ }; do
28197 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28200 offset=$((offset + $bs))
28202 for (( i=0; i < $num; i++ )); do
28206 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
28207 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
28208 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
28209 check_lsom_data $DIR/$tdir/trunc
28210 check_lsom_data $DIR/$tdir/single_dd
28211 check_lsom_data $DIR/$tfile
28214 # Deregistration step
28215 changelog_deregister || error "changelog_deregister failed"
28217 run_test 807 "verify LSOM syncing tool"
28219 check_som_nologged()
28221 local lines=$($LFS changelog $FSNAME-MDT0000 |
28222 grep 'x=trusted.som' | wc -l)
28223 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
28227 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
28228 skip "Need MDS version at least 2.11.55"
28230 # Registration step
28231 changelog_register || error "changelog_register failed"
28233 touch $DIR/$tfile || error "touch $tfile failed"
28236 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
28237 error "write $tfile failed"
28240 $TRUNCATE $DIR/$tfile 1234
28243 $TRUNCATE $DIR/$tfile 1048576
28246 # Deregistration step
28247 changelog_deregister || error "changelog_deregister failed"
28249 run_test 808 "Check trusted.som xattr not logged in Changelogs"
28254 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
28258 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
28259 skip "Need MDS version at least 2.11.56"
28261 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
28262 error "failed to create DoM-only file $DIR/$tfile"
28263 touch $DIR/$tfile || error "touch $tfile failed"
28264 check_som_nodata $DIR/$tfile
28266 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
28267 error "write $tfile failed"
28268 check_som_nodata $DIR/$tfile
28270 $TRUNCATE $DIR/$tfile 1234
28271 check_som_nodata $DIR/$tfile
28273 $TRUNCATE $DIR/$tfile 4097
28274 check_som_nodata $DIR/$file
28276 run_test 809 "Verify no SOM xattr store for DoM-only files"
28279 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28280 $GSS && skip_env "could not run with gss"
28281 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
28282 skip "OST < 2.12.58 doesn't align checksum"
28285 stack_trap "set_checksums $ORIG_CSUM" EXIT
28286 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
28291 for csum in $CKSUM_TYPES; do
28292 #define OBD_FAIL_OSC_NO_GRANT 0x411
28293 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
28294 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
28296 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
28297 before=$(md5sum $DIR/$tfile)
28298 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
28299 after=$(md5sum $DIR/$tfile)
28300 [ "$before" == "$after" ] ||
28301 error "$csum: $before != $after bs=$1 seek=$2"
28305 run_test 810 "partial page writes on ZFS (LU-11663)"
28308 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
28309 skip "OST < 2.12.51 doesn't support this fail_loc"
28311 $LFS setstripe -c 1 -i 0 $DIR/$tfile
28312 # ensure ost1 is connected
28313 stat $DIR/$tfile >/dev/null || error "can't stat"
28314 wait_osc_import_state client ost1 FULL
28315 # no locks, no reqs to let the connection idle
28316 cancel_lru_locks osc
28318 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
28319 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
28320 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
28321 wait_osc_import_state client ost1 CONNECTING
28322 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
28324 stat $DIR/$tfile >/dev/null || error "can't stat file"
28326 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
28328 test_812b() { # LU-12378
28329 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
28330 skip "OST < 2.12.51 doesn't support this fail_loc"
28332 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
28333 # ensure ost1 is connected
28334 stat $DIR/$tfile >/dev/null || error "can't stat"
28335 wait_osc_import_state client ost1 FULL
28336 # no locks, no reqs to let the connection idle
28337 cancel_lru_locks osc
28339 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
28340 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
28341 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
28342 wait_osc_import_state client ost1 CONNECTING
28343 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
28345 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
28346 wait_osc_import_state client ost1 IDLE
28348 run_test 812b "do not drop no resend request for idle connect"
28353 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
28355 $LFS setstripe -c 1 -o 0 $DIR/$tfile
28356 $LFS getstripe $DIR/$tfile
28357 $LCTL set_param osc.*.idle_timeout=10
28358 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
28359 # ensure ost1 is connected
28360 stat $DIR/$tfile >/dev/null || error "can't stat"
28361 wait_osc_import_state client ost1 FULL
28362 # no locks, no reqs to let the connection idle
28363 cancel_lru_locks osc
28365 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
28366 $LCTL set_param fail_loc=0x80000533
28368 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
28370 run_test 812c "idle import vs lock enqueue race"
28373 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
28374 [ -z "$file_heat_sav" ] && skip "no file heat support"
28385 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
28386 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
28388 $LCTL set_param -n llite.*.file_heat=1
28389 echo "Turn on file heat"
28390 echo "Period second: $period_second, Decay percentage: $decay_pct"
28392 echo "QQQQ" > $DIR/$tfile
28393 echo "QQQQ" > $DIR/$tfile
28394 echo "QQQQ" > $DIR/$tfile
28395 cat $DIR/$tfile > /dev/null
28396 cat $DIR/$tfile > /dev/null
28397 cat $DIR/$tfile > /dev/null
28398 cat $DIR/$tfile > /dev/null
28400 local out=$($LFS heat_get $DIR/$tfile)
28402 $LFS heat_get $DIR/$tfile
28403 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28404 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28405 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28406 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28408 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
28409 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
28410 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
28411 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
28413 sleep $((period_second + 3))
28414 echo "Sleep $((period_second + 3)) seconds..."
28415 # The recursion formula to calculate the heat of the file f is as
28417 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
28418 # Where Hi is the heat value in the period between time points i*I and
28419 # (i+1)*I; Ci is the access count in the period; the symbol P refers
28420 # to the weight of Ci.
28421 out=$($LFS heat_get $DIR/$tfile)
28422 $LFS heat_get $DIR/$tfile
28423 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28424 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28425 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28426 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28428 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
28429 error "read sample ($readsample) is wrong"
28430 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
28431 error "write sample ($writesample) is wrong"
28432 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
28433 error "read bytes ($readbyte) is wrong"
28434 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
28435 error "write bytes ($writebyte) is wrong"
28437 echo "QQQQ" > $DIR/$tfile
28438 echo "QQQQ" > $DIR/$tfile
28439 echo "QQQQ" > $DIR/$tfile
28440 cat $DIR/$tfile > /dev/null
28441 cat $DIR/$tfile > /dev/null
28442 cat $DIR/$tfile > /dev/null
28443 cat $DIR/$tfile > /dev/null
28445 sleep $((period_second + 3))
28446 echo "Sleep $((period_second + 3)) seconds..."
28448 out=$($LFS heat_get $DIR/$tfile)
28449 $LFS heat_get $DIR/$tfile
28450 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28451 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28452 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28453 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28455 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
28456 4 * $decay_pct) / 100") -eq 1 ] ||
28457 error "read sample ($readsample1) is wrong"
28458 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
28459 3 * $decay_pct) / 100") -eq 1 ] ||
28460 error "write sample ($writesample1) is wrong"
28461 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
28462 20 * $decay_pct) / 100") -eq 1 ] ||
28463 error "read bytes ($readbyte1) is wrong"
28464 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
28465 15 * $decay_pct) / 100") -eq 1 ] ||
28466 error "write bytes ($writebyte1) is wrong"
28468 echo "Turn off file heat for the file $DIR/$tfile"
28469 $LFS heat_set -o $DIR/$tfile
28471 echo "QQQQ" > $DIR/$tfile
28472 echo "QQQQ" > $DIR/$tfile
28473 echo "QQQQ" > $DIR/$tfile
28474 cat $DIR/$tfile > /dev/null
28475 cat $DIR/$tfile > /dev/null
28476 cat $DIR/$tfile > /dev/null
28477 cat $DIR/$tfile > /dev/null
28479 out=$($LFS heat_get $DIR/$tfile)
28480 $LFS heat_get $DIR/$tfile
28481 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28482 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28483 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28484 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28486 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28487 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28488 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28489 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28491 echo "Trun on file heat for the file $DIR/$tfile"
28492 $LFS heat_set -O $DIR/$tfile
28494 echo "QQQQ" > $DIR/$tfile
28495 echo "QQQQ" > $DIR/$tfile
28496 echo "QQQQ" > $DIR/$tfile
28497 cat $DIR/$tfile > /dev/null
28498 cat $DIR/$tfile > /dev/null
28499 cat $DIR/$tfile > /dev/null
28500 cat $DIR/$tfile > /dev/null
28502 out=$($LFS heat_get $DIR/$tfile)
28503 $LFS heat_get $DIR/$tfile
28504 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28505 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28506 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28507 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28509 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
28510 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
28511 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
28512 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
28514 $LFS heat_set -c $DIR/$tfile
28515 $LCTL set_param -n llite.*.file_heat=0
28516 echo "Turn off file heat support for the Lustre filesystem"
28518 echo "QQQQ" > $DIR/$tfile
28519 echo "QQQQ" > $DIR/$tfile
28520 echo "QQQQ" > $DIR/$tfile
28521 cat $DIR/$tfile > /dev/null
28522 cat $DIR/$tfile > /dev/null
28523 cat $DIR/$tfile > /dev/null
28524 cat $DIR/$tfile > /dev/null
28526 out=$($LFS heat_get $DIR/$tfile)
28527 $LFS heat_get $DIR/$tfile
28528 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28529 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28530 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28531 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28533 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28534 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28535 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28536 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28538 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
28541 run_test 813 "File heat verfication"
28545 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
28546 echo -n y >> $DIR/$tfile
28547 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
28548 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
28550 run_test 814 "sparse cp works as expected (LU-12361)"
28554 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
28555 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
28557 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
28560 local ost1_imp=$(get_osc_import_name client ost1)
28561 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
28564 $LFS setstripe -c 1 -i 0 $DIR/$tfile
28565 # ensure ost1 is connected
28567 stat $DIR/$tfile >/dev/null || error "can't stat"
28568 wait_osc_import_state client ost1 FULL
28569 # no locks, no reqs to let the connection idle
28570 cancel_lru_locks osc
28571 lru_resize_disable osc
28574 before=$($LCTL get_param -n \
28575 ldlm.namespaces.$imp_name.lru_size)
28577 wait_osc_import_state client ost1 IDLE
28578 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
28579 now=$($LCTL get_param -n \
28580 ldlm.namespaces.$imp_name.lru_size)
28581 [ $before == $now ] || error "lru_size changed $before != $now"
28583 run_test 816 "do not reset lru_resize on idle reconnect"
28587 exportfs -u localhost:$DIR/nfsexp
28592 systemctl restart nfs-server.service || skip "failed to restart nfsd"
28594 mkdir -p $DIR/nfsexp
28595 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
28596 error "failed to export nfs"
28598 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
28599 stack_trap cleanup_817 EXIT
28601 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
28602 error "failed to mount nfs to $tmpdir"
28604 cp /bin/true $tmpdir
28605 $DIR/nfsexp/true || error "failed to execute 'true' command"
28607 run_test 817 "nfsd won't cache write lock for exec file"
28610 test_mkdir -i0 -c1 $DIR/$tdir
28611 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
28612 $LFS setstripe -c1 -i1 $DIR/$tdir/$tfile
28615 # restore osp-syn threads
28616 stack_trap "fail $SINGLEMDS"
28618 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
28619 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
28620 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
28621 error "start $SINGLEMDS failed"
28624 local testid=$(echo $TESTNAME | tr '_' ' ')
28626 do_facet mds1 dmesg | tac | sed "/$testid/,$ d" |
28627 grep "run LFSCK" || error "run LFSCK is not suggested"
28629 run_test 818 "unlink with failed llog"
28632 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28633 cancel_lru_locks osc
28634 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
28635 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
28636 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
28639 run_test 819a "too big niobuf in read"
28642 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
28643 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
28644 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28645 cancel_lru_locks osc
28649 run_test 819b "too big niobuf in write"
28652 function test_820_start_ost() {
28655 for num in $(seq $OSTCOUNT); do
28656 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
28661 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28664 umount_client $MOUNT || error "umount failed"
28665 for num in $(seq $OSTCOUNT); do
28669 # mount client with no active OSTs
28670 # so that the client can't initialize max LOV EA size
28671 # from OSC notifications
28672 mount_client $MOUNT || error "mount failed"
28673 # delay OST starting to keep this 0 max EA size for a while
28674 test_820_start_ost &
28676 # create a directory on MDS2
28677 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
28678 error "Failed to create directory"
28679 # open intent should update default EA size
28680 # see mdc_update_max_ea_from_body()
28681 # notice this is the very first RPC to MDS2
28682 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
28685 # With SSK, this situation can lead to -EPERM being returned.
28686 # In that case, simply retry.
28687 if [ $ret -ne 0 ] && $SHARED_KEY; then
28688 if echo "$out" | grep -q "not permitted"; then
28689 cp /etc/services $DIR/$tdir/mds2
28693 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
28695 run_test 820 "update max EA from open intent"
28698 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28699 local OST_MAX_PRECREATE=20000
28701 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
28702 skip "Need MDS version at least 2.14.56"
28704 save_lustre_params mds1 \
28705 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
28706 do_facet $SINGLEMDS "$LCTL set_param -n \
28707 osp.$FSNAME-OST*MDT0000.max_create_count=0"
28708 do_facet $SINGLEMDS "$LCTL set_param -n \
28709 osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE"
28711 stack_trap "restore_lustre_params < $p; rm $p"
28713 do_facet $SINGLEMDS "$LCTL set_param -n \
28714 osp.$FSNAME-OST*-osc-MDT*.create_count=100200"
28716 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
28717 osp.$FSNAME-OST0000*MDT0000.create_count")
28718 local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \
28719 osp.$FSNAME-OST0000*MDT0000.max_create_count")
28720 local expect_count=$(((($max/2)/256) * 256))
28722 log "setting create_count to 100200:"
28723 log " -result- count: $count with max: $max, expecting: $expect_count"
28725 [[ $count -eq expect_count ]] ||
28726 error "Create count not set to max precreate."
28728 run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum"
28731 [[ $MDS1_VERSION -lt $(version_code 2.14.56) ]] &&
28732 skip "Need MDS version 2.14.56"
28734 local sync_changes=$(do_facet $SINGLEMDS \
28735 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
28737 [ "$sync_changes" -gt 100 ] &&
28738 skip "Sync changes $sync_changes > 100 already"
28740 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28742 $LFS mkdir -i 0 $DIR/$tdir
28743 $LFS setstripe -c 1 -i 0 $DIR/$tdir
28745 save_lustre_params mds1 \
28746 "osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes" > $p
28747 save_lustre_params mds1 \
28748 "osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress" >> $p
28750 do_facet mds1 "$LCTL set_param -n \
28751 osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes=100 \
28752 osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress=128"
28753 stack_trap "restore_lustre_params < $p" EXIT
28755 createmany -o $DIR/$tdir/f- 1000
28756 unlinkmany $DIR/$tdir/f- 1000 &
28757 local UNLINK_PID=$!
28760 sync_changes=$(do_facet mds1 \
28761 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
28762 # the check in the code is racy, fail the test
28763 # if the value above the limit by 10.
28764 [ $sync_changes -gt 110 ] && {
28765 kill -2 $UNLINK_PID
28767 error "osp changes throttling failed, $sync_changes>110"
28769 kill -0 $UNLINK_PID 2> /dev/null || break
28773 run_test 831 "throttling unlink/setattr queuing on OSP"
28776 # tests that do cleanup/setup should be run at the end
28780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28783 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
28784 $LCTL set_param fail_loc=0x903
28786 cancel_lru_locks MGC
28788 FAIL_ON_ERROR=true cleanup
28789 FAIL_ON_ERROR=true setup
28791 run_test 900 "umount should not race with any mgc requeue thread"
28793 # LUS-6253/LU-11185
28801 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28803 # some get_param have a bug to handle dot in param name
28804 cancel_lru_locks MGC
28805 old=$(mount -t lustre | wc -l)
28813 while [ $old -ne $oldc ]; do
28814 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
28817 if [ $count -ge $TIMEOUT ]; then
28818 error "too large timeout"
28821 umount_client $MOUNT || error "umount failed"
28822 mount_client $MOUNT || error "mount failed"
28823 cancel_lru_locks MGC
28824 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
28826 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
28830 run_test 901 "don't leak a mgc lock on client umount"
28834 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
28835 skip "client does not have LU-13377 fix"
28836 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
28837 $LCTL set_param fail_loc=0x1415
28838 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28839 cancel_lru_locks osc
28842 run_test 902 "test short write doesn't hang lustre"
28846 $LFS setstripe -i 0 -c 1 $DIR/$tfile $DIR/${tfile}-2
28847 echo "blah" > $DIR/${tfile}-2
28848 dd if=/dev/zero of=$DIR/$tfile bs=1M count=6 conv=fsync
28849 #define OBD_FAIL_OSC_SLOW_PAGE_EVICT 0x417
28850 $LCTL set_param fail_loc=0x417 fail_val=20
28852 mv $DIR/${tfile}-2 $DIR/$tfile # Destroys the big object
28853 sleep 1 # To start the destroy
28854 wait_destroy_complete 150 || error "Destroy taking too long"
28855 cat $DIR/$tfile > /dev/null || error "Evicted"
28857 run_test 903 "Test long page discard does not cause evictions"
28860 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
28861 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
28862 grep -q project || skip "skip project quota not supported"
28864 local testfile="$DIR/$tdir/$tfile"
28865 local xattr="trusted.projid"
28867 local mdts=$(comma_list $(mdts_nodes))
28868 local saved=$(do_facet mds1 $LCTL get_param -n \
28869 osd-ldiskfs.*MDT0000.enable_projid_xattr)
28871 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=0
28872 stack_trap "do_nodes $mdts $LCTL set_param \
28873 osd-ldiskfs.*MDT*.enable_projid_xattr=$saved"
28875 mkdir -p $DIR/$tdir
28877 #hide projid xattr on server
28878 $LFS project -p 1 $testfile ||
28879 error "set $testfile project id failed"
28880 getfattr -m - $testfile | grep $xattr &&
28881 error "do not show trusted.projid when disabled on server"
28882 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=1
28883 #should be hidden when projid is 0
28884 $LFS project -p 0 $testfile ||
28885 error "set $testfile project id failed"
28886 getfattr -m - $testfile | grep $xattr &&
28887 error "do not show trusted.projid with project ID 0"
28889 #still can getxattr explicitly
28890 projid=$(getfattr -n $xattr $testfile |
28891 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28892 [ $projid == "0" ] ||
28893 error "projid expected 0 not $projid"
28895 #set the projid via setxattr
28896 setfattr -n $xattr -v "1000" $testfile ||
28897 error "setattr failed with $?"
28898 projid=($($LFS project $testfile))
28899 [ ${projid[0]} == "1000" ] ||
28900 error "projid expected 1000 not $projid"
28902 #check the new projid via getxattr
28903 $LFS project -p 1001 $testfile ||
28904 error "set $testfile project id failed"
28905 getfattr -m - $testfile | grep $xattr ||
28906 error "should show trusted.projid when project ID != 0"
28907 projid=$(getfattr -n $xattr $testfile |
28908 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28909 [ $projid == "1001" ] ||
28910 error "projid expected 1001 not $projid"
28912 #try to set invalid projid
28913 setfattr -n $xattr -v "4294967295" $testfile &&
28914 error "set invalid projid should fail"
28916 #remove the xattr means setting projid to 0
28917 setfattr -x $xattr $testfile ||
28918 error "setfattr failed with $?"
28919 projid=($($LFS project $testfile))
28920 [ ${projid[0]} == "0" ] ||
28921 error "projid expected 0 not $projid"
28923 #should be hidden when parent has inherit flag and same projid
28924 $LFS project -srp 1002 $DIR/$tdir ||
28925 error "set $tdir project id failed"
28926 getfattr -m - $testfile | grep $xattr &&
28927 error "do not show trusted.projid with inherit flag"
28929 #still can getxattr explicitly
28930 projid=$(getfattr -n $xattr $testfile |
28931 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28932 [ $projid == "1002" ] ||
28933 error "projid expected 1002 not $projid"
28935 run_test 904 "virtual project ID xattr"
28939 (( $OST1_VERSION >= $(version_code 2.8.54) )) ||
28940 skip "lustre < 2.8.54 does not support ladvise"
28942 remote_ost_nodsh && skip "remote OST with nodsh"
28943 $LFS setstripe -c -1 -i 0 $DIR/$tfile || error "setstripe failed"
28945 $LFS ladvise -a willread $DIR/$tfile || error "ladvise does not work"
28947 #define OBD_FAIL_OST_OPCODE 0x253
28949 do_facet ost1 "$LCTL set_param fail_val=21 fail_loc=0x0253"
28950 $LFS ladvise -a willread $DIR/$tfile &&
28951 error "unexpected success of ladvise with fault injection"
28952 $LFS ladvise -a willread $DIR/$tfile |&
28953 grep -q "Operation not supported"
28954 (( $? == 0 )) || error "unexpected stderr of ladvise with fault injection"
28956 run_test 905 "bad or new opcode should not stuck client"
28959 grep -q io_uring_setup /proc/kallsyms ||
28960 skip "Client OS does not support io_uring I/O engine"
28961 io_uring_probe || skip "kernel does not support io_uring fully"
28962 which fio || skip_env "no fio installed"
28963 fio --enghelp | grep -q io_uring ||
28964 skip_env "fio does not support io_uring I/O engine"
28966 local file=$DIR/$tfile
28967 local ioengine="io_uring"
28971 fio --name=seqwrite --ioengine=$ioengine \
28972 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
28973 --iodepth=64 --size=$size --filename=$file --rw=write ||
28974 error "fio seqwrite $file failed"
28976 fio --name=seqread --ioengine=$ioengine \
28977 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
28978 --iodepth=64 --size=$size --filename=$file --rw=read ||
28979 error "fio seqread $file failed"
28981 rm -f $file || error "rm -f $file failed"
28983 run_test 906 "Simple test for io_uring I/O engine via fio"
28986 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
28987 check_and_cleanup_lustre
28988 if [ "$I_MOUNTED" != "yes" ]; then
28989 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true