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 SOCKETSERVER=${SOCKETSERVER:-socketserver}
23 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
24 MEMHOG=${MEMHOG:-memhog}
25 DIRECTIO=${DIRECTIO:-directio}
26 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
28 CHECK_GRANT=${CHECK_GRANT:-"yes"}
29 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
32 LUSTRE=${LUSTRE:-$(dirname $0)/..}
33 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
34 . $LUSTRE/tests/test-framework.sh
39 ALWAYS_EXCEPT="$SANITY_EXCEPT "
40 always_except LU-9693 42a 42c
41 always_except LU-6493 42b
42 always_except LU-16515 118c 118d
43 always_except LU-8411 407
46 always_except LU-14181 64e 64f
49 # skip the grant tests for ARM until they are fixed
50 if [[ $(uname -m) = aarch64 ]]; then
51 always_except LU-11671 45
54 # skip nfs tests on kernels >= 4.12.0 until they are fixed
55 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
56 always_except LU-12661 817
58 # skip cgroup tests on RHEL8.1 kernels until they are fixed
59 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
60 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
61 always_except LU-13063 411
65 [[ "$SLOW" = "no" ]] && EXCEPT_SLOW="27m 60i 64b 68 71 135 136 230d 300o"
67 if [[ "$mds1_FSTYPE" == "zfs" ]]; then
69 [[ "$SLOW" == "no" ]] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
72 if [[ "$ost1_FSTYPE" = "zfs" ]]; then
73 always_except LU-1941 130b 130c 130d 130e 130f 130g
74 always_except LU-9054 312
77 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
79 # Get the SLES distro version
81 # Returns a version string that should only be used in comparing
82 # strings returned by version_code()
85 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
87 # All SuSE Linux versions have one decimal. version_code expects two
88 local sles_version=$version.0
89 version_code $sles_version
92 # Check if we are running on Ubuntu or SLES so we can make decisions on
94 if [ -r /etc/SuSE-release ] || [ -r /etc/SUSE-brand ]; then
95 sles_version=$(sles_version_code)
96 [ $sles_version -lt $(version_code 11.4.0) ] &&
97 always_except LU-4341 170
99 [ $sles_version -lt $(version_code 12.0.0) ] &&
100 always_except LU-3703 234
101 elif [ -r /etc/os-release ]; then
102 if grep -qi ubuntu /etc/os-release; then
103 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
104 -e 's/^VERSION=//p' \
108 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
109 always_except LU-10366 410
119 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
120 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
129 check_swap_layouts_support()
131 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
132 skip "Does not support layout lock."
135 check_swap_layout_no_dom()
138 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
139 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
142 check_and_setup_lustre
146 MAXFREE=${MAXFREE:-$((300000 * $OSTCOUNT))}
148 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
149 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
150 rm -rf $DIR/[Rdfs][0-9]*
152 # $RUNAS_ID may get set incorrectly somewhere else
153 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
154 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
156 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
158 if [ "${ONLY}" = "MOUNT" ] ; then
159 echo "Lustre is up, please go on"
163 echo "preparing for tests involving mounts"
164 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
166 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
167 echo # add a newline after mke2fs.
171 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
173 # ensure all internal functions know we want full debug
175 lctl set_param debug=$PTLDEBUG 2> /dev/null || true
179 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
181 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
183 run_test 0a "touch; rm ====================="
186 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
187 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
189 run_test 0b "chmod 0755 $DIR ============================="
192 $LCTL get_param mdc.*.import | grep "state: FULL" ||
193 error "import not FULL"
194 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
197 run_test 0c "check import proc"
199 test_0d() { # LU-3397
200 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
201 skip "proc exports not supported before 2.10.57"
203 local mgs_exp="mgs.MGS.exports"
204 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
206 local exp_client_version
209 local temp_imp=$DIR/$tfile.import
210 local temp_exp=$DIR/$tfile.export
212 # save mgc import file to $temp_imp
213 $LCTL get_param mgc.*.import | tee $temp_imp
214 # Check if client uuid is found in MGS export
215 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
216 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
220 # save mgs export file to $temp_exp
221 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
223 # Compare the value of field "connect_flags"
224 imp_val=$(grep "connect_flags" $temp_imp)
225 exp_val=$(grep "connect_flags" $temp_exp)
226 [ "$exp_val" == "$imp_val" ] ||
227 error "export flags '$exp_val' != import flags '$imp_val'"
229 # Compare client versions. Only compare top-3 fields for compatibility
230 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
231 exp_val=$(version_code $(cut -d. -f1,2,3 <<<$exp_client_version))
232 imp_val=$(version_code $(lustre_build_version client | cut -d. -f1,2,3))
233 [ "$exp_val" == "$imp_val" ] ||
234 error "exp version '$exp_client_version'($exp_val) != " \
235 "'$(lustre_build_version client)'($imp_val)"
237 run_test 0d "check export proc ============================="
239 test_0e() { # LU-13417
240 (( $MDSCOUNT > 1 )) ||
241 skip "We need at least 2 MDTs for this test"
243 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
244 skip "Need server version at least 2.14.51"
246 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
247 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
249 [ $default_lmv_count -eq 1 ] ||
250 error "$MOUNT default stripe count $default_lmv_count"
252 [ $default_lmv_index -eq -1 ] ||
253 error "$MOUNT default stripe index $default_lmv_index"
255 mkdir $MOUNT/$tdir.1 || error "mkdir $MOUNT/$tdir.1 failed"
256 mkdir $MOUNT/$tdir.2 || error "mkdir $MOUNT/$tdir.2 failed"
258 local mdt_index1=$($LFS getdirstripe -i $MOUNT/$tdir.1)
259 local mdt_index2=$($LFS getdirstripe -i $MOUNT/$tdir.2)
261 [ $mdt_index1 -eq $mdt_index2 ] &&
262 error "directories are on the same MDT $mdt_index1=$mdt_index2"
264 rmdir $MOUNT/$tdir.1 $MOUNT/$tdir.2
266 run_test 0e "Enable DNE MDT balancing for mkdir in the ROOT"
269 test_mkdir $DIR/$tdir
270 test_mkdir $DIR/$tdir/d2
271 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
272 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
275 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
277 run_test 1 "mkdir; remkdir; rmdir"
280 test_mkdir $DIR/$tdir
281 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
282 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
284 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
286 run_test 2 "mkdir; touch; rmdir; check file"
289 test_mkdir $DIR/$tdir
290 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
291 touch $DIR/$tdir/$tfile
292 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
294 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
296 run_test 3 "mkdir; touch; rmdir; check dir"
298 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
300 test_mkdir -i 1 $DIR/$tdir
302 touch $DIR/$tdir/$tfile ||
303 error "Create file under remote directory failed"
306 error "Expect error removing in-use dir $DIR/$tdir"
308 test -d $DIR/$tdir || error "Remote directory disappeared"
310 rm -rf $DIR/$tdir || error "remove remote dir error"
312 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
315 test_mkdir $DIR/$tdir
316 test_mkdir $DIR/$tdir/d2
317 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
318 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
319 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
321 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
324 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
325 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
326 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
327 error "$tfile does not have perm 0666 or UID $UID"
328 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
329 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
330 error "$tfile should be 0666 and owned by UID $UID"
332 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
335 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
338 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
339 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
340 error "$tfile should be owned by UID $RUNAS_ID"
341 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
342 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
343 error "$tfile should be owned by UID $RUNAS_ID"
345 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
348 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
351 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
352 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
353 error "$tfile should be owned by GID $UID"
354 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
355 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
356 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
358 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
361 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
363 test_mkdir $DIR/$tdir
364 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
365 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
366 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
367 test_mkdir $DIR/$tdir/d/subdir
368 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
369 error "$tdir/d/subdir should be GID $RUNAS_GID"
370 if [[ $MDSCOUNT -gt 1 ]]; then
371 # check remote dir sgid inherite
372 $LFS mkdir -i 0 $DIR/$tdir.local ||
373 error "mkdir $tdir.local failed"
374 chmod g+s $DIR/$tdir.local ||
375 error "chmod $tdir.local failed"
376 chgrp $RUNAS_GID $DIR/$tdir.local ||
377 error "chgrp $tdir.local failed"
378 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
379 error "mkdir $tdir.remote failed"
380 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
381 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
382 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
383 error "$tdir.remote should be mode 02755"
386 run_test 6g "verify new dir in sgid dir inherits group"
388 test_6h() { # bug 7331
389 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
391 touch $DIR/$tfile || error "touch failed"
392 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
393 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
394 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
395 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
396 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
398 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
401 test_mkdir $DIR/$tdir
402 $MCREATE $DIR/$tdir/$tfile
403 chmod 0666 $DIR/$tdir/$tfile
404 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
405 error "$tdir/$tfile should be mode 0666"
407 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
410 if [ ! -d $DIR/$tdir ]; then
411 test_mkdir $DIR/$tdir
413 $MCREATE $DIR/$tdir/$tfile
414 echo -n foo > $DIR/$tdir/$tfile
415 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
416 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
418 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
421 test_mkdir $DIR/$tdir
422 touch $DIR/$tdir/$tfile
423 chmod 0666 $DIR/$tdir/$tfile
424 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
425 error "$tfile mode not 0666"
427 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
430 test_mkdir $DIR/$tdir
431 test_mkdir $DIR/$tdir/d2
432 test_mkdir $DIR/$tdir/d2/d3
433 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
435 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
438 test_mkdir $DIR/$tdir
439 test_mkdir $DIR/$tdir/d2
440 touch $DIR/$tdir/d2/$tfile
441 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
442 error "$tdir/d2/$tfile not a file"
444 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
447 test_mkdir $DIR/$tdir
448 test_mkdir $DIR/$tdir/d2
449 chmod 0666 $DIR/$tdir/d2
450 chmod 0705 $DIR/$tdir/d2
451 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
452 error "$tdir/d2 mode not 0705"
454 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
457 test_mkdir $DIR/$tdir
458 touch $DIR/$tdir/$tfile
459 chmod 0666 $DIR/$tdir/$tfile
460 chmod 0654 $DIR/$tdir/$tfile
461 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
462 error "$tdir/d2 mode not 0654"
464 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
467 test_mkdir $DIR/$tdir
468 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
470 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
471 error "$tdir/$tfile size not 0 after truncate"
473 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
476 test_mkdir $DIR/$tdir
477 touch $DIR/$tdir/$tfile
479 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
481 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
484 test_mkdir $DIR/$tdir
485 touch $DIR/$tdir/$tfile
486 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
487 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
488 error "$tdir/${tfile_2} not a file after rename"
489 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
491 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
494 test_mkdir $DIR/$tdir
495 touch $DIR/$tdir/$tfile
496 rm -rf $DIR/$tdir/$tfile
497 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
499 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
502 test_mkdir $DIR/$tdir
503 touch $DIR/$tdir/$tfile
504 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
506 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
507 error "$tdir/l-exist not a symlink"
508 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
509 error "$tdir/l-exist not referencing a file"
510 rm -f $DIR/$tdir/l-exist
511 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
513 run_test 17a "symlinks: create, remove (real)"
516 test_mkdir $DIR/$tdir
517 ln -s no-such-file $DIR/$tdir/l-dangle
519 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
520 error "$tdir/l-dangle not referencing no-such-file"
521 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
522 error "$tdir/l-dangle not referencing non-existent file"
523 rm -f $DIR/$tdir/l-dangle
524 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
526 run_test 17b "symlinks: create, remove (dangling)"
528 test_17c() { # bug 3440 - don't save failed open RPC for replay
529 test_mkdir $DIR/$tdir
530 ln -s foo $DIR/$tdir/$tfile
531 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
533 run_test 17c "symlinks: open dangling (should return error)"
536 test_mkdir $DIR/$tdir
537 ln -s foo $DIR/$tdir/$tfile
538 touch $DIR/$tdir/$tfile || error "creating to new symlink"
540 run_test 17d "symlinks: create dangling"
543 test_mkdir $DIR/$tdir
544 local foo=$DIR/$tdir/$tfile
545 ln -s $foo $foo || error "create symlink failed"
546 ls -l $foo || error "ls -l failed"
547 ls $foo && error "ls not failed" || true
549 run_test 17e "symlinks: create recursive symlink (should return error)"
552 test_mkdir $DIR/$tdir
553 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
554 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
555 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
556 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
557 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
558 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
561 run_test 17f "symlinks: long and very long symlink name"
563 # str_repeat(S, N) generate a string that is string S repeated N times
568 while [ $((n -= 1)) -ge 0 ]; do
574 # Long symlinks and LU-2241
576 test_mkdir $DIR/$tdir
577 local TESTS="59 60 61 4094 4095"
579 # Fix for inode size boundary in 2.1.4
580 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
583 # Patch not applied to 2.2 or 2.3 branches
584 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
585 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
589 local SYMNAME=$(str_repeat 'x' $i)
590 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
591 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
594 run_test 17g "symlinks: really long symlink name and inode boundaries"
596 test_17h() { #bug 17378
597 [ $PARALLEL == "yes" ] && skip "skip parallel run"
598 remote_mds_nodsh && skip "remote MDS with nodsh"
602 test_mkdir $DIR/$tdir
603 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
604 $LFS setstripe -c -1 $DIR/$tdir
605 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
606 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
607 touch $DIR/$tdir/$tfile || true
609 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
611 test_17i() { #bug 20018
612 [ $PARALLEL == "yes" ] && skip "skip parallel run"
613 remote_mds_nodsh && skip "remote MDS with nodsh"
615 local foo=$DIR/$tdir/$tfile
618 test_mkdir -c1 $DIR/$tdir
619 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
620 ln -s $foo $foo || error "create symlink failed"
621 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
622 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
623 ls -l $foo && error "error not detected"
626 run_test 17i "don't panic on short symlink (should return error)"
628 test_17k() { #bug 22301
629 [ $PARALLEL == "yes" ] && skip "skip parallel run"
630 [[ -z "$(which rsync 2>/dev/null)" ]] &&
631 skip "no rsync command"
632 rsync --help | grep -q xattr ||
633 skip_env "$(rsync --version | head -n1) does not support xattrs"
634 test_mkdir $DIR/$tdir
635 test_mkdir $DIR/$tdir.new
636 touch $DIR/$tdir/$tfile
637 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
638 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
639 error "rsync failed with xattrs enabled"
641 run_test 17k "symlinks: rsync with xattrs enabled"
643 test_17l() { # LU-279
644 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
645 skip "no getfattr command"
647 test_mkdir $DIR/$tdir
648 touch $DIR/$tdir/$tfile
649 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
650 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
651 # -h to not follow symlinks. -m '' to list all the xattrs.
652 # grep to remove first line: '# file: $path'.
653 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
655 lgetxattr_size_check $path $xattr ||
656 error "lgetxattr_size_check $path $xattr failed"
660 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
664 [ $PARALLEL == "yes" ] && skip "skip parallel run"
665 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
666 remote_mds_nodsh && skip "remote MDS with nodsh"
667 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
668 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
669 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
671 local short_sym="0123456789"
672 local wdir=$DIR/$tdir
677 # create a long symlink file
678 for ((i = 0; i < 4; ++i)); do
679 long_sym=${long_sym}${long_sym}
682 echo "create 512 short and long symlink files under $wdir"
683 for ((i = 0; i < 256; ++i)); do
684 ln -sf ${long_sym}"a5a5" $wdir/long-$i
685 ln -sf ${short_sym}"a5a5" $wdir/short-$i
691 wait_delete_completed
693 echo "recreate the 512 symlink files with a shorter string"
694 for ((i = 0; i < 512; ++i)); do
695 # rewrite the symlink file with a shorter string
696 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
697 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
700 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
702 echo "stop and checking mds${mds_index}:"
703 # e2fsck should not return error
705 local devname=$(mdsdevname $mds_index)
706 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
709 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
710 error "start mds${mds_index} failed"
711 df $MOUNT > /dev/null 2>&1
713 error "e2fsck detected error for short/long symlink: rc=$rc"
716 run_test 17m "run e2fsck against MDT which contains short/long symlink"
718 check_fs_consistency_17n() {
722 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
723 # so it only check MDT1/MDT2 instead of all of MDTs.
724 for mdt_index in 1 2; do
725 # e2fsck should not return error
727 local devname=$(mdsdevname $mdt_index)
728 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
731 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
732 error "mount mds$mdt_index failed"
733 df $MOUNT > /dev/null 2>&1
739 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
740 [ $PARALLEL == "yes" ] && skip "skip parallel run"
741 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
742 remote_mds_nodsh && skip "remote MDS with nodsh"
743 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
744 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
745 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
749 test_mkdir $DIR/$tdir
750 for ((i=0; i<10; i++)); do
751 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
752 error "create remote dir error $i"
753 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
754 error "create files under remote dir failed $i"
757 check_fs_consistency_17n ||
758 error "e2fsck report error after create files under remote dir"
760 for ((i = 0; i < 10; i++)); do
761 rm -rf $DIR/$tdir/remote_dir_${i} ||
762 error "destroy remote dir error $i"
765 check_fs_consistency_17n ||
766 error "e2fsck report error after unlink files under remote dir"
768 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
769 skip "lustre < 2.4.50 does not support migrate mv"
771 for ((i = 0; i < 10; i++)); do
772 mkdir -p $DIR/$tdir/remote_dir_${i}
773 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
774 error "create files under remote dir failed $i"
775 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
776 error "migrate remote dir error $i"
778 check_fs_consistency_17n || error "e2fsck report error after migration"
780 for ((i = 0; i < 10; i++)); do
781 rm -rf $DIR/$tdir/remote_dir_${i} ||
782 error "destroy remote dir error $i"
785 check_fs_consistency_17n || error "e2fsck report error after unlink"
787 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
790 remote_mds_nodsh && skip "remote MDS with nodsh"
791 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
792 skip "Need MDS version at least 2.3.64"
794 local wdir=$DIR/${tdir}o
800 mdt_index=$($LFS getstripe -m $wdir/$tfile)
801 mdt_index=$((mdt_index + 1))
804 #fail mds will wait the failover finish then set
805 #following fail_loc to avoid interfer the recovery process.
808 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
809 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
810 ls -l $wdir/$tfile && rc=1
811 do_facet mds${mdt_index} lctl set_param fail_loc=0
812 [[ $rc -eq 0 ]] || error "stat file should fail"
814 run_test 17o "stat file with incompat LMA feature"
817 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
818 ls $DIR || error "Failed to ls $DIR: $?"
820 run_test 18 "touch .../f ; ls ... =============================="
826 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
828 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
831 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
833 run_test 19b "ls -l .../f19 (should return error) =============="
836 [ $RUNAS_ID -eq $UID ] &&
837 skip_env "RUNAS_ID = UID = $UID -- skipping"
839 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
841 run_test 19c "$RUNAS touch .../f19 (should return error) =="
844 cat $DIR/f19 && error || true
846 run_test 19d "cat .../f19 (should return error) =============="
855 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
857 run_test 20 "touch .../f ; ls -l ..."
860 test_mkdir $DIR/$tdir
861 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
862 ln -s dangle $DIR/$tdir/link
863 echo foo >> $DIR/$tdir/link
864 cat $DIR/$tdir/dangle
865 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
866 $CHECKSTAT -f -t file $DIR/$tdir/link ||
867 error "$tdir/link not linked to a file"
869 run_test 21 "write to dangling link"
872 local wdir=$DIR/$tdir
874 chown $RUNAS_ID:$RUNAS_GID $wdir
875 (cd $wdir || error "cd $wdir failed";
876 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
878 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
879 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
880 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
881 error "checkstat -u failed"
883 run_test 22 "unpack tar archive as non-root user"
887 test_mkdir $DIR/$tdir
888 local file=$DIR/$tdir/$tfile
890 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
891 openfile -f O_CREAT:O_EXCL $file &&
892 error "$file recreate succeeded" || true
894 run_test 23a "O_CREAT|O_EXCL in subdir"
896 test_23b() { # bug 18988
897 test_mkdir $DIR/$tdir
898 local file=$DIR/$tdir/$tfile
901 echo foo > $file || error "write filed"
902 echo bar >> $file || error "append filed"
903 $CHECKSTAT -s 8 $file || error "wrong size"
906 run_test 23b "O_APPEND check"
908 # LU-9409, size with O_APPEND and tiny writes
910 local file=$DIR/$tfile
913 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
914 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
918 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
919 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
921 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
924 #racing tiny & normal writes
925 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
926 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
928 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
931 #racing tiny & normal writes 2, ugly numbers
932 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
933 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
935 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
938 run_test 23c "O_APPEND size checks for tiny writes"
940 # LU-11069 file offset is correct after appending writes
942 local file=$DIR/$tfile
945 echo CentaurHauls > $file
946 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
947 if ((offset != 26)); then
948 error "wrong offset, expected 26, got '$offset'"
951 run_test 23d "file offset is correct after appending writes"
955 echo '-- same directory rename'
956 test_mkdir $DIR/$tdir
957 touch $DIR/$tdir/$tfile.1
958 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
959 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
961 run_test 24a "rename file to non-existent target"
964 test_mkdir $DIR/$tdir
965 touch $DIR/$tdir/$tfile.{1,2}
966 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
967 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
968 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
970 run_test 24b "rename file to existing target"
973 test_mkdir $DIR/$tdir
974 test_mkdir $DIR/$tdir/d$testnum.1
975 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
976 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
977 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
979 run_test 24c "rename directory to non-existent target"
982 test_mkdir -c1 $DIR/$tdir
983 test_mkdir -c1 $DIR/$tdir/d$testnum.1
984 test_mkdir -c1 $DIR/$tdir/d$testnum.2
985 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
986 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
987 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
989 run_test 24d "rename directory to existing target"
992 echo '-- cross directory renames --'
996 mv $DIR/R5a/f $DIR/R5b/g
997 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
998 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
1000 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
1005 touch $DIR/R6a/f $DIR/R6b/g
1006 mv $DIR/R6a/f $DIR/R6b/g
1007 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
1008 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
1010 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
1015 test_mkdir $DIR/R7a/d
1016 mv $DIR/R7a/d $DIR/R7b/e
1017 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
1018 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
1020 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1023 test_mkdir -c1 $DIR/R8a
1024 test_mkdir -c1 $DIR/R8b
1025 test_mkdir -c1 $DIR/R8a/d
1026 test_mkdir -c1 $DIR/R8b/e
1027 mrename $DIR/R8a/d $DIR/R8b/e
1028 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1029 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1031 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1034 echo "-- rename error cases"
1036 test_mkdir $DIR/R9/a
1038 mrename $DIR/R9/f $DIR/R9/a
1039 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1040 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1041 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1043 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1047 mrename $DIR/R10/f $DIR/R10/g
1048 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1049 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1050 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1052 run_test 24j "source does not exist ============================"
1055 test_mkdir $DIR/R11a
1056 test_mkdir $DIR/R11a/d
1058 mv $DIR/R11a/f $DIR/R11a/d
1059 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1060 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1062 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1064 # bug 2429 - rename foo foo foo creates invalid file
1067 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1069 run_test 24l "Renaming a file to itself ========================"
1073 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1074 # on ext3 this does not remove either the source or target files
1075 # though the "expected" operation would be to remove the source
1076 $CHECKSTAT -t file ${f} || error "${f} missing"
1077 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1079 run_test 24m "Renaming a file to a hard link to itself ========="
1083 # this stats the old file after it was renamed, so it should fail
1085 $CHECKSTAT ${f} || error "${f} missing"
1087 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1088 $CHECKSTAT -a ${f} || error "${f} exists"
1090 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1093 test_mkdir $DIR/$tdir
1094 rename_many -s random -v -n 10 $DIR/$tdir
1096 run_test 24o "rename of files during htree split"
1099 test_mkdir $DIR/R12a
1100 test_mkdir $DIR/R12b
1101 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1102 mrename $DIR/R12a $DIR/R12b
1103 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1104 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1105 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1106 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1108 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1110 cleanup_multiop_pause() {
1112 kill -USR1 $MULTIPID
1116 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1118 test_mkdir $DIR/R13a
1119 test_mkdir $DIR/R13b
1120 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1121 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1124 trap cleanup_multiop_pause EXIT
1125 mrename $DIR/R13a $DIR/R13b
1126 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1127 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1128 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1129 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1130 cleanup_multiop_pause
1131 wait $MULTIPID || error "multiop close failed"
1133 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1135 test_24r() { #bug 3789
1136 test_mkdir $DIR/R14a
1137 test_mkdir $DIR/R14a/b
1138 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1139 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1140 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1142 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1145 test_mkdir $DIR/R15a
1146 test_mkdir $DIR/R15a/b
1147 test_mkdir $DIR/R15a/b/c
1148 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1149 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1150 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1152 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1155 test_mkdir $DIR/R16a
1156 test_mkdir $DIR/R16a/b
1157 test_mkdir $DIR/R16a/b/c
1158 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1159 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1160 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1162 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1164 test_24u() { # bug12192
1165 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1166 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1168 run_test 24u "create stripe file"
1170 simple_cleanup_common() {
1174 [[ -z "$DIR" || -z "$tdir" || ! -d "$DIR/$tdir" ]] && return 0
1176 local start=$SECONDS
1178 [[ -n "$createmany" ]] && unlinkmany $DIR/$tdir/$tfile $createmany
1179 rm -rf $DIR/$tdir || error "cleanup $DIR/$tdir failed"
1181 wait_delete_completed
1182 echo "cleanup time $((SECONDS - start))"
1186 max_pages_per_rpc() {
1187 local mdtname="$(printf "MDT%04x" ${1:-0})"
1188 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1192 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1194 local nrfiles=${COUNT:-100000}
1195 local fname="$DIR/$tdir/$tfile"
1197 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1198 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1200 test_mkdir "$(dirname $fname)"
1201 # assume MDT0000 has the fewest inodes
1202 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1203 local free_inodes=$(($(mdt_free_inodes 0) * ${stripes/#0/1}))
1204 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1206 stack_trap "simple_cleanup_common $nrfiles"
1208 createmany -m "$fname" $nrfiles
1210 cancel_lru_locks mdc
1211 lctl set_param mdc.*.stats clear
1213 # was previously test_24D: LU-6101
1214 # readdir() returns correct number of entries after cursor reload
1215 local num_ls=$(ls $DIR/$tdir | wc -l)
1216 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1217 local num_all=$(ls -a $DIR/$tdir | wc -l)
1218 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1219 [ $num_all -ne $((nrfiles + 2)) ]; then
1220 error "Expected $nrfiles files, got $num_ls " \
1221 "($num_uniq unique $num_all .&..)"
1223 # LU-5 large readdir
1224 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1225 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1226 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1227 # take into account of overhead in lu_dirpage header and end mark in
1228 # each page, plus one in rpc_num calculation.
1229 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1230 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1231 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1232 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1233 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1234 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1235 echo "readpages: $mds_readpage rpc_max: $rpc_max-2/+1"
1236 (( $mds_readpage >= $rpc_max - 2 && $mds_readpage <= $rpc_max + 1)) ||
1237 error "large readdir doesn't take effect: " \
1238 "$mds_readpage should be about $rpc_max"
1240 run_test 24v "list large directory (test hash collision, b=17560)"
1242 test_24w() { # bug21506
1244 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1245 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1246 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1247 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1248 [[ "$SZ1" -eq "$SZ2" ]] ||
1249 error "Error reading at the end of the file $tfile"
1251 run_test 24w "Reading a file larger than 4Gb"
1254 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1255 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1256 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1257 skip "Need MDS version at least 2.7.56"
1260 local remote_dir=$DIR/$tdir/remote_dir
1262 test_mkdir $DIR/$tdir
1263 $LFS mkdir -i $MDTIDX $remote_dir ||
1264 error "create remote directory failed"
1266 test_mkdir $DIR/$tdir/src_dir
1267 touch $DIR/$tdir/src_file
1268 test_mkdir $remote_dir/tgt_dir
1269 touch $remote_dir/tgt_file
1271 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1272 error "rename dir cross MDT failed!"
1274 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1275 error "rename file cross MDT failed!"
1277 touch $DIR/$tdir/ln_file
1278 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1279 error "ln file cross MDT failed"
1281 rm -rf $DIR/$tdir || error "Can not delete directories"
1283 run_test 24x "cross MDT rename/link"
1286 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1287 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1289 local remote_dir=$DIR/$tdir/remote_dir
1292 test_mkdir $DIR/$tdir
1293 $LFS mkdir -i $mdtidx $remote_dir ||
1294 error "create remote directory failed"
1296 test_mkdir $remote_dir/src_dir
1297 touch $remote_dir/src_file
1298 test_mkdir $remote_dir/tgt_dir
1299 touch $remote_dir/tgt_file
1301 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1302 error "rename subdir in the same remote dir failed!"
1304 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1305 error "rename files in the same remote dir failed!"
1307 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1308 error "link files in the same remote dir failed!"
1310 rm -rf $DIR/$tdir || error "Can not delete directories"
1312 run_test 24y "rename/link on the same dir should succeed"
1315 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1316 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1317 skip "Need MDS version at least 2.12.51"
1321 for index in 0 1; do
1322 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1323 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1326 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1328 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1329 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1331 local mdts=$(comma_list $(mdts_nodes))
1333 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1334 stack_trap "do_nodes $mdts $LCTL \
1335 set_param mdt.*.enable_remote_rename=1" EXIT
1337 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1339 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1340 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1342 run_test 24z "cross-MDT rename is done as cp"
1344 test_24A() { # LU-3182
1347 test_mkdir $DIR/$tdir
1348 stack_trap "simple_cleanup_common $NFILES"
1349 createmany -m $DIR/$tdir/$tfile $NFILES
1350 local t=$(ls $DIR/$tdir | wc -l)
1351 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1352 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1354 (( $t == $NFILES && $u == $NFILES && $v == NFILES + 2 )) ||
1355 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1357 run_test 24A "readdir() returns correct number of entries."
1359 test_24B() { # LU-4805
1360 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1364 test_mkdir $DIR/$tdir
1365 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir/ ||
1366 error "create striped dir failed"
1368 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1369 [ $count -eq 2 ] || error "Expected 2, got $count"
1371 touch $DIR/$tdir/striped_dir/a
1373 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1374 [ $count -eq 3 ] || error "Expected 3, got $count"
1376 touch $DIR/$tdir/striped_dir/.f
1378 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1379 [ $count -eq 4 ] || error "Expected 4, got $count"
1381 rm -rf $DIR/$tdir || error "Can not delete directories"
1383 run_test 24B "readdir for striped dir return correct number of entries"
1386 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1392 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1393 error "create striped dir failed"
1395 cd $DIR/$tdir/d0/striped_dir
1397 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1398 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1399 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1401 [ "$d0_ino" = "$parent_ino" ] ||
1402 error ".. wrong, expect $d0_ino, get $parent_ino"
1404 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1405 error "mv striped dir failed"
1407 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1409 [ "$d1_ino" = "$parent_ino" ] ||
1410 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1412 run_test 24C "check .. in striped dir"
1415 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1416 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1419 mkdir $DIR/$tdir/src_dir
1420 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1421 error "create remote source failed"
1423 touch $DIR/$tdir/src_dir/src_child/a
1425 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1426 error "create remote target dir failed"
1428 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1429 error "create remote target child failed"
1431 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1432 error "rename dir cross MDT failed!"
1436 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1437 error "src_child still exists after rename"
1439 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1440 error "missing file(a) after rename"
1442 rm -rf $DIR/$tdir || error "Can not delete directories"
1444 run_test 24E "cross MDT rename/link"
1447 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1450 [ "$SLOW" = "no" ] && repeats=100
1454 echo "$repeats repeats"
1455 for ((i = 0; i < repeats; i++)); do
1456 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1457 touch $DIR/$tdir/test/a || error "touch fails"
1458 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1459 rm -rf $DIR/$tdir/test || error "rmdir fails"
1464 run_test 24F "hash order vs readdir (LU-11330)"
1467 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1472 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1473 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1474 touch $DIR/$tdir-0/f1 || error "touch f1"
1475 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1476 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1477 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1478 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1479 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1481 run_test 24G "migrate symlink in rename"
1484 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1485 [[ $(hostname) != $(facet_active_host mds2) ]] ||
1486 skip "MDT1 should be on another node"
1488 test_mkdir -i 1 -c 1 $DIR/$tdir
1489 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
1490 do_facet mds2 $LCTL set_param fail_loc=0x80001103
1491 touch $DIR/$tdir/$tfile || error "touch failed"
1493 run_test 24H "repeat FLD_QUERY rpc"
1496 echo '== symlink sanity ============================================='
1500 touch $DIR/s25/foo ||
1501 error "File creation in symlinked directory failed"
1503 run_test 25a "create file in symlinked directory ==============="
1506 [ ! -d $DIR/d25 ] && test_25a
1507 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1509 run_test 25b "lookup file in symlinked directory ==============="
1513 test_mkdir $DIR/d26/d26-2
1514 ln -s d26/d26-2 $DIR/s26
1515 touch $DIR/s26/foo || error "File creation failed"
1517 run_test 26a "multiple component symlink ======================="
1520 test_mkdir -p $DIR/$tdir/d26-2
1521 ln -s $tdir/d26-2/foo $DIR/s26-2
1522 touch $DIR/s26-2 || error "File creation failed"
1524 run_test 26b "multiple component symlink at end of lookup ======"
1527 test_mkdir $DIR/d26.2
1528 touch $DIR/d26.2/foo
1529 ln -s d26.2 $DIR/s26.2-1
1530 ln -s s26.2-1 $DIR/s26.2-2
1531 ln -s s26.2-2 $DIR/s26.2-3
1532 chmod 0666 $DIR/s26.2-3/foo
1534 run_test 26c "chain of symlinks"
1536 # recursive symlinks (bug 439)
1538 ln -s d26-3/foo $DIR/d26-3
1540 run_test 26d "create multiple component recursive symlink"
1543 [ ! -h $DIR/d26-3 ] && test_26d
1546 run_test 26e "unlink multiple component recursive symlink"
1548 # recursive symlinks (bug 7022)
1550 test_mkdir $DIR/$tdir
1551 test_mkdir $DIR/$tdir/$tfile
1552 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1553 test_mkdir -p lndir/bar1
1554 test_mkdir $DIR/$tdir/$tfile/$tfile
1555 cd $tfile || error "cd $tfile failed"
1556 ln -s .. dotdot || error "ln dotdot failed"
1557 ln -s dotdot/lndir lndir || error "ln lndir failed"
1558 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1559 output=`ls $tfile/$tfile/lndir/bar1`
1560 [ "$output" = bar1 ] && error "unexpected output"
1561 rm -r $tfile || error "rm $tfile failed"
1562 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1564 run_test 26f "rm -r of a directory which has recursive symlink"
1567 test_mkdir $DIR/$tdir
1568 $LFS getstripe $DIR/$tdir
1569 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1570 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1571 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1573 run_test 27a "one stripe file"
1576 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1578 test_mkdir $DIR/$tdir
1579 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1580 $LFS getstripe -c $DIR/$tdir/$tfile
1581 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1582 error "two-stripe file doesn't have two stripes"
1584 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1586 run_test 27b "create and write to two stripe file"
1588 # 27c family tests specific striping, setstripe -o
1590 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1591 test_mkdir -p $DIR/$tdir
1594 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1595 $LFS getstripe -i $DIR/$tdir/$tfile
1596 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1597 error "stripe not on specified OST"
1599 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1601 run_test 27ca "one stripe on specified OST"
1604 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1605 test_mkdir -p $DIR/$tdir
1607 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1608 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1611 # Strip getstripe output to a space separated list of OSTs
1612 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1613 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1614 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1615 error "stripes not on specified OSTs"
1617 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1619 run_test 27cb "two stripes on specified OSTs"
1622 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1623 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1624 skip "server does not support overstriping"
1626 test_mkdir -p $DIR/$tdir
1628 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1629 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1632 # Strip getstripe output to a space separated list of OSTs
1633 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1634 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1635 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1636 error "stripes not on specified OSTs"
1638 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1640 run_test 27cc "two stripes on the same OST"
1643 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1644 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1645 skip "server does not support overstriping"
1646 test_mkdir -p $DIR/$tdir
1647 local osts="0,1,1,0"
1648 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1649 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1652 # Strip getstripe output to a space separated list of OSTs
1653 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1654 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1655 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1656 error "stripes not on specified OSTs"
1658 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1660 run_test 27cd "four stripes on two OSTs"
1663 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1664 skip_env "too many osts, skipping"
1665 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1666 skip "server does not support overstriping"
1667 # We do one more stripe than we have OSTs
1668 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1669 skip_env "ea_inode feature disabled"
1671 test_mkdir -p $DIR/$tdir
1673 for i in $(seq 0 $OSTCOUNT);
1676 if [ $i -ne $OSTCOUNT ]; then
1680 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1681 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1684 # Strip getstripe output to a space separated list of OSTs
1685 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1686 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1687 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1688 error "stripes not on specified OSTs"
1690 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1692 run_test 27ce "more stripes than OSTs with -o"
1695 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1698 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1699 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1700 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1701 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1702 error "failed to set $osp_proc=0"
1704 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1707 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1708 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1709 error "failed to set $osp_proc=1"
1712 error "should return error due to $osp_proc=0"
1714 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1717 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1718 skip "server does not support overstriping"
1719 [[ $mds1_FSTYPE != "ldiskfs" ]] && skip_env "ldiskfs only test"
1720 large_xattr_enabled || skip_env "ea_inode feature disabled"
1724 for ((i=1;i<1000;i++)); do
1725 osts+=",$((i % OSTCOUNT))"
1728 local mdts=$(comma_list $(mdts_nodes))
1729 local before=$(do_nodes $mdts \
1730 "$LCTL get_param -n osd-ldiskfs.*MDT*.stats" |
1731 awk '/many credits/{print $3}' |
1734 $LFS setstripe -o $osts $DIR/$tfile || error "setstripe failed"
1735 $LFS getstripe $DIR/$tfile | grep stripe
1737 rm -f $DIR/$tfile || error "can't unlink"
1739 after=$(do_nodes $mdts \
1740 "$LCTL get_param -n osd-ldiskfs.*MDT*.stats" |
1741 awk '/many credits/{print $3}' |
1744 (( before == after )) ||
1745 error "too many credits happened: $after > $before"
1747 run_test 27cg "1000 shouldn't cause too many credits"
1750 test_mkdir $DIR/$tdir
1751 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1752 error "setstripe failed"
1753 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1754 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1756 run_test 27d "create file with default settings"
1759 # LU-5839 adds check for existed layout before setting it
1760 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1761 skip "Need MDS version at least 2.7.56"
1763 test_mkdir $DIR/$tdir
1764 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1765 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1766 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1768 run_test 27e "setstripe existing file (should return error)"
1771 test_mkdir $DIR/$tdir
1772 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1773 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1774 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1775 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1776 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1777 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1779 run_test 27f "setstripe with bad stripe size (should return error)"
1782 test_mkdir $DIR/$tdir
1783 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1784 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1785 error "$DIR/$tdir/$tfile has object"
1787 run_test 27g "$LFS getstripe with no objects"
1790 test_mkdir $DIR/$tdir
1791 touch $DIR/$tdir/$tfile || error "touch failed"
1792 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1793 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1795 (( rc == 2 )) || error "getstripe did not return ENOENT"
1797 run_test 27ga "$LFS getstripe with missing file (should return error)"
1800 test_mkdir $DIR/$tdir
1801 touch $DIR/$tdir/$tfile || error "touch failed"
1802 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1803 error "missing objects"
1805 run_test 27i "$LFS getstripe with some objects"
1808 test_mkdir $DIR/$tdir
1809 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1810 error "setstripe failed" || true
1812 run_test 27j "setstripe with bad stripe offset (should return error)"
1814 test_27k() { # bug 2844
1815 test_mkdir $DIR/$tdir
1816 local file=$DIR/$tdir/$tfile
1817 local ll_max_blksize=$((4 * 1024 * 1024))
1818 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1819 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1820 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1821 dd if=/dev/zero of=$file bs=4k count=1
1822 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1823 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1825 run_test 27k "limit i_blksize for broken user apps"
1828 mcreate $DIR/$tfile || error "creating file"
1829 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1830 error "setstripe should have failed" || true
1832 run_test 27l "check setstripe permissions (should return error)"
1835 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1837 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1838 skip_env "multiple clients -- skipping"
1840 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1842 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1843 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1845 stack_trap simple_cleanup_common
1846 test_mkdir $DIR/$tdir
1847 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1848 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1849 error "dd should fill OST0"
1851 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1853 [ $i -gt 256 ] && break
1856 touch $DIR/$tdir/$tfile.$i
1857 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1858 awk '{print $1}'| grep -w "0") ] &&
1859 error "OST0 was full but new created file still use it"
1861 touch $DIR/$tdir/$tfile.$i
1862 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1863 awk '{print $1}'| grep -w "0") ] &&
1864 error "OST0 was full but new created file still use it" || true
1866 run_test 27m "create file while OST0 was full"
1868 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1869 # if the OST isn't full anymore.
1871 local ostidx=${1:-""}
1876 local list=$(comma_list $(osts_nodes))
1877 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1879 do_nodes $list lctl set_param fail_loc=0
1880 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1881 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1882 awk '{print $1 * 2;exit;}')
1883 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1885 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1889 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1890 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1891 remote_mds_nodsh && skip "remote MDS with nodsh"
1892 remote_ost_nodsh && skip "remote OST with nodsh"
1895 rm -f $DIR/$tdir/$tfile
1896 exhaust_precreations 0 0x80000215
1897 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1898 touch $DIR/$tdir/$tfile || error "touch failed"
1899 $LFS getstripe $DIR/$tdir/$tfile
1902 run_test 27n "create file with some full OSTs"
1905 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1906 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1907 remote_mds_nodsh && skip "remote MDS with nodsh"
1908 remote_ost_nodsh && skip "remote OST with nodsh"
1911 rm -f $DIR/$tdir/$tfile
1912 exhaust_all_precreations 0x215
1914 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1919 run_test 27o "create file with all full OSTs (should error)"
1921 function create_and_checktime() {
1926 for ((i=0; i < $loops; i++)); do
1927 local start=$SECONDS
1928 multiop $fname-$i Oc
1929 ((SECONDS-start < TIMEOUT)) ||
1930 error "creation took " $((SECONDS-$start)) && return 1
1935 local mdts=$(comma_list $(mdts_nodes))
1937 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1938 skip "Need MDS version at least 2.13.57"
1940 local f0=$DIR/${tfile}-0
1941 local f1=$DIR/${tfile}-1
1943 wait_delete_completed
1945 # refill precreated objects
1946 $LFS setstripe -i0 -c1 $f0
1948 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1949 # force QoS allocation policy
1950 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1951 stack_trap "do_nodes $mdts $LCTL set_param \
1952 lov.*.qos_threshold_rr=$saved" EXIT
1955 # one OST is unavailable, but still have few objects preallocated
1957 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1958 rm -rf $f1 $DIR/$tdir*" EXIT
1960 for ((i=0; i < 7; i++)); do
1961 mkdir $DIR/$tdir$i || error "can't create dir"
1962 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1963 error "can't set striping"
1965 for ((i=0; i < 7; i++)); do
1966 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1970 run_test 27oo "don't let few threads to reserve too many objects"
1973 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1974 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1975 remote_mds_nodsh && skip "remote MDS with nodsh"
1976 remote_ost_nodsh && skip "remote OST with nodsh"
1979 rm -f $DIR/$tdir/$tfile
1980 test_mkdir $DIR/$tdir
1982 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1983 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1984 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1986 exhaust_precreations 0 0x80000215
1987 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1988 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1989 $LFS getstripe $DIR/$tdir/$tfile
1993 run_test 27p "append to a truncated file with some full OSTs"
1996 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1997 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1998 remote_mds_nodsh && skip "remote MDS with nodsh"
1999 remote_ost_nodsh && skip "remote OST with nodsh"
2002 rm -f $DIR/$tdir/$tfile
2004 mkdir_on_mdt0 $DIR/$tdir
2005 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
2006 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
2007 error "truncate $DIR/$tdir/$tfile failed"
2008 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
2010 exhaust_all_precreations 0x215
2012 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
2013 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
2017 run_test 27q "append to truncated file with all OSTs full (should error)"
2020 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2021 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2022 remote_mds_nodsh && skip "remote MDS with nodsh"
2023 remote_ost_nodsh && skip "remote OST with nodsh"
2026 rm -f $DIR/$tdir/$tfile
2027 exhaust_precreations 0 0x80000215
2029 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
2033 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
2035 test_27s() { # bug 10725
2036 test_mkdir $DIR/$tdir
2037 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2038 local stripe_count=0
2039 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2040 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2041 error "stripe width >= 2^32 succeeded" || true
2044 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2046 test_27t() { # bug 10864
2051 $WLFS getstripe $tfile
2054 run_test 27t "check that utils parse path correctly"
2056 test_27u() { # bug 4900
2057 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2058 remote_mds_nodsh && skip "remote MDS with nodsh"
2061 local list=$(comma_list $(mdts_nodes))
2063 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2064 do_nodes $list $LCTL set_param fail_loc=0x139
2065 test_mkdir -p $DIR/$tdir
2066 stack_trap "simple_cleanup_common 1000"
2067 createmany -o $DIR/$tdir/$tfile 1000
2068 do_nodes $list $LCTL set_param fail_loc=0
2070 TLOG=$TMP/$tfile.getstripe
2071 $LFS getstripe $DIR/$tdir > $TLOG
2072 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2073 [[ $OBJS -gt 0 ]] &&
2074 error "$OBJS objects created on OST-0. See $TLOG" ||
2077 run_test 27u "skip object creation on OSC w/o objects"
2079 test_27v() { # bug 4900
2080 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2081 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2082 remote_mds_nodsh && skip "remote MDS with nodsh"
2083 remote_ost_nodsh && skip "remote OST with nodsh"
2085 exhaust_all_precreations 0x215
2088 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2090 touch $DIR/$tdir/$tfile
2091 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2093 for (( i=1; i < OSTCOUNT; i++ )); do
2094 do_facet ost$i lctl set_param fail_loc=0x705
2096 local START=`date +%s`
2097 createmany -o $DIR/$tdir/$tfile 32
2099 local FINISH=`date +%s`
2100 local TIMEOUT=`lctl get_param -n timeout`
2101 local PROCESS=$((FINISH - START))
2102 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2103 error "$FINISH - $START >= $TIMEOUT / 2"
2104 sleep $((TIMEOUT / 2 - PROCESS))
2107 run_test 27v "skip object creation on slow OST"
2109 test_27w() { # bug 10997
2110 test_mkdir $DIR/$tdir
2111 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2112 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2113 error "stripe size $size != 65536" || true
2114 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2115 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2117 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2120 [[ $OSTCOUNT -lt 2 ]] &&
2121 skip_env "skipping multiple stripe count/offset test"
2123 test_mkdir $DIR/$tdir
2124 for i in $(seq 1 $OSTCOUNT); do
2126 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2127 error "setstripe -c $i -i $offset failed"
2128 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2129 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2130 [ $count -ne $i ] && error "stripe count $count != $i" || true
2131 [ $index -ne $offset ] &&
2132 error "stripe offset $index != $offset" || true
2135 run_test 27wa "check $LFS setstripe -c -i options"
2138 remote_ost_nodsh && skip "remote OST with nodsh"
2139 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2140 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2142 OFFSET=$(($OSTCOUNT - 1))
2144 local OST=$(ostname_from_index $OSTIDX)
2146 test_mkdir $DIR/$tdir
2147 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2148 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2150 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2151 for i in $(seq 0 $OFFSET); do
2152 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2153 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2154 error "OST0 was degraded but new created file still use it"
2156 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2158 run_test 27x "create files while OST0 is degraded"
2161 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2162 remote_mds_nodsh && skip "remote MDS with nodsh"
2163 remote_ost_nodsh && skip "remote OST with nodsh"
2164 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2166 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2167 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2168 osp.$mdtosc.prealloc_last_id)
2169 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2170 osp.$mdtosc.prealloc_next_id)
2171 local fcount=$((last_id - next_id))
2172 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2173 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2175 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2176 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2177 local OST_DEACTIVE_IDX=-1
2182 for OSC in $MDS_OSCS; do
2183 OST=$(osc_to_ost $OSC)
2184 OSTIDX=$(index_from_ostuuid $OST)
2185 if [ $OST_DEACTIVE_IDX == -1 ]; then
2186 OST_DEACTIVE_IDX=$OSTIDX
2188 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2189 echo $OSC "is Deactivated:"
2190 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2194 OSTIDX=$(index_from_ostuuid $OST)
2195 test_mkdir $DIR/$tdir
2196 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2198 for OSC in $MDS_OSCS; do
2199 OST=$(osc_to_ost $OSC)
2200 OSTIDX=$(index_from_ostuuid $OST)
2201 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2202 echo $OST "is degraded:"
2203 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2204 obdfilter.$OST.degraded=1
2209 createmany -o $DIR/$tdir/$tfile $fcount
2211 for OSC in $MDS_OSCS; do
2212 OST=$(osc_to_ost $OSC)
2213 OSTIDX=$(index_from_ostuuid $OST)
2214 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2215 echo $OST "is recovered from degraded:"
2216 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2217 obdfilter.$OST.degraded=0
2219 do_facet $SINGLEMDS lctl --device %$OSC activate
2223 # all osp devices get activated, hence -1 stripe count restored
2224 local stripe_count=0
2226 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2227 # devices get activated.
2229 $LFS setstripe -c -1 $DIR/$tfile
2230 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2232 [ $stripe_count -ne $OSTCOUNT ] &&
2233 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2236 run_test 27y "create files while OST0 is degraded and the rest inactive"
2242 lmm_count=$($LFS getstripe -c $1)
2243 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2244 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2246 local old_ifs="$IFS"
2248 fid=($($LFS path2fid $1))
2251 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2252 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2254 # compare lmm_seq and lu_fid->f_seq
2255 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2256 # compare lmm_object_id and lu_fid->oid
2257 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2259 # check the trusted.fid attribute of the OST objects of the file
2260 local have_obdidx=false
2262 $LFS getstripe $1 | while read obdidx oid hex seq; do
2263 # skip lines up to and including "obdidx"
2264 [ -z "$obdidx" ] && break
2265 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2266 $have_obdidx || continue
2268 local ost=$((obdidx + 1))
2269 local dev=$(ostdevname $ost)
2272 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2274 seq=$(echo $seq | sed -e "s/^0x//g")
2275 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2276 oid_hex=$(echo $oid)
2278 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2280 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2284 # Don't unmount/remount the OSTs if we don't need to do that.
2285 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2286 # update too, until that use mount/ll_decode_filter_fid/mount.
2287 # Re-enable when debugfs will understand new filter_fid.
2289 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2290 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2291 $dev 2>/dev/null" | grep "parent=")
2293 if [ -z "$ff" ]; then
2295 mount_fstype ost$ost
2296 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2297 $(facet_mntpt ost$ost)/$obj_file)
2298 unmount_fstype ost$ost
2299 start ost$ost $dev $OST_MOUNT_OPTS
2303 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2305 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2307 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2308 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2310 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2311 # stripe_size=1048576 component_id=1 component_start=0 \
2312 # component_end=33554432
2313 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2314 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2315 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2317 if grep -q 'stripe=' <<<$ff; then
2318 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2320 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2321 # into f_ver in this case. See comment on ff_parent.
2322 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2325 # compare lmm_seq and filter_fid->ff_parent.f_seq
2326 [ $ff_pseq = $lmm_seq ] ||
2327 error "FF parent SEQ $ff_pseq != $lmm_seq"
2328 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2329 [ $ff_poid = $lmm_oid ] ||
2330 error "FF parent OID $ff_poid != $lmm_oid"
2331 (($ff_pstripe == $stripe_nr)) ||
2332 error "FF stripe $ff_pstripe != $stripe_nr"
2334 stripe_nr=$((stripe_nr + 1))
2335 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2337 if grep -q 'stripe_count=' <<<$ff; then
2338 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2339 -e 's/ .*//' <<<$ff)
2340 [ $lmm_count = $ff_scnt ] ||
2341 error "FF stripe count $lmm_count != $ff_scnt"
2347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2348 remote_ost_nodsh && skip "remote OST with nodsh"
2350 test_mkdir $DIR/$tdir
2351 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2352 { error "setstripe -c -1 failed"; return 1; }
2353 # We need to send a write to every object to get parent FID info set.
2354 # This _should_ also work for setattr, but does not currently.
2355 # touch $DIR/$tdir/$tfile-1 ||
2356 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2357 { error "dd $tfile-1 failed"; return 2; }
2358 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2359 { error "setstripe -c -1 failed"; return 3; }
2360 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2361 { error "dd $tfile-2 failed"; return 4; }
2363 # make sure write RPCs have been sent to OSTs
2366 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2367 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2369 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2371 test_27A() { # b=19102
2372 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2374 save_layout_restore_at_exit $MOUNT
2375 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2376 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2377 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2378 local default_size=$($LFS getstripe -S $MOUNT)
2379 local default_offset=$($LFS getstripe -i $MOUNT)
2380 local dsize=$(do_facet $SINGLEMDS \
2381 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2382 [ $default_size -eq $dsize ] ||
2383 error "stripe size $default_size != $dsize"
2384 [ $default_offset -eq -1 ] ||
2385 error "stripe offset $default_offset != -1"
2387 run_test 27A "check filesystem-wide default LOV EA values"
2389 test_27B() { # LU-2523
2390 test_mkdir $DIR/$tdir
2391 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2393 # open f1 with O_LOV_DELAY_CREATE
2395 # call setstripe ioctl on open file descriptor for f1
2397 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2401 # open f1 with O_LOV_DELAY_CREATE
2403 # call setstripe ioctl on open file descriptor for f1
2405 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2407 # Allow multiop to fail in imitation of NFS's busted semantics.
2410 run_test 27B "call setstripe on open unlinked file/rename victim"
2412 # 27C family tests full striping and overstriping
2413 test_27Ca() { #LU-2871
2414 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2422 test_mkdir $DIR/$tdir
2424 for i in $(seq 0 $((OSTCOUNT - 1))); do
2425 # set stripe across all OSTs starting from OST$i
2426 $LFS setstripe -i $i -c -1 $tfile$i
2427 # get striping information
2428 ost_idx=($($LFS getstripe $tfile$i |
2429 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2430 echo "OST Index: ${ost_idx[*]}"
2433 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2434 error "${#ost_idx[@]} != $OSTCOUNT"
2436 for index in $(seq 0 $((OSTCOUNT - 1))); do
2438 for j in "${ost_idx[@]}"; do
2439 if [ $index -eq $j ]; then
2445 error "Can not find $index in ${ost_idx[*]}"
2449 run_test 27Ca "check full striping across all OSTs"
2452 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2453 skip "server does not support overstriping"
2454 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2455 skip_env "too many osts, skipping"
2457 test_mkdir -p $DIR/$tdir
2458 local setcount=$(($OSTCOUNT * 2))
2459 [ $setcount -lt 160 ] || large_xattr_enabled ||
2460 skip_env "ea_inode feature disabled"
2462 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2463 error "setstripe failed"
2465 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2466 [ $count -eq $setcount ] ||
2467 error "stripe count $count, should be $setcount"
2469 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2470 error "overstriped should be set in pattern"
2472 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2475 run_test 27Cb "more stripes than OSTs with -C"
2478 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2479 skip "server does not support overstriping"
2480 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2482 test_mkdir -p $DIR/$tdir
2483 local setcount=$(($OSTCOUNT - 1))
2485 [ $setcount -lt 160 ] || large_xattr_enabled ||
2486 skip_env "ea_inode feature disabled"
2488 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2489 error "setstripe failed"
2491 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2492 [ $count -eq $setcount ] ||
2493 error "stripe count $count, should be $setcount"
2495 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2496 error "overstriped should not be set in pattern"
2498 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2501 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2504 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2505 skip "server does not support overstriping"
2506 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2507 large_xattr_enabled || skip_env "ea_inode feature disabled"
2511 test_mkdir -p $DIR/$tdir
2512 local setcount=$LOV_MAX_STRIPE_COUNT
2514 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2515 error "setstripe failed"
2517 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2518 [ $count -eq $setcount ] ||
2519 error "stripe count $count, should be $setcount"
2521 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2522 error "overstriped should be set in pattern"
2524 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2527 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2529 run_test 27Cd "test maximum stripe count"
2532 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2533 skip "server does not support overstriping"
2534 test_mkdir -p $DIR/$tdir
2536 pool_add $TESTNAME || error "Pool creation failed"
2537 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2541 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2542 error "setstripe failed"
2544 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2545 [ $count -eq $setcount ] ||
2546 error "stripe count $count, should be $setcount"
2548 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2549 error "overstriped should be set in pattern"
2551 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2554 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2556 run_test 27Ce "test pool with overstriping"
2559 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2560 skip "server does not support overstriping"
2561 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2562 skip_env "too many osts, skipping"
2564 test_mkdir -p $DIR/$tdir
2566 local setcount=$(($OSTCOUNT * 2))
2567 [ $setcount -lt 160 ] || large_xattr_enabled ||
2568 skip_env "ea_inode feature disabled"
2570 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2571 error "setstripe failed"
2573 echo 1 > $DIR/$tdir/$tfile
2575 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2576 [ $count -eq $setcount ] ||
2577 error "stripe count $count, should be $setcount"
2579 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2580 error "overstriped should be set in pattern"
2582 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2585 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2587 run_test 27Cf "test default inheritance with overstriping"
2590 (( MDS1_VERSION >= $(version_code v2_15_55-80-gd96b98ee6b) )) ||
2591 skip "need MDS version at least v2_15_55-80-gd96b98ee6b for fix"
2593 $LFS setstripe -o 0,$OSTCOUNT $DIR/$tfile
2594 (( $? != 0 )) || error "must be an error for not existent OST#"
2596 run_test 27Cg "test setstripe with wrong OST idx"
2599 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2600 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2601 remote_mds_nodsh && skip "remote MDS with nodsh"
2603 local POOL=${POOL:-testpool}
2605 local last_ost=$(($OSTCOUNT - 1))
2607 local ost_list=$(seq $first_ost $ost_step $last_ost)
2608 local ost_range="$first_ost $last_ost $ost_step"
2610 test_mkdir $DIR/$tdir
2611 pool_add $POOL || error "pool_add failed"
2612 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2615 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2617 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2618 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2619 skip27D+=" -s 30,31"
2620 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2621 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2622 skip27D+=" -s 32,33"
2623 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2625 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2626 error "llapi_layout_test failed"
2628 destroy_test_pools || error "destroy test pools failed"
2630 run_test 27D "validate llapi_layout API"
2632 # Verify that default_easize is increased from its initial value after
2633 # accessing a widely striped file.
2635 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2636 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2637 skip "client does not have LU-3338 fix"
2639 # 72 bytes is the minimum space required to store striping
2640 # information for a file striped across one OST:
2641 # (sizeof(struct lov_user_md_v3) +
2642 # sizeof(struct lov_user_ost_data_v1))
2644 $LCTL set_param -n llite.*.default_easize $min_easize ||
2645 error "lctl set_param failed"
2646 local easize=$($LCTL get_param -n llite.*.default_easize)
2648 [ $easize -eq $min_easize ] ||
2649 error "failed to set default_easize"
2651 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2652 error "setstripe failed"
2653 # In order to ensure stat() call actually talks to MDS we need to
2654 # do something drastic to this file to shake off all lock, e.g.
2655 # rename it (kills lookup lock forcing cache cleaning)
2656 mv $DIR/$tfile $DIR/${tfile}-1
2657 ls -l $DIR/${tfile}-1
2660 easize=$($LCTL get_param -n llite.*.default_easize)
2662 [ $easize -gt $min_easize ] ||
2663 error "default_easize not updated"
2665 run_test 27E "check that default extended attribute size properly increases"
2667 test_27F() { # LU-5346/LU-7975
2668 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2669 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2670 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2671 skip "Need MDS version at least 2.8.51"
2672 remote_ost_nodsh && skip "remote OST with nodsh"
2674 test_mkdir $DIR/$tdir
2676 $LFS setstripe -c 2 $DIR/$tdir
2678 # stop all OSTs to reproduce situation for LU-7975 ticket
2679 for num in $(seq $OSTCOUNT); do
2683 # open/create f0 with O_LOV_DELAY_CREATE
2684 # truncate f0 to a non-0 size
2686 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2688 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2689 # open/write it again to force delayed layout creation
2690 cat /etc/hosts > $DIR/$tdir/f0 &
2694 for num in $(seq $OSTCOUNT); do
2695 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2696 error "ost$num failed to start"
2699 wait $catpid || error "cat failed"
2701 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2702 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2703 error "wrong stripecount"
2706 run_test 27F "Client resend delayed layout creation with non-zero size"
2708 test_27G() { #LU-10629
2709 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2710 skip "Need MDS version at least 2.11.51"
2711 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2712 remote_mds_nodsh && skip "remote MDS with nodsh"
2713 local POOL=${POOL:-testpool}
2714 local ostrange="0 0 1"
2716 test_mkdir $DIR/$tdir
2717 touch $DIR/$tdir/$tfile.nopool
2718 pool_add $POOL || error "pool_add failed"
2719 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2720 $LFS setstripe -p $POOL $DIR/$tdir
2722 local pool=$($LFS getstripe -p $DIR/$tdir)
2724 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2725 touch $DIR/$tdir/$tfile.default
2726 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2727 $LFS find $DIR/$tdir -type f --pool $POOL
2728 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2729 [[ "$found" == "2" ]] ||
2730 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2732 $LFS setstripe -d $DIR/$tdir
2734 pool=$($LFS getstripe -p -d $DIR/$tdir)
2736 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2738 run_test 27G "Clear OST pool from stripe"
2741 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2742 skip "Need MDS version newer than 2.11.54"
2743 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2744 test_mkdir $DIR/$tdir
2745 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2746 touch $DIR/$tdir/$tfile
2747 $LFS getstripe -c $DIR/$tdir/$tfile
2748 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2749 error "two-stripe file doesn't have two stripes"
2751 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2752 $LFS getstripe -y $DIR/$tdir/$tfile
2753 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2754 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2755 error "expected l_ost_idx: [02]$ not matched"
2757 # make sure ost list has been cleared
2758 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2759 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2760 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2762 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2764 run_test 27H "Set specific OSTs stripe"
2767 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2768 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2769 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2770 skip "Need MDS version newer than 2.12.52"
2771 local pool=$TESTNAME
2772 local ostrange="1 1 1"
2774 save_layout_restore_at_exit $MOUNT
2775 $LFS setstripe -c 2 -i 0 $MOUNT
2776 pool_add $pool || error "pool_add failed"
2777 pool_add_targets $pool $ostrange ||
2778 error "pool_add_targets failed"
2779 test_mkdir $DIR/$tdir
2780 $LFS setstripe -p $pool $DIR/$tdir
2781 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2782 $LFS getstripe $DIR/$tdir/$tfile
2784 run_test 27I "check that root dir striping does not break parent dir one"
2787 (( $MDS1_VERSION > $(version_code 2.12.51) )) ||
2788 skip "Need MDS version newer than 2.12.51"
2790 # skip basic ops on file with foreign LOV tests on 5.12-6.2 kernels
2791 # until the filemap_read() issue is fixed by v6.2-rc4-61-g5956592ce337
2792 (( $LINUX_VERSION_CODE < $(version_code 5.12.0) ||
2793 $LINUX_VERSION_CODE >= $(version_code 6.2.0) )) ||
2794 skip "Need kernel < 5.12.0 or >= 6.2.0 for filemap_read() fix"
2796 test_mkdir $DIR/$tdir
2797 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2798 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2800 # create foreign file (raw way)
2801 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2802 error "creating $tfile w/ hex flags w/o --foreign should fail"
2804 ! $LFS setstripe --foreign --flags foo \
2805 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2806 error "creating $tfile with '--flags foo' should fail"
2808 ! $LFS setstripe --foreign --flags 0xffffffff \
2809 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2810 error "creating $tfile w/ 0xffffffff flags should fail"
2812 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2813 -t 1 -F 0xda08 || error "create_foreign_file failed"
2815 # verify foreign file (raw way)
2816 parse_foreign_file -f $DIR/$tdir/$tfile |
2817 grep "lov_foreign_magic: 0x0BD70BD0" ||
2818 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2819 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2820 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2821 parse_foreign_file -f $DIR/$tdir/$tfile |
2822 grep "lov_foreign_size: 73" ||
2823 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2824 parse_foreign_file -f $DIR/$tdir/$tfile |
2825 grep "lov_foreign_type: 1" ||
2826 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2827 parse_foreign_file -f $DIR/$tdir/$tfile |
2828 grep "lov_foreign_flags: 0x0000DA08" ||
2829 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2830 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2831 grep "lov_foreign_value: 0x" |
2832 sed -e 's/lov_foreign_value: 0x//')
2833 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2834 [[ $lov = ${lov2// /} ]] ||
2835 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2837 # create foreign file (lfs + API)
2838 $LFS setstripe --foreign=none --flags 0xda08 \
2839 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2840 error "$DIR/$tdir/${tfile}2: create failed"
2842 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2843 grep "lfm_magic:.*0x0BD70BD0" ||
2844 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2845 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2846 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2847 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2848 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2849 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2850 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2851 grep "lfm_flags:.*0x0000DA08" ||
2852 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2853 $LFS getstripe $DIR/$tdir/${tfile}2 |
2854 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2855 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2857 # modify striping should fail
2858 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2859 error "$DIR/$tdir/$tfile: setstripe should fail"
2860 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2861 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2864 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2865 cat $DIR/$tdir/${tfile}2 &&
2866 error "$DIR/$tdir/${tfile}2: read should fail"
2867 cat /etc/passwd > $DIR/$tdir/$tfile &&
2868 error "$DIR/$tdir/$tfile: write should fail"
2869 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2870 error "$DIR/$tdir/${tfile}2: write should fail"
2873 chmod 222 $DIR/$tdir/$tfile ||
2874 error "$DIR/$tdir/$tfile: chmod failed"
2875 chmod 222 $DIR/$tdir/${tfile}2 ||
2876 error "$DIR/$tdir/${tfile}2: chmod failed"
2879 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2880 error "$DIR/$tdir/$tfile: chown failed"
2881 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2882 error "$DIR/$tdir/${tfile}2: chown failed"
2884 # rename should work
2885 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2886 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2887 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2888 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2890 #remove foreign file
2891 rm $DIR/$tdir/${tfile}.new ||
2892 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2893 rm $DIR/$tdir/${tfile}2.new ||
2894 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2896 run_test 27J "basic ops on file with foreign LOV"
2899 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2900 skip "Need MDS version newer than 2.12.49"
2902 test_mkdir $DIR/$tdir
2903 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2904 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2906 # create foreign dir (raw way)
2907 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2908 error "creating $tdir w/ hex flags w/o --foreign should fail"
2910 ! $LFS setdirstripe --foreign --flags foo \
2911 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2912 error "creating $tdir with '--flags foo' should fail"
2914 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2915 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2916 error "creating $tdir w/ 0xffffffff flags should fail"
2918 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2919 error "create_foreign_dir FAILED"
2921 # verify foreign dir (raw way)
2922 parse_foreign_dir -d $DIR/$tdir/$tdir |
2923 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2924 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2925 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2926 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2927 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2928 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2929 parse_foreign_dir -d $DIR/$tdir/$tdir |
2930 grep "lmv_foreign_flags: 55813$" ||
2931 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2932 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2933 grep "lmv_foreign_value: 0x" |
2934 sed 's/lmv_foreign_value: 0x//')
2935 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2937 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2939 # create foreign dir (lfs + API)
2940 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2941 $DIR/$tdir/${tdir}2 ||
2942 error "$DIR/$tdir/${tdir}2: create failed"
2944 $LFS getdirstripe -v $DIR/$tdir/${tdir}2
2946 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2947 grep "lfm_magic:.*0x0CD50CD0" ||
2948 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2949 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2950 # - sizeof(lfm_type) - sizeof(lfm_flags)
2951 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2952 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2953 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2954 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2955 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2956 grep "lfm_flags:.*0x0000DA05" ||
2957 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2958 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2959 grep "lfm_value.*${uuid1}@${uuid2}" ||
2960 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2962 # file create in dir should fail
2963 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
2964 touch $DIR/$tdir/${tdir}2/$tfile &&
2965 error "$DIR/${tdir}2: file create should fail"
2968 chmod 777 $DIR/$tdir/$tdir ||
2969 error "$DIR/$tdir: chmod failed"
2970 chmod 777 $DIR/$tdir/${tdir}2 ||
2971 error "$DIR/${tdir}2: chmod failed"
2974 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2975 error "$DIR/$tdir: chown failed"
2976 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2977 error "$DIR/${tdir}2: chown failed"
2979 # rename should work
2980 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2981 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2982 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2983 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2986 rmdir $DIR/$tdir/${tdir}.new ||
2987 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2988 rmdir $DIR/$tdir/${tdir}2.new ||
2989 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2991 run_test 27K "basic ops on dir with foreign LMV"
2994 remote_mds_nodsh && skip "remote MDS with nodsh"
2996 local POOL=${POOL:-$TESTNAME}
2998 pool_add $POOL || error "pool_add failed"
3000 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
3001 error "pool_list does not contain ${FSNAME}.${POOL}:" \
3002 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
3004 run_test 27L "lfs pool_list gives correct pool name"
3007 (( $MDS1_VERSION >= $(version_code 2.12.57) )) ||
3008 skip "Need MDS version >= than 2.12.57"
3009 remote_mds_nodsh && skip "remote MDS with nodsh"
3010 (( $OSTCOUNT > 1 )) || skip "need > 1 OST"
3012 # Set default striping on directory
3015 local mdts=$(comma_list $(mdts_nodes))
3017 # if we run against a 2.12 server which lacks overstring support
3018 # then the connect_flag will not report overstriping, even if client
3020 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
3021 stripe_opt="-C $setcount"
3022 elif (( $OSTCOUNT >= $setcount )); then
3023 stripe_opt="-c $setcount"
3025 skip "server does not support overstriping"
3028 test_mkdir $DIR/$tdir
3030 # Validate existing append_* params and ensure restore
3031 local pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3032 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3033 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3035 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3036 ((orig_count == 1)) || error "expected append_stripe_count == 1, got $orig_count"
3037 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1"
3039 $LFS setstripe $stripe_opt $DIR/$tdir
3041 echo 1 > $DIR/$tdir/${tfile}.1
3042 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
3043 (( $count == $setcount )) ||
3044 error "(1) stripe count $count, should be $setcount"
3046 local appendcount=$orig_count
3047 echo 1 >> $DIR/$tdir/${tfile}.2_append
3048 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
3049 (( $count == $appendcount )) ||
3050 error "(2)stripe count $count, should be $appendcount for append"
3052 # Disable O_APPEND striping, verify it works
3053 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3055 # Should now get the default striping, which is 4
3057 echo 1 >> $DIR/$tdir/${tfile}.3_append
3058 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3059 (( $count == $setcount )) ||
3060 error "(3) stripe count $count, should be $setcount"
3062 # Try changing the stripe count for append files
3063 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3065 # Append striping is now 2 (directory default is still 4)
3067 echo 1 >> $DIR/$tdir/${tfile}.4_append
3068 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3069 (( $count == $appendcount )) ||
3070 error "(4) stripe count $count, should be $appendcount for append"
3072 # Test append stripe count of -1
3073 # Exercise LU-16872 patch with specific striping, only if MDS has fix
3074 (( $MDS1_VERSION > $(version_code 2.15.56.46) )) &&
3075 $LFS setstripe -o 0,$((OSTCOUNT - 1)) $DIR/$tdir &&
3076 touch $DIR/$tdir/$tfile.specific.{1..128}
3077 stack_trap "rm -f $DIR/$tdir/$tfile.*"
3079 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3080 appendcount=$OSTCOUNT
3081 echo 1 >> $DIR/$tdir/${tfile}.5
3082 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3083 (( $count == $appendcount )) ||
3084 error "(5) stripe count $count, should be $appendcount for append"
3086 # Set append striping back to default of 1
3087 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3089 # Try a new default striping, PFL + DOM
3090 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3092 # Create normal DOM file, DOM returns stripe count == 0
3094 touch $DIR/$tdir/${tfile}.6
3095 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3096 (( $count == $setcount )) ||
3097 error "(6) stripe count $count, should be $setcount"
3101 echo 1 >> $DIR/$tdir/${tfile}.7_append
3102 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3103 (( $count == $appendcount )) ||
3104 error "(7) stripe count $count, should be $appendcount for append"
3106 # Clean up DOM layout
3107 $LFS setstripe -d $DIR/$tdir
3109 save_layout_restore_at_exit $MOUNT
3110 # Now test that append striping works when layout is from root
3111 $LFS setstripe -c 2 $MOUNT
3112 # Make a special directory for this
3113 mkdir $DIR/${tdir}/${tdir}.2
3115 # Verify for normal file
3117 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3118 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3119 (( $count == $setcount )) ||
3120 error "(8) stripe count $count, should be $setcount"
3123 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3124 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3125 (( $count == $appendcount )) ||
3126 error "(9) stripe count $count, should be $appendcount for append"
3128 # Now test O_APPEND striping with pools
3129 pool_add $TESTNAME || error "pool creation failed"
3130 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3131 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3133 echo 1 >> $DIR/$tdir/${tfile}.10_append
3135 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3136 [[ "$pool" == "$TESTNAME" ]] || error "(10) incorrect pool: $pool"
3138 # Check that count is still correct
3140 echo 1 >> $DIR/$tdir/${tfile}.11_append
3141 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3142 (( $count == $appendcount )) ||
3143 error "(11) stripe count $count, should be $appendcount for append"
3145 # Disable O_APPEND stripe count, verify pool works separately
3146 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3148 echo 1 >> $DIR/$tdir/${tfile}.12_append
3150 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3151 [[ "$pool" == "$TESTNAME" ]] || error "(12) incorrect pool: $pool"
3153 # Remove pool setting, verify it's not applied
3154 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3156 echo 1 >> $DIR/$tdir/${tfile}.13_append
3158 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3159 [[ -z "$pool" ]] || error "(13) pool found: $pool"
3161 run_test 27M "test O_APPEND striping"
3164 combined_mgs_mds && skip "needs separate MGS/MDT"
3166 pool_add $TESTNAME || error "pool_add failed"
3167 do_facet mgs "$LCTL pool_list $FSNAME" |
3168 grep -Fx "${FSNAME}.${TESTNAME}" ||
3169 error "lctl pool_list on MGS failed"
3171 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3173 clean_foreign_symlink() {
3175 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3176 for i in $DIR/$tdir/* ; do
3177 $LFS unlink_foreign $i || true
3182 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3183 skip "Need MDS version newer than 2.12.51"
3185 test_mkdir $DIR/$tdir
3186 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3187 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3189 trap clean_foreign_symlink EXIT
3191 # enable foreign_symlink behaviour
3192 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3194 # foreign symlink LOV format is a partial path by default
3196 # create foreign file (lfs + API)
3197 $LFS setstripe --foreign=symlink --flags 0xda05 \
3198 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3199 error "$DIR/$tdir/${tfile}: create failed"
3201 $LFS getstripe -v $DIR/$tdir/${tfile} |
3202 grep "lfm_magic:.*0x0BD70BD0" ||
3203 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3204 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3205 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3206 $LFS getstripe -v $DIR/$tdir/${tfile} |
3207 grep "lfm_flags:.*0x0000DA05" ||
3208 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3209 $LFS getstripe $DIR/$tdir/${tfile} |
3210 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3211 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3213 # modify striping should fail
3214 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3215 error "$DIR/$tdir/$tfile: setstripe should fail"
3217 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3218 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3219 cat /etc/passwd > $DIR/$tdir/$tfile &&
3220 error "$DIR/$tdir/$tfile: write should fail"
3222 # rename should succeed
3223 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3224 error "$DIR/$tdir/$tfile: rename has failed"
3226 #remove foreign_symlink file should fail
3227 rm $DIR/$tdir/${tfile}.new &&
3228 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3231 mkdir /tmp/${uuid1} ||
3232 error "/tmp/${uuid1}: mkdir has failed"
3233 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3234 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3235 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3236 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3237 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3238 #read should succeed now
3239 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3240 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3241 #write should succeed now
3242 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3243 error "$DIR/$tdir/${tfile}.new: write should succeed"
3244 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3245 error "$DIR/$tdir/${tfile}.new: diff has failed"
3246 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3247 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3249 #check that getstripe still works
3250 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3251 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3253 # chmod should still succeed
3254 chmod 644 $DIR/$tdir/${tfile}.new ||
3255 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3257 # chown should still succeed
3258 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3259 error "$DIR/$tdir/${tfile}.new: chown has failed"
3261 # rename should still succeed
3262 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3263 error "$DIR/$tdir/${tfile}.new: rename has failed"
3265 #remove foreign_symlink file should still fail
3266 rm $DIR/$tdir/${tfile} &&
3267 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3269 #use special ioctl() to unlink foreign_symlink file
3270 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3271 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3274 run_test 27O "basic ops on foreign file of symlink type"
3277 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3278 skip "Need MDS version newer than 2.12.49"
3280 test_mkdir $DIR/$tdir
3281 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3282 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3284 trap clean_foreign_symlink EXIT
3286 # enable foreign_symlink behaviour
3287 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3289 # foreign symlink LMV format is a partial path by default
3291 # create foreign dir (lfs + API)
3292 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3293 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3294 error "$DIR/$tdir/${tdir}: create failed"
3296 $LFS getdirstripe -v $DIR/$tdir/${tdir}
3298 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3299 grep "lfm_magic:.*0x0CD50CD0" ||
3300 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3301 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3302 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3303 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3304 grep "lfm_flags:.*0x0000DA05" ||
3305 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3306 $LFS getdirstripe $DIR/$tdir/${tdir} |
3307 grep "lfm_value.*${uuid1}/${uuid2}" ||
3308 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3310 # file create in dir should fail
3311 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3312 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
3314 # rename should succeed
3315 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3316 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3318 #remove foreign_symlink dir should fail
3319 rmdir $DIR/$tdir/${tdir}.new &&
3320 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3323 mkdir -p /tmp/${uuid1}/${uuid2} ||
3324 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3325 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3326 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3327 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3328 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3329 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3330 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3331 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3333 #check that getstripe fails now that foreign_symlink enabled
3334 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3335 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3337 # file create in dir should work now
3338 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3339 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3340 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3341 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3342 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3343 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3345 # chmod should still succeed
3346 chmod 755 $DIR/$tdir/${tdir}.new ||
3347 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3349 # chown should still succeed
3350 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3351 error "$DIR/$tdir/${tdir}.new: chown has failed"
3353 # rename should still succeed
3354 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3355 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3357 #remove foreign_symlink dir should still fail
3358 rmdir $DIR/$tdir/${tdir} &&
3359 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3361 #use special ioctl() to unlink foreign_symlink file
3362 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3363 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3365 #created file should still exist
3366 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3367 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3368 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3369 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3371 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3374 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3375 stack_trap "rm -f $TMP/$tfile*"
3377 test_mkdir $DIR/$tdir-1
3378 test_mkdir $DIR/$tdir-2
3380 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3381 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3383 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3384 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3386 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3387 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3389 # Create some bad symlinks and ensure that we don't loop
3390 # forever or something. These should return ELOOP (40) and
3391 # ENOENT (2) but I don't want to test for that because there's
3392 # always some weirdo architecture that needs to ruin
3393 # everything by defining these error numbers differently.
3395 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3396 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3398 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3399 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3403 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3406 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
3407 skip "need MDS 2.14.55 or later"
3408 (( $OSTCOUNT >= 2 )) || skip_env "needs at least 2 OSTs"
3410 local testdir="$DIR/$tdir"
3411 test_mkdir -p $testdir
3412 stack_trap "rm -rf $testdir"
3413 $LFS setstripe -c -1 $testdir || error "setstripe failed"
3415 local f1="$testdir/f1"
3416 touch $f1 || error "failed to touch $f1"
3417 local count=$($LFS getstripe -c $f1)
3418 (( $count == $OSTCOUNT )) || error "wrong stripe count"
3420 do_facet $SINGLEMDS $LCTL set_param lod.*.max_stripecount=-1
3421 (( $? == 34 )) || error "setting max_stripecount to -1 should fail and return ERANGE"
3423 local maxcount=$(($OSTCOUNT - 1))
3424 local mdts=$(comma_list $(mdts_nodes))
3425 do_nodes $mdts $LCTL set_param lod.*.max_stripecount=$maxcount
3426 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_stripecount=0"
3428 local f2="$testdir/f2"
3429 touch $f2 || error "failed to touch $f2"
3430 local count=$($LFS getstripe -c $f2)
3431 (( $count == $maxcount )) || error "wrong stripe count"
3433 run_test 27R "test max_stripecount limitation when stripe count is set to -1"
3436 [ $(facet_host client) == $(facet_host ost1) ] &&
3437 skip "need ost1 and client on different nodes"
3439 #define OBD_FAIL_OSC_NO_GRANT 0x411
3440 $LCTL set_param fail_loc=0x20000411 fail_val=1
3441 #define OBD_FAIL_OST_ENOSPC 0x215
3442 do_facet ost1 "$LCTL set_param fail_loc=0x80000215"
3443 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3444 $MULTIOP $DIR/$tfile oO_WRONLY:P$((4 * 1024 * 1024 + 10 * 4096))c ||
3445 error "multiop failed"
3447 run_test 27T "no eio on close on partial write due to enosp"
3450 local dir=$DIR/$tdir
3451 local file=$dir/$tfile
3452 local append_pool=${TESTNAME}-append
3453 local normal_pool=${TESTNAME}-normal
3457 local mdts=$(comma_list $(mdts_nodes))
3459 (( $MDS1_VERSION >= $(version_code 2.15.51) )) ||
3460 skip "Need MDS version at least 2.15.51 for append pool feature"
3462 # Validate existing append_* params and ensure restore
3463 pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3464 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3465 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3467 stripe_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3468 ((stripe_count == 1)) || error "expected append_stripe_count != 0, got $stripe_count"
3469 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$stripe_count"
3471 pool_add $append_pool || error "pool creation failed"
3472 pool_add_targets $append_pool 0 1 || error "Pool add targets failed"
3474 pool_add $normal_pool || error "pool creation failed"
3475 pool_add_targets $normal_pool 0 1 || error "Pool add targets failed"
3478 $LFS setstripe -E 1M -c 1 -p $normal_pool -E 2M -c 2 -p $normal_pool -E eof -c -1 $dir
3481 $LFS getstripe $file.1
3483 pool=$($LFS getstripe -p $file.1)
3484 [[ "$pool" == "$normal_pool" ]] || error "got pool '$pool', expected '$normal_pool'"
3486 stripe_count2=$($LFS getstripe -c $file.1)
3487 ((stripe_count2 == stripe_count)) ||
3488 error "got stripe_count '$stripe_count2', expected '$stripe_count'"
3490 do_nodes $mdts $LCTL set_param mdd.*.append_pool=$append_pool
3493 $LFS getstripe $file.2
3495 pool=$($LFS getstripe -p $file.2)
3496 [[ "$pool" == "$append_pool" ]] || error "got pool '$pool', expected '$append_pool'"
3498 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3501 $LFS getstripe $file.3
3503 stripe_count2=$($LFS getstripe -c $file.3)
3504 ((stripe_count2 == 2)) || error "got stripe_count '$stripe_count2', expected 2"
3506 run_test 27U "append pool and stripe count work with composite default layout"
3508 # createtest also checks that device nodes are created and
3509 # then visible correctly (#2091)
3510 test_28() { # bug 2091
3512 $CREATETEST $DIR/d28/ct || error "createtest failed"
3514 run_test 28 "create/mknod/mkdir with bad file types ============"
3517 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3519 [ $MDS1_VERSION -ge $(version_code 2.14.51) ] && {
3521 stack_trap "restore_opencache"
3524 sync; sleep 1; sync # flush out any dirty pages from previous tests
3531 declare -i LOCKCOUNTORIG=0
3532 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3533 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3535 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3537 declare -i LOCKUNUSEDCOUNTORIG=0
3538 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3539 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3546 declare -i LOCKCOUNTCURRENT=0
3547 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3548 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3551 declare -i LOCKUNUSEDCOUNTCURRENT=0
3552 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3553 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3556 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3557 $LCTL set_param -n ldlm.dump_namespaces ""
3558 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3559 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3560 log "dumped log to $TMP/test_29.dk (bug 5793)"
3563 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3564 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3565 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3566 log "dumped log to $TMP/test_29.dk (bug 5793)"
3570 run_test 29 "IT_GETATTR regression ============================"
3572 test_30a() { # was test_30
3573 cp $(which ls) $DIR || cp /bin/ls $DIR
3574 $DIR/ls / || error "Can't execute binary from lustre"
3577 run_test 30a "execute binary from Lustre (execve) =============="
3580 cp `which ls` $DIR || cp /bin/ls $DIR
3582 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3585 run_test 30b "execute binary from Lustre as non-root ==========="
3587 test_30c() { # b=22376
3588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3590 cp $(which ls) $DIR || cp /bin/ls $DIR
3592 cancel_lru_locks mdc
3593 cancel_lru_locks osc
3594 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3597 run_test 30c "execute binary from Lustre without read perms ===="
3600 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3602 for i in {1..10}; do
3603 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3606 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3607 wait $PID || error "executing dd from Lustre failed"
3613 run_test 30d "execute binary from Lustre while clear locks"
3616 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3617 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3619 run_test 31a "open-unlink file =================================="
3622 touch $DIR/f31 || error "touch $DIR/f31 failed"
3623 ln $DIR/f31 $DIR/f31b || error "ln failed"
3624 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3625 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3627 run_test 31b "unlink file with multiple links while open ======="
3630 touch $DIR/f31 || error "touch $DIR/f31 failed"
3631 ln $DIR/f31 $DIR/f31c || error "ln failed"
3632 multiop_bg_pause $DIR/f31 O_uc ||
3633 error "multiop_bg_pause for $DIR/f31 failed"
3635 $MULTIOP $DIR/f31c Ouc
3636 kill -USR1 $MULTIPID
3639 run_test 31c "open-unlink file with multiple links ============="
3642 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3643 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3645 run_test 31d "remove of open directory ========================="
3647 test_31e() { # bug 2904
3648 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3650 run_test 31e "remove of open non-empty directory ==============="
3652 test_31f() { # bug 4554
3653 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3656 test_mkdir $DIR/d31f
3657 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3658 cp /etc/hosts $DIR/d31f
3660 $LFS getstripe $DIR/d31f/hosts
3661 multiop_bg_pause $DIR/d31f D_c || return 1
3664 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3665 test_mkdir $DIR/d31f
3666 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3667 cp /etc/hosts $DIR/d31f
3669 $LFS getstripe $DIR/d31f/hosts
3670 multiop_bg_pause $DIR/d31f D_c || return 1
3673 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3674 wait $MULTIPID || error "first opendir $MULTIPID failed"
3678 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3679 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3682 run_test 31f "remove of open directory with open-unlink file ==="
3685 echo "-- cross directory link --"
3686 test_mkdir -c1 $DIR/${tdir}ga
3687 test_mkdir -c1 $DIR/${tdir}gb
3688 touch $DIR/${tdir}ga/f
3689 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3690 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3691 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3692 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3693 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3695 run_test 31g "cross directory link==============="
3698 echo "-- cross directory link --"
3699 test_mkdir -c1 $DIR/${tdir}
3700 test_mkdir -c1 $DIR/${tdir}/dir
3701 touch $DIR/${tdir}/f
3702 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3703 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3704 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3705 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3706 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3708 run_test 31h "cross directory link under child==============="
3711 echo "-- cross directory link --"
3712 test_mkdir -c1 $DIR/$tdir
3713 test_mkdir -c1 $DIR/$tdir/dir
3714 touch $DIR/$tdir/dir/f
3715 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3716 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3717 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3718 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3719 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3721 run_test 31i "cross directory link under parent==============="
3724 test_mkdir -c1 -p $DIR/$tdir
3725 test_mkdir -c1 -p $DIR/$tdir/dir1
3726 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3727 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3728 link $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "link to the same dir"
3731 run_test 31j "link for directory"
3734 test_mkdir -c1 -p $DIR/$tdir
3736 touch $DIR/$tdir/exist
3737 link $DIR/$tdir/s $DIR/$tdir/t || error "link"
3738 link $DIR/$tdir/s $DIR/$tdir/exist && error "link to exist file"
3739 link $DIR/$tdir/s $DIR/$tdir/s && error "link to the same file"
3740 link $DIR/$tdir/s $DIR/$tdir && error "link to parent dir"
3741 link $DIR/$tdir $DIR/$tdir/s && error "link parent dir to target"
3742 link $DIR/$tdir/not-exist $DIR/$tdir/foo && error "link non-existing to new"
3743 link $DIR/$tdir/not-exist $DIR/$tdir/s && error "link non-existing to exist"
3746 run_test 31k "link to file: the same, non-existing, dir"
3749 local ln_ver=$(ln --version | awk '/coreutils/ { print $4 }')
3751 (( $(version_code $ln_ver) < $(version_code 8.31) )) ||
3752 (( $(version_code $(uname -r)) >= $(version_code 5.18) )) ||
3753 skip "need coreutils < 8.31 or kernel >= 5.18 for ln"
3755 touch $DIR/$tfile || error "create failed"
3756 mkdir $DIR/$tdir || error "mkdir failed"
3757 ln $DIR/$tfile $DIR/$tdir/ || error "ln to '$tdir/' failed"
3759 run_test 31l "link to file: target dir has trailing slash"
3765 touch $DIR/d31m2/exist
3766 link $DIR/d31m/s $DIR/d31m2/t || error "link"
3767 link $DIR/d31m/s $DIR/d31m2/exist && error "link to exist file"
3768 link $DIR/d31m/s $DIR/d31m2 && error "link to parent dir"
3769 link $DIR/d31m2 $DIR/d31m/s && error "link parent dir to target"
3770 link $DIR/d31m/not-exist $DIR/d31m2/foo && error "link non-existing to new"
3771 link $DIR/d31m/not-exist $DIR/d31m2/s && error "link non-existing to exist"
3774 run_test 31m "link to file: the same, non-existing, dir"
3777 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3778 nlink=$(stat --format=%h $DIR/$tfile)
3779 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3781 local cmd="exec $fd<$DIR/$tfile"
3784 trap "eval $cmd" EXIT
3785 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3786 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3787 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3788 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3789 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3792 run_test 31n "check link count of unlinked file"
3795 local tempfile=$(mktemp $1_XXXXXX)
3796 link $tempfile $1 2> /dev/null &&
3797 echo "$BASHPID: link $tempfile to $1 succeeded"
3801 test_31o() { # LU-2901
3802 test_mkdir $DIR/$tdir
3803 for LOOP in $(seq 100); do
3804 rm -f $DIR/$tdir/$tfile*
3805 for THREAD in $(seq 8); do
3806 link_one $DIR/$tdir/$tfile.$LOOP &
3809 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3810 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3811 error "$LINKS duplicate links to $tfile.$LOOP" &&
3815 run_test 31o "duplicate hard links with same filename"
3818 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3820 test_mkdir $DIR/$tdir
3821 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3822 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3824 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3825 error "open unlink test1 failed"
3826 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3827 error "open unlink test2 failed"
3829 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3830 error "test1 still exists"
3831 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3832 error "test2 still exists"
3834 run_test 31p "remove of open striped directory"
3837 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3839 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3840 index=$($LFS getdirstripe -i $DIR/$tdir)
3841 [ $index -eq 3 ] || error "first stripe index $index != 3"
3842 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3843 [ $index -eq 1 ] || error "second stripe index $index != 1"
3845 # when "-c <stripe_count>" is set, the number of MDTs specified after
3846 # "-i" should equal to the stripe count
3847 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3849 run_test 31q "create striped directory on specific MDTs"
3853 touch $DIR/$tfile.target
3854 touch $DIR/$tfile.source
3856 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
3857 $LCTL set_param fail_loc=0x1419 fail_val=3
3858 cat $DIR/$tfile.target &
3861 # Guarantee open is waiting before we get here
3863 mv $DIR/$tfile.source $DIR/$tfile.target
3867 if [[ $RC -ne 0 ]]; then
3868 error "open with cat failed, rc=$RC"
3871 run_test 31r "open-rename(replace) race"
3873 cleanup_test32_mount() {
3876 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3877 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3878 losetup -d $loopdev || true
3884 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3886 echo "== more mountpoints and symlinks ================="
3887 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3888 trap cleanup_test32_mount EXIT
3889 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3890 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3891 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3892 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3893 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3894 cleanup_test32_mount
3896 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3899 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3901 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3902 trap cleanup_test32_mount EXIT
3903 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3904 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3905 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3906 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3907 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3908 cleanup_test32_mount
3910 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3913 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3915 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3916 trap cleanup_test32_mount EXIT
3917 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3918 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3919 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3920 test_mkdir -p $DIR/$tdir/d2/test_dir
3921 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3922 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3923 cleanup_test32_mount
3925 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3930 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3931 trap cleanup_test32_mount EXIT
3932 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3933 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3934 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3935 test_mkdir -p $DIR/$tdir/d2/test_dir
3936 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3937 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3938 cleanup_test32_mount
3940 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3944 test_mkdir -p $DIR/$tdir/tmp
3945 local tmp_dir=$DIR/$tdir/tmp
3946 ln -s $DIR/$tdir $tmp_dir/symlink11
3947 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3948 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3949 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3951 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3955 test_mkdir -p $DIR/$tdir/tmp
3956 local tmp_dir=$DIR/$tdir/tmp
3957 ln -s $DIR/$tdir $tmp_dir/symlink11
3958 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3959 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3960 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3962 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3965 local tmp_dir=$DIR/$tdir/tmp
3966 test_mkdir -p $tmp_dir
3967 test_mkdir $DIR/${tdir}2
3968 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3969 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3970 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3971 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3972 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3973 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3975 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3978 rm -fr $DIR/$tdir $DIR/${tdir}2
3979 tmp_dir=$DIR/$tdir/tmp
3980 test_mkdir -p $tmp_dir
3981 test_mkdir $DIR/${tdir}2
3982 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3983 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3984 ls $tmp_dir/symlink12 || error "listing symlink12"
3985 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3987 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3990 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3992 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3993 trap cleanup_test32_mount EXIT
3994 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3995 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3996 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3997 touch $DIR/$tdir/test_file
3998 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3999 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
4000 cleanup_test32_mount
4002 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
4005 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4007 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4008 trap cleanup_test32_mount EXIT
4009 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4010 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4011 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4012 touch $DIR/$tdir/test_file
4013 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
4014 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
4015 cleanup_test32_mount
4017 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
4020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4023 trap cleanup_test32_mount EXIT
4024 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4025 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4026 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4027 test_mkdir -p $DIR/$tdir/d2
4028 touch $DIR/$tdir/d2/test_file || error "touch failed"
4029 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
4030 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
4031 cleanup_test32_mount
4033 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
4036 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4039 trap cleanup_test32_mount EXIT
4040 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4041 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4042 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4043 test_mkdir -p $DIR/$tdir/d2
4044 touch $DIR/$tdir/d2/test_file || error "touch failed"
4045 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
4046 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
4047 cleanup_test32_mount
4049 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
4053 test_mkdir -p $DIR/d32m/tmp
4054 TMP_DIR=$DIR/d32m/tmp
4055 ln -s $DIR $TMP_DIR/symlink11
4056 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
4057 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
4058 error "symlink11 not a link"
4059 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
4060 error "symlink01 not a link"
4062 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
4066 test_mkdir -p $DIR/d32n/tmp
4067 TMP_DIR=$DIR/d32n/tmp
4068 ln -s $DIR $TMP_DIR/symlink11
4069 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
4070 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
4071 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
4073 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
4077 test_mkdir -p $DIR/d32o/tmp
4078 TMP_DIR=$DIR/d32o/tmp
4079 ln -s $DIR/$tfile $TMP_DIR/symlink12
4080 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4081 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
4082 error "symlink12 not a link"
4083 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
4084 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
4085 error "$DIR/d32o/tmp/symlink12 not file type"
4086 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
4087 error "$DIR/d32o/symlink02 not file type"
4089 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
4099 test_mkdir -p $DIR/d32p/tmp
4101 TMP_DIR=$DIR/d32p/tmp
4103 ln -s $DIR/$tfile $TMP_DIR/symlink12
4105 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4107 cat $DIR/d32p/tmp/symlink12 ||
4108 error "Can't open $DIR/d32p/tmp/symlink12"
4110 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
4113 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
4116 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4118 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4119 trap cleanup_test32_mount EXIT
4120 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4121 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4122 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4123 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4124 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
4125 cleanup_test32_mount
4127 run_test 32q "stat follows mountpoints in Lustre (should return error)"
4130 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4132 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4133 trap cleanup_test32_mount EXIT
4134 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4135 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4136 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4137 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4138 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
4139 cleanup_test32_mount
4141 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
4146 chmod 444 $DIR/$tfile
4147 chown $RUNAS_ID $DIR/$tfile
4149 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4152 run_test 33aa "write file with mode 444 (should return error)"
4156 test_mkdir $DIR/$tdir
4157 chown $RUNAS_ID $DIR/$tdir
4158 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
4159 error "$RUNAS create $tdir/$tfile failed"
4160 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4161 error "open RDWR" || true
4163 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4167 test_mkdir $DIR/$tdir
4168 chown $RUNAS_ID $DIR/$tdir
4169 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4171 run_test 33b "test open file with malformed flags (No panic)"
4174 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4175 remote_ost_nodsh && skip "remote OST with nodsh"
4183 test_mkdir $DIR/$tdir
4184 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4187 for ostnum in $(seq $OSTCOUNT); do
4188 # test-framework's OST numbering is one-based, while Lustre's
4190 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4191 # check if at least some write_bytes stats are counted
4192 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4193 obdfilter.$ostname.stats |
4194 awk '/^write_bytes/ {print $7}' )
4195 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4196 if (( ${write_bytes:-0} > 0 )); then
4202 $all_zeros || return 0
4205 echo foo > $DIR/$tdir/bar
4209 # Total up write_bytes after writing. We'd better find non-zeros.
4210 for ostnum in $(seq $OSTCOUNT); do
4211 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4212 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4213 obdfilter/$ostname/stats |
4214 awk '/^write_bytes/ {print $7}' )
4215 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4216 if (( ${write_bytes:-0} > 0 )); then
4223 for ostnum in $(seq $OSTCOUNT); do
4224 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4225 echo "Check write_bytes is in obdfilter.*.stats:"
4226 do_facet ost$ostnum lctl get_param -n \
4227 obdfilter.$ostname.stats
4229 error "OST not keeping write_bytes stats (b=22312)"
4232 run_test 33c "test write_bytes stats"
4235 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4236 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4239 local remote_dir=$DIR/$tdir/remote_dir
4241 test_mkdir $DIR/$tdir
4242 $LFS mkdir -i $MDTIDX $remote_dir ||
4243 error "create remote directory failed"
4245 touch $remote_dir/$tfile
4246 chmod 444 $remote_dir/$tfile
4247 chown $RUNAS_ID $remote_dir/$tfile
4249 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4251 chown $RUNAS_ID $remote_dir
4252 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4253 error "create" || true
4254 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4255 error "open RDWR" || true
4256 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4258 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4261 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4265 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4266 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4267 mkdir $DIR/$tdir/local_dir
4269 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4270 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4271 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4273 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4274 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4276 rmdir $DIR/$tdir/* || error "rmdir failed"
4279 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4280 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4281 mkdir $DIR/$tdir/local_dir
4283 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4284 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4285 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4287 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4288 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4290 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4293 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4294 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4295 mkdir $DIR/$tdir/local_dir
4297 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4298 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4299 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4301 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4302 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4304 run_test 33e "mkdir and striped directory should have same mode"
4308 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4312 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4313 remote_mds_nodsh && skip "remote MDS with nodsh"
4316 chmod go+rwx $DIR/$tdir
4317 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4318 trap cleanup_33f EXIT
4320 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4321 error "cannot create striped directory"
4323 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4324 error "cannot create files in striped directory"
4326 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4327 error "cannot remove files in striped directory"
4329 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4330 error "cannot remove striped directory"
4334 run_test 33f "nonroot user can create, access, and remove a striped directory"
4337 mkdir -p $DIR/$tdir/dir2
4339 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4341 [[ $err =~ "exists" ]] || error "Not exists error"
4343 run_test 33g "nonroot user create already existing root created file"
4349 test_mkdir -c $MDSCOUNT -H $hash_type $DIR/$tdir ||
4350 error "lfs mkdir -H $hash_type $tdir failed"
4351 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4353 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4357 for fname in $DIR/$tdir/$tfile.bak \
4358 $DIR/$tdir/$tfile.SAV \
4359 $DIR/$tdir/$tfile.orig \
4360 $DIR/$tdir/$tfile~; do
4361 touch $fname || error "touch $fname failed"
4362 index2=$($LFS getstripe -m $fname)
4363 (( $index == $index2 )) ||
4364 error "$fname MDT index mismatch $index != $index2"
4368 local patterns=(".$tfile.XXXXXX" "$tfile.XXXXXXXX")
4371 for pattern in ${patterns[*]}; do
4372 echo "pattern $pattern"
4373 fname=$DIR/$tdir/$pattern
4374 for (( i = 0; i < $count; i++ )); do
4375 fname=$(mktemp $DIR/$tdir/$pattern) ||
4376 error "mktemp $DIR/$tdir/$pattern failed"
4377 index2=$($LFS getstripe -m $fname)
4378 (( $index == $index2 )) && continue
4380 failed=$((failed + 1))
4381 echo "$fname MDT index mismatch $index != $index2"
4385 echo "$failed/$count MDT index mismatches, expect ~2-4"
4386 (( failed < 10 )) || error "MDT index mismatch $failed/$count times"
4391 # verify that "crush" is still broken with all files on same MDT,
4392 # crush2 should have about 1/MDSCOUNT files on each MDT, with margin
4393 [[ "$hash_type" == "crush" ]] && expect=$count ||
4394 expect=$((count / MDSCOUNT))
4396 # crush2 doesn't put all-numeric suffixes on the same MDT,
4397 # filename like $tfile.12345678 should *not* be considered temp
4398 for pattern in ${patterns[*]}; do
4399 local base=${pattern%%X*}
4400 local suff=${pattern#$base}
4402 echo "pattern $pattern"
4403 for (( i = 0; i < $count; i++ )); do
4404 fname=$DIR/$tdir/$base$((${suff//X/1} + i))
4405 touch $fname || error "touch $fname failed"
4406 index2=$($LFS getstripe -m $fname)
4407 (( $index != $index2 )) && continue
4413 # the number of "bad" hashes is random, as it depends on the random
4414 # filenames generated by "mktemp". Allow some margin in the results.
4415 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4416 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4417 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4418 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4421 # crush2 doesn't put suffixes with special characters on the same MDT
4422 # filename like $tfile.txt.1234 should *not* be considered temp
4423 for pattern in ${patterns[*]}; do
4424 local base=${pattern%%X*}
4425 local suff=${pattern#$base}
4427 pattern=$base...${suff/XXX}
4428 echo "pattern=$pattern"
4429 for (( i = 0; i < $count; i++ )); do
4430 fname=$(mktemp $DIR/$tdir/$pattern) ||
4431 error "touch $fname failed"
4432 index2=$($LFS getstripe -m $fname)
4433 (( $index != $index2 )) && continue
4439 # the number of "bad" hashes is random, as it depends on the random
4440 # filenames generated by "mktemp". Allow some margin in the results.
4441 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4442 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4443 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4444 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4448 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4449 (( $MDS1_VERSION >= $(version_code 2.13.50) )) ||
4450 skip "Need MDS version at least 2.13.50"
4454 run_test 33h "temp file is located on the same MDT as target (crush)"
4457 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4458 echo "MDS1_VERSION=$MDS1_VERSION version_code=$(version_code 2.15.0)"
4459 (( $MDS1_VERSION > $(version_code 2.15.0) )) ||
4460 skip "Need MDS version at least 2.15.0 for crush2"
4464 run_test 33hh "temp file is located on the same MDT as target (crush2)"
4468 (( MDSCOUNT < 2 )) && skip "needs >= 2 MDTs"
4470 local FNAME=$(str_repeat 'f' 250)
4472 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
4473 createmany -o $DIR/$tdir/$FNAME 1000 || error "createmany failed"
4478 count=$($LFS getstripe -m $DIR/$tdir/* | grep -cw 1)
4480 local MDC=$(lctl dl | awk '/MDT0001-mdc-[^M]/ { print $4 }')
4482 lctl --device %$MDC deactivate
4483 stack_trap "lctl --device %$MDC activate"
4484 ls $DIR/$tdir > /dev/null && error "ls should return an error"
4485 total=$(\ls -l $DIR/$tdir | wc -l)
4486 # "ls -l" will list total in the first line
4487 total=$((total - 1))
4488 (( total + count == 1000 )) ||
4489 error "ls list $total files, $count files on MDT1"
4491 run_test 33i "striped directory can be accessed when one MDT is down"
4494 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4496 mkdir -p $DIR/$tdir/
4498 $LFS setdirstripe -D -i0,1 $DIR/$tdir/striped_dir_a &&
4499 error "setdirstripe -D -i0,1 incorrectly succeeded"
4501 $LFS setdirstripe -D -i0,1 -c1 $DIR/$tdir/striped_dir_b &&
4502 error "setdirstripe -D -i0,1 -c1 incorrectly succeeded"
4504 $LFS setdirstripe -D -i0,1 -c3 $DIR/$tdir/striped_dir_c &&
4505 error "setdirstripe -D -i0,1 -c3 incorrectly succeeded"
4507 $LFS setdirstripe -i0,1 $DIR/$tdir/striped_dir_e ||
4508 error "-D was not specified, but still failed"
4510 run_test 33j "lfs setdirstripe -D -i x,y,x should fail"
4512 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4515 $MCREATE $DIR/f34 || error "mcreate failed"
4516 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4517 error "getstripe failed"
4518 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4519 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4520 error "getstripe failed"
4521 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4522 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4524 run_test 34a "truncate file that has not been opened ==========="
4527 [ ! -f $DIR/f34 ] && test_34a
4528 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4529 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4530 $OPENFILE -f O_RDONLY $DIR/f34
4531 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4532 error "getstripe failed"
4533 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4534 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4536 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4539 [ ! -f $DIR/f34 ] && test_34a
4540 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4541 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4542 $OPENFILE -f O_RDWR $DIR/f34
4543 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4544 error "$LFS getstripe failed"
4545 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4546 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4548 run_test 34c "O_RDWR opening file-with-size works =============="
4551 [ ! -f $DIR/f34 ] && test_34a
4552 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4554 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4555 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4558 run_test 34d "write to sparse file ============================="
4562 $MCREATE $DIR/f34e || error "mcreate failed"
4563 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4564 $CHECKSTAT -s 1000 $DIR/f34e ||
4565 error "Size of $DIR/f34e not equal to 1000 bytes"
4566 $OPENFILE -f O_RDWR $DIR/f34e
4567 $CHECKSTAT -s 1000 $DIR/f34e ||
4568 error "Size of $DIR/f34e not equal to 1000 bytes"
4570 run_test 34e "create objects, some with size and some without =="
4572 test_34f() { # bug 6242, 6243
4573 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4577 $MCREATE $DIR/f34f || error "mcreate failed"
4578 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4579 dd if=$DIR/f34f of=$TMP/f34f
4580 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4581 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4582 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4583 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4584 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4586 run_test 34f "read from a file with no objects until EOF ======="
4589 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4591 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4593 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4594 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4595 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4596 cancel_lru_locks osc
4597 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4598 error "wrong size after lock cancel"
4600 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4601 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4602 error "expanding truncate failed"
4603 cancel_lru_locks osc
4604 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4605 error "wrong expanded size after lock cancel"
4607 run_test 34g "truncate long file ==============================="
4610 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4615 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4616 sync # Flush the cache so that multiop below does not block on cache
4617 # flush when getting the group lock
4618 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4621 # Since just timed wait is not good enough, let's do a sync write
4622 # that way we are sure enough time for a roundtrip + processing
4623 # passed + 2 seconds of extra margin.
4624 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4628 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4629 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4633 local nsz=`stat -c %s $DIR/$tfile`
4634 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4636 run_test 34h "ftruncate file under grouplock should not block"
4639 cp /bin/sh $DIR/f35a
4641 chown $RUNAS_ID $DIR/f35a
4642 $RUNAS $DIR/f35a && error || true
4645 run_test 35a "exec file with mode 444 (should return and not leak)"
4649 utime $DIR/f36 || error "utime failed for MDS"
4651 run_test 36a "MDS utime check (mknod, utime)"
4655 utime $DIR/f36 || error "utime failed for OST"
4657 run_test 36b "OST utime check (open, utime)"
4662 chown $RUNAS_ID $DIR/d36
4663 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4665 run_test 36c "non-root MDS utime check (mknod, utime)"
4668 [ ! -d $DIR/d36 ] && test_36c
4669 echo "" > $DIR/d36/f36
4670 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4672 run_test 36d "non-root OST utime check (open, utime)"
4675 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4677 test_mkdir $DIR/$tdir
4678 touch $DIR/$tdir/$tfile
4679 $RUNAS utime $DIR/$tdir/$tfile &&
4680 error "utime worked, expected failure" || true
4682 run_test 36e "utime on non-owned file (should return error)"
4686 local LANG_SAVE=$LANG
4687 local LC_LANG_SAVE=$LC_LANG
4688 export LANG=C LC_LANG=C # for date language
4690 DATESTR="Dec 20 2000"
4691 test_mkdir $DIR/$tdir
4692 lctl set_param fail_loc=$fl
4694 cp /etc/hosts $DIR/$tdir/$tfile
4695 sync & # write RPC generated with "current" inode timestamp, but delayed
4697 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4698 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4699 cancel_lru_locks $OSC
4700 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4702 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4703 echo "BEFORE: $LS_BEFORE" && \
4704 echo "AFTER : $LS_AFTER" && \
4705 echo "WANT : $DATESTR" && \
4706 error "$DIR/$tdir/$tfile timestamps changed" || true
4708 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4712 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4714 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4715 subr_36fh "0x80000214"
4717 run_test 36f "utime on file racing with OST BRW write =========="
4720 remote_ost_nodsh && skip "remote OST with nodsh"
4721 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4722 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4723 skip "Need MDS version at least 2.12.51"
4728 local tgt="obdfilter"
4730 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4732 test_mkdir $DIR/$tdir
4733 fmd_max_age=$(do_facet $facet \
4734 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4737 echo "FMD max age: ${fmd_max_age}s"
4738 touch $DIR/$tdir/$tfile
4739 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4740 gawk '{cnt=cnt+$1} END{print cnt}')
4741 echo "FMD before: $fmd"
4743 error "FMD wasn't create by touch"
4744 sleep $((fmd_max_age + 12))
4745 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4746 gawk '{cnt=cnt+$1} END{print cnt}')
4747 echo "FMD after: $fmd"
4749 error "FMD wasn't expired by ping"
4751 run_test 36g "FMD cache expiry ====================="
4754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4756 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4757 subr_36fh "0x80000227"
4759 run_test 36h "utime on file racing with OST BRW write =========="
4762 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4764 test_mkdir $DIR/$tdir
4765 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4767 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4768 local new_mtime=$((mtime + 200))
4770 #change Modify time of striped dir
4771 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4772 error "change mtime failed"
4774 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4776 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4778 run_test 36i "change mtime on striped directory"
4780 # test_37 - duplicate with tests 32q 32r
4783 local file=$DIR/$tfile
4785 openfile -f O_DIRECTORY $file
4788 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4789 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4791 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4793 test_39a() { # was test_39
4795 touch $DIR/${tfile}2
4796 # ls -l $DIR/$tfile $DIR/${tfile}2
4797 # ls -lu $DIR/$tfile $DIR/${tfile}2
4798 # ls -lc $DIR/$tfile $DIR/${tfile}2
4800 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4801 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4803 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4805 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4807 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4808 error "O_TRUNC didn't change timestamps"
4811 run_test 39a "mtime changed on create"
4814 test_mkdir -c1 $DIR/$tdir
4815 cp -p /etc/passwd $DIR/$tdir/fopen
4816 cp -p /etc/passwd $DIR/$tdir/flink
4817 cp -p /etc/passwd $DIR/$tdir/funlink
4818 cp -p /etc/passwd $DIR/$tdir/frename
4819 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4822 echo "aaaaaa" >> $DIR/$tdir/fopen
4823 echo "aaaaaa" >> $DIR/$tdir/flink
4824 echo "aaaaaa" >> $DIR/$tdir/funlink
4825 echo "aaaaaa" >> $DIR/$tdir/frename
4827 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4828 local link_new=`stat -c %Y $DIR/$tdir/flink`
4829 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4830 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4832 cat $DIR/$tdir/fopen > /dev/null
4833 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4834 rm -f $DIR/$tdir/funlink2
4835 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4837 for (( i=0; i < 2; i++ )) ; do
4838 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4839 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4840 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4841 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4843 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4844 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4845 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4846 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4848 cancel_lru_locks $OSC
4849 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4852 run_test 39b "mtime change on open, link, unlink, rename ======"
4854 # this should be set to past
4855 TEST_39_MTIME=`date -d "1 year ago" +%s`
4861 local mtime0=`stat -c %Y $DIR1/$tfile`
4863 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4864 local mtime1=`stat -c %Y $DIR1/$tfile`
4865 [ "$mtime1" = $TEST_39_MTIME ] || \
4866 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4869 echo hello >> $DIR1/$tfile
4871 local mtime2=`stat -c %Y $DIR1/$tfile`
4872 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4873 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4875 mv $DIR1/$tfile $DIR1/$tfile-1
4877 for (( i=0; i < 2; i++ )) ; do
4878 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4879 [ "$mtime2" = "$mtime3" ] || \
4880 error "mtime ($mtime2) changed (to $mtime3) on rename"
4882 cancel_lru_locks $OSC
4883 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4886 run_test 39c "mtime change on rename ==========================="
4890 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4893 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4895 for (( i=0; i < 2; i++ )) ; do
4896 local mtime=`stat -c %Y $DIR1/$tfile`
4897 [ $mtime = $TEST_39_MTIME ] || \
4898 error "mtime($mtime) is not set to $TEST_39_MTIME"
4900 cancel_lru_locks $OSC
4901 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4904 run_test 39d "create, utime, stat =============================="
4908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4911 local mtime1=`stat -c %Y $DIR1/$tfile`
4913 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4915 for (( i=0; i < 2; i++ )) ; do
4916 local mtime2=`stat -c %Y $DIR1/$tfile`
4917 [ $mtime2 = $TEST_39_MTIME ] || \
4918 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4920 cancel_lru_locks $OSC
4921 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4924 run_test 39e "create, stat, utime, stat ========================"
4928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4931 mtime1=`stat -c %Y $DIR1/$tfile`
4934 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4936 for (( i=0; i < 2; i++ )) ; do
4937 local mtime2=`stat -c %Y $DIR1/$tfile`
4938 [ $mtime2 = $TEST_39_MTIME ] || \
4939 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4941 cancel_lru_locks $OSC
4942 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4945 run_test 39f "create, stat, sleep, utime, stat ================="
4949 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4951 echo hello >> $DIR1/$tfile
4952 local mtime1=`stat -c %Y $DIR1/$tfile`
4955 chmod o+r $DIR1/$tfile
4957 for (( i=0; i < 2; i++ )) ; do
4958 local mtime2=`stat -c %Y $DIR1/$tfile`
4959 [ "$mtime1" = "$mtime2" ] || \
4960 error "lost mtime: $mtime2, should be $mtime1"
4962 cancel_lru_locks $OSC
4963 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4966 run_test 39g "write, chmod, stat ==============================="
4970 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4976 echo hello >> $DIR1/$tfile
4977 local mtime1=`stat -c %Y $DIR1/$tfile`
4979 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4981 if [ "$d1" != "$d2" ]; then
4982 echo "write and touch not within one second"
4984 for (( i=0; i < 2; i++ )) ; do
4985 local mtime2=`stat -c %Y $DIR1/$tfile`
4986 [ "$mtime2" = $TEST_39_MTIME ] || \
4987 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4989 cancel_lru_locks $OSC
4990 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4994 run_test 39h "write, utime within one second, stat ============="
4997 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5002 echo hello >> $DIR1/$tfile
5003 local mtime1=`stat -c %Y $DIR1/$tfile`
5005 mv $DIR1/$tfile $DIR1/$tfile-1
5007 for (( i=0; i < 2; i++ )) ; do
5008 local mtime2=`stat -c %Y $DIR1/$tfile-1`
5010 [ "$mtime1" = "$mtime2" ] || \
5011 error "lost mtime: $mtime2, should be $mtime1"
5013 cancel_lru_locks $OSC
5014 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5017 run_test 39i "write, rename, stat =============================="
5020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5022 start_full_debug_logging
5026 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
5027 lctl set_param fail_loc=0x80000412
5028 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
5029 error "multiop failed"
5031 local mtime1=`stat -c %Y $DIR1/$tfile`
5033 mv $DIR1/$tfile $DIR1/$tfile-1
5035 kill -USR1 $multipid
5036 wait $multipid || error "multiop close failed"
5038 for (( i=0; i < 2; i++ )) ; do
5039 local mtime2=`stat -c %Y $DIR1/$tfile-1`
5040 [ "$mtime1" = "$mtime2" ] ||
5041 error "mtime is lost on close: $mtime2, " \
5045 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5047 lctl set_param fail_loc=0
5048 stop_full_debug_logging
5050 run_test 39j "write, rename, close, stat ======================="
5053 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5058 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
5060 local mtime1=`stat -c %Y $DIR1/$tfile`
5062 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
5064 kill -USR1 $multipid
5065 wait $multipid || error "multiop close failed"
5067 for (( i=0; i < 2; i++ )) ; do
5068 local mtime2=`stat -c %Y $DIR1/$tfile`
5070 [ "$mtime2" = $TEST_39_MTIME ] || \
5071 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
5074 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5077 run_test 39k "write, utime, close, stat ========================"
5079 # this should be set to future
5080 TEST_39_ATIME=`date -d "1 year" +%s`
5083 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5084 remote_mds_nodsh && skip "remote MDS with nodsh"
5086 local atime_diff=$(do_facet $SINGLEMDS \
5087 lctl get_param -n mdd.*MDT0000*.atime_diff)
5089 mkdir_on_mdt0 $DIR/$tdir
5091 # test setting directory atime to future
5092 touch -a -d @$TEST_39_ATIME $DIR/$tdir
5093 local atime=$(stat -c %X $DIR/$tdir)
5094 [ "$atime" = $TEST_39_ATIME ] ||
5095 error "atime is not set to future: $atime, $TEST_39_ATIME"
5097 # test setting directory atime from future to now
5098 local now=$(date +%s)
5099 touch -a -d @$now $DIR/$tdir
5101 atime=$(stat -c %X $DIR/$tdir)
5102 [ "$atime" -eq "$now" ] ||
5103 error "atime is not updated from future: $atime, $now"
5105 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
5108 # test setting directory atime when now > dir atime + atime_diff
5109 local d1=$(date +%s)
5111 local d2=$(date +%s)
5112 cancel_lru_locks mdc
5113 atime=$(stat -c %X $DIR/$tdir)
5114 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5115 error "atime is not updated : $atime, should be $d2"
5117 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
5120 # test not setting directory atime when now < dir atime + atime_diff
5122 cancel_lru_locks mdc
5123 atime=$(stat -c %X $DIR/$tdir)
5124 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5125 error "atime is updated to $atime, should remain $d1<atime<$d2"
5127 do_facet $SINGLEMDS \
5128 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5130 run_test 39l "directory atime update ==========================="
5133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5137 local far_past_mtime=$(date -d "May 29 1953" +%s)
5138 local far_past_atime=$(date -d "Dec 17 1903" +%s)
5140 touch -m -d @$far_past_mtime $DIR1/$tfile
5141 touch -a -d @$far_past_atime $DIR1/$tfile
5143 for (( i=0; i < 2; i++ )) ; do
5144 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
5145 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
5146 error "atime or mtime set incorrectly"
5148 cancel_lru_locks $OSC
5149 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5152 run_test 39m "test atime and mtime before 1970"
5154 test_39n() { # LU-3832
5155 remote_mds_nodsh && skip "remote MDS with nodsh"
5157 local atime_diff=$(do_facet $SINGLEMDS \
5158 lctl get_param -n mdd.*MDT0000*.atime_diff)
5163 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
5166 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
5167 atime0=$(stat -c %X $DIR/$tfile)
5170 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5171 atime1=$(stat -c %X $DIR/$tfile)
5174 cancel_lru_locks mdc
5175 cancel_lru_locks osc
5176 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5177 atime2=$(stat -c %X $DIR/$tfile)
5179 do_facet $SINGLEMDS \
5180 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5182 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
5183 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
5185 run_test 39n "check that O_NOATIME is honored"
5188 TESTDIR=$DIR/$tdir/$tfile
5189 [ -e $TESTDIR ] && rm -rf $TESTDIR
5196 links2=$(stat -c %h .)
5197 [ $(($links1 + 2)) != $links2 ] &&
5198 error "wrong links count $(($links1 + 2)) != $links2"
5200 links3=$(stat -c %h .)
5201 [ $(($links1 + 1)) != $links3 ] &&
5202 error "wrong links count $links1 != $links3"
5205 run_test 39o "directory cached attributes updated after create"
5208 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
5211 TESTDIR=$DIR/$tdir/$tdir
5212 [ -e $TESTDIR ] && rm -rf $TESTDIR
5213 test_mkdir -p $TESTDIR
5217 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
5218 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
5220 links2=$(stat -c %h .)
5221 [ $(($links1 + 2)) != $links2 ] &&
5222 error "wrong links count $(($links1 + 2)) != $links2"
5224 links3=$(stat -c %h .)
5225 [ $(($links1 + 1)) != $links3 ] &&
5226 error "wrong links count $links1 != $links3"
5229 run_test 39p "remote directory cached attributes updated after create ========"
5232 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
5233 skip "no atime update on old OST"
5234 if [ "$ost1_FSTYPE" != ldiskfs ]; then
5235 skip_env "ldiskfs only test"
5239 saved_adiff=$(do_facet ost1 \
5240 lctl get_param -n obdfilter.*OST0000.atime_diff)
5241 stack_trap "do_facet ost1 \
5242 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
5244 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
5246 $LFS setstripe -i 0 $DIR/$tfile
5247 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
5248 error "can't write initial file"
5249 cancel_lru_locks osc
5251 # exceed atime_diff and access file
5253 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
5254 error "can't udpate atime"
5256 local atime_cli=$(stat -c %X $DIR/$tfile)
5257 echo "client atime: $atime_cli"
5258 # allow atime update to be written to device
5259 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
5262 local ostdev=$(ostdevname 1)
5263 local fid=($($LFS getstripe $DIR/$tfile | grep 0x))
5264 local seq=${fid[3]#0x}
5268 if [ $seq == 0 ]; then
5271 oid_hex=${fid[2]#0x}
5273 local objpath="O/$seq/d$(($oid % 32))/$oid_hex"
5274 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
5276 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
5277 local atime_ost=$(do_facet ost1 "$cmd" |&
5278 awk -F'[: ]' '/atime:/ { print $4 }')
5279 (( atime_cli == atime_ost )) ||
5280 error "atime on client $atime_cli != ost $atime_ost"
5282 run_test 39r "lazy atime update on OST"
5284 test_39q() { # LU-8041
5285 local testdir=$DIR/$tdir
5287 multiop_bg_pause $testdir D_c || error "multiop failed"
5289 cancel_lru_locks mdc
5290 kill -USR1 $multipid
5291 local atime=$(stat -c %X $testdir)
5292 [ "$atime" -ne 0 ] || error "atime is zero"
5294 run_test 39q "close won't zero out atime"
5303 umount_client $MOUNT
5304 mount_client $MOUNT relatime
5306 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer conv=fsync
5307 atime0=$(stat -c %X $DIR/$tfile)
5309 # First read updates atime
5311 cat $DIR/$tfile >/dev/null
5312 atime1=$(stat -c %X $DIR/$tfile) # (atime = atime0 + 1)
5314 # Next reads do not update atime
5316 cat $DIR/$tfile >/dev/null
5317 atime2=$(stat -c %X $DIR/$tfile) # (atime = atime0 + 1)
5319 # If mtime is greater than atime, atime is updated
5321 touch -m $DIR/$tfile # (mtime = now)
5323 cat $DIR/$tfile >/dev/null # (atime is updated because atime < mtime)
5324 atime3=$(stat -c %X $DIR/$tfile) # (atime = mtime = atime0 + 3)
5326 # Next reads do not update atime
5328 cat $DIR/$tfile >/dev/null
5329 atime4=$(stat -c %X $DIR/$tfile)
5331 # Remount the client to clear 'relatime' option
5332 remount_client $MOUNT
5334 (( atime0 < atime1 )) ||
5335 error "atime $atime0 should be smaller than $atime1"
5336 (( atime1 == atime2 )) ||
5337 error "atime $atime1 was updated to $atime2"
5338 (( atime1 < atime3 )) || error "atime1 $atime1 != atime3 $atime3"
5339 (( atime3 == atime4 )) || error "atime3 $atime3 != atime4 $atime4"
5341 run_test 39s "relatime is supported"
5344 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5345 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5346 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5347 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5348 error "$tfile is not 4096 bytes in size"
5350 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5354 small_write $DIR/f41 18
5356 run_test 41 "test small file write + fstat ====================="
5358 count_ost_writes() {
5359 lctl get_param -n ${OSC}.*.stats |
5360 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5361 END { printf("%0.0f", writes) }'
5368 BG_DIRTY_RATIO_SAVE=10
5369 MAX_BG_DIRTY_RATIO=25
5373 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5374 # dirty_ratio, dirty_background_ratio
5375 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5376 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5377 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5378 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5380 # if file not here, we are a 2.4 kernel
5381 kill -CONT `pidof kupdated`
5386 # setup the trap first, so someone cannot exit the test at the
5387 # exact wrong time and mess up a machine
5388 trap start_writeback EXIT
5389 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5390 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5391 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5392 sysctl -w vm.dirty_writeback_centisecs=0
5393 sysctl -w vm.dirty_writeback_centisecs=0
5394 # save and increase /proc/sys/vm/dirty_ratio
5395 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5396 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5397 # save and increase /proc/sys/vm/dirty_background_ratio
5398 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5399 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5401 # if file not here, we are a 2.4 kernel
5402 kill -STOP `pidof kupdated`
5406 # ensure that all stripes have some grant before we test client-side cache
5408 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5409 dd if=/dev/zero of=$i bs=4k count=1
5414 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5415 # file truncation, and file removal.
5417 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5420 cancel_lru_locks $OSC
5422 sync; sleep 1; sync # just to be safe
5423 BEFOREWRITES=`count_ost_writes`
5424 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5425 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5426 AFTERWRITES=`count_ost_writes`
5427 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5428 error "$BEFOREWRITES < $AFTERWRITES"
5431 run_test 42a "ensure that we don't flush on close"
5434 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5437 cancel_lru_locks $OSC
5440 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5441 BEFOREWRITES=$(count_ost_writes)
5442 unlink $DIR/f42b || error "unlink $DIR/f42b: $?"
5443 AFTERWRITES=$(count_ost_writes)
5444 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5445 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5447 BEFOREWRITES=$(count_ost_writes)
5448 sync || error "sync: $?"
5449 AFTERWRITES=$(count_ost_writes)
5450 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5451 error "$BEFOREWRITES < $AFTERWRITES on sync"
5453 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5457 run_test 42b "test destroy of file with cached dirty data ======"
5459 # if these tests just want to test the effect of truncation,
5460 # they have to be very careful. consider:
5461 # - the first open gets a {0,EOF}PR lock
5462 # - the first write conflicts and gets a {0, count-1}PW
5463 # - the rest of the writes are under {count,EOF}PW
5464 # - the open for truncate tries to match a {0,EOF}PR
5465 # for the filesize and cancels the PWs.
5466 # any number of fixes (don't get {0,EOF} on open, match
5467 # composite locks, do smarter file size management) fix
5468 # this, but for now we want these tests to verify that
5469 # the cancellation with truncate intent works, so we
5470 # start the file with a full-file pw lock to match against
5471 # until the truncate.
5476 cancel_lru_locks $OSC
5478 # prime the file with 0,EOF PW to match
5482 # now the real test..
5483 dd if=/dev/zero of=$file bs=1024 count=100
5484 BEFOREWRITES=`count_ost_writes`
5485 $TRUNCATE $file $offset
5486 cancel_lru_locks $OSC
5487 AFTERWRITES=`count_ost_writes`
5492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5495 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5496 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5499 run_test 42c "test partial truncate of file with cached dirty data"
5502 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5504 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
5505 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
5506 $LCTL set_param debug=+cache
5509 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5510 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5513 run_test 42d "test complete truncate of file with cached dirty data"
5515 test_42e() { # bug22074
5516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5518 local TDIR=$DIR/${tdir}e
5519 local pages=16 # hardcoded 16 pages, don't change it.
5520 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5521 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5525 test_mkdir $DIR/${tdir}e
5526 $LFS setstripe -c 1 $TDIR
5527 createmany -o $TDIR/f $files
5529 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5531 # we assume that with $OSTCOUNT files, at least one of them will
5532 # be allocated on OST0.
5533 warmup_files=$((OSTCOUNT * max_dirty_mb))
5534 createmany -o $TDIR/w $warmup_files
5536 # write a large amount of data into one file and sync, to get good
5537 # avail_grant number from OST.
5538 for ((i=0; i<$warmup_files; i++)); do
5539 idx=$($LFS getstripe -i $TDIR/w$i)
5540 [ $idx -ne 0 ] && continue
5541 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5544 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5546 $LCTL get_param $proc_osc0/cur_dirty_bytes
5547 $LCTL get_param $proc_osc0/cur_grant_bytes
5549 # create as much dirty pages as we can while not to trigger the actual
5550 # RPCs directly. but depends on the env, VFS may trigger flush during this
5551 # period, hopefully we are good.
5552 for ((i=0; i<$warmup_files; i++)); do
5553 idx=$($LFS getstripe -i $TDIR/w$i)
5554 [ $idx -ne 0 ] && continue
5555 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5557 $LCTL get_param $proc_osc0/cur_dirty_bytes
5558 $LCTL get_param $proc_osc0/cur_grant_bytes
5560 # perform the real test
5561 $LCTL set_param $proc_osc0/rpc_stats 0
5562 for ((;i<$files; i++)); do
5563 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5564 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5567 $LCTL get_param $proc_osc0/rpc_stats
5570 local have_ppr=false
5571 $LCTL get_param $proc_osc0/rpc_stats |
5572 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5573 # skip lines until we are at the RPC histogram data
5574 [ "$PPR" == "pages" ] && have_ppr=true && continue
5575 $have_ppr || continue
5577 # we only want the percent stat for < 16 pages
5578 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5580 percent=$((percent + WPCT))
5581 if [[ $percent -gt 15 ]]; then
5582 error "less than 16-pages write RPCs" \
5589 run_test 42e "verify sub-RPC writes are not done synchronously"
5591 test_43A() { # was test_43
5592 test_mkdir $DIR/$tdir
5593 cp -p /bin/ls $DIR/$tdir/$tfile
5594 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5596 # give multiop a chance to open
5599 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5601 # Wait for multiop to exit
5604 run_test 43A "execution of file opened for write should return -ETXTBSY"
5607 test_mkdir $DIR/$tdir
5608 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5609 $DIR/$tdir/sleep 60 &
5611 # Make sure exec of $tdir/sleep wins race with truncate
5613 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5616 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5619 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5621 test_mkdir $DIR/$tdir
5622 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5623 $DIR/$tdir/sleep 60 &
5625 # Make sure exec of $tdir/sleep wins race with truncate
5627 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5630 run_test 43b "truncate of file being executed should return -ETXTBSY"
5633 local testdir="$DIR/$tdir"
5636 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5637 ( cd $testdir && md5sum -c )
5639 run_test 43c "md5sum of copy into lustre"
5641 test_44A() { # was test_44
5642 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5644 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5645 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5647 run_test 44A "zero length read from a sparse stripe"
5650 local nstripe=$($LFS getstripe -c -d $DIR)
5651 [ -z "$nstripe" ] && skip "can't get stripe info"
5652 [[ $nstripe -gt $OSTCOUNT ]] &&
5653 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5655 local stride=$($LFS getstripe -S -d $DIR)
5656 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5657 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5660 OFFSETS="0 $((stride/2)) $((stride-1))"
5661 for offset in $OFFSETS; do
5662 for i in $(seq 0 $((nstripe-1))); do
5663 local GLOBALOFFSETS=""
5665 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5666 local myfn=$DIR/d44a-$size
5667 echo "--------writing $myfn at $size"
5668 ll_sparseness_write $myfn $size ||
5669 error "ll_sparseness_write"
5670 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5671 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5672 error "ll_sparseness_verify $GLOBALOFFSETS"
5674 for j in $(seq 0 $((nstripe-1))); do
5676 size=$((((j + $nstripe )*$stride + $offset)))
5677 ll_sparseness_write $myfn $size ||
5678 error "ll_sparseness_write"
5679 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5681 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5682 error "ll_sparseness_verify $GLOBALOFFSETS"
5687 run_test 44a "test sparse pwrite ==============================="
5691 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5697 before=`dirty_osc_total`
5698 echo executing "\"$*\""
5700 after=`dirty_osc_total`
5701 echo before $before, after $after
5704 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5707 # Obtain grants from OST if it supports it
5708 echo blah > ${f}_grant
5711 do_dirty_record "echo blah > $f"
5712 [[ $before -eq $after ]] && error "write wasn't cached"
5713 do_dirty_record "> $f"
5714 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5715 do_dirty_record "echo blah > $f"
5716 [[ $before -eq $after ]] && error "write wasn't cached"
5717 do_dirty_record "sync"
5718 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5719 do_dirty_record "echo blah > $f"
5720 [[ $before -eq $after ]] && error "write wasn't cached"
5721 do_dirty_record "cancel_lru_locks osc"
5722 [[ $before -gt $after ]] ||
5723 error "lock cancellation didn't lower dirty count"
5726 run_test 45 "osc io page accounting ============================"
5728 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5729 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5730 # objects offset and an assert hit when an rpc was built with 1023's mapped
5731 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5733 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5738 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5740 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5741 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5745 run_test 46 "dirtying a previously written page ================"
5747 # test_47 is removed "Device nodes check" is moved to test_28
5749 test_48a() { # bug 2399
5750 [ "$mds1_FSTYPE" = "zfs" ] &&
5751 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5752 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5754 test_mkdir $DIR/$tdir
5756 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5757 test_mkdir $DIR/$tdir
5758 touch foo || error "'touch foo' failed after recreating cwd"
5760 touch .foo || error "'touch .foo' failed after recreating cwd"
5762 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5763 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5764 cd . || error "'cd .' failed after recreating cwd"
5765 mkdir . && error "'mkdir .' worked after recreating cwd"
5766 rmdir . && error "'rmdir .' worked after recreating cwd"
5767 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5768 cd .. || error "'cd ..' failed after recreating cwd"
5770 run_test 48a "Access renamed working dir (should return errors)="
5772 test_48b() { # bug 2399
5774 test_mkdir $DIR/$tdir
5776 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5777 touch foo && error "'touch foo' worked after removing cwd"
5778 mkdir foo && error "'mkdir foo' worked after removing cwd"
5779 touch .foo && error "'touch .foo' worked after removing cwd"
5780 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5781 ls . > /dev/null && error "'ls .' worked after removing cwd"
5782 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5783 mkdir . && error "'mkdir .' worked after removing cwd"
5784 rmdir . && error "'rmdir .' worked after removing cwd"
5785 ln -s . foo && error "'ln -s .' worked after removing cwd"
5786 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5788 run_test 48b "Access removed working dir (should return errors)="
5790 test_48c() { # bug 2350
5791 #lctl set_param debug=-1
5794 test_mkdir -p $DIR/$tdir/dir
5796 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5797 $TRACE touch foo && error "touch foo worked after removing cwd"
5798 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5799 touch .foo && error "touch .foo worked after removing cwd"
5800 mkdir .foo && error "mkdir .foo worked after removing cwd"
5801 $TRACE ls . && error "'ls .' worked after removing cwd"
5802 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5803 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5804 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5805 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5806 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5808 run_test 48c "Access removed working subdir (should return errors)"
5810 test_48d() { # bug 2350
5811 #lctl set_param debug=-1
5814 test_mkdir -p $DIR/$tdir/dir
5816 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5817 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5818 $TRACE touch foo && error "'touch foo' worked after removing parent"
5819 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5820 touch .foo && error "'touch .foo' worked after removing parent"
5821 mkdir .foo && error "mkdir .foo worked after removing parent"
5822 $TRACE ls . && error "'ls .' worked after removing parent"
5823 $TRACE ls .. && error "'ls ..' worked after removing parent"
5824 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5825 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5826 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5829 run_test 48d "Access removed parent subdir (should return errors)"
5831 test_48e() { # bug 4134
5832 #lctl set_param debug=-1
5835 test_mkdir -p $DIR/$tdir/dir
5837 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5838 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5839 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5840 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5841 # On a buggy kernel addition of "touch foo" after cd .. will
5842 # produce kernel oops in lookup_hash_it
5843 touch ../foo && error "'cd ..' worked after recreate parent"
5845 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5847 run_test 48e "Access to recreated parent subdir (should return errors)"
5850 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5851 skip "need MDS >= 2.13.55"
5852 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5853 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5854 skip "needs different host for mdt1 mdt2"
5855 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5857 $LFS mkdir -i0 $DIR/$tdir
5858 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5860 for d in sub1 sub2 sub3; do
5861 #define OBD_FAIL_OSD_REF_DEL 0x19c
5862 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5863 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5866 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5868 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5870 test_49() { # LU-1030
5871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5872 remote_ost_nodsh && skip "remote OST with nodsh"
5874 # get ost1 size - $FSNAME-OST0000
5875 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5877 # write 800M at maximum
5878 [[ $ost1_size -lt 2 ]] && ost1_size=2
5879 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5881 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5882 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5885 # change max_pages_per_rpc while writing the file
5886 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5887 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5888 # loop until dd process exits
5889 while ps ax -opid | grep -wq $dd_pid; do
5890 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5891 sleep $((RANDOM % 5 + 1))
5893 # restore original max_pages_per_rpc
5894 $LCTL set_param $osc1_mppc=$orig_mppc
5895 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5897 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5901 test_mkdir $DIR/$tdir
5903 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5905 run_test 50 "special situations: /proc symlinks ==============="
5907 test_51a() { # was test_51
5908 # bug 1516 - create an empty entry right after ".." then split dir
5909 test_mkdir -c1 $DIR/$tdir
5910 touch $DIR/$tdir/foo
5911 $MCREATE $DIR/$tdir/bar
5913 createmany -m $DIR/$tdir/longfile 201
5915 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5916 $MCREATE $DIR/$tdir/longfile$FNUM
5921 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5923 run_test 51a "special situations: split htree with empty entry =="
5925 cleanup_print_lfs_df () {
5932 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5934 local dir=$DIR/$tdir
5935 local nrdirs=$((65536 + 100))
5937 # cleanup the directory
5940 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5944 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5945 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5946 [[ $numfree -lt $nrdirs ]] &&
5947 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5949 # need to check free space for the directories as well
5950 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5951 numfree=$(( blkfree / $(fs_inode_ksize) ))
5952 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5954 trap cleanup_print_lfs_df EXIT
5957 createmany -d $dir/d $nrdirs || {
5958 unlinkmany $dir/d $nrdirs
5959 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5963 nrdirs=$(ls -U $dir | wc -l)
5965 # unlink all but 100 subdirectories, then check it still works
5967 local delete=$((nrdirs - left))
5972 # for ldiskfs the nlink count should be 1, but this is OSD specific
5973 # and so this is listed for informational purposes only
5974 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5975 unlinkmany -d $dir/d $delete ||
5976 error "unlink of first $delete subdirs failed"
5978 echo "nlink between: $(stat -c %h $dir)"
5979 local found=$(ls -U $dir | wc -l)
5980 [ $found -ne $left ] &&
5981 error "can't find subdirs: found only $found, expected $left"
5983 unlinkmany -d $dir/d $delete $left ||
5984 error "unlink of second $left subdirs failed"
5985 # regardless of whether the backing filesystem tracks nlink accurately
5986 # or not, the nlink count shouldn't be more than "." and ".." here
5987 local after=$(stat -c %h $dir)
5988 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5989 echo "nlink after: $after"
5991 cleanup_print_lfs_df
5993 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5996 local stripecount=$1
5999 log "create files with stripecount=$stripecount"
6000 $LFS setstripe -C $stripecount $DIR/$tdir
6001 createmany -o $DIR/$tdir/t- $nfiles
6002 $LFS getstripe $DIR/$tdir > $TMP/$tfile
6003 for ((n = 0; n < $OSTCOUNT; n++)); do
6004 objs[$n]=$(awk -vobjs=0 '($1 == '$n') { objs += 1 } \
6005 END { printf("%0.0f", objs) }' $TMP/$tfile)
6006 objs0[$n]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
6007 '($1 == '$n') { objs += 1 } \
6008 END { printf("%0.0f", objs) }')
6009 log "OST$n has ${objs[$n]} objects, ${objs0[$n]} are index 0"
6011 unlinkmany $DIR/$tdir/t- $nfiles
6016 local max=6 # allow variance of (1 - $min/$max) = 33% by default
6018 # For some combinations of stripecount and OSTCOUNT current code
6019 # is not ideal, and allocates 50% fewer *first* objects to some OSTs
6020 # than others. Rather than skipping this test entirely, check that
6021 # and keep testing to ensure imbalance does not get worse. LU-15282
6022 (( (OSTCOUNT == 6 && stripecount == 4) ||
6023 (OSTCOUNT == 10 && (stripecount == 4 || stripecount == 8)) ||
6024 (OSTCOUNT == 12 && (stripecount == 8 || stripecount == 9)))) && max=9
6025 for ((nlast=0, n = 1; n < $OSTCOUNT; nlast=n,n++)); do
6026 (( ${objs[$n]} > ${objs[$nlast]} * 4 / 5 )) ||
6027 { $LFS df && $LFS df -i &&
6028 error "stripecount=$stripecount: " \
6029 "OST $n has fewer objects vs. OST $nlast " \
6030 "(${objs[$n]} < ${objs[$nlast]} x 4/5)"; }
6031 (( ${objs[$n]} < ${objs[$nlast]} * 5 / 4 )) ||
6032 { $LFS df && $LFS df -i &&
6033 error "stripecount=$stripecount: " \
6034 "OST $n has more objects vs. OST $nlast " \
6035 "(${objs[$n]} > ${objs[$nlast]} x 5/4)"; }
6037 (( ${objs0[$n]} > ${objs0[$nlast]} * $min / $max )) ||
6038 { $LFS df && $LFS df -i &&
6039 error "stripecount=$stripecount: " \
6040 "OST $n has fewer #0 objects vs. OST $nlast " \
6041 "(${objs0[$n]} < ${objs0[$nlast]} x $min/$max)"; }
6042 (( ${objs0[$n]} < ${objs0[$nlast]} * $max / $min )) ||
6043 { $LFS df && $LFS df -i &&
6044 error "stripecount=$stripecount: " \
6045 "OST $n has more #0 objects vs. OST $nlast " \
6046 "(${objs0[$n]} > ${objs0[$nlast]} x $max/$min)"; }
6051 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6052 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
6056 local nfiles=$((per_ost * OSTCOUNT))
6057 local mdts=$(comma_list $(mdts_nodes))
6058 local param="osp.*.create_count"
6059 local qos_old=$(do_facet mds1 \
6060 "$LCTL get_param -n lod.$FSNAME-*.qos_threshold_rr" | head -n 1)
6063 "$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=100"
6064 stack_trap "do_nodes $mdts \
6065 '$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=${qos_old%%%}'"
6067 test_mkdir $DIR/$tdir
6068 local dirstripes=$(lfs getdirstripe -c $DIR/$tdir)
6069 (( dirstripes > 0 )) || dirstripes=1
6071 # Ensure enough OST objects precreated for tests to pass without
6072 # running out of objects. This is an LOV r-r OST algorithm test,
6073 # not an OST object precreation test.
6074 local old=$(do_facet mds1 "$LCTL get_param -n $param" | head -n 1)
6075 (( old >= nfiles )) ||
6077 local create_count=$((nfiles * OSTCOUNT / dirstripes))
6079 do_nodes $mdts "$LCTL set_param $param=$create_count"
6080 stack_trap "do_nodes $mdts $LCTL set_param $param=$old"
6082 # trigger precreation from all MDTs for all OSTs
6083 for ((i = 0; i < $MDSCOUNT * 2; i++ )); do
6084 $LFS setstripe -c -1 $DIR/$tdir/wide.$i
6088 for ((stripecount = 3; stripecount <= $OSTCOUNT; stripecount++)); do
6089 sleep 8 # allow object precreation to catch up
6090 test_51d_sub $stripecount $nfiles
6093 run_test 51d "check LOV round-robin OST object distribution"
6096 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6097 skip_env "ldiskfs only test"
6100 test_mkdir -c1 $DIR/$tdir
6101 test_mkdir -c1 $DIR/$tdir/d0
6103 touch $DIR/$tdir/d0/foo
6104 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
6105 error "file exceed 65000 nlink limit!"
6106 unlinkmany $DIR/$tdir/d0/f- 65001
6109 run_test 51e "check file nlink limit"
6112 test_mkdir $DIR/$tdir
6115 local ulimit_old=$(ulimit -n)
6116 local spare=20 # number of spare fd's for scripts/libraries, etc.
6117 local mdt=$($LFS getstripe -m $DIR/$tdir)
6118 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
6120 echo "MDT$mdt numfree=$numfree, max=$max"
6121 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
6122 if [ $((numfree + spare)) -gt $ulimit_old ]; then
6123 while ! ulimit -n $((numfree + spare)); do
6124 numfree=$((numfree * 3 / 4))
6126 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
6128 echo "left ulimit at $ulimit_old"
6131 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
6132 unlinkmany $DIR/$tdir/f $numfree
6133 error "create+open $numfree files in $DIR/$tdir failed"
6135 ulimit -n $ulimit_old
6137 # if createmany exits at 120s there will be fewer than $numfree files
6138 unlinkmany $DIR/$tdir/f $numfree || true
6140 run_test 51f "check many open files limit"
6143 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
6144 test_mkdir $DIR/$tdir
6145 touch $DIR/$tdir/foo
6146 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
6147 echo bar >> $DIR/$tdir/foo || error "append bar failed"
6148 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6149 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6150 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6152 echo foo >> $DIR/$tdir/foo || error "append foo failed"
6153 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6154 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
6156 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
6157 cp -r $DIR/$tdir $TMP/
6158 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
6160 run_test 52a "append-only flag test (should return errors)"
6163 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
6164 test_mkdir $DIR/$tdir
6165 touch $DIR/$tdir/foo
6166 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
6167 cat test > $DIR/$tdir/foo && error "cat test worked"
6168 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6169 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6170 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6172 echo foo >> $DIR/$tdir/foo && error "echo worked"
6173 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6174 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
6175 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
6176 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
6178 chattr -i $DIR/$tdir/foo || error "chattr failed"
6180 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
6182 run_test 52b "immutable flag test (should return errors) ======="
6185 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6186 remote_mds_nodsh && skip "remote MDS with nodsh"
6187 remote_ost_nodsh && skip "remote OST with nodsh"
6200 local support_last_seq=true
6202 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
6203 support_last_seq=false
6206 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
6208 for value in $(do_facet $SINGLEMDS \
6209 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
6210 param=$(echo ${value[0]} | cut -d "=" -f1)
6211 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
6213 if $support_last_seq; then
6214 param_seq=$(echo $param |
6215 sed -e s/prealloc_last_id/prealloc_last_seq/g)
6216 mds_last_seq=$(do_facet $SINGLEMDS \
6217 $LCTL get_param -n $param_seq)
6219 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
6221 ostnum=$(index_from_ostuuid ${ostname}_UUID)
6222 node=$(facet_active_host ost$((ostnum+1)))
6223 param="obdfilter.$ostname.last_id"
6224 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
6225 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
6226 ost_last_id=$ost_last
6228 if $support_last_seq; then
6229 ost_last_id=$(echo $ost_last |
6230 awk -F':' '{print $2}' |
6232 ost_last_seq=$(echo $ost_last |
6233 awk -F':' '{print $1}')
6234 [[ $ost_last_seq = $mds_last_seq ]] || continue
6237 if [[ $ost_last_id != $mds_last ]]; then
6238 error "$ost_last_id != $mds_last"
6245 $found || error "can not match last_seq/last_id for $mdtosc"
6248 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
6251 LANG=C perl -MSocket -e ';' || skip "no Socket perl module installed"
6253 LANG=C $SOCKETSERVER $DIR/socket ||
6254 error "$SOCKETSERVER $DIR/socket failed: $?"
6255 LANG=C $SOCKETCLIENT $DIR/socket ||
6256 error "$SOCKETCLIENT $DIR/socket failed: $?"
6257 unlink $DIR/socket || error "unlink $DIR/socket failed: $?"
6259 run_test 54a "unix domain socket test =========================="
6265 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
6267 run_test 54b "char device works in lustre ======================"
6270 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
6271 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
6272 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
6274 for i in $(seq 3 7); do
6275 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
6284 loopdev="$DIR/loop54c"
6287 $UMOUNT $DIR/$tdir || rc=$?
6288 losetup -d $loopdev || true
6289 losetup -d $LOOPDEV || true
6290 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
6295 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6297 loopdev="$DIR/loop54c"
6300 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
6301 trap cleanup_54c EXIT
6302 mknod $loopdev b 7 $LOOPNUM
6303 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
6304 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
6305 losetup $loopdev $DIR/$tfile ||
6306 error "can't set up $loopdev for $DIR/$tfile"
6307 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
6308 test_mkdir $DIR/$tdir
6309 mount -t ext2 $loopdev $DIR/$tdir ||
6310 error "error mounting $loopdev on $DIR/$tdir"
6311 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
6314 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
6318 run_test 54c "block device works in lustre ====================="
6321 local pipe="$DIR/$tfile.pipe"
6322 local string="aaaaaa"
6325 echo -n "$string" > $pipe &
6326 local result=$(cat $pipe)
6327 [[ "$result" == "$string" ]] || error "$result != $string"
6329 run_test 54d "fifo device works in lustre ======================"
6334 cp -aL /dev/console $f
6335 echo $string > $f || error "echo $string to $f failed"
6337 run_test 54e "console/tty device works in lustre ======================"
6340 local dev_path="/sys/kernel/debug/lustre/devices"
6342 load_module obdclass/obd_test verbose=2 || error "load_module failed"
6344 # This must be run in iteractive mode, since attach and setup
6346 eval "$LCTL <<-EOF || error 'OBD device creation failed'
6347 attach obd_test obd_name obd_uuid
6352 cat "$dev_path" | tail -n 10
6354 $LCTL --device "obd_name" cleanup
6355 $LCTL --device "obd_name" detach
6357 dmesg | tail -n 25 | grep "Lustre: OBD:.*FAIL" &&
6358 error "OBD unit test failed"
6360 rmmod -v obd_test ||
6361 error "rmmod failed (may trigger a failure in a later test)"
6363 run_test 55a "OBD device life cycle unit tests"
6366 local dev_path="/sys/kernel/debug/lustre/devices"
6367 local dev_count="$(wc -l $dev_path | awk '{print $1}')"
6368 local num_dev_to_create="$((8192 - $dev_count))"
6370 load_module obdclass/obd_test || error "load_module failed"
6372 local start=$SECONDS
6374 # This must be run in iteractive mode, since attach and setup
6376 for ((i = 1; i <= num_dev_to_create; i++)); do
6377 echo "attach obd_test obd_name_$i obd_uuid_$i"
6378 echo "setup obd_test_$i"
6379 done | $LCTL || error "OBD device creation failed"
6381 echo "Load time: $((SECONDS - start))"
6383 cat "$dev_path" | tail -n 10
6385 for ((i = 1; i <= num_dev_to_create; i++)); do
6386 echo "--device obd_name_$i cleanup"
6387 echo "--device obd_name_$i detach"
6388 done | $LCTL || error "OBD device cleanup failed"
6390 echo "Unload time: $((SECONDS - start))"
6392 rmmod -v obd_test ||
6393 error "rmmod failed (may trigger a failure in a later test)"
6395 run_test 55b "Load and unload max OBD devices"
6400 local dir=$DIR/$tdir
6403 test_mkdir -p $dir/dir
6404 for i in $(seq $numfiles); do
6406 touch $dir/dir/file$i
6409 local numcomp=$($LFS getstripe --component-count $dir)
6411 [[ $numcomp == 0 ]] && numcomp=1
6413 # test lfs getstripe with --recursive
6414 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
6416 [[ $filenum -eq $((numfiles * 2)) ]] ||
6417 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
6418 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
6419 [[ $filenum -eq $numfiles ]] ||
6420 error "$LFS getstripe $dir: found $filenum, not $numfiles"
6421 echo "$LFS getstripe showed obdidx or l_ost_idx"
6423 # test lfs getstripe with file instead of dir
6424 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
6425 [[ $filenum -eq 1 ]] ||
6426 error "$LFS getstripe $dir/file1: found $filenum, not 1"
6427 echo "$LFS getstripe file1 passed"
6429 #test lfs getstripe with --verbose
6430 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
6431 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
6432 error "$LFS getstripe --verbose $dir: "\
6433 "got $filenum want $((numfiles * numcomp)) lmm_magic"
6434 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
6435 error "$LFS getstripe $dir: showed lmm_magic"
6437 #test lfs getstripe with -v prints lmm_fid
6438 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
6439 local countfids=$((numdirs + numfiles * numcomp))
6440 [[ $filenum -eq $countfids ]] ||
6441 error "$LFS getstripe -v $dir: "\
6442 "got $filenum want $countfids lmm_fid"
6443 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
6444 error "$LFS getstripe $dir: showed lmm_fid by default"
6445 echo "$LFS getstripe --verbose passed"
6447 #check for FID information
6448 local fid1=$($LFS getstripe --fid $dir/file1)
6449 local fid2=$($LFS getstripe --verbose $dir/file1 |
6450 awk '/lmm_fid: / { print $2; exit; }')
6451 local fid3=$($LFS path2fid $dir/file1)
6453 [ "$fid1" != "$fid2" ] &&
6454 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
6455 [ "$fid1" != "$fid3" ] &&
6456 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
6457 echo "$LFS getstripe --fid passed"
6459 #test lfs getstripe with --obd
6460 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6461 error "$LFS getstripe --obd wrong_uuid: should return error"
6463 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6466 local obduuid=$(ostuuid_from_index $ostidx)
6467 local found=$($LFS getstripe -r --obd $obduuid $dir |
6468 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6470 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6471 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6473 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6476 [[ $found -eq $filenum ]] ||
6477 error "$LFS getstripe --obd: found $found expect $filenum"
6478 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6479 sed '/^[ ]*'${ostidx}'[ ]/d' |
6480 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6481 error "$LFS getstripe --obd: should not show file on other obd"
6482 echo "$LFS getstripe --obd passed"
6484 run_test 56a "check $LFS getstripe"
6487 local dir=$DIR/$tdir
6491 for i in $(seq $numdirs); do
6492 test_mkdir $dir/dir$i
6495 # test lfs getdirstripe default mode is non-recursion, which is
6496 # different from lfs getstripe
6497 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6499 [[ $dircnt -eq 1 ]] ||
6500 error "$LFS getdirstripe: found $dircnt, not 1"
6501 dircnt=$($LFS getdirstripe --recursive $dir |
6502 grep -c lmv_stripe_count)
6503 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6504 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6506 run_test 56b "check $LFS getdirstripe"
6509 verify_yaml_available || skip_env "YAML verification not installed"
6510 local output_file=$DIR/$tfile.out
6512 $LFS getdirstripe -v -D -y $DIR 1> $output_file
6515 cat $output_file | verify_yaml || error "layout is not valid YAML"
6517 run_test 56bb "check $LFS getdirstripe layout is YAML"
6520 remote_ost_nodsh && skip "remote OST with nodsh"
6523 local ost_name=$(ostname_from_index $ost_idx)
6524 local old_status=$(ost_dev_status $ost_idx)
6525 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6527 [[ -z "$old_status" ]] ||
6528 skip_env "OST $ost_name is in $old_status status"
6530 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6531 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6532 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6533 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6534 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6535 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6538 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6539 error "$LFS df -v showing inactive devices"
6542 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6544 [[ "$new_status" =~ "D" ]] ||
6545 error "$ost_name status is '$new_status', missing 'D'"
6546 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6547 [[ "$new_status" =~ "N" ]] ||
6548 error "$ost_name status is '$new_status', missing 'N'"
6550 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6551 [[ "$new_status" =~ "f" ]] ||
6552 error "$ost_name status is '$new_status', missing 'f'"
6555 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6556 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6557 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6558 [[ -z "$p" ]] && restore_lustre_params < $p || true
6561 new_status=$(ost_dev_status $ost_idx)
6562 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6563 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6564 # can't check 'f' as devices may actually be on flash
6566 run_test 56c "check 'lfs df' showing device status"
6569 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6570 local osts=$($LFS df -v $MOUNT | grep -c OST)
6574 (( mdts == MDSCOUNT )) ||
6575 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6576 (( osts == OSTCOUNT )) ||
6577 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6579 run_test 56d "'lfs df -v' prints only configured devices"
6582 err_enoent=2 # No such file or directory
6583 err_eopnotsupp=95 # Operation not supported
6585 enoent_mnt=/pmt1 # Invalid dentry. Path not present
6586 notsup_mnt=/tmp # Valid dentry, but Not a lustreFS
6588 # Check for handling of path not exists
6589 output=$($LFS df $enoent_mnt 2>&1)
6592 fs=$(echo $output | awk -F: '{print $2}' | awk '{print $3}' | tr -d \')
6593 [[ $fs = $enoent_mnt && $ret -eq $err_enoent ]] ||
6594 error "expect failure $err_enoent, not $ret"
6596 # Check for handling of non-Lustre FS
6597 output=$($LFS df $notsup_mnt)
6600 fs=$(echo $output | awk '{print $1}' | awk -F: '{print $2}')
6601 [[ $fs = $notsup_mnt && $ret -eq $err_eopnotsupp ]] ||
6602 error "expect success $err_eopnotsupp, not $ret"
6604 # Check for multiple LustreFS argument
6605 output=$($LFS df $MOUNT $MOUNT $MOUNT | grep -c "filesystem_summary:")
6608 [[ $output -eq 3 && $ret -eq 0 ]] ||
6609 error "expect success 3, not $output, rc = $ret"
6611 # Check for correct non-Lustre FS handling among multiple
6613 output=$($LFS df $MOUNT $notsup_mnt $MOUNT |
6614 grep -c "filesystem_summary:"; exit ${PIPESTATUS[0]})
6617 [[ $output -eq 2 && $ret -eq $err_eopnotsupp ]] ||
6618 error "expect success 2, not $output, rc = $ret"
6620 run_test 56e "'lfs df' Handle non LustreFS & multiple LustreFS"
6625 local local_tdir="$1"
6626 local local_numfiles="$2"
6627 local local_numdirs="$3"
6628 local dir_params="$4"
6629 local dir_stripe_params="$5"
6631 if [ ! -d "$local_tdir" ] ; then
6632 test_mkdir -p $dir_stripe_params $local_tdir
6633 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6634 for i in $(seq $local_numfiles) ; do
6635 touch $local_tdir/file$i
6637 for i in $(seq $local_numdirs) ; do
6638 test_mkdir $dir_stripe_params $local_tdir/dir$i
6639 for j in $(seq $local_numfiles) ; do
6640 touch $local_tdir/dir$i/file$j
6646 setup_56_special() {
6648 local local_numfiles=$2
6649 local local_numdirs=$3
6651 setup_56 $local_tdir $local_numfiles $local_numdirs
6653 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6654 for i in $(seq $local_numfiles) ; do
6655 mknod $local_tdir/loop${i}b b 7 $i
6656 mknod $local_tdir/null${i}c c 1 3
6657 ln -s $local_tdir/file1 $local_tdir/link${i}
6659 for i in $(seq $local_numdirs) ; do
6660 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6661 mknod $local_tdir/dir$i/null${i}c c 1 3
6662 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6668 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6669 local expected=$(($NUMDIRS + 2))
6671 setup_56 $dir $NUMFILES $NUMDIRS
6673 # test lfs find with -name
6674 for i in $(seq $NUMFILES) ; do
6675 local nums=$($LFS find -name "*$i" $dir | wc -l)
6677 [ $nums -eq $expected ] ||
6678 error "lfs find -name '*$i' $dir wrong: "\
6679 "found $nums, expected $expected"
6682 run_test 56g "check lfs find -name"
6685 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6686 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6688 setup_56 $dir $NUMFILES $NUMDIRS
6690 # test lfs find with ! -name
6691 for i in $(seq $NUMFILES) ; do
6692 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6694 [ $nums -eq $expected ] ||
6695 error "lfs find ! -name '*$i' $dir wrong: "\
6696 "found $nums, expected $expected"
6699 run_test 56h "check lfs find ! -name"
6702 local dir=$DIR/$tdir
6706 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6709 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6711 run_test 56i "check 'lfs find -ost UUID' skips directories"
6714 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6716 setup_56_special $dir $NUMFILES $NUMDIRS
6718 local expected=$((NUMDIRS + 1))
6719 local cmd="$LFS find -type d $dir"
6720 local nums=$($cmd | wc -l)
6722 [ $nums -eq $expected ] ||
6723 error "'$cmd' wrong: found $nums, expected $expected"
6725 run_test 56j "check lfs find -type d"
6728 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6730 setup_56_special $dir $NUMFILES $NUMDIRS
6732 local expected=$(((NUMDIRS + 1) * NUMFILES))
6733 local cmd="$LFS find -type f $dir"
6734 local nums=$($cmd | wc -l)
6736 [ $nums -eq $expected ] ||
6737 error "'$cmd' wrong: found $nums, expected $expected"
6739 run_test 56k "check lfs find -type f"
6742 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6744 setup_56_special $dir $NUMFILES $NUMDIRS
6746 local expected=$((NUMDIRS + NUMFILES))
6747 local cmd="$LFS find -type b $dir"
6748 local nums=$($cmd | wc -l)
6750 [ $nums -eq $expected ] ||
6751 error "'$cmd' wrong: found $nums, expected $expected"
6753 run_test 56l "check lfs find -type b"
6756 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6758 setup_56_special $dir $NUMFILES $NUMDIRS
6760 local expected=$((NUMDIRS + NUMFILES))
6761 local cmd="$LFS find -type c $dir"
6762 local nums=$($cmd | wc -l)
6763 [ $nums -eq $expected ] ||
6764 error "'$cmd' wrong: found $nums, expected $expected"
6766 run_test 56m "check lfs find -type c"
6769 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6770 setup_56_special $dir $NUMFILES $NUMDIRS
6772 local expected=$((NUMDIRS + NUMFILES))
6773 local cmd="$LFS find -type l $dir"
6774 local nums=$($cmd | wc -l)
6776 [ $nums -eq $expected ] ||
6777 error "'$cmd' wrong: found $nums, expected $expected"
6779 run_test 56n "check lfs find -type l"
6782 local dir=$DIR/$tdir
6784 setup_56 $dir $NUMFILES $NUMDIRS
6785 utime $dir/file1 > /dev/null || error "utime (1)"
6786 utime $dir/file2 > /dev/null || error "utime (2)"
6787 utime $dir/dir1 > /dev/null || error "utime (3)"
6788 utime $dir/dir2 > /dev/null || error "utime (4)"
6789 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6790 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6793 local nums=$($LFS find -mtime +0 $dir | wc -l)
6795 [ $nums -eq $expected ] ||
6796 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6799 cmd="$LFS find -mtime 0 $dir"
6800 nums=$($cmd | wc -l)
6801 [ $nums -eq $expected ] ||
6802 error "'$cmd' wrong: found $nums, expected $expected"
6804 run_test 56o "check lfs find -mtime for old files"
6807 local dir=$DIR/$tdir
6811 # just to make sure there is something that won't be found
6813 touch $dir/$tfile.now
6815 for age in year week day hour min; do
6816 count=$((count + 1))
6818 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6819 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6820 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6822 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6823 local nums=$($cmd | wc -l)
6824 [ $nums -eq $expected ] ||
6825 error "'$cmd' wrong: found $nums, expected $expected"
6827 cmd="$LFS find $dir -atime $count${age:0:1}"
6828 nums=$($cmd | wc -l)
6829 [ $nums -eq $expected ] ||
6830 error "'$cmd' wrong: found $nums, expected $expected"
6834 cmd="$LFS find $dir -ctime +1s -type f"
6835 nums=$($cmd | wc -l)
6836 (( $nums == $count * 2 + 1)) ||
6837 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6839 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6841 test_newerXY_base() {
6844 local dir=$DIR/$tdir
6848 if [ $y == "t" ]; then
6849 if [ $x == "b" ]; then
6850 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6852 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6855 ref=$DIR/$tfile.newer.$x$y
6856 touch $ref || error "touch $ref failed"
6859 echo "before = $ref"
6861 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6863 if [ $y == "t" ]; then
6864 if [ $x == "b" ]; then
6865 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6867 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6870 negref=$DIR/$tfile.negnewer.$x$y
6871 touch $negref || error "touch $negref failed"
6874 echo "after = $negref"
6875 local cmd="$LFS find $dir -newer$x$y $ref"
6876 local nums=$(eval $cmd | wc -l)
6877 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6879 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6880 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6882 cmd="$LFS find $dir ! -newer$x$y $negref"
6883 nums=$(eval $cmd | wc -l)
6884 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6885 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6887 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6888 nums=$(eval $cmd | wc -l)
6889 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6890 error "'$cmd' wrong: found $nums between, expected $expected"; }
6896 test_newerXY_base "a" "a"
6897 test_newerXY_base "a" "m"
6898 test_newerXY_base "a" "c"
6899 test_newerXY_base "m" "a"
6900 test_newerXY_base "m" "m"
6901 test_newerXY_base "m" "c"
6902 test_newerXY_base "c" "a"
6903 test_newerXY_base "c" "m"
6904 test_newerXY_base "c" "c"
6906 test_newerXY_base "a" "t"
6907 test_newerXY_base "m" "t"
6908 test_newerXY_base "c" "t"
6910 (( $MDS1_VERSION >= $(version_code v2_13_53-145-g186b97e68a) &&
6911 $CLIENT_VERSION >= $(version_code v2_13_53-145-g186b97e68a) )) ||
6912 { echo "btime needs v2_13_53-145-g186b97e68a"; return 0; }
6914 test_newerXY_base "b" "b"
6915 test_newerXY_base "b" "t"
6917 run_test 56oc "check lfs find -newerXY work"
6920 (( $MDS1_VERSION >= $(version_code v2_13_53-145-g186b97e68a) )) ||
6921 skip "btime unsupported on MDS < v2_13_53-145-g186b97e68a"
6923 (( $CLIENT_VERSION >= $(version_code v2_13_53-145-g186b97e68a) )) ||
6924 skip "btime unsupported on clients < v2_13_53-145-g186b97e68a"
6926 local dir=$DIR/$tdir
6927 local ref=$DIR/$tfile.ref
6928 local negref=$DIR/$tfile.negref
6930 mkdir $dir || error "mkdir $dir failed"
6931 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6932 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6933 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6934 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6935 touch $ref || error "touch $ref failed"
6936 # sleep 3 seconds at least
6939 local before=$(do_facet mds1 date +%s)
6940 local skew=$(($(date +%s) - before + 1))
6942 if (( skew < 0 && skew > -5 )); then
6943 sleep $((0 - skew + 1))
6947 # Set the dir stripe params to limit files all on MDT0,
6948 # otherwise we need to calc the max clock skew between
6949 # the client and MDTs.
6950 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6952 touch $negref || error "touch $negref failed"
6954 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6955 local nums=$($cmd | wc -l)
6956 local expected=$(((NUMFILES + 1) * NUMDIRS))
6958 [ $nums -eq $expected ] ||
6959 error "'$cmd' wrong: found $nums, expected $expected"
6961 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6962 nums=$($cmd | wc -l)
6963 expected=$((NUMFILES + 1))
6964 [ $nums -eq $expected ] ||
6965 error "'$cmd' wrong: found $nums, expected $expected"
6967 [ $skew -lt 0 ] && return
6969 local after=$(do_facet mds1 date +%s)
6970 local age=$((after - before + 1 + skew))
6972 cmd="$LFS find $dir -btime -${age}s -type f"
6973 nums=$($cmd | wc -l)
6974 expected=$(((NUMFILES + 1) * NUMDIRS))
6976 echo "Clock skew between client and server: $skew, age:$age"
6977 [ $nums -eq $expected ] ||
6978 error "'$cmd' wrong: found $nums, expected $expected"
6980 expected=$(($NUMDIRS + 1))
6981 cmd="$LFS find $dir -btime -${age}s -type d"
6982 nums=$($cmd | wc -l)
6983 [ $nums -eq $expected ] ||
6984 error "'$cmd' wrong: found $nums, expected $expected"
6985 rm -f $ref $negref || error "Failed to remove $ref $negref"
6987 run_test 56od "check lfs find -btime with units"
6990 [ $RUNAS_ID -eq $UID ] &&
6991 skip_env "RUNAS_ID = UID = $UID -- skipping"
6993 local dir=$DIR/$tdir
6995 setup_56 $dir $NUMFILES $NUMDIRS
6996 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6998 local expected=$NUMFILES
6999 local cmd="$LFS find -uid $RUNAS_ID $dir"
7000 local nums=$($cmd | wc -l)
7002 [ $nums -eq $expected ] ||
7003 error "'$cmd' wrong: found $nums, expected $expected"
7005 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
7006 cmd="$LFS find ! -uid $RUNAS_ID $dir"
7007 nums=$($cmd | wc -l)
7008 [ $nums -eq $expected ] ||
7009 error "'$cmd' wrong: found $nums, expected $expected"
7011 run_test 56p "check lfs find -uid and ! -uid"
7014 [ $RUNAS_ID -eq $UID ] &&
7015 skip_env "RUNAS_ID = UID = $UID -- skipping"
7017 local dir=$DIR/$tdir
7019 setup_56 $dir $NUMFILES $NUMDIRS
7020 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
7022 local expected=$NUMFILES
7023 local cmd="$LFS find -gid $RUNAS_GID $dir"
7024 local nums=$($cmd | wc -l)
7026 [ $nums -eq $expected ] ||
7027 error "'$cmd' wrong: found $nums, expected $expected"
7029 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
7030 cmd="$LFS find ! -gid $RUNAS_GID $dir"
7031 nums=$($cmd | wc -l)
7032 [ $nums -eq $expected ] ||
7033 error "'$cmd' wrong: found $nums, expected $expected"
7035 run_test 56q "check lfs find -gid and ! -gid"
7038 local dir=$DIR/$tdir
7040 setup_56 $dir $NUMFILES $NUMDIRS
7043 local cmd="$LFS find -size 0 -type f -lazy $dir"
7044 local nums=$($cmd | wc -l)
7046 [ $nums -eq $expected ] ||
7047 error "'$cmd' wrong: found $nums, expected $expected"
7048 cmd="$LFS find -size 0 -type f $dir"
7049 nums=$($cmd | wc -l)
7050 [ $nums -eq $expected ] ||
7051 error "'$cmd' wrong: found $nums, expected $expected"
7054 cmd="$LFS find ! -size 0 -type f -lazy $dir"
7055 nums=$($cmd | wc -l)
7056 [ $nums -eq $expected ] ||
7057 error "'$cmd' wrong: found $nums, expected $expected"
7058 cmd="$LFS find ! -size 0 -type f $dir"
7059 nums=$($cmd | wc -l)
7060 [ $nums -eq $expected ] ||
7061 error "'$cmd' wrong: found $nums, expected $expected"
7063 echo "test" > $dir/$tfile
7064 echo "test2" > $dir/$tfile.2 && sync
7066 cmd="$LFS find -size 5 -type f -lazy $dir"
7067 nums=$($cmd | wc -l)
7068 [ $nums -eq $expected ] ||
7069 error "'$cmd' wrong: found $nums, expected $expected"
7070 cmd="$LFS find -size 5 -type f $dir"
7071 nums=$($cmd | wc -l)
7072 [ $nums -eq $expected ] ||
7073 error "'$cmd' wrong: found $nums, expected $expected"
7076 cmd="$LFS find -size +5 -type f -lazy $dir"
7077 nums=$($cmd | wc -l)
7078 [ $nums -eq $expected ] ||
7079 error "'$cmd' wrong: found $nums, expected $expected"
7080 cmd="$LFS find -size +5 -type f $dir"
7081 nums=$($cmd | wc -l)
7082 [ $nums -eq $expected ] ||
7083 error "'$cmd' wrong: found $nums, expected $expected"
7086 cmd="$LFS find -size +0 -type f -lazy $dir"
7087 nums=$($cmd | wc -l)
7088 [ $nums -eq $expected ] ||
7089 error "'$cmd' wrong: found $nums, expected $expected"
7090 cmd="$LFS find -size +0 -type f $dir"
7091 nums=$($cmd | wc -l)
7092 [ $nums -eq $expected ] ||
7093 error "'$cmd' wrong: found $nums, expected $expected"
7096 cmd="$LFS find ! -size -5 -type f -lazy $dir"
7097 nums=$($cmd | wc -l)
7098 [ $nums -eq $expected ] ||
7099 error "'$cmd' wrong: found $nums, expected $expected"
7100 cmd="$LFS find ! -size -5 -type f $dir"
7101 nums=$($cmd | wc -l)
7102 [ $nums -eq $expected ] ||
7103 error "'$cmd' wrong: found $nums, expected $expected"
7106 cmd="$LFS find -size -5 -type f -lazy $dir"
7107 nums=$($cmd | wc -l)
7108 [ $nums -eq $expected ] ||
7109 error "'$cmd' wrong: found $nums, expected $expected"
7110 cmd="$LFS find -size -5 -type f $dir"
7111 nums=$($cmd | wc -l)
7112 [ $nums -eq $expected ] ||
7113 error "'$cmd' wrong: found $nums, expected $expected"
7115 run_test 56r "check lfs find -size works"
7122 cancel_lru_locks $OSC
7124 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
7125 local nums=$($cmd | wc -l)
7127 [ $nums -eq $expected ] ||
7128 error "'$cmd' wrong: found $nums, expected $expected"
7130 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
7132 if (( rpcs_before + glimpses != rpcs_after )); then
7133 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
7134 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
7136 if [[ $glimpses == 0 ]]; then
7137 error "'$cmd' should not send glimpse RPCs to OST"
7139 error "'$cmd' should send $glimpses glimpse RPCs to OST"
7145 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
7146 skip "MDS < 2.12.58 doesn't return LSOM data"
7147 local dir=$DIR/$tdir
7148 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
7150 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
7152 # statahead_agl may cause extra glimpse which confuses results. LU-13017
7153 $LCTL set_param -n llite.*.statahead_agl=0
7154 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
7156 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7157 # open and close all files to ensure LSOM is updated
7158 cancel_lru_locks $OSC
7159 find $dir -type f | xargs cat > /dev/null
7161 # expect_found glimpse_rpcs command_to_run
7162 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
7163 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
7164 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
7165 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
7167 echo "test" > $dir/$tfile
7168 echo "test2" > $dir/$tfile.2 && sync
7169 cancel_lru_locks $OSC
7170 cat $dir/$tfile $dir/$tfile.2 > /dev/null
7172 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
7173 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
7174 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
7175 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
7177 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
7178 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
7179 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
7180 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
7181 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
7182 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
7184 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
7187 local dir=$DIR/$tdir
7188 local tmp=$TMP/$tfile.log
7191 test_mkdir -p $dir || error "failed to mkdir $dir"
7192 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
7193 error "failed to setstripe $dir/$tfile"
7194 mdt_idx=$($LFS getdirstripe -i $dir)
7195 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
7197 stack_trap "rm -f $tmp" EXIT
7198 $LFS find --size +100K --ost 0 $dir |& tee $tmp
7199 ! grep -q obd_uuid $tmp ||
7200 error "failed to find --size +100K --ost 0 $dir"
7201 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
7202 ! grep -q obd_uuid $tmp ||
7203 error "failed to find --size +100K --mdt $mdt_idx $dir"
7205 run_test 56rb "check lfs find --size --ost/--mdt works"
7208 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
7209 local dir=$DIR/$tdir
7212 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
7213 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
7214 (( $MDSCOUNT > 2 )) &&
7215 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
7216 mkdir $dir/$tdir-{1..10}
7217 touch $dir/$tfile-{1..10}
7219 found=$($LFS find $dir --mdt-count 2 | wc -l)
7221 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
7223 found=$($LFS find $dir -T +1 | wc -l)
7224 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
7225 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
7227 found=$($LFS find $dir --mdt-hash all_char | wc -l)
7229 (( $found == $expect )) || error "found $found all_char, expect $expect"
7231 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
7232 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
7233 (( $found == $expect )) || error "found $found all_char, expect $expect"
7235 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
7238 local dir=$DIR/$tdir
7243 mkfifo $dir/fifo || error "failed to create fifo file"
7244 $LFS find $dir -t p --printf "%p %y %LP\n" ||
7245 error "should not fail even cannot get projid from pipe file"
7246 found=$($LFS find $dir -t p --printf "%y")
7247 [[ "p" == $found ]] || error "found $found, expect p"
7249 mknod $dir/chardev c 1 5 ||
7250 error "failed to create character device file"
7251 $LFS find $dir -t c --printf "%p %y %LP\n" ||
7252 error "should not fail even cannot get projid from chardev file"
7253 found=$($LFS find $dir -t c --printf "%y")
7254 [[ "c" == $found ]] || error "found $found, expect c"
7256 found=$($LFS find $dir ! -type d --printf "%p %y %LP\n" | wc -l)
7257 (( found == 2 )) || error "unable to list all files"
7259 run_test 56rd "check lfs find --printf special files"
7261 test_56s() { # LU-611 #LU-9369
7262 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
7264 local dir=$DIR/$tdir
7265 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
7267 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7268 for i in $(seq $NUMDIRS); do
7269 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
7272 local expected=$NUMDIRS
7273 local cmd="$LFS find -c $OSTCOUNT $dir"
7274 local nums=$($cmd | wc -l)
7276 [ $nums -eq $expected ] || {
7277 $LFS getstripe -R $dir
7278 error "'$cmd' wrong: found $nums, expected $expected"
7281 expected=$((NUMDIRS + onestripe))
7282 cmd="$LFS find -stripe-count +0 -type f $dir"
7283 nums=$($cmd | wc -l)
7284 [ $nums -eq $expected ] || {
7285 $LFS getstripe -R $dir
7286 error "'$cmd' wrong: found $nums, expected $expected"
7290 cmd="$LFS find -stripe-count 1 -type f $dir"
7291 nums=$($cmd | wc -l)
7292 [ $nums -eq $expected ] || {
7293 $LFS getstripe -R $dir
7294 error "'$cmd' wrong: found $nums, expected $expected"
7297 cmd="$LFS find -stripe-count -2 -type f $dir"
7298 nums=$($cmd | wc -l)
7299 [ $nums -eq $expected ] || {
7300 $LFS getstripe -R $dir
7301 error "'$cmd' wrong: found $nums, expected $expected"
7305 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
7306 nums=$($cmd | wc -l)
7307 [ $nums -eq $expected ] || {
7308 $LFS getstripe -R $dir
7309 error "'$cmd' wrong: found $nums, expected $expected"
7312 run_test 56s "check lfs find -stripe-count works"
7314 test_56t() { # LU-611 #LU-9369
7315 local dir=$DIR/$tdir
7317 setup_56 $dir 0 $NUMDIRS
7318 for i in $(seq $NUMDIRS); do
7319 $LFS setstripe -S 8M $dir/dir$i/$tfile
7322 local expected=$NUMDIRS
7323 local cmd="$LFS find -S 8M $dir"
7324 local nums=$($cmd | wc -l)
7326 [ $nums -eq $expected ] || {
7327 $LFS getstripe -R $dir
7328 error "'$cmd' wrong: found $nums, expected $expected"
7332 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
7334 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
7336 expected=$(((NUMDIRS + 1) * NUMFILES))
7337 cmd="$LFS find -stripe-size 512k -type f $dir"
7338 nums=$($cmd | wc -l)
7339 [ $nums -eq $expected ] ||
7340 error "'$cmd' wrong: found $nums, expected $expected"
7342 cmd="$LFS find -stripe-size +320k -type f $dir"
7343 nums=$($cmd | wc -l)
7344 [ $nums -eq $expected ] ||
7345 error "'$cmd' wrong: found $nums, expected $expected"
7347 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
7348 cmd="$LFS find -stripe-size +200k -type f $dir"
7349 nums=$($cmd | wc -l)
7350 [ $nums -eq $expected ] ||
7351 error "'$cmd' wrong: found $nums, expected $expected"
7353 cmd="$LFS find -stripe-size -640k -type f $dir"
7354 nums=$($cmd | wc -l)
7355 [ $nums -eq $expected ] ||
7356 error "'$cmd' wrong: found $nums, expected $expected"
7359 cmd="$LFS find -stripe-size 256k -type f $dir"
7360 nums=$($cmd | wc -l)
7361 [ $nums -eq $expected ] ||
7362 error "'$cmd' wrong: found $nums, expected $expected"
7364 cmd="$LFS find -stripe-size -320k -type f $dir"
7365 nums=$($cmd | wc -l)
7366 [ $nums -eq $expected ] ||
7367 error "'$cmd' wrong: found $nums, expected $expected"
7370 cmd="$LFS find -stripe-size 1024k -type f $dir"
7371 nums=$($cmd | wc -l)
7372 [ $nums -eq $expected ] ||
7373 error "'$cmd' wrong: found $nums, expected $expected"
7375 run_test 56t "check lfs find -stripe-size works"
7377 test_56u() { # LU-611
7378 local dir=$DIR/$tdir
7380 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
7382 if [[ $OSTCOUNT -gt 1 ]]; then
7383 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
7389 local expected=$(((NUMDIRS + 1) * NUMFILES))
7390 local cmd="$LFS find -stripe-index 0 -type f $dir"
7391 local nums=$($cmd | wc -l)
7393 [ $nums -eq $expected ] ||
7394 error "'$cmd' wrong: found $nums, expected $expected"
7397 cmd="$LFS find -stripe-index 1 -type f $dir"
7398 nums=$($cmd | wc -l)
7399 [ $nums -eq $expected ] ||
7400 error "'$cmd' wrong: found $nums, expected $expected"
7402 cmd="$LFS find ! -stripe-index 0 -type f $dir"
7403 nums=$($cmd | wc -l)
7404 [ $nums -eq $expected ] ||
7405 error "'$cmd' wrong: found $nums, expected $expected"
7408 # This should produce an error and not return any files
7409 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
7410 nums=$($cmd 2>/dev/null | wc -l)
7411 [ $nums -eq $expected ] ||
7412 error "'$cmd' wrong: found $nums, expected $expected"
7414 if [[ $OSTCOUNT -gt 1 ]]; then
7415 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
7416 cmd="$LFS find -stripe-index 0,1 -type f $dir"
7417 nums=$($cmd | wc -l)
7418 [ $nums -eq $expected ] ||
7419 error "'$cmd' wrong: found $nums, expected $expected"
7422 run_test 56u "check lfs find -stripe-index works"
7426 local dir=$DIR/$tdir
7428 setup_56 $dir $NUMFILES $NUMDIRS
7430 UUID=$(mdtuuid_from_index $mdt_idx $dir)
7431 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
7433 for file in $($LFS find -m $UUID $dir); do
7434 file_midx=$($LFS getstripe -m $file)
7435 [ $file_midx -eq $mdt_idx ] ||
7436 error "lfs find -m $UUID != getstripe -m $file_midx"
7439 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
7442 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
7443 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7445 local dir=$DIR/$tdir
7447 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
7448 stack_trap "rm -rf $dir"
7450 local stripe_size=$($LFS getstripe -S -d $dir) ||
7451 error "$LFS getstripe -S -d $dir failed"
7452 stripe_size=${stripe_size%% *}
7454 local file_size=$((stripe_size * OSTCOUNT))
7455 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
7456 local required_space=$((file_num * file_size))
7457 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
7459 (( free_space >= required_space / 1024 )) ||
7460 skip_env "need $required_space, have $free_space kbytes"
7463 local dd_count=$((file_size / dd_bs))
7465 # write data into the files
7470 for ((i = 1; i <= NUMFILES; i++ )); do
7472 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7473 error "write data into $file failed"
7475 for ((i = 1; i <= NUMDIRS; i++ )); do
7476 for ((j = 1; j <= NUMFILES; j++ )); do
7477 file=$dir/dir$i/file$j
7478 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7479 error "write data into $file failed"
7483 # $LFS_MIGRATE will fail if hard link migration is unsupported
7484 if (( MDS1_VERSION > $(version_code 2.5.55) )); then
7485 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
7486 error "creating links to $dir/dir1/file1 failed"
7491 (( OSTCOUNT <= 1 )) || expected=$((OSTCOUNT - 1))
7494 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
7497 eval $cmd || error "$cmd failed"
7499 check_stripe_count $dir/file1 $expected
7501 if (( $MDS1_VERSION >= $(version_code 2.6.90) )); then
7502 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
7503 # OST 1 if it is on OST 0. This file is small enough to
7504 # be on only one stripe.
7505 file=$dir/migr_1_ost
7506 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
7507 error "write data into $file failed"
7508 local obdidx=$($LFS getstripe -i $file)
7509 local oldmd5=$(md5sum $file)
7512 (( obdidx != 0 )) || newobdidx=1
7513 cmd="$LFS migrate -i $newobdidx $file"
7515 eval $cmd || error "$cmd failed"
7517 local realobdix=$($LFS getstripe -i $file)
7518 local newmd5=$(md5sum $file)
7520 (( $newobdidx == $realobdix )) ||
7521 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
7522 [[ "$oldmd5" == "$newmd5" ]] ||
7523 error "md5sum differ: $oldmd5, $newmd5"
7527 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7529 eval $cmd || error "$cmd failed"
7531 for (( j = 1; j <= NUMFILES; j++ )); do
7532 check_stripe_count $dir/dir1/file$j $expected
7535 # lfs_migrate works with lfs find
7536 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7537 $LFS_MIGRATE -y -c $expected"
7539 eval $cmd || error "$cmd failed"
7541 for (( i = 2; i <= NUMFILES; i++ )); do
7542 check_stripe_count $dir/file$i $expected
7544 for (( i = 2; i <= NUMDIRS; i++ )); do
7545 for (( j = 1; j <= NUMFILES; j++ )); do
7546 check_stripe_count $dir/dir$i/file$j $expected
7550 run_test 56wa "check lfs_migrate -c stripe_count works"
7553 local file1=$DIR/$tdir/file1
7554 local create_pool=false
7555 local initial_pool=$($LFS getstripe -p $DIR)
7559 echo -n "Creating test dir..."
7560 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7563 echo -n "Creating test file..."
7564 touch $file1 || error "cannot create file"
7567 echo -n "Detecting existing pools..."
7568 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7570 if [ ${#pool_list[@]} -gt 0 ]; then
7571 echo "${pool_list[@]}"
7572 for thispool in "${pool_list[@]}"; do
7573 if [[ -z "$initial_pool" ||
7574 "$initial_pool" != "$thispool" ]]; then
7576 echo "Using existing pool '$pool'"
7581 echo "none detected."
7583 if [ -z "$pool" ]; then
7584 pool=${POOL:-testpool}
7585 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7586 echo -n "Creating pool '$pool'..."
7588 pool_add $pool &> /dev/null ||
7589 error "pool_add failed"
7592 echo -n "Adding target to pool..."
7593 pool_add_targets $pool 0 0 1 &> /dev/null ||
7594 error "pool_add_targets failed"
7598 echo -n "Setting pool using -p option..."
7599 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7600 error "migrate failed rc = $?"
7603 echo -n "Verifying test file is in pool after migrating..."
7604 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7605 error "file was not migrated to pool $pool"
7608 echo -n "Removing test file from pool '$pool'..."
7609 # "lfs migrate $file" won't remove the file from the pool
7610 # until some striping information is changed.
7611 $LFS migrate -c 1 $file1 &> /dev/null ||
7612 error "cannot remove from pool"
7613 [ "$($LFS getstripe -p $file1)" ] &&
7614 error "pool still set"
7617 echo -n "Setting pool using --pool option..."
7618 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7619 error "migrate failed rc = $?"
7624 if $create_pool; then
7625 destroy_test_pools 2> /dev/null ||
7626 error "destroy test pools failed"
7629 run_test 56wb "check lfs_migrate pool support"
7632 local file1="$DIR/$tdir/$tfile"
7642 echo -n "Creating test dir..."
7643 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7644 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7645 error "cannot set stripe by '-S 1M -c 1'"
7648 echo -n "Setting initial stripe for test file..."
7649 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7650 error "cannot set stripe"
7651 cur_ssize=$($LFS getstripe -S "$file1")
7652 (( cur_ssize == 524288 )) || error "setstripe -S $cur_ssize != 524288"
7655 dd if=/dev/urandom of=$file1 bs=1M count=12 || error "dd $file1 failed"
7656 stack_trap "rm -f $file1"
7657 md5="$(md5sum $file1)"
7659 # File currently set to -S 512K -c 1
7661 # Ensure -c and -S options are rejected when -R is set
7662 echo -n "Verifying incompatible options are detected..."
7663 $LFS_MIGRATE -R -c 1 "$file1" &&
7664 error "incompatible -R and -c options not detected"
7665 $LFS_MIGRATE -R -S 1M "$file1" &&
7666 error "incompatible -R and -S options not detected"
7667 $LFS_MIGRATE -R -p pool "$file1" &&
7668 error "incompatible -R and -p options not detected"
7669 $LFS_MIGRATE -R -E eof -c 1 "$file1" &&
7670 error "incompatible -R and -E options not detected"
7671 $LFS_MIGRATE -R -A "$file1" &&
7672 error "incompatible -R and -A options not detected"
7673 $LFS_MIGRATE -A -c 1 "$file1" &&
7674 error "incompatible -A and -c options not detected"
7675 $LFS_MIGRATE -A -S 1M "$file1" &&
7676 error "incompatible -A and -S options not detected"
7677 $LFS_MIGRATE -A -p pool "$file1" &&
7678 error "incompatible -A and -p options not detected"
7679 $LFS_MIGRATE -A -E eof -c 1 "$file1" &&
7680 error "incompatible -A and -E options not detected"
7683 # Ensure unrecognized options are passed through to 'lfs migrate'
7684 echo -n "Verifying -S option is passed through to lfs migrate..."
7685 $LFS_MIGRATE -y -S 1M "$file1" || error "migration failed"
7686 cur_ssize=$($LFS getstripe -S "$file1")
7687 (( cur_ssize == 1048576 )) || error "migrate -S $cur_ssize != 1048576"
7688 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (1)"
7691 # File currently set to -S 1M -c 1
7693 # Ensure long options are supported
7694 echo -n "Verifying long options supported..."
7695 $LFS_MIGRATE --non-block "$file1" ||
7696 error "long option without argument not supported"
7697 $LFS_MIGRATE --stripe-size 512K "$file1" ||
7698 error "long option with argument not supported"
7699 cur_ssize=$($LFS getstripe -S "$file1")
7700 (( cur_ssize == 524288 )) ||
7701 error "migrate --stripe-size $cur_ssize != 524288"
7702 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (2)"
7705 # File currently set to -S 512K -c 1
7707 if (( OSTCOUNT > 1 )); then
7708 echo -n "Verifying explicit stripe count can be set..."
7709 $LFS_MIGRATE -c 2 "$file1" || error "migrate failed"
7710 cur_scount=$($LFS getstripe -c "$file1")
7711 (( cur_scount == 2 )) || error "migrate -c $cur_scount != 2"
7712 [[ "$(md5sum $file1)" == "$md5" ]] ||
7713 error "file data has changed (3)"
7717 # File currently set to -S 512K -c 1 or -S 512K -c 2
7719 # Ensure parent striping is used if -R is set, and no stripe
7720 # count or size is specified
7721 echo -n "Setting stripe for parent directory..."
7722 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7723 error "cannot set stripe '-S 2M -c 1'"
7724 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (4)"
7727 echo -n "Verifying restripe option uses parent stripe settings..."
7728 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7729 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7730 $LFS_MIGRATE -R "$file1" || error "migrate failed"
7731 cur_ssize=$($LFS getstripe -S "$file1")
7732 (( cur_ssize == parent_ssize )) ||
7733 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7734 cur_scount=$($LFS getstripe -c "$file1")
7735 (( cur_scount == parent_scount )) ||
7736 error "migrate -R stripe_count $cur_scount != $parent_scount"
7737 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (5)"
7740 # File currently set to -S 1M -c 1
7742 # Ensure striping is preserved if -R is not set, and no stripe
7743 # count or size is specified
7744 echo -n "Verifying striping size preserved when not specified..."
7745 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7746 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7747 error "cannot set stripe on parent directory"
7748 $LFS_MIGRATE "$file1" || error "migrate failed"
7749 cur_ssize=$($LFS getstripe -S "$file1")
7750 (( cur_ssize == orig_ssize )) ||
7751 error "migrate by default $cur_ssize != $orig_ssize"
7752 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (6)"
7755 # Ensure file name properly detected when final option has no argument
7756 echo -n "Verifying file name properly detected..."
7757 $LFS_MIGRATE "$file1" ||
7758 error "file name interpreted as option argument"
7759 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (7)"
7762 # Ensure PFL arguments are passed through properly
7763 echo -n "Verifying PFL options passed through..."
7764 new_scount=$(((OSTCOUNT + 1) / 2))
7765 $LFS_MIGRATE -E 1M -c 1 -E 16M -c $new_scount -E eof -c -1 "$file1" ||
7766 error "migrate PFL arguments failed"
7767 cur_comp=$($LFS getstripe --comp-count $file1)
7768 (( cur_comp == 3 )) || error "component count '$cur_comp' != 3"
7769 cur_scount=$($LFS getstripe --stripe-count $file1)
7770 (( cur_scount == new_scount)) ||
7771 error "PFL stripe count $cur_scount != $new_scount"
7772 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (8)"
7775 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7778 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
7780 local file1=$DIR/$tdir/$tfile
7782 echo -n "Creating test dir..."
7783 test_mkdir $DIR/$tdir || error "cannot create dir"
7786 echo -n "Creating test file..."
7787 echo "$tfile" > $file1
7790 # Ensure 'lfs migrate' will fail by using a non-existent option,
7791 # and make sure rsync is not called to recover
7792 echo -n "Make sure --no-rsync option works..."
7793 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7794 grep -q 'refusing to fall back to rsync' ||
7795 error "rsync was called with --no-rsync set"
7798 # Ensure rsync is called without trying 'lfs migrate' first
7799 echo -n "Make sure --rsync option works..."
7800 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7801 grep -q 'falling back to rsync' &&
7802 error "lfs migrate was called with --rsync set"
7805 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7811 test_mkdir $td || error "cannot create $td"
7812 touch $tf || error "cannot touch $tf"
7814 echo -n "Make sure --non-direct|-D works..."
7815 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7816 grep -q "lfs migrate --non-direct" ||
7817 error "--non-direct option cannot work correctly"
7818 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7819 grep -q "lfs migrate -D" ||
7820 error "-D option cannot work correctly"
7823 run_test 56we "check lfs_migrate --non-direct|-D support"
7826 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7827 check_swap_layouts_support
7829 local dir=$DIR/$tdir
7830 local ref1=/etc/passwd
7831 local file1=$dir/file1
7833 test_mkdir $dir || error "creating dir $dir"
7834 $LFS setstripe -c 2 $file1
7836 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7837 stripe=$($LFS getstripe -c $file1)
7838 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7839 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7844 run_test 56x "lfs migration support"
7847 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7848 check_swap_layouts_support
7850 local dir=$DIR/$tdir/$testnum
7854 local ref1=/etc/passwd
7855 local file1=$dir/file1
7857 $LFS setstripe -c 2 $file1
7859 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7861 local stripe=$($LFS getstripe -c $file1)
7863 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7864 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7869 run_test 56xa "lfs migration --block support"
7871 check_migrate_links() {
7872 [[ "$1" == "--rsync" ]] && local opts="--rsync -y" && shift
7874 local file1="$dir/file1"
7878 local total_count=$(($begin + $count - 1))
7879 local symlink_count=10
7882 if [ ! -f "$file1" ]; then
7883 echo -n "creating initial file..."
7884 $LFS setstripe -c 1 -S "512k" "$file1" ||
7885 error "cannot setstripe initial file"
7888 echo -n "creating symlinks..."
7889 for s in $(seq 1 $symlink_count); do
7890 ln -s "$file1" "$dir/slink$s" ||
7891 error "cannot create symlinks"
7895 echo -n "creating nonlinked files..."
7896 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7897 error "cannot create nonlinked files"
7902 if [ ! -f "$dir/file$total_count" ]; then
7903 echo -n "creating hard links $begin:$total_count..."
7904 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7905 /dev/null || error "cannot create hard links"
7909 echo -n "checking number of hard links listed in xattrs..."
7910 local fid=$($LFS getstripe -F "$file1")
7911 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7914 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7915 skip "hard link list has unexpected size, skipping test"
7917 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7918 error "link names should exceed xattrs size"
7921 echo -n "migrating files..."
7922 local migrate_out=$($runas $LFS_MIGRATE $opts -S '1m' $dir)
7924 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7927 # make sure all links have been properly migrated
7928 echo -n "verifying files..."
7929 fid=$($LFS getstripe -F "$file1") ||
7930 error "cannot get fid for file $file1"
7931 for i in $(seq 2 $total_count); do
7932 local fid2=$($LFS getstripe -F $dir/file$i)
7934 [ "$fid2" == "$fid" ] ||
7935 error "migrated hard link has mismatched FID"
7938 # make sure hard links were properly detected, and migration was
7939 # performed only once for the entire link set; nonlinked files should
7941 local actual=$(grep -c 'done' <<< "$migrate_out")
7942 local expected=$(($uniq_count + 1))
7944 [ "$actual" -eq "$expected" ] ||
7945 error "hard links individually migrated ($actual != $expected)"
7947 # make sure the correct number of hard links are present
7948 local hardlinks=$(stat -c '%h' "$file1")
7950 [ $hardlinks -eq $total_count ] ||
7951 error "num hard links $hardlinks != $total_count"
7958 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7959 skip "Need MDS version at least 2.10.55"
7961 local dir="$DIR/$tdir"
7963 test_mkdir "$dir" || error "cannot create dir $dir"
7965 echo "testing lfs migrate mode when all links fit within xattrs"
7966 check_migrate_links "$dir" 2 99
7968 echo "testing rsync mode when all links fit within xattrs"
7969 check_migrate_links --rsync "$dir" 2 99
7971 echo "testing lfs migrate mode when all links do not fit within xattrs"
7972 check_migrate_links "$dir" 101 100
7974 echo "testing rsync mode when all links do not fit within xattrs"
7975 check_migrate_links --rsync "$dir" 101 100
7977 chown -R $RUNAS_ID $dir
7978 echo "testing non-root lfs migrate mode when not all links are in xattr"
7979 check_migrate_links "$dir" 101 100 "$RUNAS"
7984 run_test 56xb "lfs migration hard link support"
7987 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7989 local dir="$DIR/$tdir"
7991 test_mkdir "$dir" || error "cannot create dir $dir"
7993 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7994 echo -n "Setting initial stripe for 20MB test file..."
7995 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7996 error "cannot setstripe 20MB file"
7998 echo -n "Sizing 20MB test file..."
7999 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
8001 echo -n "Verifying small file autostripe count is 1..."
8002 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
8003 error "cannot migrate 20MB file"
8004 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
8005 error "cannot get stripe for $dir/20mb"
8006 [ $stripe_count -eq 1 ] ||
8007 error "unexpected stripe count $stripe_count for 20MB file"
8011 # Test 2: File is small enough to fit within the available space on
8012 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
8013 # have at least an additional 1KB for each desired stripe for test 3
8014 echo -n "Setting stripe for 1GB test file..."
8015 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
8017 echo -n "Sizing 1GB test file..."
8018 # File size is 1GB + 3KB
8019 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
8022 # need at least 512MB per OST for 1GB file to fit in 2 stripes
8023 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
8024 if (( avail > 524288 * OSTCOUNT )); then
8025 echo -n "Migrating 1GB file..."
8026 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
8027 error "cannot migrate 1GB file"
8029 echo -n "Verifying autostripe count is sqrt(n) + 1..."
8030 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
8031 error "cannot getstripe for 1GB file"
8032 [ $stripe_count -eq 2 ] ||
8033 error "unexpected stripe count $stripe_count != 2"
8037 # Test 3: File is too large to fit within the available space on
8038 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
8039 if [ $OSTCOUNT -ge 3 ]; then
8040 # The required available space is calculated as
8041 # file size (1GB + 3KB) / OST count (3).
8042 local kb_per_ost=349526
8044 echo -n "Migrating 1GB file with limit..."
8045 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
8046 error "cannot migrate 1GB file with limit"
8049 stripe_count=$($LFS getstripe -c "$dir/1gb")
8050 echo -n "Verifying 1GB autostripe count with limited space..."
8051 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
8052 error "unexpected stripe count $stripe_count (min 3)"
8059 run_test 56xc "lfs migration autostripe"
8062 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8064 local dir=$DIR/$tdir
8065 local f_mgrt=$dir/$tfile.mgrt
8066 local f_yaml=$dir/$tfile.yaml
8067 local f_copy=$dir/$tfile.copy
8068 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
8069 local layout_copy="-c 2 -S 2M -i 1"
8070 local yamlfile=$dir/yamlfile
8071 local layout_before;
8074 test_mkdir "$dir" || error "cannot create dir $dir"
8075 stack_trap "rm -rf $dir"
8076 $LFS setstripe $layout_yaml $f_yaml ||
8077 error "cannot setstripe $f_yaml with layout $layout_yaml"
8078 $LFS getstripe --yaml $f_yaml > $yamlfile
8079 $LFS setstripe $layout_copy $f_copy ||
8080 error "cannot setstripe $f_copy with layout $layout_copy"
8082 dd if=/dev/zero of=$f_mgrt bs=1M count=4
8084 # 1. test option --yaml
8085 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
8086 error "cannot migrate $f_mgrt with --yaml $yamlfile"
8087 layout_before=$(get_layout_param $f_yaml)
8088 layout_after=$(get_layout_param $f_mgrt)
8089 [ "$layout_after" == "$layout_before" ] ||
8090 error "lfs_migrate --yaml: $layout_after != $layout_before"
8092 # 2. test option --copy
8093 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
8094 error "cannot migrate $f_mgrt with --copy $f_copy"
8095 layout_before=$(SKIP_INDEX=yes get_layout_param $f_copy)
8096 layout_after=$(SKIP_INDEX=yes get_layout_param $f_mgrt)
8097 [ "$layout_after" == "$layout_before" ] ||
8098 error "lfs_migrate --copy: $layout_after != $layout_before"
8100 run_test 56xd "check lfs_migrate --yaml and --copy support"
8103 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8105 local dir=$DIR/$tdir
8106 local f_comp=$dir/$tfile
8107 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
8108 local layout_before=""
8109 local layout_after=""
8111 test_mkdir "$dir" || error "cannot create dir $dir"
8112 stack_trap "rm -rf $dir"
8113 $LFS setstripe $layout $f_comp ||
8114 error "cannot setstripe $f_comp with layout $layout"
8115 layout_before=$(SKIP_INDEX=yes get_layout_param $f_comp)
8116 dd if=/dev/zero of=$f_comp bs=1M count=4
8118 # 1. migrate a comp layout file by lfs_migrate
8119 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
8120 layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
8121 [ "$layout_before" == "$layout_after" ] ||
8122 error "lfs_migrate: $layout_before != $layout_after"
8124 # 2. migrate a comp layout file by lfs migrate
8125 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
8126 layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
8127 [ "$layout_before" == "$layout_after" ] ||
8128 error "lfs migrate: $layout_before != $layout_after"
8130 run_test 56xe "migrate a composite layout file"
8133 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
8135 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
8136 skip "Need server version at least 2.13.53"
8138 local dir=$DIR/$tdir
8139 local f_comp=$dir/$tfile
8140 local layout="-E 1M -c1 -E -1 -c2"
8144 test_mkdir "$dir" || error "cannot create dir $dir"
8145 stack_trap "rm -rf $dir"
8146 $LFS setstripe $layout $f_comp ||
8147 error "cannot setstripe $f_comp with layout $layout"
8148 fid_before=$($LFS getstripe --fid $f_comp)
8149 dd if=/dev/zero of=$f_comp bs=1M count=4
8151 # 1. migrate a comp layout file to a comp layout
8152 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
8153 fid_after=$($LFS getstripe --fid $f_comp)
8154 [ "$fid_before" == "$fid_after" ] ||
8155 error "comp-to-comp migrate: $fid_before != $fid_after"
8157 # 2. migrate a comp layout file to a plain layout
8158 $LFS migrate -c2 $f_comp ||
8159 error "cannot migrate $f_comp by lfs migrate"
8160 fid_after=$($LFS getstripe --fid $f_comp)
8161 [ "$fid_before" == "$fid_after" ] ||
8162 error "comp-to-plain migrate: $fid_before != $fid_after"
8164 # 3. migrate a plain layout file to a comp layout
8165 $LFS migrate $layout $f_comp ||
8166 error "cannot migrate $f_comp by lfs migrate"
8167 fid_after=$($LFS getstripe --fid $f_comp)
8168 [ "$fid_before" == "$fid_after" ] ||
8169 error "plain-to-comp migrate: $fid_before != $fid_after"
8171 run_test 56xf "FID is not lost during migration of a composite layout file"
8173 check_file_ost_range() {
8180 file_range=($($LFS getstripe -y "$file" |
8181 awk '/l_ost_idx:/ { print $NF }'))
8183 if [[ "${#file_range[@]}" = 0 ]]; then
8184 echo "No osts found for $file"
8188 for idx in "${file_range[@]}"; do
8189 [[ " $range " =~ " $idx " ]] ||
8197 local stripe_opt="$1"
8200 local pool_ostidx="$(seq $* | tr '\n' ' ')"
8202 $LFS migrate $stripe_opt -p $pool $DIR/$tfile ||
8203 error "Fail to migrate $tfile on $pool"
8204 [[ "$($LFS getstripe -p $DIR/$tfile)" = "$pool" ]] ||
8205 error "$tfile is not in pool $pool"
8206 check_file_ost_range "$DIR/$tfile" $pool_ostidx ||
8207 error "$tfile osts mismatch with pool $pool (osts $pool_ostidx)"
8211 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
8212 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
8213 [[ $MDS1_VERSION -gt $(version_code 2.14.52) ]] ||
8214 skip "Need MDS version newer than 2.14.52"
8216 local -a pool_names=("${TESTNAME}_0" "${TESTNAME}_1" "${TESTNAME}_2")
8217 local -a pool_ranges=("0 0" "1 1" "0 1")
8220 for i in "${!pool_names[@]}"; do
8221 pool_add ${pool_names[$i]} ||
8222 error "pool_add failed (pool: ${pool_names[$i]})"
8223 pool_add_targets ${pool_names[$i]} ${pool_ranges[$i]} ||
8224 error "pool_add_targets failed (pool: ${pool_names[$i]})"
8227 # init the file to migrate
8228 $LFS setstripe -c1 -i1 $DIR/$tfile ||
8229 error "Unable to create $tfile on OST1"
8230 stack_trap "rm -f $DIR/$tfile"
8231 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=4 status=none ||
8232 error "Unable to write on $tfile"
8234 echo "1. migrate $tfile on pool ${pool_names[0]}"
8235 sub_test_56xg "-c-1" "${pool_names[0]}" ${pool_ranges[0]}
8237 echo "2. migrate $tfile on pool ${pool_names[2]}"
8238 sub_test_56xg "-c-1 -S2M" "${pool_names[2]}" ${pool_ranges[2]}
8240 echo "3. migrate $tfile on pool ${pool_names[1]}"
8241 sub_test_56xg "-n -c-1" "${pool_names[1]}" ${pool_ranges[1]}
8243 echo "4. migrate $tfile on pool ${pool_names[2]} with default stripe parameters"
8244 sub_test_56xg "" "${pool_names[2]}" ${pool_ranges[2]}
8248 destroy_test_pools ||
8249 error "pool_destroy failed"
8251 run_test 56xg "lfs migrate pool support"
8254 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8257 local file1=$DIR/$tfile
8258 local tmp1=$TMP/$tfile.tmp
8260 $LFS setstripe -c 2 $file1
8262 stack_trap "rm -f $file1 $tmp1"
8263 dd if=/dev/urandom of=$tmp1 bs=1M count=$size_mb ||
8264 error "error creating $tmp1"
8268 local start=$SECONDS
8270 $LFS migrate --stats --stats-interval=1 -W 1M -c 1 $file1 ||
8271 error "migrate failed rc = $?"
8273 local elapsed=$((SECONDS - start))
8275 # with 1MB/s, elapsed should equal size_mb
8276 (( elapsed >= size_mb * 95 / 100 )) ||
8277 error "'lfs migrate -W' too fast ($elapsed < 0.95 * $size_mb)?"
8279 (( elapsed <= size_mb * 120 / 100 )) ||
8280 error_not_in_vm "'lfs migrate -W' slow ($elapsed > 1.2 * $size_mb)"
8282 (( elapsed <= size_mb * 350 / 100 )) ||
8283 error "'lfs migrate -W' too slow in VM ($elapsed > 3.5 * $size_mb)"
8285 stripe=$($LFS getstripe -c $file1)
8286 (( $stripe == 1 )) || error "stripe of $file1 is $stripe != 1"
8287 cmp $file1 $tmp1 || error "content mismatch $file1 differs from $tmp1"
8289 # Clean up file (since it is multiple MB)
8292 run_test 56xh "lfs migrate bandwidth limitation support"
8295 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8296 verify_yaml_available || skip_env "YAML verification not installed"
8299 local file1=$DIR/$tfile.1
8300 local file2=$DIR/$tfile.2
8301 local file3=$DIR/$tfile.3
8302 local output_file=$DIR/$tfile.out
8303 local tmp1=$TMP/$tfile.tmp
8305 $LFS setstripe -c 2 $file1
8306 $LFS setstripe -c 2 $file2
8307 $LFS setstripe -c 2 $file3
8309 stack_trap "rm -f $file1 $file2 $file3 $tmp1 $output_file"
8310 dd if=/dev/urandom of=$tmp1 bs=1M count=$size_mb ||
8311 error "error creating $tmp1"
8317 $LFS migrate --stats --stats-interval=1 \
8318 -c 1 $file1 $file2 $file3 1> $output_file ||
8319 error "migrate failed rc = $?"
8322 cat $output_file | verify_yaml || error "rename_stats is not valid YAML"
8324 # Clean up file (since it is multiple MB)
8325 rm -f $file1 $file2 $file3 $tmp1 $output_file
8327 run_test 56xi "lfs migrate stats support"
8329 test_56xj() { # LU-16571 "lfs migrate -b" can cause thread starvation on OSS
8330 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8332 local file=$DIR/$tfile
8333 local linkdir=$DIR/$tdir
8335 test_mkdir $linkdir || error "fail to create $linkdir"
8336 $LFS setstripe -i 0 -c 1 -S1M $file
8337 stack_trap "rm -rf $file $linkdir"
8338 dd if=/dev/urandom of=$file bs=1M count=10 ||
8339 error "fail to create $file"
8346 thread_max=$(do_facet ost1 "$LCTL get_param -n ost.OSS.ost.threads_max")
8347 cpts=$(do_facet ost1 "$LCTL get_param -n cpu_partition_table | wc -l")
8348 (( nlinks = thread_max * 3 / 2 / cpts))
8350 echo "create $nlinks hard links of $file"
8351 createmany -l $file $linkdir/link $nlinks
8353 # Parallel migrates (should not block)
8355 for ((i = 0; i < nlinks; i++)); do
8356 echo $linkdir/link$i
8357 done | xargs -n1 -P $nlinks $LFS migrate -c2
8360 stripe_count=$($LFS getstripe -c $file) ||
8361 error "fail to get stripe count on $file"
8363 ((stripe_count == 2)) ||
8364 error "fail to migrate $file (stripe_count = $stripe_count)"
8366 run_test 56xj "lfs migrate -b should not cause starvation of threads on OSS"
8369 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8372 local file1=$DIR/$tfile
8374 stack_trap "rm -f $file1"
8375 $LFS setstripe -c 1 $file1
8376 dd if=/dev/zero of=$file1 bs=1M count=$size_mb ||
8377 error "error creating $file1"
8378 $LFS mirror extend -N $file1 || error "can't mirror"
8379 dd if=/dev/zero of=$file1 bs=4k count=1 conv=notrunc ||
8381 $LFS getstripe $file1 | grep stale ||
8382 error "one component must be stale"
8384 local start=$SECONDS
8385 $LFS mirror resync --stats --stats-interval=1 -W 1M $file1 ||
8386 error "migrate failed rc = $?"
8387 local elapsed=$((SECONDS - start))
8388 $LFS getstripe $file1 | grep stale &&
8389 error "all components must be sync"
8391 # with 1MB/s, elapsed should equal size_mb
8392 (( elapsed >= size_mb * 95 / 100 )) ||
8393 error "'lfs mirror resync -W' too fast ($elapsed < 0.95 * $size_mb)?"
8395 (( elapsed <= size_mb * 120 / 100 )) ||
8396 error_not_in_vm "'lfs mirror resync -W' slow ($elapsed > 1.2 * $size_mb)"
8398 (( elapsed <= size_mb * 350 / 100 )) ||
8399 error "'lfs mirror resync -W' too slow in VM ($elapsed > 3.5 * $size_mb)"
8401 run_test 56xk "lfs mirror resync bandwidth limitation support"
8404 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8405 verify_yaml_available || skip_env "YAML verification not installed"
8408 local file1=$DIR/$tfile.1
8409 local output_file=$DIR/$tfile.out
8411 stack_trap "rm -f $file1"
8412 $LFS setstripe -c 1 $file1
8413 dd if=/dev/zero of=$file1 bs=1M count=$size_mb ||
8414 error "error creating $file1"
8415 $LFS mirror extend -N $file1 || error "can't mirror"
8416 dd if=/dev/zero of=$file1 bs=4k count=1 conv=notrunc ||
8418 $LFS getstripe $file1 | grep stale ||
8419 error "one component must be stale"
8420 $LFS getstripe $file1
8422 $LFS mirror resync --stats --stats-interval=1 $file1 >$output_file ||
8423 error "resync failed rc = $?"
8424 $LFS getstripe $file1 | grep stale &&
8425 error "all components must be sync"
8428 cat $output_file | verify_yaml || error "stats is not valid YAML"
8430 run_test 56xl "lfs mirror resync stats support"
8433 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
8434 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
8437 local dir=$DIR/$tdir
8441 test_mkdir -p $dir || error "creating dir $dir"
8442 touch $f1 || error "creating std file $f1"
8443 $MULTIOP $f2 H2c || error "creating released file $f2"
8445 # a directory can be raid0, so ask only for files
8446 res=$($LFS find $dir -L raid0 -type f | wc -l)
8447 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
8449 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
8450 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
8452 # only files can be released, so no need to force file search
8453 res=$($LFS find $dir -L released)
8454 [[ $res == $f2 ]] || error "search released: found $res != $f2"
8456 res=$($LFS find $dir -type f \! -L released)
8457 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
8459 run_test 56y "lfs find -L raid0|released"
8461 test_56z() { # LU-4824
8462 # This checks to make sure 'lfs find' continues after errors
8463 # There are two classes of errors that should be caught:
8464 # - If multiple paths are provided, all should be searched even if one
8466 # - If errors are encountered during the search, it should not terminate
8468 local dir=$DIR/$tdir
8472 for i in d{0..9}; do
8474 touch $dir/$i/$tfile
8476 $LFS find $DIR/non_existent_dir $dir &&
8477 error "$LFS find did not return an error"
8478 # Make a directory unsearchable. This should NOT be the last entry in
8479 # directory order. Arbitrarily pick the 6th entry
8480 chmod 700 $($LFS find $dir -type d | sed '6!d')
8482 $RUNAS $LFS find $DIR/non_existent $dir
8483 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
8485 # The user should be able to see 10 directories and 9 files
8486 (( count == 19 )) ||
8487 error "$LFS find found $count != 19 entries after error"
8489 run_test 56z "lfs find should continue after an error"
8491 test_56aa() { # LU-5937
8492 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
8494 local dir=$DIR/$tdir
8497 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
8499 createmany -o $dir/striped_dir/${tfile}- 1024
8500 local dirs=$($LFS find --size +8k $dir/)
8502 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
8504 run_test 56aa "lfs find --size under striped dir"
8506 test_56ab() { # LU-10705
8507 test_mkdir $DIR/$tdir
8508 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
8509 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
8510 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
8511 # Flush writes to ensure valid blocks. Need to be more thorough for
8512 # ZFS, since blocks are not allocated/returned to client immediately.
8514 wait_zfs_commit ost1 2
8515 cancel_lru_locks osc
8518 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
8520 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
8522 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
8523 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
8525 rm -f $DIR/$tdir/$tfile.[123]
8527 run_test 56ab "lfs find --blocks"
8531 local dir="$DIR/$tdir"
8532 local perms=(001 002 003 004 005 006 007
8533 010 020 030 040 050 060 070
8534 100 200 300 400 500 600 700
8535 111 222 333 444 555 666 777)
8536 local perm_minus=(8 8 4 8 4 4 2
8540 local perm_slash=(8 8 12 8 12 12 14
8543 16 16 24 16 24 24 28)
8546 for perm in ${perms[*]}; do
8547 touch "$dir/$tfile.$perm"
8548 chmod $perm "$dir/$tfile.$perm"
8551 for ((i = 0; i < ${#perms[*]}; i++)); do
8552 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
8554 error "lfs find -perm ${perms[i]}:"\
8557 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
8558 (( $num == ${perm_minus[i]} )) ||
8559 error "lfs find -perm -${perms[i]}:"\
8560 "$num != ${perm_minus[i]}"
8562 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
8563 (( $num == ${perm_slash[i]} )) ||
8564 error "lfs find -perm /${perms[i]}:"\
8565 "$num != ${perm_slash[i]}"
8568 run_test 56aca "check lfs find -perm with octal representation"
8571 local dir=$DIR/$tdir
8572 # p is the permission of write and execute for user, group and other
8573 # without the umask. It is used to test +wx.
8574 local p=$(printf "%o" "$((0333 & ~$(umask)))")
8575 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
8576 local symbolic=(+t a+t u+t g+t o+t
8582 o=r,ug+o,u+w u=r,a+u,u+w
8583 g=r,ugo=g,u+w u+x,+X +X
8584 u+x,u+X u+X u+x,g+X o+r,+X
8588 for perm in ${perms[*]}; do
8589 touch "$dir/$tfile.$perm"
8590 chmod $perm "$dir/$tfile.$perm"
8593 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
8594 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
8597 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
8600 run_test 56acb "check lfs find -perm with symbolic representation"
8603 local dir=$DIR/$tdir
8604 local tests="17777 787 789 abcd
8605 ug=uu ug=a ug=gu uo=ou urw
8609 for err in $tests; do
8610 if $LFS find $dir -perm $err 2>/dev/null; then
8611 error "lfs find -perm $err: parsing should have failed"
8615 run_test 56acc "check parsing error for lfs find -perm"
8618 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
8619 skip "Need MDS version at least 2.10.50"
8621 # Create composite files with one component
8622 local dir=$DIR/$tdir
8624 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
8625 # Create composite files with three components
8626 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
8627 # LU-16904 Create plain layout files
8628 lfs setstripe -c 1 $dir/$tfile-{1..10}
8630 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
8632 [[ $nfiles == 10 ]] ||
8633 error "lfs find -E 1M found $nfiles != 10 files"
8635 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
8636 [[ $nfiles == 25 ]] ||
8637 error "lfs find ! -E 1M found $nfiles != 25 files"
8639 # All files have a component that starts at 0
8640 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
8641 [[ $nfiles == 35 ]] ||
8642 error "lfs find --component-start 0 - $nfiles != 35 files"
8644 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
8645 [[ $nfiles == 15 ]] ||
8646 error "lfs find --component-start 2M - $nfiles != 15 files"
8648 # All files created here have a componenet that does not starts at 2M
8649 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
8650 [[ $nfiles == 35 ]] ||
8651 error "lfs find ! --component-start 2M - $nfiles != 35 files"
8653 # Find files with a specified number of components
8654 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
8655 [[ $nfiles == 15 ]] ||
8656 error "lfs find --component-count 3 - $nfiles != 15 files"
8658 # Remember non-composite files have a component count of zero
8659 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
8660 [[ $nfiles == 10 ]] ||
8661 error "lfs find --component-count 0 - $nfiles != 10 files"
8663 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
8664 [[ $nfiles == 20 ]] ||
8665 error "lfs find ! --component-count 3 - $nfiles != 20 files"
8667 # All files have a flag called "init"
8668 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
8669 [[ $nfiles == 35 ]] ||
8670 error "lfs find --component-flags init - $nfiles != 35 files"
8672 # Multi-component files will have a component not initialized
8673 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
8674 [[ $nfiles == 15 ]] ||
8675 error "lfs find !--component-flags init - $nfiles != 15 files"
8680 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
8683 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
8684 skip "Need MDS version at least 2.10.57"
8694 # create mirrored directories and mirrored files
8695 mkdir $td || error "mkdir $td failed"
8696 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
8697 createmany -o $tf- 10 || error "create $tf- failed"
8699 for i in $(seq 2); do
8701 mkdir $dir || error "mkdir $dir failed"
8702 $LFS mirror create -N$((3 + i)) $dir ||
8703 error "create mirrored dir $dir failed"
8704 createmany -o $dir/$tfile- 10 ||
8705 error "create $dir/$tfile- failed"
8708 # change the states of some mirrored files
8710 for i in $(seq 2); do
8712 for j in $(seq 4 9); do
8713 echo foo > $dir/$tfile-$j
8717 # find mirrored files with specific mirror count
8718 cmd="$LFS find --mirror-count 3 --type f $td"
8719 nfiles=$($cmd | wc -l)
8720 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
8722 cmd="$LFS find ! --mirror-count 3 --type f $td"
8723 nfiles=$($cmd | wc -l)
8724 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
8726 cmd="$LFS find --mirror-count +2 --type f $td"
8727 nfiles=$($cmd | wc -l)
8728 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8730 cmd="$LFS find --mirror-count -6 --type f $td"
8731 nfiles=$($cmd | wc -l)
8732 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8734 # find mirrored files with specific file state
8735 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
8736 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
8738 cmd="$LFS find --mirror-state=ro --type f $td"
8739 nfiles=$($cmd | wc -l)
8740 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
8742 cmd="$LFS find ! --mirror-state=ro --type f $td"
8743 nfiles=$($cmd | wc -l)
8744 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8746 cmd="$LFS find --mirror-state=wp --type f $td"
8747 nfiles=$($cmd | wc -l)
8748 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8750 cmd="$LFS find ! --mirror-state=sp --type f $td"
8751 nfiles=$($cmd | wc -l)
8752 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8754 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
8756 test_56da() { # LU-14179
8757 local path=$DIR/$tdir
8762 local longdir=$(str_repeat 'a' 255)
8764 for i in {1..15}; do
8771 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
8776 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
8779 touch $(str_repeat 'f' 255)
8781 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
8782 error "lfs find reported an error"
8786 run_test 56da "test lfs find with long paths"
8788 test_56ea() { #LU-10378
8789 local path=$DIR/$tdir
8790 local pool=$TESTNAME
8793 pool_add $pool || error "pool_add $pool failed"
8794 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8795 error "adding targets to $pool failed"
8797 # Set default pool on directory before creating file
8798 mkdir $path || error "mkdir $path failed"
8799 $LFS setstripe -p $pool $path ||
8800 error "set OST pool on $pool failed"
8801 touch $path/$tfile || error "touch $path/$tfile failed"
8803 # Compare basic file attributes from -printf and stat
8804 local attr_printf=$($LFS find $path/$tfile -printf "%A@ %T@ %C@ %U %G %n")
8805 local attr_stat=$(stat -c "%X %Y %Z %u %g %h" $path/$tfile)
8807 [[ "${attr_printf}" == "${attr_stat}" ]] ||
8808 error "Attrs from lfs find and stat don't match"
8810 # Compare Lustre attributes from lfs find and lfs getstripe
8811 local lattr_printf=$($LFS find $path/$tfile -printf "%Lc %LS %Li %Lp")
8812 local str_cnt=$($LFS getstripe --stripe-count $path/$tfile)
8813 local str_size=$($LFS getstripe --stripe-size $path/$tfile)
8814 local str_idx=$($LFS getstripe --stripe-index $path/$tfile)
8815 local fpool=$($LFS getstripe --pool $path/$tfile)
8816 local lattr_getstr="${str_cnt} ${str_size} ${str_idx} ${fpool}"
8818 [[ "${lattr_printf}" == "${lattr_getstr}" ]] ||
8819 error "Attrs from lfs find and lfs getstripe don't match"
8821 # Verify behavior for unknown escape/format sequences
8822 local esc_printf=$($LFS find $path/$tfile -printf '\\ %% \Q %Q')
8824 [[ "${esc_printf}" == '\ % \Q %Q' ]] ||
8825 error "Escape/format codes don't match"
8827 run_test 56ea "test lfs find -printf option"
8830 local dir=$DIR/$tdir
8831 local subdir_1=$dir/subdir_1
8833 test_mkdir -p $subdir_1
8834 ln -s subdir_1 $dir/link_1
8836 $LFS getstripe $dir | grep "^$dir/link_1$" -A1 ||
8837 error "symlink is not followed"
8839 $LFS getstripe --no-follow $dir |
8840 grep "^$dir/link_1 has no stripe info$" ||
8841 error "symlink should not have stripe info"
8844 ln -s testfile $dir/file_link_2
8846 $LFS getstripe $dir | grep "^$dir/file_link_2$" -A1 ||
8847 error "symlink is not followed"
8849 $LFS getstripe --no-follow $dir |
8850 grep "^$dir/file_link_2 has no stripe info$" ||
8851 error "symlink should not have stripe info"
8853 run_test 56eb "check lfs getstripe on symlink"
8856 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8857 local dir=$DIR/$tdir
8858 local srcfile=$dir/srcfile
8859 local srcyaml=$dir/srcyaml
8860 local destfile=$dir/destfile
8864 $LFS setstripe -i 1 $srcfile
8865 $LFS getstripe --hex-idx --yaml $srcfile > $srcyaml
8866 # if the setstripe yaml parsing fails for any reason, the command can
8867 # randomly assign the correct OST index, leading to an erroneous
8868 # success. but the chance of false success is low enough that a
8869 # regression should still be quickly caught.
8870 $LFS setstripe --yaml=$srcyaml $destfile
8872 local srcindex=$($LFS getstripe -i $srcfile)
8873 local destindex=$($LFS getstripe -i $destfile)
8875 if [[ ! $srcindex -eq $destindex ]]; then
8876 error "setstripe did not set OST index correctly"
8879 run_test 56ec "check lfs getstripe,setstripe --hex --yaml"
8882 local dir=$DIR/$tdir
8883 local subdir=$dir/subdir
8884 local file1=$dir/$tfile
8885 local file2=$dir/$tfile\2
8886 local link=$dir/$tfile-link
8890 $LFS setdirstripe -c1 $subdir
8895 nfiles=$($LFS find --links 1 $dir | wc -l)
8896 (( $nfiles == 1 )) ||
8897 error "lfs find --links expected 1 file, got $nfiles"
8899 nfiles=$($LFS find --type f --links 2 $dir | wc -l)
8900 (( $nfiles == 2 )) ||
8901 error "lfs find --links expected 2 files, got $nfiles"
8903 nfiles=$($LFS find --type d --links 2 $dir | wc -l)
8904 (( $nfiles == 1 )) ||
8905 error "lfs find --links expected 1 directory, got $nfiles"
8907 run_test 56eda "check lfs find --links"
8910 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
8912 local dir=$DIR/$tdir
8913 local stripedir=$dir/stripedir
8918 $LFS setdirstripe -c2 $stripedir
8920 $LFS getdirstripe $stripedir
8922 nfiles=$($LFS find --type d --links 2 $stripedir | wc -l)
8923 (( $nfiles == 1 )) ||
8924 error "lfs find --links expected 1 directory, got $nfiles"
8926 run_test 56edb "check lfs find --links for directory striped on multiple MDTs"
8929 local dir=$DIR/$tdir
8942 nfiles=$($LFS find $dir1 $dir2 ! -type d | wc -l)
8943 (( $nfiles == 2 )) ||
8944 error "(1) lfs find expected 2 files, got $nfiles"
8946 nfiles=$($LFS find $dir1 $dir2 -type f | wc -l)
8947 (( $nfiles == 2 )) ||
8948 error "(2) lfs find expected 2 files, got $nfiles"
8950 nfiles=$($LFS find -type f $dir1 $dir2 | wc -l)
8951 (( $nfiles == 2 )) ||
8952 error "(3) lfs find expected 2 files, got $nfiles"
8954 run_test 56ef "lfs find with multiple paths"
8957 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8958 # note test will not do anything if MDS is not local
8959 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8960 skip_env "ldiskfs only test"
8962 remote_mds_nodsh && skip "remote MDS with nodsh"
8964 local MNTDEV="osd*.*MDT*.mntdev"
8965 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
8966 [ -z "$DEV" ] && error "can't access $MNTDEV"
8967 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
8968 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
8969 error "can't access $DEV"
8970 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
8971 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
8975 run_test 57a "verify MDS filesystem created with large inodes =="
8978 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8979 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8980 skip_env "ldiskfs only test"
8982 remote_mds_nodsh && skip "remote MDS with nodsh"
8984 local dir=$DIR/$tdir
8987 local fileN=$dir/f$filecount
8989 rm -rf $dir || error "removing $dir"
8991 local mdtidx=$($LFS getstripe -m $dir)
8992 local mdtname=MDT$(printf %04x $mdtidx)
8993 local facet=mds$((mdtidx + 1))
8995 echo "mcreating $filecount files"
8996 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
8998 # verify that files do not have EAs yet
8999 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
9000 error "$file1 has an EA"
9001 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
9002 error "$fileN has an EA"
9006 df $dir #make sure we get new statfs data
9007 local mdsfree=$(do_facet $facet \
9008 lctl get_param -n osd*.*$mdtname.kbytesfree)
9009 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
9012 echo "opening files to create objects/EAs"
9013 for file in $(seq -f $dir/f%g 1 $filecount); do
9014 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
9015 error "opening $file"
9018 # verify that files have EAs now
9019 $LFS getstripe -y $file1 | grep -q "l_ost_idx" ||
9020 error "$file1 missing EA"
9021 $LFS getstripe -y $fileN | grep -q "l_ost_idx" ||
9022 error "$fileN missing EA"
9024 sleep 1 #make sure we get new statfs data
9026 local mdsfree2=$(do_facet $facet \
9027 lctl get_param -n osd*.*$mdtname.kbytesfree)
9028 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
9030 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
9031 if [ "$mdsfree" != "$mdsfree2" ]; then
9032 error "MDC before $mdcfree != after $mdcfree2"
9034 echo "MDC before $mdcfree != after $mdcfree2"
9035 echo "unable to confirm if MDS has large inodes"
9040 run_test 57b "default LOV EAs are stored inside large inodes ==="
9043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9044 [ -z "$(which wiretest 2>/dev/null)" ] &&
9045 skip_env "could not find wiretest"
9049 run_test 58 "verify cross-platform wire constants =============="
9052 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9054 echo "touch 130 files"
9055 createmany -o $DIR/f59- 130
9057 unlinkmany $DIR/f59- 130
9059 # wait for commitment of removal
9060 wait_delete_completed
9062 run_test 59 "verify cancellation of llog records async ========="
9064 TEST60_HEAD="test_60 run $RANDOM"
9066 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9067 remote_mgs_nodsh && skip "remote MGS with nodsh"
9068 do_facet mgs "! which run-llog.sh &> /dev/null" &&
9069 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
9070 skip_env "missing subtest run-llog.sh"
9072 log "$TEST60_HEAD - from kernel mode"
9073 do_facet mgs "$LCTL dk > /dev/null"
9074 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
9075 do_facet mgs $LCTL dk > $TMP/$tfile
9077 # LU-6388: test llog_reader
9078 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
9079 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
9080 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
9081 skip_env "missing llog_reader"
9082 local fstype=$(facet_fstype mgs)
9083 [ $fstype != ldiskfs -a $fstype != zfs ] &&
9084 skip_env "Only for ldiskfs or zfs type mgs"
9086 local mntpt=$(facet_mntpt mgs)
9087 local mgsdev=$(mgsdevname 1)
9099 #get fid and record list
9100 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
9102 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
9104 #remount mgs as ldiskfs or zfs type
9105 stop mgs || error "stop mgs failed"
9106 mount_fstype mgs || error "remount mgs failed"
9107 for ((i = 0; i < ${#fid_list[@]}; i++)); do
9110 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
9111 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
9116 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
9118 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
9120 echo "obj_file is $obj_file"
9121 do_facet mgs $llog_reader $obj_file
9123 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
9124 awk '{ print $3 }' | sed -e "s/^type=//g")
9125 if [ $rec_type != $rec ]; then
9126 echo "FAILED test_60a wrong record type $rec_type," \
9132 #check obj path if record type is LLOG_LOGID_MAGIC
9133 if [ "$rec" == "1064553b" ]; then
9134 path=$(do_facet mgs $llog_reader $obj_file |
9135 grep "path=" | awk '{ print $NF }' |
9136 sed -e "s/^path=//g")
9137 if [ $obj_file != $mntpt/$path ]; then
9138 echo "FAILED test_60a wrong obj path" \
9139 "$montpt/$path, should be $obj_file"
9146 #restart mgs before "error", otherwise it will block the next test
9147 stop mgs || error "stop mgs failed"
9148 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
9149 $pass || error "test failed, see FAILED test_60a messages for specifics"
9151 run_test 60a "llog_test run from kernel module and test llog_reader"
9153 test_60b() { # bug 6411
9154 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9157 LLOG_COUNT=$(do_facet mgs dmesg |
9158 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
9159 /llog_[a-z]*.c:[0-9]/ {
9171 [[ $LLOG_COUNT -gt 120 ]] &&
9172 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
9174 run_test 60b "limit repeated messages from CERROR/CWARN"
9177 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9179 echo "create 5000 files"
9180 createmany -o $DIR/f60c- 5000
9181 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
9182 lctl set_param fail_loc=0x80000137
9183 unlinkmany $DIR/f60c- 5000
9184 lctl set_param fail_loc=0
9186 run_test 60c "unlink file when mds full"
9189 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9191 SAVEPRINTK=$(lctl get_param -n printk)
9192 # verify "lctl mark" is even working"
9193 MESSAGE="test message ID $RANDOM $$"
9194 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
9195 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
9197 lctl set_param printk=0 || error "set lnet.printk failed"
9198 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
9199 MESSAGE="new test message ID $RANDOM $$"
9200 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
9201 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
9202 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
9204 lctl set_param -n printk="$SAVEPRINTK"
9206 run_test 60d "test printk console message masking"
9209 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9210 remote_mds_nodsh && skip "remote MDS with nodsh"
9213 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
9214 do_facet mds1 lctl set_param fail_loc=0x15b
9217 run_test 60e "no space while new llog is being created"
9220 local old_path=$($LCTL get_param -n debug_path)
9222 stack_trap "$LCTL set_param debug_path=$old_path"
9223 stack_trap "rm -f $TMP/$tfile*"
9224 rm -f $TMP/$tfile* 2> /dev/null
9225 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
9226 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
9227 test_mkdir $DIR/$tdir
9228 # retry in case the open is cached and not released
9229 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
9230 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
9234 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
9236 run_test 60f "change debug_path works"
9242 test_mkdir -c $MDSCOUNT $DIR/$tdir
9247 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
9248 -c $MDSCOUNT $DIR/$tdir/subdir$index \
9250 mkdir $DIR/$tdir/subdir$index 2>/dev/null
9251 rmdir $DIR/$tdir/subdir$index 2>/dev/null
9252 index=$((index + 1))
9258 for i in {0..100}; do
9259 # define OBD_FAIL_OSD_TXN_START 0x19a
9260 local index=$((i % MDSCOUNT + 1))
9262 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
9269 for i in $(seq $MDSCOUNT); do
9270 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
9273 mkdir $DIR/$tdir/new || error "mkdir failed"
9274 rmdir $DIR/$tdir/new || error "rmdir failed"
9276 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
9278 for i in $(seq $MDSCOUNT); do
9279 wait_update_facet mds$i "$LCTL get_param -n \
9280 mdd.$(facet_svc mds$i).lfsck_namespace |
9281 awk '/^status/ { print \\\$2 }'" "completed"
9285 rm -rf $DIR/$tdir || error "rmdir failed"
9287 run_test 60g "transaction abort won't cause MDT hung"
9290 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
9291 skip "Need MDS version at least 2.12.52"
9292 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
9296 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
9297 #define OBD_FAIL_MDS_STRIPE_FID 0x189
9298 for fail_loc in 0x80000188 0x80000189; do
9299 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
9300 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
9301 error "mkdir $dir-$fail_loc failed"
9302 for i in {0..10}; do
9303 # create may fail on missing stripe
9304 echo $i > $DIR/$tdir-$fail_loc/$i
9306 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
9307 error "getdirstripe $tdir-$fail_loc failed"
9308 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
9309 error "migrate $tdir-$fail_loc failed"
9310 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
9311 error "getdirstripe $tdir-$fail_loc failed"
9312 pushd $DIR/$tdir-$fail_loc
9314 echo $f | cmp $f - || error "$f data mismatch"
9317 rm -rf $DIR/$tdir-$fail_loc
9320 run_test 60h "striped directory with missing stripes can be accessed"
9322 function t60i_load() {
9324 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
9325 $LCTL set_param fail_loc=0x131c fail_val=1
9326 for ((i=0; i<5000; i++)); do
9327 touch $DIR/$tdir/f$i
9332 changelog_register || error "changelog_register failed"
9333 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
9334 changelog_users $SINGLEMDS | grep -q $cl_user ||
9335 error "User $cl_user not found in changelog_users"
9336 changelog_chmask "ALL"
9339 for((i=0; i<100; i++)); do
9340 changelog_dump >/dev/null ||
9341 error "can't read changelog"
9345 changelog_deregister || error "changelog_deregister failed"
9346 $LCTL set_param fail_loc=0
9348 run_test 60i "llog: new record vs reader race"
9351 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
9352 skip "need MDS version at least 2.15.50"
9353 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9354 remote_mds_nodsh && skip "remote MDS with nodsh"
9355 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
9357 changelog_users $SINGLEMDS | grep "^cl" &&
9358 skip "active changelog user"
9360 local llog_reader=$(do_facet $SINGLEMDS "which llog_reader 2> /dev/null")
9362 [[ -z $(do_facet $SINGLEMDS ls -d $llog_reader 2> /dev/null) ]] &&
9363 skip_env "missing llog_reader"
9365 mkdir_on_mdt0 $DIR/$tdir
9367 local f=$DIR/$tdir/$tfile
9372 changelog_register || error "cannot register changelog user"
9374 # set changelog_mask to ALL
9375 changelog_chmask "ALL"
9378 createmany -o ${f}- 100 || error "createmany failed as $RUNAS_ID"
9379 unlinkmany ${f}- 100 || error "unlinkmany failed"
9381 tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
9382 mdt_dev=$(facet_device $SINGLEMDS)
9384 do_facet $SINGLEMDS sync
9385 plain=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'dump changelog_catalog \
9386 $tmpfile' $mdt_dev; $llog_reader $tmpfile" |
9387 awk '{match($0,"path=([^ ]+)",a)}END{print a[1]}')
9389 stack_trap "do_facet $SINGLEMDS rm -f $tmpfile"
9391 # if $tmpfile is not on EXT3 filesystem for some reason
9392 [[ ${plain:0:1} == 'O' ]] ||
9393 skip "path $plain is not in 'O/1/d<n>/<n>' format"
9395 size=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'dump $plain $tmpfile' \
9396 $mdt_dev; stat -c %s $tmpfile")
9397 echo "Truncate llog from $size to $((size - size % 8192))"
9398 size=$((size - size % 8192))
9399 do_facet $SINGLEMDS $TRUNCATE $tmpfile $size
9400 errs=$(do_facet $SINGLEMDS "$llog_reader $tmpfile" |
9401 grep -c 'in bitmap only')
9402 (( $errs > 0 )) || error "llog_reader didn't find lost records"
9404 size=$((size - 9000))
9405 echo "Corrupt llog in the middle at $size"
9406 do_facet $SINGLEMDS dd if=/dev/urandom of=$tmpfile bs=1 seek=$size \
9407 count=333 conv=notrunc
9408 errs=$(do_facet $SINGLEMDS "$llog_reader $tmpfile" |
9409 grep -c 'next chunk')
9410 (( $errs > 0 )) || error "llog_reader didn't skip bad chunk"
9412 run_test 60j "llog_reader reports corruptions"
9415 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9418 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
9419 cancel_lru_locks osc
9420 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
9423 run_test 61a "mmap() writes don't make sync hang ================"
9426 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
9428 run_test 61b "mmap() of unstriped file is successful"
9430 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
9431 # Though this test is irrelevant anymore, it helped to reveal some
9432 # other grant bugs (LU-4482), let's keep it.
9433 test_63a() { # was test_63
9434 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9436 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
9438 for i in `seq 10` ; do
9439 dd if=/dev/zero of=$DIR/f63 bs=8k &
9445 rm -f $DIR/f63 || true
9447 run_test 63a "Verify oig_wait interruption does not crash ======="
9449 # bug 2248 - async write errors didn't return to application on sync
9450 # bug 3677 - async write errors left page locked
9452 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9455 lctl set_param debug=-1
9457 # ensure we have a grant to do async writes
9458 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
9461 sync # sync lest earlier test intercept the fail_loc
9463 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9464 lctl set_param fail_loc=0x80000406
9465 $MULTIOP $DIR/$tfile Owy && \
9466 error "sync didn't return ENOMEM"
9467 sync; sleep 2; sync # do a real sync this time to flush page
9468 lctl get_param -n llite.*.dump_page_cache | grep locked && \
9469 error "locked page left in cache after async error" || true
9472 run_test 63b "async write errors should be returned to fsync ==="
9475 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9478 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
9480 run_test 64a "verify filter grant calculations (in kernel) ====="
9483 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9485 bash oos.sh $MOUNT || error "oos.sh failed: $?"
9487 run_test 64b "check out-of-space detection on client"
9490 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
9492 run_test 64c "verify grant shrink"
9498 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
9501 # this does exactly what osc_request.c:osc_announce_cached() does in
9502 # order to calculate max amount of grants to ask from server
9506 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
9507 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
9509 ((rpc_in_flight++));
9510 nrpages=$((nrpages * rpc_in_flight))
9512 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
9514 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
9516 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
9517 local undirty=$((nrpages * PAGE_SIZE))
9519 local max_extent_pages
9520 max_extent_pages=$(import_param $tgt grant_max_extent_size)
9521 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
9522 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
9523 local grant_extent_tax
9524 grant_extent_tax=$(import_param $tgt grant_extent_tax)
9526 undirty=$((undirty + nrextents * grant_extent_tax))
9531 # this is size of unit for grant allocation. It should be equal to
9532 # what tgt_grant.c:tgt_grant_chunk() calculates
9536 local grant_extent_tax
9538 max_brw_size=$(import_param $tgt max_brw_size)
9540 grant_extent_tax=$(import_param $tgt grant_extent_tax)
9542 echo $(((max_brw_size + grant_extent_tax) * 2))
9546 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
9547 skip "OST < 2.10.55 doesn't limit grants enough"
9549 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
9551 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
9552 skip "no grant_param connect flag"
9554 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9556 $LCTL set_param -n -n debug="$OLDDEBUG" || true
9557 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9560 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
9561 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
9563 $LFS setstripe $DIR/$tfile -i 0 -c 1
9564 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
9567 while kill -0 $ddpid; do
9568 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
9570 if [[ $cur_grant -gt $max_cur_granted ]]; then
9572 error "cur_grant $cur_grant > $max_cur_granted"
9578 run_test 64d "check grant limit exceed"
9584 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
9586 ((cur_grants == expected)) ||
9587 error "$msg: grants mismatch: $cur_grants, expected $expected"
9591 echo $((($1 + $2 - 1) & ~($2 - 1)))
9595 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9596 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
9597 skip "Need OSS version at least 2.11.56"
9599 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9600 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9601 $LCTL set_param debug=+cache
9603 # Remount client to reset grant
9604 remount_client $MOUNT || error "failed to remount client"
9605 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9607 local init_grants=$(import_param $osc_tgt initial_grant)
9609 check_grants $osc_tgt $init_grants "init grants"
9611 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9612 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9613 local gbs=$(import_param $osc_tgt grant_block_size)
9615 # write random number of bytes from max_brw_size / 4 to max_brw_size
9616 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9617 # align for direct io
9618 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9619 # round to grant consumption unit
9620 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9622 local grants=$((wb_round_up + extent_tax))
9624 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9625 stack_trap "rm -f $DIR/$tfile"
9627 # define OBD_FAIL_TGT_NO_GRANT 0x725
9628 # make the server not grant more back
9629 do_facet ost1 $LCTL set_param fail_loc=0x725
9630 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
9632 do_facet ost1 $LCTL set_param fail_loc=0
9634 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
9636 rm -f $DIR/$tfile || error "rm failed"
9638 # Remount client to reset grant
9639 remount_client $MOUNT || error "failed to remount client"
9640 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9642 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9644 # define OBD_FAIL_TGT_NO_GRANT 0x725
9645 # make the server not grant more back
9646 do_facet ost1 $LCTL set_param fail_loc=0x725
9647 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
9648 do_facet ost1 $LCTL set_param fail_loc=0
9650 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
9652 run_test 64e "check grant consumption (no grant allocation)"
9655 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9657 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9658 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9659 $LCTL set_param debug=+cache
9661 # Remount client to reset grant
9662 remount_client $MOUNT || error "failed to remount client"
9663 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9665 local init_grants=$(import_param $osc_tgt initial_grant)
9666 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9667 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9668 local gbs=$(import_param $osc_tgt grant_block_size)
9669 local chunk=$(grant_chunk $osc_tgt)
9671 # write random number of bytes from max_brw_size / 4 to max_brw_size
9672 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9673 # align for direct io
9674 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9675 # round to grant consumption unit
9676 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9678 local grants=$((wb_round_up + extent_tax))
9680 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9681 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
9682 error "error writing to $DIR/$tfile"
9684 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9685 "direct io with grant allocation"
9687 rm -f $DIR/$tfile || error "rm failed"
9689 # Remount client to reset grant
9690 remount_client $MOUNT || error "failed to remount client"
9691 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9693 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9695 # Testing that buffered IO consumes grant on the client
9697 # Delay the RPC on the server so it's guaranteed to not complete even
9698 # if the RPC is sent from the client
9699 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
9700 $LCTL set_param fail_loc=0x50a fail_val=3
9701 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 conv=notrunc ||
9702 error "error writing to $DIR/$tfile with buffered IO"
9704 check_grants $osc_tgt $((init_grants - grants)) \
9705 "buffered io, not write rpc"
9707 # Clear the fail loc and do a sync on the client
9708 $LCTL set_param fail_loc=0 fail_val=0
9711 # RPC is now known to have sent
9712 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9713 "buffered io, one RPC"
9715 run_test 64f "check grant consumption (with grant allocation)"
9718 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
9719 skip "Need MDS version at least 2.14.56"
9721 local mdts=$(comma_list $(mdts_nodes))
9723 local old=$($LCTL get_param mdc.$FSNAME-*.grant_shrink_interval |
9725 stack_trap "$LCTL set_param $old"
9727 # generate dirty pages and increase dirty granted on MDT
9728 stack_trap "rm -f $DIR/$tfile-*"
9729 for (( i = 0; i < 10; i++)); do
9730 $LFS setstripe -E 1M -L mdt $DIR/$tfile-$i ||
9731 error "can't set stripe"
9732 dd if=/dev/zero of=$DIR/$tfile-$i bs=128k count=1 ||
9734 $LFS getstripe $DIR/$tfile-$i | grep -q pattern.*mdt || {
9735 $LFS getstripe $DIR/$tfile-$i
9736 error "not DoM file"
9743 # wait until grant shrink reset grant dirty on MDTs
9744 for ((i = 0; i < 120; i++)); do
9745 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9746 awk '{sum=sum+$1} END {print sum}')
9747 vm_dirty=$(awk '/Dirty:/{print $2}' /proc/meminfo)
9748 echo "$grant_dirty grants, $vm_dirty pages"
9749 (( grant_dirty + vm_dirty == 0 )) && break
9750 (( i == 3 )) && sync &&
9751 $LCTL set_param mdc.$FSNAME-*.grant_shrink_interval=5
9755 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9756 awk '{sum=sum+$1} END {print sum}')
9757 (( grant_dirty == 0 )) || error "$grant_dirty on MDT"
9759 run_test 64g "grant shrink on MDT"
9762 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9763 skip "need OST at least 2.14.56 to avoid grant shrink on read"
9765 local instance=$($LFS getname -i $DIR)
9766 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9767 local num_exps=$(do_facet ost1 \
9768 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
9769 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9770 local avail=$($LCTL get_param -n osc.*OST0000-osc-$instance.kbytesavail)
9771 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9773 # 10MiB is for file to be written, max_brw_size * 16 *
9774 # num_exps is space reserve so that tgt_grant_shrink() decided
9776 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
9777 (( avail * 1024 < expect )) &&
9778 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
9780 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
9781 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
9782 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
9783 $LCTL set_param osc.*OST0000*.grant_shrink=1
9784 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
9786 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9787 stack_trap "rm -f $DIR/$tfile"
9788 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
9790 # drop cache so that coming read would do rpc
9791 cancel_lru_locks osc
9793 # shrink interval is set to 10, pause for 7 seconds so that
9794 # grant thread did not wake up yet but coming read entered
9795 # shrink mode for rpc (osc_should_shrink_grant())
9798 declare -a cur_grant_bytes
9799 declare -a tot_granted
9800 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9801 tot_granted[0]=$(do_facet ost1 \
9802 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9804 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
9806 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9807 tot_granted[1]=$(do_facet ost1 \
9808 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9810 # grant change should be equal on both sides
9811 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
9812 tot_granted[0] - tot_granted[1])) ||
9813 error "grant change mismatch, " \
9814 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
9815 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
9817 run_test 64h "grant shrink on read"
9820 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9821 skip "need OST at least 2.14.56 to avoid grant shrink on replay"
9823 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9824 remote_ost_nodsh && skip "remote OSTs with nodsh"
9826 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9827 stack_trap "rm -f $DIR/$tfile"
9829 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
9831 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
9832 local instance=$($LFS getname -i $DIR)
9834 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9835 local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
9837 # shrink grants and simulate rpc loss
9838 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
9839 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
9840 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
9844 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
9846 local testid=$(echo $TESTNAME | tr '_' ' ')
9848 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
9849 grep "GRANT, real grant" &&
9850 error "client has more grants then it owns" || true
9852 run_test 64i "shrink on reconnect"
9854 # bug 1414 - set/get directories' stripe info
9856 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9858 test_mkdir $DIR/$tdir
9860 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
9862 run_test 65a "directory with no stripe info"
9865 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9867 test_mkdir $DIR/$tdir
9868 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9870 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9873 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
9875 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
9878 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9879 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
9881 test_mkdir $DIR/$tdir
9882 local stripesize=$($LFS getstripe -S $DIR/$tdir)
9884 $LFS setstripe -S $((stripesize * 4)) -i 1 \
9885 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
9887 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
9889 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
9892 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9894 test_mkdir $DIR/$tdir
9895 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
9896 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9898 if [[ $STRIPECOUNT -le 0 ]]; then
9900 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
9901 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
9902 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
9904 sc=$(($STRIPECOUNT - 1))
9906 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
9907 touch $DIR/$tdir/f4 $DIR/$tdir/f5
9908 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
9909 error "lverify failed"
9911 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
9914 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9916 # LU-16904 delete layout when root is set as PFL layout
9917 save_layout_restore_at_exit $MOUNT
9918 $LFS setstripe -d $MOUNT || error "setstripe failed"
9920 test_mkdir $DIR/$tdir
9922 $LFS setstripe $DIR/$tdir || error "setstripe"
9923 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9924 error "no stripe info failed"
9926 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
9928 run_test 65e "directory setstripe defaults"
9931 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9933 test_mkdir $DIR/${tdir}f
9934 $RUNAS $LFS setstripe $DIR/${tdir}f &&
9935 error "setstripe succeeded" || true
9937 run_test 65f "dir setstripe permission (should return error) ==="
9940 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9942 # LU-16904 delete layout when root is set as PFL layout
9943 save_layout_restore_at_exit $MOUNT
9944 $LFS setstripe -d $MOUNT || error "setstripe failed"
9946 test_mkdir $DIR/$tdir
9947 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9949 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9950 error "setstripe -S failed"
9951 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
9952 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9953 error "delete default stripe failed"
9955 run_test 65g "directory setstripe -d"
9958 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9960 test_mkdir $DIR/$tdir
9961 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9963 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9964 error "setstripe -S failed"
9965 test_mkdir $DIR/$tdir/dd1
9966 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
9967 error "stripe info inherit failed"
9969 run_test 65h "directory stripe info inherit ===================="
9972 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9974 save_layout_restore_at_exit $MOUNT
9976 # bug6367: set non-default striping on root directory
9977 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
9979 # bug12836: getstripe on -1 default directory striping
9980 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
9982 # bug12836: getstripe -v on -1 default directory striping
9983 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
9985 # bug12836: new find on -1 default directory striping
9986 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
9988 run_test 65i "various tests to set root directory striping"
9990 test_65j() { # bug6367
9991 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9995 # if we aren't already remounting for each test, do so for this test
9996 if [ "$I_MOUNTED" = "yes" ]; then
9997 cleanup || error "failed to unmount"
10001 save_layout_restore_at_exit $MOUNT
10003 $LFS setstripe -d $MOUNT || error "setstripe failed"
10005 run_test 65j "set default striping on root directory (bug 6367)="
10009 wait_delete_completed
10010 do_facet $SINGLEMDS "lctl set_param -n \
10011 osp.$ost*MDT0000.max_create_count=$max_count"
10012 do_facet $SINGLEMDS "lctl set_param -n \
10013 osp.$ost*MDT0000.create_count=$count"
10014 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
10015 echo $INACTIVE_OSC "is Activate"
10017 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
10020 test_65k() { # bug11679
10021 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10022 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10023 remote_mds_nodsh && skip "remote MDS with nodsh"
10025 local disable_precreate=true
10026 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
10027 disable_precreate=false
10029 echo "Check OST status: "
10030 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
10031 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
10033 for OSC in $MDS_OSCS; do
10034 echo $OSC "is active"
10035 do_facet $SINGLEMDS lctl --device %$OSC activate
10038 for INACTIVE_OSC in $MDS_OSCS; do
10039 local ost=$(osc_to_ost $INACTIVE_OSC)
10040 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
10041 lov.*md*.target_obd |
10042 awk -F: /$ost/'{ print $1 }' | head -n 1)
10044 mkdir -p $DIR/$tdir
10045 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
10046 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
10048 echo "Deactivate: " $INACTIVE_OSC
10049 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
10051 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
10052 osp.$ost*MDT0000.create_count")
10053 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
10054 osp.$ost*MDT0000.max_create_count")
10055 $disable_precreate &&
10056 do_facet $SINGLEMDS "lctl set_param -n \
10057 osp.$ost*MDT0000.max_create_count=0"
10059 for idx in $(seq 0 $((OSTCOUNT - 1))); do
10060 [ -f $DIR/$tdir/$idx ] && continue
10061 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
10062 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
10064 error "setstripe $idx should succeed"; }
10065 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
10067 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
10070 do_facet $SINGLEMDS "lctl set_param -n \
10071 osp.$ost*MDT0000.max_create_count=$max_count"
10072 do_facet $SINGLEMDS "lctl set_param -n \
10073 osp.$ost*MDT0000.create_count=$count"
10074 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
10075 echo $INACTIVE_OSC "is Activate"
10077 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
10080 run_test 65k "validate manual striping works properly with deactivated OSCs"
10082 test_65l() { # bug 12836
10083 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10085 test_mkdir -p $DIR/$tdir/test_dir
10086 $LFS setstripe -c -1 $DIR/$tdir/test_dir
10087 $LFS find -mtime -1 $DIR/$tdir >/dev/null
10089 run_test 65l "lfs find on -1 stripe dir ========================"
10092 local layout=$(save_layout $MOUNT)
10093 $RUNAS $LFS setstripe -c 2 $MOUNT && {
10094 restore_layout $MOUNT $layout
10095 error "setstripe should fail by non-root users"
10099 run_test 65m "normal user can't set filesystem default stripe"
10102 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
10103 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
10104 skip "Need MDS version at least 2.12.50"
10105 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
10107 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
10108 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
10109 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
10111 save_layout_restore_at_exit $MOUNT
10113 # new subdirectory under root directory should not inherit
10114 # the default layout from root
10115 # LU-16904 check if the root is set as PFL layout
10116 local numcomp=$($LFS getstripe --component-count $MOUNT)
10118 if [[ $numcomp -eq 0 ]]; then
10119 local dir1=$MOUNT/$tdir-1
10120 mkdir $dir1 || error "mkdir $dir1 failed"
10121 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
10122 error "$dir1 shouldn't have LOV EA"
10125 # delete the default layout on root directory
10126 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
10128 local dir2=$MOUNT/$tdir-2
10129 mkdir $dir2 || error "mkdir $dir2 failed"
10130 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
10131 error "$dir2 shouldn't have LOV EA"
10133 # set a new striping pattern on root directory
10134 local def_stripe_size=$($LFS getstripe -S $MOUNT)
10135 local new_def_stripe_size=$((def_stripe_size * 2))
10136 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
10137 error "set stripe size on $MOUNT failed"
10139 # new file created in $dir2 should inherit the new stripe size from
10140 # the filesystem default
10141 local file2=$dir2/$tfile-2
10142 touch $file2 || error "touch $file2 failed"
10144 local file2_stripe_size=$($LFS getstripe -S $file2)
10145 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
10147 echo "file2_stripe_size: '$file2_stripe_size'"
10148 echo "new_def_stripe_size: '$new_def_stripe_size'"
10149 error "$file2 didn't inherit stripe size $new_def_stripe_size"
10152 local dir3=$MOUNT/$tdir-3
10153 mkdir $dir3 || error "mkdir $dir3 failed"
10154 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
10155 # the root layout, which is the actual default layout that will be used
10156 # when new files are created in $dir3.
10157 local dir3_layout=$(get_layout_param $dir3)
10158 local root_dir_layout=$(get_layout_param $MOUNT)
10159 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
10161 echo "dir3_layout: '$dir3_layout'"
10162 echo "root_dir_layout: '$root_dir_layout'"
10163 error "$dir3 should show the default layout from $MOUNT"
10166 # set OST pool on root directory
10167 local pool=$TESTNAME
10168 pool_add $pool || error "add $pool failed"
10169 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
10170 error "add targets to $pool failed"
10172 $LFS setstripe -p $pool $MOUNT ||
10173 error "set OST pool on $MOUNT failed"
10175 # new file created in $dir3 should inherit the pool from
10176 # the filesystem default
10177 local file3=$dir3/$tfile-3
10178 touch $file3 || error "touch $file3 failed"
10180 local file3_pool=$($LFS getstripe -p $file3)
10181 [[ "$file3_pool" = "$pool" ]] ||
10182 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
10184 local dir4=$MOUNT/$tdir-4
10185 mkdir $dir4 || error "mkdir $dir4 failed"
10186 local dir4_layout=$(get_layout_param $dir4)
10187 root_dir_layout=$(get_layout_param $MOUNT)
10188 echo "$LFS getstripe -d $dir4"
10189 $LFS getstripe -d $dir4
10190 echo "$LFS getstripe -d $MOUNT"
10191 $LFS getstripe -d $MOUNT
10192 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
10194 echo "dir4_layout: '$dir4_layout'"
10195 echo "root_dir_layout: '$root_dir_layout'"
10196 error "$dir4 should show the default layout from $MOUNT"
10199 # new file created in $dir4 should inherit the pool from
10200 # the filesystem default
10201 local file4=$dir4/$tfile-4
10202 touch $file4 || error "touch $file4 failed"
10204 local file4_pool=$($LFS getstripe -p $file4)
10205 [[ "$file4_pool" = "$pool" ]] ||
10206 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
10208 # new subdirectory under non-root directory should inherit
10209 # the default layout from its parent directory
10210 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
10211 error "set directory layout on $dir4 failed"
10213 local dir5=$dir4/$tdir-5
10214 mkdir $dir5 || error "mkdir $dir5 failed"
10216 dir4_layout=$(get_layout_param $dir4)
10217 local dir5_layout=$(get_layout_param $dir5)
10218 [[ "$dir4_layout" = "$dir5_layout" ]] ||
10220 echo "dir4_layout: '$dir4_layout'"
10221 echo "dir5_layout: '$dir5_layout'"
10222 error "$dir5 should inherit the default layout from $dir4"
10225 # though subdir under ROOT doesn't inherit default layout, but
10226 # its sub dir/file should be created with default layout.
10227 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
10228 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
10229 skip "Need MDS version at least 2.12.59"
10231 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
10232 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
10233 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
10235 if [ $default_lmv_hash == "none" ]; then
10236 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
10238 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
10239 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
10242 $LFS setdirstripe -D -c 2 $MOUNT ||
10243 error "setdirstripe -D -c 2 failed"
10244 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
10245 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
10246 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
10248 # $dir4 layout includes pool
10249 $LFS setstripe -S $((new_def_stripe_size * 2)) $dir4
10250 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
10251 error "pool lost on setstripe"
10252 $LFS setstripe -E -1 -S $new_def_stripe_size $dir4
10253 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
10254 error "pool lost on compound layout setstripe"
10256 run_test 65n "don't inherit default layout from root for new subdirectories"
10259 (( $MDS1_VERSION >= $(version_code 2.14.57) )) ||
10260 skip "need MDS version at least 2.14.57"
10262 # set OST pool on root directory
10263 local pool=$TESTNAME
10265 pool_add $pool || error "add $pool failed"
10266 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
10267 error "add targets to $pool failed"
10269 local dir1=$MOUNT/$tdir
10271 mkdir $dir1 || error "mkdir $dir1 failed"
10273 # set a new striping pattern on root directory
10274 local def_stripe_size=$($LFS getstripe -S $MOUNT)
10276 $LFS setstripe -p $pool $dir1 ||
10277 error "set directory layout on $dir1 failed"
10279 # $dir1 layout includes pool
10280 $LFS setstripe -S $((def_stripe_size * 2)) $dir1
10281 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
10282 error "pool lost on setstripe"
10283 $LFS setstripe -E 1M -L mdt -E -1 -c 1 $dir1
10284 $LFS getstripe $dir1
10285 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
10286 error "pool lost on compound layout setstripe"
10288 $LFS setdirstripe -i 0 -c 2 $dir1/dir2 ||
10289 error "setdirstripe failed on sub-dir with inherited pool"
10290 $LFS getstripe $dir1/dir2
10291 [[ "$pool" = $($LFS getstripe -p -d $dir1/dir2) ]] ||
10292 error "pool lost on compound layout setdirstripe"
10294 $LFS setstripe -E -1 -c 1 $dir1
10295 $LFS getstripe -d $dir1
10296 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
10297 error "pool lost on setstripe"
10299 run_test 65o "pool inheritance for mdt component"
10301 test_65p () { # LU-16152
10302 local src_dir=$DIR/$tdir/src_dir
10303 local dst_dir=$DIR/$tdir/dst_dir
10304 local yaml_file=$DIR/$tdir/layout.yaml
10307 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
10308 skip "Need at least version 2.15.51"
10310 test_mkdir -p $src_dir
10311 $LFS setstripe -E 2048M -c 4 -E EOF -c 8 $src_dir ||
10312 error "failed to setstripe"
10313 $LFS getstripe --yaml -d $src_dir > $yaml_file ||
10314 error "failed to getstripe"
10316 test_mkdir -p $dst_dir
10317 $LFS setstripe --yaml $yaml_file $dst_dir ||
10318 error "failed to setstripe with yaml file"
10319 border=$($LFS getstripe -d $dst_dir |
10320 awk '/lcme_extent.e_end:/ { print $2; exit; }') ||
10321 error "failed to getstripe"
10323 # 2048M is 0x80000000, or 2147483648
10324 (( $border == 2147483648 )) ||
10325 error "failed to handle huge number in yaml layout"
10327 run_test 65p "setstripe with yaml file and huge number"
10329 # bug 2543 - update blocks count on client
10331 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10333 local COUNT=${COUNT:-8}
10334 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
10335 sync; sync_all_data; sync; sync_all_data
10336 cancel_lru_locks osc
10337 local BLOCKS=$(ls -s --block-size=1k $DIR/f66 | awk '{ print $1 }')
10338 (( BLOCKS >= COUNT )) || error "$DIR/f66 blocks $BLOCKS < $COUNT"
10340 run_test 66 "update inode blocks count on client ==============="
10343 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
10347 swapon -s | awk '($1 == "'$1'") { print $4 }'
10350 # bug5265, obdfilter oa2dentry return -ENOENT
10351 # #define OBD_FAIL_SRV_ENOENT 0x217
10353 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10354 remote_ost_nodsh && skip "remote OST with nodsh"
10357 $LFS setstripe -c 1 -i 0 $f
10358 stack_trap "rm -f $f ${f}.2"
10360 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
10362 do_facet ost1 lctl set_param fail_loc=0x217
10363 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
10364 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
10366 do_facet ost1 lctl set_param fail_loc=0
10367 $DIRECTIO write $f 0 2 || error "write error"
10369 cancel_lru_locks osc
10370 $DIRECTIO read $f 0 1 || error "read error"
10372 do_facet ost1 lctl set_param fail_loc=0x217
10373 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
10375 do_facet ost1 lctl set_param fail_loc=0
10377 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
10380 test_mkdir $DIR/$tdir
10381 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
10382 bash rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
10384 run_test 71 "Running dbench on lustre (don't segment fault) ===="
10386 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
10387 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10388 [ "$RUNAS_ID" = "$UID" ] &&
10389 skip_env "RUNAS_ID = UID = $UID -- skipping"
10390 # Check that testing environment is properly set up. Skip if not
10391 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
10392 skip_env "User $RUNAS_ID does not exist - skipping"
10395 chmod 777 $DIR/$tfile
10396 chmod ug+s $DIR/$tfile
10397 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
10398 error "$RUNAS dd $DIR/$tfile failed"
10399 # See if we are still setuid/sgid
10400 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
10401 error "S/gid is not dropped on write"
10402 # Now test that MDS is updated too
10403 cancel_lru_locks mdc
10404 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
10405 error "S/gid is not dropped on MDS"
10408 run_test 72a "Test that remove suid works properly (bug5695) ===="
10410 test_72b() { # bug 24226 -- keep mode setting when size is not changing
10413 [ "$RUNAS_ID" = "$UID" ] &&
10414 skip_env "RUNAS_ID = UID = $UID -- skipping"
10415 [ "$RUNAS_ID" -eq 0 ] &&
10416 skip_env "RUNAS_ID = 0 -- skipping"
10417 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10418 # Check that testing environment is properly set up. Skip if not
10419 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
10420 skip_env "User $RUNAS_ID does not exist - skipping"
10422 touch $DIR/${tfile}-f{g,u}
10423 test_mkdir $DIR/${tfile}-dg
10424 test_mkdir $DIR/${tfile}-du
10425 chmod 770 $DIR/${tfile}-{f,d}{g,u}
10426 chmod g+s $DIR/${tfile}-{f,d}g
10427 chmod u+s $DIR/${tfile}-{f,d}u
10428 for perm in 777 2777 4777; do
10429 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
10430 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
10431 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
10432 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
10436 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
10438 # bug 3462 - multiple simultaneous MDC requests
10440 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10442 test_mkdir $DIR/d73-1
10443 test_mkdir $DIR/d73-2
10444 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
10447 lctl set_param fail_loc=0x80000129
10448 $MULTIOP $DIR/d73-1/f73-2 Oc &
10450 lctl set_param fail_loc=0
10452 $MULTIOP $DIR/d73-2/f73-3 Oc &
10456 wait $pid1 || return 1
10460 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
10461 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
10462 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
10466 run_test 73 "multiple MDC requests (should not deadlock)"
10468 test_74a() { # bug 6149, 6184
10469 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10472 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
10474 # very important to OR with CFS_FAIL_ONCE (0x80000000) -- otherwise it
10475 # will spin in a tight reconnection loop
10476 $LCTL set_param fail_loc=0x8000030e
10477 # get any lock that won't be difficult - lookup works.
10479 $LCTL set_param fail_loc=0
10483 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
10485 test_74b() { # bug 13310
10486 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10488 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
10490 # very important to OR with CFS_FAIL_ONCE (0x80000000) -- otherwise it
10491 # will spin in a tight reconnection loop
10492 $LCTL set_param fail_loc=0x8000030e
10493 # get a "difficult" lock
10495 $LCTL set_param fail_loc=0
10499 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
10502 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10504 #define OBD_FAIL_LDLM_NEW_LOCK
10505 $LCTL set_param fail_loc=0x319
10506 touch $DIR/$tfile && error "touch successful"
10507 $LCTL set_param fail_loc=0
10510 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
10512 slab_lic=/sys/kernel/slab/lustre_inode_cache
10514 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
10515 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
10516 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
10519 test_76a() { # Now for b=20433, added originally in b=1443
10520 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10522 cancel_lru_locks osc
10523 # there may be some slab objects cached per core
10524 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
10525 local before=$(num_objects)
10526 local count=$((512 * cpus))
10527 [ "$SLOW" = "no" ] && count=$((128 * cpus))
10528 local margin=$((count / 10))
10529 if [[ -f $slab_lic/aliases ]]; then
10530 local aliases=$(cat $slab_lic/aliases)
10531 (( aliases > 0 )) && margin=$((margin * aliases))
10534 echo "before slab objects: $before"
10535 for i in $(seq $count); do
10539 cancel_lru_locks osc
10540 local after=$(num_objects)
10541 echo "created: $count, after slab objects: $after"
10542 # shared slab counts are not very accurate, allow significant margin
10543 # the main goal is that the cache growth is not permanently > $count
10544 while (( after > before + margin )); do
10546 after=$(num_objects)
10548 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
10549 if (( wait > 60 )); then
10550 error "inode slab grew from $before+$margin to $after"
10554 run_test 76a "confirm clients recycle inodes properly ===="
10557 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10558 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
10561 local before=$(num_objects)
10563 for i in $(seq $count); do
10568 local after=$(num_objects)
10571 while (( after > before )); do
10573 after=$(num_objects)
10575 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
10576 if (( wait > 60 )); then
10577 error "inode slab grew from $before to $after"
10581 echo "slab objects before: $before, after: $after"
10583 run_test 76b "confirm clients recycle directory inodes properly ===="
10585 export ORIG_CSUM=""
10588 # Note: in sptlrpc modes which enable its own bulk checksum, the
10589 # original crc32_le bulk checksum will be automatically disabled,
10590 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
10591 # will be checked by sptlrpc code against sptlrpc bulk checksum.
10592 # In this case set_checksums() will not be no-op, because sptlrpc
10593 # bulk checksum will be enabled all through the test.
10595 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
10596 lctl set_param -n osc.*.checksums $1
10600 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
10601 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
10602 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
10603 tr -d [] | head -n1)}
10604 set_checksum_type()
10606 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
10608 log "set checksum type to $1, rc = $rc"
10612 get_osc_checksum_type()
10614 # arugment 1: OST name, like OST0000
10616 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
10617 sed 's/.*\[\(.*\)\].*/\1/g')
10619 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
10620 echo $checksum_type
10623 F77_TMP=$TMP/f77-temp
10626 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
10627 error "error writing to $F77_TMP"
10630 test_77a() { # bug 10889
10631 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10632 $GSS && skip_env "could not run with gss"
10634 [ ! -f $F77_TMP ] && setup_f77
10636 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
10640 run_test 77a "normal checksum read/write operation"
10642 test_77b() { # bug 10889
10643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10644 $GSS && skip_env "could not run with gss"
10646 [ ! -f $F77_TMP ] && setup_f77
10647 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10648 $LCTL set_param fail_loc=0x80000409
10651 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10652 error "dd error: $?"
10653 $LCTL set_param fail_loc=0
10655 for algo in $CKSUM_TYPES; do
10656 cancel_lru_locks osc
10657 set_checksum_type $algo
10658 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10659 $LCTL set_param fail_loc=0x80000408
10660 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
10661 $LCTL set_param fail_loc=0
10664 set_checksum_type $ORIG_CSUM_TYPE
10667 run_test 77b "checksum error on client write, read"
10672 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
10674 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
10675 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
10676 $check_ost && [ -n "$ost_file_prefix" ] &&
10677 do_facet ost1 rm -f ${ost_file_prefix}\*
10681 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10682 $GSS && skip_env "could not run with gss"
10683 remote_ost_nodsh && skip "remote OST with nodsh"
10686 local osc_file_prefix
10688 local check_ost=false
10689 local ost_file_prefix
10695 # ensure corruption will occur on first OSS/OST
10696 $LFS setstripe -i 0 $DIR/$tfile
10698 [ ! -f $F77_TMP ] && setup_f77
10699 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10700 error "dd write error: $?"
10701 fid=$($LFS path2fid $DIR/$tfile)
10703 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
10706 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
10707 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
10709 echo "OSS do not support bulk pages dump upon error"
10712 osc_file_prefix=$($LCTL get_param -n debug_path)
10713 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
10715 trap cleanup_77c EXIT
10718 # enable bulk pages dump upon error on Client
10719 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
10720 # enable bulk pages dump upon error on OSS
10722 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
10724 # flush Client cache to allow next read to reach OSS
10725 cancel_lru_locks osc
10727 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10728 $LCTL set_param fail_loc=0x80000408
10729 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
10730 $LCTL set_param fail_loc=0
10734 # check cksum dump on Client
10735 osc_file=$(ls ${osc_file_prefix}*)
10736 [ -n "$osc_file" ] || error "no checksum dump file on Client"
10737 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
10738 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
10739 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
10740 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
10742 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
10743 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10744 error "dump content does not match on Client"
10746 $check_ost || skip "No need to check cksum dump on OSS"
10748 # check cksum dump on OSS
10749 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
10750 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
10751 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
10752 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
10753 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10754 error "dump content does not match on OSS"
10758 run_test 77c "checksum error on client read with debug"
10760 test_77d() { # bug 10889
10761 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10762 $GSS && skip_env "could not run with gss"
10764 stack_trap "rm -f $DIR/$tfile"
10765 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10766 $LCTL set_param fail_loc=0x80000409
10768 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10769 error "direct write: rc=$?"
10770 $LCTL set_param fail_loc=0
10773 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10774 $LCTL set_param fail_loc=0x80000408
10776 cancel_lru_locks osc
10777 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10778 error "direct read: rc=$?"
10779 $LCTL set_param fail_loc=0
10782 run_test 77d "checksum error on OST direct write, read"
10784 test_77f() { # bug 10889
10785 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10786 $GSS && skip_env "could not run with gss"
10789 stack_trap "rm -f $DIR/$tfile"
10790 for algo in $CKSUM_TYPES; do
10791 cancel_lru_locks osc
10792 set_checksum_type $algo
10793 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10794 $LCTL set_param fail_loc=0x409
10795 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
10796 error "direct write succeeded"
10797 $LCTL set_param fail_loc=0
10799 set_checksum_type $ORIG_CSUM_TYPE
10802 run_test 77f "repeat checksum error on write (expect error)"
10804 test_77g() { # bug 10889
10805 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10806 $GSS && skip_env "could not run with gss"
10807 remote_ost_nodsh && skip "remote OST with nodsh"
10809 [ ! -f $F77_TMP ] && setup_f77
10811 local file=$DIR/$tfile
10812 stack_trap "rm -f $file" EXIT
10814 $LFS setstripe -c 1 -i 0 $file
10815 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
10816 do_facet ost1 lctl set_param fail_loc=0x8000021a
10818 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
10819 error "write error: rc=$?"
10820 do_facet ost1 lctl set_param fail_loc=0
10823 cancel_lru_locks osc
10824 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
10825 do_facet ost1 lctl set_param fail_loc=0x8000021b
10827 cmp $F77_TMP $file || error "file compare failed"
10828 do_facet ost1 lctl set_param fail_loc=0
10831 run_test 77g "checksum error on OST write, read"
10833 test_77k() { # LU-10906
10834 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10835 $GSS && skip_env "could not run with gss"
10837 local cksum_param="osc.$FSNAME*.checksums"
10838 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
10842 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
10843 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
10844 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
10847 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
10848 error "failed to set checksum=$i on MGS"
10849 wait_update $HOSTNAME "$get_checksum" $i
10851 echo "remount client, checksum should be $i"
10852 remount_client $MOUNT || error "failed to remount client"
10853 checksum=$(eval $get_checksum)
10854 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10856 # remove persistent param to avoid races with checksum mountopt below
10857 do_facet mgs $LCTL set_param -P -d $cksum_param ||
10858 error "failed to delete checksum on MGS"
10860 for opt in "checksum" "nochecksum"; do
10861 #remount with mount option
10862 echo "remount client with option $opt, checksum should be $i"
10863 umount_client $MOUNT || error "failed to umount client"
10864 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
10865 error "failed to mount client with option '$opt'"
10866 checksum=$(eval $get_checksum)
10867 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10871 remount_client $MOUNT || error "failed to remount client"
10873 run_test 77k "enable/disable checksum correctly"
10876 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10877 $GSS && skip_env "could not run with gss"
10880 stack_trap "set_checksums $ORIG_CSUM" EXIT
10881 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10883 set_checksum_type invalid && error "unexpected success of invalid checksum type"
10885 $LFS setstripe -c 1 -i 0 $DIR/$tfile
10886 for algo in $CKSUM_TYPES; do
10887 set_checksum_type $algo || error "fail to set checksum type $algo"
10888 osc_algo=$(get_osc_checksum_type OST0000)
10889 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
10891 # no locks, no reqs to let the connection idle
10892 cancel_lru_locks osc
10893 lru_resize_disable osc
10894 wait_osc_import_state client ost1 IDLE
10896 # ensure ost1 is connected
10897 stat $DIR/$tfile >/dev/null || error "can't stat"
10898 wait_osc_import_state client ost1 FULL
10900 osc_algo=$(get_osc_checksum_type OST0000)
10901 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
10905 run_test 77l "preferred checksum type is remembered after reconnected"
10907 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
10912 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
10913 skip "Need at least version 2.14.52"
10914 local param=checksum_speed
10916 $LCTL get_param $param || error "reading $param failed"
10918 csum_speeds=$($LCTL get_param -n $param)
10920 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
10921 error "known checksum types are missing"
10923 run_test 77m "Verify checksum_speed is correctly read"
10925 check_filefrag_77n() {
10930 while read extidx a b start end rest; do
10931 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
10932 nr_ext=$(( $nr_ext + 1 ))
10933 starts+=( ${start%..} )
10936 done < <( filefrag -sv $1 )
10938 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
10943 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
10946 $TRUNCATE $DIR/$tfile 0
10947 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
10948 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
10949 check_filefrag_77n $DIR/$tfile ||
10950 skip "$tfile blocks not contiguous around hole"
10953 stack_trap "set_checksums $ORIG_CSUM" EXIT
10954 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10955 stack_trap "rm -f $DIR/$tfile"
10957 for algo in $CKSUM_TYPES; do
10958 if [[ "$algo" =~ ^t10 ]]; then
10959 set_checksum_type $algo ||
10960 error "fail to set checksum type $algo"
10961 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
10962 error "fail to read $tfile with $algo"
10968 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
10971 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
10972 skip "Need MDS version at least 2.14.55"
10973 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
10974 skip "Need OST version at least 2.14.55"
10975 local ofd=obdfilter
10978 # print OST checksum_type
10979 echo "$ofd.$FSNAME-*.checksum_type:"
10980 do_nodes $(comma_list $(osts_nodes)) \
10981 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type
10983 # print MDT checksum_type
10984 echo "$mdt.$FSNAME-*.checksum_type:"
10985 do_nodes $(comma_list $(mdts_nodes)) \
10986 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type
10988 local o_count=$(do_nodes $(comma_list $(osts_nodes)) \
10989 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l)
10991 (( $o_count == $OSTCOUNT )) ||
10992 error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT"
10994 local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \
10995 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l)
10997 (( $m_count == $MDSCOUNT )) ||
10998 error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT"
11000 run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))"
11002 cleanup_test_78() {
11007 test_78() { # bug 10901
11008 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11009 remote_ost || skip_env "local OST"
11012 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
11013 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
11014 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
11015 echo "MemTotal: $MEMTOTAL"
11017 # reserve 256MB of memory for the kernel and other running processes,
11018 # and then take 1/2 of the remaining memory for the read/write buffers.
11019 if [ $MEMTOTAL -gt 512 ] ;then
11020 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
11022 # for those poor memory-starved high-end clusters...
11023 MEMTOTAL=$((MEMTOTAL / 2))
11025 echo "Mem to use for directio: $MEMTOTAL"
11027 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
11028 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
11029 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
11030 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
11032 echo "Smallest OST: $SMALLESTOST"
11033 [[ $SMALLESTOST -lt 10240 ]] &&
11034 skip "too small OSTSIZE, useless to run large O_DIRECT test"
11036 trap cleanup_test_78 EXIT
11038 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
11039 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
11041 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
11042 echo "File size: $F78SIZE"
11043 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
11044 for i in $(seq 1 $NSEQ); do
11045 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
11046 echo directIO rdwr round $i of $NSEQ
11047 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
11052 run_test 78 "handle large O_DIRECT writes correctly ============"
11054 test_79() { # bug 12743
11055 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11057 wait_delete_completed
11059 BKTOTAL=$(calc_osc_kbytes kbytestotal)
11060 BKFREE=$(calc_osc_kbytes kbytesfree)
11061 BKAVAIL=$(calc_osc_kbytes kbytesavail)
11063 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
11064 DFTOTAL=`echo $STRING | cut -d, -f1`
11065 DFUSED=`echo $STRING | cut -d, -f2`
11066 DFAVAIL=`echo $STRING | cut -d, -f3`
11067 DFFREE=$(($DFTOTAL - $DFUSED))
11069 ALLOWANCE=$((64 * $OSTCOUNT))
11071 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
11072 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
11073 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
11075 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
11076 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
11077 error "df free($DFFREE) mismatch OST free($BKFREE)"
11079 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
11080 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
11081 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
11084 run_test 79 "df report consistency check ======================="
11086 test_80() { # bug 10718
11087 remote_ost_nodsh && skip "remote OST with nodsh"
11088 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11090 # relax strong synchronous semantics for slow backends like ZFS
11091 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
11092 local soc="obdfilter.*.sync_lock_cancel"
11093 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
11095 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
11096 if [ -z "$save" ]; then
11097 soc="obdfilter.*.sync_on_lock_cancel"
11098 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
11101 if [ "$save" != "never" ]; then
11102 local hosts=$(comma_list $(osts_nodes))
11104 do_nodes $hosts $LCTL set_param $soc=never
11105 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
11109 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
11110 sync; sleep 1; sync
11111 local before=$(date +%s)
11112 cancel_lru_locks osc
11113 local after=$(date +%s)
11114 local diff=$((after - before))
11115 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
11119 run_test 80 "Page eviction is equally fast at high offsets too"
11121 test_81a() { # LU-456
11122 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11123 remote_ost_nodsh && skip "remote OST with nodsh"
11125 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
11126 # MUST OR with the CFS_FAIL_ONCE (0x80000000)
11127 do_facet ost1 lctl set_param fail_loc=0x80000228
11129 # write should trigger a retry and success
11130 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11131 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11133 if [ $RC -ne 0 ] ; then
11134 error "write should success, but failed for $RC"
11137 run_test 81a "OST should retry write when get -ENOSPC ==============="
11139 test_81b() { # LU-456
11140 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11141 remote_ost_nodsh && skip "remote OST with nodsh"
11143 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
11144 # Don't OR with the CFS_FAIL_ONCE (0x80000000)
11145 do_facet ost1 lctl set_param fail_loc=0x228
11147 # write should retry several times and return -ENOSPC finally
11148 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11149 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11152 if [ $RC -ne $ENOSPC ] ; then
11153 error "dd should fail for -ENOSPC, but succeed."
11156 run_test 81b "OST should return -ENOSPC when retry still fails ======="
11159 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
11161 test_mkdir $DIR/$tdir.cvsroot
11162 chown $RUNAS_ID $DIR/$tdir.cvsroot
11165 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
11168 # some versions of cvs import exit(1) when asked to import links or
11169 # files they can't read. ignore those files.
11170 local toignore=$(find . -type l -printf '-I %f\n' -o \
11171 ! -perm /4 -printf '-I %f\n')
11172 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
11173 $tdir.reposname vtag rtag
11176 test_mkdir $DIR/$tdir.reposname
11177 chown $RUNAS_ID $DIR/$tdir.reposname
11178 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
11180 cd $DIR/$tdir.reposname
11182 $RUNAS cvs add -m 'addmsg' foo99
11184 $RUNAS cvs commit -m 'nomsg' foo99
11185 rm -fr $DIR/$tdir.cvsroot
11187 run_test 99 "cvs strange file/directory operations"
11190 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11191 [[ "$NETTYPE" =~ tcp ]] ||
11192 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
11193 [[ -n "$(type -p ss)" ]] || skip_env "ss not available"
11194 remote_ost_nodsh && skip "remote OST with nodsh"
11195 remote_mds_nodsh && skip "remote MDS with nodsh"
11196 remote_servers || skip "useless for local single node setup"
11198 ss -tna | ( rc=1; while read STATE SND RCV LOCAL REMOTE STAT; do
11199 [[ "${REMOTE/*:/}" == "$ACCEPTOR_PORT" ]] || continue
11202 if (( ${LOCAL/*:/} >= 1024 )); then
11203 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
11205 error "local: ${LOCAL/*:/} > 1024 remote: ${REMOTE/*:/}"
11208 (( $rc == 0 )) || error "privileged port not found" )
11210 run_test 100 "check local port using privileged port"
11212 function get_named_value()
11216 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
11220 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11225 local cache_limit=32
11227 $LCTL set_param -n osc.*-osc*.rpc_stats=0
11228 $LCTL set_param -n llite.*.read_ahead_stats=0
11229 local max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
11230 awk '/^max_cached_mb/ { print $2 }')
11231 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$max_cached_mb"
11232 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
11235 # randomly read 10000 of 64K chunks from file 3x 32MB in size
11237 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
11238 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
11241 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
11242 get_named_value 'read.but.discarded'); do
11243 discard=$(($discard + $s))
11246 $LCTL get_param osc.*-osc*.rpc_stats
11247 $LCTL get_param llite.*.read_ahead_stats
11249 # Discard is generally zero, but sometimes a few random reads line up
11250 # and trigger larger readahead, which is wasted & leads to discards.
11251 if [[ $(($discard)) -gt $nreads ]]; then
11252 error "too many ($discard) discarded pages"
11254 rm -f $DIR/$tfile || true
11256 run_test 101a "check read-ahead for random reads"
11258 setup_test101bc() {
11259 test_mkdir $DIR/$tdir
11261 local FILE_LENGTH=$2
11264 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
11266 local list=$(comma_list $(osts_nodes))
11267 set_osd_param $list '' read_cache_enable 0
11268 set_osd_param $list '' writethrough_cache_enable 0
11270 trap cleanup_test101bc EXIT
11271 # prepare the read-ahead file
11272 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
11274 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
11275 count=$FILE_SIZE_MB 2> /dev/null
11279 cleanup_test101bc() {
11284 local list=$(comma_list $(osts_nodes))
11285 set_osd_param $list '' read_cache_enable 1
11286 set_osd_param $list '' writethrough_cache_enable 1
11290 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
11295 local stripe_size=$2
11296 local stride_length=$((stripe_size / read_size))
11297 local stride_width=$((stride_length * OSTCOUNT))
11298 local discard_limit=$(( ((stride_length - 1) * 3 / stride_width) *
11299 (stride_width - stride_length) ))
11300 local discard=$($LCTL get_param -n llite.*.read_ahead_stats |
11301 get_named_value 'read.but.discarded' | calc_total)
11303 if [[ $discard -gt $discard_limit ]]; then
11304 $LCTL get_param llite.*.read_ahead_stats
11305 error "($discard limit ${discard_limit}) discarded pages with size (${read_size})"
11307 echo "Read-ahead success for size ${read_size}"
11312 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11313 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11315 local STRIPE_SIZE=1048576
11316 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
11318 if [ $SLOW == "yes" ]; then
11319 local FILE_LENGTH=$((STRIDE_SIZE * 64))
11321 local FILE_LENGTH=$((STRIDE_SIZE * 8))
11324 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
11326 # prepare the read-ahead file
11327 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
11328 cancel_lru_locks osc
11329 for BIDX in 2 4 8 16 32 64 128 256
11331 local BSIZE=$((BIDX*4096))
11332 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
11333 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
11334 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
11335 $LCTL set_param -n llite.*.read_ahead_stats=0
11336 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
11337 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
11338 cancel_lru_locks osc
11339 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
11344 run_test 101b "check stride-io mode read-ahead ================="
11347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11349 local STRIPE_SIZE=1048576
11350 local FILE_LENGTH=$((STRIPE_SIZE*100))
11353 local osc_rpc_stats
11355 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
11357 cancel_lru_locks osc
11358 $LCTL set_param osc.*.rpc_stats=0
11359 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
11360 $LCTL get_param osc.*.rpc_stats
11361 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
11362 local stats=$($LCTL get_param -n $osc_rpc_stats)
11363 local lines=$(echo "$stats" | awk 'END {print NR;}')
11366 if [ $lines -le 20 ]; then
11367 echo "continue debug"
11370 for size in 1 2 4 8; do
11371 local rpc=$(echo "$stats" |
11372 awk '($1 == "'$size':") {print $2; exit; }')
11373 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
11374 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
11376 echo "$osc_rpc_stats check passed!"
11381 run_test 101c "check stripe_size aligned read-ahead"
11384 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11386 local file=$DIR/$tfile
11387 local sz_MB=${FILESIZE_101d:-80}
11388 local ra_MB=${READAHEAD_MB:-40}
11390 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
11391 [ $free_MB -lt $sz_MB ] &&
11392 skip "Need free space ${sz_MB}M, have ${free_MB}M"
11394 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
11395 $LFS setstripe -c -1 $file || error "setstripe failed"
11397 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
11398 echo Cancel LRU locks on lustre client to flush the client cache
11399 cancel_lru_locks osc
11401 echo Disable read-ahead
11402 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
11403 $LCTL set_param -n llite.*.max_read_ahead_mb=0
11404 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
11405 $LCTL get_param -n llite.*.max_read_ahead_mb
11407 echo "Reading the test file $file with read-ahead disabled"
11408 local sz_KB=$((sz_MB * 1024 / 4))
11409 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
11410 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
11411 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
11412 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
11414 echo "Cancel LRU locks on lustre client to flush the client cache"
11415 cancel_lru_locks osc
11416 echo Enable read-ahead with ${ra_MB}MB
11417 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
11419 echo "Reading the test file $file with read-ahead enabled"
11420 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
11421 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
11423 echo "read-ahead disabled time read $raOFF"
11424 echo "read-ahead enabled time read $raON"
11427 wait_delete_completed
11429 # use awk for this check instead of bash because it handles decimals
11430 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
11431 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
11433 run_test 101d "file read with and without read-ahead enabled"
11436 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11438 local file=$DIR/$tfile
11439 local size_KB=500 #KB
11443 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
11444 local need_KB=$((count * size_KB))
11445 [[ $free_KB -le $need_KB ]] &&
11446 skip_env "Need free space $need_KB, have $free_KB"
11448 echo "Creating $count ${size_KB}K test files"
11449 for ((i = 0; i < $count; i++)); do
11450 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
11453 echo "Cancel LRU locks on lustre client to flush the client cache"
11454 cancel_lru_locks $OSC
11456 echo "Reset readahead stats"
11457 $LCTL set_param -n llite.*.read_ahead_stats=0
11459 for ((i = 0; i < $count; i++)); do
11460 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
11463 $LCTL get_param llite.*.max_cached_mb
11464 $LCTL get_param llite.*.read_ahead_stats
11465 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11466 get_named_value 'misses' | calc_total)
11468 for ((i = 0; i < $count; i++)); do
11469 rm -rf $file.$i 2>/dev/null
11472 #10000 means 20% reads are missing in readahead
11473 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
11475 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
11478 which iozone || skip_env "no iozone installed"
11480 local old_debug=$($LCTL get_param debug)
11481 old_debug=${old_debug#*=}
11482 $LCTL set_param debug="reada mmap"
11484 # create a test file
11485 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
11487 echo Cancel LRU locks on lustre client to flush the client cache
11488 cancel_lru_locks osc
11490 echo Reset readahead stats
11491 $LCTL set_param -n llite.*.read_ahead_stats=0
11493 echo mmap read the file with small block size
11494 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
11497 echo checking missing pages
11498 $LCTL get_param llite.*.read_ahead_stats
11499 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11500 get_named_value 'misses' | calc_total)
11502 $LCTL set_param debug="$old_debug"
11503 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
11506 run_test 101f "check mmap read performance"
11508 test_101g_brw_size_test() {
11510 local pages=$((mb * 1048576 / PAGE_SIZE))
11511 local file=$DIR/$tfile
11513 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
11514 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
11515 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
11516 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
11520 stack_trap "rm -f $file" EXIT
11521 $LCTL set_param -n osc.*.rpc_stats=0
11523 # 10 RPCs should be enough for the test
11525 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
11526 { error "dd write ${mb} MB blocks failed"; return 3; }
11527 cancel_lru_locks osc
11528 dd of=/dev/null if=$file bs=${mb}M count=$count ||
11529 { error "dd write ${mb} MB blocks failed"; return 4; }
11531 # calculate number of full-sized read and write RPCs
11532 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
11533 sed -n '/pages per rpc/,/^$/p' |
11534 awk '/'$pages':/ { reads += $2; writes += $6 }; \
11535 END { print reads,writes }'))
11536 # allow one extra full-sized read RPC for async readahead
11537 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
11538 { error "${rpcs[0]} != $count read RPCs"; return 5; }
11539 [[ ${rpcs[1]} == $count ]] ||
11540 { error "${rpcs[1]} != $count write RPCs"; return 6; }
11544 remote_ost_nodsh && skip "remote OST with nodsh"
11547 local osts=$(get_facets OST)
11548 local list=$(comma_list $(osts_nodes))
11549 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11550 local brw_size="obdfilter.*.brw_size"
11552 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11554 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
11556 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
11557 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
11558 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
11559 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
11560 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
11561 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
11563 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
11566 if [[ $orig_mb -lt 16 ]]; then
11567 save_lustre_params $osts "$brw_size" > $p
11568 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
11569 error "set 16MB RPC size failed"
11571 echo "remount client to enable new RPC size"
11572 remount_client $MOUNT || error "remount_client failed"
11575 test_101g_brw_size_test 16 || error "16MB RPC test failed"
11576 # should be able to set brw_size=12, but no rpc_stats for that
11577 test_101g_brw_size_test 8 || error "8MB RPC test failed"
11580 test_101g_brw_size_test 4 || error "4MB RPC test failed"
11582 if [[ $orig_mb -lt 16 ]]; then
11583 restore_lustre_params < $p
11584 remount_client $MOUNT || error "remount_client restore failed"
11587 rm -f $p $DIR/$tfile
11589 run_test 101g "Big bulk(4/16 MiB) readahead"
11592 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11594 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
11595 error "dd 70M file failed"
11596 echo Cancel LRU locks on lustre client to flush the client cache
11597 cancel_lru_locks osc
11599 echo "Reset readahead stats"
11600 $LCTL set_param -n llite.*.read_ahead_stats 0
11602 echo "Read 10M of data but cross 64M bundary"
11603 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
11604 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11605 get_named_value 'misses' | calc_total)
11606 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
11607 rm -f $p $DIR/$tfile
11609 run_test 101h "Readahead should cover current read window"
11612 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
11613 error "dd 10M file failed"
11615 local max_per_file_mb=$($LCTL get_param -n \
11616 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
11617 cancel_lru_locks osc
11618 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
11619 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
11620 error "set max_read_ahead_per_file_mb to 1 failed"
11622 echo "Reset readahead stats"
11623 $LCTL set_param llite.*.read_ahead_stats=0
11625 dd if=$DIR/$tfile of=/dev/null bs=2M
11627 $LCTL get_param llite.*.read_ahead_stats
11628 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11629 awk '/misses/ { print $2 }')
11630 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
11633 run_test 101i "allow current readahead to exceed reservation"
11636 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
11637 error "setstripe $DIR/$tfile failed"
11638 local file_size=$((1048576 * 16))
11639 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
11640 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
11642 echo Disable read-ahead
11643 $LCTL set_param -n llite.*.max_read_ahead_mb=0
11645 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
11646 for blk in $PAGE_SIZE 1048576 $file_size; do
11647 cancel_lru_locks osc
11648 echo "Reset readahead stats"
11649 $LCTL set_param -n llite.*.read_ahead_stats=0
11650 local count=$(($file_size / $blk))
11651 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
11652 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11653 get_named_value 'failed.to.fast.read' | calc_total)
11654 $LCTL get_param -n llite.*.read_ahead_stats
11655 [ $miss -eq $count ] || error "expected $count got $miss"
11658 rm -f $p $DIR/$tfile
11660 run_test 101j "A complete read block should be submitted when no RA"
11662 test_readahead_base() {
11663 local file=$DIR/$tfile
11669 $LCTL set_param -n llite.*.read_ahead_stats=0
11670 # The first page is not accounted into readahead
11671 ramax=$(((size + PAGE_SIZE - 1) / PAGE_SIZE - 1))
11672 iosz=$(((size + 1048575) / 1048576 * 1048576))
11673 echo "Test readahead: size=$size ramax=$ramx iosz=$iosz"
11675 $LCTL mark "Test readahead: size=$size ramax=$ramx iosz=$iosz"
11676 fallocate -l $size $file || error "failed to fallocate $file"
11677 cancel_lru_locks osc
11678 $MULTIOP $file or${iosz}c || error "failed to read $file"
11679 $LCTL get_param -n llite.*.read_ahead_stats
11680 ranum=$($LCTL get_param -n llite.*.read_ahead_stats |
11681 awk '/readahead.pages/ { print $7 }' | calc_total)
11682 (( $ranum <= $ramax )) ||
11683 error "read-ahead pages is $ranum more than $ramax"
11684 rm -rf $file || error "failed to remove $file"
11689 local file=$DIR/$tfile
11695 check_set_fallocate_or_skip
11696 stack_trap "rm -f $file" EXIT
11698 test_readahead_base 4096
11700 # file size: 16K = 16384
11701 test_readahead_base 16384
11702 test_readahead_base 16385
11703 test_readahead_base 16383
11705 # file size: 1M + 1 = 1048576 + 1
11706 test_readahead_base 1048577
11707 # file size: 1M + 16K
11708 test_readahead_base $((1048576 + 16384))
11710 # file size: stripe_size * (stripe_count - 1) + 16K
11711 $LFS setstripe -c -1 $file || error "failed to setstripe $file"
11712 test_readahead_base $((1048576 * (OSTCOUNT - 1) + 16384))
11713 # file size: stripe_size * stripe_count + 16K
11714 $LFS setstripe -c -1 $file || error "failed to setstripe $file"
11715 test_readahead_base $((1048576 * OSTCOUNT + 16384))
11716 # file size: 2 * stripe_size * stripe_count + 16K
11717 $LFS setstripe -c -1 $file || error "failed to setstripe $file"
11718 test_readahead_base $((2 * 1048576 * OSTCOUNT + 16384))
11720 run_test 101m "read ahead for small file and last stripe of the file"
11723 test_mkdir $DIR/$tdir
11724 chown $RUNAS_ID $DIR/$tdir
11727 STRIPE_COUNT=$OSTCOUNT
11728 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
11730 trap cleanup_test102 EXIT
11732 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
11734 for num in 1 2 3 4; do
11735 for count in $(seq 1 $STRIPE_COUNT); do
11736 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
11737 local size=`expr $STRIPE_SIZE \* $num`
11738 local file=file"$num-$idx-$count"
11739 $1 $LFS setstripe -S $size -i $idx -c $count $file
11745 $1 tar cf $TMP/f102.tar $tdir --xattrs
11748 cleanup_test102() {
11750 rm -f $TMP/f102.tar
11751 rm -rf $DIR/d0.sanity/d102
11755 [ "$UID" != 0 ] && skip "must run as root"
11756 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
11757 skip_env "must have user_xattr"
11759 [ -z "$(which setfattr 2>/dev/null)" ] &&
11760 skip_env "could not find setfattr"
11762 local testfile=$DIR/$tfile
11765 echo "set/get xattr..."
11766 setfattr -n trusted.name1 -v value1 $testfile ||
11767 error "setfattr -n trusted.name1=value1 $testfile failed"
11768 getfattr -n trusted.name1 $testfile 2> /dev/null |
11769 grep "trusted.name1=.value1" ||
11770 error "$testfile missing trusted.name1=value1"
11772 setfattr -n user.author1 -v author1 $testfile ||
11773 error "setfattr -n user.author1=author1 $testfile failed"
11774 getfattr -n user.author1 $testfile 2> /dev/null |
11775 grep "user.author1=.author1" ||
11776 error "$testfile missing trusted.author1=author1"
11778 echo "listxattr..."
11779 setfattr -n trusted.name2 -v value2 $testfile ||
11780 error "$testfile unable to set trusted.name2"
11781 setfattr -n trusted.name3 -v value3 $testfile ||
11782 error "$testfile unable to set trusted.name3"
11783 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
11784 grep "trusted.name" | wc -l) -eq 3 ] ||
11785 error "$testfile missing 3 trusted.name xattrs"
11787 setfattr -n user.author2 -v author2 $testfile ||
11788 error "$testfile unable to set user.author2"
11789 setfattr -n user.author3 -v author3 $testfile ||
11790 error "$testfile unable to set user.author3"
11791 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
11792 grep "user.author" | wc -l) -eq 3 ] ||
11793 error "$testfile missing 3 user.author xattrs"
11795 echo "remove xattr..."
11796 setfattr -x trusted.name1 $testfile ||
11797 error "$testfile error deleting trusted.name1"
11798 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
11799 error "$testfile did not delete trusted.name1 xattr"
11801 setfattr -x user.author1 $testfile ||
11802 error "$testfile error deleting user.author1"
11803 echo "set lustre special xattr ..."
11804 $LFS setstripe -c1 $testfile
11805 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
11806 awk -F "=" '/trusted.lov/ { print $2 }' )
11807 setfattr -n "trusted.lov" -v $lovea $testfile ||
11808 error "$testfile doesn't ignore setting trusted.lov again"
11809 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
11810 error "$testfile allow setting invalid trusted.lov"
11813 run_test 102a "user xattr test =================================="
11815 check_102b_layout() {
11817 local testfile=$DIR/$tfile
11819 echo "test layout '$layout'"
11820 $LFS setstripe $layout $testfile || error "setstripe failed"
11821 $LFS getstripe -y $testfile
11823 echo "get/set/list trusted.lov xattr ..." # b=10930
11824 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
11825 [[ "$value" =~ "trusted.lov" ]] ||
11826 error "can't get trusted.lov from $testfile"
11827 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
11828 error "getstripe failed"
11830 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
11832 value=$(cut -d= -f2 <<<$value)
11833 # LU-13168: truncated xattr should fail if short lov_user_md header
11834 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
11835 lens="${#value}" || lens="$(seq 4 2 ${#value})"
11836 for len in $lens; do
11837 echo "setfattr $len $testfile.2"
11838 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
11839 [ $len -lt 66 ] && error "short xattr len=$len worked"
11841 local stripe_size=$($LFS getstripe -S $testfile.2)
11842 local stripe_count=$($LFS getstripe -c $testfile.2)
11843 [[ $stripe_size -eq 65536 ]] ||
11844 error "stripe size $stripe_size != 65536"
11845 [[ $stripe_count -eq $stripe_count_orig ]] ||
11846 error "stripe count $stripe_count != $stripe_count_orig"
11847 rm $testfile $testfile.2
11851 [ -z "$(which setfattr 2>/dev/null)" ] &&
11852 skip_env "could not find setfattr"
11853 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11855 # check plain layout
11856 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
11858 # and also check composite layout
11859 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
11862 run_test 102b "getfattr/setfattr for trusted.lov EAs"
11865 [ -z "$(which setfattr 2>/dev/null)" ] &&
11866 skip_env "could not find setfattr"
11867 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11869 # b10930: get/set/list lustre.lov xattr
11870 echo "get/set/list lustre.lov xattr ..."
11871 test_mkdir $DIR/$tdir
11872 chown $RUNAS_ID $DIR/$tdir
11873 local testfile=$DIR/$tdir/$tfile
11874 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
11875 error "setstripe failed"
11876 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
11877 error "getstripe failed"
11878 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
11879 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
11881 local testfile2=${testfile}2
11882 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
11883 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
11885 $RUNAS $MCREATE $testfile2
11886 $RUNAS setfattr -n lustre.lov -v $value $testfile2
11887 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
11888 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
11889 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
11890 [ $stripe_count -eq $STRIPECOUNT ] ||
11891 error "stripe count $stripe_count != $STRIPECOUNT"
11893 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
11895 compare_stripe_info1() {
11896 local stripe_index_all_zero=true
11898 for num in 1 2 3 4; do
11899 for count in $(seq 1 $STRIPE_COUNT); do
11900 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
11901 local size=$((STRIPE_SIZE * num))
11902 local file=file"$num-$offset-$count"
11903 stripe_size=$($LFS getstripe -S $PWD/$file)
11904 [[ $stripe_size -ne $size ]] &&
11905 error "$file: size $stripe_size != $size"
11906 stripe_count=$($LFS getstripe -c $PWD/$file)
11907 # allow fewer stripes to be created, ORI-601
11908 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
11909 error "$file: count $stripe_count != $count"
11910 stripe_index=$($LFS getstripe -i $PWD/$file)
11911 [[ $stripe_index -ne 0 ]] &&
11912 stripe_index_all_zero=false
11916 $stripe_index_all_zero &&
11917 error "all files are being extracted starting from OST index 0"
11921 have_xattrs_include() {
11922 tar --help | grep -q xattrs-include &&
11923 echo --xattrs-include="lustre.*"
11927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11928 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11930 XINC=$(have_xattrs_include)
11932 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11933 cd $DIR/$tdir/$tdir
11934 compare_stripe_info1
11936 run_test 102d "tar restore stripe info from tarfile,not keep osts"
11939 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11940 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11942 XINC=$(have_xattrs_include)
11944 test_mkdir $DIR/$tdir.restore
11946 tar cf - --xattrs $tdir | tar xf - \
11947 -C $DIR/$tdir.restore --xattrs $XINC
11948 cd $DIR/$tdir.restore/$tdir
11949 compare_stripe_info1
11951 run_test 102f "tar copy files, not keep osts"
11954 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
11955 skip "must have user_xattr"
11956 [ -z "$(which setfattr 2>/dev/null)" ] &&
11957 skip_env "could not find setfattr"
11958 [ -z "$(which getfattr 2>/dev/null)" ] &&
11959 skip_env "could not find getfattr"
11961 local xsize=${1:-1024} # in bytes
11962 local file=$DIR/$tfile
11963 local value="$(generate_string $xsize)"
11964 local xbig=trusted.big
11968 log "save $xbig on $file"
11969 if [ -z "$toobig" ]
11971 setfattr -n $xbig -v $value $file ||
11972 error "saving $xbig on $file failed"
11974 setfattr -n $xbig -v $value $file &&
11975 error "saving $xbig on $file succeeded"
11979 local orig=$(get_xattr_value $xbig $file)
11980 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
11982 local xsml=trusted.sml
11983 log "save $xsml on $file"
11984 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
11986 local new=$(get_xattr_value $xbig $file)
11987 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
11989 log "grow $xsml on $file"
11990 setfattr -n $xsml -v "$value" $file ||
11991 error "growing $xsml on $file failed"
11993 new=$(get_xattr_value $xbig $file)
11994 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
11995 log "$xbig still valid after growing $xsml"
12000 test_102h() { # bug 15777
12003 run_test 102h "grow xattr from inside inode to external block"
12006 large_xattr_enabled || skip_env "ea_inode feature disabled"
12008 echo "setting xattr of max xattr size: $(max_xattr_size)"
12009 grow_xattr $(max_xattr_size)
12011 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
12012 echo "This should fail:"
12013 grow_xattr $(($(max_xattr_size) + 10)) 1
12015 run_test 102ha "grow xattr from inside inode to external inode"
12017 test_102i() { # bug 17038
12018 [ -z "$(which getfattr 2>/dev/null)" ] &&
12019 skip "could not find getfattr"
12022 ln -s $DIR/$tfile $DIR/${tfile}link
12023 getfattr -n trusted.lov $DIR/$tfile ||
12024 error "lgetxattr on $DIR/$tfile failed"
12025 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
12026 grep -i "no such attr" ||
12027 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
12028 rm -f $DIR/$tfile $DIR/${tfile}link
12030 run_test 102i "lgetxattr test on symbolic link ============"
12033 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12034 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12036 XINC=$(have_xattrs_include)
12037 setup_test102 "$RUNAS"
12038 chown $RUNAS_ID $DIR/$tdir
12039 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
12040 cd $DIR/$tdir/$tdir
12041 compare_stripe_info1 "$RUNAS"
12043 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
12046 [ -z "$(which setfattr 2>/dev/null)" ] &&
12047 skip "could not find setfattr"
12050 # b22187 just check that does not crash for regular file.
12051 setfattr -n trusted.lov $DIR/$tfile
12052 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
12053 local test_kdir=$DIR/$tdir
12054 test_mkdir $test_kdir
12055 local default_size=$($LFS getstripe -S $test_kdir)
12056 local default_count=$($LFS getstripe -c $test_kdir)
12057 local default_offset=$($LFS getstripe -i $test_kdir)
12058 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
12059 error 'dir setstripe failed'
12060 setfattr -n trusted.lov $test_kdir
12061 local stripe_size=$($LFS getstripe -S $test_kdir)
12062 local stripe_count=$($LFS getstripe -c $test_kdir)
12063 local stripe_offset=$($LFS getstripe -i $test_kdir)
12064 [ $stripe_size -eq $default_size ] ||
12065 error "stripe size $stripe_size != $default_size"
12066 [ $stripe_count -eq $default_count ] ||
12067 error "stripe count $stripe_count != $default_count"
12068 [ $stripe_offset -eq $default_offset ] ||
12069 error "stripe offset $stripe_offset != $default_offset"
12070 rm -rf $DIR/$tfile $test_kdir
12072 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
12075 [ -z "$(which getfattr 2>/dev/null)" ] &&
12076 skip "could not find getfattr"
12078 # LU-532 trusted. xattr is invisible to non-root
12079 local testfile=$DIR/$tfile
12083 echo "listxattr as user..."
12084 chown $RUNAS_ID $testfile
12085 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
12086 grep -q "trusted" &&
12087 error "$testfile trusted xattrs are user visible"
12091 run_test 102l "listxattr size test =================================="
12093 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
12094 local path=$DIR/$tfile
12097 listxattr_size_check $path || error "listattr_size_check $path failed"
12099 run_test 102m "Ensure listxattr fails on small bufffer ========"
12103 getxattr() { # getxattr path name
12104 # Return the base64 encoding of the value of xattr name on path.
12108 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
12110 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
12112 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
12114 getfattr --absolute-names --encoding=base64 --name=$name $path |
12115 awk -F= -v name=$name '$1 == name {
12116 print substr($0, index($0, "=") + 1);
12120 test_102n() { # LU-4101 mdt: protect internal xattrs
12121 [ -z "$(which setfattr 2>/dev/null)" ] &&
12122 skip "could not find setfattr"
12123 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
12125 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
12128 local file0=$DIR/$tfile.0
12129 local file1=$DIR/$tfile.1
12130 local xattr0=$TMP/$tfile.0
12131 local xattr1=$TMP/$tfile.1
12132 local namelist="lov lma lmv link fid version som hsm"
12136 rm -rf $file0 $file1 $xattr0 $xattr1
12137 touch $file0 $file1
12139 # Get 'before' xattrs of $file1.
12140 getfattr --absolute-names --dump --match=- $file1 > $xattr0
12142 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
12143 namelist+=" lfsck_namespace"
12144 for name in $namelist; do
12145 # Try to copy xattr from $file0 to $file1.
12146 value=$(getxattr $file0 trusted.$name 2> /dev/null)
12148 setfattr --name=trusted.$name --value="$value" $file1 ||
12149 error "setxattr 'trusted.$name' failed"
12151 # Try to set a garbage xattr.
12152 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
12154 if [[ x$name == "xlov" ]]; then
12155 setfattr --name=trusted.lov --value="$value" $file1 &&
12156 error "setxattr invalid 'trusted.lov' success"
12158 setfattr --name=trusted.$name --value="$value" $file1 ||
12159 error "setxattr invalid 'trusted.$name' failed"
12162 # Try to remove the xattr from $file1. We don't care if this
12163 # appears to succeed or fail, we just don't want there to be
12164 # any changes or crashes.
12165 setfattr --remove=$trusted.$name $file1 2> /dev/null
12168 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
12171 # Try to copy xattr from $file0 to $file1.
12172 value=$(getxattr $file0 trusted.$name 2> /dev/null)
12174 setfattr --name=trusted.$name --value="$value" $file1 ||
12175 error "setxattr 'trusted.$name' failed"
12177 # Try to set a garbage xattr.
12178 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
12180 setfattr --name=trusted.$name --value="$value" $file1 ||
12181 error "setxattr 'trusted.$name' failed"
12183 # Try to remove the xattr from $file1. We don't care if this
12184 # appears to succeed or fail, we just don't want there to be
12185 # any changes or crashes.
12186 setfattr --remove=$trusted.$name $file1 2> /dev/null
12189 # Get 'after' xattrs of file1.
12190 getfattr --absolute-names --dump --match=- $file1 > $xattr1
12192 if ! diff $xattr0 $xattr1; then
12193 error "before and after xattrs of '$file1' differ"
12196 rm -rf $file0 $file1 $xattr0 $xattr1
12200 run_test 102n "silently ignore setxattr on internal trusted xattrs"
12202 test_102p() { # LU-4703 setxattr did not check ownership
12203 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
12204 skip "MDS needs to be at least 2.5.56"
12206 local testfile=$DIR/$tfile
12210 echo "setfacl as user..."
12211 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
12212 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
12214 echo "setfattr as user..."
12215 setfacl -m "u:$RUNAS_ID:---" $testfile
12216 $RUNAS setfattr -x system.posix_acl_access $testfile
12217 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
12219 run_test 102p "check setxattr(2) correctly fails without permission"
12222 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
12223 skip "MDS needs to be at least 2.6.92"
12225 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
12227 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
12230 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
12231 skip "MDS needs to be at least 2.6.93"
12233 touch $DIR/$tfile || error "touch"
12234 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
12235 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
12236 rm $DIR/$tfile || error "rm"
12239 mkdir -p $DIR/$tdir || error "mkdir"
12240 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
12241 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
12242 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
12243 error "$testfile error deleting user.author1"
12244 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
12245 grep "user.$(basename $tdir)" &&
12246 error "$tdir did not delete user.$(basename $tdir)"
12247 rmdir $DIR/$tdir || error "rmdir"
12250 test_mkdir $DIR/$tdir
12251 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
12252 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
12253 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
12254 error "$testfile error deleting user.author1"
12255 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
12256 grep "user.$(basename $tdir)" &&
12257 error "$tdir did not delete user.$(basename $tdir)"
12258 rmdir $DIR/$tdir || error "rm striped dir"
12260 run_test 102r "set EAs with empty values"
12263 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
12264 skip "MDS needs to be at least 2.11.52"
12266 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12268 save_lustre_params client "llite.*.xattr_cache" > $save
12270 for cache in 0 1; do
12271 lctl set_param llite.*.xattr_cache=$cache
12274 touch $DIR/$tfile || error "touch"
12275 for prefix in lustre security system trusted user; do
12276 # Note getxattr() may fail with 'Operation not
12277 # supported' or 'No such attribute' depending
12278 # on prefix and cache.
12279 getfattr -n $prefix.n102s $DIR/$tfile &&
12280 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
12284 restore_lustre_params < $save
12286 run_test 102s "getting nonexistent xattrs should fail"
12289 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
12290 skip "MDS needs to be at least 2.11.52"
12292 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12294 save_lustre_params client "llite.*.xattr_cache" > $save
12296 for cache in 0 1; do
12297 lctl set_param llite.*.xattr_cache=$cache
12299 for buf_size in 0 256; do
12301 touch $DIR/$tfile || error "touch"
12302 setfattr -n user.multiop $DIR/$tfile
12303 $MULTIOP $DIR/$tfile oa$buf_size ||
12304 error "cannot get zero length xattr value (buf_size = $buf_size)"
12308 restore_lustre_params < $save
12310 run_test 102t "zero length xattr values handled correctly"
12314 local test=$LUSTRE/tests/acl/$1.test
12315 local tmp=$(mktemp -t $1-XXXXXX).test
12323 local sedusers="-e s/bin/$bin/g -e s/daemon/$dmn/g"
12324 local sedgroups="-e s/:users/:$grp/g"
12325 [[ -z "$nbd" ]] || sedusers+=" -e s/nobody/$nbd/g"
12327 sed $sedusers $sedgroups < $test > $tmp
12328 stack_trap "rm -f $tmp"
12329 [[ -s $tmp ]] || error "sed failed to create test script"
12331 echo "performing $1 with bin='$bin' daemon='$dmn' users='$grp'..."
12332 $LUSTRE/tests/acl/run $tmp || error "run_acl_subtest '$1' failed"
12336 [ "$UID" != 0 ] && skip "must run as root"
12337 $GSS && skip_env "could not run under gss"
12338 [[ "$(lctl get_param -n mdc.*-mdc-*.connect_flags)" =~ "acl" ]] ||
12339 skip_env "must have acl enabled"
12340 which setfacl || skip_env "could not find setfacl"
12341 remote_mds_nodsh && skip "remote MDS with nodsh"
12343 local mdts=$(comma_list $(mdts_nodes))
12344 local saved=$(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.job_xattr)
12346 [[ -z "$saved" ]] || do_nodes $mdts $LCTL set_param mdt.*.job_xattr=NONE
12347 stack_trap "[[ -z \"$saved\" ]] || \
12348 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=$saved" EXIT
12350 ACLBIN=${ACLBIN:-"bin"}
12351 ACLDMN=${ACLDMN:-"daemon"}
12352 ACLGRP=${ACLGRP:-"users"}
12353 ACLNBD=${ACLNBD:-"nobody"}
12356 [[ "$(id -u $ACLBIN)" != "$(do_facet mds1 id -u $ACLBIN)" ]]; then
12357 echo "bad 'bin' user '$ACLBIN', using '$USER0'"
12359 if ! id $ACLBIN ; then
12361 skip_env "can't find suitable ACL 'bin' $ACLBIN"
12364 if ! id $ACLDMN || (( $(id -u $ACLDMN) < $(id -u $ACLBIN) )) ||
12365 [[ "$(id -u $ACLDMN)" != "$(do_facet mds1 id -u $ACLDMN)" ]]; then
12366 echo "bad 'daemon' user '$ACLDMN', using '$USER1'"
12368 if ! id $ACLDMN ; then
12370 skip_env "can't find suitable ACL 'daemon' $ACLDMN"
12373 if ! getent group $ACLGRP; then
12374 echo "missing 'users' group '$ACLGRP', using '$TSTUSR'"
12376 if ! getent group $ACLGRP; then
12377 echo "cannot find group '$ACLGRP', adding it"
12379 add_group 60000 $ACLGRP
12383 local bingid=$(getent group $ACLBIN | cut -d: -f 3)
12384 local dmngid=$(getent group $ACLDMN | cut -d: -f 3)
12385 local grpgid=$(getent group $ACLGRP | cut -d: -f 3)
12387 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
12388 echo "group '$ACLGRP' has low gid=$grpgid, use '$TSTUSR'"
12390 if ! getent group $ACLGRP; then
12391 echo "cannot find group '$ACLGRP', adding it"
12393 add_group 60000 $ACLGRP
12395 grpgid=$(getent group $ACLGRP | cut -d: -f 3)
12396 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
12398 skip_env "$ACLGRP gid=$grpgid less than $bingid|$dmngid"
12402 gpasswd -a $ACLDMN $ACLBIN ||
12403 error "setting client group failed" # LU-5641
12404 do_facet mds1 gpasswd -a $ACLDMN $ACLBIN ||
12405 error "setting MDS group failed" # LU-5641
12407 declare -a identity_old
12409 for num in $(seq $MDSCOUNT); do
12410 switch_identity $num true || identity_old[$num]=$?
12413 SAVE_UMASK=$(umask)
12415 mkdir -p $DIR/$tdir
12418 run_acl_subtest cp $ACLBIN $ACLDMN $ACLGRP
12419 run_acl_subtest getfacl-noacl $ACLBIN $ACLDMN $ACLGRP
12420 run_acl_subtest misc $ACLBIN $ACLDMN $ACLGRP
12421 run_acl_subtest permissions $ACLBIN $ACLDMN $ACLGRP
12422 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
12423 # CentOS7- uses nobody=99, while newer distros use nobody=65534
12424 if ! id -u $ACLNBD ||
12425 (( $(id -u nobody) != $(do_facet mds1 id -u nobody) )); then
12427 if ! id -u $ACLNBD; then
12431 if [[ -n "$ACLNBD" ]] && ! getent group $ACLNBD; then
12432 add_group $(id -u $ACLNBD) $ACLNBD
12433 if ! getent group $ACLNBD; then
12437 if (( $MDS1_VERSION > $(version_code 2.8.55) )) &&
12438 [[ -n "$ACLNBD" ]] && which setfattr; then
12439 run_acl_subtest permissions_xattr \
12440 $ACLBIN $ACLDMN $ACLGRP $ACLNBD
12441 elif [[ -z "$ACLNBD" ]]; then
12442 echo "skip 'permission_xattr' test - missing 'nobody' user/grp"
12444 echo "skip 'permission_xattr' test - missing setfattr command"
12446 run_acl_subtest setfacl $ACLBIN $ACLDMN $ACLGRP
12448 # inheritance test got from HP
12449 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
12450 chmod +x make-tree || error "chmod +x failed"
12451 run_acl_subtest inheritance $ACLBIN $ACLDMN $ACLGRP
12454 echo "LU-974 ignore umask when acl is enabled..."
12455 run_acl_subtest 974 $ACLBIN $ACLDMN $ACLGRP
12456 if [ $MDSCOUNT -ge 2 ]; then
12457 run_acl_subtest 974_remote $ACLBIN $ACLDMN $ACLGRP
12460 echo "LU-2561 newly created file is same size as directory..."
12461 if [ "$mds1_FSTYPE" != "zfs" ]; then
12462 run_acl_subtest 2561 $ACLBIN $ACLDMN $ACLGRP
12464 run_acl_subtest 2561_zfs $ACLBIN $ACLDMN $ACLGRP
12467 run_acl_subtest 4924 $ACLBIN $ACLDMN $ACLGRP
12472 for num in $(seq $MDSCOUNT); do
12473 if [ "${identity_old[$num]}" = 1 ]; then
12474 switch_identity $num false || identity_old[$num]=$?
12478 run_test 103a "acl test"
12484 stack_trap "rm -f $DIR/$tfile.*"
12485 for U in {0..511}; do
12487 local O=$(printf "%04o" $U)
12489 umask $(printf "%04o" $((511 ^ $O)))
12490 $LFS setstripe -c 1 $DIR/$tfile.s$O
12491 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
12493 (( $S == ($O & 0666) )) ||
12494 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
12496 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
12497 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
12498 (( $S == ($O & 0666) )) ||
12499 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
12501 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
12502 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
12503 (( $S == ($O & 0666) )) ||
12504 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
12505 rm -f $DIR/$tfile.[smp]$0
12509 # limit the concurrently running threads to 64. LU-11878
12510 local idx=$((U % 64))
12511 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
12516 run_test 103b "umask lfs setstripe"
12519 mkdir -p $DIR/$tdir
12520 cp -rp $DIR/$tdir $DIR/$tdir.bak
12522 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
12523 error "$DIR/$tdir shouldn't contain default ACL"
12524 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
12525 error "$DIR/$tdir.bak shouldn't contain default ACL"
12528 run_test 103c "'cp -rp' won't set empty acl"
12533 local saved_debug=$($LCTL get_param -n debug)
12535 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
12536 skip "MDS needs to be at least 2.14.52"
12538 large_xattr_enabled || skip_env "ea_inode feature disabled"
12540 mkdir -p $DIR/$tdir
12541 # add big LOV EA to cause reply buffer overflow earlier
12542 $LFS setstripe -C 1000 $DIR/$tdir
12543 lctl set_param mdc.*-mdc*.stats=clear
12545 $LCTL set_param debug=0
12546 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
12547 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
12549 # add a large number of default ACLs (expect 8000+ for 2.13+)
12550 for U in {2..7000}; do
12551 setfacl -d -m user:$U:rwx $DIR/$tdir ||
12552 error "Able to add just $U default ACLs"
12554 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
12555 echo "$numacl default ACLs created"
12557 stat $DIR/$tdir || error "Cannot stat directory"
12558 # check file creation
12559 touch $DIR/$tdir/$tfile ||
12560 error "failed to create $tfile with $numacl default ACLs"
12561 stat $DIR/$tdir/$tfile || error "Cannot stat file"
12562 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12563 echo "$fileacl ACLs were inherited"
12564 (( $fileacl == $numacl )) ||
12565 error "Not all default ACLs were inherited: $numacl != $fileacl"
12566 # check that new ACLs creation adds new ACLs to inherited ACLs
12567 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
12568 error "Cannot set new ACL"
12569 numacl=$((numacl + 1))
12570 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12571 (( $fileacl == $numacl )) ||
12572 error "failed to add new ACL: $fileacl != $numacl as expected"
12573 # adds more ACLs to a file to reach their maximum at 8000+
12575 for U in {20000..25000}; do
12576 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
12577 numacl=$((numacl + 1))
12579 echo "Added $numacl more ACLs to the file"
12580 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12581 echo "Total $fileacl ACLs in file"
12582 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
12583 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
12584 rmdir $DIR/$tdir || error "Cannot remove directory"
12586 run_test 103e "inheritance of big amount of default ACLs"
12589 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
12590 skip "MDS needs to be at least 2.14.51"
12592 large_xattr_enabled || skip_env "ea_inode feature disabled"
12594 # enable changelog to consume more internal MDD buffers
12597 mkdir -p $DIR/$tdir
12599 $LFS setstripe -C 1000 $DIR/$tdir
12600 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
12601 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
12602 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
12603 rmdir $DIR/$tdir || error "Cannot remove directory"
12605 run_test 103f "changelog doesn't interfere with default ACLs buffers"
12608 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12611 lfs df || error "lfs df failed"
12612 lfs df -ih || error "lfs df -ih failed"
12613 lfs df -h $DIR || error "lfs df -h $DIR failed"
12614 lfs df -i $DIR || error "lfs df -i $DIR failed"
12615 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
12616 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
12618 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
12619 lctl --device %$OSC deactivate
12620 lfs df || error "lfs df with deactivated OSC failed"
12621 lctl --device %$OSC activate
12622 # wait the osc back to normal
12623 wait_osc_import_ready client ost
12625 lfs df || error "lfs df with reactivated OSC failed"
12628 run_test 104a "lfs df [-ih] [path] test ========================="
12631 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12632 [ $RUNAS_ID -eq $UID ] &&
12633 skip_env "RUNAS_ID = UID = $UID -- skipping"
12635 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
12636 grep "Permission denied" | wc -l)))
12637 if [ $denied_cnt -ne 0 ]; then
12638 error "lfs check servers test failed"
12641 run_test 104b "$RUNAS lfs check servers test ===================="
12644 # Verify $1 is within range of $2.
12645 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
12646 # $1 is <= 2% of $2. Else Fail.
12649 # Strip all units (M, G, T)
12650 actual=$(echo $1 | tr -d A-Z)
12651 expect=$(echo $2 | tr -d A-Z)
12653 expect_lo=$(($expect * 98 / 100)) # 2% below
12654 expect_hi=$(($expect * 102 / 100)) # 2% above
12656 # permit 2% drift above and below
12657 (( $actual >= $expect_lo && $actual <= $expect_hi ))
12661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12662 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
12664 local ost_param="osd-zfs.$FSNAME-OST0000."
12665 local mdt_param="osd-zfs.$FSNAME-MDT0000."
12666 local ofacets=$(get_facets OST)
12667 local mfacets=$(get_facets MDS)
12668 local saved_ost_blocks=
12669 local saved_mdt_blocks=
12671 echo "Before recordsize change"
12672 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
12673 df=($(df -h | grep "$MOUNT"$))
12676 echo "lfs output : ${lfs_df[*]}"
12677 echo "df output : ${df[*]}"
12679 for facet in ${ofacets//,/ }; do
12680 if [ -z $saved_ost_blocks ]; then
12681 saved_ost_blocks=$(do_facet $facet \
12682 lctl get_param -n $ost_param.blocksize)
12683 echo "OST Blocksize: $saved_ost_blocks"
12685 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12686 do_facet $facet zfs set recordsize=32768 $ost
12689 # BS too small. Sufficient for functional testing.
12690 for facet in ${mfacets//,/ }; do
12691 if [ -z $saved_mdt_blocks ]; then
12692 saved_mdt_blocks=$(do_facet $facet \
12693 lctl get_param -n $mdt_param.blocksize)
12694 echo "MDT Blocksize: $saved_mdt_blocks"
12696 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12697 do_facet $facet zfs set recordsize=32768 $mdt
12700 # Give new values chance to reflect change
12703 echo "After recordsize change"
12704 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
12705 df_after=($(df -h | grep "$MOUNT"$))
12708 echo "lfs output : ${lfs_df_after[*]}"
12709 echo "df output : ${df_after[*]}"
12712 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
12713 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
12714 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
12715 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
12716 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
12717 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
12720 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
12721 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
12722 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
12723 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
12724 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
12725 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
12727 # Restore MDT recordize back to original
12728 for facet in ${mfacets//,/ }; do
12729 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12730 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
12733 # Restore OST recordize back to original
12734 for facet in ${ofacets//,/ }; do
12735 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12736 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
12741 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
12744 (( $RUNAS_ID != $UID )) ||
12745 skip_env "RUNAS_ID = UID = $UID -- skipping"
12747 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
12748 skip "lustre version doesn't support lctl dl with non-root"
12750 # debugfs only allows root users to access files, so the
12751 # previous move of the "devices" file to debugfs broke
12752 # "lctl dl" for non-root users. The LU-9680 Netlink
12753 # interface again allows non-root users to list devices.
12754 [ "$($RUNAS $LCTL dl | wc -l)" -ge 3 ] ||
12755 error "lctl dl doesn't work for non root"
12757 ost_count="$($RUNAS $LCTL dl | grep $FSNAME-OST* | wc -l)"
12758 [ "$ost_count" -eq $OSTCOUNT ] ||
12759 error "lctl dl reports wrong number of OST devices"
12761 mdt_count="$($RUNAS $LCTL dl | grep $FSNAME-MDT* | wc -l)"
12762 [ "$mdt_count" -eq $MDSCOUNT ] ||
12763 error "lctl dl reports wrong number of MDT devices"
12765 run_test 104d "$RUNAS lctl dl test"
12768 # doesn't work on 2.4 kernels
12770 if $(flock_is_enabled); then
12771 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
12773 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
12777 run_test 105a "flock when mounted without -o flock test ========"
12781 if $(flock_is_enabled); then
12782 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
12784 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
12788 run_test 105b "fcntl when mounted without -o flock test ========"
12792 if $(flock_is_enabled); then
12793 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
12795 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
12799 run_test 105c "lockf when mounted without -o flock test"
12801 test_105d() { # bug 15924
12802 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12804 test_mkdir $DIR/$tdir
12805 flock_is_enabled || skip_env "mount w/o flock enabled"
12806 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
12807 $LCTL set_param fail_loc=0x80000315
12808 flocks_test 2 $DIR/$tdir
12810 run_test 105d "flock race (should not freeze) ========"
12812 test_105e() { # bug 22660 && 22040
12813 flock_is_enabled || skip_env "mount w/o flock enabled"
12816 flocks_test 3 $DIR/$tfile
12818 run_test 105e "Two conflicting flocks from same process"
12820 test_106() { #bug 10921
12821 test_mkdir $DIR/$tdir
12822 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
12823 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
12825 run_test 106 "attempt exec of dir followed by chown of that dir"
12828 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12836 local save_pattern=$(sysctl -n kernel.core_pattern)
12837 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
12838 sysctl -w kernel.core_pattern=$file
12839 sysctl -w kernel.core_uses_pid=0
12841 ulimit -c unlimited
12847 kill -s 11 $SLEEPPID
12849 if [ -e $file ]; then
12850 size=`stat -c%s $file`
12851 [ $size -eq 0 ] && error "Fail to create core file $file"
12853 error "Fail to create core file $file"
12856 sysctl -w kernel.core_pattern=$save_pattern
12857 sysctl -w kernel.core_uses_pid=$save_uses_pid
12860 run_test 107 "Coredump on SIG"
12863 test_mkdir $DIR/$tdir
12864 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
12865 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
12866 error "mkdir with 256 char should fail, but did not"
12867 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
12868 error "create with 255 char failed"
12869 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
12870 error "create with 256 char should fail, but did not"
12875 run_test 110 "filename length checking"
12877 test_116a() { # was previously test_116()
12878 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12879 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12880 remote_mds_nodsh && skip "remote MDS with nodsh"
12882 echo -n "Free space priority "
12883 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
12888 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
12889 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
12890 stack_trap simple_cleanup_common
12892 # Check if we need to generate uneven OSTs
12893 test_mkdir -p $DIR/$tdir/OST${MINI}
12894 local FILL=$((MINV / 4))
12895 local DIFF=$((MAXV - MINV))
12896 local DIFF2=$((DIFF * 100 / MINV))
12898 local threshold=$(do_facet $SINGLEMDS \
12899 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
12900 threshold=${threshold%%%}
12901 echo -n "Check for uneven OSTs: "
12902 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
12904 if [[ $DIFF2 -gt $threshold ]]; then
12906 echo "Don't need to fill OST$MINI"
12908 # generate uneven OSTs. Write 2% over the QOS threshold value
12910 DIFF=$((threshold - DIFF2 + 2))
12911 DIFF2=$((MINV * DIFF / 100))
12912 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
12913 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
12914 error "setstripe failed"
12915 DIFF=$((DIFF2 / 2048))
12917 while [ $i -lt $DIFF ]; do
12919 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
12920 bs=2M count=1 2>/dev/null
12929 DIFF=$((MAXV - MINV))
12930 DIFF2=$((DIFF * 100 / MINV))
12931 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
12932 if [ $DIFF2 -gt $threshold ]; then
12935 skip "QOS imbalance criteria not met"
12943 # now fill using QOS
12944 $LFS setstripe -c 1 $DIR/$tdir
12945 FILL=$((FILL / 200))
12946 if [ $FILL -gt 600 ]; then
12949 echo "writing $FILL files to QOS-assigned OSTs"
12951 while [ $i -lt $FILL ]; do
12953 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
12954 count=1 2>/dev/null
12957 echo "wrote $i 200k files"
12961 echo "Note: free space may not be updated, so measurements might be off"
12963 DIFF2=$((MAXV - MINV))
12964 echo "free space delta: orig $DIFF final $DIFF2"
12965 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
12966 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
12967 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
12968 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
12969 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
12970 if [[ $DIFF -gt 0 ]]; then
12971 FILL=$((DIFF2 * 100 / DIFF - 100))
12972 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
12975 # Figure out which files were written where
12976 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12977 awk '/'$MINI1': / {print $2; exit}')
12979 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12980 echo "$MINC files created on smaller OST $MINI1"
12981 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12982 awk '/'$MAXI1': / {print $2; exit}')
12984 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12985 echo "$MAXC files created on larger OST $MAXI1"
12986 if [[ $MINC -gt 0 ]]; then
12987 FILL=$((MAXC * 100 / MINC - 100))
12988 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
12990 [[ $MAXC -gt $MINC ]] ||
12991 error_ignore LU-9 "stripe QOS didn't balance free space"
12993 run_test 116a "stripe QOS: free space balance ==================="
12995 test_116b() { # LU-2093
12996 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12997 remote_mds_nodsh && skip "remote MDS with nodsh"
12999 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
13000 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
13001 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
13002 [ -z "$old_rr" ] && skip "no QOS"
13003 do_facet $SINGLEMDS lctl set_param \
13004 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
13005 mkdir -p $DIR/$tdir
13006 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
13007 createmany -o $DIR/$tdir/f- 20 || error "can't create"
13008 do_facet $SINGLEMDS lctl set_param fail_loc=0
13010 do_facet $SINGLEMDS lctl set_param \
13011 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
13013 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
13015 test_117() # bug 10891
13017 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13019 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
13020 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
13021 lctl set_param fail_loc=0x21e
13022 > $DIR/$tfile || error "truncate failed"
13023 lctl set_param fail_loc=0
13024 echo "Truncate succeeded."
13027 run_test 117 "verify osd extend =========="
13029 NO_SLOW_RESENDCOUNT=4
13030 export OLD_RESENDCOUNT=""
13031 set_resend_count () {
13032 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
13033 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
13034 lctl set_param -n $PROC_RESENDCOUNT $1
13035 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
13038 # for reduce test_118* time (b=14842)
13039 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
13041 # Reset async IO behavior after error case
13043 FILE=$DIR/reset_async
13045 # Ensure all OSCs are cleared
13046 $LFS setstripe -c -1 $FILE
13047 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
13052 test_118a() #bug 11710
13054 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13058 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13059 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13060 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
13062 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13063 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13068 run_test 118a "verify O_SYNC works =========="
13072 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13073 remote_ost_nodsh && skip "remote OST with nodsh"
13077 #define OBD_FAIL_SRV_ENOENT 0x217
13078 set_nodes_failloc "$(osts_nodes)" 0x217
13079 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13081 set_nodes_failloc "$(osts_nodes)" 0
13082 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13083 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13086 if [[ $RC -eq 0 ]]; then
13087 error "Must return error due to dropped pages, rc=$RC"
13091 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13092 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13096 echo "Dirty pages not leaked on ENOENT"
13098 # Due to the above error the OSC will issue all RPCs syncronously
13099 # until a subsequent RPC completes successfully without error.
13100 $MULTIOP $DIR/$tfile Ow4096yc
13105 run_test 118b "Reclaim dirty pages on fatal error =========="
13109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13111 # for 118c, restore the original resend count, LU-1940
13112 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
13113 set_resend_count $OLD_RESENDCOUNT
13114 remote_ost_nodsh && skip "remote OST with nodsh"
13118 #define OBD_FAIL_OST_EROFS 0x216
13119 set_nodes_failloc "$(osts_nodes)" 0x216
13121 # multiop should block due to fsync until pages are written
13122 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
13126 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
13127 error "Multiop failed to block on fsync, pid=$MULTIPID"
13130 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13132 if [[ $WRITEBACK -eq 0 ]]; then
13133 error "No page in writeback, writeback=$WRITEBACK"
13136 set_nodes_failloc "$(osts_nodes)" 0
13139 if [[ $RC -ne 0 ]]; then
13140 error "Multiop fsync failed, rc=$RC"
13143 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13144 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13146 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13147 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13151 echo "Dirty pages flushed via fsync on EROFS"
13154 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
13156 # continue to use small resend count to reduce test_118* time (b=14842)
13157 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
13161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13162 remote_ost_nodsh && skip "remote OST with nodsh"
13166 #define OBD_FAIL_OST_BRW_PAUSE_BULK
13167 set_nodes_failloc "$(osts_nodes)" 0x214
13168 # multiop should block due to fsync until pages are written
13169 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
13173 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
13174 error "Multiop failed to block on fsync, pid=$MULTIPID"
13177 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13179 if [[ $WRITEBACK -eq 0 ]]; then
13180 error "No page in writeback, writeback=$WRITEBACK"
13183 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
13184 set_nodes_failloc "$(osts_nodes)" 0
13186 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13187 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13189 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13190 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13194 echo "Dirty pages gaurenteed flushed via fsync"
13197 run_test 118d "Fsync validation inject a delay of the bulk =========="
13200 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13204 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
13205 lctl set_param fail_loc=0x8000040a
13207 # Should simulate EINVAL error which is fatal
13208 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13210 if [[ $RC -eq 0 ]]; then
13211 error "Must return error due to dropped pages, rc=$RC"
13214 lctl set_param fail_loc=0x0
13216 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13217 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13218 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13220 if [[ $LOCKED -ne 0 ]]; then
13221 error "Locked pages remain in cache, locked=$LOCKED"
13224 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13225 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13229 echo "No pages locked after fsync"
13234 run_test 118f "Simulate unrecoverable OSC side error =========="
13237 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13241 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
13242 lctl set_param fail_loc=0x406
13244 # simulate local -ENOMEM
13245 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13248 lctl set_param fail_loc=0
13249 if [[ $RC -eq 0 ]]; then
13250 error "Must return error due to dropped pages, rc=$RC"
13253 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13254 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13255 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13257 if [[ $LOCKED -ne 0 ]]; then
13258 error "Locked pages remain in cache, locked=$LOCKED"
13261 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13262 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13266 echo "No pages locked after fsync"
13271 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
13274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13275 remote_ost_nodsh && skip "remote OST with nodsh"
13279 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
13280 set_nodes_failloc "$(osts_nodes)" 0x20e
13281 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
13282 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13285 set_nodes_failloc "$(osts_nodes)" 0
13286 if [[ $RC -eq 0 ]]; then
13287 error "Must return error due to dropped pages, rc=$RC"
13290 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13291 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13292 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13294 if [[ $LOCKED -ne 0 ]]; then
13295 error "Locked pages remain in cache, locked=$LOCKED"
13298 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13299 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13303 echo "No pages locked after fsync"
13307 run_test 118h "Verify timeout in handling recoverables errors =========="
13309 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
13312 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13313 remote_ost_nodsh && skip "remote OST with nodsh"
13317 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
13318 set_nodes_failloc "$(osts_nodes)" 0x20e
13320 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
13321 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
13324 set_nodes_failloc "$(osts_nodes)" 0
13328 if [[ $RC -ne 0 ]]; then
13329 error "got error, but should be not, rc=$RC"
13332 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13333 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13334 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
13335 if [[ $LOCKED -ne 0 ]]; then
13336 error "Locked pages remain in cache, locked=$LOCKED"
13339 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13340 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13344 echo "No pages locked after fsync"
13348 run_test 118i "Fix error before timeout in recoverable error =========="
13350 [ "$SLOW" = "no" ] && set_resend_count 4
13353 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13354 remote_ost_nodsh && skip "remote OST with nodsh"
13358 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
13359 set_nodes_failloc "$(osts_nodes)" 0x220
13361 # return -EIO from OST
13362 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13364 set_nodes_failloc "$(osts_nodes)" 0x0
13365 if [[ $RC -eq 0 ]]; then
13366 error "Must return error due to dropped pages, rc=$RC"
13369 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13370 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13371 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
13372 if [[ $LOCKED -ne 0 ]]; then
13373 error "Locked pages remain in cache, locked=$LOCKED"
13376 # in recoverable error on OST we want resend and stay until it finished
13377 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13378 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13382 echo "No pages locked after fsync"
13386 run_test 118j "Simulate unrecoverable OST side error =========="
13390 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13391 remote_ost_nodsh && skip "remote OSTs with nodsh"
13393 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
13394 set_nodes_failloc "$(osts_nodes)" 0x20e
13395 test_mkdir $DIR/$tdir
13397 for ((i=0;i<10;i++)); do
13398 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
13399 error "dd to $DIR/$tdir/$tfile-$i failed" )&
13406 set_nodes_failloc "$(osts_nodes)" 0
13409 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
13411 test_118l() # LU-646
13413 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13415 test_mkdir $DIR/$tdir
13416 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
13419 run_test 118l "fsync dir"
13421 test_118m() # LU-3066
13423 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13425 test_mkdir $DIR/$tdir
13426 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
13429 run_test 118m "fdatasync dir ========="
13431 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
13438 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13439 remote_ost_nodsh && skip "remote OSTs with nodsh"
13441 # Sleep to avoid a cached response.
13442 #define OBD_STATFS_CACHE_SECONDS 1
13445 # Inject a 10 second delay in the OST_STATFS handler.
13446 #define OBD_FAIL_OST_STATFS_DELAY 0x242
13447 set_nodes_failloc "$(osts_nodes)" 0x242
13450 stat --file-system $MOUNT > /dev/null
13453 set_nodes_failloc "$(osts_nodes)" 0
13455 if ((end - begin > 20)); then
13456 error "statfs took $((end - begin)) seconds, expected 10"
13459 run_test 118n "statfs() sends OST_STATFS requests in parallel"
13461 test_119a() # bug 11737
13463 BSIZE=$((512 * 1024))
13464 directio write $DIR/$tfile 0 1 $BSIZE
13465 # We ask to read two blocks, which is more than a file size.
13466 # directio will indicate an error when requested and actual
13467 # sizes aren't equeal (a normal situation in this case) and
13468 # print actual read amount.
13469 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
13470 if [ "$NOB" != "$BSIZE" ]; then
13471 error "read $NOB bytes instead of $BSIZE"
13475 run_test 119a "Short directIO read must return actual read amount"
13477 test_119b() # bug 11737
13479 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13481 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
13482 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
13484 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
13485 error "direct read failed"
13488 run_test 119b "Sparse directIO read must return actual read amount"
13490 test_119c() # bug 13099
13493 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
13494 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
13497 run_test 119c "Testing for direct read hitting hole"
13499 # Note: test 119d was removed, skipping 119d for new tests to avoid polluting
13500 # Maloo test history
13504 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13506 local stripe_size=$((1024 * 1024)) #1 MiB
13507 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13508 local file_size=$((25 * stripe_size))
13511 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13512 stack_trap "rm -f $DIR/$tfile*"
13514 # Just a bit bigger than the largest size in the test set below
13515 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
13516 error "buffered i/o to create file failed"
13518 if zfs_or_rotational; then
13519 # DIO on ZFS can take up to 2 seconds per IO
13520 # rotational is better, but still slow.
13521 # Limit testing on those media to larger sizes
13522 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size"
13524 bsizes="$PAGE_SIZE $((PAGE_SIZE * 4)) $stripe_size \
13525 $((stripe_size * 4))"
13528 for bs in $bsizes; do
13529 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13530 echo "Read/write with DIO at size $bs"
13531 # Read and write with DIO from source to dest
13532 dd if=$DIR/$tfile.1 bs=$bs of=$DIR/$tfile.2 \
13533 iflag=direct oflag=direct ||
13536 ls -la $DIR/$tfile.1 $DIR/$tfile.2
13537 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
13538 error "size incorrect, file copy read/write bsize: $bs"
13539 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13540 error "files differ, bsize $bs"
13541 rm -f $DIR/$tfile.2
13544 run_test 119e "Basic tests of dio read and write at various sizes"
13548 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13550 local stripe_size=$((1024 * 1024)) #1 MiB
13551 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13552 local file_size=$((25 * stripe_size))
13555 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13556 stack_trap "rm -f $DIR/$tfile*"
13558 # Just a bit bigger than the largest size in the test set below
13559 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
13560 error "buffered i/o to create file failed"
13562 if zfs_or_rotational; then
13563 # DIO on ZFS can take up to 2 seconds per IO
13564 # rotational is better, but still slow.
13565 # Limit testing on those media to larger sizes
13566 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size"
13568 bsizes="$PAGE_SIZE $((PAGE_SIZE * 4)) $stripe_size \
13569 $((stripe_size * 4))"
13572 for bs in $bsizes; do
13573 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13574 # Read and write with DIO from source to dest in two
13575 # threads - should give correct copy of file
13578 dd if=$DIR/$tfile.1 bs=$bs of=$DIR/$tfile.2 iflag=direct \
13579 oflag=direct conv=notrunc &
13581 # Note block size is different here for a more interesting race
13582 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 \
13583 iflag=direct oflag=direct conv=notrunc &
13589 if (( rc1 != 0 )); then
13590 error "dio copy 1 w/bsize $bs failed: $rc1"
13592 if (( rc2 != 0 )); then
13593 error "dio copy 2 w/bsize $bs failed: $rc2"
13597 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
13598 error "size incorrect, file copy read/write bsize: $bs"
13599 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13600 error "files differ, bsize $bs"
13601 rm -f $DIR/$tfile.2
13604 run_test 119f "dio vs dio race"
13608 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13610 local stripe_size=$((1024 * 1024)) #1 MiB
13611 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13612 local file_size=$((25 * stripe_size))
13615 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13616 stack_trap "rm -f $DIR/$tfile*"
13618 # Just a bit bigger than the largest size in the test set below
13619 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
13620 error "buffered i/o to create file failed"
13622 if zfs_or_rotational; then
13623 # DIO on ZFS can take up to 2 seconds per IO
13624 # rotational is better, but still slow.
13625 # Limit testing on those media to larger sizes
13626 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size"
13628 bsizes="$PAGE_SIZE $((PAGE_SIZE * 4)) $stripe_size \
13629 $((stripe_size * 4))"
13632 for bs in $bsizes; do
13633 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13635 dd if=$DIR/$tfile.1 bs=$bs of=$DIR/$tfile.2 iflag=direct \
13636 oflag=direct conv=notrunc &
13638 # Buffered I/O with similar but not the same block size
13639 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 &
13645 if (( rc1 != 0 )); then
13646 error "dio copy 1 w/bsize $bs failed: $rc1"
13648 if (( rc2 != 0 )); then
13649 error "buffered copy 2 w/bsize $bs failed: $rc2"
13652 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
13653 error "size incorrect"
13654 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13655 error "files differ, bsize $bs"
13656 rm -f $DIR/$tfile.2
13659 run_test 119g "dio vs buffered I/O race"
13662 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13663 remote_mds_nodsh && skip "remote MDS with nodsh"
13664 test_mkdir -i0 -c1 $DIR/$tdir
13665 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13666 skip_env "no early lock cancel on server"
13668 lru_resize_disable mdc
13669 lru_resize_disable osc
13670 cancel_lru_locks mdc
13671 # asynchronous object destroy at MDT could cause bl ast to client
13672 cancel_lru_locks osc
13674 stat $DIR/$tdir > /dev/null
13675 can1=$(do_facet mds1 \
13676 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13677 awk '/ldlm_cancel/ {print $2}')
13678 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13679 awk '/ldlm_bl_callback/ {print $2}')
13680 test_mkdir -i0 -c1 $DIR/$tdir/d1
13681 can2=$(do_facet mds1 \
13682 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13683 awk '/ldlm_cancel/ {print $2}')
13684 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13685 awk '/ldlm_bl_callback/ {print $2}')
13686 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13687 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13688 lru_resize_enable mdc
13689 lru_resize_enable osc
13691 run_test 120a "Early Lock Cancel: mkdir test"
13694 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13695 remote_mds_nodsh && skip "remote MDS with nodsh"
13696 test_mkdir $DIR/$tdir
13697 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13698 skip_env "no early lock cancel on server"
13700 lru_resize_disable mdc
13701 lru_resize_disable osc
13702 cancel_lru_locks mdc
13703 stat $DIR/$tdir > /dev/null
13704 can1=$(do_facet $SINGLEMDS \
13705 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13706 awk '/ldlm_cancel/ {print $2}')
13707 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13708 awk '/ldlm_bl_callback/ {print $2}')
13709 touch $DIR/$tdir/f1
13710 can2=$(do_facet $SINGLEMDS \
13711 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13712 awk '/ldlm_cancel/ {print $2}')
13713 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13714 awk '/ldlm_bl_callback/ {print $2}')
13715 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13716 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13717 lru_resize_enable mdc
13718 lru_resize_enable osc
13720 run_test 120b "Early Lock Cancel: create test"
13723 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13724 remote_mds_nodsh && skip "remote MDS with nodsh"
13725 test_mkdir -i0 -c1 $DIR/$tdir
13726 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13727 skip "no early lock cancel on server"
13729 lru_resize_disable mdc
13730 lru_resize_disable osc
13731 test_mkdir -i0 -c1 $DIR/$tdir/d1
13732 test_mkdir -i0 -c1 $DIR/$tdir/d2
13733 touch $DIR/$tdir/d1/f1
13734 cancel_lru_locks mdc
13735 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
13736 can1=$(do_facet mds1 \
13737 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13738 awk '/ldlm_cancel/ {print $2}')
13739 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13740 awk '/ldlm_bl_callback/ {print $2}')
13741 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13742 can2=$(do_facet mds1 \
13743 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13744 awk '/ldlm_cancel/ {print $2}')
13745 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13746 awk '/ldlm_bl_callback/ {print $2}')
13747 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13748 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13749 lru_resize_enable mdc
13750 lru_resize_enable osc
13752 run_test 120c "Early Lock Cancel: link test"
13755 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13756 remote_mds_nodsh && skip "remote MDS with nodsh"
13757 test_mkdir -i0 -c1 $DIR/$tdir
13758 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13759 skip_env "no early lock cancel on server"
13761 lru_resize_disable mdc
13762 lru_resize_disable osc
13764 cancel_lru_locks mdc
13765 stat $DIR/$tdir > /dev/null
13766 can1=$(do_facet mds1 \
13767 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13768 awk '/ldlm_cancel/ {print $2}')
13769 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13770 awk '/ldlm_bl_callback/ {print $2}')
13771 chmod a+x $DIR/$tdir
13772 can2=$(do_facet mds1 \
13773 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13774 awk '/ldlm_cancel/ {print $2}')
13775 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13776 awk '/ldlm_bl_callback/ {print $2}')
13777 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13778 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13779 lru_resize_enable mdc
13780 lru_resize_enable osc
13782 run_test 120d "Early Lock Cancel: setattr test"
13785 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13786 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13787 skip_env "no early lock cancel on server"
13788 remote_mds_nodsh && skip "remote MDS with nodsh"
13790 local dlmtrace_set=false
13792 test_mkdir -i0 -c1 $DIR/$tdir
13793 lru_resize_disable mdc
13794 lru_resize_disable osc
13795 ! $LCTL get_param debug | grep -q dlmtrace &&
13796 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
13797 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
13798 cancel_lru_locks mdc
13799 cancel_lru_locks osc
13800 dd if=$DIR/$tdir/f1 of=/dev/null
13801 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
13802 # XXX client can not do early lock cancel of OST lock
13803 # during unlink (LU-4206), so cancel osc lock now.
13805 cancel_lru_locks osc
13806 can1=$(do_facet mds1 \
13807 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13808 awk '/ldlm_cancel/ {print $2}')
13809 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13810 awk '/ldlm_bl_callback/ {print $2}')
13811 unlink $DIR/$tdir/f1
13813 can2=$(do_facet mds1 \
13814 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13815 awk '/ldlm_cancel/ {print $2}')
13816 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13817 awk '/ldlm_bl_callback/ {print $2}')
13818 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
13819 $LCTL dk $TMP/cancel.debug.txt
13820 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
13821 $LCTL dk $TMP/blocking.debug.txt
13822 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
13823 lru_resize_enable mdc
13824 lru_resize_enable osc
13826 run_test 120e "Early Lock Cancel: unlink test"
13829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13830 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13831 skip_env "no early lock cancel on server"
13832 remote_mds_nodsh && skip "remote MDS with nodsh"
13834 test_mkdir -i0 -c1 $DIR/$tdir
13835 lru_resize_disable mdc
13836 lru_resize_disable osc
13837 test_mkdir -i0 -c1 $DIR/$tdir/d1
13838 test_mkdir -i0 -c1 $DIR/$tdir/d2
13839 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
13840 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
13841 cancel_lru_locks mdc
13842 cancel_lru_locks osc
13843 dd if=$DIR/$tdir/d1/f1 of=/dev/null
13844 dd if=$DIR/$tdir/d2/f2 of=/dev/null
13845 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
13846 # XXX client can not do early lock cancel of OST lock
13847 # during rename (LU-4206), so cancel osc lock now.
13849 cancel_lru_locks osc
13850 can1=$(do_facet mds1 \
13851 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13852 awk '/ldlm_cancel/ {print $2}')
13853 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13854 awk '/ldlm_bl_callback/ {print $2}')
13855 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13857 can2=$(do_facet mds1 \
13858 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13859 awk '/ldlm_cancel/ {print $2}')
13860 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13861 awk '/ldlm_bl_callback/ {print $2}')
13862 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13863 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13864 lru_resize_enable mdc
13865 lru_resize_enable osc
13867 run_test 120f "Early Lock Cancel: rename test"
13870 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13871 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13872 skip_env "no early lock cancel on server"
13873 remote_mds_nodsh && skip "remote MDS with nodsh"
13875 lru_resize_disable mdc
13876 lru_resize_disable osc
13878 echo create $count files
13879 test_mkdir $DIR/$tdir
13880 cancel_lru_locks mdc
13881 cancel_lru_locks osc
13884 can0=$(do_facet $SINGLEMDS \
13885 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13886 awk '/ldlm_cancel/ {print $2}')
13887 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13888 awk '/ldlm_bl_callback/ {print $2}')
13889 createmany -o $DIR/$tdir/f $count
13891 can1=$(do_facet $SINGLEMDS \
13892 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13893 awk '/ldlm_cancel/ {print $2}')
13894 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13895 awk '/ldlm_bl_callback/ {print $2}')
13897 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
13898 echo rm $count files
13901 can2=$(do_facet $SINGLEMDS \
13902 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13903 awk '/ldlm_cancel/ {print $2}')
13904 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13905 awk '/ldlm_bl_callback/ {print $2}')
13907 echo total: $count removes in $((t2-t1))
13908 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
13910 # wait for commitment of removal
13911 lru_resize_enable mdc
13912 lru_resize_enable osc
13914 run_test 120g "Early Lock Cancel: performance test"
13916 test_121() { #bug #10589
13917 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13920 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
13921 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
13922 lctl set_param fail_loc=0x310
13923 cancel_lru_locks osc > /dev/null
13924 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
13925 lctl set_param fail_loc=0
13926 [[ $reads -eq $writes ]] ||
13927 error "read $reads blocks, must be $writes blocks"
13929 run_test 121 "read cancel race ========="
13931 test_123a_base() { # was test 123, statahead(bug 11401)
13934 ost_set_temp_seq_width_all $DATA_SEQ_MAX_WIDTH
13937 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
13938 log "testing UP system. Performance may be lower than expected."
13941 running_in_vm && SLOWOK=1
13943 $LCTL set_param mdc.*.batch_stats=0
13946 test_mkdir $DIR/$tdir
13947 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
13948 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
13950 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
13951 createmany -o $DIR/$tdir/$tfile $j $((i - j))
13953 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
13954 lctl set_param -n llite.*.statahead_max 0
13955 lctl get_param llite.*.statahead_max
13956 cancel_lru_locks mdc
13957 cancel_lru_locks osc
13959 time $lsx $DIR/$tdir | wc -l
13961 delta=$((etime - stime))
13962 log "$lsx $i files without statahead: $delta sec"
13963 lctl set_param llite.*.statahead_max=$max
13965 swrong=$(lctl get_param -n llite.*.statahead_stats |
13966 awk '/statahead.wrong:/ { print $NF }')
13967 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
13968 cancel_lru_locks mdc
13969 cancel_lru_locks osc
13971 time $lsx $DIR/$tdir | wc -l
13973 delta_sa=$((etime - stime))
13974 log "$lsx $i files with statahead: $delta_sa sec"
13975 lctl get_param -n llite.*.statahead_stats
13976 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13977 awk '/statahead.wrong:/ { print $NF }')
13979 [[ $swrong -lt $ewrong ]] &&
13980 log "statahead was stopped, maybe too many locks held!"
13981 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
13983 if (( $delta_sa*100 > $delta*105 && $delta_sa > $delta+2)); then
13984 max=$(lctl get_param -n llite.*.statahead_max |
13986 lctl set_param -n llite.*.statahead_max 0
13987 lctl get_param llite.*.statahead_max
13988 cancel_lru_locks mdc
13989 cancel_lru_locks osc
13991 time $lsx $DIR/$tdir | wc -l
13993 delta=$((etime - stime))
13994 log "$lsx $i files again without statahead: $delta sec"
13995 lctl set_param llite.*.statahead_max=$max
13996 if (( $delta_sa*100 > delta*105 && delta_sa > delta+2 )); then
13997 if [ $SLOWOK -eq 0 ]; then
13998 error "$lsx $i files is slower with statahead!"
14000 log "$lsx $i files is slower with statahead!"
14006 [ $delta -gt 20 ] && break
14007 [ $delta -gt 8 ] && MULT=$((50 / delta))
14008 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
14016 delta=$((etime - stime))
14017 log "rm -r $DIR/$tdir/: $delta seconds"
14019 lctl get_param -n llite.*.statahead_stats
14020 $LCTL get_param mdc.*.batch_stats
14024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14026 test_123a_base "ls -l"
14028 run_test 123aa "verify statahead work"
14031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14033 statx_supported || skip_env "Test must be statx() syscall supported"
14035 test_123a_base "$STATX -l"
14037 run_test 123ab "verify statahead work by using statx"
14040 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14042 statx_supported || skip_env "Test must be statx() syscall supported"
14049 cancel_lru_locks $OSC
14050 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
14051 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
14052 awk '/agl.total:/ { print $NF }')
14053 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
14054 test_123a_base "$STATX --cached=always -D"
14055 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
14056 awk '/agl.total:/ { print $NF }')
14057 [ $agl_before -eq $agl_after ] ||
14058 error "Should not trigger AGL thread - $agl_before:$agl_after"
14059 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
14060 [ $rpcs_after -eq $rpcs_before ] ||
14061 error "$STATX should not send glimpse RPCs to $OSC"
14063 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
14065 test_batch_statahead() {
14073 echo -e "\nbatching: statahead_max=$max statahead_batch_max=$batch_max"
14074 $LCTL set_param mdc.*.batch_stats=0
14075 $LCTL set_param llite.*.statahead_max=$max
14076 $LCTL set_param llite.*.statahead_batch_max=$batch_max
14077 # Verify that batched statahead is faster than one without statahead
14078 test_123a_base "ls -l"
14080 stack_trap "rm -rf $DIR/$tdir" EXIT
14081 mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
14082 createmany -o $DIR/$tdir/$tfile $num || error "failed to create files"
14084 # unbatched statahead
14085 $LCTL set_param llite.*.statahead_batch_max=0
14086 $LCTL set_param llite.*.statahead_stats=clear
14087 $LCTL set_param mdc.*.stats=clear
14088 cancel_lru_locks mdc
14089 cancel_lru_locks osc
14090 time ls -l $DIR/$tdir | wc -l
14091 unbatch_rpcs=$(calc_stats mdc.*.stats ldlm_ibits_enqueue)
14093 hit_total=$($LCTL get_param -n llite.*.statahead_stats |
14094 awk '/hit.total:/ { print $NF }')
14095 # hit ratio should be larger than 75% (7500).
14096 (( $hit_total > 7500 )) ||
14097 error "unbatched statahead hit count ($hit_total) is too low"
14099 # batched statahead
14100 $LCTL set_param llite.*.statahead_batch_max=$batch_max
14101 $LCTL set_param llite.*.statahead_stats=clear
14102 $LCTL set_param mdc.*.batch_stats=clear
14103 $LCTL set_param mdc.*.stats=clear
14104 cancel_lru_locks mdc
14105 cancel_lru_locks osc
14106 time ls -l $DIR/$tdir | wc -l
14107 batch_rpcs=$(calc_stats mdc.*.stats mds_batch)
14108 # wait for statahead thread to quit and update statahead stats
14110 hit_total=$($LCTL get_param -n llite.*.statahead_stats |
14111 awk '/hit.total:/ { print $NF }')
14112 # hit ratio should be larger than 75% (7500).
14113 (( $hit_total > 7500 )) ||
14114 error "batched statahead hit count ($hit_total) is too low"
14116 echo "unbatched RPCs: $unbatch_rpcs, batched RPCs: $batch_rpcs"
14117 (( $unbatch_rpcs > $batch_rpcs )) ||
14118 error "batched statahead does not reduce RPC count"
14119 $LCTL get_param mdc.*.batch_stats
14123 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14125 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
14126 skip "Need server version at least 2.15.53"
14131 max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
14132 batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
14134 stack_trap "$LCTL set_param llite.*.statahead_max=$max" EXIT
14135 stack_trap "$LCTL set_param llite.*.statahead_batch_max=$batch_max" EXIT
14137 test_batch_statahead 32 32
14138 test_batch_statahead 2048 256
14140 run_test 123ad "Verify batching statahead works correctly"
14142 test_123b () { # statahead(bug 15027)
14143 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14145 test_mkdir $DIR/$tdir
14146 createmany -o $DIR/$tdir/$tfile-%d 1000
14148 cancel_lru_locks mdc
14149 cancel_lru_locks osc
14151 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
14152 lctl set_param fail_loc=0x80000803
14153 ls -lR $DIR/$tdir > /dev/null
14155 lctl set_param fail_loc=0x0
14156 lctl get_param -n llite.*.statahead_stats
14161 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
14164 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
14166 test_mkdir -i 0 -c 1 $DIR/$tdir.0
14167 test_mkdir -i 1 -c 1 $DIR/$tdir.1
14168 touch $DIR/$tdir.1/{1..3}
14169 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
14171 remount_client $MOUNT
14173 $MULTIOP $DIR/$tdir.0 Q
14175 # let statahead to complete
14176 ls -l $DIR/$tdir.0 > /dev/null
14178 testid=$(echo $TESTNAME | tr '_' ' ')
14179 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
14180 error "statahead warning" || true
14182 run_test 123c "Can not initialize inode warning on DNE statahead"
14189 test_mkdir -c -1 $DIR/$tdir || error "test_mkdir $DIR/$tdir failed"
14190 $LFS setdirstripe -D -c $MDSCOUNT $DIR/$tdir ||
14191 error "setdirstripe $DIR/$tdir failed"
14192 createmany -d $DIR/$tdir/$tfile $num || error "createmany $num failed"
14193 remount_client $MOUNT
14194 $LCTL get_param llite.*.statahead_max
14195 $LCTL set_param llite.*.statahead_stats=0 ||
14196 error "clear statahead_stats failed"
14197 swrong=$(lctl get_param -n llite.*.statahead_stats |
14198 awk '/statahead.wrong:/ { print $NF }')
14199 ls -l $DIR/$tdir || error "ls -l $DIR/$tdir failed"
14200 # wait for statahead thread finished to update hit/miss stats.
14202 $LCTL get_param -n llite.*.statahead_stats
14203 ewrong=$(lctl get_param -n llite.*.statahead_stats |
14204 awk '/statahead.wrong:/ { print $NF }')
14205 (( $swrong == $ewrong )) ||
14206 log "statahead was stopped, maybe too many locks held!"
14208 run_test 123d "Statahead on striped directories works correctly"
14213 local dir=$DIR/$tdir
14215 mkdir $dir || error "mkdir $dir failed"
14216 $LFS setstripe -C 32 $dir || error "setstripe $dir failed"
14217 stack_trap "rm -rf $dir"
14219 touch $dir/$tfile.{0..1000} || error "touch 1000 files failed"
14221 max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
14222 batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
14223 stack_trap "$LCTL set_param llite.*.statahead_max=$max" EXIT
14224 stack_trap "$LCTL set_param llite.*.statahead_batch_max=$batch_max" EXIT
14226 $LCTL set_param llite.*.statahead_max=2048
14227 $LCTL set_param llite.*.statahead_batch_max=1024
14230 $LCTL get_param mdc.*.batch_stats
14231 $LCTL get_param llite.*.statahead_*
14233 run_test 123e "statahead with large wide striping"
14238 local dir=$DIR/$tdir
14240 mkdir $dir || error "mkdir $dir failed"
14241 $LFS setstripe -C 1000 $dir || error "setstripe $dir failed"
14242 stack_trap "rm -rf $dir"
14244 touch $dir/$tfile.{0..200} || error "touch 200 files failed"
14246 max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
14247 batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
14249 $LCTL set_param llite.*.statahead_max=64
14250 $LCTL set_param llite.*.statahead_batch_max=64
14253 lctl get_param mdc.*.batch_stats
14254 lctl get_param llite.*.statahead_*
14256 $LCTL set_param llite.*.statahead_max=$max
14257 $LCTL set_param llite.*.statahead_batch_max=$batch_max
14259 run_test 123f "Retry mechanism with large wide striping files"
14262 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14263 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14264 skip_env "no lru resize on server"
14268 test_mkdir $DIR/$tdir
14270 log "create $NR files at $DIR/$tdir"
14271 createmany -o $DIR/$tdir/f $NR ||
14272 error "failed to create $NR files in $DIR/$tdir"
14274 cancel_lru_locks mdc
14275 ls -l $DIR/$tdir > /dev/null
14279 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
14280 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
14281 LRU_SIZE=$($LCTL get_param -n $PARAM)
14282 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
14283 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
14285 log "NS=$(basename $NSDIR)"
14290 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
14291 skip "Not enough cached locks created!"
14293 log "LRU=$LRU_SIZE"
14297 # We know that lru resize allows one client to hold $LIMIT locks
14298 # for 10h. After that locks begin to be killed by client.
14300 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
14302 if [ $LIMIT -lt $LRU_SIZE ]; then
14303 skip "Limit is too small $LIMIT"
14306 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
14307 # killing locks. Some time was spent for creating locks. This means
14308 # that up to the moment of sleep finish we must have killed some of
14309 # them (10-100 locks). This depends on how fast ther were created.
14310 # Many of them were touched in almost the same moment and thus will
14311 # be killed in groups.
14312 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
14314 # Use $LRU_SIZE_B here to take into account real number of locks
14315 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
14316 local LRU_SIZE_B=$LRU_SIZE
14318 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
14319 log "OLD_LVF=$OLD_LVF"
14320 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
14322 # Let's make sure that we really have some margin. Client checks
14323 # cached locks every 10 sec.
14324 SLEEP=$((SLEEP+20))
14325 log "Sleep ${SLEEP} sec"
14327 while ((SEC<$SLEEP)); do
14331 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
14332 echo -n "$LRU_SIZE"
14335 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
14336 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
14338 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
14339 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
14340 unlinkmany $DIR/$tdir/f $NR
14344 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
14345 log "unlink $NR files at $DIR/$tdir"
14346 unlinkmany $DIR/$tdir/f $NR
14348 run_test 124a "lru resize ======================================="
14350 get_max_pool_limit()
14352 local limit=$($LCTL get_param \
14353 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
14355 for l in $limit; do
14356 if [[ $l -gt $max ]]; then
14364 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14365 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14366 skip_env "no lru resize on server"
14368 LIMIT=$(get_max_pool_limit)
14370 NR=$(($(default_lru_size)*20))
14371 if [[ $NR -gt $LIMIT ]]; then
14372 log "Limit lock number by $LIMIT locks"
14376 IFree=$(mdsrate_inodes_available)
14377 if [ $IFree -lt $NR ]; then
14378 log "Limit lock number by $IFree inodes"
14382 lru_resize_disable mdc
14383 test_mkdir -p $DIR/$tdir/disable_lru_resize
14385 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
14386 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
14387 cancel_lru_locks mdc
14390 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
14393 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
14396 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
14400 nolruresize_delta=$((etime-stime))
14401 log "ls -la time: $nolruresize_delta seconds"
14402 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
14403 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
14405 lru_resize_enable mdc
14406 test_mkdir -p $DIR/$tdir/enable_lru_resize
14408 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
14409 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
14410 cancel_lru_locks mdc
14413 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
14416 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
14419 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
14423 lruresize_delta=$((etime-stime))
14424 log "ls -la time: $lruresize_delta seconds"
14425 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
14427 if [ $lruresize_delta -gt $nolruresize_delta ]; then
14428 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
14429 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
14430 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
14432 log "lru resize performs the same with no lru resize"
14434 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
14436 run_test 124b "lru resize (performance test) ======================="
14439 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14440 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14441 skip_env "no lru resize on server"
14443 # cache ununsed locks on client
14445 cancel_lru_locks mdc
14446 test_mkdir $DIR/$tdir
14447 createmany -o $DIR/$tdir/f $nr ||
14448 error "failed to create $nr files in $DIR/$tdir"
14449 ls -l $DIR/$tdir > /dev/null
14451 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14452 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14453 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
14454 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
14455 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
14457 # set lru_max_age to 1 sec
14458 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
14459 echo "sleep $((recalc_p * 2)) seconds..."
14460 sleep $((recalc_p * 2))
14462 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
14463 # restore lru_max_age
14464 $LCTL set_param -n $nsdir.lru_max_age $max_age
14465 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
14466 unlinkmany $DIR/$tdir/f $nr
14468 run_test 124c "LRUR cancel very aged locks"
14471 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14472 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14473 skip_env "no lru resize on server"
14475 # cache ununsed locks on client
14478 lru_resize_disable mdc
14479 stack_trap "lru_resize_enable mdc" EXIT
14481 cancel_lru_locks mdc
14483 # asynchronous object destroy at MDT could cause bl ast to client
14484 test_mkdir $DIR/$tdir
14485 createmany -o $DIR/$tdir/f $nr ||
14486 error "failed to create $nr files in $DIR/$tdir"
14487 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
14489 ls -l $DIR/$tdir > /dev/null
14491 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14492 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14493 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
14494 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
14496 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
14498 # set lru_max_age to 1 sec
14499 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
14500 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
14502 echo "sleep $((recalc_p * 2)) seconds..."
14503 sleep $((recalc_p * 2))
14505 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
14507 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
14509 run_test 124d "cancel very aged locks if lru-resize diasbaled"
14511 test_125() { # 13358
14512 $LCTL get_param -n llite.*.client_type | grep -q local ||
14513 skip "must run as local client"
14514 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
14515 skip_env "must have acl enabled"
14516 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
14517 id $USER0 || skip_env "missing user $USER0"
14519 test_mkdir $DIR/$tdir
14520 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
14521 setfacl -R -m u:$USER0:rwx $DIR/$tdir ||
14522 error "setfacl $DIR/$tdir failed"
14523 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
14525 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
14527 test_126() { # bug 12829/13455
14528 $GSS && skip_env "must run as gss disabled"
14529 $LCTL get_param -n llite.*.client_type | grep -q local ||
14530 skip "must run as local client"
14531 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
14533 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
14534 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
14536 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
14538 run_test 126 "check that the fsgid provided by the client is taken into account"
14540 test_127a() { # bug 15521
14541 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14542 local name count samp unit min max sum sumsq
14543 local tmpfile=$TMP/$tfile.tmp
14545 # enable stats header if it is disabled
14546 $LCTL set_param enable_stats_header=1
14548 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
14549 echo "stats before reset"
14550 stack_trap "rm -f $tmpfile"
14551 local now=$(date +%s)
14553 $LCTL get_param osc.*.stats | tee $tmpfile
14555 local snapshot_time=$(awk '/snapshot_time/ { print $2; exit }' $tmpfile)
14556 local start_time=$(awk '/start_time/ { print $2; exit }' $tmpfile)
14557 local elapsed=$(awk '/elapsed_time/ { print $2; exit }' $tmpfile)
14558 local uptime=$(awk '{ print $1 }' /proc/uptime)
14560 # snapshot_time should match POSIX epoch time, allow some delta for VMs
14561 (( ${snapshot_time%\.*} >= $now - 5 &&
14562 ${snapshot_time%\.*} <= $now + 5 )) ||
14563 error "snapshot_time=$snapshot_time != now=$now"
14564 # elapsed _should_ be from mount, but at least less than uptime
14565 (( ${elapsed%\.*} < ${uptime%\.*} )) ||
14566 error "elapsed=$elapsed > uptime=$uptime"
14567 (( ${snapshot_time%\.*} - ${start_time%\.*} >= ${elapsed%\.*} - 2 &&
14568 ${snapshot_time%\.*} - ${start_time%\.*} <= ${elapsed%\.*} + 2 )) ||
14569 error "elapsed=$elapsed != $snapshot_time - $start_time"
14571 $LCTL set_param osc.*.stats=0
14572 local reset=$(date +%s)
14573 local fsize=$((2048 * 1024))
14575 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
14576 cancel_lru_locks osc
14577 dd if=$DIR/$tfile of=/dev/null bs=$fsize
14580 $LCTL get_param osc.*0000-osc-*.stats > $tmpfile
14581 while read name count samp unit min max sum sumsq; do
14582 [[ "$samp" == "samples" ]] || continue
14584 echo "got name=$name count=$count unit=$unit min=$min max=$max"
14585 [ ! $min ] && error "Missing min value for $name proc entry"
14586 eval $name=$count || error "Wrong proc format"
14589 read_bytes|write_bytes)
14590 [[ "$unit" =~ "bytes" ]] ||
14591 error "unit is not 'bytes': $unit"
14592 (( $min >= 4096 )) || error "min is too small: $min"
14593 (( $min <= $fsize )) || error "min is too big: $min"
14594 (( $max >= 4096 )) || error "max is too small: $max"
14595 (( $max <= $fsize )) || error "max is too big: $max"
14596 (( $sum == $fsize )) || error "sum is wrong: $sum"
14597 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
14598 error "sumsquare is too small: $sumsq"
14599 (( $sumsq <= $fsize * $fsize )) ||
14600 error "sumsquare is too big: $sumsq"
14602 ost_read|ost_write)
14603 [[ "$unit" =~ "usec" ]] ||
14604 error "unit is not 'usec': $unit"
14610 #check that we actually got some stats
14611 [ "$read_bytes" ] || error "Missing read_bytes stats"
14612 [ "$write_bytes" ] || error "Missing write_bytes stats"
14613 [ "$read_bytes" != 0 ] || error "no read done"
14614 [ "$write_bytes" != 0 ] || error "no write done"
14616 snapshot_time=$(awk '/snapshot_time/ { print $2; exit }' $tmpfile)
14617 start_time=$(awk '/start_time/ { print $2; exit }' $tmpfile)
14618 elapsed=$(awk '/elapsed_time/ { print $2; exit }' $tmpfile)
14620 # snapshot_time should match POSIX epoch time, allow some delta for VMs
14621 (( ${snapshot_time%\.*} >= $now - 5 &&
14622 ${snapshot_time%\.*} <= $now + 5 )) ||
14623 error "reset snapshot_time=$snapshot_time != now=$now"
14624 # elapsed should be from time of stats reset
14625 (( ${elapsed%\.*} >= $now - $reset - 2 &&
14626 ${elapsed%\.*} <= $now - $reset + 2 )) ||
14627 error "reset elapsed=$elapsed > $now - $reset"
14628 (( ${snapshot_time%\.*} - ${start_time%\.*} >= ${elapsed%\.*} - 2 &&
14629 ${snapshot_time%\.*} - ${start_time%\.*} <= ${elapsed%\.*} + 2 )) ||
14630 error "reset elapsed=$elapsed != $snapshot_time - $start_time"
14632 run_test 127a "verify the client stats are sane"
14634 test_127b() { # bug LU-333
14635 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14636 local name count samp unit min max sum sumsq
14638 echo "stats before reset"
14639 $LCTL get_param llite.*.stats
14640 $LCTL set_param llite.*.stats=0
14642 # perform 2 reads and writes so MAX is different from SUM.
14643 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
14644 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
14645 cancel_lru_locks osc
14646 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
14647 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
14649 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
14650 stack_trap "rm -f $TMP/$tfile.tmp"
14651 while read name count samp unit min max sum sumsq; do
14652 echo "got name=$name count=$count unit=$unit min=$min max=$max"
14653 eval $name=$count || error "Wrong proc format"
14656 read_bytes|write_bytes)
14657 [[ "$unit" =~ "bytes" ]] ||
14658 error "unit is not 'bytes': $unit"
14659 (( $count == 2 )) || error "count is not 2: $count"
14660 (( $min == $PAGE_SIZE )) ||
14661 error "min is not $PAGE_SIZE: $min"
14662 (( $max == $PAGE_SIZE )) ||
14663 error "max is not $PAGE_SIZE: $max"
14664 (( $sum == $PAGE_SIZE * 2 )) ||
14665 error "sum is not $((PAGE_SIZE * 2)): $sum"
14668 [[ "$unit" =~ "usec" ]] ||
14669 error "unit is not 'usec': $unit"
14673 done < $TMP/$tfile.tmp
14675 #check that we actually got some stats
14676 [ "$read_bytes" ] || error "Missing read_bytes stats"
14677 [ "$write_bytes" ] || error "Missing write_bytes stats"
14678 [ "$read_bytes" != 0 ] || error "no read done"
14679 [ "$write_bytes" != 0 ] || error "no write done"
14681 run_test 127b "verify the llite client stats are sane"
14683 test_127c() { # LU-12394
14684 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
14691 $LCTL set_param llite.*.extents_stats=1
14692 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
14694 # Use two stripes so there is enough space in default config
14695 $LFS setstripe -c 2 $DIR/$tfile
14697 # Extent stats start at 0-4K and go in power of two buckets
14698 # LL_HIST_START = 12 --> 2^12 = 4K
14699 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
14700 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
14702 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
14704 # Write and read, 2x each, second time at a non-zero offset
14705 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
14706 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
14707 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
14708 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
14712 $LCTL get_param llite.*.extents_stats
14715 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
14717 local bucket=$($LCTL get_param -n llite.*.extents_stats |
14719 reads=$(echo $bucket | awk '{print $5}')
14720 writes=$(echo $bucket | awk '{print $9}')
14721 [ "$reads" -eq $count ] ||
14722 error "$reads reads in < $bsize bucket, expect $count"
14723 [ "$writes" -eq $count ] ||
14724 error "$writes writes in < $bsize bucket, expect $count"
14727 # Test mmap write and read
14728 $LCTL set_param llite.*.extents_stats=c
14730 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
14731 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
14732 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
14734 $LCTL get_param llite.*.extents_stats
14736 count=$(((size*1024) / PAGE_SIZE))
14738 bsize=$((2 * PAGE_SIZE / 1024))K
14740 bucket=$($LCTL get_param -n llite.*.extents_stats |
14742 reads=$(echo $bucket | awk '{print $5}')
14743 writes=$(echo $bucket | awk '{print $9}')
14744 # mmap writes fault in the page first, creating an additonal read
14745 [ "$reads" -eq $((2 * count)) ] ||
14746 error "$reads reads in < $bsize bucket, expect $count"
14747 [ "$writes" -eq $count ] ||
14748 error "$writes writes in < $bsize bucket, expect $count"
14750 run_test 127c "test llite extent stats with regular & mmap i/o"
14752 test_128() { # bug 15212
14754 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
14759 result=$(grep error $TMP/$tfile.log)
14760 rm -f $DIR/$tfile $TMP/$tfile.log
14761 [ -z "$result" ] ||
14762 error "consecutive find's under interactive lfs failed"
14764 run_test 128 "interactive lfs for 2 consecutive find's"
14766 set_dir_limits () {
14771 local ldproc=/proc/fs/ldiskfs
14772 local facets=$(get_facets MDS)
14774 for facet in ${facets//,/ }; do
14775 canondev=$(ldiskfs_canon \
14776 *.$(convert_facet2label $facet).mntdev $facet)
14777 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
14778 ldproc=/sys/fs/ldiskfs
14779 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
14780 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
14784 check_mds_dmesg() {
14785 local facets=$(get_facets MDS)
14786 for facet in ${facets//,/ }; do
14787 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
14793 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14794 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
14795 skip "Need MDS version with at least 2.5.56"
14796 if [ "$mds1_FSTYPE" != ldiskfs ]; then
14797 skip_env "ldiskfs only test"
14799 remote_mds_nodsh && skip "remote MDS with nodsh"
14802 local has_warning=false
14805 mkdir -p $DIR/$tdir
14807 # block size of mds1
14808 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
14809 set_dir_limits $maxsize $((maxsize * 6 / 8))
14810 stack_trap "set_dir_limits 0 0"
14811 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
14812 local dirsize=$(stat -c%s "$DIR/$tdir")
14814 while (( $dirsize <= $maxsize )); do
14815 $MCREATE $DIR/$tdir/file_base_$nfiles
14817 # check two errors:
14818 # ENOSPC for ext4 max_dir_size, which has been used since
14819 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
14820 if (( rc == ENOSPC )); then
14822 echo "rc=$rc returned as expected after $nfiles files"
14824 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
14825 error "create failed w/o dir size limit"
14827 # messages may be rate limited if test is run repeatedly
14828 check_mds_dmesg '"is approaching max"' ||
14829 echo "warning message should be output"
14830 check_mds_dmesg '"has reached max"' ||
14831 echo "reached message should be output"
14833 dirsize=$(stat -c%s "$DIR/$tdir")
14835 [[ $dirsize -ge $maxsize ]] && return 0
14836 error "dirsize $dirsize < $maxsize after $nfiles files"
14837 elif (( rc != 0 )); then
14840 nfiles=$((nfiles + 1))
14841 dirsize=$(stat -c%s "$DIR/$tdir")
14844 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
14846 run_test 129 "test directory size limit ========================"
14856 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
14857 [[ -z "$filefrag_op" ]] || skip_env "filefrag does not support FIEMAP"
14859 trap cleanup_130 EXIT RETURN
14861 local fm_file=$DIR/$tfile
14862 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
14863 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
14864 error "dd failed for $fm_file"
14866 # LU-1795: test filefrag/FIEMAP once, even if unsupported on ZFS
14867 filefrag -ves $fm_file
14869 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14870 skip "LU-1941: FIEMAP unimplemented on ZFS"
14871 (( $rc == 0 )) || error "filefrag $fm_file failed"
14873 filefrag_op=$(filefrag -ve -k $fm_file |
14874 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14875 local lun=$($LFS getstripe -i $fm_file)
14877 local start_blk=$(echo $filefrag_op | cut -d: -f2 | cut -d. -f1)
14880 for line in $filefrag_op; do
14881 local frag_lun=$(echo $line | cut -d: -f5)
14882 local ext_len=$(echo $line | cut -d: -f4)
14884 if (( $frag_lun != $lun )); then
14885 error "FIEMAP on 1-stripe file($fm_file) failed"
14888 (( tot_len += ext_len ))
14891 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
14892 error "FIEMAP on 1-stripe file($fm_file) failed"
14896 echo "FIEMAP on single striped file succeeded"
14898 run_test 130a "FIEMAP (1-stripe file)"
14901 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14903 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14904 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14905 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14906 skip "LU-1941: FIEMAP unimplemented on ZFS"
14908 trap cleanup_130 EXIT RETURN
14910 local fm_file=$DIR/$tfile
14911 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
14912 error "setstripe on $fm_file"
14914 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
14915 error "dd failed on $fm_file"
14917 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14918 filefrag_op=$(filefrag -ve -k $fm_file |
14919 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14921 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14922 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14928 for line in $filefrag_op; do
14929 local frag_lun=$(echo $line | cut -d: -f5 |
14930 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14931 local ext_len=$(echo $line | cut -d: -f4)
14932 if (( $frag_lun != $last_lun )); then
14933 if (( tot_len != 1024 )); then
14934 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14937 (( num_luns += 1 ))
14941 (( tot_len += ext_len ))
14944 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
14945 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14949 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
14951 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
14954 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14956 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14957 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14958 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14959 skip "LU-1941: FIEMAP unimplemented on ZFS"
14961 trap cleanup_130 EXIT RETURN
14963 local fm_file=$DIR/$tfile
14964 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
14966 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
14967 error "dd failed on $fm_file"
14969 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14970 filefrag_op=$(filefrag -ve -k $fm_file |
14971 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14973 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14974 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14979 for line in $filefrag_op; do
14980 local frag_lun=$(echo $line | cut -d: -f5 |
14981 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14982 local ext_len=$(echo $line | cut -d: -f4)
14983 if (( $frag_lun != $last_lun )); then
14984 local logical=$(echo $line | cut -d: -f2 | cut -d. -f1)
14985 if (( logical != 512 )); then
14986 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
14989 if (( tot_len != 512 )); then
14990 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14993 (( num_luns += 1 ))
14997 (( tot_len += ext_len ))
15000 if (( num_luns != 2 || tot_len != 512 )); then
15001 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
15005 echo "FIEMAP on 2-stripe file with hole succeeded"
15007 run_test 130c "FIEMAP (2-stripe file with hole)"
15010 (( $OSTCOUNT >= 3 )) || skip "needs >= 3 OSTs"
15012 filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15013 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15014 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15015 skip "LU-1941: FIEMAP unimplemented on ZFS"
15017 trap cleanup_130 EXIT RETURN
15019 local fm_file=$DIR/$tfile
15020 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
15021 error "setstripe on $fm_file"
15023 local actual_stripe_count=$($LFS getstripe -c $fm_file)
15024 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
15025 error "dd failed on $fm_file"
15027 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15028 filefrag_op=$(filefrag -ve -k $fm_file |
15029 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15031 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
15032 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15037 for line in $filefrag_op; do
15038 local frag_lun=$(echo $line | cut -d: -f5 |
15039 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15040 local ext_len=$(echo $line | cut -d: -f4)
15041 if (( $frag_lun != $last_lun )); then
15042 if (( tot_len != 1024 )); then
15043 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
15046 (( num_luns += 1 ))
15050 (( tot_len += ext_len ))
15053 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
15054 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
15058 echo "FIEMAP on N-stripe file succeeded"
15060 run_test 130d "FIEMAP (N-stripe file)"
15063 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
15065 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15066 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15067 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15068 skip "LU-1941: FIEMAP unimplemented on ZFS"
15070 trap cleanup_130 EXIT RETURN
15072 local fm_file=$DIR/$tfile
15073 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
15074 stack_trap "rm -f $fm_file"
15077 local expected_len=$(( (num_blks / 2) * 64 ))
15078 for ((i = 0; i < $num_blks; i++)); do
15079 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
15080 conv=notrunc > /dev/null 2>&1
15083 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15084 filefrag_op=$(filefrag -ve -k $fm_file |
15085 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15087 local last_lun=$(echo $filefrag_op | cut -d: -f5)
15092 for line in $filefrag_op; do
15093 local frag_lun=$(echo $line | cut -d: -f5)
15094 local ext_len=$(echo $line | cut -d: -f4)
15095 if (( $frag_lun != $last_lun )); then
15096 if (( tot_len != $expected_len )); then
15097 error "OST$last_lun $tot_len != $expected_len"
15099 (( num_luns += 1 ))
15103 (( tot_len += ext_len ))
15106 if (( num_luns != 2 || tot_len != $expected_len )); then
15107 error "OST$last_lun $num_luns != 2, $tot_len != $expected_len"
15110 echo "FIEMAP with continuation calls succeeded"
15112 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
15115 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15116 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15117 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15118 skip "LU-1941: FIEMAP unimplemented on ZFS"
15120 local fm_file=$DIR/$tfile
15121 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
15122 error "multiop create with lov_delay_create on $fm_file"
15124 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15125 filefrag_extents=$(filefrag -vek $fm_file |
15126 awk '/extents? found/ { print $2 }')
15127 if (( $filefrag_extents != 0 )); then
15128 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
15133 run_test 130f "FIEMAP (unstriped file)"
15136 (( $MDS1_VERSION >= $(version_code 2.12.53) )) ||
15137 skip "Need MDS version with at least 2.12.53 for overstriping"
15138 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15139 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15140 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15141 skip "LU-1941: FIEMAP unimplemented on ZFS"
15143 local file=$DIR/$tfile
15144 local nr=$((OSTCOUNT * 100))
15146 $LFS setstripe -C $nr $file || error "failed to setstripe -C $nr $file"
15148 stack_trap "rm -f $file"
15149 dd if=/dev/zero of=$file count=$nr bs=1M
15151 nr=$($LFS getstripe -c $file)
15153 local extents=$(filefrag -v $file |
15154 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
15156 echo "filefrag list $extents extents in file with stripecount $nr"
15157 if (( extents < nr )); then
15158 $LFS getstripe $file
15160 error "filefrag printed $extents < $nr extents"
15163 run_test 130g "FIEMAP (overstripe file)"
15165 # Test for writev/readv
15167 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
15168 error "writev test failed"
15169 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
15170 error "readv failed"
15173 run_test 131a "test iov's crossing stripe boundary for writev/readv"
15176 local fsize=$((524288 + 1048576 + 1572864))
15177 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
15178 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
15179 error "append writev test failed"
15181 ((fsize += 1572864 + 1048576))
15182 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
15183 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
15184 error "append writev test failed"
15187 run_test 131b "test append writev"
15190 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
15193 run_test 131c "test read/write on file w/o objects"
15196 rwv -f $DIR/$tfile -w -n 1 1572864
15197 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
15198 if [ "$NOB" != 1572864 ]; then
15199 error "Short read filed: read $NOB bytes instead of 1572864"
15203 run_test 131d "test short read"
15206 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
15207 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
15208 error "read hitting hole failed"
15211 run_test 131e "test read hitting hole"
15219 # open 11 samples [usecs] 468 4793 13658 35791898
15221 mds*) res=($(do_facet $facet \
15222 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op"))
15224 ost*) res=($(do_facet $facet \
15225 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op"))
15227 *) error "Wrong facet '$facet'" ;;
15229 [[ -n "$res" ]] || error "counter for $op on $facet not incremented"
15230 # if $want is zero, it means any stat increment is ok.
15231 if (( $want > 0 )); then
15232 local count=${res[1]}
15234 if (( $count != $want )); then
15235 if [[ $facet =~ "mds" ]]; then
15236 do_nodes $(comma_list $(mdts_nodes)) \
15237 $LCTL get_param mdt.*.md_stats
15239 do_nodes $(comma_list $(osts-nodes)) \
15240 $LCTL get_param obdfilter.*.stats
15242 error "The $op counter on $facet is $count, not $want"
15248 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15249 remote_ost_nodsh && skip "remote OST with nodsh"
15250 remote_mds_nodsh && skip "remote MDS with nodsh"
15251 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
15252 skip_env "MDS doesn't support rename stats"
15254 local testdir=$DIR/${tdir}/stats_testdir
15256 mkdir -p $DIR/${tdir}
15259 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15260 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
15262 # verify mdt stats first.
15263 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
15264 check_stats $SINGLEMDS "mkdir" 1
15266 # clear "open" from "lfs mkdir" above
15267 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15268 touch ${testdir}/${tfile} || error "touch failed"
15269 check_stats $SINGLEMDS "open" 1
15270 check_stats $SINGLEMDS "close" 1
15271 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
15272 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
15273 check_stats $SINGLEMDS "mknod" 2
15275 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
15276 check_stats $SINGLEMDS "unlink" 1
15277 rm -f ${testdir}/${tfile} || error "file remove failed"
15278 check_stats $SINGLEMDS "unlink" 2
15280 # remove working dir and check mdt stats again.
15281 rmdir ${testdir} || error "rmdir failed"
15282 check_stats $SINGLEMDS "rmdir" 1
15284 local testdir1=$DIR/${tdir}/stats_testdir1
15285 mkdir_on_mdt0 -p ${testdir}
15286 mkdir_on_mdt0 -p ${testdir1}
15287 touch ${testdir1}/test1
15288 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
15289 check_stats $SINGLEMDS "crossdir_rename" 1
15291 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
15292 check_stats $SINGLEMDS "samedir_rename" 1
15294 rm -rf $DIR/${tdir}
15296 run_test 133a "Verifying MDT stats ========================================"
15301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15302 remote_ost_nodsh && skip "remote OST with nodsh"
15303 remote_mds_nodsh && skip "remote MDS with nodsh"
15305 local testdir=$DIR/${tdir}/stats_testdir
15307 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
15308 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
15309 touch ${testdir}/${tfile} || error "touch failed"
15310 cancel_lru_locks mdc
15313 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15314 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
15316 # extra mdt stats verification.
15317 chmod 444 ${testdir}/${tfile} || error "chmod failed"
15318 check_stats $SINGLEMDS "setattr" 1
15319 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15320 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
15322 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
15323 check_stats $SINGLEMDS "getattr" 1
15325 rm -rf $DIR/${tdir}
15327 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
15328 # so the check below is not reliable
15329 [ $MDSCOUNT -eq 1 ] || return 0
15331 # Sleep to avoid a cached response.
15332 #define OBD_STATFS_CACHE_SECONDS 1
15334 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15335 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
15336 $LFS df || error "lfs failed"
15337 check_stats $SINGLEMDS "statfs" 1
15339 # check aggregated statfs (LU-10018)
15340 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
15342 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
15345 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15346 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
15348 check_stats $SINGLEMDS "statfs" 1
15350 # We want to check that the client didn't send OST_STATFS to
15351 # ost1 but the MDT also uses OST_STATFS for precreate. So some
15352 # extra care is needed here.
15353 if remote_mds; then
15354 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
15355 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
15357 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
15358 [ "$res" ] && error "OST got STATFS"
15363 run_test 133b "Verifying extra MDT stats =================================="
15366 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15367 remote_ost_nodsh && skip "remote OST with nodsh"
15368 remote_mds_nodsh && skip "remote MDS with nodsh"
15370 local testdir=$DIR/$tdir/stats_testdir
15372 test_mkdir -p $testdir
15374 # verify obdfilter stats.
15375 $LFS setstripe -c 1 -i 0 $testdir/$tfile
15377 cancel_lru_locks osc
15378 wait_delete_completed
15381 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15382 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
15384 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
15387 cancel_lru_locks osc
15388 check_stats ost1 "write" 1
15390 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
15391 check_stats ost1 "read" 1
15393 > $testdir/$tfile || error "truncate failed"
15394 check_stats ost1 "punch" 1
15396 rm -f $testdir/$tfile || error "file remove failed"
15397 wait_delete_completed
15398 check_stats ost1 "destroy" 1
15402 run_test 133c "Verifying OST stats ========================================"
15409 while [ $value -ge 2 ]; do
15414 if [ $orig -gt $order ]; then
15422 local size=('K' 'M' 'G' 'T');
15424 local size_string=$value
15426 while [ $value -ge 1024 ]; do
15427 if [ $i -gt 3 ]; then
15428 #T is the biggest unit we get here, if that is bigger,
15430 size_string=${value}T
15433 value=$((value >> 10))
15434 if [ $value -lt 1024 ]; then
15435 size_string=${value}${size[$i]}
15444 get_rename_size() {
15446 local context=${2:-.}
15447 local sample=$(do_facet $SINGLEMDS $LCTL \
15448 get_param mdt.$FSNAME-MDT0000.rename_stats |
15449 grep -A1 $context |
15450 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
15455 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15456 remote_ost_nodsh && skip "remote OST with nodsh"
15457 remote_mds_nodsh && skip "remote MDS with nodsh"
15458 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
15459 skip_env "MDS doesn't support rename stats"
15461 local testdir1=$DIR/${tdir}/stats_testdir1
15462 local testdir2=$DIR/${tdir}/stats_testdir2
15463 mkdir -p $DIR/${tdir} || error "mkdir $tdir failed"
15465 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
15467 mkdir_on_mdt0 ${testdir1} || error "mkdir $testdir1 failed"
15468 mkdir_on_mdt0 ${testdir2} || error "mkdir $testdir2 failed"
15470 createmany -o $testdir1/test 512 || error "createmany failed"
15472 # check samedir rename size
15473 mv ${testdir1}/test0 ${testdir1}/test_0
15475 local testdir1_size=$(ls -l $DIR/${tdir} |
15476 awk '/stats_testdir1/ {print $5}')
15477 local testdir2_size=$(ls -l $DIR/${tdir} |
15478 awk '/stats_testdir2/ {print $5}')
15480 testdir1_size=$(order_2 $testdir1_size)
15481 testdir2_size=$(order_2 $testdir2_size)
15483 testdir1_size=$(size_in_KMGT $testdir1_size)
15484 testdir2_size=$(size_in_KMGT $testdir2_size)
15486 echo "source rename dir size: ${testdir1_size}"
15487 echo "target rename dir size: ${testdir2_size}"
15489 local cmd="do_facet $SINGLEMDS $LCTL "
15490 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
15492 eval $cmd || error "$cmd failed"
15493 local samedir=$($cmd | grep 'same_dir')
15494 local same_sample=$(get_rename_size $testdir1_size)
15495 [ -z "$samedir" ] && error "samedir_rename_size count error"
15496 [[ $same_sample -eq 1 ]] ||
15497 error "samedir_rename_size error $same_sample"
15498 echo "Check same dir rename stats success"
15500 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
15502 # check crossdir rename size
15503 mv ${testdir1}/test_0 ${testdir2}/test_0
15505 testdir1_size=$(ls -l $DIR/${tdir} |
15506 awk '/stats_testdir1/ {print $5}')
15507 testdir2_size=$(ls -l $DIR/${tdir} |
15508 awk '/stats_testdir2/ {print $5}')
15510 testdir1_size=$(order_2 $testdir1_size)
15511 testdir2_size=$(order_2 $testdir2_size)
15513 testdir1_size=$(size_in_KMGT $testdir1_size)
15514 testdir2_size=$(size_in_KMGT $testdir2_size)
15516 echo "source rename dir size: ${testdir1_size}"
15517 echo "target rename dir size: ${testdir2_size}"
15519 eval $cmd || error "$cmd failed"
15520 local crossdir=$($cmd | grep 'crossdir')
15521 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
15522 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
15523 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
15524 [[ $src_sample -eq 1 ]] ||
15525 error "crossdir_rename_size error $src_sample"
15526 [[ $tgt_sample -eq 1 ]] ||
15527 error "crossdir_rename_size error $tgt_sample"
15528 echo "Check cross dir rename stats success"
15529 rm -rf $DIR/${tdir}
15531 run_test 133d "Verifying rename_stats ========================================"
15534 remote_mds_nodsh && skip "remote MDS with nodsh"
15535 remote_ost_nodsh && skip "remote OST with nodsh"
15536 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15538 local testdir=$DIR/${tdir}/stats_testdir
15539 local ctr f0 f1 bs=32768 count=42 sum
15541 mkdir -p ${testdir} || error "mkdir failed"
15543 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
15545 for ctr in {write,read}_bytes; do
15547 cancel_lru_locks osc
15549 do_facet ost1 $LCTL set_param -n \
15550 "obdfilter.*.exports.clear=clear"
15552 if [ $ctr = write_bytes ]; then
15554 f1=${testdir}/${tfile}
15556 f0=${testdir}/${tfile}
15560 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
15563 cancel_lru_locks osc
15565 sum=$(do_facet ost1 $LCTL get_param \
15566 "obdfilter.*.exports.*.stats" |
15567 awk -v ctr=$ctr 'BEGIN { sum = 0 }
15568 $1 == ctr { sum += $7 }
15569 END { printf("%0.0f", sum) }')
15571 if ((sum != bs * count)); then
15572 error "Bad $ctr sum, expected $((bs * count)), got $sum"
15576 rm -rf $DIR/${tdir}
15578 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
15581 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
15582 skip "too old lustre for get_param -R ($facet_ver)"
15584 # verifying readability.
15585 $LCTL get_param -R '*' &> /dev/null
15587 # Verifing writability with badarea_io.
15588 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
15589 local skipped_params='force_lbug|changelog_mask|daemon_file'
15590 $LCTL list_param -FR '*' | grep '=' | tr -d = |
15591 egrep -v "$skipped_params" |
15592 xargs -n 1 find $proc_dirs -name |
15593 xargs -n 1 badarea_io ||
15594 error "client badarea_io failed"
15596 # remount the FS in case writes/reads /proc break the FS
15597 cleanup || error "failed to unmount"
15598 setup || error "failed to setup"
15600 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
15603 remote_mds_nodsh && skip "remote MDS with nodsh"
15604 remote_ost_nodsh && skip "remote OST with nodsh"
15606 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
15607 local proc_dirs_str=$(eval echo $proc_dirs)
15608 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
15610 for facet in mds1 ost1; do
15611 local facet_ver=$(lustre_version_code $facet)
15612 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
15613 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
15615 log "$facet: too old lustre for get_param -R"
15617 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
15618 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
15619 tr -d = | egrep -v $skipped_params |
15620 xargs -n 1 find $proc_dirs_str -name |
15621 xargs -n 1 badarea_io" ||
15622 error "$facet badarea_io failed"
15624 skip_noexit "$facet: too old lustre for get_param -R"
15628 # remount the FS in case writes/reads /proc break the FS
15629 cleanup || error "failed to unmount"
15630 setup || error "failed to setup"
15632 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
15635 remote_mds_nodsh && skip "remote MDS with nodsh"
15636 remote_ost_nodsh && skip "remote OST with nodsh"
15637 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
15638 skip "Need MDS version at least 2.9.54"
15641 for facet in client mds1 ost1; do
15642 # Get the list of files that are missing the terminating newline
15643 local plist=$(do_facet $facet
15644 $LCTL list_param -FR '*' | grep '=' | tr -d =)
15646 for ent in $plist; do
15647 local missing=$(do_facet $facet $LCTL get_param $ent \|\
15648 awk -v FS='\v' -v RS='\v\v' \
15649 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
15650 print FILENAME}'" 2>/dev/null)
15651 [ -z $missing ] || {
15652 do_facet $facet $LCTL get_param $ent | od -An -tx1
15653 error "file does not end with newline: $facet-$ent"
15658 run_test 133h "Proc files should end with newlines"
15661 remote_mds_nodsh && skip "remote MDS with nodsh"
15662 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
15663 skip "Need MDS version at least 2.7.54"
15665 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
15666 cancel_lru_locks mdc
15668 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
15669 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
15670 [ $unused -eq 0 ] || error "$unused locks are not cleared"
15673 createmany -o $DIR/$tdir/f $nr ||
15674 error "failed to create $nr files in $DIR/$tdir"
15675 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
15677 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
15678 do_facet mds1 $LCTL set_param fail_loc=0x327
15679 do_facet mds1 $LCTL set_param fail_val=500
15682 echo "sleep 10 seconds ..."
15684 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
15686 do_facet mds1 $LCTL set_param fail_loc=0
15687 do_facet mds1 $LCTL set_param fail_val=0
15688 [ $lck_cnt -lt $unused ] ||
15689 error "No locks reclaimed, before:$unused, after:$lck_cnt"
15692 unlinkmany $DIR/$tdir/f $nr
15694 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
15697 remote_mds_nodsh && skip "remote MDS with nodsh"
15698 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
15699 skip "Need MDS version at least 2.7.54"
15701 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
15702 cancel_lru_locks mdc
15704 local low_wm=$(do_facet mds1 $LCTL get_param -n \
15705 ldlm.lock_reclaim_threshold_mb)
15706 # disable reclaim temporarily
15707 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
15709 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
15710 do_facet mds1 $LCTL set_param fail_loc=0x328
15711 do_facet mds1 $LCTL set_param fail_val=500
15713 $LCTL set_param debug=+trace
15716 createmany -o $DIR/$tdir/f $nr &
15717 local create_pid=$!
15719 echo "Sleep $TIMEOUT seconds ..."
15721 if ! ps -p $create_pid > /dev/null 2>&1; then
15722 do_facet mds1 $LCTL set_param fail_loc=0
15723 do_facet mds1 $LCTL set_param fail_val=0
15724 do_facet mds1 $LCTL set_param \
15725 ldlm.lock_reclaim_threshold_mb=${low_wm}m
15726 error "createmany finished incorrectly!"
15728 do_facet mds1 $LCTL set_param fail_loc=0
15729 do_facet mds1 $LCTL set_param fail_val=0
15730 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
15731 wait $create_pid || return 1
15733 unlinkmany $DIR/$tdir/f $nr
15735 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
15738 remote_mds_nodsh && skip "remote MDS with nodsh"
15739 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
15740 skip "Need MDS version at least 2.13.50"
15743 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
15745 #define OBD_FAIL_PLAIN_RECORDS 0x1319
15746 #set only one record at plain llog
15747 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
15749 ost_set_temp_seq_width_all $DATA_SEQ_MAX_WIDTH
15751 #fill already existed plain llog each 64767
15752 #wrapping whole catalog
15753 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
15755 createmany -o $DIR/$tdir/$tfile_ 64700
15756 for (( i = 0; i < 64700; i = i + 2 ))
15758 rm $DIR/$tdir/$tfile_$i &
15759 rm $DIR/$tdir/$tfile_$((i + 1)) &
15764 #waiting osp synchronization
15765 wait_delete_completed
15767 run_test 135 "Race catalog processing"
15770 remote_mds_nodsh && skip "remote MDS with nodsh"
15771 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
15772 skip "Need MDS version at least 2.13.50"
15775 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
15776 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
15777 #set only one record at plain llog
15778 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
15779 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
15781 ost_set_temp_seq_width_all $DATA_SEQ_MAX_WIDTH
15783 #fill already existed 2 plain llogs each 64767
15784 #wrapping whole catalog
15785 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
15786 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
15787 wait_delete_completed
15789 createmany -o $DIR/$tdir/$tfile_ 10
15792 do_facet $SINGLEMDS $LCTL set_param fail_val=3
15793 for (( i = 0; i < 10; i = i + 3 ))
15795 rm $DIR/$tdir/$tfile_$i &
15796 rm $DIR/$tdir/$tfile_$((i + 1)) &
15800 rm $DIR/$tdir/$tfile_$((i + 2)) &
15803 #waiting osp synchronization
15804 wait_delete_completed
15806 run_test 136 "Race catalog processing 2"
15808 test_140() { #bug-17379
15809 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15811 test_mkdir $DIR/$tdir
15812 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
15813 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
15815 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
15816 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
15818 while i=$((i + 1)); do
15820 cd $i || error "Changing to $i"
15821 ln -s ../stat stat || error "Creating stat symlink"
15822 # Read the symlink until ELOOP present,
15823 # not LBUGing the system is considered success,
15824 # we didn't overrun the stack.
15825 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
15826 if [ $ret -ne 0 ]; then
15827 if [ $ret -eq 40 ]; then
15830 error "Open stat symlink"
15836 echo "The symlink depth = $i"
15837 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
15838 error "Invalid symlink depth"
15840 # Test recursive symlink
15841 ln -s symlink_self symlink_self
15842 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
15843 echo "open symlink_self returns $ret"
15844 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
15846 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
15849 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15851 local TF="$TMP/$tfile"
15853 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15854 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
15856 cancel_lru_locks $OSC
15857 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
15858 remount_client $MOUNT
15860 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
15863 $TRUNCATE $DIR/$tfile 6000
15864 cancel_lru_locks $OSC
15865 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
15868 echo "12345" >>$DIR/$tfile
15869 cancel_lru_locks $OSC
15870 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
15873 echo "12345" >>$DIR/$tfile
15874 cancel_lru_locks $OSC
15875 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
15877 run_test 150a "truncate/append tests"
15880 check_set_fallocate_or_skip
15884 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15885 out=$(check_fallocate $DIR/$tfile 2>&1) ||
15886 skip_eopnotsupp "$out|check_fallocate failed"
15888 run_test 150b "Verify fallocate (prealloc) functionality"
15891 check_set_fallocate_or_skip
15894 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15895 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
15897 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
15898 # precomputed md5sum for 20MB of zeroes
15899 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
15900 local sum=($(md5sum $DIR/$tfile))
15902 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
15904 check_set_fallocate 1
15907 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
15908 sum=($(md5sum $DIR/$tfile))
15910 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
15912 run_test 150bb "Verify fallocate modes both zero space"
15915 check_set_fallocate_or_skip
15916 local striping="-c2"
15918 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15919 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
15920 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
15921 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
15922 local want=$((OSTCOUNT * 1048576))
15924 # Must allocate all requested space, not more than 5% extra
15925 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15926 error "bytes $bytes is not $want"
15930 echo "verify fallocate on PFL file"
15932 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
15934 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
15935 error "Create $DIR/$tfile failed"
15936 fallocate -l $((1048576 * 512)) $DIR/$tfile || error "fallocate failed"
15937 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
15938 want=$((512 * 1048576))
15940 # Must allocate all requested space, not more than 5% extra
15941 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15942 error "bytes $bytes is not $want"
15944 run_test 150c "Verify fallocate Size and Blocks"
15947 check_set_fallocate_or_skip
15948 local striping="-c2"
15950 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
15952 stack_trap "rm -f $DIR/$tdir; wait_delete_completed"
15953 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
15954 error "setstripe failed"
15955 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
15956 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
15957 local want=$((OSTCOUNT * 1048576))
15959 # Must allocate all requested space, not more than 5% extra
15960 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15961 error "bytes $bytes is not $want"
15963 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
15966 check_set_fallocate_or_skip
15970 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15971 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15972 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15974 # Find OST with Minimum Size
15975 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15976 sort -un | head -1)
15978 # Get 100MB per OST of the available space to reduce run time
15979 # else 60% of the available space if we are running SLOW tests
15980 if [ $SLOW == "no" ]; then
15981 local space=$((1024 * 100 * OSTCOUNT))
15983 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
15986 fallocate -l${space}k $DIR/$tfile ||
15987 error "fallocate ${space}k $DIR/$tfile failed"
15988 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
15990 # get size immediately after fallocate. This should be correctly
15992 local size=$(stat -c '%s' $DIR/$tfile)
15993 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
15995 # Sleep for a while for statfs to get updated. And not pull from cache.
15998 echo "df after fallocate:"
16001 (( size / 1024 == space )) || error "size $size != requested $space"
16002 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
16003 error "used $used < space $space"
16005 rm $DIR/$tfile || error "rm failed"
16007 wait_delete_completed
16009 echo "df after unlink:"
16012 run_test 150e "Verify 60% of available OST space consumed by fallocate"
16017 local want_size_before=20480 # in bytes
16018 local want_blocks_before=40 # 512 sized blocks
16019 local want_blocks_after=24 # 512 sized blocks
16020 local length=$(((want_blocks_before - want_blocks_after) * 512))
16022 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
16023 skip "need at least 2.14.0 for fallocate punch"
16025 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
16026 skip "LU-14160: punch mode is not implemented on OSD ZFS"
16029 check_set_fallocate_or_skip
16030 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16032 [[ "x$DOM" == "xyes" ]] &&
16033 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
16035 echo "Verify fallocate punch: Range within the file range"
16036 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
16037 error "dd failed for bs 4096 and count 5"
16039 # Call fallocate with punch range which is within the file range
16040 out=$(fallocate -p --offset 4096 -l $length $DIR/$tfile 2>&1) ||
16041 skip_eopnotsupp "$out|fallocate: offset 4096 and length $length"
16042 # client must see changes immediately after fallocate
16043 size=$(stat -c '%s' $DIR/$tfile)
16044 blocks=$(stat -c '%b' $DIR/$tfile)
16046 # Verify punch worked.
16047 (( blocks == want_blocks_after )) ||
16048 error "punch failed: blocks $blocks != $want_blocks_after"
16050 (( size == want_size_before )) ||
16051 error "punch failed: size $size != $want_size_before"
16053 # Verify there is hole in file
16054 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
16055 # precomputed md5sum
16056 local expect="4a9a834a2db02452929c0a348273b4aa"
16058 cksum=($(md5sum $DIR/$tfile))
16059 [[ "${cksum[0]}" == "$expect" ]] ||
16060 error "unexpected MD5SUM after punch: ${cksum[0]}"
16062 # Start second sub-case for fallocate punch.
16063 echo "Verify fallocate punch: Range overlapping and less than blocksize"
16064 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
16065 error "dd failed for bs 4096 and count 5"
16067 # Punch range less than block size will have no change in block count
16068 want_blocks_after=40 # 512 sized blocks
16070 # Punch overlaps two blocks and less than blocksize
16071 out=$(fallocate -p --offset 4000 -l 3000 $DIR/$tfile 2>&1) ||
16072 skip_eopnotsupp "$out|fallocate: offset 4000 length 3000"
16073 size=$(stat -c '%s' $DIR/$tfile)
16074 blocks=$(stat -c '%b' $DIR/$tfile)
16076 # Verify punch worked.
16077 (( blocks == want_blocks_after )) ||
16078 error "punch failed: blocks $blocks != $want_blocks_after"
16080 (( size == want_size_before )) ||
16081 error "punch failed: size $size != $want_size_before"
16083 # Verify if range is really zero'ed out. We expect Zeros.
16084 # precomputed md5sum
16085 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
16086 cksum=($(md5sum $DIR/$tfile))
16087 [[ "${cksum[0]}" == "$expect" ]] ||
16088 error "unexpected MD5SUM after punch: ${cksum[0]}"
16090 run_test 150f "Verify fallocate punch functionality"
16098 local BS=4096 # Block size in bytes
16100 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
16101 skip "need at least 2.14.0 for fallocate punch"
16103 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
16104 skip "LU-14160: punch mode is not implemented on OSD ZFS"
16107 check_set_fallocate_or_skip
16108 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16110 if [[ "x$DOM" == "xyes" ]]; then
16111 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
16112 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
16114 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
16115 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
16118 # Get 100MB per OST of the available space to reduce run time
16119 # else 60% of the available space if we are running SLOW tests
16120 if [ $SLOW == "no" ]; then
16121 space=$((1024 * 100 * OSTCOUNT))
16123 # Find OST with Minimum Size
16124 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
16125 sort -un | head -1)
16126 echo "min size OST: $space"
16127 space=$(((space * 60)/100 * OSTCOUNT))
16129 # space in 1k units, round to 4k blocks
16130 local blkcount=$((space * 1024 / $BS))
16132 echo "Verify fallocate punch: Very large Range"
16133 fallocate -l${space}k $DIR/$tfile ||
16134 error "fallocate ${space}k $DIR/$tfile failed"
16135 # write 1M at the end, start and in the middle
16136 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
16137 error "dd failed: bs $BS count 256"
16138 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
16139 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
16140 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
16141 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
16144 size=$(stat -c '%s' $DIR/$tfile)
16146 # gather punch length.
16147 local punch_size=$((size - (BS * 2)))
16149 echo "punch_size = $punch_size"
16150 echo "size - punch_size: $((size - punch_size))"
16151 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
16153 # Call fallocate to punch all except 2 blocks. We leave the
16154 # first and the last block
16155 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
16156 out=$(fallocate -p --offset $BS -l $punch_size $DIR/$tfile 2>&1) ||
16157 skip_eopnotsupp "$out|fallocate: offset $BS length $punch_size"
16159 size_after=$(stat -c '%s' $DIR/$tfile)
16160 blocks_after=$(stat -c '%b' $DIR/$tfile)
16162 # Verify punch worked.
16163 # Size should be kept
16164 (( size == size_after )) ||
16165 error "punch failed: size $size != $size_after"
16167 # two 4k data blocks to remain plus possible 1 extra extent block
16168 (( blocks_after <= ((BS / 512) * 3) )) ||
16169 error "too many blocks remains: $blocks_after"
16171 # Verify that file has hole between the first and the last blocks
16172 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
16173 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
16175 echo "Hole at [$hole_start, $hole_end)"
16176 (( hole_start == BS )) ||
16177 error "no hole at offset $BS after punch"
16179 (( hole_end == BS + punch_size )) ||
16180 error "data at offset $hole_end < $((BS + punch_size))"
16182 run_test 150g "Verify fallocate punch on large range"
16185 local file=$DIR/$tfile
16188 check_set_fallocate_or_skip
16189 statx_supported || skip_env "Test must be statx() syscall supported"
16191 # fallocate() does not update the size information on the MDT
16192 fallocate -l 16K $file || error "failed to fallocate $file"
16193 cancel_lru_locks $OSC
16194 # STATX with cached-always mode will not send glimpse RPCs to OST,
16195 # it uses the caching attrs on the client side as much as possible.
16196 size=$($STATX --cached=always -c %s $file)
16197 [ $size == 16384 ] ||
16198 error "size after fallocate() is $size, expected 16384"
16200 run_test 150h "Verify extend fallocate updates the file size"
16202 #LU-2902 roc_hit was not able to read all values from lproc
16203 function roc_hit_init() {
16204 local list=$(comma_list $(osts_nodes))
16205 local dir=$DIR/$tdir-check
16206 local file=$dir/$tfile
16212 #use setstripe to do a write to every ost
16213 for i in $(seq 0 $((OSTCOUNT-1))); do
16214 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
16215 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
16216 idx=$(printf %04x $i)
16217 BEFORE=$(get_osd_param $list *OST*$idx stats |
16218 awk '$1 == "cache_access" {sum += $7}
16219 END { printf("%0.0f", sum) }')
16221 cancel_lru_locks osc
16222 cat $file >/dev/null
16224 AFTER=$(get_osd_param $list *OST*$idx stats |
16225 awk '$1 == "cache_access" {sum += $7}
16226 END { printf("%0.0f", sum) }')
16228 echo BEFORE:$BEFORE AFTER:$AFTER
16229 if ! let "AFTER - BEFORE == 4"; then
16231 error "roc_hit is not safe to use"
16239 function roc_hit() {
16240 local list=$(comma_list $(osts_nodes))
16241 echo $(get_osd_param $list '' stats |
16242 awk '$1 == "cache_hit" {sum += $7}
16243 END { printf("%0.0f", sum) }')
16246 function set_cache() {
16249 if [ "$2" == "off" ]; then
16252 local list=$(comma_list $(osts_nodes))
16253 set_osd_param $list '' $1_cache_enable $on
16255 cancel_lru_locks osc
16259 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16260 remote_ost_nodsh && skip "remote OST with nodsh"
16261 (( CLIENT_VERSION == OST1_VERSION )) ||
16262 skip "LU-13081: no interop testing for OSS cache"
16265 local list=$(comma_list $(osts_nodes))
16267 # check whether obdfilter is cache capable at all
16268 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
16269 skip "not cache-capable obdfilter"
16272 # check cache is enabled on all obdfilters
16273 if get_osd_param $list '' read_cache_enable | grep 0; then
16274 skip "oss cache is disabled"
16277 set_osd_param $list '' writethrough_cache_enable 1
16279 # check write cache is enabled on all obdfilters
16280 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
16281 skip "oss write cache is NOT enabled"
16286 #define OBD_FAIL_OBD_NO_LRU 0x609
16287 do_nodes $list $LCTL set_param fail_loc=0x609
16289 # pages should be in the case right after write
16290 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
16293 local BEFORE=$(roc_hit)
16294 cancel_lru_locks osc
16295 cat $DIR/$tfile >/dev/null
16296 local AFTER=$(roc_hit)
16298 do_nodes $list $LCTL set_param fail_loc=0
16300 if ! let "AFTER - BEFORE == CPAGES"; then
16301 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
16304 cancel_lru_locks osc
16305 # invalidates OST cache
16306 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
16307 set_osd_param $list '' read_cache_enable 0
16308 cat $DIR/$tfile >/dev/null
16310 # now data shouldn't be found in the cache
16312 cancel_lru_locks osc
16313 cat $DIR/$tfile >/dev/null
16315 if let "AFTER - BEFORE != 0"; then
16316 error "IN CACHE: before: $BEFORE, after: $AFTER"
16319 set_osd_param $list '' read_cache_enable 1
16322 run_test 151 "test cache on oss and controls ==============================="
16325 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16327 local TF="$TMP/$tfile"
16329 # simulate ENOMEM during write
16330 #define OBD_FAIL_OST_NOMEM 0x226
16331 lctl set_param fail_loc=0x80000226
16332 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
16334 sync || error "sync failed"
16335 lctl set_param fail_loc=0
16337 # discard client's cache
16338 cancel_lru_locks osc
16340 # simulate ENOMEM during read
16341 lctl set_param fail_loc=0x80000226
16342 cmp $TF $DIR/$tfile || error "cmp failed"
16343 lctl set_param fail_loc=0
16347 run_test 152 "test read/write with enomem ============================"
16350 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
16352 run_test 153 "test if fdatasync does not crash ======================="
16354 dot_lustre_fid_permission_check() {
16356 local ffid=$MOUNT/.lustre/fid/$fid
16359 echo "stat fid $fid"
16360 stat $ffid || error "stat $ffid failed."
16361 echo "touch fid $fid"
16362 touch $ffid || error "touch $ffid failed."
16363 echo "write to fid $fid"
16364 cat /etc/hosts > $ffid || error "write $ffid failed."
16365 echo "read fid $fid"
16366 diff /etc/hosts $ffid || error "read $ffid failed."
16367 echo "append write to fid $fid"
16368 cat /etc/hosts >> $ffid || error "append write $ffid failed."
16369 echo "rename fid $fid"
16370 mv $ffid $test_dir/$tfile.1 &&
16371 error "rename $ffid to $tfile.1 should fail."
16372 touch $test_dir/$tfile.1
16373 mv $test_dir/$tfile.1 $ffid &&
16374 error "rename $tfile.1 to $ffid should fail."
16375 rm -f $test_dir/$tfile.1
16376 echo "truncate fid $fid"
16377 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
16378 echo "link fid $fid"
16379 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
16380 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
16381 id $USER0 || skip_env "missing user $USER0"
16382 echo "setfacl fid $fid"
16383 setfacl -R -m u:$USER0:rwx $ffid ||
16384 error "setfacl $ffid failed"
16385 echo "getfacl fid $fid"
16386 getfacl $ffid || error "getfacl $ffid failed."
16388 echo "unlink fid $fid"
16389 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
16390 echo "mknod fid $fid"
16391 mknod $ffid c 1 3 && error "mknod $ffid should fail."
16393 fid=[0xf00000400:0x1:0x0]
16394 ffid=$MOUNT/.lustre/fid/$fid
16396 echo "stat non-exist fid $fid"
16397 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
16398 echo "write to non-exist fid $fid"
16399 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
16400 echo "link new fid $fid"
16401 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
16403 mkdir -p $test_dir/$tdir
16404 touch $test_dir/$tdir/$tfile
16405 fid=$($LFS path2fid $test_dir/$tdir)
16408 error "error: could not get fid for $test_dir/$dir/$tfile."
16410 ffid=$MOUNT/.lustre/fid/$fid
16413 ls $ffid || error "ls $ffid failed."
16414 echo "touch $fid/$tfile.1"
16415 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
16417 echo "touch $MOUNT/.lustre/fid/$tfile"
16418 touch $MOUNT/.lustre/fid/$tfile && \
16419 error "touch $MOUNT/.lustre/fid/$tfile should fail."
16421 echo "setxattr to $MOUNT/.lustre/fid"
16422 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
16424 echo "listxattr for $MOUNT/.lustre/fid"
16425 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
16427 echo "delxattr from $MOUNT/.lustre/fid"
16428 setfattr -x trusted.name1 $MOUNT/.lustre/fid
16430 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
16431 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
16432 error "touch invalid fid should fail."
16434 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
16435 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
16436 error "touch non-normal fid should fail."
16438 echo "rename $tdir to $MOUNT/.lustre/fid"
16439 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
16440 error "rename to $MOUNT/.lustre/fid should fail."
16442 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
16444 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
16445 local new_obf_mode=777
16447 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
16448 chmod $new_obf_mode $DIR/.lustre/fid ||
16449 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
16451 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
16452 [ $obf_mode -eq $new_obf_mode ] ||
16453 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
16455 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
16456 chmod $old_obf_mode $DIR/.lustre/fid ||
16457 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
16460 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
16461 fid=$($LFS path2fid $test_dir/$tfile-2)
16463 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
16465 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
16466 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
16467 error "create lov data thru .lustre failed"
16469 echo "cp /etc/passwd $test_dir/$tfile-2"
16470 cp /etc/passwd $test_dir/$tfile-2 ||
16471 error "copy to $test_dir/$tfile-2 failed."
16472 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
16473 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
16474 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
16476 rm -rf $test_dir/tfile.lnk
16477 rm -rf $test_dir/$tfile-2
16481 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
16482 skip "Need MDS version at least 2.4.1"
16484 local tf=$DIR/$tfile
16487 local fid=$($LFS path2fid $tf)
16488 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
16490 # check that we get the same pathname back
16493 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
16494 echo "$rootpath $fid"
16495 found=$($LFS fid2path $rootpath "$fid")
16496 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
16497 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
16500 # check wrong root path format
16501 rootpath=$MOUNT"_wrong"
16502 found=$($LFS fid2path $rootpath "$fid")
16503 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
16505 run_test 154A "lfs path2fid and fid2path basic checks"
16508 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
16509 skip "Need MDS version at least 2.4.1"
16511 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
16512 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
16513 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
16514 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
16516 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
16517 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
16519 # check that we get the same pathname
16520 echo "PFID: $PFID, name: $name"
16521 local FOUND=$($LFS fid2path $MOUNT "$PFID")
16522 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
16523 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
16524 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
16526 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
16528 run_test 154B "verify the ll_decode_linkea tool"
16531 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16532 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16533 (( $MDS1_VERSION >= $(version_code 2.2.51) )) ||
16534 skip "Need MDS version at least 2.2.51"
16535 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
16537 cp /etc/hosts $DIR/$tfile
16539 fid=$($LFS path2fid $DIR/$tfile)
16541 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
16543 dot_lustre_fid_permission_check "$fid" $DIR ||
16544 error "dot lustre permission check $fid failed"
16546 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
16548 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
16550 touch $MOUNT/.lustre/file &&
16551 error "creation is not allowed under .lustre"
16553 mkdir $MOUNT/.lustre/dir &&
16554 error "mkdir is not allowed under .lustre"
16558 run_test 154a "Open-by-FID"
16561 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16562 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16563 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16564 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
16565 skip "Need MDS version at least 2.2.51"
16567 local remote_dir=$DIR/$tdir/remote_dir
16571 mkdir -p $DIR/$tdir
16572 $LFS mkdir -i $MDTIDX $remote_dir ||
16573 error "create remote directory failed"
16575 cp /etc/hosts $remote_dir/$tfile
16577 fid=$($LFS path2fid $remote_dir/$tfile)
16579 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
16581 dot_lustre_fid_permission_check "$fid" $remote_dir ||
16582 error "dot lustre permission check $fid failed"
16585 run_test 154b "Open-by-FID for remote directory"
16588 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
16589 skip "Need MDS version at least 2.4.1"
16591 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
16592 local FID1=$($LFS path2fid $DIR/$tfile.1)
16593 local FID2=$($LFS path2fid $DIR/$tfile.2)
16594 local FID3=$($LFS path2fid $DIR/$tfile.3)
16597 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
16598 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
16599 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
16601 [ "$FID" = "${!want}" ] ||
16602 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
16606 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
16608 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
16609 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
16613 run_test 154c "lfs path2fid and fid2path multiple arguments"
16616 remote_mds_nodsh && skip "remote MDS with nodsh"
16617 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
16618 skip "Need MDS version at least 2.5.53"
16620 if remote_mds; then
16621 nid=$($LCTL list_nids | sed "s/\./\\\./g")
16625 local proc_ofile="mdt.*.exports.'$nid'.open_files"
16632 local fid=$($LFS path2fid $DIR/$tfile)
16635 cmd="exec $fd<$DIR/$tfile"
16637 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
16638 echo "$fid_list" | grep "$fid"
16641 cmd="exec $fd>/dev/null"
16643 if [ $rc -ne 0 ]; then
16644 error "FID $fid not found in open files list $fid_list"
16647 run_test 154d "Verify open file fid"
16651 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
16652 skip "Need MDS version at least 2.6.50"
16654 if ls -a $MOUNT | grep -q '^\.lustre$'; then
16655 error ".lustre returned by readdir"
16658 run_test 154e ".lustre is not returned by readdir"
16661 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16663 # create parent directory on a single MDT to avoid cross-MDT hardlinks
16664 mkdir_on_mdt0 $DIR/$tdir
16665 # test dirs inherit from its stripe
16666 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
16667 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
16668 cp /etc/hosts $DIR/$tdir/foo1/$tfile
16669 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
16672 # get fid of parents
16673 local FID0=$($LFS path2fid $DIR/$tdir)
16674 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
16675 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
16676 local FID3=$($LFS path2fid $DIR)
16678 # check that path2fid --parents returns expected <parent_fid>/name
16679 # 1) test for a directory (single parent)
16680 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
16681 [ "$parent" == "$FID0/foo1" ] ||
16682 error "expected parent: $FID0/foo1, got: $parent"
16684 # 2) test for a file with nlink > 1 (multiple parents)
16685 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
16686 echo "$parent" | grep -F "$FID1/$tfile" ||
16687 error "$FID1/$tfile not returned in parent list"
16688 echo "$parent" | grep -F "$FID2/link" ||
16689 error "$FID2/link not returned in parent list"
16691 # 3) get parent by fid
16692 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
16693 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16694 echo "$parent" | grep -F "$FID1/$tfile" ||
16695 error "$FID1/$tfile not returned in parent list (by fid)"
16696 echo "$parent" | grep -F "$FID2/link" ||
16697 error "$FID2/link not returned in parent list (by fid)"
16699 # 4) test for entry in root directory
16700 parent=$($LFS path2fid --parents $DIR/f)
16701 echo "$parent" | grep -F "$FID3/f" ||
16702 error "$FID3/f not returned in parent list"
16704 # 5) test it on root directory
16705 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
16706 error "$MOUNT should not have parents"
16708 # enable xattr caching and check that linkea is correctly updated
16709 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
16710 save_lustre_params client "llite.*.xattr_cache" > $save
16711 lctl set_param llite.*.xattr_cache 1
16713 # 6.1) linkea update on rename
16714 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
16716 # get parents by fid
16717 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16718 # foo1 should no longer be returned in parent list
16719 echo "$parent" | grep -F "$FID1" &&
16720 error "$FID1 should no longer be in parent list"
16721 # the new path should appear
16722 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
16723 error "$FID2/$tfile.moved is not in parent list"
16725 # 6.2) linkea update on unlink
16726 rm -f $DIR/$tdir/foo2/link
16727 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16728 # foo2/link should no longer be returned in parent list
16729 echo "$parent" | grep -F "$FID2/link" &&
16730 error "$FID2/link should no longer be in parent list"
16734 restore_lustre_params < $save
16737 run_test 154f "get parent fids by reading link ea"
16741 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
16742 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
16743 skip "Need MDS version at least 2.6.92"
16745 mkdir_on_mdt0 $DIR/$tdir
16746 llapi_fid_test -d $DIR/$tdir
16748 run_test 154g "various llapi FID tests"
16752 (( $CLIENT_VERSION >= $(version_code 2.15.55.1) )) ||
16753 skip "Need client at least version 2.15.55.1"
16755 # Create an empty file
16758 # Get FID (interactive mode) and save under $TMP/$tfile.log
16759 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
16760 path2fid $DIR/$tfile
16763 fid=$(cat $TMP/$tfile.log)
16764 # $fid should not be empty
16765 [[ ! -z $fid ]] || error "FID is empty"
16766 $LFS rmfid $DIR "$fid" || error "rmfid failed for $fid"
16768 run_test 154h "Verify interactive path2fid"
16770 test_155_small_load() {
16771 local temp=$TMP/$tfile
16772 local file=$DIR/$tfile
16774 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
16775 error "dd of=$temp bs=6096 count=1 failed"
16777 cancel_lru_locks $OSC
16778 cmp $temp $file || error "$temp $file differ"
16780 $TRUNCATE $temp 6000
16781 $TRUNCATE $file 6000
16782 cmp $temp $file || error "$temp $file differ (truncate1)"
16784 echo "12345" >>$temp
16785 echo "12345" >>$file
16786 cmp $temp $file || error "$temp $file differ (append1)"
16788 echo "12345" >>$temp
16789 echo "12345" >>$file
16790 cmp $temp $file || error "$temp $file differ (append2)"
16796 test_155_big_load() {
16797 remote_ost_nodsh && skip "remote OST with nodsh"
16799 local temp=$TMP/$tfile
16800 local file=$DIR/$tfile
16803 local cache_size=$(do_facet ost$((MAXI+1)) \
16804 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
16806 # LU-16042: can not get the cache size on Arm64 VM here, fallback to a
16808 if [ -z "$cache_size" ]; then
16811 local large_file_size=$((cache_size * 2))
16813 echo "OSS cache size: $cache_size KB"
16814 echo "Large file size: $large_file_size KB"
16816 [ $MAXV -le $large_file_size ] &&
16817 skip_env "max available OST size needs > $large_file_size KB"
16819 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
16821 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
16822 error "dd of=$temp bs=$large_file_size count=1k failed"
16825 cancel_lru_locks osc
16826 cmp $temp $file || error "$temp $file differ"
16832 save_writethrough() {
16833 local facets=$(get_facets OST)
16835 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
16839 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16841 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16843 save_writethrough $p
16846 set_cache writethrough on
16847 test_155_small_load
16848 restore_lustre_params < $p
16851 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
16854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16856 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16858 save_writethrough $p
16861 set_cache writethrough off
16862 test_155_small_load
16863 restore_lustre_params < $p
16866 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
16869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16871 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16873 save_writethrough $p
16876 set_cache writethrough on
16877 test_155_small_load
16878 restore_lustre_params < $p
16881 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
16884 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16886 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16888 save_writethrough $p
16891 set_cache writethrough off
16892 test_155_small_load
16893 restore_lustre_params < $p
16896 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
16899 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16901 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16903 save_writethrough $p
16906 set_cache writethrough on
16908 restore_lustre_params < $p
16911 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
16914 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16916 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16918 save_writethrough $p
16921 set_cache writethrough off
16923 restore_lustre_params < $p
16926 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
16929 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16931 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16933 save_writethrough $p
16936 set_cache writethrough on
16938 restore_lustre_params < $p
16941 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
16944 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16946 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16948 save_writethrough $p
16951 set_cache writethrough off
16953 restore_lustre_params < $p
16956 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
16959 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16960 remote_ost_nodsh && skip "remote OST with nodsh"
16961 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
16962 skip "stats not implemented on old servers"
16963 [ "$ost1_FSTYPE" = "zfs" ] &&
16964 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
16965 (( CLIENT_VERSION == OST1_VERSION )) ||
16966 skip "LU-13081: no interop testing for OSS cache"
16971 local file="$DIR/$tfile"
16972 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16974 save_writethrough $p
16977 log "Turn on read and write cache"
16979 set_cache writethrough on
16981 log "Write data and read it back."
16982 log "Read should be satisfied from the cache."
16983 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16985 cancel_lru_locks osc
16986 cat $file >/dev/null
16988 if ! let "AFTER - BEFORE == CPAGES"; then
16989 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
16991 log "cache hits: before: $BEFORE, after: $AFTER"
16994 log "Read again; it should be satisfied from the cache."
16996 cancel_lru_locks osc
16997 cat $file >/dev/null
16999 if ! let "AFTER - BEFORE == CPAGES"; then
17000 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
17002 log "cache hits:: before: $BEFORE, after: $AFTER"
17005 log "Turn off the read cache and turn on the write cache"
17007 set_cache writethrough on
17009 log "Read again; it should be satisfied from the cache."
17011 cancel_lru_locks osc
17012 cat $file >/dev/null
17014 if ! let "AFTER - BEFORE == CPAGES"; then
17015 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
17017 log "cache hits:: before: $BEFORE, after: $AFTER"
17020 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
17021 # > 2.12.56 uses pagecache if cached
17022 log "Read again; it should not be satisfied from the cache."
17024 cancel_lru_locks osc
17025 cat $file >/dev/null
17027 if ! let "AFTER - BEFORE == 0"; then
17028 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
17030 log "cache hits:: before: $BEFORE, after: $AFTER"
17034 log "Write data and read it back."
17035 log "Read should be satisfied from the cache."
17036 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
17038 cancel_lru_locks osc
17039 cat $file >/dev/null
17041 if ! let "AFTER - BEFORE == CPAGES"; then
17042 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
17044 log "cache hits:: before: $BEFORE, after: $AFTER"
17047 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
17048 # > 2.12.56 uses pagecache if cached
17049 log "Read again; it should not be satisfied from the cache."
17051 cancel_lru_locks osc
17052 cat $file >/dev/null
17054 if ! let "AFTER - BEFORE == 0"; then
17055 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
17057 log "cache hits:: before: $BEFORE, after: $AFTER"
17061 log "Turn off read and write cache"
17063 set_cache writethrough off
17065 log "Write data and read it back"
17066 log "It should not be satisfied from the cache."
17068 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
17069 cancel_lru_locks osc
17071 cat $file >/dev/null
17073 if ! let "AFTER - BEFORE == 0"; then
17074 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
17076 log "cache hits:: before: $BEFORE, after: $AFTER"
17079 log "Turn on the read cache and turn off the write cache"
17081 set_cache writethrough off
17083 log "Write data and read it back"
17084 log "It should not be satisfied from the cache."
17086 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
17088 cancel_lru_locks osc
17089 cat $file >/dev/null
17091 if ! let "AFTER - BEFORE == 0"; then
17092 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
17094 log "cache hits:: before: $BEFORE, after: $AFTER"
17097 log "Read again; it should be satisfied from the cache."
17099 cancel_lru_locks osc
17100 cat $file >/dev/null
17102 if ! let "AFTER - BEFORE == CPAGES"; then
17103 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
17105 log "cache hits:: before: $BEFORE, after: $AFTER"
17108 restore_lustre_params < $p
17111 run_test 156 "Verification of tunables"
17114 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17115 remote_mds_nodsh && skip "remote MDS with nodsh"
17116 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
17117 skip "Need MDS version at least 2.2.0"
17119 changelog_register || error "changelog_register failed"
17120 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17121 changelog_users $SINGLEMDS | grep -q $cl_user ||
17122 error "User $cl_user not found in changelog_users"
17124 mkdir_on_mdt0 $DIR/$tdir
17127 test_mkdir -p $DIR/$tdir/pics/2008/zachy
17128 changelog_clear 0 || error "changelog_clear failed"
17129 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
17130 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
17131 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
17132 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
17133 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
17134 rm $DIR/$tdir/pics/desktop.jpg
17136 echo "verifying changelog mask"
17137 changelog_chmask "-MKDIR"
17138 changelog_chmask "-CLOSE"
17140 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
17141 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
17143 changelog_chmask "+MKDIR"
17144 changelog_chmask "+CLOSE"
17146 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
17147 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
17149 MKDIRS=$(changelog_dump | grep -c "MKDIR")
17150 CLOSES=$(changelog_dump | grep -c "CLOSE")
17151 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
17152 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
17155 echo "verifying target fid"
17156 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
17157 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
17158 [ "$fidc" == "$fidf" ] ||
17159 error "changelog '$tfile' fid $fidc != file fid $fidf"
17160 echo "verifying parent fid"
17161 # The FID returned from the Changelog may be the directory shard on
17162 # a different MDT, and not the FID returned by path2fid on the parent.
17163 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
17164 # since this is what will matter when recreating this file in the tree.
17165 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
17166 local pathp=$($LFS fid2path $MOUNT "$fidp")
17167 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
17168 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
17170 echo "getting records for $cl_user"
17171 changelog_users $SINGLEMDS
17172 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
17174 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
17175 error "changelog_clear failed"
17176 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
17177 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
17178 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
17179 error "user index expect $user_rec1 + $nclr != $user_rec2"
17181 local min0_rec=$(changelog_users $SINGLEMDS |
17182 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
17183 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
17184 awk '{ print $1; exit; }')
17186 changelog_dump | tail -n 5
17187 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
17188 [ $first_rec == $((min0_rec + 1)) ] ||
17189 error "first index should be $min0_rec + 1 not $first_rec"
17191 # LU-3446 changelog index reset on MDT restart
17192 local cur_rec1=$(changelog_users $SINGLEMDS |
17193 awk '/^current.index:/ { print $NF }')
17194 changelog_clear 0 ||
17195 error "clear all changelog records for $cl_user failed"
17196 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
17197 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
17198 error "Fail to start $SINGLEMDS"
17199 local cur_rec2=$(changelog_users $SINGLEMDS |
17200 awk '/^current.index:/ { print $NF }')
17201 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
17202 [ $cur_rec1 == $cur_rec2 ] ||
17203 error "current index should be $cur_rec1 not $cur_rec2"
17205 echo "verifying users from this test are deregistered"
17206 changelog_deregister || error "changelog_deregister failed"
17207 changelog_users $SINGLEMDS | grep -q $cl_user &&
17208 error "User '$cl_user' still in changelog_users"
17210 # lctl get_param -n mdd.*.changelog_users
17211 # current_index: 144
17212 # ID index (idle seconds)
17213 # cl3 144 (2) mask=<list>
17214 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
17215 # this is the normal case where all users were deregistered
17216 # make sure no new records are added when no users are present
17217 local last_rec1=$(changelog_users $SINGLEMDS |
17218 awk '/^current.index:/ { print $NF }')
17219 touch $DIR/$tdir/chloe
17220 local last_rec2=$(changelog_users $SINGLEMDS |
17221 awk '/^current.index:/ { print $NF }')
17222 echo "verify changelogs are off: $last_rec1 == $last_rec2"
17223 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
17225 # any changelog users must be leftovers from a previous test
17226 changelog_users $SINGLEMDS
17227 echo "other changelog users; can't verify off"
17230 run_test 160a "changelog sanity"
17232 test_160b() { # LU-3587
17233 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17234 remote_mds_nodsh && skip "remote MDS with nodsh"
17235 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
17236 skip "Need MDS version at least 2.2.0"
17238 changelog_register || error "changelog_register failed"
17239 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17240 changelog_users $SINGLEMDS | grep -q $cl_user ||
17241 error "User '$cl_user' not found in changelog_users"
17243 local longname1=$(str_repeat a 255)
17244 local longname2=$(str_repeat b 255)
17247 echo "creating very long named file"
17248 touch $longname1 || error "create of '$longname1' failed"
17249 echo "renaming very long named file"
17250 mv $longname1 $longname2
17252 changelog_dump | grep RENME | tail -n 5
17255 run_test 160b "Verify that very long rename doesn't crash in changelog"
17258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17259 remote_mds_nodsh && skip "remote MDS with nodsh"
17261 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
17262 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
17263 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
17264 skip "Need MDS version at least 2.5.58 or 2.5.2+"
17268 # Registration step
17269 changelog_register || error "changelog_register failed"
17272 mkdir -p $DIR/$tdir
17273 $MCREATE $DIR/$tdir/foo_160c
17274 changelog_chmask "-TRUNC"
17275 $TRUNCATE $DIR/$tdir/foo_160c 200
17276 changelog_chmask "+TRUNC"
17277 $TRUNCATE $DIR/$tdir/foo_160c 199
17278 changelog_dump | tail -n 5
17279 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
17280 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
17282 run_test 160c "verify that changelog log catch the truncate event"
17285 remote_mds_nodsh && skip "remote MDS with nodsh"
17286 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17287 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17288 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
17289 skip "Need MDS version at least 2.7.60"
17291 # Registration step
17292 changelog_register || error "changelog_register failed"
17294 mkdir -p $DIR/$tdir/migrate_dir
17295 changelog_clear 0 || error "changelog_clear failed"
17297 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
17298 changelog_dump | tail -n 5
17299 local migrates=$(changelog_dump | grep -c "MIGRT")
17300 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
17302 run_test 160d "verify that changelog log catch the migrate event"
17305 remote_mds_nodsh && skip "remote MDS with nodsh"
17308 changelog_register || error "changelog_register failed"
17310 local MDT0=$(facet_svc $SINGLEMDS)
17313 # No user (expect fail)
17314 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
17316 if [ $rc -eq 0 ]; then
17317 error "Should fail without user"
17318 elif [ $rc -ne 4 ]; then
17319 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
17322 # Delete a future user (expect fail)
17323 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
17325 if [ $rc -eq 0 ]; then
17326 error "Deleted non-existant user cl77"
17327 elif [ $rc -ne 2 ]; then
17328 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
17331 # Clear to a bad index (1 billion should be safe)
17332 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
17335 if [ $rc -eq 0 ]; then
17336 error "Successfully cleared to invalid CL index"
17337 elif [ $rc -ne 22 ]; then
17338 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
17341 run_test 160e "changelog negative testing (should return errors)"
17344 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17345 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
17346 skip "Need MDS version at least 2.10.56"
17348 local mdts=$(comma_list $(mdts_nodes))
17351 changelog_register || error "first changelog_register failed"
17352 changelog_register || error "second changelog_register failed"
17354 declare -A cl_user1
17355 declare -A cl_user2
17360 # generate some changelog records to accumulate on each MDT
17361 # use all_char because created files should be evenly distributed
17362 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17363 error "test_mkdir $tdir failed"
17364 log "$(date +%s): creating first files"
17365 for ((i = 0; i < MDSCOUNT * 2; i++)); do
17366 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
17367 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
17370 # check changelogs have been generated
17371 local start=$SECONDS
17372 local idle_time=$((MDSCOUNT * 5 + 5))
17373 local nbcl=$(changelog_dump | wc -l)
17374 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17376 for param in "changelog_max_idle_time=$idle_time" \
17378 "changelog_min_gc_interval=2" \
17379 "changelog_min_free_cat_entries=3"; do
17380 local MDT0=$(facet_svc $SINGLEMDS)
17381 local var="${param%=*}"
17382 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17384 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17385 do_nodes $mdts $LCTL set_param mdd.*.$param
17388 # force cl_user2 to be idle (1st part), but also cancel the
17389 # cl_user1 records so that it is not evicted later in the test.
17390 local sleep1=$((idle_time / 2))
17391 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
17394 # simulate changelog catalog almost full
17395 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
17396 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
17398 for i in $(seq $MDSCOUNT); do
17399 cl_users=(${CL_USERS[mds$i]})
17400 cl_user1[mds$i]="${cl_users[0]}"
17401 cl_user2[mds$i]="${cl_users[1]}"
17403 [ -n "${cl_user1[mds$i]}" ] ||
17404 error "mds$i: no user registered"
17405 [ -n "${cl_user2[mds$i]}" ] ||
17406 error "mds$i: only ${cl_user2[mds$i]} is registered"
17408 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17409 [ -n "$user_rec1" ] ||
17410 error "mds$i: User ${cl_user1[mds$i]} not registered"
17411 __changelog_clear mds$i ${cl_user1[mds$i]} +2
17412 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17413 [ -n "$user_rec2" ] ||
17414 error "mds$i: User ${cl_user1[mds$i]} not registered"
17415 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
17416 "$user_rec1 + 2 == $user_rec2"
17417 [ $((user_rec1 + 2)) == $user_rec2 ] ||
17418 error "mds$i: user ${cl_user1[mds$i]} index expected " \
17419 "$user_rec1 + 2, but is $user_rec2"
17420 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
17421 [ -n "$user_rec2" ] ||
17422 error "mds$i: User ${cl_user2[mds$i]} not registered"
17423 [ $user_rec1 == $user_rec2 ] ||
17424 error "mds$i: user ${cl_user2[mds$i]} index expected " \
17425 "$user_rec1, but is $user_rec2"
17428 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
17429 local sleep2=$((idle_time - (SECONDS - start) + 1))
17430 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
17433 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
17434 # cl_user1 should be OK because it recently processed records.
17435 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
17436 for ((i = 0; i < MDSCOUNT * 2; i++)); do
17437 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
17438 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
17441 # ensure gc thread is done
17442 for i in $(mdts_nodes); do
17443 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
17444 error "$i: GC-thread not done"
17448 for (( i = 1; i <= MDSCOUNT; i++ )); do
17449 # check cl_user1 still registered
17450 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
17451 error "mds$i: User ${cl_user1[mds$i]} not registered"
17452 # check cl_user2 unregistered
17453 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
17454 error "mds$i: User ${cl_user2[mds$i]} still registered"
17456 # check changelogs are present and starting at $user_rec1 + 1
17457 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17458 [ -n "$user_rec1" ] ||
17459 error "mds$i: User ${cl_user1[mds$i]} not registered"
17460 first_rec=$($LFS changelog $(facet_svc mds$i) |
17461 awk '{ print $1; exit; }')
17463 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
17464 [ $((user_rec1 + 1)) == $first_rec ] ||
17465 error "mds$i: rec $first_rec != $user_rec1 + 1"
17468 run_test 160f "changelog garbage collect (timestamped users)"
17471 remote_mds_nodsh && skip "remote MDS with nodsh"
17472 [[ $MDS1_VERSION -ge $(version_code 2.14.55) ]] ||
17473 skip "Need MDS version at least 2.14.55"
17475 local mdts=$(comma_list $(mdts_nodes))
17478 changelog_register || error "first changelog_register failed"
17479 changelog_register || error "second changelog_register failed"
17481 declare -A cl_user1
17482 declare -A cl_user2
17487 # generate some changelog records to accumulate on each MDT
17488 # use all_char because created files should be evenly distributed
17489 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17490 error "test_mkdir $tdir failed"
17491 for ((i = 0; i < MDSCOUNT; i++)); do
17492 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17493 error "create $DIR/$tdir/d$i.1 failed"
17496 # check changelogs have been generated
17497 local nbcl=$(changelog_dump | wc -l)
17498 (( $nbcl > 0 )) || error "no changelogs found"
17500 # reduce the max_idle_indexes value to make sure we exceed it
17501 for param in "changelog_max_idle_indexes=2" \
17503 "changelog_min_gc_interval=2"; do
17504 local MDT0=$(facet_svc $SINGLEMDS)
17505 local var="${param%=*}"
17506 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17508 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17509 do_nodes $mdts $LCTL set_param mdd.*.$param ||
17510 error "unable to set mdd.*.$param"
17513 local start=$SECONDS
17514 for i in $(seq $MDSCOUNT); do
17515 cl_users=(${CL_USERS[mds$i]})
17516 cl_user1[mds$i]="${cl_users[0]}"
17517 cl_user2[mds$i]="${cl_users[1]}"
17519 [ -n "${cl_user1[mds$i]}" ] ||
17520 error "mds$i: user1 is not registered"
17521 [ -n "${cl_user2[mds$i]}" ] ||
17522 error "mds$i: only ${cl_user1[mds$i]} is registered"
17524 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17525 [ -n "$user_rec1" ] ||
17526 error "mds$i: user1 ${cl_user1[mds$i]} not found"
17527 __changelog_clear mds$i ${cl_user1[mds$i]} +2
17528 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17529 [ -n "$user_rec2" ] ||
17530 error "mds$i: user1 ${cl_user1[mds$i]} not found (2)"
17531 echo "mds$i: verifying user1 ${cl_user1[mds$i]} clear: " \
17532 "$user_rec1 + 2 == $user_rec2"
17533 [ $((user_rec1 + 2)) == $user_rec2 ] ||
17534 error "mds$i: user1 ${cl_user1[mds$i]} index " \
17535 "expected $user_rec1 + 2, but is $user_rec2"
17536 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
17537 [ -n "$user_rec2" ] ||
17538 error "mds$i: user2 ${cl_user2[mds$i]} not found"
17539 [ $user_rec1 == $user_rec2 ] ||
17540 error "mds$i: user2 ${cl_user2[mds$i]} index " \
17541 "expected $user_rec1, but is $user_rec2"
17544 # ensure we are past the previous changelog_min_gc_interval set above
17545 local sleep2=$((start + 2 - SECONDS))
17546 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17547 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
17548 # cl_user1 should be OK because it recently processed records.
17549 for ((i = 0; i < MDSCOUNT; i++)); do
17550 $LFS mkdir -i $i $DIR/$tdir/d$i.3 ||
17551 error "create $DIR/$tdir/d$i.3 failed"
17554 # ensure gc thread is done
17555 for i in $(mdts_nodes); do
17556 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
17557 error "$i: GC-thread not done"
17561 for (( i = 1; i <= MDSCOUNT; i++ )); do
17562 # check cl_user1 still registered
17563 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
17564 error "mds$i: user1 ${cl_user1[mds$i]} not found (3)"
17565 # check cl_user2 unregistered
17566 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
17567 error "mds$i: user2 ${cl_user2[mds$i]} is registered"
17569 # check changelogs are present and starting at $user_rec1 + 1
17570 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17571 [ -n "$user_rec1" ] ||
17572 error "mds$i: user1 ${cl_user1[mds$i]} not found (4)"
17573 first_rec=$($LFS changelog $(facet_svc mds$i) |
17574 awk '{ print $1; exit; }')
17576 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
17577 [ $((user_rec1 + 1)) == $first_rec ] ||
17578 error "mds$i: rec $first_rec != $user_rec1 + 1"
17581 run_test 160g "changelog garbage collect on idle records"
17584 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17585 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
17586 skip "Need MDS version at least 2.10.56"
17588 local mdts=$(comma_list $(mdts_nodes))
17591 changelog_register || error "first changelog_register failed"
17592 changelog_register || error "second changelog_register failed"
17594 declare -A cl_user1
17595 declare -A cl_user2
17600 # generate some changelog records to accumulate on each MDT
17601 # use all_char because created files should be evenly distributed
17602 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17603 error "test_mkdir $tdir failed"
17604 for ((i = 0; i < MDSCOUNT; i++)); do
17605 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17606 error "create $DIR/$tdir/d$i.1 failed"
17609 # check changelogs have been generated
17610 local nbcl=$(changelog_dump | wc -l)
17611 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17613 for param in "changelog_max_idle_time=10" \
17615 "changelog_min_gc_interval=2"; do
17616 local MDT0=$(facet_svc $SINGLEMDS)
17617 local var="${param%=*}"
17618 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17620 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17621 do_nodes $mdts $LCTL set_param mdd.*.$param
17624 # force cl_user2 to be idle (1st part)
17627 for i in $(seq $MDSCOUNT); do
17628 cl_users=(${CL_USERS[mds$i]})
17629 cl_user1[mds$i]="${cl_users[0]}"
17630 cl_user2[mds$i]="${cl_users[1]}"
17632 [ -n "${cl_user1[mds$i]}" ] ||
17633 error "mds$i: no user registered"
17634 [ -n "${cl_user2[mds$i]}" ] ||
17635 error "mds$i: only ${cl_user2[mds$i]} is registered"
17637 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17638 [ -n "$user_rec1" ] ||
17639 error "mds$i: User ${cl_user1[mds$i]} not registered"
17640 __changelog_clear mds$i ${cl_user1[mds$i]} +2
17641 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17642 [ -n "$user_rec2" ] ||
17643 error "mds$i: User ${cl_user1[mds$i]} not registered"
17644 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
17645 "$user_rec1 + 2 == $user_rec2"
17646 [ $((user_rec1 + 2)) == $user_rec2 ] ||
17647 error "mds$i: user ${cl_user1[mds$i]} index expected " \
17648 "$user_rec1 + 2, but is $user_rec2"
17649 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
17650 [ -n "$user_rec2" ] ||
17651 error "mds$i: User ${cl_user2[mds$i]} not registered"
17652 [ $user_rec1 == $user_rec2 ] ||
17653 error "mds$i: user ${cl_user2[mds$i]} index expected " \
17654 "$user_rec1, but is $user_rec2"
17657 # force cl_user2 to be idle (2nd part) and to reach
17658 # changelog_max_idle_time
17661 # force each GC-thread start and block then
17662 # one per MDT/MDD, set fail_val accordingly
17663 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
17664 do_nodes $mdts $LCTL set_param fail_loc=0x1316
17666 # generate more changelogs to trigger fail_loc
17667 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
17668 error "create $DIR/$tdir/${tfile}bis failed"
17670 # stop MDT to stop GC-thread, should be done in back-ground as it will
17671 # block waiting for the thread to be released and exit
17672 declare -A stop_pids
17673 for i in $(seq $MDSCOUNT); do
17675 stop_pids[mds$i]=$!
17678 for i in $(mdts_nodes); do
17681 local facets=$(facets_up_on_host $i)
17683 for facet in ${facets//,/ }; do
17684 if [[ $facet == mds* ]]; then
17688 # ensure each MDS's gc threads are still present and all in "R"
17689 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
17690 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
17691 error "$i: expected $nb GC-thread"
17693 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
17695 error "$i: GC-thread not found in R-state"
17696 # check umounts of each MDT on MDS have reached kthread_stop()
17697 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
17698 error "$i: expected $nb umount"
17700 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
17701 error "$i: umount not found in D-state"
17704 # release all GC-threads
17705 do_nodes $mdts $LCTL set_param fail_loc=0
17707 # wait for MDT stop to complete
17708 for i in $(seq $MDSCOUNT); do
17709 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
17713 # may try to check if any orphan changelog records are present
17714 # via ldiskfs/zfs and llog_reader...
17716 # re-start/mount MDTs
17717 for i in $(seq $MDSCOUNT); do
17718 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
17719 error "Fail to start mds$i"
17723 for i in $(seq $MDSCOUNT); do
17724 # check cl_user1 still registered
17725 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
17726 error "mds$i: User ${cl_user1[mds$i]} not registered"
17727 # check cl_user2 unregistered
17728 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
17729 error "mds$i: User ${cl_user2[mds$i]} still registered"
17731 # check changelogs are present and starting at $user_rec1 + 1
17732 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17733 [ -n "$user_rec1" ] ||
17734 error "mds$i: User ${cl_user1[mds$i]} not registered"
17735 first_rec=$($LFS changelog $(facet_svc mds$i) |
17736 awk '{ print $1; exit; }')
17738 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
17739 [ $((user_rec1 + 1)) == $first_rec ] ||
17740 error "mds$i: first index should be $user_rec1 + 1, " \
17741 "but is $first_rec"
17744 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
17749 local mdts=$(comma_list $(mdts_nodes))
17751 changelog_register || error "first changelog_register failed"
17753 # generate some changelog records to accumulate on each MDT
17754 # use all_char because created files should be evenly distributed
17755 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17756 error "test_mkdir $tdir failed"
17757 for ((i = 0; i < MDSCOUNT; i++)); do
17758 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17759 error "create $DIR/$tdir/d$i.1 failed"
17762 # check changelogs have been generated
17763 local nbcl=$(changelog_dump | wc -l)
17764 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17766 # simulate race between register and unregister
17767 # XXX as fail_loc is set per-MDS, with DNE configs the race
17768 # simulation will only occur for one MDT per MDS and for the
17769 # others the normal race scenario will take place
17770 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
17771 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
17772 do_nodes $mdts $LCTL set_param fail_val=1
17774 # unregister 1st user
17775 changelog_deregister &
17777 # wait some time for deregister work to reach race rdv
17779 # register 2nd user
17780 changelog_register || error "2nd user register failed"
17782 wait $pid1 || error "1st user deregister failed"
17786 declare -A LAST_REC
17787 for i in $(seq $MDSCOUNT); do
17788 if changelog_users mds$i | grep "^cl"; then
17789 # make sure new records are added with one user present
17790 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
17791 awk '/^current.index:/ { print $NF }')
17793 error "mds$i has no user registered"
17797 # generate more changelog records to accumulate on each MDT
17798 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
17799 error "create $DIR/$tdir/${tfile}bis failed"
17801 for i in $(seq $MDSCOUNT); do
17802 last_rec=$(changelog_users $SINGLEMDS |
17803 awk '/^current.index:/ { print $NF }')
17804 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
17805 [ $last_rec != ${LAST_REC[mds$i]} ] ||
17806 error "changelogs are off on mds$i"
17809 run_test 160i "changelog user register/unregister race"
17812 remote_mds_nodsh && skip "remote MDS with nodsh"
17813 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
17814 skip "Need MDS version at least 2.12.56"
17816 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
17817 stack_trap "umount $MOUNT2" EXIT
17819 changelog_register || error "first changelog_register failed"
17820 stack_trap "changelog_deregister" EXIT
17822 # generate some changelog
17823 # use all_char because created files should be evenly distributed
17824 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17825 error "mkdir $tdir failed"
17826 for ((i = 0; i < MDSCOUNT; i++)); do
17827 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17828 error "create $DIR/$tdir/d$i.1 failed"
17831 # open the changelog device
17832 exec 3>/dev/changelog-$FSNAME-MDT0000
17833 stack_trap "exec 3>&-" EXIT
17834 exec 4</dev/changelog-$FSNAME-MDT0000
17835 stack_trap "exec 4<&-" EXIT
17837 # umount the first lustre mount
17839 stack_trap "mount_client $MOUNT" EXIT
17841 # read changelog, which may or may not fail, but should not crash
17845 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17846 changelog_users $SINGLEMDS | grep -q $cl_user ||
17847 error "User $cl_user not found in changelog_users"
17849 printf 'clear:'$cl_user':0' >&3
17851 run_test 160j "client can be umounted while its chanangelog is being used"
17854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17855 remote_mds_nodsh && skip "remote MDS with nodsh"
17857 mkdir -p $DIR/$tdir/1/1
17859 changelog_register || error "changelog_register failed"
17860 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17862 changelog_users $SINGLEMDS | grep -q $cl_user ||
17863 error "User '$cl_user' not found in changelog_users"
17864 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
17865 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
17866 rmdir $DIR/$tdir/1/1 & sleep 1
17868 touch $DIR/$tdir/2/2
17869 rm -rf $DIR/$tdir/2
17874 changelog_dump | grep rmdir || error "rmdir not recorded"
17876 run_test 160k "Verify that changelog records are not lost"
17878 # Verifies that a file passed as a parameter has recently had an operation
17879 # performed on it that has generated an MTIME changelog which contains the
17880 # correct parent FID. As files might reside on a different MDT from the
17881 # parent directory in DNE configurations, the FIDs are translated to paths
17882 # before being compared, which should be identical
17883 compare_mtime_changelog() {
17891 mdtidx=$($LFS getstripe --mdt-index $file)
17892 mdtidx=$(printf "%04x" $mdtidx)
17894 # Obtain the parent FID from the MTIME changelog
17895 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
17896 [ -z "$mtime" ] && error "MTIME changelog not recorded"
17898 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
17899 [ -z "$cl_fid" ] && error "parent FID not present"
17901 # Verify that the path for the parent FID is the same as the path for
17902 # the test directory
17903 pdir=$($LFS fid2path $MOUNT "$cl_fid")
17907 [[ "${pdir%/}" == "$dir" ]] ||
17908 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
17912 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17914 remote_mds_nodsh && skip "remote MDS with nodsh"
17915 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
17916 skip "Need MDS version at least 2.13.55"
17920 changelog_register || error "changelog_register failed"
17921 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17923 changelog_users $SINGLEMDS | grep -q $cl_user ||
17924 error "User '$cl_user' not found in changelog_users"
17926 # Clear some types so that MTIME changelogs are generated
17927 changelog_chmask "-CREAT"
17928 changelog_chmask "-CLOSE"
17930 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
17932 # Test CL_MTIME during setattr
17933 touch $DIR/$tdir/$tfile
17934 compare_mtime_changelog $DIR/$tdir/$tfile
17936 # Test CL_MTIME during close
17937 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
17938 compare_mtime_changelog $DIR/$tdir/${tfile}_2
17940 run_test 160l "Verify that MTIME changelog records contain the parent FID"
17943 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17944 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17945 skip "Need MDS version at least 2.14.51"
17952 changelog_register || error "first changelog_register failed"
17953 changelog_register || error "second changelog_register failed"
17955 cl_users=(${CL_USERS[mds1]})
17956 cl_user1="${cl_users[0]}"
17957 cl_user2="${cl_users[1]}"
17958 # generate some changelog records to accumulate on MDT0
17959 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17960 createmany -m $DIR/$tdir/$tfile 50 ||
17961 error "create $DIR/$tdir/$tfile failed"
17962 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
17965 # check changelogs have been generated
17966 local nbcl=$(changelog_dump | wc -l)
17967 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17969 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
17970 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
17972 __changelog_clear mds1 $cl_user1 +10
17973 __changelog_clear mds1 $cl_user2 0 &
17976 __changelog_clear mds1 $cl_user1 0 ||
17977 error "fail to cancel record for $cl_user1"
17979 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
17981 run_test 160m "Changelog clear race"
17984 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17985 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17986 skip "Need MDS version at least 2.14.51"
17995 changelog_register || error "first changelog_register failed"
17997 cl_users=(${CL_USERS[mds1]})
17998 cl_user1="${cl_users[0]}"
18000 # generate some changelog records to accumulate on MDT0
18001 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
18002 first_rec=$(changelog_users $SINGLEMDS |
18003 awk '/^current.index:/ { print $NF }')
18004 while (( last_rec < (( first_rec + 65000)) )); do
18005 createmany -m $DIR/$tdir/$tfile 10000 ||
18006 error "create $DIR/$tdir/$tfile failed"
18008 for i in $(seq 0 10000); do
18009 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
18013 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
18014 error "unlinkmany failed unlink"
18015 last_rec=$(changelog_users $SINGLEMDS |
18016 awk '/^current.index:/ { print $NF }')
18017 echo last record $last_rec
18018 (( last_rec == 0 )) && error "no changelog found"
18021 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
18022 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
18024 __changelog_clear mds1 $cl_user1 0 &
18027 __changelog_clear mds1 $cl_user1 0 ||
18028 error "fail to cancel record for $cl_user1"
18030 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
18032 run_test 160n "Changelog destroy race"
18035 local mdt="$(facet_svc $SINGLEMDS)"
18037 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
18038 remote_mds_nodsh && skip "remote MDS with nodsh"
18039 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
18040 skip "Need MDS version at least 2.14.52"
18042 changelog_register --user test_160o -m unlnk+close+open ||
18043 error "changelog_register failed"
18045 do_facet $SINGLEMDS $LCTL --device $mdt \
18046 changelog_register -u "Tt3_-#" &&
18047 error "bad symbols in name should fail"
18049 do_facet $SINGLEMDS $LCTL --device $mdt \
18050 changelog_register -u test_160o &&
18051 error "the same name registration should fail"
18053 do_facet $SINGLEMDS $LCTL --device $mdt \
18054 changelog_register -u test_160toolongname &&
18055 error "too long name registration should fail"
18057 changelog_chmask "MARK+HSM"
18058 lctl get_param mdd.*.changelog*mask
18059 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
18060 changelog_users $SINGLEMDS | grep -q $cl_user ||
18061 error "User $cl_user not found in changelog_users"
18063 echo $cl_user | grep -q test_160o ||
18064 error "User $cl_user has no specific name 'test160o'"
18067 changelog_clear 0 || error "changelog_clear failed"
18068 # generate some changelog records to accumulate on MDT0
18069 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
18070 touch $DIR/$tdir/$tfile # open 1
18072 OPENS=$(changelog_dump | grep -c "OPEN")
18073 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
18075 # must be no MKDIR it wasn't set as user mask
18076 MKDIR=$(changelog_dump | grep -c "MKDIR")
18077 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
18079 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
18080 mdd.$mdt.changelog_current_mask -n)
18081 # register maskless user
18082 changelog_register || error "changelog_register failed"
18083 # effective mask should be not changed because it is not minimal
18084 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18085 mdd.$mdt.changelog_current_mask -n)
18086 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
18087 # set server mask to minimal value
18088 changelog_chmask "MARK"
18089 # check effective mask again, should be treated as DEFMASK now
18090 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18091 mdd.$mdt.changelog_current_mask -n)
18092 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
18094 if (( $MDS1_VERSION >= $(version_code 2.15.52) )) ; then
18095 # set server mask back to some value
18096 changelog_chmask "CLOSE,UNLNK"
18097 # check effective mask again, should not remain as DEFMASK
18098 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18099 mdd.$mdt.changelog_current_mask -n)
18100 [[ $mask != *"HLINK"* ]] || error "mask is still DEFMASK"
18103 do_facet $SINGLEMDS $LCTL --device $mdt \
18104 changelog_deregister -u test_160o ||
18105 error "cannot deregister by name"
18107 run_test 160o "changelog user name and mask"
18110 remote_mds_nodsh && skip "remote MDS with nodsh" && return
18111 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
18112 skip "Need MDS version at least 2.14.51"
18113 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
18119 changelog_register || error "first changelog_register failed"
18121 cl_users=(${CL_USERS[mds1]})
18122 cl_user1="${cl_users[0]}"
18124 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
18125 createmany -m $DIR/$tdir/$tfile 50 ||
18126 error "create $DIR/$tdir/$tfile failed"
18127 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
18130 # check changelogs have been generated
18131 entry_count=$(changelog_dump | wc -l)
18132 ((entry_count != 0)) || error "no changelog entries found"
18134 # remove changelog_users and check that orphan entries are removed
18136 local dev=$(mdsdevname 1)
18137 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $dev"
18138 start mds1 $dev $MDS_MOUNT_OPTS || error "cannot start mds1"
18139 entry_count=$(changelog_dump | wc -l)
18140 ((entry_count == 0)) ||
18141 error "found $entry_count changelog entries, expected none"
18143 run_test 160p "Changelog orphan cleanup with no users"
18146 local mdt="$(facet_svc $SINGLEMDS)"
18149 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
18150 remote_mds_nodsh && skip "remote MDS with nodsh"
18151 [ $MDS1_VERSION -ge $(version_code 2.14.54) ] ||
18152 skip "Need MDS version at least 2.14.54"
18154 # set server mask to minimal value like server init does
18155 changelog_chmask "MARK"
18156 clu=$(do_facet $SINGLEMDS $LCTL --device $mdt changelog_register -n) ||
18157 error "changelog_register failed"
18158 # check effective mask again, should be treated as DEFMASK now
18159 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18160 mdd.$mdt.changelog_current_mask -n)
18161 do_facet $SINGLEMDS $LCTL --device $mdt changelog_deregister $clu ||
18162 error "changelog_deregister failed"
18163 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
18165 run_test 160q "changelog effective mask is DEFMASK if not set"
18168 remote_mds_nodsh && skip "remote MDS with nodsh"
18169 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
18170 skip "Need MDS version at least 2.14.55"
18172 local mdts=$(comma_list $(mdts_nodes))
18174 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
18175 do_nodes $mdts $LCTL set_param fail_loc=0x1314 \
18176 fail_val=$((24 * 3600 * 10))
18178 # Create a user which is 10 days old
18179 changelog_register || error "first changelog_register failed"
18181 declare -A cl_user1
18184 # generate some changelog records to accumulate on each MDT
18185 # use all_char because created files should be evenly distributed
18186 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
18187 error "test_mkdir $tdir failed"
18188 for ((i = 0; i < MDSCOUNT; i++)); do
18189 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
18190 error "create $DIR/$tdir/d$i.1 failed"
18193 # check changelogs have been generated
18194 local nbcl=$(changelog_dump | wc -l)
18195 (( nbcl > 0 )) || error "no changelogs found"
18197 # reduce the max_idle_indexes value to make sure we exceed it
18198 for param in "changelog_max_idle_indexes=2097446912" \
18199 "changelog_max_idle_time=2592000" \
18201 "changelog_min_gc_interval=2"; do
18202 local MDT0=$(facet_svc $SINGLEMDS)
18203 local var="${param%=*}"
18204 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
18206 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
18207 do_nodes $mdts $LCTL set_param mdd.*.$param ||
18208 error "unable to set mdd.*.$param"
18211 local start=$SECONDS
18212 for i in $(seq $MDSCOUNT); do
18213 cl_users=(${CL_USERS[mds$i]})
18214 cl_user1[mds$i]="${cl_users[0]}"
18216 [[ -n "${cl_user1[mds$i]}" ]] ||
18217 error "mds$i: no user registered"
18220 #define OBD_FAIL_MDS_CHANGELOG_IDX_PUMP 0x16d
18221 do_nodes $mdts $LCTL set_param fail_loc=0x16d fail_val=500000000
18223 # ensure we are past the previous changelog_min_gc_interval set above
18224 local sleep2=$((start + 2 - SECONDS))
18225 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
18227 # Generate one more changelog to trigger GC
18228 for ((i = 0; i < MDSCOUNT; i++)); do
18229 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
18230 error "create $DIR/$tdir/d$i.3 failed"
18233 # ensure gc thread is done
18234 for node in $(mdts_nodes); do
18235 wait_update $node "pgrep chlg_gc_thread" "" 20 ||
18236 error "$node: GC-thread not done"
18239 do_nodes $mdts $LCTL set_param fail_loc=0
18241 for (( i = 1; i <= MDSCOUNT; i++ )); do
18242 # check cl_user1 is purged
18243 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" &&
18244 error "mds$i: User ${cl_user1[mds$i]} is registered"
18248 run_test 160s "changelog garbage collect on idle records * time"
18251 remote_mds_nodsh && skip "remote MDS with nodsh"
18252 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
18253 skip "Need MDS version at least 2.15.50"
18255 local MDT0=$(facet_svc $SINGLEMDS)
18261 changelog_register --user user1 -m all ||
18262 error "user1 failed to register"
18264 mkdir_on_mdt0 $DIR/$tdir
18265 # create default overstripe to maximize changelog size
18266 $LFS setstripe -C 8 $DIR/$tdir || error "setstripe failed"
18267 createmany -o $DIR/$tdir/u1_ 2000 || error "createmany for user1 failed"
18268 llog_size1=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
18270 # user2 consumes less records so less space
18271 changelog_register --user user2 || error "user2 failed to register"
18272 createmany -o $DIR/$tdir/u2_ 500 || error "createmany for user2 failed"
18273 llog_size2=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
18275 # check changelogs have been generated
18276 local nbcl=$(changelog_dump | wc -l)
18277 (( nbcl > 0 )) || error "no changelogs found"
18279 # reduce the changelog_min_gc_interval to force check
18280 for param in "changelog_gc=1" "changelog_min_gc_interval=2"; do
18281 local var="${param%=*}"
18282 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
18284 stack_trap "do_facet mds1 $LCTL set_param mdd.$MDT0.$var=$old"
18285 do_facet mds1 $LCTL set_param mdd.$MDT0.$param ||
18286 error "unable to set mdd.*.$param"
18290 cl_users=(${CL_USERS[mds1]})
18291 cl_user1="${cl_users[0]}"
18292 cl_user2="${cl_users[1]}"
18294 [[ -n $cl_user1 ]] ||
18295 error "mds1: user #1 isn't registered"
18296 [[ -n $cl_user2 ]] ||
18297 error "mds1: user #2 isn't registered"
18299 # ensure we are past the previous changelog_min_gc_interval set above
18300 local sleep2=$((start + 2 - SECONDS))
18301 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
18303 #define OBD_FAIL_MDS_CHANGELOG_ENOSPC 0x018c
18304 do_facet mds1 $LCTL set_param fail_loc=0x018c \
18305 fail_val=$(((llog_size1 + llog_size2) / 2))
18307 # Generate more changelog to trigger GC
18308 createmany -o $DIR/$tdir/u3_ 4 ||
18309 error "create failed for more files"
18311 # ensure gc thread is done
18312 wait_update_facet mds1 "pgrep chlg_gc_thread" "" 20 ||
18313 error "mds1: GC-thread not done"
18315 do_facet mds1 $LCTL set_param fail_loc=0
18317 # check cl_user1 is purged
18318 changelog_users mds1 | grep -q "$cl_user1" &&
18319 error "User $cl_user1 is registered"
18320 # check cl_user2 is not purged
18321 changelog_users mds1 | grep -q "$cl_user2" ||
18322 error "User $cl_user2 is not registered"
18324 run_test 160t "changelog garbage collect on lack of space"
18327 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18329 test_mkdir -c1 $DIR/$tdir
18330 cp /etc/hosts $DIR/$tdir/$tfile
18331 test_mkdir -c1 $DIR/$tdir/foo1
18332 test_mkdir -c1 $DIR/$tdir/foo2
18333 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
18334 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
18335 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
18336 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
18337 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
18338 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
18339 $LFS fid2path $DIR $FID
18340 error "bad link ea"
18343 rm $DIR/$tdir/foo2/zachary
18345 rm $DIR/$tdir/foo2/thor
18347 rm $DIR/$tdir/$tfile
18349 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
18350 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
18351 { $LFS fid2path $DIR $FID; error "bad link rename"; }
18352 rm $DIR/$tdir/foo2/maggie
18355 local longname=$tfile.avg_len_is_thirty_two_
18356 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
18357 error_noexit 'failed to unlink many hardlinks'" EXIT
18358 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
18359 error "failed to hardlink many files"
18360 links=$($LFS fid2path $DIR $FID | wc -l)
18361 echo -n "${links}/1000 links in link EA"
18362 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
18364 run_test 161a "link ea sanity"
18367 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18368 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
18371 local remote_dir=$DIR/$tdir/remote_dir
18373 mkdir -p $DIR/$tdir
18374 $LFS mkdir -i $MDTIDX $remote_dir ||
18375 error "create remote directory failed"
18377 cp /etc/hosts $remote_dir/$tfile
18378 mkdir -p $remote_dir/foo1
18379 mkdir -p $remote_dir/foo2
18380 ln $remote_dir/$tfile $remote_dir/foo1/sofia
18381 ln $remote_dir/$tfile $remote_dir/foo2/zachary
18382 ln $remote_dir/$tfile $remote_dir/foo1/luna
18383 ln $remote_dir/$tfile $remote_dir/foo2/thor
18385 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
18387 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
18388 $LFS fid2path $DIR $FID
18389 error "bad link ea"
18392 rm $remote_dir/foo2/zachary
18394 rm $remote_dir/foo2/thor
18396 rm $remote_dir/$tfile
18398 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
18399 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
18400 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
18401 $LFS fid2path $DIR $FID
18402 error "bad link rename"
18404 rm $remote_dir/foo2/maggie
18407 local longname=filename_avg_len_is_thirty_two_
18408 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
18409 error "failed to hardlink many files"
18410 links=$($LFS fid2path $DIR $FID | wc -l)
18411 echo -n "${links}/1000 links in link EA"
18412 [[ ${links} -gt 60 ]] ||
18413 error "expected at least 60 links in link EA"
18414 unlinkmany $remote_dir/foo2/$longname 1000 ||
18415 error "failed to unlink many hardlinks"
18417 run_test 161b "link ea sanity under remote directory"
18420 remote_mds_nodsh && skip "remote MDS with nodsh"
18421 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18422 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
18423 skip "Need MDS version at least 2.1.5"
18425 # define CLF_RENAME_LAST 0x0001
18426 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
18427 changelog_register || error "changelog_register failed"
18430 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
18431 touch $DIR/$tdir/foo_161c
18432 touch $DIR/$tdir/bar_161c
18433 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
18434 changelog_dump | grep RENME | tail -n 5
18435 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
18436 changelog_clear 0 || error "changelog_clear failed"
18437 if [ x$flags != "x0x1" ]; then
18438 error "flag $flags is not 0x1"
18441 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
18442 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
18443 touch $DIR/$tdir/foo_161c
18444 touch $DIR/$tdir/bar_161c
18445 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
18446 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
18447 changelog_dump | grep RENME | tail -n 5
18448 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
18449 changelog_clear 0 || error "changelog_clear failed"
18450 if [ x$flags != "x0x0" ]; then
18451 error "flag $flags is not 0x0"
18453 echo "rename overwrite a target having nlink > 1," \
18454 "changelog record has flags of $flags"
18456 # rename doesn't overwrite a target (changelog flag 0x0)
18457 touch $DIR/$tdir/foo_161c
18458 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
18459 changelog_dump | grep RENME | tail -n 5
18460 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
18461 changelog_clear 0 || error "changelog_clear failed"
18462 if [ x$flags != "x0x0" ]; then
18463 error "flag $flags is not 0x0"
18465 echo "rename doesn't overwrite a target," \
18466 "changelog record has flags of $flags"
18468 # define CLF_UNLINK_LAST 0x0001
18469 # unlink a file having nlink = 1 (changelog flag 0x1)
18470 rm -f $DIR/$tdir/foo2_161c
18471 changelog_dump | grep UNLNK | tail -n 5
18472 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
18473 changelog_clear 0 || error "changelog_clear failed"
18474 if [ x$flags != "x0x1" ]; then
18475 error "flag $flags is not 0x1"
18477 echo "unlink a file having nlink = 1," \
18478 "changelog record has flags of $flags"
18480 # unlink a file having nlink > 1 (changelog flag 0x0)
18481 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
18482 rm -f $DIR/$tdir/foobar_161c
18483 changelog_dump | grep UNLNK | tail -n 5
18484 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
18485 changelog_clear 0 || error "changelog_clear failed"
18486 if [ x$flags != "x0x0" ]; then
18487 error "flag $flags is not 0x0"
18489 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
18491 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
18494 remote_mds_nodsh && skip "remote MDS with nodsh"
18495 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
18500 changelog_register || error "changelog_register failed"
18502 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
18503 # interfer with $MOUNT/.lustre/fid/ access
18505 [[ $? -eq 0 ]] || error "mkdir failed"
18507 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | CFS_FAIL_ONCE
18508 $LCTL set_param fail_loc=0x8000140c
18510 $LCTL set_param fail_val=5
18513 echo foofoo > $DIR/$tdir/$tfile &
18516 # wait for create to be delayed
18520 [[ $? -eq 0 ]] || error "create should be blocked"
18522 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
18523 stack_trap "rm -f $tempfile"
18524 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
18525 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
18526 # some delay may occur during ChangeLog publishing and file read just
18527 # above, that could allow file write to happen finally
18528 [[ -s $tempfile ]] && echo "file should be empty"
18530 $LCTL set_param fail_loc=0
18533 [[ $? -eq 0 ]] || error "create failed"
18535 run_test 161d "create with concurrent .lustre/fid access"
18538 local expected="$1"
18543 path=$($LFS fid2path "$@")
18546 if [ $rc -ne 0 ]; then
18547 error "path looked up of '$expected' failed: rc=$rc"
18548 elif [ "$path" != "$expected" ]; then
18549 error "path looked up '$path' instead of '$expected'"
18551 echo "FID '$fid' resolves to path '$path' as expected"
18555 test_162a() { # was test_162
18556 test_mkdir -p -c1 $DIR/$tdir/d2
18557 touch $DIR/$tdir/d2/$tfile
18558 touch $DIR/$tdir/d2/x1
18559 touch $DIR/$tdir/d2/x2
18560 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
18561 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
18563 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
18564 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
18567 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
18568 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
18569 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
18571 # softlink to wrong file
18572 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
18573 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
18574 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
18577 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
18578 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
18579 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
18580 # fid2path dir/fsname should both work
18581 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
18582 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
18584 # hardlink count: check that there are 2 links
18585 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
18586 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
18588 # hardlink indexing: remove the first link
18589 rm $DIR/$tdir/d2/p/q/r/hlink
18590 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
18592 run_test 162a "path lookup sanity"
18595 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18596 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18599 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18600 error "create striped dir failed"
18602 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
18603 tail -n 1 | awk '{print $2}')
18604 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
18606 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
18607 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
18610 for ((i=0;i<5;i++)); do
18611 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
18612 error "get fid for f$i failed"
18613 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
18615 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
18616 error "get fid for d$i failed"
18617 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
18622 run_test 162b "striped directory path lookup sanity"
18624 # LU-4239: Verify fid2path works with paths 100 or more directories deep
18626 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
18627 skip "Need MDS version at least 2.7.51"
18629 local lpath=$tdir.local
18630 local rpath=$tdir.remote
18632 test_mkdir $DIR/$lpath
18633 test_mkdir $DIR/$rpath
18635 for ((i = 0; i <= 101; i++)); do
18638 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
18639 error "get fid for local directory $DIR/$lpath failed"
18640 check_path "$DIR/$lpath" $MOUNT $FID --link 0
18643 test_mkdir $DIR/$rpath
18644 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
18645 error "get fid for remote directory $DIR/$rpath failed"
18646 check_path "$DIR/$rpath" $MOUNT $FID --link 0
18651 run_test 162c "fid2path works with paths 100 or more directories deep"
18653 oalr_event_count() {
18657 awk -v name="${FSNAME}-OST0000" \
18658 -v event="${event}" \
18659 '$1 == "TRACE" && $2 == event && $3 == name' \
18664 oalr_expect_event_count() {
18667 local expect="${3}"
18670 count=$(oalr_event_count "${event}" "${trace}")
18671 if ((count == expect)); then
18675 error_noexit "${event} event count was '${count}', expected ${expect}"
18681 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
18683 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
18687 sync # Flush previous IOs so we can count log entries.
18688 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
18689 stack_trap cleanup_165 EXIT
18693 local trace="/tmp/${tfile}.trace"
18697 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18698 skip "OFD access log unsupported"
18701 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18704 do_facet ost1 ofd_access_log_reader --list
18707 do_facet ost1 killall -TERM ofd_access_log_reader
18711 if ((rc != 0)); then
18712 error "ofd_access_log_reader exited with rc = '${rc}'"
18715 # Parse trace file for discovery events:
18716 oalr_expect_event_count alr_log_add "${trace}" 1
18717 oalr_expect_event_count alr_log_eof "${trace}" 1
18718 oalr_expect_event_count alr_log_free "${trace}" 1
18720 run_test 165a "ofd access log discovery"
18723 local trace="/tmp/${tfile}.trace"
18724 local file="${DIR}/${tfile}"
18733 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18734 skip "OFD access log unsupported"
18737 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18740 do_facet ost1 ofd_access_log_reader --list
18742 lfs setstripe -c 1 -i 0 "${file}"
18743 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18744 error "cannot create '${file}'"
18747 do_facet ost1 killall -TERM ofd_access_log_reader
18751 if ((rc != 0)); then
18752 error "ofd_access_log_reader exited with rc = '${rc}'"
18755 oalr_expect_event_count alr_log_entry "${trace}" 1
18757 pfid1=$($LFS path2fid "${file}")
18759 # 1 2 3 4 5 6 7 8 9 10
18760 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
18761 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
18763 echo "entry = '${entry[*]}'" >&2
18766 if [[ "${pfid1}" != "${pfid2}" ]]; then
18767 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
18771 if ((size != 1048576)); then
18772 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
18776 if [[ "${flags}" != "w" ]]; then
18777 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
18780 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18783 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
18784 error "cannot read '${file}'"
18787 do_facet ost1 killall -TERM ofd_access_log_reader
18791 if ((rc != 0)); then
18792 error "ofd_access_log_reader exited with rc = '${rc}'"
18795 oalr_expect_event_count alr_log_entry "${trace}" 1
18797 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
18798 echo "entry = '${entry[*]}'" >&2
18801 if [[ "${pfid1}" != "${pfid2}" ]]; then
18802 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
18806 if ((size != 524288)); then
18807 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
18811 if [[ "${flags}" != "r" ]]; then
18812 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
18815 run_test 165b "ofd access log entries are produced and consumed"
18818 local trace="/tmp/${tfile}.trace"
18819 local file="${DIR}/${tdir}/${tfile}"
18821 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18822 skip "OFD access log unsupported"
18824 test_mkdir "${DIR}/${tdir}"
18827 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18830 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
18832 # 4096 / 64 = 64. Create twice as many entries.
18833 for ((i = 0; i < 128; i++)); do
18834 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
18835 error "cannot create file"
18840 do_facet ost1 killall -TERM ofd_access_log_reader
18843 if ((rc != 0)); then
18844 error "ofd_access_log_reader exited with rc = '${rc}'"
18847 unlinkmany "${file}-%d" 128
18849 run_test 165c "full ofd access logs do not block IOs"
18851 oal_get_read_count() {
18854 # STATS lustre-OST0001 alr_read_count 1
18856 do_facet ost1 cat "${stats}" |
18857 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
18858 END { print count; }'
18861 oal_expect_read_count() {
18866 # Ask ofd_access_log_reader to write stats.
18867 do_facet ost1 killall -USR1 ofd_access_log_reader
18869 # Allow some time for things to happen.
18872 count=$(oal_get_read_count "${stats}")
18873 if ((count == expect)); then
18877 error_noexit "bad read count, got ${count}, expected ${expect}"
18878 do_facet ost1 cat "${stats}" >&2
18883 local stats="/tmp/${tfile}.stats"
18884 local file="${DIR}/${tdir}/${tfile}"
18885 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
18887 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18888 skip "OFD access log unsupported"
18890 test_mkdir "${DIR}/${tdir}"
18893 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
18896 lfs setstripe -c 1 -i 0 "${file}"
18898 do_facet ost1 lctl set_param "${param}=rw"
18899 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18900 error "cannot create '${file}'"
18901 oal_expect_read_count "${stats}" 1
18903 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18904 error "cannot read '${file}'"
18905 oal_expect_read_count "${stats}" 2
18907 do_facet ost1 lctl set_param "${param}=r"
18908 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18909 error "cannot create '${file}'"
18910 oal_expect_read_count "${stats}" 2
18912 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18913 error "cannot read '${file}'"
18914 oal_expect_read_count "${stats}" 3
18916 do_facet ost1 lctl set_param "${param}=w"
18917 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18918 error "cannot create '${file}'"
18919 oal_expect_read_count "${stats}" 4
18921 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18922 error "cannot read '${file}'"
18923 oal_expect_read_count "${stats}" 4
18925 do_facet ost1 lctl set_param "${param}=0"
18926 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18927 error "cannot create '${file}'"
18928 oal_expect_read_count "${stats}" 4
18930 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
18931 error "cannot read '${file}'"
18932 oal_expect_read_count "${stats}" 4
18934 do_facet ost1 killall -TERM ofd_access_log_reader
18937 if ((rc != 0)); then
18938 error "ofd_access_log_reader exited with rc = '${rc}'"
18941 run_test 165d "ofd_access_log mask works"
18944 local stats="/tmp/${tfile}.stats"
18945 local file0="${DIR}/${tdir}-0/${tfile}"
18946 local file1="${DIR}/${tdir}-1/${tfile}"
18948 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18949 skip "OFD access log unsupported"
18951 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
18953 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
18954 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
18956 lfs setstripe -c 1 -i 0 "${file0}"
18957 lfs setstripe -c 1 -i 0 "${file1}"
18960 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
18963 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
18964 error "cannot create '${file0}'"
18966 oal_expect_read_count "${stats}" 0
18968 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
18969 error "cannot create '${file1}'"
18971 oal_expect_read_count "${stats}" 1
18973 do_facet ost1 killall -TERM ofd_access_log_reader
18976 if ((rc != 0)); then
18977 error "ofd_access_log_reader exited with rc = '${rc}'"
18980 run_test 165e "ofd_access_log MDT index filter works"
18983 local trace="/tmp/${tfile}.trace"
18988 do_facet ost1 timeout 60 ofd_access_log_reader \
18989 --exit-on-close --debug=- --trace=- > "${trace}" &
18996 if ((rc != 0)); then
18997 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
19002 run_test 165f "ofd_access_log_reader --exit-on-close works"
19005 # do directio so as not to populate the page cache
19006 log "creating a 10 Mb file"
19007 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
19008 error "multiop failed while creating a file"
19009 log "starting reads"
19010 dd if=$DIR/$tfile of=/dev/null bs=4096 &
19011 log "truncating the file"
19012 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
19013 error "multiop failed while truncating the file"
19015 kill %+ || true # reads might have finished
19016 echo "wait until dd is finished"
19018 log "removing the temporary file"
19019 rm -rf $DIR/$tfile || error "tmp file removal failed"
19021 run_test 169 "parallel read and truncate should not deadlock"
19024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19026 $LCTL clear # bug 18514
19027 $LCTL debug_daemon start $TMP/${tfile}_log_good
19029 $LCTL debug_daemon stop
19030 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
19031 error "sed failed to read log_good"
19033 $LCTL debug_daemon start $TMP/${tfile}_log_good
19035 $LCTL debug_daemon stop
19037 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
19038 error "lctl df log_bad failed"
19040 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
19041 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
19043 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
19044 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
19046 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
19047 error "bad_line good_line1 good_line2 are empty"
19049 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
19050 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
19051 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
19053 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
19054 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
19055 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
19057 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
19058 error "bad_line_new good_line_new are empty"
19060 local expected_good=$((good_line1 + good_line2*2))
19062 rm -f $TMP/${tfile}*
19063 # LU-231, short malformed line may not be counted into bad lines
19064 if [ $bad_line -ne $bad_line_new ] &&
19065 [ $bad_line -ne $((bad_line_new - 1)) ]; then
19066 error "expected $bad_line bad lines, but got $bad_line_new"
19070 if [ $expected_good -ne $good_line_new ]; then
19071 error "expected $expected_good good lines, but got $good_line_new"
19076 run_test 170 "test lctl df to handle corrupted log ====================="
19078 test_171() { # bug20592
19079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19081 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
19082 $LCTL set_param fail_loc=0x50e
19083 $LCTL set_param fail_val=3000
19084 multiop_bg_pause $DIR/$tfile O_s || true
19086 kill -USR1 $MULTIPID
19090 if dmesg | grep "recursive fault"; then
19091 error "caught a recursive fault"
19093 $LCTL set_param fail_loc=0
19096 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
19100 #define OBD_FAIL_OBD_CLEANUP 0x60e
19101 $LCTL set_param fail_loc=0x60e
19102 umount $MOUNT || error "umount $MOUNT failed"
19103 stack_trap "mount_client $MOUNT"
19105 (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )) ||
19106 error "no client OBDs are remained"
19108 $LCTL dl | while read devno state type name foo; do
19111 $LCTL --device $name cleanup
19112 $LCTL --device $name detach
19115 # skip server devices
19120 if (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )); then
19121 $LCTL dl | egrep " osc | lov | lmv | mdc "
19122 error "some client OBDs are still remained"
19126 run_test 172 "manual device removal with lctl cleanup/detach ======"
19128 # it would be good to share it with obdfilter-survey/iokit-libecho code
19129 setup_obdecho_osc () {
19132 local obdfilter_name=$2
19133 echo "Creating new osc for $obdfilter_name on $ost_nid"
19134 # make sure we can find loopback nid
19135 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
19137 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
19138 ${obdfilter_name}_osc_UUID || rc=2; }
19139 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
19140 ${obdfilter_name}_UUID $ost_nid || rc=3; }
19144 cleanup_obdecho_osc () {
19145 local obdfilter_name=$1
19146 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
19147 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
19154 local pages=${3:-64}
19159 local obd_size=$(get_obd_size $node $OBD)
19160 local page_size=$(get_page_size $node)
19161 if [[ -n "$obd_size" ]]; then
19162 local new_count=$((obd_size / (pages * page_size / 1024)))
19163 [[ $new_count -ge $count ]] || count=$new_count
19166 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
19167 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
19169 if [ $rc -eq 0 ]; then
19170 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
19171 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
19173 echo "New object id is $id"
19174 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
19176 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
19177 "test_brw $count w v $pages $id" || rc=4; }
19178 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
19180 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
19181 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
19182 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
19183 { do_facet $node "$LCTL --device ec detach" || rc=6; }
19184 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
19189 skip "obdecho on osc is no longer supported"
19191 run_test 180a "test obdecho on osc"
19194 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19195 remote_ost_nodsh && skip "remote OST with nodsh"
19197 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
19198 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
19199 error "failed to load module obdecho"
19201 local target=$(do_facet ost1 $LCTL dl |
19202 awk '/obdfilter/ { print $4; exit; }')
19204 if [ -n "$target" ]; then
19205 obdecho_test $target ost1 || error "obdecho_test failed with $?"
19207 do_facet ost1 $LCTL dl
19208 error "there is no obdfilter target on ost1"
19211 run_test 180b "test obdecho directly on obdfilter"
19213 test_180c() { # LU-2598
19214 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19215 remote_ost_nodsh && skip "remote OST with nodsh"
19216 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
19217 skip "Need MDS version at least 2.4.0"
19219 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
19220 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
19221 error "failed to load module obdecho"
19223 local target=$(do_facet ost1 $LCTL dl |
19224 awk '/obdfilter/ { print $4; exit; }')
19226 if [ -n "$target" ]; then
19227 local pages=16384 # 64MB bulk I/O RPC size
19229 obdecho_test "$target" ost1 "$pages" ||
19230 error "obdecho_test with pages=$pages failed with $?"
19232 do_facet ost1 $LCTL dl
19233 error "there is no obdfilter target on ost1"
19236 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
19238 test_181() { # bug 22177
19239 test_mkdir $DIR/$tdir
19240 # create enough files to index the directory
19241 createmany -o $DIR/$tdir/foobar 4000
19242 # print attributes for debug purpose
19245 multiop_bg_pause $DIR/$tdir D_Sc || return 1
19247 # remove the files & current working dir
19248 unlinkmany $DIR/$tdir/foobar 4000
19250 kill -USR1 $MULTIPID
19252 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
19255 run_test 181 "Test open-unlinked dir ========================"
19261 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
19263 $LCTL set_param mdc.*.rpc_stats=clear
19265 for (( i = 0; i < $tcount; i++ )) ; do
19266 mkdir $DIR/$tdir/$i
19269 for (( i = 0; i < $tcount; i++ )) ; do
19270 createmany -o $DIR/$tdir/$i/f- $fcount &
19274 for (( i = 0; i < $tcount; i++ )) ; do
19275 unlinkmany $DIR/$tdir/$i/f- $fcount &
19279 $LCTL get_param mdc.*.rpc_stats
19283 run_test 182a "Test parallel modify metadata operations from mdc"
19286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
19287 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19294 do_facet mds1 $LCTL list_param \
19295 osp.$FSNAME-MDT*-osp-MDT*.rpc_stats ||
19296 skip "MDS lacks parallel RPC handling"
19298 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
19300 rpc_count=$(do_facet mds1 $LCTL get_param -n \
19301 osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight)
19304 createmany -i 0 -d $DIR/$tdir/t- $tcount
19306 for (( i = 0; i < $tcount; i++ )) ; do
19307 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
19311 delta=$((etime - stime))
19312 echo "Time for file creation $delta sec for $rpc_count parallel RPCs"
19315 for (( i = 0; i < $tcount; i++ )) ; do
19316 unlinkmany -d $DIR/$tdir/$i/d- $dcount &
19320 delta=$((etime - stime))
19321 echo "Time for file removal $delta sec for $rpc_count parallel RPCs"
19325 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
19327 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=1
19330 createmany -i 0 -d $DIR/$tdir/t- $tcount
19332 for (( i = 0; i < $tcount; i++ )) ; do
19333 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
19337 delta=$((etime - stime))
19338 echo "Time for file creation $delta sec for 1 RPC sent at a time"
19341 for (( i = 0; i < $tcount; i++ )) ; do
19342 unlinkmany -d $DIR/$tdir/t-$i/d- $dcount &
19346 delta=$((etime - stime))
19347 echo "Time for file removal $delta sec for 1 RPC sent at a time"
19349 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=$rpc_count
19351 run_test 182b "Test parallel modify metadata operations from osp"
19353 test_183() { # LU-2275
19354 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19355 remote_mds_nodsh && skip "remote MDS with nodsh"
19356 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
19357 skip "Need MDS version at least 2.3.56"
19359 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
19360 echo aaa > $DIR/$tdir/$tfile
19362 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
19363 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
19365 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
19366 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
19368 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
19370 # Flush negative dentry cache
19371 touch $DIR/$tdir/$tfile
19373 # We are not checking for any leaked references here, they'll
19374 # become evident next time we do cleanup with module unload.
19377 run_test 183 "No crash or request leak in case of strange dispositions ========"
19379 # test suite 184 is for LU-2016, LU-2017
19381 check_swap_layouts_support
19383 dir0=$DIR/$tdir/$testnum
19384 test_mkdir -p -c1 $dir0
19389 $LFS setstripe -c1 $file1
19391 $LFS setstripe -c2 $file2
19393 gen1=$($LFS getstripe -g $file1)
19394 gen2=$($LFS getstripe -g $file2)
19396 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
19397 gen=$($LFS getstripe -g $file1)
19398 [[ $gen1 != $gen ]] ||
19399 error "Layout generation on $file1 does not change"
19400 gen=$($LFS getstripe -g $file2)
19401 [[ $gen2 != $gen ]] ||
19402 error "Layout generation on $file2 does not change"
19404 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
19405 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
19407 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
19409 run_test 184a "Basic layout swap"
19412 check_swap_layouts_support
19414 dir0=$DIR/$tdir/$testnum
19415 mkdir -p $dir0 || error "creating dir $dir0"
19422 $LFS setstripe -c1 $file1
19423 $LFS setstripe -c2 $file2
19424 $LFS setstripe -c1 $file3
19425 chown $RUNAS_ID $file3
19426 gen1=$($LFS getstripe -g $file1)
19427 gen2=$($LFS getstripe -g $file2)
19429 $LFS swap_layouts $dir1 $dir2 &&
19430 error "swap of directories layouts should fail"
19431 $LFS swap_layouts $dir1 $file1 &&
19432 error "swap of directory and file layouts should fail"
19433 $RUNAS $LFS swap_layouts $file1 $file2 &&
19434 error "swap of file we cannot write should fail"
19435 $LFS swap_layouts $file1 $file3 &&
19436 error "swap of file with different owner should fail"
19437 /bin/true # to clear error code
19439 run_test 184b "Forbidden layout swap (will generate errors)"
19442 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
19443 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
19444 check_swap_layouts_support
19445 check_swap_layout_no_dom $DIR
19447 local dir0=$DIR/$tdir/$testnum
19448 mkdir -p $dir0 || error "creating dir $dir0"
19450 local ref1=$dir0/ref1
19451 local ref2=$dir0/ref2
19452 local file1=$dir0/file1
19453 local file2=$dir0/file2
19454 # create a file large enough for the concurrent test
19455 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
19456 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
19457 echo "ref file size: ref1($(stat -c %s $ref1))," \
19458 "ref2($(stat -c %s $ref2))"
19461 dd if=$ref1 of=$file1 bs=16k &
19464 # Make sure dd starts to copy file, but wait at most 5 seconds
19466 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
19468 $LFS swap_layouts $file1 $file2
19471 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
19472 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
19474 # how many bytes copied before swapping layout
19475 local copied=$(stat -c %s $file2)
19476 local remaining=$(stat -c %s $ref1)
19477 remaining=$((remaining - copied))
19478 echo "Copied $copied bytes before swapping layout..."
19480 cmp -n $copied $file1 $ref2 | grep differ &&
19481 error "Content mismatch [0, $copied) of ref2 and file1"
19482 cmp -n $copied $file2 $ref1 ||
19483 error "Content mismatch [0, $copied) of ref1 and file2"
19484 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
19485 error "Content mismatch [$copied, EOF) of ref1 and file1"
19488 rm -f $ref1 $ref2 $file1 $file2
19490 run_test 184c "Concurrent write and layout swap"
19493 check_swap_layouts_support
19494 check_swap_layout_no_dom $DIR
19495 [ -z "$(which getfattr 2>/dev/null)" ] &&
19496 skip_env "no getfattr command"
19498 local file1=$DIR/$tdir/$tfile-1
19499 local file2=$DIR/$tdir/$tfile-2
19500 local file3=$DIR/$tdir/$tfile-3
19504 mkdir -p $DIR/$tdir
19505 touch $file1 || error "create $file1 failed"
19506 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
19507 error "create $file2 failed"
19508 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
19509 error "create $file3 failed"
19510 lovea1=$(get_layout_param $file1)
19512 $LFS swap_layouts $file2 $file3 ||
19513 error "swap $file2 $file3 layouts failed"
19514 $LFS swap_layouts $file1 $file2 ||
19515 error "swap $file1 $file2 layouts failed"
19517 lovea2=$(get_layout_param $file2)
19520 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
19522 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
19523 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
19525 run_test 184d "allow stripeless layouts swap"
19528 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
19529 skip "Need MDS version at least 2.6.94"
19530 check_swap_layouts_support
19531 check_swap_layout_no_dom $DIR
19532 [ -z "$(which getfattr 2>/dev/null)" ] &&
19533 skip_env "no getfattr command"
19535 local file1=$DIR/$tdir/$tfile-1
19536 local file2=$DIR/$tdir/$tfile-2
19537 local file3=$DIR/$tdir/$tfile-3
19540 mkdir -p $DIR/$tdir
19541 touch $file1 || error "create $file1 failed"
19542 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
19543 error "create $file2 failed"
19544 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
19545 error "create $file3 failed"
19547 $LFS swap_layouts $file1 $file2 ||
19548 error "swap $file1 $file2 layouts failed"
19550 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
19551 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
19553 echo 123 > $file1 || error "Should be able to write into $file1"
19555 $LFS swap_layouts $file1 $file3 ||
19556 error "swap $file1 $file3 layouts failed"
19558 echo 123 > $file1 || error "Should be able to write into $file1"
19560 rm -rf $file1 $file2 $file3
19562 run_test 184e "Recreate layout after stripeless layout swaps"
19565 # Create a file with name longer than sizeof(struct stat) ==
19566 # 144 to see if we can get chars from the file name to appear
19567 # in the returned striping. Note that 'f' == 0x66.
19568 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
19570 mkdir -p $DIR/$tdir
19571 mcreate $DIR/$tdir/$file
19572 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
19573 error "IOC_MDC_GETFILEINFO returned garbage striping"
19576 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
19578 test_185() { # LU-2441
19579 # LU-3553 - no volatile file support in old servers
19580 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
19581 skip "Need MDS version at least 2.3.60"
19583 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
19584 touch $DIR/$tdir/spoo
19585 local mtime1=$(stat -c "%Y" $DIR/$tdir)
19586 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
19587 error "cannot create/write a volatile file"
19588 [ "$FILESET" == "" ] &&
19589 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
19590 error "FID is still valid after close"
19592 multiop_bg_pause $DIR/$tdir Vw4096_c
19599 # assume that the next FID for this client is sequential, since stdout
19600 # is unfortunately eaten by multiop_bg_pause
19601 local n=$((${fidv[1]} + 1))
19602 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
19603 if [ "$FILESET" == "" ]; then
19604 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
19605 error "FID is missing before close"
19607 kill -USR1 $multi_pid
19608 # 1 second delay, so if mtime change we will see it
19610 local mtime2=$(stat -c "%Y" $DIR/$tdir)
19611 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
19613 run_test 185 "Volatile file support"
19615 function create_check_volatile() {
19619 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
19622 local FID=$(cat /tmp/${tfile}.fid)
19623 [ "$FID" == "" ] && error "can't get FID for volatile"
19624 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
19625 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
19626 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
19630 cancel_lru_locks mdc # flush opencache
19631 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
19636 # LU-12516 - volatile creation via .lustre
19637 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
19638 skip "Need MDS version at least 2.3.55"
19640 create_check_volatile 0
19641 [ $MDSCOUNT -lt 2 ] && return 0
19644 create_check_volatile 1
19648 run_test 185a "Volatile file creation in .lustre/fid/"
19651 remote_mds_nodsh && skip "remote MDS with nodsh"
19652 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
19653 skip "Need MDS version at least 2.3.0"
19655 local dir0=$DIR/$tdir/$testnum
19656 mkdir -p $dir0 || error "creating dir $dir0"
19658 local file=$dir0/file1
19659 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
19660 stack_trap "rm -f $file"
19661 local dv1=$($LFS data_version $file)
19662 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
19663 local dv2=$($LFS data_version $file)
19664 [[ $dv1 != $dv2 ]] ||
19665 error "data version did not change on write $dv1 == $dv2"
19667 run_test 187a "Test data version change"
19670 remote_mds_nodsh && skip "remote MDS with nodsh"
19671 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
19672 skip "Need MDS version at least 2.3.0"
19674 local dir0=$DIR/$tdir/$testnum
19675 mkdir -p $dir0 || error "creating dir $dir0"
19677 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
19678 [[ ${DV[0]} != ${DV[1]} ]] ||
19679 error "data version did not change on write"\
19680 " ${DV[0]} == ${DV[1]}"
19685 run_test 187b "Test data version change on volatile file"
19688 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19689 remote_mgs_nodsh && skip "remote MGS with nodsh"
19690 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
19692 local POOL=${POOL:-cea1}
19693 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
19694 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
19697 local last_ost=$(($OSTCOUNT - 1))
19699 local ost_list=$(seq $first_ost $ost_step $last_ost)
19700 local ost_range="$first_ost $last_ost $ost_step"
19701 local test_path=$POOL_ROOT/$POOL_DIR_NAME
19702 local file_dir=$POOL_ROOT/file_tst
19703 local subdir=$test_path/subdir
19707 # former test_200a test_200b
19708 pool_add $POOL || { rc=$? ; break; }
19709 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
19710 # former test_200c test_200d
19711 mkdir -p $test_path
19712 pool_set_dir $POOL $test_path || { rc=$? ; break; }
19713 pool_check_dir $POOL $test_path || { rc=$? ; break; }
19715 pool_check_dir $POOL $subdir || { rc=$? ; break; }
19716 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
19717 || { rc=$? ; break; }
19718 # former test_200e test_200f
19719 local files=$((OSTCOUNT*3))
19720 pool_alloc_files $POOL $test_path $files "$ost_list" \
19721 || { rc=$? ; break; }
19722 pool_create_files $POOL $file_dir $files "$ost_list" \
19723 || { rc=$? ; break; }
19724 # former test_200g test_200h
19725 pool_lfs_df $POOL || { rc=$? ; break; }
19726 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
19728 # former test_201a test_201b test_201c
19729 pool_remove_first_target $POOL || { rc=$? ; break; }
19731 local f=$test_path/$tfile
19732 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
19733 pool_remove $POOL $f || { rc=$? ; break; }
19741 run_test 200 "OST pools"
19743 # usage: default_attr <count | size | offset>
19745 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
19748 # usage: check_default_stripe_attr
19749 check_default_stripe_attr() {
19750 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
19753 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
19755 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
19759 error "unknown getstripe attr '$1'"
19762 [ $ACTUAL == $EXPECTED ] ||
19763 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
19767 test_mkdir $DIR/$tdir
19768 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
19770 check_default_stripe_attr --stripe-count
19771 check_default_stripe_attr --stripe-size
19772 check_default_stripe_attr --stripe-index
19774 run_test 204a "Print default stripe attributes"
19777 test_mkdir $DIR/$tdir
19778 $LFS setstripe --stripe-count 1 $DIR/$tdir
19780 check_default_stripe_attr --stripe-size
19781 check_default_stripe_attr --stripe-index
19783 run_test 204b "Print default stripe size and offset"
19786 test_mkdir $DIR/$tdir
19787 $LFS setstripe --stripe-size 65536 $DIR/$tdir
19789 check_default_stripe_attr --stripe-count
19790 check_default_stripe_attr --stripe-index
19792 run_test 204c "Print default stripe count and offset"
19795 test_mkdir $DIR/$tdir
19796 $LFS setstripe --stripe-index 0 $DIR/$tdir
19798 check_default_stripe_attr --stripe-count
19799 check_default_stripe_attr --stripe-size
19801 run_test 204d "Print default stripe count and size"
19804 test_mkdir $DIR/$tdir
19805 $LFS setstripe -d $DIR/$tdir
19807 # LU-16904 check if root is set as PFL layout
19808 local numcomp=$($LFS getstripe --component-count $MOUNT)
19810 if [[ $numcomp -gt 0 ]]; then
19811 check_default_stripe_attr --stripe-count
19813 check_default_stripe_attr --stripe-count --raw
19815 check_default_stripe_attr --stripe-size --raw
19816 check_default_stripe_attr --stripe-index --raw
19818 run_test 204e "Print raw stripe attributes"
19821 test_mkdir $DIR/$tdir
19822 $LFS setstripe --stripe-count 1 $DIR/$tdir
19824 check_default_stripe_attr --stripe-size --raw
19825 check_default_stripe_attr --stripe-index --raw
19827 run_test 204f "Print raw stripe size and offset"
19830 test_mkdir $DIR/$tdir
19831 $LFS setstripe --stripe-size 65536 $DIR/$tdir
19833 check_default_stripe_attr --stripe-count --raw
19834 check_default_stripe_attr --stripe-index --raw
19836 run_test 204g "Print raw stripe count and offset"
19839 test_mkdir $DIR/$tdir
19840 $LFS setstripe --stripe-index 0 $DIR/$tdir
19842 check_default_stripe_attr --stripe-count --raw
19843 check_default_stripe_attr --stripe-size --raw
19845 run_test 204h "Print raw stripe count and size"
19847 # Figure out which job scheduler is being used, if any,
19848 # or use a fake one
19849 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
19850 JOBENV=SLURM_JOB_ID
19851 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
19853 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
19855 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
19856 JOBENV=LOADL_STEP_ID
19857 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
19860 $LCTL list_param jobid_name > /dev/null 2>&1
19861 if [ $? -eq 0 ]; then
19867 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
19869 verify_jobstats() {
19874 # we don't really need to clear the stats for this test to work, since each
19875 # command has a unique jobid, but it makes debugging easier if needed.
19876 # for facet in $facets; do
19877 # local dev=$(convert_facet2label $facet)
19878 # # clear old jobstats
19879 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
19882 # use a new JobID for each test, or we might see an old one
19883 [ "$JOBENV" = "FAKE_JOBID" ] &&
19884 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
19886 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
19888 [ "$JOBENV" = "nodelocal" ] && {
19889 FAKE_JOBID=id.$testnum.%e.$RANDOM
19890 $LCTL set_param jobid_name=$FAKE_JOBID
19891 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
19894 log "Test: ${cmd[*]}"
19895 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
19897 if [ $JOBENV = "FAKE_JOBID" ]; then
19898 FAKE_JOBID=$JOBVAL ${cmd[*]}
19903 # all files are created on OST0000
19904 for facet in $facets; do
19905 local stats="*.$(convert_facet2label $facet).job_stats"
19907 # strip out libtool wrappers for in-tree executables
19908 if (( $(do_facet $facet lctl get_param $stats |
19909 sed -e 's/\.lt-/./' | grep -cw $JOBVAL) != 1 )); then
19910 do_facet $facet lctl get_param $stats
19911 error "No jobstats for $JOBVAL found on $facet::$stats"
19917 local new_jobenv=$1
19919 set_persistent_param_and_check client "jobid_var" \
19920 "$FSNAME.sys.jobid_var" $new_jobenv
19923 test_205a() { # Job stats
19924 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19925 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
19926 skip "Need MDS version with at least 2.7.1"
19927 remote_mgs_nodsh && skip "remote MGS with nodsh"
19928 remote_mds_nodsh && skip "remote MDS with nodsh"
19929 remote_ost_nodsh && skip "remote OST with nodsh"
19930 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
19931 skip "Server doesn't support jobstats"
19932 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
19934 local old_jobenv=$($LCTL get_param -n jobid_var)
19935 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
19936 stack_trap "jobstats_set $old_jobenv" EXIT
19940 local old_jobid_name=$($LCTL get_param jobid_name)
19941 stack_trap "$LCTL set_param $old_jobid_name" EXIT
19943 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
19944 mdt.*.job_cleanup_interval | head -n 1)
19945 local new_interval=5
19946 do_facet $SINGLEMDS \
19947 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
19948 stack_trap "do_facet $SINGLEMDS \
19949 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
19950 local start=$SECONDS
19954 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
19955 verify_jobstats "$cmd" "$SINGLEMDS"
19957 cmd="rmdir $DIR/$tdir"
19958 verify_jobstats "$cmd" "$SINGLEMDS"
19959 # mkdir on secondary MDT
19960 if [ $MDSCOUNT -gt 1 ]; then
19961 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
19962 verify_jobstats "$cmd" "mds2"
19965 cmd="mknod $DIR/$tfile c 1 3"
19966 verify_jobstats "$cmd" "$SINGLEMDS"
19968 cmd="rm -f $DIR/$tfile"
19969 verify_jobstats "$cmd" "$SINGLEMDS"
19970 # create all files on OST0000 so verify_jobstats can find OST stats
19972 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
19973 verify_jobstats "$cmd" "$SINGLEMDS"
19975 cmd="touch $DIR/$tfile"
19976 verify_jobstats "$cmd" "$SINGLEMDS ost1"
19978 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
19979 verify_jobstats "$cmd" "ost1"
19981 cancel_lru_locks osc
19982 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
19983 verify_jobstats "$cmd" "ost1"
19985 cmd="$TRUNCATE $DIR/$tfile 0"
19986 verify_jobstats "$cmd" "$SINGLEMDS ost1"
19988 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
19989 verify_jobstats "$cmd" "$SINGLEMDS"
19990 # jobstats expiry - sleep until old stats should be expired
19991 local left=$((new_interval + 5 - (SECONDS - start)))
19992 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
19993 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
19995 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
19996 verify_jobstats "$cmd" "$SINGLEMDS"
19997 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
19998 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
20000 # Ensure that jobid are present in changelog (if supported by MDS)
20001 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
20002 changelog_dump | tail -10
20003 jobids=$(changelog_dump | tail -9 | grep -c "j=")
20004 [ $jobids -eq 9 ] ||
20005 error "Wrong changelog jobid count $jobids != 9"
20009 jobstats_set $JOBENV
20011 changelog_dump | grep $tfile
20012 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
20013 [ $jobids -eq 0 ] ||
20014 error "Unexpected jobids when jobid_var=$JOBENV"
20017 # test '%j' access to environment variable - if supported
20018 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
20019 JOBENV="JOBCOMPLEX"
20020 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
20022 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
20025 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
20026 JOBENV="JOBCOMPLEX"
20027 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
20029 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
20032 # test '%j' access to per-session jobid - if supported
20033 if lctl list_param jobid_this_session > /dev/null 2>&1
20035 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
20036 lctl set_param jobid_this_session=$USER
20038 JOBENV="JOBCOMPLEX"
20039 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
20041 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
20044 run_test 205a "Verify job stats"
20046 # LU-13117, LU-13597, LU-16599
20048 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
20049 skip "Need MDS version at least 2.13.54.91"
20051 local job_stats="mdt.*.job_stats"
20052 local old_jobid=$(do_facet mds1 $LCTL get_param jobid_var)
20054 do_facet mds1 $LCTL set_param $job_stats=clear
20056 # Setting jobid_var to USER might not be supported
20057 [[ -n "$old_jobid" ]] && stack_trap "$LCTL set_param $old_jobid"
20058 $LCTL set_param jobid_var=USER || true
20059 stack_trap "$LCTL set_param $($LCTL get_param jobid_name)"
20060 $LCTL set_param jobid_name="%j.%e.%u"
20062 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
20063 do_facet mds1 $LCTL get_param $job_stats | grep "job_id:.*foolish" &&
20064 { do_facet mds1 $LCTL get_param $job_stats;
20065 error "Unexpected jobid found"; }
20066 do_facet mds1 $LCTL get_param $job_stats | grep "open:.*min.*max.*sum"||
20067 { do_facet mds1 $LCTL get_param $job_stats;
20068 error "wrong job_stats format found"; }
20070 (( $MDS1_VERSION <= $(version_code 2.15.0) )) &&
20071 echo "MDS does not yet escape jobid" && return 0
20073 mkdir_on_mdt0 $DIR/$tdir
20074 $LCTL set_param jobid_var=TEST205b
20075 env -i TEST205b="has sp" touch $DIR/$tdir/$tfile.2
20076 local jobid=$(do_facet mds1 $LCTL get_param $job_stats |
20077 awk '/has\\x20sp/ {print $3}')
20078 [[ -n "$jobid" ]] || { do_facet mds1 $LCTL get_param $job_stats;
20079 error "jobid not escaped"; }
20081 if (( $MDS1_VERSION >= $(version_code 2.15.53.139) )); then
20082 # need to run such a command on mds1:
20083 # lctl set_param mdt.$FSNAME-MDT0000.job_stats='"has\x20sp.touch.0"'
20085 # there might be multiple MDTs on single mds server, so need to
20086 # specifiy MDT0000. Or the command will fail due to other MDTs
20087 do_facet_vp mds1 $LCTL set_param mdt.$FSNAME-MDT0000.job_stats=$jobid ||
20088 error "cannot clear escaped jobid in job_stats";
20090 echo "MDS does not support clearing escaped jobid"
20093 run_test 205b "Verify job stats jobid and output format"
20097 $LCTL set_param llite.*.stats=0
20098 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
20099 $LCTL get_param llite.*.stats
20100 $LCTL get_param llite.*.stats | grep \
20101 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
20102 error "wrong client stats format found"
20104 run_test 205c "Verify client stats format"
20107 local file=$DIR/$tdir/$tfile
20109 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
20110 skip "need lustre >= 2.15.53 for lljobstat"
20111 (( $OST1_VERSION >= $(version_code 2.15.53) )) ||
20112 skip "need lustre >= 2.15.53 for lljobstat"
20113 verify_yaml_available || skip_env "YAML verification not installed"
20115 test_mkdir -i 0 $DIR/$tdir
20116 $LFS setstripe -E 1M -L mdt -E -1 $file || error "create file failed"
20117 stack_trap "rm -rf $DIR/$tdir"
20119 dd if=/dev/zero of=$file bs=1M count=10 conv=sync ||
20120 error "failed to write data to $file"
20123 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats"
20124 echo -n 'verify rename_stats...'
20125 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats" |
20126 verify_yaml || error "rename_stats is not valid YAML"
20129 echo -n 'verify mdt job_stats...'
20130 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.job_stats" |
20131 verify_yaml || error "job_stats on mds1 is not valid YAML"
20134 echo -n 'verify ost job_stats...'
20135 do_facet ost1 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.job_stats" |
20136 verify_yaml || error "job_stats on ost1 is not valid YAML"
20139 run_test 205d "verify the format of some stats files"
20143 local file=$DIR/$tdir/$tfile
20144 local -a cli_params
20146 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
20147 skip "need lustre >= 2.15.53 for lljobstat"
20148 (( $OST1_VERSION >= $(version_code 2.15.53) )) ||
20149 skip "need lustre >= 2.15.53 for lljobstat"
20150 verify_yaml_available || skip_env "YAML verification not installed"
20152 cli_params=( $($LCTL get_param jobid_name jobid_var) )
20153 $LCTL set_param jobid_var=nodelocal jobid_name=205e.%e.%u
20154 stack_trap "$LCTL set_param ${cli_params[*]}" EXIT
20156 mkdir_on_mdt0 $DIR/$tdir || error "failed to create dir"
20157 stack_trap "rm -rf $DIR/$tdir"
20159 $LFS setstripe -E EOF -i 0 -c 1 $file ||
20160 error "failed to create $file on ost1"
20161 dd if=/dev/zero of=$file bs=1M count=10 oflag=sync ||
20162 error "failed to write data to $file"
20164 do_facet mds1 "$LCTL get_param *.*.job_stats"
20165 do_facet ost1 "$LCTL get_param *.*.job_stats"
20167 do_facet ost1 "lljobstat -n 1 -i 0 -c 1000"
20168 do_facet ost1 "lljobstat -n 1 -i 0 -c 1000" | verify_yaml ||
20169 error "The output of lljobstat is not an valid YAML"
20171 # verify that job dd.0 does exist and has some ops on ost1
20172 # typically this line is like:
20173 # - 205e.dd.0: {ops: 20, ...}
20174 ops_comma=$(do_facet ost1 "lljobstat -n 1 -i 0 -c 1000" |
20175 awk '$2=="205e.dd.0:" {print $4}')
20177 (( ${ops_comma%,} >= 10 )) ||
20178 error "cannot find job 205e.dd.0 with ops >= 10"
20180 run_test 205e "verify the output of lljobstat"
20183 verify_yaml_available || skip_env "YAML verification not installed"
20185 # check both qos_ost_weights and qos_mdt_weights
20186 do_facet mds1 $LCTL get_param -n lod.*.qos*weights
20187 do_facet mds1 $LCTL get_param -n lod.*.qos*weights | verify_yaml ||
20188 error "qos_ost_weights is not valid YAML"
20190 run_test 205f "verify qos_ost_weights YAML format "
20192 __test_205_jobstats_dump() {
20194 local nbr_instance=$1
20197 if (( ${#pids[@]} >= nbr_instance )); then
20202 do_facet mds1 "$LCTL get_param mdt.*.job_stats > /dev/null" &
20207 __test_205_cleanup() {
20209 # Clear all job entries
20210 do_facet mds1 "$LCTL set_param mdt.*.job_stats=clear"
20214 local -a mds1_params
20215 local -a cli_params
20219 mds1_params=( $(do_facet mds1 $LCTL get_param mdt.*.job_cleanup_interval) )
20220 do_facet mds1 $LCTL set_param mdt.*.job_cleanup_interval=$interval
20221 stack_trap "do_facet mds1 $LCTL set_param ${mds1_params[*]}" EXIT
20223 cli_params=( $($LCTL get_param jobid_name jobid_var) )
20224 $LCTL set_param jobid_var=TEST205G_ID jobid_name=%j.%p
20225 stack_trap "$LCTL set_param ${cli_params[*]}" EXIT
20228 export TEST205G_ID=205g
20229 stack_trap "unset TEST205G_ID" EXIT
20231 printf $DIR/$tfile.{0001..1000} | xargs -P10 -n1 touch
20234 __test_205_jobstats_dump 4 & pids+="$! "
20235 stack_trap "__test_205_cleanup $pids" EXIT INT
20237 [[ $SLOW == "no" ]] && sleep 90 || sleep 240
20239 run_test 205g "stress test for job_stats procfile"
20242 (( $MDS1_VERSION >= $(version_code 2.15.57.7) )) ||
20243 skip "Need MDS >= v2_15_57-7-g23a2db28dc for jobid xattr"
20244 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
20246 local dir=$DIR/$tdir
20247 local f=$dir/$tfile
20248 local f2=$dir/$tfile-2
20249 local f3=$dir/$tfile-3
20250 local subdir=$DIR/dir
20253 local mdts=$(comma_list $(mdts_nodes))
20254 local mds_saved=$(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.job_xattr)
20255 local client_saved=$($LCTL get_param -n jobid_var)
20257 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.job_xattr=$mds_saved" EXIT
20258 stack_trap "$LCTL set_param jobid_var=$client_saved" EXIT
20260 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.job ||
20261 error "failed to set job_xattr parameter to user.job"
20262 $LCTL set_param jobid_var=procname.uid ||
20263 error "failed to set jobid_var parameter"
20268 val=$(getfattr -n user.job $f | grep user.job)
20269 [[ $val = user.job=\"touch.0\" ]] ||
20270 error "expected user.job=\"touch.0\", got '$val'"
20273 val=$(getfattr -n user.job $subdir | grep user.job)
20274 [[ $val = user.job=\"mkdir.0\" ]] ||
20275 error "expected user.job=\"mkdir.0\", got '$val'"
20277 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=NONE ||
20278 error "failed to set job_xattr parameter to NONE"
20281 val=$(getfattr -d $f2)
20283 error "expected no user xattr, got '$val'"
20285 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=trusted.job ||
20286 error "failed to set job_xattr parameter to trusted.job"
20289 val=$(getfattr -n trusted.job $f3 | grep trusted.job)
20290 [[ $val = trusted.job=\"touch.0\" ]] ||
20291 error "expected trusted.job=\"touch.0\", got '$val'"
20293 run_test 205h "check jobid xattr is stored correctly"
20296 (( $MDS1_VERSION >= $(version_code 2.15.57.7) )) ||
20297 skip "Need MDS >= v2_15_57-7-g23a2db28dc for jobid xattr"
20299 local mdts=$(comma_list $(mdts_nodes))
20300 local mds_saved=$(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.job_xattr)
20302 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.job_xattr=$mds_saved" EXIT
20304 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.1234567 ||
20305 error "failed to set mdt.*.job_xattr to user.1234567"
20307 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.12345678 &&
20308 error "failed to reject too long job_xattr name"
20310 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=userjob &&
20311 error "failed to reject job_xattr name in bad format"
20313 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.job/ &&
20314 error "failed to reject job_xattr name with invalid character"
20316 do_nodes $mdts "printf 'mdt.*.job_xattr=user.job\x80' |
20317 xargs $LCTL set_param" &&
20318 error "failed to reject job_xattr name with non-ascii character"
20322 run_test 205i "check job_xattr parameter accepts and rejects values correctly"
20324 # LU-1480, LU-1773 and LU-1657
20326 mkdir -p $DIR/$tdir
20327 $LFS setstripe -c -1 $DIR/$tdir
20328 #define OBD_FAIL_LOV_INIT 0x1403
20329 $LCTL set_param fail_loc=0xa0001403
20330 $LCTL set_param fail_val=1
20331 touch $DIR/$tdir/$tfile || true
20333 run_test 206 "fail lov_init_raid0() doesn't lbug"
20336 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
20337 local fsz=`stat -c %s $DIR/$tfile`
20338 cancel_lru_locks mdc
20340 # do not return layout in getattr intent
20341 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
20342 $LCTL set_param fail_loc=0x170
20343 local sz=`stat -c %s $DIR/$tfile`
20345 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
20349 run_test 207a "can refresh layout at glimpse"
20352 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
20353 local cksum=`md5sum $DIR/$tfile`
20354 local fsz=`stat -c %s $DIR/$tfile`
20355 cancel_lru_locks mdc
20356 cancel_lru_locks osc
20358 # do not return layout in getattr intent
20359 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
20360 $LCTL set_param fail_loc=0x171
20362 # it will refresh layout after the file is opened but before read issues
20363 echo checksum is "$cksum"
20364 echo "$cksum" |md5sum -c --quiet || error "file differs"
20368 run_test 207b "can refresh layout at open"
20371 # FIXME: in this test suite, only RD lease is used. This is okay
20372 # for now as only exclusive open is supported. After generic lease
20373 # is done, this test suite should be revised. - Jinshan
20375 remote_mds_nodsh && skip "remote MDS with nodsh"
20376 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
20377 skip "Need MDS version at least 2.4.52"
20379 echo "==== test 1: verify get lease work"
20380 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
20382 echo "==== test 2: verify lease can be broken by upcoming open"
20383 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
20387 $MULTIOP $DIR/$tfile oO_RDWR:c
20388 kill -USR1 $PID && wait $PID || error "break lease error"
20390 echo "==== test 3: verify lease can't be granted if an open already exists"
20391 $MULTIOP $DIR/$tfile oO_RDWR:_c &
20395 $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
20396 kill -USR1 $PID && wait $PID || error "open file error"
20398 echo "==== test 4: lease can sustain over recovery"
20399 $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
20405 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
20407 echo "==== test 5: lease broken can't be regained by replay"
20408 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
20412 # open file to break lease and then recovery
20413 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
20416 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
20420 run_test 208 "Exclusive open"
20423 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
20424 skip_env "must have disp_stripe"
20427 sync; sleep 5; sync;
20429 echo 3 > /proc/sys/vm/drop_caches
20430 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
20431 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
20432 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
20434 # open/close 500 times
20435 for i in $(seq 500); do
20439 echo 3 > /proc/sys/vm/drop_caches
20440 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
20441 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
20442 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
20444 echo "before: $req_before, after: $req_after"
20445 [ $((req_after - req_before)) -ge 300 ] &&
20446 error "open/close requests are not freed"
20449 run_test 209 "read-only open/close requests should be freed promptly"
20454 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
20458 $LFS getstripe $DIR/$tfile
20460 wait $pid || error "multiop failed"
20462 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
20466 $LFS getstripe $DIR/$tfile
20468 wait $pid || error "multiop failed"
20470 run_test 210 "lfs getstripe does not break leases"
20472 function test_211() {
20477 stack_trap "rm -f $DIR/$tfile" EXIT
20478 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=10 oflag=direct ||
20479 error "can't create file"
20480 $LFS mirror extend -N $DIR/$tfile ||
20481 error "can't create a replica"
20482 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
20483 $LFS getstripe $DIR/$tfile
20484 stale=$($LFS getstripe $DIR/$tfile | grep stale | wc -l)
20485 (( $stale != 1 )) && error "expected 1 stale, found $stale"
20487 $MULTIOP $DIR/$tfile OeW_E+eUc &
20491 id=$($LFS getstripe $DIR/$tfile |
20492 awk '/lcme_mirror_id:/{id=$2}/lcme_flags.*init$/{print id}')
20493 $LFS mirror split -d --mirror-id $id $DIR/$tfile &&
20494 error "removed last in-sync replica?"
20498 (( $? == 0 )) || error "failed split broke the lease"
20500 run_test 211 "failed mirror split doesn't break write lease"
20504 size=$((size % 8192 + 1))
20505 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
20506 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
20507 rm -f $DIR/f212 $DIR/f212.xyz
20509 run_test 212 "Sendfile test ============================================"
20512 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
20513 cancel_lru_locks osc
20514 lctl set_param fail_loc=0x8000040f
20515 # generate a read lock
20516 cat $DIR/$tfile > /dev/null
20517 # write to the file, it will try to cancel the above read lock.
20518 cat /etc/hosts >> $DIR/$tfile
20520 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
20522 test_214() { # for bug 20133
20523 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
20524 for (( i=0; i < 340; i++ )) ; do
20525 touch $DIR/$tdir/d214c/a$i
20528 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
20529 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
20530 ls $DIR/d214c || error "ls $DIR/d214c failed"
20531 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
20532 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
20534 run_test 214 "hash-indexed directory test - bug 20133"
20536 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
20537 create_lnet_proc_files() {
20538 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
20541 # counterpart of create_lnet_proc_files
20542 remove_lnet_proc_files() {
20543 rm -f $TMP/lnet_$1.sys
20546 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
20547 # 3rd arg as regexp for body
20548 check_lnet_proc_stats() {
20549 local l=$(cat "$TMP/lnet_$1" |wc -l)
20550 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
20552 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
20555 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
20556 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
20557 # optional and can be regexp for 2nd line (lnet.routes case)
20558 check_lnet_proc_entry() {
20559 local blp=2 # blp stands for 'position of 1st line of body'
20560 [ -z "$5" ] || blp=3 # lnet.routes case
20562 local l=$(cat "$TMP/lnet_$1" |wc -l)
20563 # subtracting one from $blp because the body can be empty
20564 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
20566 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
20567 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
20569 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
20570 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
20572 # bail out if any unexpected line happened
20573 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
20574 [ "$?" != 0 ] || error "$2 misformatted"
20577 test_215() { # for bugs 18102, 21079, 21517
20578 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20580 local N='(0|[1-9][0-9]*)' # non-negative numeric
20581 local P='[1-9][0-9]*' # positive numeric
20582 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
20583 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
20584 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
20585 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
20587 local L1 # regexp for 1st line
20588 local L2 # regexp for 2nd line (optional)
20589 local BR # regexp for the rest (body)
20591 # lnet.stats should look as 11 space-separated non-negative numerics
20592 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
20593 create_lnet_proc_files "stats"
20594 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
20595 remove_lnet_proc_files "stats"
20597 # lnet.routes should look like this:
20598 # Routing disabled/enabled
20599 # net hops priority state router
20600 # where net is a string like tcp0, hops > 0, priority >= 0,
20601 # state is up/down,
20602 # router is a string like 192.168.1.1@tcp2
20603 L1="^Routing (disabled|enabled)$"
20604 L2="^net +hops +priority +state +router$"
20605 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
20606 create_lnet_proc_files "routes"
20607 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
20608 remove_lnet_proc_files "routes"
20610 # lnet.routers should look like this:
20611 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
20612 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
20613 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
20614 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
20615 L1="^ref +rtr_ref +alive +router$"
20616 BR="^$P +$P +(up|down) +$NID$"
20617 create_lnet_proc_files "routers"
20618 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
20619 remove_lnet_proc_files "routers"
20621 # lnet.peers should look like this:
20622 # nid refs state last max rtr min tx min queue
20623 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
20624 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
20625 # numeric (0 or >0 or <0), queue >= 0.
20626 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
20627 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
20628 create_lnet_proc_files "peers"
20629 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
20630 remove_lnet_proc_files "peers"
20632 # lnet.buffers should look like this:
20633 # pages count credits min
20634 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
20635 L1="^pages +count +credits +min$"
20636 BR="^ +$N +$N +$I +$I$"
20637 create_lnet_proc_files "buffers"
20638 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
20639 remove_lnet_proc_files "buffers"
20641 # lnet.nis should look like this:
20642 # nid status alive refs peer rtr max tx min
20643 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
20644 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
20645 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
20646 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
20647 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
20648 create_lnet_proc_files "nis"
20649 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
20650 remove_lnet_proc_files "nis"
20652 # can we successfully write to lnet.stats?
20653 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
20655 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
20657 test_216() { # bug 20317
20658 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20659 remote_ost_nodsh && skip "remote OST with nodsh"
20662 local facets=$(get_facets OST)
20663 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
20665 save_lustre_params client "osc.*.contention_seconds" > $p
20666 save_lustre_params $facets \
20667 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
20668 save_lustre_params $facets \
20669 "ldlm.namespaces.filter-*.contended_locks" >> $p
20670 save_lustre_params $facets \
20671 "ldlm.namespaces.filter-*.contention_seconds" >> $p
20672 clear_stats osc.*.osc_stats
20674 # agressive lockless i/o settings
20675 do_nodes $(comma_list $(osts_nodes)) \
20676 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
20677 ldlm.namespaces.filter-*.contended_locks=0 \
20678 ldlm.namespaces.filter-*.contention_seconds=60"
20679 lctl set_param -n osc.*.contention_seconds=60
20681 $DIRECTIO write $DIR/$tfile 0 10 4096
20682 $CHECKSTAT -s 40960 $DIR/$tfile
20684 # disable lockless i/o
20685 do_nodes $(comma_list $(osts_nodes)) \
20686 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
20687 ldlm.namespaces.filter-*.contended_locks=32 \
20688 ldlm.namespaces.filter-*.contention_seconds=0"
20689 lctl set_param -n osc.*.contention_seconds=0
20690 clear_stats osc.*.osc_stats
20692 dd if=/dev/zero of=$DIR/$tfile count=0
20693 $CHECKSTAT -s 0 $DIR/$tfile
20695 restore_lustre_params <$p
20699 run_test 216 "check lockless direct write updates file size and kms correctly"
20701 test_217() { # bug 22430
20702 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20706 for node in $(nodes_list); do
20707 local nid=$(host_nids_address $node $NETTYPE)
20708 local node_ip=$(do_node $node getent ahostsv4 $node |
20709 awk '{ print $1; exit; }')
20711 echo "node: '$node', nid: '$nid', node_ip='$node_ip'"
20712 # if hostname matches any NID, use hostname for better testing
20713 if [[ -z "$nid" || "$nid" =~ "$node_ip" ]]; then
20714 echo "lctl ping node $node@$NETTYPE"
20715 lctl ping $node@$NETTYPE
20716 else # otherwise, at least test 'lctl ping' is working
20717 echo "lctl ping nid $(h2nettype $nid)"
20718 lctl ping $(h2nettype $nid)
20719 echo "skipping $node (no hyphen detected)"
20723 run_test 217 "check lctl ping for hostnames with embedded hyphen ('-')"
20726 # do directio so as not to populate the page cache
20727 log "creating a 10 Mb file"
20728 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
20729 error "multiop failed while creating a file"
20730 log "starting reads"
20731 dd if=$DIR/$tfile of=/dev/null bs=4096 &
20732 log "truncating the file"
20733 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
20734 error "multiop failed while truncating the file"
20736 kill %+ || true # reads might have finished
20737 echo "wait until dd is finished"
20739 log "removing the temporary file"
20740 rm -rf $DIR/$tfile || error "tmp file removal failed"
20742 run_test 218 "parallel read and truncate should not deadlock"
20745 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20747 # write one partial page
20748 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
20749 # set no grant so vvp_io_commit_write will do sync write
20750 $LCTL set_param fail_loc=0x411
20751 # write a full page at the end of file
20752 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
20754 $LCTL set_param fail_loc=0
20755 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
20756 $LCTL set_param fail_loc=0x411
20757 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
20760 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
20761 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
20763 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
20765 test_220() { #LU-325
20766 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20767 remote_ost_nodsh && skip "remote OST with nodsh"
20768 remote_mds_nodsh && skip "remote MDS with nodsh"
20769 remote_mgs_nodsh && skip "remote MGS with nodsh"
20773 # create on MDT0000 so the last_id and next_id are correct
20774 mkdir_on_mdt0 $DIR/$tdir
20775 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
20779 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
20780 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
20781 osp.$mdtosc_proc1.prealloc_last_id)
20782 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
20783 osp.$mdtosc_proc1.prealloc_next_id)
20787 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
20788 #define OBD_FAIL_OST_ENOINO 0x229
20789 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
20790 create_pool $FSNAME.$TESTNAME || return 1
20791 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
20793 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
20795 MDSOBJS=$((last_id - next_id))
20796 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
20798 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
20799 echo "OST still has $count kbytes free"
20801 echo "create $MDSOBJS files @next_id..."
20802 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
20804 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
20805 osp.$mdtosc_proc1.prealloc_last_id)
20806 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
20807 osp.$mdtosc_proc1.prealloc_next_id)
20809 echo "after creation, last_id=$last_id2, next_id=$next_id2"
20814 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
20815 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
20817 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
20818 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
20819 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
20820 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
20821 echo "unlink $MDSOBJS files @$next_id..."
20822 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
20824 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
20827 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20829 dd if=`which date` of=$MOUNT/date oflag=sync
20830 chmod +x $MOUNT/date
20832 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
20833 $LCTL set_param fail_loc=0x80001401
20835 $MOUNT/date > /dev/null
20838 run_test 221 "make sure fault and truncate race to not cause OOM"
20841 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20844 test_mkdir $DIR/$tdir
20845 $LFS setstripe -c 1 -i 0 $DIR/$tdir
20846 createmany -o $DIR/$tdir/$tfile 10
20847 cancel_lru_locks mdc
20848 cancel_lru_locks osc
20849 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
20850 $LCTL set_param fail_loc=0x31a
20851 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
20852 $LCTL set_param fail_loc=0
20855 run_test 222a "AGL for ls should not trigger CLIO lock failure"
20858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20861 test_mkdir $DIR/$tdir
20862 $LFS setstripe -c 1 -i 0 $DIR/$tdir
20863 createmany -o $DIR/$tdir/$tfile 10
20864 cancel_lru_locks mdc
20865 cancel_lru_locks osc
20866 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
20867 $LCTL set_param fail_loc=0x31a
20868 rm -r $DIR/$tdir || error "AGL for rmdir failed"
20869 $LCTL set_param fail_loc=0
20871 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
20874 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20877 test_mkdir $DIR/$tdir
20878 $LFS setstripe -c 1 -i 0 $DIR/$tdir
20879 createmany -o $DIR/$tdir/$tfile 10
20880 cancel_lru_locks mdc
20881 cancel_lru_locks osc
20882 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
20883 $LCTL set_param fail_loc=0x31b
20884 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
20885 $LCTL set_param fail_loc=0
20888 run_test 223 "osc reenqueue if without AGL lock granted ======================="
20890 test_224a() { # LU-1039, MRP-303
20891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20892 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
20893 $LCTL set_param fail_loc=0x508
20894 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fsync
20895 $LCTL set_param fail_loc=0
20898 run_test 224a "Don't panic on bulk IO failure"
20900 test_224bd_sub() { # LU-1039, MRP-303
20901 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20905 dd if=/dev/urandom of=$TMP/$tfile bs=1M count=1
20907 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20909 dd if=$TMP/$tfile of=$DIR/$tfile bs=1M count=1
20910 cancel_lru_locks osc
20912 stack_trap "set_checksums $ORIG_CSUM" EXIT
20913 local at_max_saved=0
20915 # adaptive timeouts may prevent seeing the issue
20916 if at_is_enabled; then
20917 at_max_saved=$(at_max_get mds)
20918 at_max_set 0 mds client
20919 stack_trap "at_max_set $at_max_saved mds client" EXIT
20922 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
20923 do_facet ost1 $LCTL set_param fail_val=$timeout fail_loc=0x80000515
20924 dd of=$TMP/$tfile.new if=$DIR/$tfile bs=1M count=1 || "$@"
20926 do_facet ost1 $LCTL set_param fail_loc=0
20927 cmp $TMP/$tfile $TMP/$tfile.new || error "file contents wrong"
20932 test_224bd_sub 3 error "dd failed"
20934 run_test 224b "Don't panic on bulk IO failure"
20936 test_224c() { # LU-6441
20937 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20938 remote_mds_nodsh && skip "remote MDS with nodsh"
20940 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
20941 save_writethrough $p
20942 set_cache writethrough on
20944 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
20945 local at_max=$($LCTL get_param -n at_max)
20946 local timeout=$($LCTL get_param -n timeout)
20947 local test_at="at_max"
20948 local param_at="$FSNAME.sys.at_max"
20949 local test_timeout="timeout"
20950 local param_timeout="$FSNAME.sys.timeout"
20952 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
20954 set_persistent_param_and_check client "$test_at" "$param_at" 0
20955 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
20957 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
20958 do_facet ost1 "$LCTL set_param fail_loc=0x520"
20959 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20960 stack_trap "rm -f $DIR/$tfile"
20961 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
20963 do_facet ost1 "$LCTL set_param fail_loc=0"
20965 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
20966 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
20969 $LCTL set_param -n $pages_per_rpc
20970 restore_lustre_params < $p
20973 run_test 224c "Don't hang if one of md lost during large bulk RPC"
20975 test_224d() { # LU-11169
20976 test_224bd_sub $((TIMEOUT + 2)) error "dd failed"
20978 run_test 224d "Don't corrupt data on bulk IO timeout"
20980 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
20982 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20983 if [ -z ${MDSSURVEY} ]; then
20984 skip_env "mds-survey not found"
20986 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
20987 skip "Need MDS version at least 2.2.51"
20989 local mds=$(facet_host $SINGLEMDS)
20990 local target=$(do_nodes $mds 'lctl dl' |
20991 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
20993 local cmd1="file_count=1000 thrhi=4"
20994 local cmd2="dir_count=2 layer=mdd stripe_count=0"
20995 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
20996 local cmd="$cmd1 $cmd2 $cmd3"
20998 rm -f ${TMP}/mds_survey*
21000 eval $cmd || error "mds-survey with zero-stripe failed"
21001 cat ${TMP}/mds_survey*
21002 rm -f ${TMP}/mds_survey*
21004 run_test 225a "Metadata survey sanity with zero-stripe"
21007 if [ -z ${MDSSURVEY} ]; then
21008 skip_env "mds-survey not found"
21010 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
21011 skip "Need MDS version at least 2.2.51"
21012 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21013 remote_mds_nodsh && skip "remote MDS with nodsh"
21014 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
21015 skip_env "Need to mount OST to test"
21018 local mds=$(facet_host $SINGLEMDS)
21019 local target=$(do_nodes $mds 'lctl dl' |
21020 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
21022 local cmd1="file_count=1000 thrhi=4"
21023 local cmd2="dir_count=2 layer=mdd stripe_count=1"
21024 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
21025 local cmd="$cmd1 $cmd2 $cmd3"
21027 rm -f ${TMP}/mds_survey*
21029 eval $cmd || error "mds-survey with stripe_count failed"
21030 cat ${TMP}/mds_survey*
21031 rm -f ${TMP}/mds_survey*
21033 run_test 225b "Metadata survey sanity with stripe_count = 1"
21035 mcreate_path2fid () {
21041 local path=$DIR/$tdir/$name
21046 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
21047 error "cannot create $desc"
21049 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
21051 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
21053 fid_path=$($LFS fid2path $MOUNT $fid)
21055 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
21057 [ "$path" == "$fid_path" ] ||
21058 error "fid2path returned $fid_path, expected $path"
21060 echo "pass with $path and $fid"
21065 mkdir -p $DIR/$tdir
21067 mcreate_path2fid 0010666 0 0 fifo "FIFO"
21068 mcreate_path2fid 0020666 1 3 null "character special file (null)"
21069 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
21070 mcreate_path2fid 0040666 0 0 dir "directory"
21071 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
21072 mcreate_path2fid 0100666 0 0 file "regular file"
21073 mcreate_path2fid 0120666 0 0 link "symbolic link"
21074 mcreate_path2fid 0140666 0 0 sock "socket"
21076 run_test 226a "call path2fid and fid2path on files of all type"
21079 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21084 mkdir -p $DIR/$tdir
21085 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
21086 error "create remote directory failed"
21087 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
21088 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
21089 "character special file (null)"
21090 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
21091 "character special file (no device)"
21092 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
21093 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
21094 "block special file (loop)"
21095 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
21096 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
21097 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
21099 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
21102 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21103 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
21104 skip "Need MDS version at least 2.13.55"
21106 local submnt=/mnt/submnt
21107 local srcfile=/etc/passwd
21108 local dstfile=$submnt/passwd
21114 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
21115 error "create remote directory failed"
21116 mkdir -p $submnt || error "create $submnt failed"
21117 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
21118 error "mount $submnt failed"
21119 stack_trap "umount $submnt" EXIT
21121 cp $srcfile $dstfile
21122 fid=$($LFS path2fid $dstfile)
21123 path=$($LFS fid2path $submnt "$fid")
21124 [ "$path" = "$dstfile" ] ||
21125 error "fid2path $submnt $fid failed ($path != $dstfile)"
21127 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
21130 (( $CLIENT_VERSION >= $(version_code 2.15.57) )) ||
21131 skip "Need client at least version 2.15.57"
21133 # Define First test dataset
21134 local testdirs_01=$DIR/$tdir
21135 local testdata_01=$testdirs_01/${tdir}_01
21136 local testresult_01=${tdir}_01
21137 # Define Second test dataset
21138 local testdirs_02=$DIR/$tdir/$tdir
21139 local testdata_02=$testdirs_02/${tdir}_02
21140 local testresult_02=${tdir}_02
21141 # Define third test dataset (top level)
21142 local testdata_03=$DIR/${tdir}_03
21143 local testresult_03=${tdir}_03
21145 # Create first test dataset
21146 mkdir -p $testdirs_01 || error "cannot create dir $testdirs_01"
21147 touch $testdata_01 || error "cannot create file $testdata_01"
21149 # Create second test dataset
21150 mkdir -p $testdirs_02 || error "cannot create dir $testdirs_02"
21151 touch $testdata_02 || error "cannot create file $testdata_02"
21153 # Create third test dataset
21154 touch $testdata_03 || error "cannot create file $testdata_03"
21156 local fid01=$($LFS getstripe -F "$testdata_01") ||
21157 error "getstripe failed on $testdata_01"
21158 local fid02=$($LFS getstripe -F "$testdata_02") ||
21159 error "getstripe failed on $testdata_01"
21160 local fid03=$($LFS getstripe -F "$testdata_03") ||
21161 error "getstripe failed on $testdata_03"
21163 # Verify only -n option
21164 local out1=$($LFS fid2path -n $DIR $fid01) ||
21165 error "fid2path failed on $fid01"
21166 local out2=$($LFS fid2path -n $DIR $fid02) ||
21167 error "fid2path failed on $fid02"
21168 local out3=$($LFS fid2path -n $DIR $fid03) ||
21169 error "fid2path failed on $fid03"
21171 [[ "$out1" == "$testresult_01" ]] ||
21172 error "fid2path failed: Expected $testresult_01 got $out1"
21173 [[ "$out2" == "$testresult_02" ]] ||
21174 error "fid2path failed: Expected $testresult_02 got $out2"
21175 [[ "$out3" == "$testresult_03" ]] ||
21176 error "fid2path failed: Expected $testresult_03 got $out3"
21178 # Verify with option -fn together
21179 out1=$($LFS fid2path -fn $DIR $fid01) ||
21180 error "fid2path -fn failed on $fid01"
21181 out2=$($LFS fid2path -fn $DIR $fid02) ||
21182 error "fid2path -fn failed on $fid02"
21183 out3=$($LFS fid2path -fn $DIR $fid03) ||
21184 error "fid2path -fn failed on $fid03"
21186 local tmpout=$(echo $out1 | cut -d" " -f2)
21187 [[ "$tmpout" == "$testresult_01" ]] ||
21188 error "fid2path -fn failed: Expected $testresult_01 got $out1"
21190 tmpout=$(echo $out2 | cut -d" " -f2)
21191 [[ "$tmpout" == "$testresult_02" ]] ||
21192 error "fid2path -fn failed: Expected $testresult_02 got $out2"
21194 tmpout=$(echo $out3 | cut -d" " -f2)
21195 [[ "$tmpout" == "$testresult_03" ]] ||
21196 error "fid2path -fn failed: Expected $testresult_03 got $out3"
21198 run_test 226d "verify fid2path with -n and -fn option"
21201 (( $CLIENT_VERSION >= $(version_code 2.15.56) )) ||
21202 skip "Need client at least version 2.15.56"
21204 # Define filename with 'newline' and a space
21205 local testfile="Test"$'\n'"file 01"
21206 # Define link name with multiple 'newline' and a space
21207 local linkfile="Link"$'\n'"file "$'\n'"01"
21208 # Remove prior hard link
21209 rm -f $DIR/"$linkfile"
21212 touch $DIR/"$testfile"
21214 ln $DIR/"$testfile" $DIR/"$linkfile"
21216 local fid=$($LFS getstripe -F "$DIR/$testfile") ||
21217 error "getstripe failed on $DIR/$testfile"
21219 # Call with -0 option
21220 local out1=$($LFS fid2path -0 $DIR $fid | xargs --null -n1 \
21221 echo "FILE:" | grep -c "FILE:")
21223 # With -0 option the output should be exactly 2 lines.
21224 (( $out1 == 2 )) || error "fid2path -0 failed on $fid, $out1"
21226 run_test 226e "Verify path2fid -0 option with newline and space"
21228 # LU-1299 Executing or running ldd on a truncated executable does not
21229 # cause an out-of-memory condition.
21231 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21232 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
21234 dd if=$(which date) of=$MOUNT/date bs=1k count=1
21235 chmod +x $MOUNT/date
21237 $MOUNT/date > /dev/null
21238 ldd $MOUNT/date > /dev/null
21241 run_test 227 "running truncated executable does not cause OOM"
21243 # LU-1512 try to reuse idle OI blocks
21245 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21246 remote_mds_nodsh && skip "remote MDS with nodsh"
21247 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21249 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
21250 local myDIR=$DIR/$tdir
21253 #define OBD_FAIL_SEQ_EXHAUST 0x1002
21254 $LCTL set_param fail_loc=0x80001002
21255 createmany -o $myDIR/t- 10000
21256 $LCTL set_param fail_loc=0
21257 # The guard is current the largest FID holder
21259 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
21261 local IDX=$(($SEQ % 64))
21263 do_facet $SINGLEMDS sync
21264 # Make sure journal flushed.
21266 local blk1=$(do_facet $SINGLEMDS \
21267 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21268 grep Blockcount | awk '{print $4}')
21270 # Remove old files, some OI blocks will become idle.
21271 unlinkmany $myDIR/t- 10000
21272 # Create new files, idle OI blocks should be reused.
21273 createmany -o $myDIR/t- 2000
21274 do_facet $SINGLEMDS sync
21275 # Make sure journal flushed.
21277 local blk2=$(do_facet $SINGLEMDS \
21278 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21279 grep Blockcount | awk '{print $4}')
21281 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
21283 run_test 228a "try to reuse idle OI blocks"
21286 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21287 remote_mds_nodsh && skip "remote MDS with nodsh"
21288 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21290 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
21291 local myDIR=$DIR/$tdir
21294 #define OBD_FAIL_SEQ_EXHAUST 0x1002
21295 $LCTL set_param fail_loc=0x80001002
21296 createmany -o $myDIR/t- 10000
21297 $LCTL set_param fail_loc=0
21298 # The guard is current the largest FID holder
21300 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
21302 local IDX=$(($SEQ % 64))
21304 do_facet $SINGLEMDS sync
21305 # Make sure journal flushed.
21307 local blk1=$(do_facet $SINGLEMDS \
21308 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21309 grep Blockcount | awk '{print $4}')
21311 # Remove old files, some OI blocks will become idle.
21312 unlinkmany $myDIR/t- 10000
21315 stop $SINGLEMDS || error "Fail to stop MDT."
21317 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
21318 error "Fail to start MDT."
21320 client_up || error "Fail to df."
21321 # Create new files, idle OI blocks should be reused.
21322 createmany -o $myDIR/t- 2000
21323 do_facet $SINGLEMDS sync
21324 # Make sure journal flushed.
21326 local blk2=$(do_facet $SINGLEMDS \
21327 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21328 grep Blockcount | awk '{print $4}')
21330 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
21332 run_test 228b "idle OI blocks can be reused after MDT restart"
21336 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21337 remote_mds_nodsh && skip "remote MDS with nodsh"
21338 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21340 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
21341 local myDIR=$DIR/$tdir
21344 #define OBD_FAIL_SEQ_EXHAUST 0x1002
21345 $LCTL set_param fail_loc=0x80001002
21346 # 20000 files can guarantee there are index nodes in the OI file
21347 createmany -o $myDIR/t- 20000
21348 $LCTL set_param fail_loc=0
21349 # The guard is current the largest FID holder
21351 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
21353 local IDX=$(($SEQ % 64))
21355 do_facet $SINGLEMDS sync
21356 # Make sure journal flushed.
21358 local blk1=$(do_facet $SINGLEMDS \
21359 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21360 grep Blockcount | awk '{print $4}')
21362 # Remove old files, some OI blocks will become idle.
21363 unlinkmany $myDIR/t- 20000
21365 # The OI file should become empty now
21367 # Create new files, idle OI blocks should be reused.
21368 createmany -o $myDIR/t- 2000
21369 do_facet $SINGLEMDS sync
21370 # Make sure journal flushed.
21372 local blk2=$(do_facet $SINGLEMDS \
21373 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21374 grep Blockcount | awk '{print $4}')
21376 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
21378 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
21380 test_229() { # LU-2482, LU-3448
21381 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21382 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
21383 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
21384 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
21388 # Create a file with a released layout and stripe count 2.
21389 $MULTIOP $DIR/$tfile H2c ||
21390 error "failed to create file with released layout"
21392 $LFS getstripe -v $DIR/$tfile
21394 local pattern=$($LFS getstripe -L $DIR/$tfile)
21395 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
21397 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
21399 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
21400 stat $DIR/$tfile || error "failed to stat released file"
21402 chown $RUNAS_ID $DIR/$tfile ||
21403 error "chown $RUNAS_ID $DIR/$tfile failed"
21405 chgrp $RUNAS_ID $DIR/$tfile ||
21406 error "chgrp $RUNAS_ID $DIR/$tfile failed"
21408 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
21409 rm $DIR/$tfile || error "failed to remove released file"
21411 run_test 229 "getstripe/stat/rm/attr changes work on released files"
21414 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21415 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21416 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21417 skip "Need MDS version at least 2.11.52"
21421 test_mkdir $DIR/$tdir
21422 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
21423 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
21424 [ $mdt_idx -ne 0 ] &&
21425 error "create local directory on wrong MDT $mdt_idx"
21427 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
21428 error "create remote directory failed"
21429 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
21430 [ $mdt_idx -ne $MDTIDX ] &&
21431 error "create remote directory on wrong MDT $mdt_idx"
21433 createmany -o $DIR/$tdir/test_230/t- 10 ||
21434 error "create files on remote directory failed"
21435 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
21436 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
21437 rm -r $DIR/$tdir || error "unlink remote directory failed"
21439 run_test 230a "Create remote directory and files under the remote directory"
21442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21443 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21444 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21445 skip "Need MDS version at least 2.11.52"
21453 local migrate_dir=$DIR/$tdir/migrate_dir
21454 local other_dir=$DIR/$tdir/other_dir
21456 test_mkdir $DIR/$tdir
21457 test_mkdir -i0 -c1 $migrate_dir
21458 test_mkdir -i0 -c1 $other_dir
21459 for ((i=0; i<10; i++)); do
21460 mkdir -p $migrate_dir/dir_${i}
21461 createmany -o $migrate_dir/dir_${i}/f 10 ||
21462 error "create files under remote dir failed $i"
21465 cp /etc/passwd $migrate_dir/$tfile
21466 cp /etc/passwd $other_dir/$tfile
21467 chattr +SAD $migrate_dir
21468 chattr +SAD $migrate_dir/$tfile
21470 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
21471 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
21472 local old_dir_mode=$(stat -c%f $migrate_dir)
21473 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
21475 mkdir -p $migrate_dir/dir_default_stripe2
21476 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
21477 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
21479 mkdir -p $other_dir
21480 ln $migrate_dir/$tfile $other_dir/luna
21481 ln $migrate_dir/$tfile $migrate_dir/sofia
21482 ln $other_dir/$tfile $migrate_dir/david
21483 ln -s $migrate_dir/$tfile $other_dir/zachary
21484 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
21485 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
21491 for len in 58 59 60; do
21492 lnktgt=$(str_repeat 'l' $len)
21493 touch $migrate_dir/$lnktgt
21494 ln -s $lnktgt $migrate_dir/${len}char_ln
21498 for len in 4094 4095; do
21499 lnktgt=$(str_repeat 'l' $len)
21500 ln -s $lnktgt $migrate_dir/${len}char_ln
21504 for len in 254 255; do
21505 touch $migrate_dir/$(str_repeat 'l' $len)
21508 $LFS migrate -m $MDTIDX $migrate_dir ||
21509 error "fails on migrating remote dir to MDT1"
21511 echo "migratate to MDT1, then checking.."
21512 for ((i = 0; i < 10; i++)); do
21513 for file in $(find $migrate_dir/dir_${i}); do
21514 mdt_index=$($LFS getstripe -m $file)
21515 # broken symlink getstripe will fail
21516 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
21517 error "$file is not on MDT${MDTIDX}"
21521 # the multiple link file should still in MDT0
21522 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
21523 [ $mdt_index == 0 ] ||
21524 error "$file is not on MDT${MDTIDX}"
21526 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
21527 [ "$old_dir_flag" = "$new_dir_flag" ] ||
21528 error " expect $old_dir_flag get $new_dir_flag"
21530 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
21531 [ "$old_file_flag" = "$new_file_flag" ] ||
21532 error " expect $old_file_flag get $new_file_flag"
21534 local new_dir_mode=$(stat -c%f $migrate_dir)
21535 [ "$old_dir_mode" = "$new_dir_mode" ] ||
21536 error "expect mode $old_dir_mode get $new_dir_mode"
21538 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
21539 [ "$old_file_mode" = "$new_file_mode" ] ||
21540 error "expect mode $old_file_mode get $new_file_mode"
21542 diff /etc/passwd $migrate_dir/$tfile ||
21543 error "$tfile different after migration"
21545 diff /etc/passwd $other_dir/luna ||
21546 error "luna different after migration"
21548 diff /etc/passwd $migrate_dir/sofia ||
21549 error "sofia different after migration"
21551 diff /etc/passwd $migrate_dir/david ||
21552 error "david different after migration"
21554 diff /etc/passwd $other_dir/zachary ||
21555 error "zachary different after migration"
21557 diff /etc/passwd $migrate_dir/${tfile}_ln ||
21558 error "${tfile}_ln different after migration"
21560 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
21561 error "${tfile}_ln_other different after migration"
21563 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
21564 [ $stripe_count = 2 ] ||
21565 error "dir strpe_count $d != 2 after migration."
21567 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
21568 [ $stripe_count = 2 ] ||
21569 error "file strpe_count $d != 2 after migration."
21571 #migrate back to MDT0
21574 $LFS migrate -m $MDTIDX $migrate_dir ||
21575 error "fails on migrating remote dir to MDT0"
21577 echo "migrate back to MDT0, checking.."
21578 for file in $(find $migrate_dir); do
21579 mdt_index=$($LFS getstripe -m $file)
21580 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
21581 error "$file is not on MDT${MDTIDX}"
21584 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
21585 [ "$old_dir_flag" = "$new_dir_flag" ] ||
21586 error " expect $old_dir_flag get $new_dir_flag"
21588 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
21589 [ "$old_file_flag" = "$new_file_flag" ] ||
21590 error " expect $old_file_flag get $new_file_flag"
21592 local new_dir_mode=$(stat -c%f $migrate_dir)
21593 [ "$old_dir_mode" = "$new_dir_mode" ] ||
21594 error "expect mode $old_dir_mode get $new_dir_mode"
21596 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
21597 [ "$old_file_mode" = "$new_file_mode" ] ||
21598 error "expect mode $old_file_mode get $new_file_mode"
21600 diff /etc/passwd ${migrate_dir}/$tfile ||
21601 error "$tfile different after migration"
21603 diff /etc/passwd ${other_dir}/luna ||
21604 error "luna different after migration"
21606 diff /etc/passwd ${migrate_dir}/sofia ||
21607 error "sofia different after migration"
21609 diff /etc/passwd ${other_dir}/zachary ||
21610 error "zachary different after migration"
21612 diff /etc/passwd $migrate_dir/${tfile}_ln ||
21613 error "${tfile}_ln different after migration"
21615 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
21616 error "${tfile}_ln_other different after migration"
21618 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
21619 [ $stripe_count = 2 ] ||
21620 error "dir strpe_count $d != 2 after migration."
21622 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
21623 [ $stripe_count = 2 ] ||
21624 error "file strpe_count $d != 2 after migration."
21626 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21628 run_test 230b "migrate directory"
21631 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21632 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21633 remote_mds_nodsh && skip "remote MDS with nodsh"
21634 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21635 skip "Need MDS version at least 2.11.52"
21641 local migrate_dir=$DIR/$tdir/migrate_dir
21643 #If migrating directory fails in the middle, all entries of
21644 #the directory is still accessiable.
21645 test_mkdir $DIR/$tdir
21646 test_mkdir -i0 -c1 $migrate_dir
21647 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
21649 createmany -o $migrate_dir/f $total ||
21650 error "create files under ${migrate_dir} failed"
21652 # fail after migrating top dir, and this will fail only once, so the
21653 # first sub file migration will fail (currently f3), others succeed.
21654 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
21655 do_facet mds1 lctl set_param fail_loc=0x1801
21656 local t=$(ls $migrate_dir | wc -l)
21657 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
21658 error "migrate should fail"
21659 local u=$(ls $migrate_dir | wc -l)
21660 [ "$u" == "$t" ] || error "$u != $t during migration"
21662 # add new dir/file should succeed
21663 mkdir $migrate_dir/dir ||
21664 error "mkdir failed under migrating directory"
21665 touch $migrate_dir/file ||
21666 error "create file failed under migrating directory"
21668 # add file with existing name should fail
21669 for file in $migrate_dir/f*; do
21670 stat $file > /dev/null || error "stat $file failed"
21671 $OPENFILE -f O_CREAT:O_EXCL $file &&
21672 error "open(O_CREAT|O_EXCL) $file should fail"
21673 $MULTIOP $file m && error "create $file should fail"
21674 touch $DIR/$tdir/remote_dir/$tfile ||
21675 error "touch $tfile failed"
21676 ln $DIR/$tdir/remote_dir/$tfile $file &&
21677 error "link $file should fail"
21678 mdt_index=$($LFS getstripe -m $file)
21679 if [ $mdt_index == 0 ]; then
21680 # file failed to migrate is not allowed to rename to
21681 mv $DIR/$tdir/remote_dir/$tfile $file &&
21682 error "rename to $file should fail"
21684 mv $DIR/$tdir/remote_dir/$tfile $file ||
21685 error "rename to $file failed"
21687 echo hello >> $file || error "write $file failed"
21690 # resume migration with different options should fail
21691 $LFS migrate -m 0 $migrate_dir &&
21692 error "migrate -m 0 $migrate_dir should fail"
21694 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
21695 error "migrate -c 2 $migrate_dir should fail"
21697 # resume migration should succeed
21698 $LFS migrate -m $MDTIDX $migrate_dir ||
21699 error "migrate $migrate_dir failed"
21701 echo "Finish migration, then checking.."
21702 for file in $(find $migrate_dir); do
21703 mdt_index=$($LFS getstripe -m $file)
21704 [ $mdt_index == $MDTIDX ] ||
21705 error "$file is not on MDT${MDTIDX}"
21708 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21710 run_test 230c "check directory accessiblity if migration failed"
21713 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21714 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21715 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21716 skip "Need MDS version at least 2.11.52"
21718 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
21720 local migrate_dir=$DIR/$tdir/migrate_dir
21730 old_index=$((RANDOM % MDSCOUNT))
21731 old_count=$((MDSCOUNT - old_index))
21732 new_index=$((RANDOM % MDSCOUNT))
21733 new_count=$((MDSCOUNT - new_index))
21734 new_hash=1 # for all_char
21736 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
21737 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
21739 test_mkdir $DIR/$tdir
21740 test_mkdir -i $old_index -c $old_count $migrate_dir
21742 for ((i=0; i<100; i++)); do
21743 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
21744 createmany -o $migrate_dir/dir_${i}/f 100 ||
21745 error "create files under remote dir failed $i"
21748 echo -n "Migrate from MDT$old_index "
21749 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
21750 echo -n "to MDT$new_index"
21751 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
21754 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
21755 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
21756 error "migrate remote dir error"
21758 echo "Finish migration, then checking.."
21759 for file in $(find $migrate_dir -maxdepth 1); do
21760 mdt_index=$($LFS getstripe -m $file)
21761 if [ $mdt_index -lt $new_index ] ||
21762 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
21763 error "$file is on MDT$mdt_index"
21767 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21769 run_test 230d "check migrate big directory"
21772 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21773 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21774 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21775 skip "Need MDS version at least 2.11.52"
21782 mkdir_on_mdt0 $DIR/$tdir
21783 mkdir $DIR/$tdir/migrate_dir
21784 mkdir $DIR/$tdir/other_dir
21785 touch $DIR/$tdir/migrate_dir/a
21786 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
21787 ls $DIR/$tdir/other_dir
21789 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
21790 error "migrate dir fails"
21792 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
21793 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
21795 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
21796 [ $mdt_index == 0 ] || error "a is not on MDT0"
21798 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
21799 error "migrate dir fails"
21801 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
21802 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
21804 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
21805 [ $mdt_index == 1 ] || error "a is not on MDT1"
21807 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
21808 [ $mdt_index == 1 ] || error "b is not on MDT1"
21810 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
21811 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
21813 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
21815 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21817 run_test 230e "migrate mulitple local link files"
21820 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21821 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21822 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21823 skip "Need MDS version at least 2.11.52"
21828 mkdir -p $DIR/$tdir
21829 mkdir $DIR/$tdir/migrate_dir
21830 $LFS mkdir -i1 $DIR/$tdir/other_dir
21831 touch $DIR/$tdir/migrate_dir/a
21832 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
21833 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
21834 ls $DIR/$tdir/other_dir
21836 # a should be migrated to MDT1, since no other links on MDT0
21837 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
21838 error "#1 migrate dir fails"
21839 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
21840 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
21841 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
21842 [ $mdt_index == 1 ] || error "a is not on MDT1"
21844 # a should stay on MDT1, because it is a mulitple link file
21845 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
21846 error "#2 migrate dir fails"
21847 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
21848 [ $mdt_index == 1 ] || error "a is not on MDT1"
21850 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
21851 error "#3 migrate dir fails"
21853 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
21854 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
21855 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
21857 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
21858 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
21860 # a should be migrated to MDT0, since no other links on MDT1
21861 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
21862 error "#4 migrate dir fails"
21863 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
21864 [ $mdt_index == 0 ] || error "a is not on MDT0"
21866 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21868 run_test 230f "migrate mulitple remote link files"
21871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21872 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21873 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21874 skip "Need MDS version at least 2.11.52"
21876 mkdir -p $DIR/$tdir/migrate_dir
21878 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
21879 error "migrating dir to non-exist MDT succeeds"
21882 run_test 230g "migrate dir to non-exist MDT"
21885 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21886 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21887 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21888 skip "Need MDS version at least 2.11.52"
21892 mkdir -p $DIR/$tdir/migrate_dir
21894 $LFS migrate -m1 $DIR &&
21895 error "migrating mountpoint1 should fail"
21897 $LFS migrate -m1 $DIR/$tdir/.. &&
21898 error "migrating mountpoint2 should fail"
21901 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
21902 error "migrating $tdir/migrate_dir/.. should fail"
21906 run_test 230h "migrate .. and root"
21909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21910 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21911 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21912 skip "Need MDS version at least 2.11.52"
21914 mkdir -p $DIR/$tdir/migrate_dir
21916 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
21917 error "migration fails with a tailing slash"
21919 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
21920 error "migration fails with two tailing slashes"
21922 run_test 230i "lfs migrate -m tolerates trailing slashes"
21925 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21926 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
21927 skip "Need MDS version at least 2.11.52"
21929 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
21930 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
21931 error "create $tfile failed"
21932 cat /etc/passwd > $DIR/$tdir/$tfile
21934 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
21936 cmp /etc/passwd $DIR/$tdir/$tfile ||
21937 error "DoM file mismatch after migration"
21939 run_test 230j "DoM file data not changed after dir migration"
21942 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
21943 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
21944 skip "Need MDS version at least 2.11.56"
21947 local files_on_starting_mdt=0
21949 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
21950 $LFS getdirstripe $DIR/$tdir
21951 for i in $(seq $total); do
21952 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
21953 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
21954 files_on_starting_mdt=$((files_on_starting_mdt + 1))
21957 echo "$files_on_starting_mdt files on MDT0"
21959 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
21960 $LFS getdirstripe $DIR/$tdir
21962 files_on_starting_mdt=0
21963 for i in $(seq $total); do
21964 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
21965 error "file $tfile.$i mismatch after migration"
21966 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
21967 files_on_starting_mdt=$((files_on_starting_mdt + 1))
21970 echo "$files_on_starting_mdt files on MDT1 after migration"
21971 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
21973 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
21974 $LFS getdirstripe $DIR/$tdir
21976 files_on_starting_mdt=0
21977 for i in $(seq $total); do
21978 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
21979 error "file $tfile.$i mismatch after 2nd migration"
21980 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
21981 files_on_starting_mdt=$((files_on_starting_mdt + 1))
21984 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
21985 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
21989 run_test 230k "file data not changed after dir migration"
21992 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21993 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
21994 skip "Need MDS version at least 2.11.56"
21996 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
21997 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
21998 error "create files under remote dir failed $i"
21999 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
22001 run_test 230l "readdir between MDTs won't crash"
22004 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22005 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22006 skip "Need MDS version at least 2.11.56"
22009 local mig_dir=$DIR/$tdir/migrate_dir
22010 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
22014 echo "Creating files and dirs with xattrs"
22015 test_mkdir $DIR/$tdir
22016 test_mkdir -i0 -c1 $mig_dir
22018 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
22019 error "cannot set xattr attr1 on dir"
22020 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
22021 error "cannot set xattr attr2 on dir"
22022 touch $mig_dir/dir/f0
22023 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
22024 error "cannot set xattr attr1 on file"
22025 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
22026 error "cannot set xattr attr2 on file"
22027 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
22028 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
22029 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
22030 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
22031 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
22032 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
22033 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
22034 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
22035 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
22037 echo "Migrating to MDT1"
22038 $LFS migrate -m $MDTIDX $mig_dir ||
22039 error "fails on migrating dir to MDT1"
22041 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
22042 echo "Checking xattrs"
22043 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
22044 [ "$val" = $longstr ] ||
22045 error "expecting xattr1 $longstr on dir, found $val"
22046 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
22047 [ "$val" = $shortstr ] ||
22048 error "expecting xattr2 $shortstr on dir, found $val"
22049 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
22050 [ "$val" = $longstr ] ||
22051 error "expecting xattr1 $longstr on file, found $val"
22052 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
22053 [ "$val" = $shortstr ] ||
22054 error "expecting xattr2 $shortstr on file, found $val"
22056 run_test 230m "xattrs not changed after dir migration"
22059 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22060 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
22061 skip "Need MDS version at least 2.13.53"
22063 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
22064 cat /etc/hosts > $DIR/$tdir/$tfile
22065 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
22066 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
22068 cmp /etc/hosts $DIR/$tdir/$tfile ||
22069 error "File data mismatch after migration"
22071 run_test 230n "Dir migration with mirrored file"
22074 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
22075 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
22076 skip "Need MDS version at least 2.13.52"
22078 local mdts=$(comma_list $(mdts_nodes))
22080 local restripe_status
22084 [[ $mds1_FSTYPE == zfs ]] && timeout=300
22086 # in case "crush" hash type is not set
22087 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
22089 restripe_status=$(do_facet mds1 $LCTL get_param -n \
22090 mdt.*MDT0000.enable_dir_restripe)
22091 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
22092 stack_trap "do_nodes $mdts $LCTL set_param \
22093 mdt.*.enable_dir_restripe=$restripe_status"
22096 createmany -m $DIR/$tdir/f 100 ||
22097 error "create files under remote dir failed $i"
22098 createmany -d $DIR/$tdir/d 100 ||
22099 error "create dirs under remote dir failed $i"
22101 for i in $(seq 2 $MDSCOUNT); do
22102 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
22103 $LFS setdirstripe -c $i $DIR/$tdir ||
22104 error "split -c $i $tdir failed"
22105 wait_update $HOSTNAME \
22106 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
22107 error "dir split not finished"
22108 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
22109 awk '/migrate/ {sum += $2} END { print sum }')
22110 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
22111 # delta is around total_files/stripe_count
22112 (( $delta < 200 / (i - 1) + 4 )) ||
22113 error "$delta files migrated >= $((200 / (i - 1) + 4))"
22116 run_test 230o "dir split"
22119 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22120 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
22121 skip "Need MDS version at least 2.13.52"
22123 local mdts=$(comma_list $(mdts_nodes))
22125 local restripe_status
22129 [[ $mds1_FSTYPE == zfs ]] && timeout=300
22131 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
22133 restripe_status=$(do_facet mds1 $LCTL get_param -n \
22134 mdt.*MDT0000.enable_dir_restripe)
22135 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
22136 stack_trap "do_nodes $mdts $LCTL set_param \
22137 mdt.*.enable_dir_restripe=$restripe_status"
22139 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
22140 createmany -m $DIR/$tdir/f 100 ||
22141 error "create files under remote dir failed"
22142 createmany -d $DIR/$tdir/d 100 ||
22143 error "create dirs under remote dir failed"
22145 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
22146 local mdt_hash="crush"
22148 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
22149 $LFS setdirstripe -c $c $DIR/$tdir ||
22150 error "split -c $c $tdir failed"
22151 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
22152 mdt_hash="$mdt_hash,fixed"
22153 elif [ $c -eq 1 ]; then
22156 wait_update $HOSTNAME \
22157 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
22158 error "dir merge not finished"
22159 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
22160 awk '/migrate/ {sum += $2} END { print sum }')
22161 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
22162 # delta is around total_files/stripe_count
22163 (( delta < 200 / c + 4 )) ||
22164 error "$delta files migrated >= $((200 / c + 4))"
22167 run_test 230p "dir merge"
22170 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
22171 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
22172 skip "Need MDS version at least 2.13.52"
22174 local mdts=$(comma_list $(mdts_nodes))
22175 local saved_threshold=$(do_facet mds1 \
22176 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
22177 local saved_delta=$(do_facet mds1 \
22178 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
22179 local threshold=100
22182 local stripe_count=0
22187 # test with fewer files on ZFS
22188 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
22190 stack_trap "do_nodes $mdts $LCTL set_param \
22191 mdt.*.dir_split_count=$saved_threshold"
22192 stack_trap "do_nodes $mdts $LCTL set_param \
22193 mdt.*.dir_split_delta=$saved_delta"
22194 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
22195 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
22196 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
22197 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
22198 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
22199 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
22201 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
22202 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
22204 create=$((threshold * 3 / 2))
22205 while [ $stripe_count -lt $MDSCOUNT ]; do
22206 createmany -m $DIR/$tdir/f $total $create ||
22207 error "create sub files failed"
22208 stat $DIR/$tdir > /dev/null
22209 total=$((total + create))
22210 stripe_count=$((stripe_count + delta))
22211 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
22213 wait_update $HOSTNAME \
22214 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
22215 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
22217 wait_update $HOSTNAME \
22218 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
22219 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
22221 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
22222 echo "$nr_files/$total files on MDT$stripe_index after split"
22223 # allow 10% margin of imbalance with crush hash
22224 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
22225 error "$nr_files files on MDT$stripe_index after split"
22227 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
22228 [ $nr_files -eq $total ] ||
22229 error "total sub files $nr_files != $total"
22232 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
22234 echo "fixed layout directory won't auto split"
22235 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
22236 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
22237 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
22238 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
22239 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
22241 run_test 230q "dir auto split"
22244 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
22245 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
22246 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
22247 skip "Need MDS version at least 2.13.54"
22249 # maximum amount of local locks:
22250 # parent striped dir - 2 locks
22251 # new stripe in parent to migrate to - 1 lock
22252 # source and target - 2 locks
22253 # Total 5 locks for regular file
22254 mkdir -p $DIR/$tdir
22255 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
22256 touch $DIR/$tdir/dir1/eee
22258 # create 4 hardlink for 4 more locks
22259 # Total: 9 locks > RS_MAX_LOCKS (8)
22260 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
22261 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
22262 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
22263 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
22264 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
22265 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
22266 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
22267 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
22269 cancel_lru_locks mdc
22271 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
22272 error "migrate dir fails"
22274 rm -rf $DIR/$tdir || error "rm dir failed after migration"
22276 run_test 230r "migrate with too many local locks"
22279 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
22280 skip "Need MDS version at least 2.14.52"
22282 local mdts=$(comma_list $(mdts_nodes))
22283 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
22284 mdt.*MDT0000.enable_dir_restripe)
22286 stack_trap "do_nodes $mdts $LCTL set_param \
22287 mdt.*.enable_dir_restripe=$restripe_status"
22291 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
22292 test_mkdir $DIR/$tdir
22293 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
22294 error "$LFS mkdir should return EEXIST if target exists"
22298 run_test 230s "lfs mkdir should return -EEXIST if target exists"
22302 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
22303 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
22304 skip "Need MDS version at least 2.14.50"
22306 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
22307 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
22308 $LFS project -p 1 -s $DIR/$tdir ||
22309 error "set $tdir project id failed"
22310 $LFS project -p 2 -s $DIR/$tdir/subdir ||
22311 error "set subdir project id failed"
22312 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
22314 run_test 230t "migrate directory with project ID set"
22318 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
22319 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
22320 skip "Need MDS version at least 2.14.53"
22324 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
22325 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
22326 $LFS migrate -m -1 $DIR/$tdir/sub{0..99} || error "migrate sub failed"
22327 for i in $(seq 0 $((MDSCOUNT - 1))); do
22328 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
22329 echo "$count dirs migrated to MDT$i"
22331 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
22332 (( count >= MDSCOUNT - 1 )) || error "dirs migrated to $count MDTs"
22334 run_test 230u "migrate directory by QOS"
22338 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
22339 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
22340 skip "Need MDS version at least 2.14.53"
22344 mkdir $DIR/$tdir || error "mkdir $tdir failed"
22345 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
22346 $LFS migrate -m 0,2,1 $DIR/$tdir || error "migrate $tdir failed"
22347 for i in $(seq 0 $((MDSCOUNT - 1))); do
22348 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
22349 echo "$count subdirs migrated to MDT$i"
22350 (( i == 3 )) && (( count > 0 )) &&
22351 error "subdir shouldn't be migrated to MDT3"
22353 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
22354 (( count == 3 )) || error "dirs migrated to $count MDTs"
22356 run_test 230v "subdir migrated to the MDT where its parent is located"
22359 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22360 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
22361 skip "Need MDS version at least 2.15.0"
22363 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
22364 createmany -o $DIR/$tdir/f 10 || error "create files failed"
22365 createmany -d $DIR/$tdir/d 10 || error "create dirs failed"
22367 $LFS migrate -m 1 -c $MDSCOUNT -d $DIR/$tdir ||
22368 error "migrate failed"
22370 (( $($LFS getdirstripe -c $DIR/$tdir) == MDSCOUNT )) ||
22371 error "$tdir stripe count mismatch"
22373 for i in $(seq 0 9); do
22374 (( $($LFS getdirstripe -c $DIR/$tdir/d$i) == 0 )) ||
22375 error "d$i is striped"
22378 run_test 230w "non-recursive mode dir migration"
22381 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22382 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
22383 skip "Need MDS version at least 2.15.0"
22385 mkdir -p $DIR/$tdir || error "mkdir failed"
22386 createmany -d $DIR/$tdir/sub 100 || error "createmany failed"
22388 local mdt_name=$(mdtname_from_index 0)
22389 local low=$(do_facet mds2 $LCTL get_param -n \
22390 osp.*$mdt_name-osp-MDT0001.reserved_ino_low)
22391 local high=$(do_facet mds2 $LCTL get_param -n \
22392 osp.*$mdt_name-osp-MDT0001.reserved_ino_high)
22393 local ffree=$($LFS df -i $MOUNT | awk "/$mdt_name/ { print \$4 }")
22394 local maxage=$(do_facet mds2 $LCTL get_param -n \
22395 osp.*$mdt_name-osp-MDT0001.maxage)
22397 stack_trap "do_facet mds2 $LCTL set_param -n \
22398 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low \
22399 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high" EXIT
22400 stack_trap "do_facet mds2 $LCTL set_param -n \
22401 osp.*$mdt_name-osp-MDT0001.maxage=$maxage" EXIT
22403 do_facet mds2 $LCTL set_param -n \
22404 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$((ffree + 1))
22405 do_facet mds2 $LCTL set_param -n osp.*$mdt_name-osp-MDT0001.maxage=1
22407 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir &&
22408 error "migrate $tdir should fail"
22410 do_facet mds2 $LCTL set_param -n \
22411 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low
22412 do_facet mds2 $LCTL set_param -n \
22413 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high
22415 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir ||
22416 error "migrate failed"
22417 (( $($LFS getdirstripe -c $DIR/$tdir) == $MDSCOUNT )) ||
22418 error "$tdir stripe count mismatch"
22420 run_test 230x "dir migration check space"
22423 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22424 (( MDS1_VERSION >= $(version_code 2.15.55.45) )) ||
22425 skip "Need MDS version at least 2.15.55.45"
22429 test_mkdir -c -1 $DIR/$tdir || error "mkdir $tdir failed"
22430 $LFS getdirstripe $DIR/$tdir
22431 createmany -d $DIR/$tdir/d 100 || error "createmany failed"
22432 $LFS migrate -m 1 -c 2 $DIR/$tdir &
22436 #OBD_FAIL_MIGRATE_BAD_HASH 0x1802
22437 do_facet mds2 lctl set_param fail_loc=0x1802
22440 do_facet mds2 lctl set_param fail_loc=0
22441 $LFS getdirstripe $DIR/$tdir
22442 unlinkmany -d $DIR/$tdir/d 100 || error "unlinkmany failed"
22443 rmdir $DIR/$tdir || error "rmdir $tdir failed"
22445 run_test 230y "unlink dir with bad hash type"
22448 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22449 (( MDS1_VERSION >= $(version_code 2.15.55.45) )) ||
22450 skip "Need MDS version at least 2.15.55.45"
22454 test_mkdir -c -1 $DIR/$tdir || error "mkdir $tdir failed"
22455 $LFS getdirstripe $DIR/$tdir
22456 createmany -d $DIR/$tdir/d 100 || error "createmany failed"
22457 $LFS migrate -m 1 -c 2 -H fnv_1a_64 $DIR/$tdir &
22461 #OBD_FAIL_MIGRATE_BAD_HASH 0x1802
22462 do_facet mds2 lctl set_param fail_loc=0x1802
22465 do_facet mds2 lctl set_param fail_loc=0
22466 $LFS getdirstripe $DIR/$tdir
22469 $LFS migrate -m 1 -c 2 -H fnv_1a_64 $DIR/$tdir ||
22470 error "resume migration failed"
22471 $LFS getdirstripe $DIR/$tdir
22472 [ $($LFS getdirstripe -H $DIR/$tdir) == "fnv_1a_64,fixed" ] ||
22473 error "migration is not finished"
22475 run_test 230z "resume dir migration with bad hash type"
22479 # For simplicity this test assumes that max_pages_per_rpc
22480 # is the same across all OSCs
22481 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
22482 local bulk_size=$((max_pages * PAGE_SIZE))
22483 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
22486 mkdir -p $DIR/$tdir
22487 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
22488 error "failed to set stripe with -S ${brw_size}M option"
22489 stack_trap "rm -rf $DIR/$tdir"
22491 # clear the OSC stats
22492 $LCTL set_param osc.*.stats=0 &>/dev/null
22495 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
22496 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
22497 oflag=direct &>/dev/null || error "dd failed"
22499 sync; sleep 1; sync # just to be safe
22500 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
22501 if [ x$nrpcs != "x1" ]; then
22502 $LCTL get_param osc.*.stats
22503 error "found $nrpcs ost_write RPCs, not 1 as expected"
22507 # Drop the OSC cache, otherwise we will read from it
22508 cancel_lru_locks osc
22510 # clear the OSC stats
22511 $LCTL set_param osc.*.stats=0 &>/dev/null
22513 # Client reads $bulk_size.
22514 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
22515 iflag=direct &>/dev/null || error "dd failed"
22517 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
22518 if [ x$nrpcs != "x1" ]; then
22519 $LCTL get_param osc.*.stats
22520 error "found $nrpcs ost_read RPCs, not 1 as expected"
22523 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
22526 mkdir -p $DIR/$tdir
22527 stack_trap "rm -rf $DIR/$tdir"
22529 for i in {0..1023}; do
22530 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
22531 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
22532 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
22536 run_test 231b "must not assert on fully utilized OST request buffer"
22539 mkdir -p $DIR/$tdir
22540 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
22542 #define OBD_FAIL_LDLM_OST_LVB 0x31c
22543 do_facet ost1 $LCTL set_param fail_loc=0x31c
22545 # ignore dd failure
22546 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
22547 stack_trap "rm -f $DIR/$tdir/$tfile"
22549 do_facet ost1 $LCTL set_param fail_loc=0
22550 umount_client $MOUNT || error "umount failed"
22551 mount_client $MOUNT || error "mount failed"
22552 stop ost1 || error "cannot stop ost1"
22553 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22555 run_test 232a "failed lock should not block umount"
22558 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
22559 skip "Need MDS version at least 2.10.58"
22561 mkdir -p $DIR/$tdir
22562 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
22563 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
22564 stack_trap "rm -f $DIR/$tdir/$tfile"
22566 cancel_lru_locks osc
22568 #define OBD_FAIL_LDLM_OST_LVB 0x31c
22569 do_facet ost1 $LCTL set_param fail_loc=0x31c
22572 $LFS data_version $DIR/$tdir/$tfile || true
22574 do_facet ost1 $LCTL set_param fail_loc=0
22575 umount_client $MOUNT || error "umount failed"
22576 mount_client $MOUNT || error "mount failed"
22577 stop ost1 || error "cannot stop ost1"
22578 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22580 run_test 232b "failed data version lock should not block umount"
22583 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
22584 skip "Need MDS version at least 2.3.64"
22585 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
22587 local fid=$($LFS path2fid $MOUNT)
22589 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
22590 error "cannot access $MOUNT using its FID '$fid'"
22592 run_test 233a "checking that OBF of the FS root succeeds"
22595 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
22596 skip "Need MDS version at least 2.5.90"
22597 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
22599 local fid=$($LFS path2fid $MOUNT/.lustre)
22601 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
22602 error "cannot access $MOUNT/.lustre using its FID '$fid'"
22604 fid=$($LFS path2fid $MOUNT/.lustre/fid)
22605 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
22606 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
22608 run_test 233b "checking that OBF of the FS .lustre succeeds"
22611 local p="$TMP/sanityN-$TESTNAME.parameters"
22612 save_lustre_params client "llite.*.xattr_cache" > $p
22613 lctl set_param llite.*.xattr_cache 1 ||
22614 skip_env "xattr cache is not supported"
22616 mkdir -p $DIR/$tdir || error "mkdir failed"
22617 touch $DIR/$tdir/$tfile || error "touch failed"
22618 # OBD_FAIL_LLITE_XATTR_ENOMEM
22619 $LCTL set_param fail_loc=0x1405
22620 getfattr -n user.attr $DIR/$tdir/$tfile &&
22621 error "getfattr should have failed with ENOMEM"
22622 $LCTL set_param fail_loc=0x0
22625 restore_lustre_params < $p
22628 run_test 234 "xattr cache should not crash on ENOMEM"
22631 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
22632 skip "Need MDS version at least 2.4.52"
22634 flock_deadlock $DIR/$tfile
22639 124) error "process hangs on a deadlock"
22641 *) error "error executing flock_deadlock $DIR/$tfile"
22645 run_test 235 "LU-1715: flock deadlock detection does not work properly"
22649 check_swap_layouts_support
22651 local ref1=/etc/passwd
22652 local ref2=/etc/group
22653 local file1=$DIR/$tdir/f1
22654 local file2=$DIR/$tdir/f2
22656 test_mkdir -c1 $DIR/$tdir
22657 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
22658 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
22659 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
22660 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
22661 local fd=$(free_fd)
22662 local cmd="exec $fd<>$file2"
22665 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
22666 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
22669 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
22674 run_test 236 "Layout swap on open unlinked file"
22676 # LU-4659 linkea consistency
22678 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
22679 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
22680 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
22681 skip "Need MDS version at least 2.5.58 or 2.5.2+"
22684 ln $DIR/$tfile $DIR/$tfile.lnk
22685 touch $DIR/$tfile.new
22686 mv $DIR/$tfile.new $DIR/$tfile
22687 local fid1=$($LFS path2fid $DIR/$tfile)
22688 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
22689 local path1=$($LFS fid2path $FSNAME "$fid1")
22690 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
22691 local path2=$($LFS fid2path $FSNAME "$fid2")
22692 [ $tfile.lnk == $path2 ] ||
22693 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
22696 run_test 238 "Verify linkea consistency"
22698 test_239A() { # was test_239
22699 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
22700 skip "Need MDS version at least 2.5.60"
22702 local list=$(comma_list $(mdts_nodes))
22704 mkdir -p $DIR/$tdir
22705 createmany -o $DIR/$tdir/f- 5000
22706 unlinkmany $DIR/$tdir/f- 5000
22707 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
22708 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
22709 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
22710 osp.*MDT*.sync_in_flight" | calc_sum)
22711 [ "$changes" -eq 0 ] || error "$changes not synced"
22713 run_test 239A "osp_sync test"
22715 test_239a() { #LU-5297
22716 remote_mds_nodsh && skip "remote MDS with nodsh"
22719 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
22720 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
22721 chgrp $RUNAS_GID $DIR/$tfile
22722 wait_delete_completed
22724 run_test 239a "process invalid osp sync record correctly"
22726 test_239b() { #LU-5297
22727 remote_mds_nodsh && skip "remote MDS with nodsh"
22730 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
22731 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
22732 chgrp $RUNAS_GID $DIR/$tfile1
22733 wait_delete_completed
22734 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
22736 chgrp $RUNAS_GID $DIR/$tfile2
22737 wait_delete_completed
22739 run_test 239b "process osp sync record with ENOMEM error correctly"
22742 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22743 remote_mds_nodsh && skip "remote MDS with nodsh"
22745 mkdir -p $DIR/$tdir
22747 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
22748 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
22749 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
22750 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
22752 umount_client $MOUNT || error "umount failed"
22753 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
22754 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
22755 mount_client $MOUNT || error "failed to mount client"
22757 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
22758 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
22760 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
22766 for LOOP in $(seq $count); do
22767 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
22768 cancel_lru_locks $OSC || true
22776 for LOOP in $(seq $1); do
22777 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
22782 test_241a() { # was test_241
22783 local bsize=$PAGE_SIZE
22785 (( bsize < 40960 )) && bsize=40960
22786 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
22788 cancel_lru_locks $OSC
22789 test_241_bio 1000 $bsize &
22791 test_241_dio 1000 $bsize
22794 run_test 241a "bio vs dio"
22797 local bsize=$PAGE_SIZE
22799 (( bsize < 40960 )) && bsize=40960
22800 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
22802 test_241_dio 1000 $bsize &
22804 test_241_dio 1000 $bsize
22807 run_test 241b "dio vs dio"
22810 remote_mds_nodsh && skip "remote MDS with nodsh"
22812 mkdir_on_mdt0 $DIR/$tdir
22813 touch $DIR/$tdir/$tfile
22815 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
22816 do_facet mds1 lctl set_param fail_loc=0x105
22817 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
22819 do_facet mds1 lctl set_param fail_loc=0
22820 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
22822 run_test 242 "mdt_readpage failure should not cause directory unreadable"
22826 test_mkdir $DIR/$tdir
22827 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
22829 run_test 243 "various group lock tests"
22833 test_mkdir $DIR/$tdir
22834 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
22835 sendfile_grouplock $DIR/$tdir/$tfile || \
22836 error "sendfile+grouplock failed"
22839 run_test 244a "sendfile with group lock tests"
22843 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
22846 local size=$((1024*1024))
22848 test_mkdir $DIR/$tdir
22849 for i in $(seq 1 $threads); do
22850 local file=$DIR/$tdir/file_$((i / 10))
22851 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
22854 for i in $(seq 1 $threads); do
22858 run_test 244b "multi-threaded write with group lock"
22861 local flagname="multi_mod_rpcs"
22862 local connect_data_name="max_mod_rpcs"
22865 # check if multiple modify RPCs flag is set
22866 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
22867 grep "connect_flags:")
22870 echo "$out" | grep -qw $flagname
22871 if [ $? -ne 0 ]; then
22872 echo "connect flag $flagname is not set"
22876 # check if multiple modify RPCs data is set
22877 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
22880 echo "$out" | grep -qw $connect_data_name ||
22881 error "import should have connect data $connect_data_name"
22883 run_test 245a "check mdc connection flag/data: multiple modify RPCs"
22886 local flagname="multi_mod_rpcs"
22887 local connect_data_name="max_mod_rpcs"
22890 remote_mds_nodsh && skip "remote MDS with nodsh"
22891 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
22893 # check if multiple modify RPCs flag is set
22894 out=$(do_facet mds1 \
22895 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import |
22896 grep "connect_flags:")
22899 [[ "$out" =~ $flagname ]] || skip "connect flag $flagname is not set"
22901 # check if multiple modify RPCs data is set
22902 out=$(do_facet mds1 \
22903 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import)
22905 [[ "$out" =~ $connect_data_name ]] ||
22908 error "missing connect data $connect_data_name"
22911 run_test 245b "check osp connection flag/data: multiple modify RPCs"
22917 umount_client $submount
22922 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
22924 skip_env "Fileset feature is not supported"
22926 local submount=${MOUNT}_$tdir
22929 mkdir -p $submount || error "mkdir $submount failed"
22930 FILESET="$FILESET/$tdir" mount_client $submount ||
22931 error "mount $submount failed"
22932 trap "cleanup_247 $submount" EXIT
22933 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
22934 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
22935 error "read $MOUNT/$tdir/$tfile failed"
22936 cleanup_247 $submount
22938 run_test 247a "mount subdir as fileset"
22941 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
22942 skip_env "Fileset feature is not supported"
22944 local submount=${MOUNT}_$tdir
22946 rm -rf $MOUNT/$tdir
22947 mkdir -p $submount || error "mkdir $submount failed"
22949 FILESET="$FILESET/$tdir" mount_client $submount &&
22950 error "mount $submount should fail"
22953 run_test 247b "mount subdir that dose not exist"
22956 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
22957 skip_env "Fileset feature is not supported"
22959 local submount=${MOUNT}_$tdir
22961 mkdir -p $MOUNT/$tdir/dir1
22962 mkdir -p $submount || error "mkdir $submount failed"
22963 trap "cleanup_247 $submount" EXIT
22964 FILESET="$FILESET/$tdir" mount_client $submount ||
22965 error "mount $submount failed"
22966 local fid=$($LFS path2fid $MOUNT/)
22967 $LFS fid2path $submount $fid && error "fid2path should fail"
22968 cleanup_247 $submount
22970 run_test 247c "running fid2path outside subdirectory root"
22973 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
22974 skip "Fileset feature is not supported"
22976 local submount=${MOUNT}_$tdir
22978 mkdir -p $MOUNT/$tdir/dir1
22979 mkdir -p $submount || error "mkdir $submount failed"
22980 FILESET="$FILESET/$tdir" mount_client $submount ||
22981 error "mount $submount failed"
22982 trap "cleanup_247 $submount" EXIT
22984 local td=$submount/dir1
22985 local fid=$($LFS path2fid $td)
22986 [ -z "$fid" ] && error "path2fid unable to get $td FID"
22988 # check that we get the same pathname back
22991 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
22992 echo "$rootpath $fid"
22993 found=$($LFS fid2path $rootpath "$fid")
22994 [ -n "$found" ] || error "fid2path should succeed"
22995 [ "$found" == "$td" ] || error "fid2path $found != $td"
22997 # check wrong root path format
22998 rootpath=$submount"_wrong"
22999 found=$($LFS fid2path $rootpath "$fid")
23000 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
23002 cleanup_247 $submount
23004 run_test 247d "running fid2path inside subdirectory root"
23008 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
23010 skip "Fileset feature is not supported"
23012 local submount=${MOUNT}_$tdir
23015 mkdir -p $submount || error "mkdir $submount failed"
23016 FILESET="$FILESET/.." mount_client $submount &&
23017 error "mount $submount should fail"
23020 run_test 247e "mount .. as fileset"
23023 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
23024 (( $MDS1_VERSION >= $(version_code 2.14.50.162) )) ||
23025 skip "Need at least version 2.14.50.162"
23026 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
23027 skip "Fileset feature is not supported"
23029 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
23030 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
23031 error "mkdir remote failed"
23032 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
23033 error "mkdir remote/subdir failed"
23034 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
23035 error "mkdir striped failed"
23036 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
23038 local submount=${MOUNT}_$tdir
23040 mkdir -p $submount || error "mkdir $submount failed"
23041 stack_trap "rmdir $submount"
23044 local fileset=$FILESET
23045 local mdts=$(comma_list $(mdts_nodes))
23047 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
23048 for dir in $tdir/remote $tdir/remote/subdir $tdir/striped \
23049 $tdir/striped/subdir $tdir/striped/.; do
23050 FILESET="$fileset/$dir" mount_client $submount ||
23051 error "mount $dir failed"
23052 umount_client $submount
23055 run_test 247f "mount striped or remote directory as fileset"
23057 test_subdir_mount_lock()
23060 local submount=${MOUNT}_$(basename $testdir)
23062 touch $DIR/$testdir/$tfile || error "touch $tfile failed"
23064 mkdir -p $submount || error "mkdir $submount failed"
23065 stack_trap "rmdir $submount"
23067 FILESET="$fileset/$testdir" mount_client $submount ||
23068 error "mount $FILESET failed"
23069 stack_trap "umount $submount"
23071 local mdts=$(comma_list $(mdts_nodes))
23075 stat $submount > /dev/null || error "stat $submount failed"
23076 cancel_lru_locks $MDC
23077 stat $submount > /dev/null || error "stat $submount failed"
23078 stat $submount/$tfile > /dev/null || error "stat $tfile failed"
23079 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
23080 stat $submount/$tfile > /dev/null || error "stat $tfile failed"
23081 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
23082 awk '/getattr/ {sum += $2} END {print sum}')
23084 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
23088 (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
23090 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
23091 error "mkdir $tdir failed"
23092 test_subdir_mount_lock $tdir
23094 run_test 247g "striped directory submount revalidate ROOT from cache"
23097 (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
23098 (( $MDS1_VERSION >= $(version_code 2.15.51) )) ||
23099 skip "Need MDS version at least 2.15.51"
23101 $LFS mkdir -i 1 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
23102 test_subdir_mount_lock $tdir
23103 mkdir_on_mdt -i 0 $DIR/$tdir/$tdir.0 || error "mkdir $tdir.0 failed"
23104 mkdir_on_mdt -i 1 $DIR/$tdir/$tdir.0/$tdir.1 ||
23105 error "mkdir $tdir.1 failed"
23106 test_subdir_mount_lock $tdir/$tdir.0/$tdir.1
23108 run_test 247h "remote directory submount revalidate ROOT from cache"
23111 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
23112 [ -z "$fast_read_sav" ] && skip "no fast read support"
23114 # create a large file for fast read verification
23115 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
23117 # make sure the file is created correctly
23118 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
23119 { rm -f $DIR/$tfile; skip "file creation error"; }
23121 echo "Test 1: verify that fast read is 4 times faster on cache read"
23123 # small read with fast read enabled
23124 $LCTL set_param -n llite.*.fast_read=1
23125 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
23126 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23127 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23128 # small read with fast read disabled
23129 $LCTL set_param -n llite.*.fast_read=0
23130 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
23131 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23132 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23134 # verify that fast read is 4 times faster for cache read
23135 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
23136 error_not_in_vm "fast read was not 4 times faster: " \
23137 "$t_fast vs $t_slow"
23139 echo "Test 2: verify the performance between big and small read"
23140 $LCTL set_param -n llite.*.fast_read=1
23142 # 1k non-cache read
23143 cancel_lru_locks osc
23144 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
23145 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23146 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23148 # 1M non-cache read
23149 cancel_lru_locks osc
23150 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
23151 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23152 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23154 # verify that big IO is not 4 times faster than small IO
23155 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
23156 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
23158 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
23161 run_test 248a "fast read verification"
23164 # Default short_io_bytes=16384, try both smaller and larger sizes.
23165 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
23166 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
23167 echo "bs=53248 count=113 normal buffered write"
23168 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
23169 error "dd of initial data file failed"
23170 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
23172 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
23173 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
23174 error "dd with sync normal writes failed"
23175 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
23177 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
23178 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
23179 error "dd with sync small writes failed"
23180 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
23182 cancel_lru_locks osc
23184 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
23185 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
23186 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
23187 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
23188 iflag=direct || error "dd with O_DIRECT small read failed"
23189 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
23190 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
23191 error "compare $TMP/$tfile.1 failed"
23193 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
23194 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
23196 # just to see what the maximum tunable value is, and test parsing
23197 echo "test invalid parameter 2MB"
23198 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
23199 error "too-large short_io_bytes allowed"
23200 echo "test maximum parameter 512KB"
23201 # if we can set a larger short_io_bytes, run test regardless of version
23202 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
23203 # older clients may not allow setting it this large, that's OK
23204 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
23205 skip "Need at least client version 2.13.50"
23206 error "medium short_io_bytes failed"
23208 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
23209 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
23211 echo "test large parameter 64KB"
23212 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
23213 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
23215 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
23216 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
23217 error "dd with sync large writes failed"
23218 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
23220 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
23221 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
23222 num=$((113 * 4096 / PAGE_SIZE))
23223 echo "bs=$size count=$num oflag=direct large write $tfile.3"
23224 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
23225 error "dd with O_DIRECT large writes failed"
23226 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
23227 error "compare $DIR/$tfile.3 failed"
23229 cancel_lru_locks osc
23231 echo "bs=$size count=$num iflag=direct large read $tfile.2"
23232 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
23233 error "dd with O_DIRECT large read failed"
23234 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
23235 error "compare $TMP/$tfile.2 failed"
23237 echo "bs=$size count=$num iflag=direct large read $tfile.3"
23238 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
23239 error "dd with O_DIRECT large read failed"
23240 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
23241 error "compare $TMP/$tfile.3 failed"
23243 run_test 248b "test short_io read and write for both small and large sizes"
23245 test_249() { # LU-7890
23246 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
23247 skip "Need at least version 2.8.54"
23250 $LFS setstripe -c 1 $DIR/$tfile
23251 # Offset 2T == 4k * 512M
23252 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
23253 error "dd to 2T offset failed"
23255 run_test 249 "Write above 2T file size"
23258 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
23259 && skip "no 16TB file size limit on ZFS"
23261 $LFS setstripe -c 1 $DIR/$tfile
23262 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
23263 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
23264 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
23265 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
23266 conv=notrunc,fsync && error "append succeeded"
23269 run_test 250 "Write above 16T limit"
23272 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
23274 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
23275 #Skip once - writing the first stripe will succeed
23276 $LCTL set_param fail_loc=0xa0001407 fail_val=1
23277 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
23278 error "short write happened"
23280 $LCTL set_param fail_loc=0xa0001407 fail_val=1
23281 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
23282 error "short read happened"
23286 run_test 251 "Handling short read and write correctly"
23289 remote_mds_nodsh && skip "remote MDS with nodsh"
23290 remote_ost_nodsh && skip "remote OST with nodsh"
23291 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
23292 skip_env "ldiskfs only test"
23302 # check lr_reader on OST0000
23304 dev=$(facet_device $tgt)
23305 out=$(do_facet $tgt $LR_READER $dev)
23306 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
23308 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
23309 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
23310 error "Invalid uuid returned by $LR_READER on target $tgt"
23311 echo -e "uuid returned by $LR_READER is '$uuid'\n"
23313 # check lr_reader -c on MDT0000
23315 dev=$(facet_device $tgt)
23316 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
23317 skip "$LR_READER does not support additional options"
23319 out=$(do_facet $tgt $LR_READER -c $dev)
23320 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
23322 num=$(echo "$out" | grep -c "mdtlov")
23323 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
23324 error "Invalid number of mdtlov clients returned by $LR_READER"
23325 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
23327 # check lr_reader -cr on MDT0000
23328 out=$(do_facet $tgt $LR_READER -cr $dev)
23329 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
23331 echo "$out" | grep -q "^reply_data:$" ||
23332 error "$LR_READER should have returned 'reply_data' section"
23333 num=$(echo "$out" | grep -c "client_generation")
23334 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
23336 run_test 252 "check lr_reader tool"
23339 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23340 remote_mds_nodsh && skip "remote MDS with nodsh"
23341 remote_mgs_nodsh && skip "remote MGS with nodsh"
23345 local ost_name=$(ostname_from_index $ostidx)
23348 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
23349 do_facet $SINGLEMDS $LCTL get_param -n \
23350 osp.$mdtosc_proc1.reserved_mb_high ||
23351 skip "remote MDS does not support reserved_mb_high"
23355 wait_delete_completed
23357 stack_trap "rm -rf $DIR/$tdir"
23359 pool_add $TESTNAME || error "Pool creation failed"
23360 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
23362 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
23363 error "Setstripe failed"
23365 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
23367 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
23369 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
23371 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
23372 osp.$mdtosc_proc1.prealloc_status)
23373 echo "prealloc_status $oa_status"
23375 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
23376 error "File creation should fail"
23378 #object allocation was stopped, but we still able to append files
23379 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
23380 oflag=append || error "Append failed"
23382 rm -f $DIR/$tdir/$tfile.0
23384 # For this test, we want to delete the files we created to go out of
23385 # space but leave the watermark, so we remain nearly out of space
23386 ost_watermarks_enospc_delete_files $tfile $ostidx
23388 wait_delete_completed
23392 for i in $(seq 10 12); do
23393 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
23394 2>/dev/null || error "File creation failed after rm"
23397 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
23398 osp.$mdtosc_proc1.prealloc_status)
23399 echo "prealloc_status $oa_status"
23401 if (( oa_status != 0 )); then
23402 error "Object allocation still disable after rm"
23405 run_test 253 "Check object allocation limit"
23408 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23409 remote_mds_nodsh && skip "remote MDS with nodsh"
23411 local mdt=$(facet_svc $SINGLEMDS)
23413 do_facet $SINGLEMDS $LCTL get_param -n mdd.$mdt.changelog_size ||
23414 skip "MDS does not support changelog_size"
23418 changelog_register || error "changelog_register failed"
23420 changelog_clear 0 || error "changelog_clear failed"
23422 local size1=$(do_facet $SINGLEMDS \
23423 $LCTL get_param -n mdd.$mdt.changelog_size)
23424 echo "Changelog size $size1"
23427 $LFS mkdir -i 0 $DIR/$tdir
23429 mkdir -p $DIR/$tdir/pics/2008/zachy
23430 touch $DIR/$tdir/pics/2008/zachy/timestamp
23431 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
23432 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
23433 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
23434 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
23435 rm $DIR/$tdir/pics/desktop.jpg
23437 local size2=$(do_facet $SINGLEMDS \
23438 $LCTL get_param -n mdd.$mdt.changelog_size)
23439 echo "Changelog size after work $size2"
23441 (( $size2 > $size1 )) ||
23442 error "new Changelog size=$size2 less than old size=$size1"
23444 run_test 254 "Check changelog size"
23451 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
23452 awk -F: '{print $2}' | grep $type > /dev/null
23453 if [ $? -ne 0 ]; then
23463 lfs ladvise -a willread $file > /dev/null 2>&1
23464 if [ $? -eq 0 ]; then
23468 lfs ladvise -a willread $file 2>&1 |
23469 grep "Inappropriate ioctl for device" > /dev/null
23470 if [ $? -eq 0 ]; then
23477 bc <<<"scale=2; ($1 - $2) * 100 / $2"
23480 # run a random read IO workload
23481 # usage: random_read_iops <filename> <filesize> <iosize>
23482 random_read_iops() {
23485 local iosize=${3:-4096}
23487 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
23488 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
23491 drop_file_oss_cache() {
23495 $LFS ladvise -a dontneed $file 2>/dev/null ||
23496 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
23499 ladvise_willread_performance()
23502 local average_origin=0
23503 local average_cache=0
23504 local average_ladvise=0
23506 for ((i = 1; i <= $repeat; i++)); do
23507 echo "Iter $i/$repeat: reading without willread hint"
23508 cancel_lru_locks osc
23509 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
23510 local speed_origin=$(random_read_iops $DIR/$tfile $size)
23511 echo "Iter $i/$repeat: uncached speed: $speed_origin"
23512 average_origin=$(bc <<<"$average_origin + $speed_origin")
23514 cancel_lru_locks osc
23515 local speed_cache=$(random_read_iops $DIR/$tfile $size)
23516 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
23517 average_cache=$(bc <<<"$average_cache + $speed_cache")
23519 cancel_lru_locks osc
23520 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
23521 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
23522 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
23523 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
23524 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
23526 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
23527 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
23528 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
23530 speedup_cache=$(percent $average_cache $average_origin)
23531 speedup_ladvise=$(percent $average_ladvise $average_origin)
23533 echo "Average uncached read: $average_origin"
23534 echo "Average speedup with OSS cached read: " \
23535 "$average_cache = +$speedup_cache%"
23536 echo "Average speedup with ladvise willread: " \
23537 "$average_ladvise = +$speedup_ladvise%"
23539 local lowest_speedup=20
23540 if (( ${average_cache%.*} < $lowest_speedup )); then
23541 echo "Speedup with OSS cached read less than $lowest_speedup%,"\
23542 " got $average_cache%. Skipping ladvise willread check."
23546 # the test won't work on ZFS until it supports 'ladvise dontneed', but
23547 # it is still good to run until then to exercise 'ladvise willread'
23548 ! $LFS ladvise -a dontneed $DIR/$tfile &&
23549 [ "$ost1_FSTYPE" = "zfs" ] &&
23550 echo "osd-zfs does not support dontneed or drop_caches" &&
23553 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
23554 (( ${average_ladvise%.*} > ${lowest_speedup%.*} )) ||
23555 error_not_in_vm "Speedup with willread is less than " \
23556 "$lowest_speedup%, got $average_ladvise%"
23560 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
23561 skip "lustre < 2.8.54 does not support ladvise "
23562 remote_ost_nodsh && skip "remote OST with nodsh"
23564 stack_trap "rm -f $DIR/$tfile"
23565 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
23567 ladvise_no_type willread $DIR/$tfile &&
23568 skip "willread ladvise is not supported"
23570 ladvise_no_ioctl $DIR/$tfile &&
23571 skip "ladvise ioctl is not supported"
23574 local size=$((size_mb * 1048576))
23575 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
23576 error "dd to $DIR/$tfile failed"
23578 lfs ladvise -a willread $DIR/$tfile ||
23579 error "Ladvise failed with no range argument"
23581 lfs ladvise -a willread -s 0 $DIR/$tfile ||
23582 error "Ladvise failed with no -l or -e argument"
23584 lfs ladvise -a willread -e 1 $DIR/$tfile ||
23585 error "Ladvise failed with only -e argument"
23587 lfs ladvise -a willread -l 1 $DIR/$tfile ||
23588 error "Ladvise failed with only -l argument"
23590 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
23591 error "End offset should not be smaller than start offset"
23593 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
23594 error "End offset should not be equal to start offset"
23596 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
23597 error "Ladvise failed with overflowing -s argument"
23599 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
23600 error "Ladvise failed with overflowing -e argument"
23602 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
23603 error "Ladvise failed with overflowing -l argument"
23605 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
23606 error "Ladvise succeeded with conflicting -l and -e arguments"
23608 echo "Synchronous ladvise should wait"
23610 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
23611 do_nodes $(comma_list $(osts_nodes)) \
23612 $LCTL set_param fail_val=$delay fail_loc=0x237
23613 stack_trap "do_nodes $(comma_list $(osts_nodes)) \
23614 $LCTL set_param fail_loc=0"
23616 local start_ts=$SECONDS
23617 lfs ladvise -a willread $DIR/$tfile ||
23618 error "Ladvise failed with no range argument"
23619 local end_ts=$SECONDS
23620 local inteval_ts=$((end_ts - start_ts))
23622 if [ $inteval_ts -lt $(($delay - 1)) ]; then
23623 error "Synchronous advice didn't wait reply"
23626 echo "Asynchronous ladvise shouldn't wait"
23627 local start_ts=$SECONDS
23628 lfs ladvise -a willread -b $DIR/$tfile ||
23629 error "Ladvise failed with no range argument"
23630 local end_ts=$SECONDS
23631 local inteval_ts=$((end_ts - start_ts))
23633 if [ $inteval_ts -gt $(($delay / 2)) ]; then
23634 error "Asynchronous advice blocked"
23637 ladvise_willread_performance
23639 run_test 255a "check 'lfs ladvise -a willread'"
23645 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
23649 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
23650 skip "lustre < 2.8.54 does not support ladvise "
23651 remote_ost_nodsh && skip "remote OST with nodsh"
23653 stack_trap "rm -f $DIR/$tfile"
23654 lfs setstripe -c 1 -i 0 $DIR/$tfile
23656 ladvise_no_type dontneed $DIR/$tfile &&
23657 skip "dontneed ladvise is not supported"
23659 ladvise_no_ioctl $DIR/$tfile &&
23660 skip "ladvise ioctl is not supported"
23662 ! $LFS ladvise -a dontneed $DIR/$tfile &&
23663 [ "$ost1_FSTYPE" = "zfs" ] &&
23664 skip "zfs-osd does not support 'ladvise dontneed'"
23667 local size=$((size_mb * 1048576))
23668 # In order to prevent disturbance of other processes, only check 3/4
23669 # of the memory usage
23670 local kibibytes=$((size_mb * 1024 * 3 / 4))
23672 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
23673 error "dd to $DIR/$tfile failed"
23675 #force write to complete before dropping OST cache & checking memory
23678 local total=$(facet_meminfo ost1 MemTotal)
23679 echo "Total memory: $total KiB"
23681 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
23682 local before_read=$(facet_meminfo ost1 Cached)
23683 echo "Cache used before read: $before_read KiB"
23685 lfs ladvise -a willread $DIR/$tfile ||
23686 error "Ladvise willread failed"
23687 local after_read=$(facet_meminfo ost1 Cached)
23688 echo "Cache used after read: $after_read KiB"
23690 lfs ladvise -a dontneed $DIR/$tfile ||
23691 error "Ladvise dontneed again failed"
23692 local no_read=$(facet_meminfo ost1 Cached)
23693 echo "Cache used after dontneed ladvise: $no_read KiB"
23695 if [ $total -lt $((before_read + kibibytes)) ]; then
23696 echo "Memory is too small, abort checking"
23700 if [ $((before_read + kibibytes)) -gt $after_read ]; then
23701 error "Ladvise willread should use more memory" \
23702 "than $kibibytes KiB"
23705 if [ $((no_read + kibibytes)) -gt $after_read ]; then
23706 error "Ladvise dontneed should release more memory" \
23707 "than $kibibytes KiB"
23710 run_test 255b "check 'lfs ladvise -a dontneed'"
23713 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
23714 skip "lustre < 2.10.50 does not support lockahead"
23716 local ost1_imp=$(get_osc_import_name client ost1)
23717 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
23725 test_mkdir -p $DIR/$tdir
23726 $LFS setstripe -i 0 -c 1 $DIR/$tdir
23728 #test 10 returns only success/failure
23730 lockahead_test -d $DIR/$tdir -t $i -f $tfile
23732 if [ $rc -eq 255 ]; then
23733 error "Ladvise test${i} failed, ${rc}"
23736 #test 11 counts lock enqueue requests, all others count new locks
23738 count=$(do_facet ost1 \
23739 $LCTL get_param -n ost.OSS.ost.stats)
23740 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
23742 lockahead_test -d $DIR/$tdir -t $i -f $tfile
23744 if [ $rc -eq 255 ]; then
23745 error "Ladvise test${i} failed, ${rc}"
23748 new_count=$(do_facet ost1 \
23749 $LCTL get_param -n ost.OSS.ost.stats)
23750 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
23751 awk '{ print $2 }')
23753 difference="$((new_count - count))"
23754 if [ $difference -ne $rc ]; then
23755 error "Ladvise test${i}, bad enqueue count, returned " \
23756 "${rc}, actual ${difference}"
23759 for i in $(seq 12 21); do
23760 # If we do not do this, we run the risk of having too many
23761 # locks and starting lock cancellation while we are checking
23763 cancel_lru_locks osc
23765 count=$($LCTL get_param -n \
23766 ldlm.namespaces.$imp_name.lock_unused_count)
23768 lockahead_test -d $DIR/$tdir -t $i -f $tfile
23770 if [ $rc -eq 255 ]; then
23771 error "Ladvise test ${i} failed, ${rc}"
23774 new_count=$($LCTL get_param -n \
23775 ldlm.namespaces.$imp_name.lock_unused_count)
23776 difference="$((new_count - count))"
23778 # Test 15 output is divided by 100 to map down to valid return
23779 if [ $i -eq 15 ]; then
23783 if [ $difference -ne $rc ]; then
23784 error "Ladvise test ${i}, bad lock count, returned " \
23785 "${rc}, actual ${difference}"
23789 #test 22 returns only success/failure
23791 lockahead_test -d $DIR/$tdir -t $i -f $tfile
23793 if [ $rc -eq 255 ]; then
23794 error "Ladvise test${i} failed, ${rc}"
23797 run_test 255c "suite of ladvise lockahead tests"
23800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23801 remote_mds_nodsh && skip "remote MDS with nodsh"
23802 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
23803 changelog_users $SINGLEMDS | grep "^cl" &&
23804 skip "active changelog user"
23810 mdt_dev=$(facet_device $SINGLEMDS)
23813 changelog_register || error "changelog_register failed"
23816 mkdir_on_mdt -i$(($(facet_number $SINGLEMDS) - 1)) $DIR/$tdir
23818 changelog_clear 0 || error "changelog_clear failed"
23821 touch $DIR/$tdir/{1..10}
23824 stop $SINGLEMDS || error "Fail to stop MDT"
23827 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
23828 error "Fail to start MDT"
23830 #after mount new plainllog is used
23831 touch $DIR/$tdir/{11..19}
23832 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
23833 stack_trap "rm -f $tmpfile"
23834 cat_sl=$(do_facet $SINGLEMDS "sync; \
23835 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
23836 llog_reader $tmpfile | grep -c type=1064553b")
23837 do_facet $SINGLEMDS llog_reader $tmpfile
23839 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
23841 changelog_clear 0 || error "changelog_clear failed"
23843 cat_sl=$(do_facet $SINGLEMDS "sync; \
23844 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
23845 llog_reader $tmpfile | grep -c type=1064553b")
23847 if (( cat_sl == 2 )); then
23848 error "Empty plain llog was not deleted from changelog catalog"
23849 elif (( cat_sl != 1 )); then
23850 error "Active plain llog shouldn't be deleted from catalog"
23853 run_test 256 "Check llog delete for empty and not full state"
23856 remote_mds_nodsh && skip "remote MDS with nodsh"
23857 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
23858 skip "Need MDS version at least 2.8.55"
23860 test_mkdir $DIR/$tdir
23862 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
23863 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
23866 #define OBD_FAIL_MDS_XATTR_REP 0x161
23867 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
23868 local facet=mds$((mdtidx + 1))
23869 set_nodes_failloc $(facet_active_host $facet) 0x80000161
23870 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
23872 stop $facet || error "stop MDS failed"
23873 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
23874 error "start MDS fail"
23875 wait_recovery_complete $facet
23877 run_test 257 "xattr locks are not lost"
23879 # Verify we take the i_mutex when security requires it
23881 #define OBD_FAIL_IMUTEX_SEC 0x141c
23882 $LCTL set_param fail_loc=0x141c
23884 chmod u+s $DIR/$tfile
23885 chmod a+rwx $DIR/$tfile
23886 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
23888 if [ $RC -ne 0 ]; then
23889 error "error, failed to take i_mutex, rc=$?"
23893 run_test 258a "verify i_mutex security behavior when suid attributes is set"
23895 # Verify we do NOT take the i_mutex in the normal case
23897 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
23898 $LCTL set_param fail_loc=0x141d
23901 chmod a+rw $DIR/$tfile
23902 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
23904 if [ $RC -ne 0 ]; then
23905 error "error, took i_mutex unnecessarily, rc=$?"
23910 run_test 258b "verify i_mutex security behavior"
23913 local file=$DIR/$tfile
23917 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
23919 stack_trap "rm -f $file" EXIT
23921 wait_delete_completed
23922 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
23923 echo "before: $before"
23925 $LFS setstripe -i 0 -c 1 $file
23926 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
23928 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
23929 echo "after write: $after"
23931 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
23932 do_facet ost1 $LCTL set_param fail_loc=0x2301
23934 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
23935 echo "after truncate: $after"
23938 do_facet ost1 $LCTL set_param fail_loc=0
23939 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
23941 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
23942 echo "after restart: $after"
23943 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
23944 error "missing truncate?"
23948 run_test 259 "crash at delayed truncate"
23951 #define OBD_FAIL_MDC_CLOSE 0x806
23952 $LCTL set_param fail_loc=0x80000806
23956 run_test 260 "Check mdc_close fail"
23958 ### Data-on-MDT sanity tests ###
23960 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23961 skip "Need MDS version at least 2.10.55 for DoM"
23964 local dom=$DIR/$tdir/dom_file
23965 local tmp=$DIR/$tdir/tmp_file
23967 mkdir_on_mdt0 $DIR/$tdir
23969 # basic checks for DoM component creation
23970 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
23971 error "Can set MDT layout to non-first entry"
23973 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
23974 error "Can define multiple entries as MDT layout"
23976 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
23978 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
23979 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
23980 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
23982 local mdtidx=$($LFS getstripe -m $dom)
23983 local mdtname=MDT$(printf %04x $mdtidx)
23984 local facet=mds$((mdtidx + 1))
23985 local space_check=1
23987 # Skip free space checks with ZFS
23988 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
23992 local size_tmp=$((65536 * 3))
23993 local mdtfree1=$(do_facet $facet \
23994 lctl get_param -n osd*.*$mdtname.kbytesfree)
23996 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
23997 # check also direct IO along write
23998 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
23999 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
24001 cmp $tmp $dom || error "file data is different"
24002 [ $(stat -c%s $dom) == $size_tmp ] ||
24003 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
24004 if [ $space_check == 1 ]; then
24005 local mdtfree2=$(do_facet $facet \
24006 lctl get_param -n osd*.*$mdtname.kbytesfree)
24008 # increase in usage from by $size_tmp
24009 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
24010 error "MDT free space wrong after write: " \
24011 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
24015 local size_dom=10000
24017 $TRUNCATE $dom $size_dom
24018 [ $(stat -c%s $dom) == $size_dom ] ||
24019 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
24020 if [ $space_check == 1 ]; then
24021 mdtfree1=$(do_facet $facet \
24022 lctl get_param -n osd*.*$mdtname.kbytesfree)
24023 # decrease in usage from $size_tmp to new $size_dom
24024 [ $(($mdtfree1 - $mdtfree2)) -ge \
24025 $(((size_tmp - size_dom) / 1024)) ] ||
24026 error "MDT free space is wrong after truncate: " \
24027 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
24033 size_dom=$((size_dom + size_tmp))
24034 [ $(stat -c%s $dom) == $size_dom ] ||
24035 error "bad size after append: $(stat -c%s $dom) != $size_dom"
24036 if [ $space_check == 1 ]; then
24037 mdtfree2=$(do_facet $facet \
24038 lctl get_param -n osd*.*$mdtname.kbytesfree)
24039 # increase in usage by $size_tmp from previous
24040 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
24041 error "MDT free space is wrong after append: " \
24042 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
24047 if [ $space_check == 1 ]; then
24048 mdtfree1=$(do_facet $facet \
24049 lctl get_param -n osd*.*$mdtname.kbytesfree)
24050 # decrease in usage by $size_dom from previous
24051 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
24052 error "MDT free space is wrong after removal: " \
24053 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
24056 # combined striping
24057 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
24058 error "Can't create DoM + OST striping"
24060 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
24061 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
24062 # check also direct IO along write
24063 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
24065 cmp $tmp $dom || error "file data is different"
24066 [ $(stat -c%s $dom) == $size_tmp ] ||
24067 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
24072 run_test 270a "DoM: basic functionality tests"
24075 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24076 skip "Need MDS version at least 2.10.55"
24078 local dom=$DIR/$tdir/dom_file
24079 local max_size=1048576
24081 mkdir -p $DIR/$tdir
24082 $LFS setstripe -E $max_size -L mdt $dom
24084 # truncate over the limit
24085 $TRUNCATE $dom $(($max_size + 1)) &&
24086 error "successful truncate over the maximum size"
24087 # write over the limit
24088 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
24089 error "successful write over the maximum size"
24090 # append over the limit
24091 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
24092 echo "12345" >> $dom && error "successful append over the maximum size"
24097 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
24100 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24101 skip "Need MDS version at least 2.10.55"
24103 mkdir -p $DIR/$tdir
24104 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24106 # check files inherit DoM EA
24107 touch $DIR/$tdir/first
24108 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
24109 error "bad pattern"
24110 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
24111 error "bad stripe count"
24112 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
24113 error "bad stripe size"
24115 # check directory inherits DoM EA and uses it as default
24116 mkdir $DIR/$tdir/subdir
24117 touch $DIR/$tdir/subdir/second
24118 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
24119 error "bad pattern in sub-directory"
24120 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
24121 error "bad stripe count in sub-directory"
24122 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
24123 error "bad stripe size in sub-directory"
24126 run_test 270c "DoM: DoM EA inheritance tests"
24129 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24130 skip "Need MDS version at least 2.10.55"
24132 mkdir -p $DIR/$tdir
24133 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24135 # inherit default DoM striping
24136 mkdir $DIR/$tdir/subdir
24137 touch $DIR/$tdir/subdir/f1
24139 # change default directory striping
24140 $LFS setstripe -c 1 $DIR/$tdir/subdir
24141 touch $DIR/$tdir/subdir/f2
24142 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
24143 error "wrong default striping in file 2"
24144 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
24145 error "bad pattern in file 2"
24148 run_test 270d "DoM: change striping from DoM to RAID0"
24151 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24152 skip "Need MDS version at least 2.10.55"
24154 mkdir -p $DIR/$tdir/dom
24155 mkdir -p $DIR/$tdir/norm
24158 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
24159 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
24161 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
24162 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
24164 # find DoM files by layout
24165 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
24166 [ $NUM -eq $DOMFILES ] ||
24167 error "lfs find -L: found $NUM, expected $DOMFILES"
24168 echo "Test 1: lfs find 20 DOM files by layout: OK"
24170 # there should be 1 dir with default DOM striping
24171 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
24173 error "lfs find -L: found $NUM, expected 1 dir"
24174 echo "Test 2: lfs find 1 DOM dir by layout: OK"
24176 # find DoM files by stripe size
24177 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
24178 [ $NUM -eq $DOMFILES ] ||
24179 error "lfs find -S: found $NUM, expected $DOMFILES"
24180 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
24182 # find files by stripe offset except DoM files
24183 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
24184 [ $NUM -eq $NORMFILES ] ||
24185 error "lfs find -i: found $NUM, expected $NORMFILES"
24186 echo "Test 5: lfs find no DOM files by stripe index: OK"
24189 run_test 270e "DoM: lfs find with DoM files test"
24192 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24193 skip "Need MDS version at least 2.10.55"
24195 local mdtname=${FSNAME}-MDT0000-mdtlov
24196 local dom=$DIR/$tdir/dom_file
24197 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
24198 lod.$mdtname.dom_stripesize)
24199 local dom_limit=131072
24201 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
24202 local dom_current=$(do_facet mds1 $LCTL get_param -n \
24203 lod.$mdtname.dom_stripesize)
24204 [ ${dom_limit} -eq ${dom_current} ] ||
24205 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
24207 $LFS mkdir -i 0 -c 1 $DIR/$tdir
24208 $LFS setstripe -d $DIR/$tdir
24209 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
24210 error "Can't set directory default striping"
24212 # exceed maximum stripe size
24213 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
24214 error "Can't create file with $((dom_limit * 2)) DoM stripe"
24215 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
24216 error "Able to create DoM component size more than LOD limit"
24218 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
24219 dom_current=$(do_facet mds1 $LCTL get_param -n \
24220 lod.$mdtname.dom_stripesize)
24221 [ 0 -eq ${dom_current} ] ||
24222 error "Can't set zero DoM stripe limit"
24225 # attempt to create DoM file on server with disabled DoM should
24226 # remove DoM entry from layout and be succeed
24227 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
24228 error "Can't create DoM file (DoM is disabled)"
24229 [ $($LFS getstripe -L $dom) == "mdt" ] &&
24230 error "File has DoM component while DoM is disabled"
24233 # attempt to create DoM file with only DoM stripe should return error
24234 $LFS setstripe -E $dom_limit -L mdt $dom &&
24235 error "Able to create DoM-only file while DoM is disabled"
24237 # too low values to be aligned with smallest stripe size 64K
24238 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
24239 dom_current=$(do_facet mds1 $LCTL get_param -n \
24240 lod.$mdtname.dom_stripesize)
24241 [ 30000 -eq ${dom_current} ] &&
24242 error "Can set too small DoM stripe limit"
24244 # 64K is a minimal stripe size in Lustre, expect limit of that size
24245 [ 65536 -eq ${dom_current} ] ||
24246 error "Limit is not set to 64K but ${dom_current}"
24248 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
24249 dom_current=$(do_facet mds1 $LCTL get_param -n \
24250 lod.$mdtname.dom_stripesize)
24252 [ 2147483648 -eq ${dom_current} ] &&
24253 error "Can set too large DoM stripe limit"
24255 do_facet mds1 $LCTL set_param -n \
24256 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
24257 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
24258 error "Can't create DoM component size after limit change"
24259 do_facet mds1 $LCTL set_param -n \
24260 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
24261 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
24262 error "Can't create DoM file after limit decrease"
24263 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
24264 error "Can create big DoM component after limit decrease"
24265 touch ${dom}_def ||
24266 error "Can't create file with old default layout"
24268 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
24271 run_test 270f "DoM: maximum DoM stripe size checks"
24274 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
24275 skip "Need MDS version at least 2.13.52"
24276 local dom=$DIR/$tdir/$tfile
24278 $LFS mkdir -i 0 -c 1 $DIR/$tdir
24279 local lodname=${FSNAME}-MDT0000-mdtlov
24281 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
24282 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
24283 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
24284 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
24286 local dom_limit=1024
24287 local dom_threshold="50%"
24289 $LFS setstripe -d $DIR/$tdir
24290 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
24291 error "Can't set directory default striping"
24293 do_facet mds1 $LCTL set_param -n \
24294 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
24295 # set 0 threshold and create DOM file to change tunable stripesize
24296 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
24297 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
24298 error "Failed to create $dom file"
24299 # now tunable dom_cur_stripesize should reach maximum
24300 local dom_current=$(do_facet mds1 $LCTL get_param -n \
24301 lod.${lodname}.dom_stripesize_cur_kb)
24302 [[ $dom_current == $dom_limit ]] ||
24303 error "Current DOM stripesize is not maximum"
24306 # set threshold for further tests
24307 do_facet mds1 $LCTL set_param -n \
24308 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
24309 echo "DOM threshold is $dom_threshold free space"
24312 # Spoof bfree to exceed threshold
24313 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
24314 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
24315 for spfree in 40 20 0 15 30 55; do
24316 do_facet mds1 $LCTL set_param -n fail_val=$spfree
24317 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
24318 error "Failed to create $dom file"
24319 dom_def=$(do_facet mds1 $LCTL get_param -n \
24320 lod.${lodname}.dom_stripesize_cur_kb)
24321 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
24322 [[ $dom_def != $dom_current ]] ||
24323 error "Default stripe size was not changed"
24324 if (( spfree > 0 )) ; then
24325 dom_set=$($LFS getstripe -S $dom)
24326 (( dom_set == dom_def * 1024 )) ||
24327 error "DOM component size is still old"
24329 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
24330 error "DoM component is set with no free space"
24333 dom_current=$dom_def
24336 run_test 270g "DoM: default DoM stripe size depends on free space"
24339 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
24340 skip "Need MDS version at least 2.13.53"
24342 local mdtname=${FSNAME}-MDT0000-mdtlov
24343 local dom=$DIR/$tdir/$tfile
24344 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
24346 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
24347 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
24349 $LFS mkdir -i 0 -c 1 $DIR/$tdir
24350 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
24351 error "can't create OST file"
24352 # mirrored file with DOM entry in the second mirror
24353 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
24354 error "can't create mirror with DoM component"
24356 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
24358 # DOM component in the middle and has other enries in the same mirror,
24359 # should succeed but lost DoM component
24360 $LFS setstripe --copy=${dom}_1 $dom ||
24361 error "Can't create file from OST|DOM mirror layout"
24362 # check new file has no DoM layout after all
24363 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
24364 error "File has DoM component while DoM is disabled"
24366 run_test 270h "DoM: DoM stripe removal when disabled on server"
24369 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
24370 skip "Need MDS version at least 2.14.54"
24373 # DoM with plain layout
24374 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir &&
24375 error "default plain layout with DoM must fail"
24376 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir/$tfile &&
24377 error "setstripe plain file layout with DoM must fail"
24378 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir &&
24379 error "default DoM layout with bad striping must fail"
24380 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir/$tfile &&
24381 error "setstripe to DoM layout with bad striping must fail"
24384 run_test 270i "DoM: setting invalid DoM striping should fail"
24387 (( $MDS1_VERSION >= $(version_code 2.15.55.203) )) ||
24388 skip "Need MDS version at least 2.15.55.203"
24390 local dom=$DIR/$tdir/$tfile
24394 mkdir -p $DIR/$tdir
24396 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
24398 odv=$($LFS data_version $dom)
24400 mv $dom ${dom}_moved
24401 link ${dom}_moved $dom
24402 setfattr -n user.attrx -v "some_attr" $dom
24403 ndv=$($LFS data_version $dom)
24404 (( $ndv == $odv )) ||
24405 error "data version was changed by metadata operations"
24407 dd if=/dev/urandom of=$dom bs=1M count=1 ||
24408 error "failed to write data into $dom"
24409 cancel_lru_locks mdc
24410 ndv=$($LFS data_version $dom)
24411 (( $ndv != $odv )) ||
24412 error "data version wasn't changed on write"
24415 $TRUNCATE $dom 1000 || error "failed to truncate $dom"
24416 ndv=$($LFS data_version $dom)
24417 (( $ndv != $odv )) ||
24418 error "data version wasn't changed on truncate down"
24421 $TRUNCATE $dom 25000
24422 ndv=$($LFS data_version $dom)
24423 (( $ndv != $odv )) ||
24424 error "data version wasn't changed on truncate up"
24426 # check also fallocate for ldiskfs
24427 if [[ "$mds1_FSTYPE" == ldiskfs ]]; then
24429 fallocate -l 1048576 $dom
24430 ndv=$($LFS data_version $dom)
24431 (( $ndv != $odv )) ||
24432 error "data version wasn't changed on fallocate"
24435 fallocate -p --offset 4096 -l 4096 $dom
24436 ndv=$($LFS data_version $dom)
24437 (( $ndv != $odv )) ||
24438 error "data version wasn't changed on fallocate punch"
24441 run_test 270j "DoM migration: DOM file to the OST-striped file (plain)"
24444 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24445 skip "Need MDS version at least 2.10.55"
24447 local dom=$DIR/$tdir/dom
24449 mkdir -p $DIR/$tdir
24451 $LFS setstripe -E 1024K -L mdt $dom
24453 lctl set_param -n mdc.*.stats=clear
24454 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
24455 cat $dom > /dev/null
24456 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
24457 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
24461 run_test 271a "DoM: data is cached for read after write"
24464 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24465 skip "Need MDS version at least 2.10.55"
24467 local dom=$DIR/$tdir/dom
24469 mkdir -p $DIR/$tdir
24471 $LFS setstripe -E 1024K -L mdt -E EOF $dom
24473 lctl set_param -n mdc.*.stats=clear
24474 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
24475 cancel_lru_locks mdc
24476 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
24477 # second stat to check size is cached on client
24478 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
24479 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
24480 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
24483 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
24486 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24487 skip "Need MDS version at least 2.10.55"
24489 local dom=$DIR/$tdir/dom
24491 mkdir -p $DIR/$tdir
24493 $LFS setstripe -E 1024K -L mdt -E EOF $dom
24495 lctl set_param -n mdc.*.stats=clear
24496 lctl set_param -n osc.*.stats=clear
24497 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
24498 cancel_lru_locks mdc
24499 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
24500 # second stat to check size is cached on client
24501 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
24502 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
24503 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
24504 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
24505 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
24508 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
24514 local mdt=MDT$(printf %04x $mdtidx)
24516 if [ -z $param ]; then
24517 lctl get_param -n mdc.*$mdt*.stats
24519 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
24524 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24525 skip "Need MDS version at least 2.10.55"
24527 local dom=$DIR/$tdir/dom
24529 mkdir -p $DIR/$tdir
24531 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24533 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
24534 local facet=mds$((mdtidx + 1))
24536 cancel_lru_locks mdc
24537 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
24538 createmany -o $dom 1000
24539 lctl set_param -n mdc.*.stats=clear
24540 smalliomany -w $dom 1000 200
24541 get_mdc_stats $mdtidx
24542 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
24543 # Each file has 1 open, 1 IO enqueues, total 2000
24544 # but now we have also +1 getxattr for security.capability, total 3000
24545 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
24546 unlinkmany $dom 1000
24548 cancel_lru_locks mdc
24549 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
24550 createmany -o $dom 1000
24551 lctl set_param -n mdc.*.stats=clear
24552 smalliomany -w $dom 1000 200
24553 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
24554 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
24555 # for OPEN and IO lock.
24556 [ $((enq - enq_2)) -ge 1000 ] ||
24557 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
24558 unlinkmany $dom 1000
24561 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
24563 cleanup_271def_tests() {
24569 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
24570 skip "Need MDS version at least 2.10.57"
24572 local dom=$DIR/$tdir/dom
24573 local tmp=$TMP/$tfile
24574 trap "cleanup_271def_tests $tmp" EXIT
24576 mkdir -p $DIR/$tdir
24578 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24580 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
24582 cancel_lru_locks mdc
24583 dd if=/dev/urandom of=$tmp bs=1000 count=1
24584 dd if=$tmp of=$dom bs=1000 count=1
24585 cancel_lru_locks mdc
24587 cat /etc/hosts >> $tmp
24588 lctl set_param -n mdc.*.stats=clear
24590 # append data to the same file it should update local page
24591 echo "Append to the same page"
24592 cat /etc/hosts >> $dom
24593 local num=$(get_mdc_stats $mdtidx ost_read)
24594 local ra=$(get_mdc_stats $mdtidx req_active)
24595 local rw=$(get_mdc_stats $mdtidx req_waittime)
24597 [ -z $num ] || error "$num READ RPC occured"
24598 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24602 cmp $tmp $dom || error "file miscompare"
24604 cancel_lru_locks mdc
24605 lctl set_param -n mdc.*.stats=clear
24607 echo "Open and read file"
24608 cat $dom > /dev/null
24609 local num=$(get_mdc_stats $mdtidx ost_read)
24610 local ra=$(get_mdc_stats $mdtidx req_active)
24611 local rw=$(get_mdc_stats $mdtidx req_waittime)
24613 [ -z $num ] || error "$num READ RPC occured"
24614 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24618 cmp $tmp $dom || error "file miscompare"
24622 run_test 271d "DoM: read on open (1K file in reply buffer)"
24625 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
24626 skip "Need MDS version at least 2.10.57"
24628 local dom=$DIR/$tdir/dom
24629 local tmp=$TMP/$tfile
24630 trap "cleanup_271def_tests $tmp" EXIT
24632 mkdir -p $DIR/$tdir
24634 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24636 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
24638 cancel_lru_locks mdc
24639 dd if=/dev/urandom of=$tmp bs=265000 count=1
24640 dd if=$tmp of=$dom bs=265000 count=1
24641 cancel_lru_locks mdc
24642 cat /etc/hosts >> $tmp
24643 lctl set_param -n mdc.*.stats=clear
24645 echo "Append to the same page"
24646 cat /etc/hosts >> $dom
24647 local num=$(get_mdc_stats $mdtidx ost_read)
24648 local ra=$(get_mdc_stats $mdtidx req_active)
24649 local rw=$(get_mdc_stats $mdtidx req_waittime)
24651 [ -z $num ] || error "$num READ RPC occured"
24652 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24656 cmp $tmp $dom || error "file miscompare"
24658 cancel_lru_locks mdc
24659 lctl set_param -n mdc.*.stats=clear
24661 echo "Open and read file"
24662 cat $dom > /dev/null
24663 local num=$(get_mdc_stats $mdtidx ost_read)
24664 local ra=$(get_mdc_stats $mdtidx req_active)
24665 local rw=$(get_mdc_stats $mdtidx req_waittime)
24667 [ -z $num ] && num=0
24668 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
24669 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24673 cmp $tmp $dom || error "file miscompare"
24677 run_test 271f "DoM: read on open (200K file and read tail)"
24680 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
24681 skip "Skipping due to old client or server version"
24683 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
24685 $CHECKSTAT -t file $DIR1/$tfile
24687 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
24690 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
24691 $LCTL set_param fail_loc=0x80000314
24692 rm $DIR1/$tfile || error "Unlink fails"
24694 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
24695 [ $RC -eq 0 ] || error "Failed write to stale object"
24697 run_test 271g "Discard DoM data vs client flush race"
24700 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
24701 skip "Need MDS version at least 2.11.50"
24703 local dom=$DIR/$tdir/dom
24704 mkdir -p $DIR/$tdir
24706 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
24707 dd if=/dev/urandom of=$dom bs=512K count=1 ||
24708 error "failed to write data into $dom"
24709 local old_md5=$(md5sum $dom)
24711 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
24712 error "failed to migrate to the same DoM component"
24714 local new_md5=$(md5sum $dom)
24716 [ "$old_md5" == "$new_md5" ] ||
24717 error "md5sum differ: $old_md5, $new_md5"
24719 [ $($LFS getstripe -c $dom) -eq 2 ] ||
24720 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
24722 run_test 272a "DoM migration: new layout with the same DOM component"
24725 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
24726 skip "Need MDS version at least 2.11.50"
24728 local dom=$DIR/$tdir/dom
24729 mkdir -p $DIR/$tdir
24730 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
24731 stack_trap "rm -rf $DIR/$tdir"
24733 local mdtidx=$($LFS getstripe -m $dom)
24734 local mdtname=MDT$(printf %04x $mdtidx)
24735 local facet=mds$((mdtidx + 1))
24737 local mdtfree1=$(do_facet $facet \
24738 lctl get_param -n osd*.*$mdtname.kbytesfree)
24739 dd if=/dev/urandom of=$dom bs=2M count=1 ||
24740 error "failed to write data into $dom"
24741 local old_md5=$(md5sum $dom)
24742 cancel_lru_locks mdc
24743 local mdtfree1=$(do_facet $facet \
24744 lctl get_param -n osd*.*$mdtname.kbytesfree)
24746 $LFS migrate -c2 $dom ||
24747 error "failed to migrate to the new composite layout"
24748 [[ $($LFS getstripe --component-start=0 -L $dom) != 'mdt' ]] ||
24749 error "MDT stripe was not removed"
24750 ! getfattr -n trusted.dataver $dom &> /dev/null ||
24751 error "$dir1 shouldn't have DATAVER EA"
24753 cancel_lru_locks mdc
24754 local new_md5=$(md5sum $dom)
24755 [ "$old_md5" == "$new_md5" ] ||
24756 error "$old_md5 != $new_md5"
24758 # Skip free space checks with ZFS
24759 if [ "$(facet_fstype $facet)" != "zfs" ]; then
24760 local mdtfree2=$(do_facet $facet \
24761 lctl get_param -n osd*.*$mdtname.kbytesfree)
24762 [ $mdtfree2 -gt $mdtfree1 ] ||
24763 error "MDT space is not freed after migration"
24767 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
24770 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
24771 skip "Need MDS version at least 2.11.50"
24773 local dom=$DIR/$tdir/$tfile
24774 mkdir -p $DIR/$tdir
24775 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
24776 stack_trap "rm -rf $DIR/$tdir"
24778 local mdtidx=$($LFS getstripe -m $dom)
24779 local mdtname=MDT$(printf %04x $mdtidx)
24780 local facet=mds$((mdtidx + 1))
24782 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
24783 error "failed to write data into $dom"
24784 local old_md5=$(md5sum $dom)
24785 cancel_lru_locks mdc
24786 local mdtfree1=$(do_facet $facet \
24787 lctl get_param -n osd*.*$mdtname.kbytesfree)
24789 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
24790 error "failed to migrate to the new composite layout"
24791 [[ $($LFS getstripe --component-start=0 -L $dom) != 'mdt' ]] ||
24792 error "MDT stripe was not removed"
24794 cancel_lru_locks mdc
24795 local new_md5=$(md5sum $dom)
24796 [ "$old_md5" == "$new_md5" ] ||
24797 error "$old_md5 != $new_md5"
24799 # Skip free space checks with ZFS
24800 if [ "$(facet_fstype $facet)" != "zfs" ]; then
24801 local mdtfree2=$(do_facet $facet \
24802 lctl get_param -n osd*.*$mdtname.kbytesfree)
24803 [ $mdtfree2 -gt $mdtfree1 ] ||
24804 error "MDS space is not freed after migration"
24808 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
24811 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
24812 skip "Need MDS version at least 2.12.55"
24814 local dom=$DIR/$tdir/$tfile
24815 mkdir -p $DIR/$tdir
24816 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
24818 local mdtidx=$($LFS getstripe -m $dom)
24819 local mdtname=MDT$(printf %04x $mdtidx)
24820 local facet=mds$((mdtidx + 1))
24822 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
24823 error "failed to write data into $dom"
24824 local old_md5=$(md5sum $dom)
24825 cancel_lru_locks mdc
24826 local mdtfree1=$(do_facet $facet \
24827 lctl get_param -n osd*.*$mdtname.kbytesfree)
24829 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
24830 error "failed mirroring to the new composite layout"
24831 $LFS mirror resync $dom ||
24832 error "failed mirror resync"
24833 $LFS mirror split --mirror-id 1 -d $dom ||
24834 error "failed mirror split"
24836 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
24837 error "MDT stripe was not removed"
24839 cancel_lru_locks mdc
24840 local new_md5=$(md5sum $dom)
24841 [ "$old_md5" == "$new_md5" ] ||
24842 error "$old_md5 != $new_md5"
24844 # Skip free space checks with ZFS
24845 if [ "$(facet_fstype $facet)" != "zfs" ]; then
24846 local mdtfree2=$(do_facet $facet \
24847 lctl get_param -n osd*.*$mdtname.kbytesfree)
24848 [ $mdtfree2 -gt $mdtfree1 ] ||
24849 error "MDS space is not freed after DOM mirror deletion"
24853 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
24856 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
24857 skip "Need MDS version at least 2.12.55"
24859 local dom=$DIR/$tdir/$tfile
24860 mkdir -p $DIR/$tdir
24861 $LFS setstripe -c 2 $dom
24863 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
24864 error "failed to write data into $dom"
24865 local old_md5=$(md5sum $dom)
24868 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
24869 error "failed mirroring to the DOM layout"
24870 $LFS mirror resync $dom ||
24871 error "failed mirror resync"
24872 $LFS mirror split --mirror-id 1 -d $dom ||
24873 error "failed mirror split"
24875 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
24876 error "MDT stripe wasn't set"
24879 local new_md5=$(md5sum $dom)
24880 [ "$old_md5" == "$new_md5" ] ||
24881 error "$old_md5 != $new_md5"
24885 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
24888 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
24889 skip "Need MDS version at least 2.12.55"
24891 local dom=$DIR/$tdir/$tfile
24892 mkdir -p $DIR/$tdir
24893 $LFS setstripe -c 2 $dom
24895 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
24896 error "failed to write data into $dom"
24897 local old_md5=$(md5sum $dom)
24900 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
24901 error "failed migrating to the DOM file"
24903 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
24904 error "MDT stripe wasn't set"
24907 local new_md5=$(md5sum $dom)
24908 [ "$old_md5" != "$new_md5" ] &&
24909 error "$old_md5 != $new_md5"
24913 run_test 272f "DoM migration: OST-striped file to DOM file"
24916 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
24917 skip "Need MDS version at least 2.11.50"
24919 # Layout swap cannot be done if either file has DOM component,
24920 # this will never be supported, migration should be used instead
24922 local dom=$DIR/$tdir/$tfile
24923 mkdir -p $DIR/$tdir
24925 $LFS setstripe -c2 ${dom}_plain
24926 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
24927 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
24928 error "can swap layout with DoM component"
24929 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
24930 error "can swap layout with DoM component"
24932 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
24933 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
24934 error "can swap layout with DoM component"
24935 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
24936 error "can swap layout with DoM component"
24939 run_test 273a "DoM: layout swapping should fail with DOM"
24942 mkdir -p $DIR/$tdir
24943 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
24945 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
24946 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
24948 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
24950 run_test 273b "DoM: race writeback and object destroy"
24953 mkdir -p $DIR/$tdir
24954 $LFS setstripe -E 1M -E-1 -c-1 $DIR/$tdir
24956 #define OBD_FAIL_OFD_COMMITRW_DELAY 0x1e1
24957 do_facet ost1 $LCTL set_param fail_loc=0x800001e1 fail_val=2
24959 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
24961 run_test 273c "race writeback and object destroy"
24964 remote_ost_nodsh && skip "remote OST with nodsh"
24965 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
24966 skip "Need OST version >= 2.10.57"
24968 local file=$DIR/$tfile
24971 oss=$(comma_list $(osts_nodes))
24973 dd if=/dev/urandom of=$file bs=1M count=2 ||
24974 error "failed to create a file"
24975 stack_trap "rm -f $file"
24976 cancel_lru_locks osc
24979 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
24980 error "failed to read a file"
24982 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
24983 $LCTL set_param fail_loc=0x8000031f
24985 cancel_lru_locks osc &
24988 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
24989 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
24990 #IO takes another lock, but matches the PENDING one
24991 #and places it to the IO RPC
24992 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
24993 error "failed to read a file with PENDING lock"
24995 run_test 275 "Read on a canceled duplicate lock"
24998 remote_ost_nodsh && skip "remote OST with nodsh"
25001 do_facet ost1 "(while true; do \
25002 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
25003 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
25006 for LOOP in $(seq 20); do
25008 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
25011 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
25012 rm $TMP/sanity_276_pid"
25014 run_test 276 "Race between mount and obd_statfs"
25017 $LCTL set_param ldlm.namespaces.*.lru_size=0
25018 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
25019 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
25020 awk '/^used_mb/ { print $2 }')
25021 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
25022 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
25023 oflag=direct conv=notrunc
25024 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
25025 awk '/^used_mb/ { print $2 }')
25026 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
25028 run_test 277 "Direct IO shall drop page cache"
25031 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
25032 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
25033 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
25034 skip "needs the same host for mdt1 mdt2" && return
25039 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
25040 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
25046 echo "Starting MDTs"
25047 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
25049 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
25051 do_facet mds2 $LCTL set_param fail_loc=0
25053 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
25054 wait_recovery_complete mds2
25056 run_test 278 "Race starting MDS between MDTs stop/start"
25059 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
25060 skip "Need MGS version at least 2.13.52"
25061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25062 combined_mgs_mds || skip "needs combined MGS/MDT"
25064 umount_client $MOUNT
25065 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
25066 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
25068 mount_client $MOUNT &
25070 stop mgs || error "stop mgs failed"
25071 #for a race mgs would crash
25072 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
25073 # make sure we unmount client before remounting
25075 umount_client $MOUNT
25076 mount_client $MOUNT || error "mount client failed"
25078 run_test 280 "Race between MGS umount and client llog processing"
25080 cleanup_test_300() {
25084 test_striped_dir() {
25089 mkdir -p $DIR/$tdir
25091 SAVE_UMASK=$(umask)
25092 trap cleanup_test_300 RETURN EXIT
25094 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
25095 $DIR/$tdir/striped_dir ||
25096 error "set striped dir error"
25098 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
25099 [ "$mode" = "755" ] || error "expect 755 got $mode"
25101 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
25102 error "getdirstripe failed"
25103 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
25104 if [ "$stripe_count" != "2" ]; then
25105 error "1:stripe_count is $stripe_count, expect 2"
25107 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
25108 if [ "$stripe_count" != "2" ]; then
25109 error "2:stripe_count is $stripe_count, expect 2"
25112 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
25113 if [ "$stripe_index" != "$mdt_index" ]; then
25114 error "stripe_index is $stripe_index, expect $mdt_index"
25117 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
25118 error "nlink error after create striped dir"
25120 mkdir $DIR/$tdir/striped_dir/a
25121 mkdir $DIR/$tdir/striped_dir/b
25123 stat $DIR/$tdir/striped_dir/a ||
25124 error "create dir under striped dir failed"
25125 stat $DIR/$tdir/striped_dir/b ||
25126 error "create dir under striped dir failed"
25128 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
25129 error "nlink error after mkdir"
25131 rmdir $DIR/$tdir/striped_dir/a
25132 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
25133 error "nlink error after rmdir"
25135 rmdir $DIR/$tdir/striped_dir/b
25136 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
25137 error "nlink error after rmdir"
25139 chattr +i $DIR/$tdir/striped_dir
25140 createmany -o $DIR/$tdir/striped_dir/f 10 &&
25141 error "immutable flags not working under striped dir!"
25142 chattr -i $DIR/$tdir/striped_dir
25144 rmdir $DIR/$tdir/striped_dir ||
25145 error "rmdir striped dir error"
25153 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25154 skip "skipped for lustre < 2.7.0"
25155 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25156 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25158 test_striped_dir 0 || error "failed on striped dir on MDT0"
25159 test_striped_dir 1 || error "failed on striped dir on MDT0"
25161 run_test 300a "basic striped dir sanity test"
25164 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25165 skip "skipped for lustre < 2.7.0"
25166 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25167 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25174 test_mkdir $DIR/$tdir || error "mkdir fail"
25175 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25176 error "set striped dir error"
25177 for i in {0..9}; do
25178 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
25180 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
25181 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
25182 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
25184 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
25185 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
25186 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
25190 run_test 300b "check ctime/mtime for striped dir"
25193 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25194 skip "skipped for lustre < 2.7.0"
25195 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25196 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25200 mkdir_on_mdt0 $DIR/$tdir
25201 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
25202 error "set striped dir error"
25204 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
25205 error "chown striped dir failed"
25207 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
25208 error "create 5k files failed"
25210 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
25212 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
25216 run_test 300c "chown && check ls under striped directory"
25219 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25220 skip "skipped for lustre < 2.7.0"
25221 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25222 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25227 mkdir -p $DIR/$tdir
25228 $LFS setstripe -c 2 $DIR/$tdir
25230 #local striped directory
25231 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25232 error "set striped dir error"
25233 #look at the directories for debug purposes
25235 $LFS getdirstripe $DIR/$tdir
25236 ls -l $DIR/$tdir/striped_dir
25237 $LFS getdirstripe $DIR/$tdir/striped_dir
25238 createmany -o $DIR/$tdir/striped_dir/f 10 ||
25239 error "create 10 files failed"
25241 #remote striped directory
25242 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
25243 error "set striped dir error"
25244 #look at the directories for debug purposes
25246 $LFS getdirstripe $DIR/$tdir
25247 ls -l $DIR/$tdir/remote_striped_dir
25248 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
25249 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
25250 error "create 10 files failed"
25252 for file in $(find $DIR/$tdir); do
25253 stripe_count=$($LFS getstripe -c $file)
25254 [ $stripe_count -eq 2 ] ||
25255 error "wrong stripe $stripe_count for $file"
25260 run_test 300d "check default stripe under striped directory"
25263 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25264 skip "Need MDS version at least 2.7.55"
25265 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25266 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25271 mkdir -p $DIR/$tdir
25273 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25274 error "set striped dir error"
25276 touch $DIR/$tdir/striped_dir/a
25277 touch $DIR/$tdir/striped_dir/b
25278 touch $DIR/$tdir/striped_dir/c
25280 mkdir $DIR/$tdir/striped_dir/dir_a
25281 mkdir $DIR/$tdir/striped_dir/dir_b
25282 mkdir $DIR/$tdir/striped_dir/dir_c
25284 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
25285 error "set striped adir under striped dir error"
25287 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
25288 error "set striped bdir under striped dir error"
25290 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
25291 error "set striped cdir under striped dir error"
25293 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
25294 error "rename dir under striped dir fails"
25296 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
25297 error "rename dir under different stripes fails"
25299 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
25300 error "rename file under striped dir should succeed"
25302 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
25303 error "rename dir under striped dir should succeed"
25307 run_test 300e "check rename under striped directory"
25310 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25311 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25312 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25313 skip "Need MDS version at least 2.7.55"
25319 mkdir -p $DIR/$tdir
25321 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25322 error "set striped dir error"
25324 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
25325 error "set striped dir error"
25327 touch $DIR/$tdir/striped_dir/a
25328 mkdir $DIR/$tdir/striped_dir/dir_a
25329 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
25330 error "create striped dir under striped dir fails"
25332 touch $DIR/$tdir/striped_dir1/b
25333 mkdir $DIR/$tdir/striped_dir1/dir_b
25334 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
25335 error "create striped dir under striped dir fails"
25337 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
25338 error "rename dir under different striped dir should fail"
25340 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
25341 error "rename striped dir under diff striped dir should fail"
25343 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
25344 error "rename file under diff striped dirs fails"
25348 run_test 300f "check rename cross striped directory"
25350 test_300_check_default_striped_dir()
25353 local default_count=$2
25354 local default_index=$3
25357 local dir_stripe_index
25360 echo "checking $dirname $default_count $default_index"
25361 $LFS setdirstripe -D -c $default_count -i $default_index \
25362 -H all_char $DIR/$tdir/$dirname ||
25363 error "set default stripe on striped dir error"
25364 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
25365 [ $stripe_count -eq $default_count ] ||
25366 error "expect $default_count get $stripe_count for $dirname"
25368 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
25369 [ $stripe_index -eq $default_index ] ||
25370 error "expect $default_index get $stripe_index for $dirname"
25372 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
25373 error "create dirs failed"
25375 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
25376 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
25377 for dir in $(find $DIR/$tdir/$dirname/*); do
25378 stripe_count=$($LFS getdirstripe -c $dir)
25379 (( $stripe_count == $default_count )) ||
25380 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
25381 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
25382 error "stripe count $default_count != $stripe_count for $dir"
25384 stripe_index=$($LFS getdirstripe -i $dir)
25385 [ $default_index -eq -1 ] ||
25386 [ $stripe_index -eq $default_index ] ||
25387 error "$stripe_index != $default_index for $dir"
25389 #check default stripe
25390 stripe_count=$($LFS getdirstripe -D -c $dir)
25391 [ $stripe_count -eq $default_count ] ||
25392 error "default count $default_count != $stripe_count for $dir"
25394 stripe_index=$($LFS getdirstripe -D -i $dir)
25395 [ $stripe_index -eq $default_index ] ||
25396 error "default index $default_index != $stripe_index for $dir"
25398 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
25402 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25403 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25404 skip "Need MDS version at least 2.7.55"
25410 mkdir_on_mdt0 $DIR/$tdir
25411 mkdir $DIR/$tdir/normal_dir
25413 #Checking when client cache stripe index
25414 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
25415 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
25416 error "create striped_dir failed"
25418 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
25419 error "create dir0 fails"
25420 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
25421 [ $stripe_index -eq 0 ] ||
25422 error "dir0 expect index 0 got $stripe_index"
25424 mkdir $DIR/$tdir/striped_dir/dir1 ||
25425 error "create dir1 fails"
25426 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
25427 [ $stripe_index -eq 1 ] ||
25428 error "dir1 expect index 1 got $stripe_index"
25430 #check default stripe count/stripe index
25431 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
25432 test_300_check_default_striped_dir normal_dir 1 0
25433 test_300_check_default_striped_dir normal_dir -1 1
25434 test_300_check_default_striped_dir normal_dir 2 -1
25436 #delete default stripe information
25437 echo "delete default stripeEA"
25438 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
25439 error "set default stripe on striped dir error"
25441 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
25442 for dir in $(find $DIR/$tdir/normal_dir/*); do
25443 stripe_count=$($LFS getdirstripe -c $dir)
25444 [ $stripe_count -eq 0 ] ||
25445 error "expect 1 get $stripe_count for $dir"
25448 run_test 300g "check default striped directory for normal directory"
25451 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25452 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25453 skip "Need MDS version at least 2.7.55"
25459 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
25460 error "set striped dir error"
25462 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
25463 test_300_check_default_striped_dir striped_dir 1 0
25464 test_300_check_default_striped_dir striped_dir -1 1
25465 test_300_check_default_striped_dir striped_dir 2 -1
25467 #delete default stripe information
25468 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
25469 error "set default stripe on striped dir error"
25471 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
25472 for dir in $(find $DIR/$tdir/striped_dir/*); do
25473 stripe_count=$($LFS getdirstripe -c $dir)
25474 [ $stripe_count -eq 0 ] ||
25475 error "expect 1 get $stripe_count for $dir"
25478 run_test 300h "check default striped directory for striped directory"
25481 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
25482 (( $MDSCOUNT >= 2 )) || skip_env "needs >= 2 MDTs"
25483 (( $MDS1_VERSION >= $(version_code 2.7.55) )) ||
25484 skip "Need MDS version at least 2.7.55"
25491 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
25492 error "set striped dir error"
25494 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
25495 error "create files under striped dir failed"
25497 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
25498 error "set striped hashdir error"
25500 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
25501 error "create dir0 under hash dir failed"
25502 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
25503 error "create dir1 under hash dir failed"
25504 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
25505 error "create dir2 under hash dir failed"
25507 # unfortunately, we need to umount to clear dir layout cache for now
25508 # once we fully implement dir layout, we can drop this
25509 umount_client $MOUNT || error "umount failed"
25510 mount_client $MOUNT || error "mount failed"
25512 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
25513 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
25514 (( $dircnt == 2 )) || error "lfs find striped dir got $dircnt != 2"
25516 if (( $MDS1_VERSION > $(version_code 2.15.0) )); then
25517 $LFS mkdir -i0 -c$MDSCOUNT -H crush2 $DIR/$tdir/hashdir/d3 ||
25518 error "create crush2 dir $tdir/hashdir/d3 failed"
25519 $LFS find -H crush2 $DIR/$tdir/hashdir
25520 dircnt=$($LFS find -H crush2 $DIR/$tdir/hashdir | wc -l)
25521 (( $dircnt == 1 )) || error "find crush2 dir got $dircnt != 1"
25523 # mkdir with an invalid hash type (hash=fail_val) from client
25524 # should be replaced on MDS with a valid (default) hash type
25525 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
25526 $LCTL set_param fail_loc=0x1901 fail_val=99
25527 $LFS mkdir -c2 $DIR/$tdir/hashdir/d99
25529 local hash=$($LFS getdirstripe -H $DIR/$tdir/hashdir/d99)
25530 local expect=$(do_facet mds1 \
25531 $LCTL get_param -n lod.$FSNAME-MDT0000-mdtlov.mdt_hash)
25532 [[ $hash == $expect ]] ||
25533 error "d99 hash '$hash' != expected hash '$expect'"
25536 #set the stripe to be unknown hash type on read
25537 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
25538 $LCTL set_param fail_loc=0x1901 fail_val=99
25539 for ((i = 0; i < 10; i++)); do
25540 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
25541 error "stat f-$i failed"
25542 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
25545 touch $DIR/$tdir/striped_dir/f0 &&
25546 error "create under striped dir with unknown hash should fail"
25548 $LCTL set_param fail_loc=0
25550 umount_client $MOUNT || error "umount failed"
25551 mount_client $MOUNT || error "mount failed"
25555 run_test 300i "client handle unknown hash type striped directory"
25558 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25560 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25561 skip "Need MDS version at least 2.7.55"
25568 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
25569 $LCTL set_param fail_loc=0x1702
25570 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
25571 error "set striped dir error"
25573 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
25574 error "create files under striped dir failed"
25576 $LCTL set_param fail_loc=0
25578 rm -rf $DIR/$tdir || error "unlink striped dir fails"
25582 run_test 300j "test large update record"
25585 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25586 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25587 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25588 skip "Need MDS version at least 2.7.55"
25590 # this test needs a huge transaction
25592 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
25593 osd*.$FSNAME-MDT0000.kbytestotal")
25594 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
25601 #define OBD_FAIL_LARGE_STRIPE 0x1703
25602 $LCTL set_param fail_loc=0x1703
25603 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
25604 error "set striped dir error"
25605 $LCTL set_param fail_loc=0
25607 $LFS getdirstripe $DIR/$tdir/striped_dir ||
25608 error "getstripeddir fails"
25609 rm -rf $DIR/$tdir/striped_dir ||
25610 error "unlink striped dir fails"
25614 run_test 300k "test large striped directory"
25617 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25618 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25619 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25620 skip "Need MDS version at least 2.7.55"
25624 test_mkdir -p $DIR/$tdir/striped_dir
25625 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
25626 error "chown $RUNAS_ID failed"
25627 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
25628 error "set default striped dir failed"
25630 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
25631 $LCTL set_param fail_loc=0x80000158
25632 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
25634 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
25635 [ $stripe_index -eq 1 ] ||
25636 error "expect 1 get $stripe_index for $dir"
25638 run_test 300l "non-root user to create dir under striped dir with stale layout"
25641 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25642 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
25643 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25644 skip "Need MDS version at least 2.7.55"
25646 mkdir -p $DIR/$tdir/striped_dir
25647 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
25648 error "set default stripes dir error"
25650 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
25652 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
25653 [ $stripe_count -eq 0 ] ||
25654 error "expect 0 get $stripe_count for a"
25656 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
25657 error "set default stripes dir error"
25659 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
25661 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
25662 [ $stripe_count -eq 0 ] ||
25663 error "expect 0 get $stripe_count for b"
25665 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
25666 error "set default stripes dir error"
25668 mkdir $DIR/$tdir/striped_dir/c &&
25669 error "default stripe_index is invalid, mkdir c should fails"
25671 rm -rf $DIR/$tdir || error "rmdir fails"
25673 run_test 300m "setstriped directory on single MDT FS"
25676 local list=$(comma_list $(mdts_nodes))
25679 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
25683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25684 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25685 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25686 skip "Need MDS version at least 2.7.55"
25687 remote_mds_nodsh && skip "remote MDS with nodsh"
25690 local list=$(comma_list $(mdts_nodes))
25692 trap cleanup_300n RETURN EXIT
25693 mkdir -p $DIR/$tdir
25694 chmod 777 $DIR/$tdir
25695 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
25696 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
25697 error "create striped dir succeeds with gid=0"
25699 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
25700 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
25701 error "create striped dir fails with gid=-1"
25703 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
25704 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
25705 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
25706 error "set default striped dir succeeds with gid=0"
25709 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
25710 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
25711 error "set default striped dir fails with gid=-1"
25714 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
25715 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
25716 error "create test_dir fails"
25717 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
25718 error "create test_dir1 fails"
25719 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
25720 error "create test_dir2 fails"
25723 run_test 300n "non-root user to create dir under striped dir with default EA"
25726 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25727 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25728 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25729 skip "Need MDS version at least 2.7.55"
25734 mkdir -p $DIR/$tdir
25736 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
25737 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
25738 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
25739 skip "not enough free inodes $numfree1 $numfree2"
25742 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
25743 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
25744 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
25745 skip "not enough free space $numfree1 $numfree2"
25748 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
25749 error "setdirstripe fails"
25751 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
25752 error "create dirs fails"
25754 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
25755 ls $DIR/$tdir/striped_dir > /dev/null ||
25756 error "ls striped dir fails"
25757 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
25758 error "unlink big striped dir fails"
25760 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
25763 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25764 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25765 remote_mds_nodsh && skip "remote MDS with nodsh"
25767 mkdir_on_mdt0 $DIR/$tdir
25769 #define OBD_FAIL_OUT_ENOSPC 0x1704
25770 do_facet mds2 lctl set_param fail_loc=0x80001704
25771 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
25772 && error "create striped directory should fail"
25774 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
25776 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
25779 run_test 300p "create striped directory without space"
25782 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25783 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25785 local fd=$(free_fd)
25786 local cmd="exec $fd<$tdir"
25788 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
25791 trap "eval $cmd" EXIT
25792 cd $tdir || error "cd $tdir fails"
25793 rmdir ../$tdir || error "rmdir $tdir fails"
25794 mkdir local_dir && error "create dir succeeds"
25795 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
25799 run_test 300q "create remote directory under orphan directory"
25802 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25803 skip "Need MDS version at least 2.7.55" && return
25804 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
25808 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
25809 error "set striped dir error"
25811 $LFS getdirstripe $DIR/$tdir/striped_dir ||
25812 error "getstripeddir fails"
25815 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
25816 awk '/lmv_stripe_count:/ { print $2 }')
25818 [ $MDSCOUNT -ne $stripe_count ] &&
25819 error "wrong stripe count $stripe_count expected $MDSCOUNT"
25821 rm -rf $DIR/$tdir/striped_dir ||
25822 error "unlink striped dir fails"
25824 run_test 300r "test -1 striped directory"
25826 test_300s_helper() {
25829 local stripe_dir=$DIR/$tdir/striped_dir.$count
25831 $LFS mkdir -c $count $stripe_dir ||
25832 error "lfs mkdir -c error"
25834 $LFS getdirstripe $stripe_dir ||
25835 error "lfs getdirstripe fails"
25838 stripe_count=$($LFS getdirstripe $stripe_dir |
25839 awk '/lmv_stripe_count:/ { print $2 }')
25841 [ $count -ne $stripe_count ] &&
25842 error_noexit "bad stripe count $stripe_count expected $count"
25845 dupe_stripes=$($LFS getdirstripe $stripe_dir |
25846 awk '/0x/ {count[$1] += 1}; END {
25847 for (idx in count) {
25848 if (count[idx]>1) {
25849 print "index " idx " count " count[idx]
25854 if [[ -n "$dupe_stripes" ]] ; then
25855 lfs getdirstripe $stripe_dir
25856 error_noexit "Dupe MDT above: $dupe_stripes "
25859 rm -rf $stripe_dir ||
25860 error_noexit "unlink $stripe_dir fails"
25864 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25865 skip "Need MDS version at least 2.7.55" && return
25866 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
25869 for count in $(seq 2 $MDSCOUNT); do
25870 test_300s_helper $count
25873 run_test 300s "test lfs mkdir -c without -i"
25876 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
25877 skip "need MDS 2.14.55 or later"
25878 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
25880 local testdir="$DIR/$tdir/striped_dir"
25881 local dir1=$testdir/dir1
25882 local dir2=$testdir/dir2
25886 $LFS setdirstripe -D -c -1 --max-inherit=3 $testdir ||
25887 error "failed to set default stripe count for $testdir"
25890 local stripe_count=$($LFS getdirstripe -c $dir1)
25892 (( $stripe_count == $MDSCOUNT )) || error "wrong stripe count"
25894 local max_count=$((MDSCOUNT - 1))
25895 local mdts=$(comma_list $(mdts_nodes))
25897 do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=$max_count
25898 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=0"
25901 stripe_count=$($LFS getdirstripe -c $dir2)
25903 (( $stripe_count == $max_count )) || error "wrong stripe count"
25905 run_test 300t "test max_mdt_stripecount"
25907 prepare_remote_file() {
25908 mkdir $DIR/$tdir/src_dir ||
25909 error "create remote source failed"
25911 cp /etc/hosts $DIR/$tdir/src_dir/a ||
25912 error "cp to remote source failed"
25913 touch $DIR/$tdir/src_dir/a
25915 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
25916 error "create remote target dir failed"
25918 touch $DIR/$tdir/tgt_dir/b
25920 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
25921 error "rename dir cross MDT failed!"
25923 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
25924 error "src_child still exists after rename"
25926 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
25927 error "missing file(a) after rename"
25929 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
25930 error "diff after rename"
25934 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
25935 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25937 local remote_file=$DIR/$tdir/tgt_dir/b
25939 mkdir -p $DIR/$tdir
25941 prepare_remote_file || error "prepare remote file failed"
25944 $OPENUNLINK $remote_file $remote_file ||
25945 error "openunlink $remote_file failed"
25946 $CHECKSTAT -a $remote_file || error "$remote_file exists"
25948 run_test 310a "open unlink remote file"
25951 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
25952 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25954 local remote_file=$DIR/$tdir/tgt_dir/b
25956 mkdir -p $DIR/$tdir
25958 prepare_remote_file || error "prepare remote file failed"
25960 ln $remote_file $DIR/$tfile || error "link failed for remote file"
25961 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
25962 $CHECKSTAT -t file $remote_file || error "check file failed"
25964 run_test 310b "unlink remote file with multiple links while open"
25967 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25968 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
25970 local remote_file=$DIR/$tdir/tgt_dir/b
25972 mkdir -p $DIR/$tdir
25974 prepare_remote_file || error "prepare remote file failed"
25976 ln $remote_file $DIR/$tfile || error "link failed for remote file"
25977 multiop_bg_pause $remote_file O_uc ||
25978 error "mulitop failed for remote file"
25980 $MULTIOP $DIR/$tfile Ouc
25981 kill -USR1 $MULTIPID
25984 run_test 310c "open-unlink remote file with multiple links"
25988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25989 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
25990 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
25991 skip "lustre < 2.8.54 does not contain LU-4825 fix"
25992 remote_mds_nodsh && skip "remote MDS with nodsh"
25994 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
25995 local mdts=$(comma_list $(mdts_nodes))
25997 mkdir -p $DIR/$tdir
25998 $LFS setstripe -i 0 -c 1 $DIR/$tdir
25999 createmany -o $DIR/$tdir/$tfile. 1000
26001 # statfs data is not real time, let's just calculate it
26002 old_iused=$((old_iused + 1000))
26004 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
26005 osp.*OST0000*MDT0000.create_count")
26006 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
26007 osp.*OST0000*MDT0000.max_create_count")
26008 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
26010 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
26011 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
26012 [ $index -ne 0 ] || error "$tfile stripe index is 0"
26014 unlinkmany $DIR/$tdir/$tfile. 1000
26016 do_nodes $mdts "$LCTL set_param -n \
26017 osp.*OST0000*.max_create_count=$max_count"
26018 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
26019 do_nodes $mdts "$LCTL set_param -n \
26020 osp.*OST0000*.create_count=$count"
26021 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
26022 grep "=0" && error "create_count is zero"
26025 for i in $(seq 120); do
26026 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
26027 # system may be too busy to destroy all objs in time, use
26028 # a somewhat small value to not fail autotest
26029 [ $((old_iused - new_iused)) -gt 400 ] && break
26033 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
26034 [ $((old_iused - new_iused)) -gt 400 ] ||
26035 error "objs not destroyed after unlink"
26037 run_test 311 "disable OSP precreate, and unlink should destroy objs"
26043 local fid=($($LFS getstripe $tf | grep 0x))
26044 local seq=${fid[3]#0x}
26045 local objid=${fid[1]}
26047 local vdevdir=$(dirname $(facet_vdevice $ost))
26048 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
26049 local zfs_zapid=$(do_facet $ost $cmd |
26050 grep -w "/O/$seq/d$((objid%32))" -C 5 |
26051 awk '/Object/{getline; print $1}')
26052 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
26053 awk "/$objid = /"'{printf $3}')
26058 zfs_object_blksz() {
26062 local vdevdir=$(dirname $(facet_vdevice $ost))
26063 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
26064 local blksz=$(do_facet $ost $cmd $objid |
26065 awk '/dblk/{getline; printf $4}')
26067 case "${blksz: -1}" in
26068 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
26069 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
26076 test_312() { # LU-4856
26077 remote_ost_nodsh && skip "remote OST with nodsh"
26078 [[ "$ost1_FSTYPE" == "zfs" ]] || skip "the test only applies to zfs"
26080 local max_blksz=$(do_facet ost1 \
26081 $ZFS get -p recordsize $(facet_device ost1) |
26082 awk '!/VALUE/{print $3}')
26083 local tf=$DIR/$tfile
26085 $LFS setstripe -c1 $tf
26086 local facet="ost$(($($LFS getstripe -i $tf) + 1))"
26088 # Get ZFS object id
26089 local zfs_objid=$(zfs_get_objid $facet $tf)
26090 # block size change by sequential overwrite
26093 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
26094 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
26096 local blksz=$(zfs_object_blksz $facet $zfs_objid)
26097 [[ $blksz -eq $bs ]] || error "blksz error: $blksz, expected: $bs"
26101 $LFS setstripe -c1 $tf
26102 facet="ost$(($($LFS getstripe -i $tf) + 1))"
26104 # block size change by sequential append write
26105 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
26106 zfs_objid=$(zfs_get_objid $facet $tf)
26109 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
26110 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
26111 oflag=sync conv=notrunc
26113 blksz=$(zfs_object_blksz $facet $zfs_objid)
26114 (( $blksz == 2 * count * PAGE_SIZE )) ||
26115 error "blksz error, actual $blksz, " \
26116 "expected: 2 * $count * $PAGE_SIZE"
26121 $LFS setstripe -c1 $tf
26122 facet="ost$(($($LFS getstripe -i $tf) + 1))"
26123 zfs_objid=$(zfs_get_objid $facet $tf)
26125 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
26126 blksz=$(zfs_object_blksz $facet $zfs_objid)
26127 (( blksz == PAGE_SIZE )) ||
26128 error "blksz error: $blksz, expected: $PAGE_SIZE"
26130 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
26131 blksz=$(zfs_object_blksz $facet $zfs_objid)
26132 (( blksz == 65536 )) || error "blksz error: $blksz, expected: 64k"
26134 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
26135 blksz=$(zfs_object_blksz $facet $zfs_objid)
26136 (( blksz == 65536 )) || error "rewrite error: $blksz, expected: 64k"
26138 run_test 312 "make sure ZFS adjusts its block size by write pattern"
26141 remote_ost_nodsh && skip "remote OST with nodsh"
26143 local file=$DIR/$tfile
26146 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
26148 # define OBD_FAIL_TGT_RCVD_EIO 0x720
26149 do_facet ost1 "$LCTL set_param fail_loc=0x720"
26150 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
26151 error "write should failed"
26152 do_facet ost1 "$LCTL set_param fail_loc=0"
26155 run_test 313 "io should fail after last_rcvd update fail"
26158 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
26160 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
26161 do_facet ost1 "$LCTL set_param fail_loc=0x720"
26163 wait_delete_completed
26164 do_facet ost1 "$LCTL set_param fail_loc=0"
26166 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
26168 test_315() { # LU-618
26169 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
26171 local file=$DIR/$tfile
26174 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
26175 error "multiop file write failed"
26176 $MULTIOP $file oO_RDONLY:r4063232_c &
26181 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
26184 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
26187 run_test 315 "read should be accounted"
26190 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
26191 large_xattr_enabled || skip "ea_inode feature disabled"
26193 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
26194 mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
26195 chown nobody $DIR/$tdir/d || error "chown $tdir/d failed"
26196 touch $DIR/$tdir/d/$tfile || error "touch $tdir/d/$tfile failed"
26198 $LFS migrate -m1 $DIR/$tdir/d || error "lfs migrate -m1 failed"
26200 run_test 316 "lfs migrate of file with large_xattr enabled"
26203 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
26204 skip "Need MDS version at least 2.11.53"
26205 if [ "$ost1_FSTYPE" == "zfs" ]; then
26206 skip "LU-10370: no implementation for ZFS"
26210 local grant_blk_size
26212 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
26213 awk '/grant_block_size:/ { print $2; exit; }')
26215 # Create File of size 5M. Truncate it to below size's and verify
26218 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
26219 error "Create file $DIR/$tfile failed"
26220 stack_trap "rm -f $DIR/$tfile" EXIT
26222 for trunc_sz in 2097152 4097 4000 509 0; do
26223 $TRUNCATE $DIR/$tfile $trunc_sz ||
26224 error "truncate $tfile to $trunc_sz failed"
26225 local sz=$(stat --format=%s $DIR/$tfile)
26226 local blk=$(stat --format=%b $DIR/$tfile)
26227 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
26228 grant_blk_size) * 8))
26230 if [[ $blk -ne $trunc_blk ]]; then
26231 $(which stat) $DIR/$tfile
26232 error "Expected Block $trunc_blk got $blk for $tfile"
26235 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
26236 error "Expected Size $trunc_sz got $sz for $tfile"
26241 # Create file with a hole and write actual 65536 bytes which aligned
26242 # with 4K and 64K PAGE_SIZE. Block count must be 128.
26245 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 seek=5 conv=fsync ||
26246 error "Create file : $DIR/$tfile"
26249 # Truncate to size $trunc_sz bytes. Strip tail blocks and leave only 8
26250 # blocks. The block count must drop to 8.
26252 trunc_sz=$(($(stat --format=%s $DIR/$tfile) -
26253 ((bs - grant_blk_size) + 1)))
26254 $TRUNCATE $DIR/$tfile $trunc_sz ||
26255 error "truncate $tfile to $trunc_sz failed"
26257 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
26258 sz=$(stat --format=%s $DIR/$tfile)
26259 blk=$(stat --format=%b $DIR/$tfile)
26261 if [[ $blk -ne $trunc_bsz ]]; then
26262 $(which stat) $DIR/$tfile
26263 error "Expected Block $trunc_bsz got $blk for $tfile"
26266 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
26267 error "Expected Size $trunc_sz got $sz for $tfile"
26269 run_test 317 "Verify blocks get correctly update after truncate"
26272 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
26273 local old_max_active=$($LCTL get_param -n \
26274 ${llite_name}.max_read_ahead_async_active \
26277 $LCTL set_param llite.*.max_read_ahead_async_active=256
26278 local max_active=$($LCTL get_param -n \
26279 ${llite_name}.max_read_ahead_async_active \
26281 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
26283 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
26284 error "set max_read_ahead_async_active should succeed"
26286 $LCTL set_param llite.*.max_read_ahead_async_active=512
26287 max_active=$($LCTL get_param -n \
26288 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
26289 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
26291 # restore @max_active
26292 [ $old_max_active -ne 0 ] && $LCTL set_param \
26293 llite.*.max_read_ahead_async_active=$old_max_active
26295 local old_threshold=$($LCTL get_param -n \
26296 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
26297 local max_per_file_mb=$($LCTL get_param -n \
26298 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
26300 local invalid=$(($max_per_file_mb + 1))
26302 llite.*.read_ahead_async_file_threshold_mb=$invalid\
26303 && error "set $invalid should fail"
26305 local valid=$(($invalid - 1))
26307 llite.*.read_ahead_async_file_threshold_mb=$valid ||
26308 error "set $valid should succeed"
26309 local threshold=$($LCTL get_param -n \
26310 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
26311 [ $threshold -eq $valid ] || error \
26312 "expect threshold $valid got $threshold"
26314 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
26316 run_test 318 "Verify async readahead tunables"
26319 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
26321 local before=$(date +%s)
26323 local mdir=$DIR/$tdir
26324 local file=$mdir/xxx
26326 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
26329 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
26330 $LCTL set_param fail_val=5 fail_loc=0x8000032c
26331 $LFS migrate -m1 $mdir &
26334 dd if=$file of=/dev/null
26336 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
26337 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
26339 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
26341 run_test 319 "lost lease lock on migrate error"
26343 test_398a() { # LU-4198
26344 local ost1_imp=$(get_osc_import_name client ost1)
26345 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
26348 $LFS setstripe -c 1 -i 0 $DIR/$tfile
26349 stack_trap "rm -f $DIR/$tfile"
26350 $LCTL set_param ldlm.namespaces.*.lru_size=clear
26352 # request a new lock on client
26353 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
26355 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
26356 local lock_count=$($LCTL get_param -n \
26357 ldlm.namespaces.$imp_name.lru_size)
26358 [[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
26360 $LCTL set_param ldlm.namespaces.$imp_name.lru_size=clear
26362 # no lock cached, should use lockless DIO and not enqueue new lock
26363 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
26364 lock_count=$($LCTL get_param -n \
26365 ldlm.namespaces.$imp_name.lru_size)
26366 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
26368 $LCTL set_param ldlm.namespaces.$imp_name.lru_size=clear
26370 # no lock cached, should use locked DIO append
26371 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct oflag=append \
26372 conv=notrunc || error "DIO append failed"
26373 lock_count=$($LCTL get_param -n \
26374 ldlm.namespaces.$imp_name.lru_size)
26375 [[ $lock_count -ne 0 ]] || error "lock still must be held by DIO append"
26377 run_test 398a "direct IO should cancel lock otherwise lockless"
26379 test_398b() { # LU-4198
26380 local before=$(date +%s)
26384 which fio || skip_env "no fio installed"
26385 $LFS setstripe -c -1 -S 1M $DIR/$tfile
26386 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
26388 # Single page, multiple pages, stripe size, 4*stripe size
26389 for bsize in $(( $PAGE_SIZE )) $(( 4*$PAGE_SIZE )) 1048576 4194304; do
26390 echo "mix direct rw ${bsize} by fio with $njobs jobs..."
26391 fio --name=rand-rw --rw=randrw --bs=$bsize --direct=1 \
26392 --numjobs=$njobs --fallocate=none \
26393 --iodepth=16 --allow_file_create=0 \
26394 --size=$((size/njobs))M \
26395 --filename=$DIR/$tfile &
26398 echo "mix buffer rw ${bsize} by fio with $njobs jobs..."
26399 fio --name=rand-rw --rw=randrw --bs=$bsize \
26400 --numjobs=$njobs --fallocate=none \
26401 --iodepth=16 --allow_file_create=0 \
26402 --size=$((size/njobs))M \
26403 --filename=$DIR/$tfile || true
26407 evict=$(do_facet client $LCTL get_param \
26408 osc.$FSNAME-OST*-osc-*/state |
26409 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
26411 [ -z "$evict" ] || [[ $evict -le $before ]] ||
26412 (do_facet client $LCTL get_param \
26413 osc.$FSNAME-OST*-osc-*/state;
26414 error "eviction happened: $evict before:$before")
26418 run_test 398b "DIO and buffer IO race"
26420 test_398c() { # LU-4198
26421 local ost1_imp=$(get_osc_import_name client ost1)
26422 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
26425 which fio || skip_env "no fio installed"
26427 saved_debug=$($LCTL get_param -n debug)
26428 $LCTL set_param debug=0
26430 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
26431 ((size /= 1024)) # by megabytes
26432 ((size /= 2)) # write half of the OST at most
26433 [ $size -gt 40 ] && size=40 #reduce test time anyway
26435 $LFS setstripe -c 1 $DIR/$tfile
26437 # it seems like ldiskfs reserves more space than necessary if the
26438 # writing blocks are not mapped, so it extends the file firstly
26439 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
26440 cancel_lru_locks osc
26442 # clear and verify rpc_stats later
26443 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
26446 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
26447 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
26448 --numjobs=$njobs --fallocate=none --ioengine=libaio \
26449 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
26450 --filename=$DIR/$tfile
26451 [ $? -eq 0 ] || error "fio write error"
26453 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
26454 error "Locks were requested while doing AIO"
26456 # get the percentage of 1-page I/O
26457 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
26458 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
26460 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
26462 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
26463 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
26464 --numjobs=$njobs --fallocate=none --ioengine=libaio \
26465 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
26466 --filename=$DIR/$tfile
26467 [ $? -eq 0 ] || error "fio mixed read write error"
26469 echo "AIO with large block size ${size}M"
26470 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
26471 --numjobs=1 --fallocate=none --ioengine=libaio \
26472 --iodepth=16 --allow_file_create=0 --size=${size}M \
26473 --filename=$DIR/$tfile
26474 [ $? -eq 0 ] || error "fio large block size failed"
26477 $LCTL set_param debug="$saved_debug"
26479 run_test 398c "run fio to test AIO"
26481 test_398d() { # LU-13846
26482 which aiocp || skip_env "no aiocp installed"
26483 local aio_file=$DIR/$tfile.aio
26485 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
26487 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
26488 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
26489 stack_trap "rm -f $DIR/$tfile $aio_file"
26491 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
26493 # make sure we don't crash and fail properly
26494 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
26495 error "aio not aligned with PAGE SIZE should fail"
26497 rm -f $DIR/$tfile $aio_file
26499 run_test 398d "run aiocp to verify block size > stripe size"
26502 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
26503 touch $DIR/$tfile.new
26504 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
26506 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
26508 test_398f() { # LU-14687
26509 which aiocp || skip_env "no aiocp installed"
26510 local aio_file=$DIR/$tfile.aio
26512 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
26514 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
26515 stack_trap "rm -f $DIR/$tfile $aio_file"
26517 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
26518 $LCTL set_param fail_loc=0x1418
26519 # make sure we don't crash and fail properly
26520 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
26521 error "aio with page allocation failure succeeded"
26522 $LCTL set_param fail_loc=0
26523 diff $DIR/$tfile $aio_file
26524 [[ $? != 0 ]] || error "no diff after failed aiocp"
26526 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
26528 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
26529 # stripe and i/o size must be > stripe size
26530 # Old style synchronous DIO waits after submitting each chunk, resulting in a
26531 # single RPC in flight. This test shows async DIO submission is working by
26532 # showing multiple RPCs in flight.
26533 test_398g() { # LU-13798
26534 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
26536 # We need to do some i/o first to acquire enough grant to put our RPCs
26537 # in flight; otherwise a new connection may not have enough grant
26539 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
26540 error "parallel dio failed"
26541 stack_trap "rm -f $DIR/$tfile"
26543 # Reduce RPC size to 1M to avoid combination in to larger RPCs
26544 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
26545 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
26546 stack_trap "$LCTL set_param -n $pages_per_rpc"
26548 # Recreate file so it's empty
26550 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
26551 #Pause rpc completion to guarantee we see multiple rpcs in flight
26552 #define OBD_FAIL_OST_BRW_PAUSE_BULK
26553 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
26554 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
26557 $LCTL set_param osc.*.rpc_stats=c
26559 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
26560 error "parallel dio failed"
26561 stack_trap "rm -f $DIR/$tfile"
26563 $LCTL get_param osc.*-OST0000-*.rpc_stats
26564 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
26565 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
26566 grep "8:" | awk '{print $8}')
26567 # We look at the "8 rpcs in flight" field, and verify A) it is present
26568 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
26569 # as expected for an 8M DIO to a file with 1M stripes.
26570 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
26572 # Verify turning off parallel dio works as expected
26574 $LCTL set_param osc.*.rpc_stats=c
26575 $LCTL set_param llite.*.parallel_dio=0
26576 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
26578 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
26579 error "dio with parallel dio disabled failed"
26581 # Ideally, we would see only one RPC in flight here, but there is an
26582 # unavoidable race between i/o completion and RPC in flight counting,
26583 # so while only 1 i/o is in flight at a time, the RPC in flight counter
26584 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
26585 # So instead we just verify it's always < 8.
26586 $LCTL get_param osc.*-OST0000-*.rpc_stats
26587 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
26588 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
26589 grep '^$' -B1 | grep . | awk '{print $1}')
26590 [ $ret != "8:" ] ||
26591 error "we should see fewer than 8 RPCs in flight (saw $ret)"
26593 run_test 398g "verify parallel dio async RPC submission"
26595 test_398h() { # LU-13798
26596 local dio_file=$DIR/$tfile.dio
26598 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
26600 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
26601 stack_trap "rm -f $DIR/$tfile $dio_file"
26603 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
26604 error "parallel dio failed"
26605 diff $DIR/$tfile $dio_file
26606 [[ $? == 0 ]] || error "file diff after aiocp"
26608 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
26610 test_398i() { # LU-13798
26611 local dio_file=$DIR/$tfile.dio
26613 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
26615 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
26616 stack_trap "rm -f $DIR/$tfile $dio_file"
26618 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
26619 $LCTL set_param fail_loc=0x1418
26620 # make sure we don't crash and fail properly
26621 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
26622 error "parallel dio page allocation failure succeeded"
26623 diff $DIR/$tfile $dio_file
26624 [[ $? != 0 ]] || error "no diff after failed aiocp"
26626 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
26628 test_398j() { # LU-13798
26629 # Stripe size > RPC size but less than i/o size tests split across
26630 # stripes and RPCs for individual i/o op
26631 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
26633 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
26634 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
26635 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
26636 stack_trap "$LCTL set_param -n $pages_per_rpc"
26638 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
26639 error "parallel dio write failed"
26640 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
26642 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
26643 error "parallel dio read failed"
26644 diff $DIR/$tfile $DIR/$tfile.2
26645 [[ $? == 0 ]] || error "file diff after parallel dio read"
26647 run_test 398j "test parallel dio where stripe size > rpc_size"
26649 test_398k() { # LU-13798
26650 wait_delete_completed
26653 # 4 stripe file; we will cause out of space on OST0
26654 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
26656 # Fill OST0 (if it's not too large)
26657 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
26659 if [[ $ORIGFREE -gt $MAXFREE ]]; then
26660 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
26662 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
26663 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
26664 error "dd should fill OST0"
26665 stack_trap "rm -f $DIR/$tfile.1"
26667 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
26671 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
26672 error "file is not 0 bytes in size"
26674 # dd above should not succeed, but don't error until here so we can
26675 # get debug info above
26677 error "parallel dio write with enospc succeeded"
26678 stack_trap "rm -f $DIR/$tfile"
26680 run_test 398k "test enospc on first stripe"
26682 test_398l() { # LU-13798
26683 wait_delete_completed
26686 # 4 stripe file; we will cause out of space on OST0
26687 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
26688 # happens on the second i/o chunk we issue
26689 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
26691 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
26692 stack_trap "rm -f $DIR/$tfile"
26694 # Fill OST0 (if it's not too large)
26695 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
26697 if [[ $ORIGFREE -gt $MAXFREE ]]; then
26698 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
26700 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
26701 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
26702 error "dd should fill OST0"
26703 stack_trap "rm -f $DIR/$tfile.1"
26705 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
26707 stack_trap "rm -f $DIR/$tfile.2"
26709 # Check that short write completed as expected
26710 ls -la $DIR/$tfile.2
26711 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
26712 error "file is not 1M in size"
26714 # dd above should not succeed, but don't error until here so we can
26715 # get debug info above
26717 error "parallel dio write with enospc succeeded"
26719 # Truncate source file to same length as output file and diff them
26720 $TRUNCATE $DIR/$tfile 1048576
26721 diff $DIR/$tfile $DIR/$tfile.2
26722 [[ $? == 0 ]] || error "data incorrect after short write"
26724 run_test 398l "test enospc on intermediate stripe/RPC"
26726 test_398m() { # LU-13798
26727 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
26729 # Set up failure on OST0, the first stripe:
26730 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
26731 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
26732 # OST0 is on ost1, OST1 is on ost2.
26733 # So this fail_val specifies OST0
26734 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
26735 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
26737 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
26738 error "parallel dio write with failure on first stripe succeeded"
26739 stack_trap "rm -f $DIR/$tfile"
26740 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
26742 # Place data in file for read
26743 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
26744 error "parallel dio write failed"
26746 # Fail read on OST0, first stripe
26747 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
26748 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
26749 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
26750 error "parallel dio read with error on first stripe succeeded"
26751 rm -f $DIR/$tfile.2
26752 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
26754 # Switch to testing on OST1, second stripe
26755 # Clear file contents, maintain striping
26757 # Set up failure on OST1, second stripe:
26758 do_facet ost2 $LCTL set_param fail_loc=0x20e fail_val=2
26759 stack_trap "do_facet ost2 $LCTL set_param fail_loc=0"
26761 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
26762 error "parallel dio write with failure on second stripe succeeded"
26763 stack_trap "rm -f $DIR/$tfile"
26764 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
26766 # Place data in file for read
26767 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
26768 error "parallel dio write failed"
26770 # Fail read on OST1, second stripe
26771 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
26772 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
26773 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
26774 error "parallel dio read with error on second stripe succeeded"
26775 rm -f $DIR/$tfile.2
26776 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
26778 run_test 398m "test RPC failures with parallel dio"
26780 # Parallel submission of DIO should not cause problems for append, but it's
26781 # important to verify.
26782 test_398n() { # LU-13798
26783 $LFS setstripe -C 2 -S 1M $DIR/$tfile
26785 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
26786 error "dd to create source file failed"
26787 stack_trap "rm -f $DIR/$tfile"
26789 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
26790 error "parallel dio write with failure on second stripe succeeded"
26791 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
26792 diff $DIR/$tfile $DIR/$tfile.1
26793 [[ $? == 0 ]] || error "data incorrect after append"
26796 run_test 398n "test append with parallel DIO"
26799 directio rdwr $DIR/$tfile 0 1 1 || error "bad KMS"
26801 run_test 398o "right kms with DIO"
26805 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
26806 which aiocp || skip_env "no aiocp installed"
26808 local stripe_size=$((1024 * 1024)) #1 MiB
26809 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
26810 local file_size=$((25 * stripe_size))
26812 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
26813 stack_trap "rm -f $DIR/$tfile*"
26814 # Just a bit bigger than the largest size in the test set below
26815 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
26816 error "buffered i/o to create file failed"
26818 for bs in $PAGE_SIZE $((PAGE_SIZE * 4)) $stripe_size \
26819 $((stripe_size * 4)); do
26821 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
26823 echo "bs: $bs, file_size $file_size"
26824 aiocp -a $PAGE_SIZE -b $bs -s $file_size -f O_DIRECT \
26825 $DIR/$tfile.1 $DIR/$tfile.2 &
26827 # Buffered I/O with similar but not the same block size
26828 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 \
26835 if (( rc1 != 0 )); then
26836 error "aio copy 1 w/bsize $bs failed: $rc1"
26838 if (( rc2 != 0 )); then
26839 error "buffered copy 2 w/bsize $bs failed: $rc2"
26842 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
26843 error "size incorrect"
26844 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
26845 error "files differ, bsize $bs"
26846 rm -f $DIR/$tfile.2
26849 run_test 398p "race aio with buffered i/o"
26853 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
26855 local stripe_size=$((1024 * 1024)) #1 MiB
26856 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
26857 local file_size=$((25 * stripe_size))
26859 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
26860 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
26862 # Just a bit bigger than the largest size in the test set below
26863 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
26864 error "buffered i/o to create file failed"
26866 for bs in $PAGE_SIZE $((PAGE_SIZE * 4)) $stripe_size \
26867 $((stripe_size * 4)); do
26869 echo "bs: $bs, file_size $file_size"
26870 dd if=$DIR/$tfile.1 bs=$((bs *2 )) of=$DIR/tfile.2 \
26871 conv=notrunc oflag=direct iflag=direct &
26873 # Buffered I/O with similar but not the same block size
26874 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 \
26881 if (( rc1 != 0 )); then
26882 error "dio copy 1 w/bsize $bs failed: $rc1"
26884 if (( rc2 != 0 )); then
26885 error "buffered copy 2 w/bsize $bs failed: $rc2"
26888 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
26889 error "size incorrect"
26890 diff $DIR/$tfile.1 $DIR/$tfile.2 ||
26891 error "files differ, bsize $bs"
26896 run_test 398q "race dio with buffered i/o"
26899 local read_write=$1
26900 if [ "$read_write" = "write" ]; then
26901 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
26902 elif [ "$read_write" = "read" ]; then
26903 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
26905 error "argument error"
26908 # turn off debug for performance testing
26909 local saved_debug=$($LCTL get_param -n debug)
26910 $LCTL set_param debug=0
26912 $LFS setstripe -c 1 -i 0 $DIR/$tfile
26914 # get ost1 size - $FSNAME-OST0000
26915 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
26916 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
26917 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
26919 if [ "$read_write" = "read" ]; then
26920 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
26923 local start_time=$(date +%s.%N)
26924 $dd_cmd bs=1M count=$blocks oflag=sync ||
26925 error "real dd $read_write error"
26926 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
26928 if [ "$read_write" = "write" ]; then
26932 # define OBD_FAIL_OST_FAKE_RW 0x238
26933 do_facet ost1 $LCTL set_param fail_loc=0x238
26935 local start_time=$(date +%s.%N)
26936 $dd_cmd bs=1M count=$blocks oflag=sync ||
26937 error "fake dd $read_write error"
26938 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
26940 if [ "$read_write" = "write" ]; then
26942 cancel_lru_locks osc
26943 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
26944 error "$tfile size not $blocks MB"
26946 do_facet ost1 $LCTL set_param fail_loc=0
26948 echo "fake $read_write $duration_fake vs. normal $read_write" \
26949 "$duration in seconds"
26950 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
26951 error_not_in_vm "fake write is slower"
26953 $LCTL set_param -n debug="$saved_debug"
26956 test_399a() { # LU-7655 for OST fake write
26957 remote_ost_nodsh && skip "remote OST with nodsh"
26961 run_test 399a "fake write should not be slower than normal write"
26963 test_399b() { # LU-8726 for OST fake read
26964 remote_ost_nodsh && skip "remote OST with nodsh"
26965 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
26966 skip_env "ldiskfs only test"
26971 run_test 399b "fake read should not be slower than normal read"
26973 test_400a() { # LU-1606, was conf-sanity test_74
26974 if ! which $CC > /dev/null 2>&1; then
26975 skip_env "$CC is not installed"
26978 local extra_flags=''
26979 local out=$TMP/$tfile
26980 local prefix=/usr/include/lustre
26983 # Oleg removes .c files in his test rig so test if any c files exist
26984 [[ -n "$(ls -A $LUSTRE_TESTS_API_DIR)" ]] ||
26985 skip_env "Needed .c test files are missing"
26987 if ! [[ -d $prefix ]]; then
26988 # Assume we're running in tree and fixup the include path.
26989 extra_flags+=" -I$LUSTRE/../lnet/include/uapi"
26990 extra_flags+=" -I$LUSTRE/include/uapi -I$LUSTRE/include"
26991 extra_flags+=" -L$LUSTRE/utils/.libs"
26994 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
26995 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
26996 error "client api broken"
27000 run_test 400a "Lustre client api program can compile and link"
27002 test_400b() { # LU-1606, LU-5011
27004 local out=$TMP/$tfile
27005 local prefix=/usr/include/linux/lustre
27007 # We use a hard coded prefix so that this test will not fail
27008 # when run in tree. There are headers in lustre/include/lustre/
27009 # that are not packaged (like lustre_idl.h) and have more
27010 # complicated include dependencies (like config.h and lnet/types.h).
27011 # Since this test about correct packaging we just skip them when
27012 # they don't exist (see below) rather than try to fixup cppflags.
27014 if ! which $CC > /dev/null 2>&1; then
27015 skip_env "$CC is not installed"
27018 for header in $prefix/*.h; do
27019 if ! [[ -f "$header" ]]; then
27023 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
27024 continue # lustre_ioctl.h is internal header
27027 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
27028 error "cannot compile '$header'"
27032 run_test 400b "packaged headers can be compiled"
27034 test_401a() { #LU-7437
27035 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
27036 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
27038 #count the number of parameters by "list_param -R"
27039 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
27040 #count the number of parameters by listing proc files
27041 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
27042 echo "proc_dirs='$proc_dirs'"
27043 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
27044 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
27047 [ $params -eq $procs ] ||
27048 error "found $params parameters vs. $procs proc files"
27050 # test the list_param -D option only returns directories
27051 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
27052 #count the number of parameters by listing proc directories
27053 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
27056 [ $params -eq $procs ] ||
27057 error "found $params parameters vs. $procs proc files"
27059 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
27062 # jobid_var may not allow arbitrary values, so use jobid_name
27064 if $LCTL list_param jobid_name > /dev/null 2>&1; then
27065 local testname=jobid_name tmp='testing%p'
27067 local testname=jobid_var tmp=testing
27070 local save=$($LCTL get_param -n $testname)
27072 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
27073 error "no error returned when setting bad parameters"
27075 local jobid_new=$($LCTL get_param -n foe $testname baz)
27076 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
27078 $LCTL set_param -n fog=bam $testname=$save bat=fog
27079 local jobid_old=$($LCTL get_param -n foe $testname bag)
27080 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
27082 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
27085 # jobid_var may not allow arbitrary values, so use jobid_name
27087 if $LCTL list_param jobid_name > /dev/null 2>&1; then
27088 local testname=jobid_name
27090 local testname=jobid_var
27093 local jobid_var_old=$($LCTL get_param -n $testname)
27094 local jobid_var_new
27096 $LCTL set_param $testname= &&
27097 error "no error returned for 'set_param a='"
27099 jobid_var_new=$($LCTL get_param -n $testname)
27100 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
27101 error "$testname was changed by setting without value"
27103 $LCTL set_param $testname &&
27104 error "no error returned for 'set_param a'"
27106 jobid_var_new=$($LCTL get_param -n $testname)
27107 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
27108 error "$testname was changed by setting without value"
27110 run_test 401c "Verify 'lctl set_param' without value fails in either format."
27113 # jobid_var may not allow arbitrary values, so use jobid_name
27115 if $LCTL list_param jobid_name > /dev/null 2>&1; then
27116 local testname=jobid_name new_value='foo=bar%p'
27118 local testname=jobid_var new_valuie=foo=bar
27121 local jobid_var_old=$($LCTL get_param -n $testname)
27122 local jobid_var_new
27124 $LCTL set_param $testname=$new_value ||
27125 error "'set_param a=b' did not accept a value containing '='"
27127 jobid_var_new=$($LCTL get_param -n $testname)
27128 [[ "$jobid_var_new" == "$new_value" ]] ||
27129 error "'set_param a=b' failed on a value containing '='"
27131 # Reset the $testname to test the other format
27132 $LCTL set_param $testname=$jobid_var_old
27133 jobid_var_new=$($LCTL get_param -n $testname)
27134 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
27135 error "failed to reset $testname"
27137 $LCTL set_param $testname $new_value ||
27138 error "'set_param a b' did not accept a value containing '='"
27140 jobid_var_new=$($LCTL get_param -n $testname)
27141 [[ "$jobid_var_new" == "$new_value" ]] ||
27142 error "'set_param a b' failed on a value containing '='"
27144 $LCTL set_param $testname $jobid_var_old
27145 jobid_var_new=$($LCTL get_param -n $testname)
27146 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
27147 error "failed to reset $testname"
27149 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
27151 test_401e() { # LU-14779
27152 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
27153 error "lctl list_param MGC* failed"
27154 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
27155 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
27156 error "lctl get_param lru_size failed"
27158 run_test 401e "verify 'lctl get_param' works with NID in parameter"
27161 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
27162 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
27163 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
27164 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
27165 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
27166 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
27167 remote_mds_nodsh && skip "remote MDS with nodsh"
27169 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
27170 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
27171 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
27172 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
27173 echo "Touch failed - OK"
27175 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
27178 local file1=$DIR/$tfile.1
27179 local file2=$DIR/$tfile.2
27180 local tfile=$TMP/$tfile
27182 rm -f $file1 $file2 $tfile
27187 # 30 sec OBD_TIMEOUT in ll_getattr()
27188 # right before populating st_nlink
27189 $LCTL set_param fail_loc=0x80001409
27190 stat -c %h $file1 > $tfile &
27192 # create an alias, drop all locks and reclaim the dentry
27194 cancel_lru_locks mdc
27195 cancel_lru_locks osc
27196 sysctl -w vm.drop_caches=2
27200 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
27202 rm -f $tfile $file1 $file2
27204 run_test 403 "i_nlink should not drop to zero due to aliasing"
27206 test_404() { # LU-6601
27207 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
27208 skip "Need server version newer than 2.8.52"
27209 remote_mds_nodsh && skip "remote MDS with nodsh"
27211 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
27212 awk '/osp .*-osc-MDT/ { print $4}')
27215 for osp in $mosps; do
27216 echo "Deactivate: " $osp
27217 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
27218 local stat=$(do_facet $SINGLEMDS $LCTL dl |
27219 awk -vp=$osp '$4 == p { print $2 }')
27220 [ $stat = IN ] || {
27221 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
27222 error "deactivate error"
27224 echo "Activate: " $osp
27225 do_facet $SINGLEMDS $LCTL --device %$osp activate
27226 local stat=$(do_facet $SINGLEMDS $LCTL dl |
27227 awk -vp=$osp '$4 == p { print $2 }')
27228 [ $stat = UP ] || {
27229 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
27230 error "activate error"
27234 run_test 404 "validate manual {de}activated works properly for OSPs"
27237 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
27238 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
27239 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
27240 skip "Layout swap lock is not supported"
27242 check_swap_layouts_support
27243 check_swap_layout_no_dom $DIR
27245 test_mkdir $DIR/$tdir
27246 swap_lock_test -d $DIR/$tdir ||
27247 error "One layout swap locked test failed"
27249 run_test 405 "Various layout swap lock tests"
27252 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
27253 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
27254 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
27255 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27256 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
27257 skip "Need MDS version at least 2.8.50"
27259 local def_stripe_size=$($LFS getstripe -S $MOUNT)
27260 local test_pool=$TESTNAME
27262 pool_add $test_pool || error "pool_add failed"
27263 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
27264 error "pool_add_targets failed"
27266 save_layout_restore_at_exit $MOUNT
27268 # parent set default stripe count only, child will stripe from both
27269 # parent and fs default
27270 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
27271 error "setstripe $MOUNT failed"
27272 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
27273 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
27274 for i in $(seq 10); do
27275 local f=$DIR/$tdir/$tfile.$i
27276 touch $f || error "touch failed"
27277 local count=$($LFS getstripe -c $f)
27278 [ $count -eq $OSTCOUNT ] ||
27279 error "$f stripe count $count != $OSTCOUNT"
27280 local offset=$($LFS getstripe -i $f)
27281 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
27282 local size=$($LFS getstripe -S $f)
27283 [ $size -eq $((def_stripe_size * 2)) ] ||
27284 error "$f stripe size $size != $((def_stripe_size * 2))"
27285 local pool=$($LFS getstripe -p $f)
27286 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
27289 # change fs default striping, delete parent default striping, now child
27290 # will stripe from new fs default striping only
27291 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
27292 error "change $MOUNT default stripe failed"
27293 $LFS setstripe -c 0 $DIR/$tdir ||
27294 error "delete $tdir default stripe failed"
27295 for i in $(seq 11 20); do
27296 local f=$DIR/$tdir/$tfile.$i
27297 touch $f || error "touch $f failed"
27298 local count=$($LFS getstripe -c $f)
27299 [ $count -eq 1 ] || error "$f stripe count $count != 1"
27300 local offset=$($LFS getstripe -i $f)
27301 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
27302 local size=$($LFS getstripe -S $f)
27303 [ $size -eq $def_stripe_size ] ||
27304 error "$f stripe size $size != $def_stripe_size"
27305 local pool=$($LFS getstripe -p $f)
27306 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
27309 unlinkmany $DIR/$tdir/$tfile. 1 20
27311 local f=$DIR/$tdir/$tfile
27312 pool_remove_all_targets $test_pool $f
27313 pool_remove $test_pool $f
27315 run_test 406 "DNE support fs default striping"
27318 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
27319 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
27320 skip "Need MDS version at least 2.8.55"
27321 remote_mds_nodsh && skip "remote MDS with nodsh"
27323 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
27324 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
27325 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
27326 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
27327 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
27329 #define OBD_FAIL_DT_TXN_STOP 0x2019
27330 for idx in $(seq $MDSCOUNT); do
27331 do_facet mds$idx "lctl set_param fail_loc=0x2019"
27333 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
27334 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
27335 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
27338 run_test 407 "transaction fail should cause operation fail"
27341 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
27343 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
27344 lctl set_param fail_loc=0x8000040a
27345 # let ll_prepare_partial_page() fail
27346 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
27350 # create at least 100 unused inodes so that
27351 # shrink_icache_memory(0) should not return 0
27352 touch $DIR/$tfile-{0..100}
27353 rm -f $DIR/$tfile-{0..100}
27356 echo 2 > /proc/sys/vm/drop_caches
27358 run_test 408 "drop_caches should not hang due to page leaks"
27362 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
27364 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
27365 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
27366 touch $DIR/$tdir/guard || error "(2) Fail to create"
27368 local PREFIX=$(str_repeat 'A' 128)
27369 echo "Create 1K hard links start at $(date)"
27370 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
27371 error "(3) Fail to hard link"
27373 echo "Links count should be right although linkEA overflow"
27374 stat $DIR/$tdir/guard || error "(4) Fail to stat"
27375 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
27376 [ $linkcount -eq 1001 ] ||
27377 error "(5) Unexpected hard links count: $linkcount"
27379 echo "List all links start at $(date)"
27380 ls -l $DIR/$tdir/foo > /dev/null ||
27381 error "(6) Fail to list $DIR/$tdir/foo"
27383 echo "Unlink hard links start at $(date)"
27384 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
27385 error "(7) Fail to unlink"
27386 echo "Unlink hard links finished at $(date)"
27388 run_test 409 "Large amount of cross-MDTs hard links on the same file"
27392 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
27393 skip "Need client version at least 2.9.59"
27394 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
27395 skip "Need MODULES build"
27397 # Create a file, and stat it from the kernel
27398 local testfile=$DIR/$tfile
27401 local run_id=$RANDOM
27402 local my_ino=$(stat --format "%i" $testfile)
27404 # Try to insert the module. This will always fail as the
27405 # module is designed to not be inserted.
27406 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
27409 # Anything but success is a test failure
27411 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
27412 error "no inode match"
27414 run_test 410 "Test inode number returned from kernel thread"
27416 cleanup_test411_cgroup() {
27422 local cg_basedir=/sys/fs/cgroup/memory
27424 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
27425 skip "no setup for cgroup"
27427 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
27428 error "test file creation failed"
27429 cancel_lru_locks osc
27431 # Create a very small memory cgroup to force a slab allocation error
27432 local cgdir=$cg_basedir/osc_slab_alloc
27433 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
27434 trap "cleanup_test411_cgroup $cgdir" EXIT
27435 echo 2M > $cgdir/memory.kmem.limit_in_bytes
27436 echo 1M > $cgdir/memory.limit_in_bytes
27438 # Should not LBUG, just be killed by oom-killer
27439 # dd will return 0 even allocation failure in some environment.
27440 # So don't check return value
27441 bash -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
27442 cleanup_test411_cgroup $cgdir
27446 run_test 411 "Slab allocation error with cgroup does not LBUG"
27449 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
27450 (( $MDS1_VERSION >= $(version_code 2.10.55) )) ||
27451 skip "Need server version at least 2.10.55"
27453 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
27454 error "mkdir failed"
27455 $LFS getdirstripe $DIR/$tdir
27456 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
27457 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
27458 error "expect $((MDSCOUT - 1)) get $stripe_index"
27459 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
27460 [ $stripe_count -eq 2 ] ||
27461 error "expect 2 get $stripe_count"
27463 (( $MDS1_VERSION >= $(version_code 2.14.55) )) || return 0
27468 # subdirs should be on the same MDT as parent
27469 for i in $(seq 0 $((MDSCOUNT - 1))); do
27470 $LFS mkdir -i $i $DIR/$tdir/mdt$i || error "mkdir mdt$i failed"
27471 mkdir $DIR/$tdir/mdt$i/sub || error "mkdir sub failed"
27472 index=$($LFS getstripe -m $DIR/$tdir/mdt$i/sub)
27473 (( index == i )) || error "mdt$i/sub on MDT$index"
27476 # stripe offset -1, ditto
27477 for i in {1..10}; do
27478 $LFS mkdir -i -1 $DIR/$tdir/qos$i || error "mkdir qos$i failed"
27479 index=$($LFS getstripe -m $DIR/$tdir/qos$i)
27480 mkdir $DIR/$tdir/qos$i/sub || error "mkdir sub failed"
27481 index2=$($LFS getstripe -m $DIR/$tdir/qos$i/sub)
27482 (( index == index2 )) ||
27483 error "qos$i on MDT$index, sub on MDT$index2"
27486 local testdir=$DIR/$tdir/inherit
27488 $LFS mkdir -i 1 --max-inherit=3 $testdir || error "mkdir inherit failed"
27491 testdir=$testdir/s$i
27492 mkdir $testdir || error "mkdir $testdir failed"
27493 index=$($LFS getstripe -m $testdir)
27494 (( index == 1 )) ||
27495 error "$testdir on MDT$index"
27498 # not inherit any more
27499 testdir=$testdir/s3
27500 mkdir $testdir || error "mkdir $testdir failed"
27501 getfattr -d -m dmv $testdir | grep dmv &&
27502 error "default LMV set on $testdir" || true
27504 run_test 412 "mkdir on specific MDTs"
27506 TEST413_COUNT=${TEST413_COUNT:-200}
27509 # set_maxage() is used by test_413 only.
27510 # This is a helper function to set maxage. Does not return any value.
27511 # Input: maxage to set
27514 local lmv_qos_maxage
27515 local lod_qos_maxage
27516 local new_maxage=$1
27518 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
27519 $LCTL set_param lmv.*.qos_maxage=$new_maxage
27520 stack_trap "$LCTL set_param \
27521 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
27522 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
27523 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
27524 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
27525 lod.*.mdt_qos_maxage=$new_maxage
27526 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
27527 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
27530 generate_uneven_mdts() {
27542 echo "Check for uneven MDTs: "
27544 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
27545 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
27546 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
27548 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
27549 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
27552 for ((i = 1; i < ${#ffree[@]}; i++)); do
27553 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
27554 if [ $tmp -gt $max ]; then
27558 if [ $tmp -lt $min ]; then
27564 (( min > 0 )) || skip "low space on MDT$min_index"
27565 (( ${ffree[min_index]} > 0 )) ||
27566 skip "no free files on MDT$min_index"
27567 (( ${ffree[min_index]} < 10000000 )) ||
27568 skip "too many free files on MDT$min_index"
27570 # Check if we need to generate uneven MDTs
27571 local diff=$(((max - min) * 100 / min))
27572 local testdirp=$DIR/$tdir-fillmdt # parent fill folder
27573 local testdir # individual folder within $testdirp
27577 # fallocate is faster to consume space on MDT, if available
27578 if check_fallocate_supported mds$((min_index + 1)); then
27579 cmd="fallocate -l 128K "
27581 cmd="dd if=/dev/zero bs=128K count=1 of="
27584 echo "using cmd $cmd"
27585 for (( i = 0; diff < threshold; i++ )); do
27586 testdir=${testdirp}/$i
27587 [ -d $testdir ] && continue
27589 (( i % 10 > 0 )) || { $LFS df; $LFS df -i; }
27592 # generate uneven MDTs, create till $threshold% diff
27593 echo -n "weight diff=$diff% must be > $threshold% ..."
27594 echo "Fill MDT$min_index with $TEST413_COUNT files: loop $i"
27595 $LFS mkdir -i $min_index $testdir ||
27596 error "mkdir $testdir failed"
27597 $LFS setstripe -E 1M -L mdt $testdir ||
27598 error "setstripe $testdir failed"
27600 for (( f = 0; f < TEST413_COUNT; f++ )); do
27601 $cmd$testdir/f.$f &> /dev/null || error "$cmd $f failed"
27603 sync; sleep 1; sync
27605 # wait for QOS to update
27606 (( SECONDS < start + 2 )) && sleep $((start + 2 - SECONDS))
27608 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
27609 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
27610 max=$(((${ffree[max_index]} >> 8) *
27611 (${bavail[max_index]} * bsize >> 16)))
27612 min=$(((${ffree[min_index]} >> 8) *
27613 (${bavail[min_index]} * bsize >> 16)))
27614 (( min > 0 )) || skip "low space on MDT$min_index"
27615 diff=$(((max - min) * 100 / min))
27618 echo "MDT filesfree available: ${ffree[*]}"
27619 echo "MDT blocks available: ${bavail[*]}"
27620 echo "weight diff=$diff%"
27625 local stripe_count=$2
27626 local mdts=$(comma_list $(mdts_nodes))
27629 local lmv_qos_prio_free
27630 local lmv_qos_threshold_rr
27631 local lod_qos_prio_free
27632 local lod_qos_threshold_rr
27637 # @total is total directories created if it's testing plain
27638 # directories, otherwise it's total stripe object count for
27639 # striped directories test.
27640 # remote/striped directory unlinking is slow on zfs and may
27641 # timeout, test with fewer directories
27642 [ "$mds1_FSTYPE" = "zfs" ] && total=120 || total=240
27644 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
27645 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
27646 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
27648 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
27649 stack_trap "$LCTL set_param \
27650 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
27651 stack_trap "$LCTL set_param \
27652 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
27654 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
27655 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
27656 lod_qos_prio_free=${lod_qos_prio_free%%%}
27657 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
27658 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
27659 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
27660 stack_trap "do_nodes $mdts $LCTL set_param \
27661 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
27662 stack_trap "do_nodes $mdts $LCTL set_param \
27663 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
27665 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
27666 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
27668 testdir=$DIR/$tdir-s$stripe_count/rr
27670 local stripe_index=$($LFS getstripe -m $testdir)
27671 local test_mkdir_rr=true
27673 getfattr -d -m dmv -e hex $testdir | grep dmv
27674 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
27675 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
27676 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
27677 test_mkdir_rr=false
27682 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
27683 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
27685 stack_trap "unlinkmany -d $testdir/subdir $((total / stripe_count))"
27686 for (( i = 0; i < total / stripe_count; i++ )); do
27687 eval $mkdir_cmd $testdir/subdir$i ||
27688 error "$mkdir_cmd subdir$i failed"
27691 for (( i = 0; i < $MDSCOUNT; i++ )); do
27692 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
27693 echo "$count directories created on MDT$i"
27694 if $test_mkdir_rr; then
27695 (( count == total / stripe_count / MDSCOUNT )) ||
27696 error "subdirs are not evenly distributed"
27697 elif (( i == stripe_index )); then
27698 (( count == total / stripe_count )) ||
27699 error "$count subdirs created on MDT$i"
27701 (( count == 0 )) ||
27702 error "$count subdirs created on MDT$i"
27705 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
27706 count=$($LFS getdirstripe $testdir/* |
27707 grep -c -P "^\s+$i\t")
27708 echo "$count stripes created on MDT$i"
27709 # deviation should < 5% of average
27710 delta=$((count - total / MDSCOUNT))
27711 (( ${delta#-} <= total / MDSCOUNT / 20 )) ||
27712 error "stripes are not evenly distributed"
27717 echo "Check for uneven MDTs: "
27727 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
27728 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
27729 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
27731 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
27732 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
27735 for ((i = 1; i < ${#ffree[@]}; i++)); do
27736 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
27737 if [ $tmp -gt $max ]; then
27741 if [ $tmp -lt $min ]; then
27746 echo "stripe_count=$stripe_count min_idx=$min_index max_idx=$max_index"
27748 (( min > 0 )) || skip "low space on MDT$min_index"
27749 (( ${ffree[min_index]} < 10000000 )) ||
27750 skip "too many free files on MDT$min_index"
27752 generate_uneven_mdts 120
27754 echo "MDT filesfree available: ${ffree[*]}"
27755 echo "MDT blocks available: ${bavail[*]}"
27756 echo "weight diff=$(((max - min) * 100 / min))%"
27758 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
27760 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
27761 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
27762 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
27763 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
27764 # decrease statfs age, so that it can be updated in time
27765 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
27766 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
27770 testdir=$DIR/$tdir-s$stripe_count/qos
27772 stack_trap "unlinkmany -d $testdir/subdir $((total / stripe_count))"
27773 for (( i = 0; i < total / stripe_count; i++ )); do
27774 eval $mkdir_cmd $testdir/subdir$i ||
27775 error "$mkdir_cmd subdir$i failed"
27779 for (( i = 0; i < $MDSCOUNT; i++ )); do
27780 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
27781 (( count > max )) && max=$count
27782 echo "$count directories created on MDT$i : curmax=$max"
27785 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
27787 # D-value should > 10% of average
27788 (( max - min > total / stripe_count / MDSCOUNT / 10 )) ||
27789 error "subdirs shouldn't be evenly distributed: $max - $min <= $((total / stripe_count / MDSCOUNT / 10))"
27791 # ditto for stripes
27792 if (( stripe_count > 1 )); then
27794 for (( i = 0; i < $MDSCOUNT; i++ )); do
27795 count=$($LFS getdirstripe $testdir/* |
27796 grep -c -P "^\s+$i\t")
27797 (( count > max )) && max=$count
27798 echo "$count stripes created on MDT$i"
27801 min=$($LFS getdirstripe $testdir/* |
27802 grep -c -P "^\s+$min_index\t")
27803 (( max - min > total / MDSCOUNT / 10 )) ||
27804 error "stripes shouldn't be evenly distributed: $max - $min <= $((total / MDSCOUNT / 10))"
27816 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
27817 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
27818 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
27820 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
27822 for ((i = 1; i < ${#ffree[@]}; i++)); do
27823 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
27824 (( tmp < min )) && min=$tmp && min_index=$i
27831 [ $MDSCOUNT -lt 2 ] &&
27832 skip "We need at least 2 MDTs for this test"
27834 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
27835 skip "Need server version at least 2.12.52"
27837 local stripe_max=$((MDSCOUNT - 1))
27840 # let caller set maxage for latest result
27843 # fill MDT unevenly
27844 generate_uneven_mdts 120
27846 # test 4-stripe directory at most, otherwise it's too slow
27847 # We are being very defensive. Although Autotest uses 4 MDTs.
27848 # We make sure stripe_max does not go over 4.
27849 (( stripe_max > 4 )) && stripe_max=4
27850 # unlinking striped directory is slow on zfs, and may timeout, only test
27852 [ "$mds1_FSTYPE" == "zfs" ] && stripe_max=1
27853 for stripe_count in $(seq 1 $stripe_max); do
27854 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
27855 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
27856 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
27857 error "mkdir failed"
27858 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
27861 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
27864 [ $MDSCOUNT -lt 2 ] &&
27865 skip "We need at least 2 MDTs for this test"
27867 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
27868 skip "Need server version at least 2.12.52"
27870 local stripe_max=$((MDSCOUNT - 1))
27874 # let caller set maxage for latest result
27877 # fill MDT unevenly
27878 generate_uneven_mdts 120
27880 # test 4-stripe directory at most, otherwise it's too slow
27881 # We are being very defensive. Although Autotest uses 4 MDTs.
27882 # We make sure stripe_max does not go over 4.
27883 (( stripe_max > 4 )) && stripe_max=4
27884 [ "$mds1_FSTYPE" == "zfs" ] && stripe_max=1
27885 for stripe_count in $(seq 1 $stripe_max); do
27886 testdir=$DIR/$tdir-s$stripe_count
27887 mkdir $testdir || error "mkdir $testdir failed"
27888 mkdir $testdir/rr || error "mkdir rr failed"
27889 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
27890 error "mkdir qos failed"
27891 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
27892 $testdir/rr || error "setdirstripe rr failed"
27893 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
27894 error "setdirstripe failed"
27895 test_qos_mkdir "mkdir" $stripe_count
27898 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
27901 (( $MDSCOUNT >= 2 )) ||
27902 skip "We need at least 2 MDTs for this test"
27904 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
27905 skip "Need server version at least 2.14.51"
27910 local lmv_qos_maxage
27911 local lod_qos_maxage
27913 # let caller set maxage for latest result
27914 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
27915 $LCTL set_param lmv.*.qos_maxage=1
27916 stack_trap "$LCTL set_param \
27917 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
27918 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
27919 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
27920 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
27921 lod.*.mdt_qos_maxage=1
27922 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
27923 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
27925 # fill MDT unevenly
27926 generate_uneven_mdts 120
27928 testdir=$DIR/${tdir}-s1
27929 mkdir $testdir || error "mkdir $testdir failed"
27930 mkdir $testdir/rr || error "mkdir rr failed"
27931 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
27932 # default max_inherit is -1, default max_inherit_rr is 0
27933 $LFS setdirstripe -D -c 1 $testdir/rr ||
27934 error "setdirstripe rr failed"
27935 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
27936 error "setdirstripe qos failed"
27937 test_qos_mkdir "mkdir" 1
27939 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
27940 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
27941 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
27942 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
27943 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
27945 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
27946 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
27947 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
27948 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
27949 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
27950 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
27951 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
27952 error "level2 shouldn't have default LMV" || true
27954 run_test 413c "mkdir with default LMV max inherit rr"
27957 (( MDSCOUNT >= 2 )) ||
27958 skip "We need at least 2 MDTs for this test"
27960 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
27961 skip "Need server version at least 2.14.51"
27963 local lmv_qos_threshold_rr
27965 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
27967 stack_trap "$LCTL set_param \
27968 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
27970 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
27971 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
27972 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
27973 error "$tdir shouldn't have default LMV"
27974 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
27975 error "mkdir sub failed"
27977 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
27979 (( count == 100 )) || error "$count subdirs on MDT0"
27981 run_test 413d "inherit ROOT default LMV"
27984 (( MDSCOUNT >= 2 )) ||
27985 skip "We need at least 2 MDTs for this test"
27986 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
27987 skip "Need server version at least 2.14.55"
27989 local testdir=$DIR/$tdir
27990 local tmpfile=$TMP/temp.setdirstripe.stderr.$$
27992 local sub_max_inherit
27994 mkdir -p $testdir || error "failed to create $testdir"
27996 # set default max-inherit to -1 if stripe count is 0 or 1
27997 $LFS setdirstripe -D -c 1 $testdir ||
27998 error "failed to set default LMV"
27999 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
28000 (( max_inherit == -1 )) ||
28001 error "wrong max_inherit value $max_inherit"
28003 # set default max_inherit to a fixed value if stripe count is not 0 or 1
28004 $LFS setdirstripe -D -c -1 $testdir ||
28005 error "failed to set default LMV"
28006 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
28007 (( max_inherit > 0 )) ||
28008 error "wrong max_inherit value $max_inherit"
28010 # and the subdir will decrease the max_inherit by 1
28011 mkdir -p $testdir/subdir-1 || error "failed to make subdir"
28012 sub_max_inherit=$($LFS getdirstripe -D --max-inherit $testdir/subdir-1)
28013 (( sub_max_inherit == max_inherit - 1)) ||
28014 error "wrong max-inherit of subdir $sub_max_inherit"
28016 # check specified --max-inherit and warning message
28017 stack_trap "rm -f $tmpfile"
28018 $LFS setdirstripe -D -c 2 --max-inherit=-1 $testdir 2> $tmpfile ||
28019 error "failed to set default LMV"
28020 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
28021 (( max_inherit == -1 )) ||
28022 error "wrong max_inherit value $max_inherit"
28024 # check the warning messages
28025 if ! [[ $(cat $tmpfile) =~ "max-inherit=" ]]; then
28026 error "failed to detect warning string"
28029 run_test 413e "check default max-inherit value"
28031 test_fs_dmv_inherit()
28033 local testdir=$DIR/$tdir
28040 mkdir $testdir || error "mkdir $testdir failed"
28041 count=$($LFS getdirstripe -D -c $testdir)
28042 (( count == 1 )) ||
28043 error "$testdir default LMV count mismatch $count != 1"
28044 inherit=$($LFS getdirstripe -D -X $testdir)
28045 (( inherit == 3 - i )) ||
28046 error "$testdir default LMV max-inherit $inherit != $((3 - i))"
28047 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir)
28048 (( inherit_rr == 3 - i )) ||
28049 error "$testdir default LMV max-inherit-rr $inherit_rr != $((3 - i))"
28050 testdir=$testdir/sub
28053 mkdir $testdir || error "mkdir $testdir failed"
28054 count=$($LFS getdirstripe -D -c $testdir)
28055 (( count == 0 )) ||
28056 error "$testdir default LMV count not zero: $count"
28060 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
28062 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
28063 skip "Need server version at least 2.14.55"
28065 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
28066 error "dump $DIR default LMV failed"
28067 stack_trap "setfattr --restore=$TMP/dmv.ea"
28069 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
28070 error "set $DIR default LMV failed"
28072 test_fs_dmv_inherit
28074 run_test 413f "lfs getdirstripe -D list ROOT default LMV if it's not set on dir"
28077 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
28079 mkdir -p $DIR/$tdir/l2/l3/l4 || error "mkdir $tdir/l1/l2/l3 failed"
28080 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
28081 error "dump $DIR default LMV failed"
28082 stack_trap "setfattr --restore=$TMP/dmv.ea"
28084 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
28085 error "set $DIR default LMV failed"
28087 FILESET="$FILESET/$tdir/l2/l3/l4" mount_client $MOUNT2 ||
28088 error "mount $MOUNT2 failed"
28089 stack_trap "umount_client $MOUNT2"
28091 local saved_DIR=$DIR
28095 stack_trap "export DIR=$saved_DIR"
28097 # first check filesystem-wide default LMV inheritance
28098 test_fs_dmv_inherit || error "incorrect fs default LMV inheritance"
28100 # then check subdirs are spread to all MDTs
28101 createmany -d $DIR/s $((MDSCOUNT * 100)) || error "createmany failed"
28103 local count=$($LFS getstripe -m $DIR/s* | sort -u | wc -l)
28105 (( $count == $MDSCOUNT )) || error "dirs are spread to $count MDTs"
28107 run_test 413g "enforce ROOT default LMV on subdir mount"
28110 (( MDSCOUNT >= 2 )) ||
28111 skip "We need at least 2 MDTs for this test"
28113 (( MDS1_VERSION >= $(version_code 2.15.50.6) )) ||
28114 skip "Need server version at least 2.15.50.6"
28116 local lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
28118 stack_trap "$LCTL set_param \
28119 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
28120 $LCTL set_param lmv.*.qos_maxage=1
28124 local dir=$DIR/$tdir/l1/l2/l3/l4/l5
28125 local count=$((MDSCOUNT * 20))
28127 generate_uneven_mdts 50
28129 mkdir -p $dir || error "mkdir $dir failed"
28130 stack_trap "rm -rf $dir"
28131 $LFS setdirstripe -D -c 1 -i -1 --max-inherit=$depth \
28132 --max-inherit-rr=$rr_depth $dir
28134 for ((d=0; d < depth + 2; d++)); do
28136 for ((sub=0; sub < count; sub++)); do
28139 $LFS getdirstripe -i $dir/d* | sort | uniq -c | sort -nr
28140 local num=($($LFS getdirstripe -i $dir/d* | sort | uniq -c))
28141 # subdirs within $rr_depth should be created round-robin
28142 if (( d < rr_depth )); then
28143 (( ${num[0]} != count )) ||
28144 error "all objects created on MDT ${num[1]}"
28150 run_test 413h "don't stick to parent for round-robin dirs"
28153 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
28155 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
28156 skip "Need server version at least 2.14.55"
28158 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
28159 error "dump $DIR default LMV failed"
28160 stack_trap "setfattr --restore=$TMP/dmv.ea"
28162 local testdir=$DIR/$tdir
28167 $LFS setdirstripe -D -i-1 -c1 --max-inherit=$def_max \
28168 --max-inherit-rr=$def_max_rr $DIR ||
28169 error "set $DIR default LMV failed"
28171 for i in $(seq 2 3); do
28172 def_max=$((def_max - 1))
28173 (( def_max_rr == 0 )) || def_max_rr=$((def_max_rr - 1))
28176 # RR is decremented and keeps zeroed once exhausted
28177 count=$($LFS getdirstripe -D --max-inherit-rr $testdir)
28178 (( count == def_max_rr )) ||
28179 error_noexit "$testdir: max-inherit-rr $count != $def_max_rr"
28181 # max-inherit is decremented
28182 count=$($LFS getdirstripe -D --max-inherit $testdir)
28183 (( count == def_max )) ||
28184 error_noexit "$testdir: max-inherit $count != $def_max"
28186 testdir=$testdir/d$i
28189 # d3 is the last inherited from ROOT, no inheritance anymore
28190 # i.e. no the default layout anymore
28191 mkdir -p $testdir/d4/d5
28192 count=$($LFS getdirstripe -D --max-inherit $testdir)
28193 (( count == -1 )) ||
28194 error_noexit "$testdir: max-inherit $count != -1"
28196 local p_count=$($LFS getdirstripe -i $testdir)
28198 for i in $(seq 4 5); do
28199 testdir=$testdir/d$i
28201 # the root default layout is not applied once exhausted
28202 count=$($LFS getdirstripe -i $testdir)
28203 (( count == p_count )) ||
28204 error_noexit "$testdir: stripe-offset $count != parent offset $p_count"
28207 $LFS setdirstripe -i 0 $DIR/d2
28208 count=$($LFS getdirstripe -D --max-inherit $DIR/d2)
28209 (( count == -1 )) ||
28210 error_noexit "$DIR/d2: max-inherit non-striped default $count != -1"
28212 run_test 413i "check default layout inheritance"
28219 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
28220 unlinkmany $subdir/f. $TEST413_COUNT &
28224 for pid in $pids; do
28230 run_test 413z "413 test cleanup"
28233 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
28234 $LCTL set_param fail_loc=0x80000521
28235 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
28238 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
28241 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
28242 (( $MDS1_VERSION >= $(version_code 2.11.52) )) ||
28243 skip "Need server version at least 2.11.52"
28249 # this test may be slow on ZFS
28250 [[ "$mds1_FSTYPE" == "zfs" ]] && total=50
28252 # though this test is designed for striped directory, let's test normal
28253 # directory too since lock is always saved as CoS lock.
28254 test_mkdir $DIR/$tdir || error "mkdir $tdir"
28255 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
28256 stack_trap "unlinkmany $DIR/$tdir/$tfile. $total || true"
28257 # if looping with ONLY_REPEAT, wait for previous deletions to finish
28258 wait_delete_completed_mds
28260 # run a loop without concurrent touch to measure rename duration.
28261 # only for test debug/robustness, NOT part of COS functional test.
28262 local start_time=$SECONDS
28263 for ((i = 0; i < total; i++)); do
28264 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
28267 local baseline=$((SECONDS - start_time))
28268 echo "rename $total files without 'touch' took $baseline sec"
28275 local setattr_pid=$!
28277 # rename files back to original name so unlinkmany works
28278 start_time=$SECONDS
28279 for ((i = 0; i < total; i++)); do
28280 mrename $DIR/$tdir/$tfile-new.$i $DIR/$tdir/$tfile.$i\
28283 local duration=$((SECONDS - start_time))
28285 kill -9 $setattr_pid
28287 echo "rename $total files with 'touch' took $duration sec"
28288 (( max > 2 * baseline )) || max=$((2 * baseline + 5))
28289 (( duration <= max )) ||
28290 error_not_in_vm "rename took $duration > $max sec"
28292 run_test 415 "lock revoke is not missing"
28295 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
28296 skip "Need server version at least 2.11.55"
28298 # define OBD_FAIL_OSD_TXN_START 0x19a
28299 do_facet mds1 lctl set_param fail_loc=0x19a
28301 lfs mkdir -c $MDSCOUNT $DIR/$tdir
28305 run_test 416 "transaction start failure won't cause system hung"
28309 do_nodes $(comma_list $(mdts_nodes)) \
28310 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
28311 do_nodes $(comma_list $(mdts_nodes)) \
28312 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
28313 do_nodes $(comma_list $(mdts_nodes)) \
28314 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
28318 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
28319 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
28320 skip "Need MDS version at least 2.11.56"
28322 trap cleanup_417 RETURN EXIT
28324 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
28325 do_nodes $(comma_list $(mdts_nodes)) \
28326 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
28327 $LFS migrate -m 0 $DIR/$tdir.1 &&
28328 error "migrate dir $tdir.1 should fail"
28330 do_nodes $(comma_list $(mdts_nodes)) \
28331 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
28332 $LFS mkdir -i 1 $DIR/$tdir.2 &&
28333 error "create remote dir $tdir.2 should fail"
28335 do_nodes $(comma_list $(mdts_nodes)) \
28336 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
28337 $LFS mkdir -c 2 $DIR/$tdir.3 &&
28338 error "create striped dir $tdir.3 should fail"
28341 run_test 417 "disable remote dir, striped dir and dir migration"
28343 # Checks that the outputs of df [-i] and lfs df [-i] match
28345 # usage: check_lfs_df <blocks | inodes> <mountpoint>
28355 [ "$1" == "blocks" ] && inodes= || inodes="-i"
28357 for count in {1..100}; do
28358 do_nodes "$CLIENTS" \
28359 $LCTL set_param ldlm.namespaces.*.lru_size=clear
28362 # read the lines of interest
28363 df_out=($(df -P $inodes $dir | tail -n +2)) ||
28364 error "df $inodes $dir | tail -n +2 failed"
28365 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
28366 error "lfs df $inodes $dir | grep summary: failed"
28368 # skip first substrings of each output as they are different
28369 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
28370 # compare the two outputs
28372 # skip "available" on MDT until LU-13997 is fixed.
28373 #for i in {1..5}; do
28374 for i in 1 2 4 5; do
28375 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
28383 lfs df $inodes $dir
28384 error "df and lfs df $1 output mismatch: " \
28385 "df ${inodes}: ${df_out[*]}, " \
28386 "lfs df ${inodes}: ${lfs_df_out[*]}"
28391 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28393 local dir=$DIR/$tdir
28394 local numfiles=$((RANDOM % 4096 + 2))
28395 local numblocks=$((RANDOM % 256 + 1))
28397 wait_delete_completed
28400 # check block output
28401 check_lfs_df blocks $dir
28402 # check inode output
28403 check_lfs_df inodes $dir
28405 # create a single file and retest
28406 echo "Creating a single file and testing"
28407 createmany -o $dir/$tfile- 1 &>/dev/null ||
28408 error "creating 1 file in $dir failed"
28409 check_lfs_df blocks $dir
28410 check_lfs_df inodes $dir
28412 # create a random number of files
28413 echo "Creating $((numfiles - 1)) files and testing"
28414 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
28415 error "creating $((numfiles - 1)) files in $dir failed"
28417 # write a random number of blocks to the first test file
28418 echo "Writing $numblocks 4K blocks and testing"
28419 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
28420 count=$numblocks &>/dev/null ||
28421 error "dd to $dir/${tfile}-0 failed"
28424 check_lfs_df blocks $dir
28425 check_lfs_df inodes $dir
28427 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
28428 error "unlinking $numfiles files in $dir failed"
28430 run_test 418 "df and lfs df outputs match"
28434 local dir=$DIR/$tdir
28439 cancel_lru_locks mdc
28441 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
28442 $LCTL set_param fail_loc=0x1410
28444 $LCTL set_param fail_loc=0
28447 run_test 419 "Verify open file by name doesn't crash kernel"
28451 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
28452 skip "Need MDS version at least 2.12.53"
28454 local SAVE_UMASK=$(umask)
28455 local dir=$DIR/$tdir
28456 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
28460 mkdir -m03777 $dir/testdir
28461 ls -dn $dir/testdir
28462 # Need to remove trailing '.' when SELinux is enabled
28463 local dirperms=$(ls -dn $dir/testdir |
28464 awk '{ sub(/\.$/, "", $1); print $1}')
28465 [ $dirperms == "drwxrwsrwt" ] ||
28466 error "incorrect perms on $dir/testdir"
28468 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
28469 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
28470 ls -n $dir/testdir/testfile
28471 local fileperms=$(ls -n $dir/testdir/testfile |
28472 awk '{ sub(/\.$/, "", $1); print $1}')
28473 [ $fileperms == "-rwxr-xr-x" ] ||
28474 error "incorrect perms on $dir/testdir/testfile"
28478 run_test 420 "clear SGID bit on non-directories for non-members"
28485 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28486 skip "Need MDS version at least 2.12.54"
28488 test_mkdir $DIR/$tdir
28489 createmany -o $DIR/$tdir/f 3
28490 cnt=$(ls -1 $DIR/$tdir | wc -l)
28491 [ $cnt != 3 ] && error "unexpected #files: $cnt"
28493 fid1=$(lfs path2fid $DIR/$tdir/f1)
28494 fid2=$(lfs path2fid $DIR/$tdir/f2)
28495 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
28497 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
28498 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
28500 cnt=$(ls -1 $DIR/$tdir | wc -l)
28501 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
28503 rm -f $DIR/$tdir/f3 || error "can't remove f3"
28504 createmany -o $DIR/$tdir/f 3
28505 cnt=$(ls -1 $DIR/$tdir | wc -l)
28506 [ $cnt != 3 ] && error "unexpected #files: $cnt"
28508 fid1=$(lfs path2fid $DIR/$tdir/f1)
28509 fid2=$(lfs path2fid $DIR/$tdir/f2)
28510 echo "remove using fsname $FSNAME"
28511 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
28513 cnt=$(ls -1 $DIR/$tdir | wc -l)
28514 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
28516 run_test 421a "simple rm by fid"
28523 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28524 skip "Need MDS version at least 2.12.54"
28526 test_mkdir $DIR/$tdir
28527 createmany -o $DIR/$tdir/f 3
28528 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
28531 FID1=$(lfs path2fid $DIR/$tdir/f1)
28532 FID2=$(lfs path2fid $DIR/$tdir/f2)
28533 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
28535 kill -USR1 $MULTIPID
28538 cnt=$(ls $DIR/$tdir | wc -l)
28539 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
28541 run_test 421b "rm by fid on open file"
28547 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28548 skip "Need MDS version at least 2.12.54"
28550 test_mkdir $DIR/$tdir
28551 createmany -o $DIR/$tdir/f 3
28552 touch $DIR/$tdir/$tfile
28553 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
28554 cnt=$(ls -1 $DIR/$tdir | wc -l)
28555 [ $cnt != 184 ] && error "unexpected #files: $cnt"
28557 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
28558 $LFS rmfid $DIR $FID1 || error "rmfid failed"
28560 cnt=$(ls $DIR/$tdir | wc -l)
28561 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
28563 run_test 421c "rm by fid against hardlinked files"
28569 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28570 skip "Need MDS version at least 2.12.54"
28572 test_mkdir $DIR/$tdir
28573 createmany -o $DIR/$tdir/f 4097
28574 cnt=$(ls -1 $DIR/$tdir | wc -l)
28575 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
28577 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
28578 $LFS rmfid $DIR $FIDS || error "rmfid failed"
28580 cnt=$(ls $DIR/$tdir | wc -l)
28582 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
28584 run_test 421d "rmfid en masse"
28590 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
28591 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28592 skip "Need MDS version at least 2.12.54"
28594 mkdir -p $DIR/$tdir
28595 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
28596 createmany -o $DIR/$tdir/striped_dir/f 512
28597 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
28598 [ $cnt != 512 ] && error "unexpected #files: $cnt"
28600 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
28601 sed "s/[/][^:]*://g")
28602 $LFS rmfid $DIR $FIDS || error "rmfid failed"
28604 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
28606 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
28608 run_test 421e "rmfid in DNE"
28614 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28615 skip "Need MDS version at least 2.12.54"
28617 test_mkdir $DIR/$tdir
28619 cnt=$(ls -1 $DIR/$tdir | wc -l)
28620 [ $cnt != 1 ] && error "unexpected #files: $cnt"
28622 FID=$(lfs path2fid $DIR/$tdir/f)
28623 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
28624 # rmfid should fail
28625 cnt=$(ls -1 $DIR/$tdir | wc -l)
28626 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
28628 chmod a+rw $DIR/$tdir
28630 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
28631 # rmfid should fail
28632 cnt=$(ls -1 $DIR/$tdir | wc -l)
28633 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
28636 $RUNAS touch $DIR/$tdir/f
28637 FID=$(lfs path2fid $DIR/$tdir/f)
28638 echo "rmfid as root"
28639 $LFS rmfid $DIR $FID || error "rmfid as root failed"
28640 cnt=$(ls -1 $DIR/$tdir | wc -l)
28641 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
28644 $RUNAS touch $DIR/$tdir/f
28645 cnt=$(ls -1 $DIR/$tdir | wc -l)
28646 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
28647 FID=$(lfs path2fid $DIR/$tdir/f)
28648 # rmfid w/o user_fid2path mount option should fail
28649 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
28650 cnt=$(ls -1 $DIR/$tdir | wc -l)
28651 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
28653 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
28654 stack_trap "rmdir $tmpdir"
28655 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
28656 error "failed to mount client'"
28657 stack_trap "umount_client $tmpdir"
28659 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
28660 # rmfid should succeed
28661 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
28662 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
28664 # rmfid shouldn't allow to remove files due to dir's permission
28665 chmod a+rwx $tmpdir/$tdir
28666 touch $tmpdir/$tdir/f
28667 ls -la $tmpdir/$tdir
28668 FID=$(lfs path2fid $tmpdir/$tdir/f)
28669 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
28672 run_test 421f "rmfid checks permissions"
28678 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
28679 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28680 skip "Need MDS version at least 2.12.54"
28682 mkdir -p $DIR/$tdir
28683 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
28684 createmany -o $DIR/$tdir/striped_dir/f 512
28685 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
28686 [ $cnt != 512 ] && error "unexpected #files: $cnt"
28688 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
28689 sed "s/[/][^:]*://g")
28691 rm -f $DIR/$tdir/striped_dir/f1*
28692 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
28693 removed=$((512 - cnt))
28695 # few files have been just removed, so we expect
28696 # rmfid to fail on their fids
28697 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
28698 [ $removed != $errors ] && error "$errors != $removed"
28700 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
28702 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
28704 run_test 421g "rmfid to return errors properly"
28716 (( MDS1_VERSION >= $(version_code 2.15.53) )) ||
28717 skip "Need MDS version at least 2.15.53"
28719 test_mkdir $DIR/$tdir
28720 test_mkdir $DIR/$tdir/subdir
28721 touch $DIR/$tdir/subdir/file0
28722 old_fid=$(lfs path2fid $DIR/$tdir/subdir/file0 | sed "s/[/][^:]*://g")
28723 echo File $DIR/$tdir/subdir/file0 FID $old_fid
28724 rm -f $DIR/$tdir/subdir/file0
28725 touch $DIR/$tdir/subdir/fileA
28726 fidA=$(lfs path2fid $DIR/$tdir/subdir/fileA | sed "s/[/][^:]*://g")
28727 echo File $DIR/$tdir/subdir/fileA FID $fidA
28728 touch $DIR/$tdir/subdir/fileB
28729 fidB=$(lfs path2fid $DIR/$tdir/subdir/fileB | sed "s/[/][^:]*://g")
28730 echo File $DIR/$tdir/subdir/fileB FID $fidB
28731 ln $DIR/$tdir/subdir/fileB $DIR/$tdir/subdir/fileB_hl
28732 touch $DIR/$tdir/subdir/fileC
28733 fidC=$(lfs path2fid $DIR/$tdir/subdir/fileC | sed "s/[/][^:]*://g")
28734 echo File $DIR/$tdir/subdir/fileC FID $fidC
28735 ln $DIR/$tdir/subdir/fileC $DIR/$tdir/fileC
28736 touch $DIR/$tdir/fileD
28737 fidD=$(lfs path2fid $DIR/$tdir/fileD | sed "s/[/][^:]*://g")
28738 echo File $DIR/$tdir/fileD FID $fidD
28740 # mount another client mount point with subdirectory mount
28741 export FILESET=/$tdir/subdir
28742 mount_other=${MOUNT}_other
28743 mount_client $mount_other ${MOUNT_OPTS}
28746 (( mount_ret == 0 )) || error "mount $mount_other failed"
28748 echo Removing FIDs:
28749 echo $LFS rmfid $mount_other $old_fid $fidA $fidD $fidB $fidC
28750 $LFS rmfid $mount_other $old_fid $fidA $fidD $fidB $fidC
28753 umount_client $mount_other || error "umount $mount_other failed"
28755 (( rmfid_ret != 0 )) || error "rmfid should have failed"
28757 # fileA should have been deleted
28758 stat $DIR/$tdir/subdir/fileA && error "fileA not deleted"
28760 # fileB should have been deleted
28761 stat $DIR/$tdir/subdir/fileB && error "fileB not deleted"
28763 # fileC should not have been deleted, fid also exists outside of fileset
28764 stat $DIR/$tdir/subdir/fileC || error "fileC deleted"
28766 # fileD should not have been deleted, it exists outside of fileset
28767 stat $DIR/$tdir/fileD || error "fileD deleted"
28769 run_test 421h "rmfid with fileset mount"
28772 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
28773 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
28774 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
28775 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
28776 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
28778 local amc=$(at_max_get client)
28779 local amo=$(at_max_get mds1)
28780 local timeout=`lctl get_param -n timeout`
28782 at_max_set 0 client
28785 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
28786 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
28787 fail_val=$(((2*timeout + 10)*1000))
28788 touch $DIR/$tdir/d3/file &
28790 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
28791 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
28792 fail_val=$((2*timeout + 5))
28793 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
28797 sleep $((2 * timeout))
28801 touch $DIR/$tdir/d2/file3
28802 touch $DIR/$tdir/d2/file4
28803 touch $DIR/$tdir/d2/file5
28806 at_max_set $amc client
28807 at_max_set $amo mds1
28809 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
28810 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
28811 error "Watchdog is always throttled"
28813 run_test 422 "kill a process with RPC in progress"
28826 # ensure statfs cache is expired
28829 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
28830 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
28834 run_test 423 "statfs should return a right data"
28837 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | CFS_FAIL_ONCE
28838 $LCTL set_param fail_loc=0x80000522
28839 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
28842 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
28845 test_mkdir -c -1 $DIR/$tdir
28846 $LFS setstripe -c -1 $DIR/$tdir
28848 lru_resize_disable "" 100
28849 stack_trap "lru_resize_enable" EXIT
28853 for i in $(seq $((MDSCOUNT * 125))); do
28854 local t=$DIR/$tdir/$tfile_$i
28856 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
28857 error_noexit "Create file $t"
28859 stack_trap "rm -rf $DIR/$tdir" EXIT
28861 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
28862 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
28863 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
28865 [ $lock_count -le $lru_size ] ||
28866 error "osc lock count $lock_count > lru size $lru_size"
28869 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
28870 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
28871 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
28873 [ $lock_count -le $lru_size ] ||
28874 error "mdc lock count $lock_count > lru size $lru_size"
28877 run_test 425 "lock count should not exceed lru size"
28880 splice-test -r $DIR/$tfile
28881 splice-test -rd $DIR/$tfile
28882 splice-test $DIR/$tfile
28883 splice-test -d $DIR/$tfile
28885 run_test 426 "splice test on Lustre"
28888 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
28889 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
28890 skip "Need MDS version at least 2.12.4"
28896 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
28897 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
28899 $LFS getdirstripe $DIR/$tdir/1/dir
28901 #first setfattr for creating updatelog
28902 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
28904 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
28905 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
28906 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
28907 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
28911 wait_recovery_complete mds2 $((2*TIMEOUT))
28913 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
28914 echo $log | grep "get update log failed" &&
28915 error "update log corruption is detected" || true
28917 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
28920 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28921 local max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
28922 awk '/^max_cached_mb/ { print $2 }')
28923 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$max_cached_mb"
28925 $LCTL set_param -n llite.*.max_cached_mb=64
28928 $LFS setstripe -c 1 $DIR/$tdir
28929 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
28930 stack_trap "rm -f $DIR/$tdir/$tfile.*"
28932 for f in $(seq 4); do
28933 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
28937 cancel_lru_locks osc
28939 for f in $(seq 4); do
28940 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
28944 run_test 428 "large block size IO should not hang"
28946 test_429() { # LU-7915 / LU-10948
28947 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
28948 local testfile=$DIR/$tfile
28949 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
28955 $LCTL get_param $ll_opencache_threshold_count ||
28956 skip "client does not have opencache parameter"
28958 set_opencache $new_flag
28959 stack_trap "restore_opencache"
28960 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
28961 error "enable opencache failed"
28963 # drop MDC DLM locks
28964 cancel_lru_locks mdc
28965 # clear MDC RPC stats counters
28966 $LCTL set_param $mdc_rpcstats=clear
28968 # According to the current implementation, we need to run 3 times
28969 # open & close file to verify if opencache is enabled correctly.
28970 # 1st, RPCs are sent for lookup/open and open handle is released on
28972 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
28973 # so open handle won't be released thereafter.
28974 # 3rd, No RPC is sent out.
28975 $MULTIOP $testfile oc || error "multiop failed"
28976 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
28977 echo "1st: $first_rpc RPCs in flight"
28979 $MULTIOP $testfile oc || error "multiop failed"
28980 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
28981 echo "2nd: $second_rpc RPCs in flight"
28983 $MULTIOP $testfile oc || error "multiop failed"
28984 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
28985 echo "3rd: $third_rpc RPCs in flight"
28987 #verify no MDC RPC is sent
28988 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
28990 run_test 429 "verify if opencache flag on client side does work"
28996 # data at [200K, 400K)
28997 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
28998 error "256K->512K dd fails"
29000 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
29001 error "2M->3M dd fails"
29003 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
29004 error "4M->5M dd fails"
29005 echo "Data at 256K...512K, 2M...3M and 4M...5M"
29006 # start at first component hole #1
29007 printf "Seeking hole from 1000 ... "
29008 offset=$(lseek_test -l 1000 $file)
29010 [[ $offset == 1000 ]] || error "offset $offset != 1000"
29011 printf "Seeking data from 1000 ... "
29012 offset=$(lseek_test -d 1000 $file)
29014 [[ $offset == 262144 ]] || error "offset $offset != 262144"
29016 # start at first component data block
29017 printf "Seeking hole from 300000 ... "
29018 offset=$(lseek_test -l 300000 $file)
29020 [[ $offset == 524288 ]] || error "offset $offset != 524288"
29021 printf "Seeking data from 300000 ... "
29022 offset=$(lseek_test -d 300000 $file)
29024 [[ $offset == 300000 ]] || error "offset $offset != 300000"
29026 # start at the first component but beyond end of object size
29027 printf "Seeking hole from 1000000 ... "
29028 offset=$(lseek_test -l 1000000 $file)
29030 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
29031 printf "Seeking data from 1000000 ... "
29032 offset=$(lseek_test -d 1000000 $file)
29034 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
29036 # start at second component stripe 2 (empty file)
29037 printf "Seeking hole from 1500000 ... "
29038 offset=$(lseek_test -l 1500000 $file)
29040 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
29041 printf "Seeking data from 1500000 ... "
29042 offset=$(lseek_test -d 1500000 $file)
29044 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
29046 # start at second component stripe 1 (all data)
29047 printf "Seeking hole from 3000000 ... "
29048 offset=$(lseek_test -l 3000000 $file)
29050 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
29051 printf "Seeking data from 3000000 ... "
29052 offset=$(lseek_test -d 3000000 $file)
29054 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
29056 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
29057 error "2nd dd fails"
29058 echo "Add data block at 640K...1280K"
29060 # start at before new data block, in hole
29061 printf "Seeking hole from 600000 ... "
29062 offset=$(lseek_test -l 600000 $file)
29064 [[ $offset == 600000 ]] || error "offset $offset != 600000"
29065 printf "Seeking data from 600000 ... "
29066 offset=$(lseek_test -d 600000 $file)
29068 [[ $offset == 655360 ]] || error "offset $offset != 655360"
29070 # start at the first component new data block
29071 printf "Seeking hole from 1000000 ... "
29072 offset=$(lseek_test -l 1000000 $file)
29074 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
29075 printf "Seeking data from 1000000 ... "
29076 offset=$(lseek_test -d 1000000 $file)
29078 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
29080 # start at second component stripe 2, new data
29081 printf "Seeking hole from 1200000 ... "
29082 offset=$(lseek_test -l 1200000 $file)
29084 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
29085 printf "Seeking data from 1200000 ... "
29086 offset=$(lseek_test -d 1200000 $file)
29088 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
29090 # start beyond file end
29091 printf "Using offset > filesize ... "
29092 lseek_test -l 4000000 $file && error "lseek should fail"
29093 printf "Using offset > filesize ... "
29094 lseek_test -d 4000000 $file && error "lseek should fail"
29100 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
29101 skip "MDT does not support SEEK_HOLE"
29103 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
29104 skip "OST does not support SEEK_HOLE"
29106 local file=$DIR/$tdir/$tfile
29108 mkdir -p $DIR/$tdir
29110 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
29111 # OST stripe #1 will have continuous data at [1M, 3M)
29112 # OST stripe #2 is empty
29113 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
29114 lseek_test_430 $file
29116 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
29117 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
29118 lseek_test_430 $file
29120 $LFS setstripe -c2 -S 512K $file
29121 echo "Two stripes, stripe size 512K"
29122 lseek_test_430 $file
29124 # FLR with stale mirror
29125 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
29127 echo "Mirrored file:"
29128 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
29129 echo "Plain 2 stripes 1M"
29130 lseek_test_430 $file
29133 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
29136 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
29137 skip "OST does not support SEEK_HOLE"
29140 local file=$DIR/$tdir/$tfile
29142 mkdir -p $DIR/$tdir
29143 # Empty layout lseek should fail
29146 printf "Seeking hole from 0 ... "
29147 lseek_test -l 0 $file && error "lseek should fail"
29148 printf "Seeking data from 0 ... "
29149 lseek_test -d 0 $file && error "lseek should fail"
29153 $LFS setstripe -E 1M -c2 -E eof $file
29154 $TRUNCATE $file 1048576
29155 printf "Seeking hole from 1000000 ... "
29156 offset=$(lseek_test -l 1000000 $file)
29158 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
29159 printf "Seeking data from 1000000 ... "
29160 lseek_test -d 1000000 $file && error "lseek should fail"
29163 # full component followed by non-inited one
29164 $LFS setstripe -E 1M -c2 -E eof $file
29165 dd if=/dev/urandom of=$file bs=1M count=1
29166 printf "Seeking hole from 1000000 ... "
29167 offset=$(lseek_test -l 1000000 $file)
29169 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
29170 printf "Seeking hole from 1048576 ... "
29171 lseek_test -l 1048576 $file && error "lseek should fail"
29172 # init second component and truncate back
29173 echo "123" >> $file
29174 $TRUNCATE $file 1048576
29175 printf "Seeking hole from 1000000 ... "
29176 offset=$(lseek_test -l 1000000 $file)
29178 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
29179 printf "Seeking hole from 1048576 ... "
29180 lseek_test -l 1048576 $file && error "lseek should fail"
29181 # boundary checks for big values
29182 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
29183 offset=$(lseek_test -d 0 $file.10g)
29184 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
29185 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
29186 offset=$(lseek_test -d 0 $file.100g)
29187 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
29190 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
29193 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
29194 skip "OST does not support SEEK_HOLE"
29196 local file=$DIR/$tdir/$tfile
29199 mkdir -p $DIR/$tdir
29200 stack_trap "rm -f $file $file.tmp"
29201 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M || error "dd failed"
29203 # cp version 8.33+ prefers lseek over fiemap
29204 local ver=$(cp --version | awk '{ print $4; exit; }')
29206 echo "cp $ver installed"
29207 if (( $(version_code $ver) >= $(version_code 8.33) )); then
29209 time cp -v $file $file.tmp || error "cp $file failed"
29210 (( SECONDS - start < 5 )) || {
29211 strace cp $file $file.tmp |&
29212 grep -E "open|read|seek|FIEMAP" |
29214 error "cp: too long runtime $((SECONDS - start))"
29217 echo "cp test skipped due to $ver < 8.33"
29220 # tar version 1.29+ supports SEEK_HOLE/DATA
29221 ver=$(tar --version | awk '{ print $4; exit; }')
29222 echo "tar $ver installed"
29223 if (( $(version_code $ver) >= $(version_code 1.29) )); then
29225 time tar cvf $file.tmp --sparse $file || error "tar $file error"
29226 (( SECONDS - start < 5 )) || {
29227 strace tar cf $file.tmp --sparse $file |&
29228 grep -E "open|read|seek|FIEMAP" |
29230 error "tar: too long runtime $((SECONDS - start))"
29233 echo "tar test skipped due to $ver < 1.29"
29236 run_test 430c "lseek: external tools check"
29238 test_431() { # LU-14187
29239 local file=$DIR/$tdir/$tfile
29241 mkdir -p $DIR/$tdir
29242 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
29243 dd if=/dev/urandom of=$file bs=4k count=1
29244 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
29245 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
29246 #define OBD_FAIL_OST_RESTART_IO 0x251
29247 do_facet ost1 "$LCTL set_param fail_loc=0x251"
29248 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
29252 echo 3 > /proc/sys/vm/drop_caches
29253 diff $file $file.0 || error "data diff"
29255 run_test 431 "Restart transaction for IO"
29257 cleanup_test_432() {
29258 do_facet mgs $LCTL nodemap_activate 0
29259 wait_nm_sync active
29263 local tmpdir=$TMP/dir432
29265 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
29266 skip "Need MDS version at least 2.14.52"
29268 stack_trap cleanup_test_432 EXIT
29272 do_facet mgs $LCTL nodemap_activate 1
29273 wait_nm_sync active
29274 do_facet mgs $LCTL nodemap_modify --name default \
29275 --property admin --value 1
29276 do_facet mgs $LCTL nodemap_modify --name default \
29277 --property trusted --value 1
29278 cancel_lru_locks mdc
29279 wait_nm_sync default admin_nodemap
29280 wait_nm_sync default trusted_nodemap
29282 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
29283 grep -ci "Operation not permitted") -ne 0 ]; then
29284 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
29287 run_test 432 "mv dir from outside Lustre"
29290 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29292 [[ -n "$($LCTL list_param llite.*.inode_cache 2>/dev/null)" ]] ||
29293 skip "inode cache not supported"
29295 $LCTL set_param llite.*.inode_cache=0
29296 stack_trap "$LCTL set_param llite.*.inode_cache=1"
29302 cancel_lru_locks mdc
29303 test_mkdir $DIR/$tdir || error "mkdir $tdir"
29304 createmany -m $DIR/$tdir/f $count
29305 createmany -d $DIR/$tdir/d $count
29306 ls -l $DIR/$tdir > /dev/null
29307 stack_trap "rm -rf $DIR/$tdir"
29309 before=$(num_objects)
29310 cancel_lru_locks mdc
29311 after=$(num_objects)
29313 # sometimes even @before is less than 2 * count
29314 while (( before - after < count )); do
29316 after=$(num_objects)
29318 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
29319 if (( wait > 60 )); then
29320 error "inode slab grew from $before to $after"
29324 echo "lustre_inode_cache $before objs before lock cancel, $after after"
29326 run_test 433 "ldlm lock cancel releases dentries and inodes"
29330 local getxattr_count
29331 local mdc_stat_param="mdc.$FSNAME-MDT0000*.md_stats"
29332 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
29334 [[ $(getenforce) == "Disabled" ]] ||
29335 skip "lsm selinux module have to be disabled for this test"
29337 test_mkdir -i 0 -c1 $DIR/$tdir/ ||
29338 error "fail to create $DIR/$tdir/ on MDT0000"
29340 touch $DIR/$tdir/$tfile-{001..100}
29342 # disable the xattr cache
29343 save_lustre_params client "llite.*.xattr_cache" > $p
29344 lctl set_param llite.*.xattr_cache=0
29345 stack_trap "restore_lustre_params < $p; rm -f $p" EXIT
29347 # clear clients mdc stats
29348 clear_stats $mdc_stat_param ||
29349 error "fail to clear stats on mdc MDT0000"
29351 for file in $DIR/$tdir/$tfile-{001..100}; do
29352 getfattr -n security.selinux $file |&
29353 grep -q "Operation not supported" ||
29354 error "getxattr on security.selinux should return EOPNOTSUPP"
29357 getxattr_count=$(calc_stats $mdc_stat_param "getxattr")
29358 (( getxattr_count < 100 )) ||
29359 error "client sent $getxattr_count getxattr RPCs to the MDS"
29361 run_test 434 "Client should not send RPCs for security.selinux with SElinux disabled"
29364 if [[ -f $LUSTRE/scripts/bash-completion/lustre ]]; then
29365 source $LUSTRE/scripts/bash-completion/lustre
29366 elif [[ -f /usr/share/bash-completion/completions/lustre ]]; then
29367 source /usr/share/bash-completion/completions/lustre
29369 skip "bash completion scripts not found"
29372 local lctl_completions
29373 local lfs_completions
29375 lctl_completions=$(_lustre_cmds lctl)
29376 if [[ ! $lctl_completions =~ "get_param" ]]; then
29377 error "lctl bash completion failed"
29380 lfs_completions=$(_lustre_cmds lfs)
29381 if [[ ! $lfs_completions =~ "setstripe" ]]; then
29382 error "lfs bash completion failed"
29385 run_test 440 "bash completion for lfs, lctl"
29388 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
29389 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
29390 skip "Need server version at least 2.9.55"
29392 start_full_debug_logging
29396 stop_full_debug_logging
29400 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
29401 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
29402 awk '/The barrier for/ { print $7 }')
29405 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
29410 barrier_expired() {
29413 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
29414 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
29415 awk '/will be expired/ { print $7 }')
29417 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
29426 echo "Start barrier_freeze at: $(date)"
29427 #define OBD_FAIL_BARRIER_DELAY 0x2202
29428 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
29429 # Do not reduce barrier time - See LU-11873
29430 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
29433 local b_status=$(barrier_stat)
29434 echo "Got barrier status at: $(date)"
29435 [ "$b_status" = "'freezing_p1'" ] ||
29436 error "(1) unexpected barrier status $b_status"
29438 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
29440 b_status=$(barrier_stat)
29441 [ "$b_status" = "'frozen'" ] ||
29442 error "(2) unexpected barrier status $b_status"
29444 local expired=$(barrier_expired)
29445 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
29446 sleep $((expired + 3))
29448 b_status=$(barrier_stat)
29449 [ "$b_status" = "'expired'" ] ||
29450 error "(3) unexpected barrier status $b_status"
29452 # Do not reduce barrier time - See LU-11873
29453 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
29454 error "(4) fail to freeze barrier"
29456 b_status=$(barrier_stat)
29457 [ "$b_status" = "'frozen'" ] ||
29458 error "(5) unexpected barrier status $b_status"
29460 echo "Start barrier_thaw at: $(date)"
29461 #define OBD_FAIL_BARRIER_DELAY 0x2202
29462 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
29463 do_facet mgs $LCTL barrier_thaw $FSNAME &
29466 b_status=$(barrier_stat)
29467 echo "Got barrier status at: $(date)"
29468 [ "$b_status" = "'thawing'" ] ||
29469 error "(6) unexpected barrier status $b_status"
29471 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
29473 b_status=$(barrier_stat)
29474 [ "$b_status" = "'thawed'" ] ||
29475 error "(7) unexpected barrier status $b_status"
29477 #define OBD_FAIL_BARRIER_FAILURE 0x2203
29478 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
29479 do_facet mgs $LCTL barrier_freeze $FSNAME
29481 b_status=$(barrier_stat)
29482 [ "$b_status" = "'failed'" ] ||
29483 error "(8) unexpected barrier status $b_status"
29485 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
29486 do_facet mgs $LCTL barrier_thaw $FSNAME
29490 run_test 801a "write barrier user interfaces and stat machine"
29495 mkdir $DIR/$tdir || error "(1) fail to mkdir"
29496 createmany -d $DIR/$tdir/d 6 || error "(2) fail to mkdir"
29497 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
29498 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
29499 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
29501 cancel_lru_locks mdc
29503 # 180 seconds should be long enough
29504 do_facet mgs $LCTL barrier_freeze $FSNAME 180
29506 local b_status=$(barrier_stat)
29507 [ "$b_status" = "'frozen'" ] ||
29508 error "(6) unexpected barrier status $b_status"
29510 mkdir $DIR/$tdir/d0/d10 &
29513 touch $DIR/$tdir/d1/f13 &
29516 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
29519 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
29522 rm -f $DIR/$tdir/d4/f12 &
29525 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
29527 # To guarantee taht the 'stat' is not blocked
29528 b_status=$(barrier_stat)
29529 [ "$b_status" = "'frozen'" ] ||
29530 error "(8) unexpected barrier status $b_status"
29532 # let above commands to run at background
29535 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
29536 ps -p $touch_pid || error "(10) touch should be blocked"
29537 ps -p $ln_pid || error "(11) link should be blocked"
29538 ps -p $mv_pid || error "(12) rename should be blocked"
29539 ps -p $rm_pid || error "(13) unlink should be blocked"
29541 b_status=$(barrier_stat)
29542 [ "$b_status" = "'frozen'" ] ||
29543 error "(14) unexpected barrier status $b_status"
29545 do_facet mgs $LCTL barrier_thaw $FSNAME
29546 b_status=$(barrier_stat)
29547 [ "$b_status" = "'thawed'" ] ||
29548 error "(15) unexpected barrier status $b_status"
29550 wait $mkdir_pid || error "(16) mkdir should succeed"
29551 wait $touch_pid || error "(17) touch should succeed"
29552 wait $ln_pid || error "(18) link should succeed"
29553 wait $mv_pid || error "(19) rename should succeed"
29554 wait $rm_pid || error "(20) unlink should succeed"
29558 run_test 801b "modification will be blocked by write barrier"
29561 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
29565 stop mds2 || error "(1) Fail to stop mds2"
29567 do_facet mgs $LCTL barrier_freeze $FSNAME 30
29569 local b_status=$(barrier_stat)
29570 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
29571 do_facet mgs $LCTL barrier_thaw $FSNAME
29572 error "(2) unexpected barrier status $b_status"
29575 do_facet mgs $LCTL barrier_rescan $FSNAME ||
29576 error "(3) Fail to rescan barrier bitmap"
29578 # Do not reduce barrier time - See LU-11873
29579 do_facet mgs $LCTL barrier_freeze $FSNAME 20
29581 b_status=$(barrier_stat)
29582 [ "$b_status" = "'frozen'" ] ||
29583 error "(4) unexpected barrier status $b_status"
29585 do_facet mgs $LCTL barrier_thaw $FSNAME
29586 b_status=$(barrier_stat)
29587 [ "$b_status" = "'thawed'" ] ||
29588 error "(5) unexpected barrier status $b_status"
29590 local devname=$(mdsdevname 2)
29592 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
29594 do_facet mgs $LCTL barrier_rescan $FSNAME ||
29595 error "(7) Fail to rescan barrier bitmap"
29599 run_test 801c "rescan barrier bitmap"
29602 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29603 remote_mds_nodsh && skip "remote MDS with nodsh"
29605 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
29606 skip "readonly option not available"
29608 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
29610 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
29611 error "(2) Fail to copy"
29613 # write back all cached data before setting MDT to readonly
29617 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
29618 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
29620 echo "Modify should be refused"
29621 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
29623 echo "Read should be allowed"
29624 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
29625 error "(7) Read should succeed under ro mode"
29628 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
29630 run_test 802b "be able to set MDTs to readonly"
29633 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
29634 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
29635 skip "MDS needs to be newer than 2.10.54"
29637 mkdir_on_mdt0 $DIR/$tdir
29638 # Create some objects on all MDTs to trigger related logs objects
29639 for idx in $(seq $MDSCOUNT); do
29640 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
29641 $DIR/$tdir/dir${idx} ||
29642 error "Fail to create $DIR/$tdir/dir${idx}"
29645 wait_delete_completed # ensure old test cleanups are finished
29647 echo "before create:"
29649 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
29651 for i in {1..10}; do
29652 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
29653 error "Fail to create $DIR/$tdir/foo$i"
29656 # sync ZFS-on-MDS to refresh statfs data
29657 wait_zfs_commit mds1
29659 echo "after create:"
29661 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
29663 # allow for an llog to be cleaned up during the test
29664 [ $after_used -ge $((before_used + 10 - 1)) ] ||
29665 error "before ($before_used) + 10 > after ($after_used)"
29667 for i in {1..10}; do
29668 rm -rf $DIR/$tdir/foo$i ||
29669 error "Fail to remove $DIR/$tdir/foo$i"
29672 # sync ZFS-on-MDS to refresh statfs data
29673 wait_zfs_commit mds1
29674 wait_delete_completed
29675 sleep 3 # avoid MDT return cached statfs
29676 echo "after unlink:"
29678 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
29680 # allow for an llog to be created during the test
29681 [ $after_used -le $((before_used + 1)) ] ||
29682 error "after ($after_used) > before ($before_used) + 1"
29684 run_test 803a "verify agent object for remote object"
29687 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
29688 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
29689 skip "MDS needs to be newer than 2.13.56"
29690 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29692 for i in $(seq 0 $((MDSCOUNT - 1))); do
29693 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
29701 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
29702 for i in $(seq 0 $((MDSCOUNT - 1))); do
29703 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
29704 awk '/getattr/ { print $2 }')
29705 before=$((before + tmp))
29707 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
29708 for i in $(seq 0 $((MDSCOUNT - 1))); do
29709 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
29710 awk '/getattr/ { print $2 }')
29711 after=$((after + tmp))
29714 [ $before -eq $after ] || error "getattr count $before != $after"
29716 run_test 803b "remote object can getattr from cache"
29719 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
29720 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
29721 skip "MDS needs to be newer than 2.10.54"
29722 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
29724 mkdir -p $DIR/$tdir
29725 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
29726 error "Fail to create $DIR/$tdir/dir0"
29728 local fid=$($LFS path2fid $DIR/$tdir/dir0)
29729 local dev=$(mdsdevname 2)
29731 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
29732 grep ${fid} || error "NOT found agent entry for dir0"
29734 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
29735 error "Fail to create $DIR/$tdir/dir1"
29737 touch $DIR/$tdir/dir1/foo0 ||
29738 error "Fail to create $DIR/$tdir/dir1/foo0"
29739 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
29742 for idx in $(seq $MDSCOUNT); do
29743 dev=$(mdsdevname $idx)
29744 do_facet mds${idx} \
29745 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
29746 grep ${fid} && rc=$idx
29749 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
29750 error "Fail to rename foo0 to foo1"
29751 if [ $rc -eq 0 ]; then
29752 for idx in $(seq $MDSCOUNT); do
29753 dev=$(mdsdevname $idx)
29754 do_facet mds${idx} \
29755 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
29756 grep ${fid} && rc=$idx
29760 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
29761 error "Fail to rename foo1 to foo2"
29762 if [ $rc -eq 0 ]; then
29763 for idx in $(seq $MDSCOUNT); do
29764 dev=$(mdsdevname $idx)
29765 do_facet mds${idx} \
29766 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
29767 grep ${fid} && rc=$idx
29771 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
29773 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
29774 error "Fail to link to $DIR/$tdir/dir1/foo2"
29775 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
29776 error "Fail to rename foo2 to foo0"
29777 unlink $DIR/$tdir/dir1/foo0 ||
29778 error "Fail to unlink $DIR/$tdir/dir1/foo0"
29779 rm -rf $DIR/$tdir/dir0 ||
29780 error "Fail to rm $DIR/$tdir/dir0"
29782 for idx in $(seq $MDSCOUNT); do
29786 dev=$(mdsdevname $idx)
29787 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
29789 start mds${idx} $dev $MDS_MOUNT_OPTS ||
29790 error "mount mds$idx failed"
29791 df $MOUNT > /dev/null 2>&1
29793 # e2fsck should not return error
29795 error "e2fsck detected error on MDT${idx}: rc=$rc"
29798 run_test 804 "verify agent entry for remote entry"
29801 do_facet $SINGLEMDS zfs set quota=$old $fsset
29802 unlinkmany $DIR/$tdir/f- 1000000
29807 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
29808 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
29809 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
29810 skip "netfree not implemented before 0.7"
29811 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
29812 skip "Need MDS version at least 2.10.57"
29819 local pref="osd-zfs.$FSNAME-MDT0000."
29821 # limit available space on MDS dataset to meet nospace issue
29822 # quickly. then ZFS 0.7.2 can use reserved space if asked
29823 # properly (using netfree flag in osd_declare_destroy()
29824 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
29825 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
29827 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
29828 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
29829 let "usedkb=usedkb-freekb"
29830 let "freekb=freekb/2"
29831 if let "freekb > 5000"; then
29834 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
29835 trap cleanup_805 EXIT
29836 mkdir_on_mdt0 $DIR/$tdir
29837 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
29838 error "Can't set PFL layout"
29839 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
29840 rm -rf $DIR/$tdir || error "not able to remove"
29841 do_facet $SINGLEMDS zfs set quota=$old $fsset
29844 run_test 805 "ZFS can remove from full fs"
29850 local expect=$(stat -c %s $file)
29852 check_lsom_size $1 $expect
29854 local blocks=$($LFS getsom -b $file)
29855 expect=$(stat -c %b $file)
29856 [[ $blocks == $expect ]] ||
29857 error "$file expected blocks: $expect, got: $blocks"
29865 cancel_lru_locks mdc
29867 size=$($LFS getsom -s $1)
29868 [[ $size == $expect ]] ||
29869 error "$file expected size: $expect, got: $size"
29873 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
29874 skip "Need MDS version at least 2.11.52"
29878 $LFS setstripe -c-1 $DIR/$tfile || error "setstripe $tfile failed"
29881 stack_trap "restore_opencache"
29883 # single-threaded write
29884 echo "Test SOM for single-threaded write"
29885 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
29886 error "write $tfile failed"
29887 check_lsom_size $DIR/$tfile $bs
29890 local size=$(($num * $bs))
29894 echo "Test SOM for single client multi-threaded($num) write"
29895 $TRUNCATE $DIR/$tfile 0
29896 for ((i = 0; i < $num; i++)); do
29897 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
29899 offset=$((offset + $bs))
29901 for (( i=0; i < $num; i++ )); do
29904 check_lsom_size $DIR/$tfile $size
29906 $TRUNCATE $DIR/$tfile 0
29907 for ((i = 0; i < $num; i++)); do
29908 offset=$((offset - $bs))
29909 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
29912 for (( i=0; i < $num; i++ )); do
29915 check_lsom_size $DIR/$tfile $size
29917 # multi-client writes
29918 num=$(get_node_count ${CLIENTS//,/ })
29919 size=$(($num * $bs))
29923 echo "Test SOM for multi-client ($num) writes"
29924 $TRUNCATE $DIR/$tfile 0
29925 for client in ${CLIENTS//,/ }; do
29926 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
29929 offset=$((offset + $bs))
29931 for (( i=0; i < $num; i++ )); do
29934 check_lsom_size $DIR/$tfile $offset
29937 $TRUNCATE $DIR/$tfile 0
29938 for client in ${CLIENTS//,/ }; do
29939 offset=$((offset - $bs))
29940 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
29944 for (( i=0; i < $num; i++ )); do
29947 check_lsom_size $DIR/$tfile $size
29949 # verify SOM blocks count
29950 echo "Verify SOM block count"
29951 $TRUNCATE $DIR/$tfile 0
29952 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w$((bs))YSc ||
29953 error "failed to write file $tfile with fdatasync and fstat"
29954 check_lsom_data $DIR/$tfile
29956 $TRUNCATE $DIR/$tfile 0
29957 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w$((bs * 2))Yc ||
29958 error "failed to write file $tfile with fdatasync"
29959 check_lsom_data $DIR/$tfile
29961 $TRUNCATE $DIR/$tfile 0
29962 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:O_SYNC:w$((bs * 3))c ||
29963 error "failed to write file $tfile with sync IO"
29964 check_lsom_data $DIR/$tfile
29967 echo "Test SOM for truncate"
29968 # use ftruncate to sync blocks on close request
29969 $MULTIOP $DIR/$tfile oO_WRONLY:T16384c
29970 check_lsom_size $DIR/$tfile 16384
29971 check_lsom_data $DIR/$tfile
29973 $TRUNCATE $DIR/$tfile 1234
29974 check_lsom_size $DIR/$tfile 1234
29975 # sync blocks on the MDT
29976 $MULTIOP $DIR/$tfile oc
29977 check_lsom_data $DIR/$tfile
29979 run_test 806 "Verify Lazy Size on MDS"
29982 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
29983 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
29984 skip "Need MDS version at least 2.11.52"
29986 # Registration step
29987 changelog_register || error "changelog_register failed"
29988 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
29989 changelog_users $SINGLEMDS | grep -q $cl_user ||
29990 error "User $cl_user not found in changelog_users"
29992 rm -rf $DIR/$tdir || error "rm $tdir failed"
29993 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
29994 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
29995 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
29996 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
29997 error "truncate $tdir/trunc failed"
30000 echo "Test SOM for single-threaded write with fsync"
30001 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
30002 error "write $tfile failed"
30005 # multi-client wirtes
30006 local num=$(get_node_count ${CLIENTS//,/ })
30010 echo "Test SOM for multi-client ($num) writes"
30011 touch $DIR/$tfile || error "touch $tfile failed"
30012 $TRUNCATE $DIR/$tfile 0
30013 for client in ${CLIENTS//,/ }; do
30014 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
30017 offset=$((offset + $bs))
30019 for (( i=0; i < $num; i++ )); do
30023 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
30024 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
30025 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
30026 check_lsom_data $DIR/$tdir/trunc
30027 check_lsom_data $DIR/$tdir/single_dd
30028 check_lsom_data $DIR/$tfile
30031 # Deregistration step
30032 changelog_deregister || error "changelog_deregister failed"
30034 run_test 807 "verify LSOM syncing tool"
30036 check_som_nologged()
30038 local lines=$($LFS changelog $FSNAME-MDT0000 |
30039 grep 'x=trusted.som' | wc -l)
30040 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
30044 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
30045 skip "Need MDS version at least 2.11.55"
30047 # Registration step
30048 changelog_register || error "changelog_register failed"
30050 touch $DIR/$tfile || error "touch $tfile failed"
30053 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
30054 error "write $tfile failed"
30057 $TRUNCATE $DIR/$tfile 1234
30060 $TRUNCATE $DIR/$tfile 1048576
30063 # Deregistration step
30064 changelog_deregister || error "changelog_deregister failed"
30066 run_test 808 "Check trusted.som xattr not logged in Changelogs"
30071 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
30075 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
30076 skip "Need MDS version at least 2.11.56"
30078 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
30079 error "failed to create DoM-only file $DIR/$tfile"
30080 touch $DIR/$tfile || error "touch $tfile failed"
30081 check_som_nodata $DIR/$tfile
30083 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
30084 error "write $tfile failed"
30085 check_som_nodata $DIR/$tfile
30087 $TRUNCATE $DIR/$tfile 1234
30088 check_som_nodata $DIR/$tfile
30090 $TRUNCATE $DIR/$tfile 4097
30091 check_som_nodata $DIR/$file
30093 run_test 809 "Verify no SOM xattr store for DoM-only files"
30096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
30097 $GSS && skip_env "could not run with gss"
30098 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
30099 skip "OST < 2.12.58 doesn't align checksum"
30102 stack_trap "set_checksums $ORIG_CSUM" EXIT
30103 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
30108 for csum in $CKSUM_TYPES; do
30109 #define OBD_FAIL_OSC_NO_GRANT 0x411
30110 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
30111 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
30113 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
30114 before=$(md5sum $DIR/$tfile)
30115 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
30116 after=$(md5sum $DIR/$tfile)
30117 [ "$before" == "$after" ] ||
30118 error "$csum: $before != $after bs=$1 seek=$2"
30122 run_test 810 "partial page writes on ZFS (LU-11663)"
30125 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
30126 skip "OST < 2.12.51 doesn't support this fail_loc"
30128 $LFS setstripe -c 1 -i 0 $DIR/$tfile
30129 # ensure ost1 is connected
30130 stat $DIR/$tfile >/dev/null || error "can't stat"
30131 wait_osc_import_state client ost1 FULL
30132 # no locks, no reqs to let the connection idle
30133 cancel_lru_locks osc
30135 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
30136 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
30137 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
30138 wait_osc_import_state client ost1 CONNECTING
30139 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
30141 stat $DIR/$tfile >/dev/null || error "can't stat file"
30143 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
30145 test_812b() { # LU-12378
30146 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
30147 skip "OST < 2.12.51 doesn't support this fail_loc"
30149 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
30150 # ensure ost1 is connected
30151 stat $DIR/$tfile >/dev/null || error "can't stat"
30152 wait_osc_import_state client ost1 FULL
30153 # no locks, no reqs to let the connection idle
30154 cancel_lru_locks osc
30156 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
30157 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
30158 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
30159 wait_osc_import_state client ost1 CONNECTING
30160 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
30162 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
30163 wait_osc_import_state client ost1 IDLE
30165 run_test 812b "do not drop no resend request for idle connect"
30170 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
30172 $LFS setstripe -c 1 -o 0 $DIR/$tfile
30173 $LFS getstripe $DIR/$tfile
30174 $LCTL set_param osc.*.idle_timeout=10
30175 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
30176 # ensure ost1 is connected
30177 stat $DIR/$tfile >/dev/null || error "can't stat"
30178 wait_osc_import_state client ost1 FULL
30179 # no locks, no reqs to let the connection idle
30180 cancel_lru_locks osc
30182 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
30183 $LCTL set_param fail_loc=0x80000533
30185 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
30187 run_test 812c "idle import vs lock enqueue race"
30190 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
30191 [ -z "$file_heat_sav" ] && skip "no file heat support"
30202 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
30203 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
30205 $LCTL set_param -n llite.*.file_heat=1
30206 echo "Turn on file heat"
30207 echo "Period second: $period_second, Decay percentage: $decay_pct"
30209 echo "QQQQ" > $DIR/$tfile
30210 echo "QQQQ" > $DIR/$tfile
30211 echo "QQQQ" > $DIR/$tfile
30212 cat $DIR/$tfile > /dev/null
30213 cat $DIR/$tfile > /dev/null
30214 cat $DIR/$tfile > /dev/null
30215 cat $DIR/$tfile > /dev/null
30217 local out=$($LFS heat_get $DIR/$tfile)
30219 $LFS heat_get $DIR/$tfile
30220 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30221 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30222 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30223 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30225 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
30226 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
30227 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
30228 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
30230 sleep $((period_second + 3))
30231 echo "Sleep $((period_second + 3)) seconds..."
30232 # The recursion formula to calculate the heat of the file f is as
30234 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
30235 # Where Hi is the heat value in the period between time points i*I and
30236 # (i+1)*I; Ci is the access count in the period; the symbol P refers
30237 # to the weight of Ci.
30238 out=$($LFS heat_get $DIR/$tfile)
30239 $LFS heat_get $DIR/$tfile
30240 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30241 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30242 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30243 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30245 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
30246 error "read sample ($readsample) is wrong"
30247 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
30248 error "write sample ($writesample) is wrong"
30249 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
30250 error "read bytes ($readbyte) is wrong"
30251 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
30252 error "write bytes ($writebyte) is wrong"
30254 echo "QQQQ" > $DIR/$tfile
30255 echo "QQQQ" > $DIR/$tfile
30256 echo "QQQQ" > $DIR/$tfile
30257 cat $DIR/$tfile > /dev/null
30258 cat $DIR/$tfile > /dev/null
30259 cat $DIR/$tfile > /dev/null
30260 cat $DIR/$tfile > /dev/null
30262 sleep $((period_second + 3))
30263 echo "Sleep $((period_second + 3)) seconds..."
30265 out=$($LFS heat_get $DIR/$tfile)
30266 $LFS heat_get $DIR/$tfile
30267 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30268 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30269 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30270 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30272 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
30273 4 * $decay_pct) / 100") -eq 1 ] ||
30274 error "read sample ($readsample1) is wrong"
30275 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
30276 3 * $decay_pct) / 100") -eq 1 ] ||
30277 error "write sample ($writesample1) is wrong"
30278 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
30279 20 * $decay_pct) / 100") -eq 1 ] ||
30280 error "read bytes ($readbyte1) is wrong"
30281 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
30282 15 * $decay_pct) / 100") -eq 1 ] ||
30283 error "write bytes ($writebyte1) is wrong"
30285 echo "Turn off file heat for the file $DIR/$tfile"
30286 $LFS heat_set -o $DIR/$tfile
30288 echo "QQQQ" > $DIR/$tfile
30289 echo "QQQQ" > $DIR/$tfile
30290 echo "QQQQ" > $DIR/$tfile
30291 cat $DIR/$tfile > /dev/null
30292 cat $DIR/$tfile > /dev/null
30293 cat $DIR/$tfile > /dev/null
30294 cat $DIR/$tfile > /dev/null
30296 out=$($LFS heat_get $DIR/$tfile)
30297 $LFS heat_get $DIR/$tfile
30298 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30299 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30300 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30301 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30303 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
30304 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
30305 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
30306 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
30308 echo "Trun on file heat for the file $DIR/$tfile"
30309 $LFS heat_set -O $DIR/$tfile
30311 echo "QQQQ" > $DIR/$tfile
30312 echo "QQQQ" > $DIR/$tfile
30313 echo "QQQQ" > $DIR/$tfile
30314 cat $DIR/$tfile > /dev/null
30315 cat $DIR/$tfile > /dev/null
30316 cat $DIR/$tfile > /dev/null
30317 cat $DIR/$tfile > /dev/null
30319 out=$($LFS heat_get $DIR/$tfile)
30320 $LFS heat_get $DIR/$tfile
30321 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30322 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30323 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30324 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30326 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
30327 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
30328 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
30329 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
30331 $LFS heat_set -c $DIR/$tfile
30332 $LCTL set_param -n llite.*.file_heat=0
30333 echo "Turn off file heat support for the Lustre filesystem"
30335 echo "QQQQ" > $DIR/$tfile
30336 echo "QQQQ" > $DIR/$tfile
30337 echo "QQQQ" > $DIR/$tfile
30338 cat $DIR/$tfile > /dev/null
30339 cat $DIR/$tfile > /dev/null
30340 cat $DIR/$tfile > /dev/null
30341 cat $DIR/$tfile > /dev/null
30343 out=$($LFS heat_get $DIR/$tfile)
30344 $LFS heat_get $DIR/$tfile
30345 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30346 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30347 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30348 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30350 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
30351 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
30352 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
30353 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
30355 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
30358 run_test 813 "File heat verfication"
30362 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
30363 echo -n y >> $DIR/$tfile
30364 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
30365 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
30367 run_test 814 "sparse cp works as expected (LU-12361)"
30371 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
30372 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
30374 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
30377 local ost1_imp=$(get_osc_import_name client ost1)
30378 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
30381 $LFS setstripe -c 1 -i 0 $DIR/$tfile
30382 # ensure ost1 is connected
30384 stat $DIR/$tfile >/dev/null || error "can't stat"
30385 wait_osc_import_state client ost1 FULL
30386 # no locks, no reqs to let the connection idle
30387 cancel_lru_locks osc
30388 lru_resize_disable osc
30391 before=$($LCTL get_param -n \
30392 ldlm.namespaces.$imp_name.lru_size)
30394 wait_osc_import_state client ost1 IDLE
30395 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
30396 now=$($LCTL get_param -n \
30397 ldlm.namespaces.$imp_name.lru_size)
30398 [ $before == $now ] || error "lru_size changed $before != $now"
30400 run_test 816 "do not reset lru_resize on idle reconnect"
30404 exportfs -u localhost:$DIR/nfsexp
30409 systemctl restart nfs-server.service || skip "failed to restart nfsd"
30411 mkdir -p $DIR/nfsexp
30412 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
30413 error "failed to export nfs"
30415 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
30416 stack_trap cleanup_817 EXIT
30418 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
30419 error "failed to mount nfs to $tmpdir"
30421 cp /bin/true $tmpdir
30422 $DIR/nfsexp/true || error "failed to execute 'true' command"
30424 run_test 817 "nfsd won't cache write lock for exec file"
30427 test_mkdir -i0 -c1 $DIR/$tdir
30428 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
30429 $LFS setstripe -c1 -i1 $DIR/$tdir/$tfile
30432 # restore osp-syn threads
30433 stack_trap "fail $SINGLEMDS"
30435 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
30436 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
30437 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
30438 error "start $SINGLEMDS failed"
30441 local testid=$(echo $TESTNAME | tr '_' ' ')
30443 do_facet mds1 dmesg | tac | sed "/$testid/,$ d" |
30444 grep "run LFSCK" || error "run LFSCK is not suggested"
30446 run_test 818 "unlink with failed llog"
30449 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
30450 cancel_lru_locks osc
30451 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
30452 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
30453 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
30456 run_test 819a "too big niobuf in read"
30459 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
30460 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
30461 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
30462 cancel_lru_locks osc
30466 run_test 819b "too big niobuf in write"
30469 function test_820_start_ost() {
30472 for num in $(seq $OSTCOUNT); do
30473 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
30478 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
30481 umount_client $MOUNT || error "umount failed"
30482 for num in $(seq $OSTCOUNT); do
30486 # mount client with no active OSTs
30487 # so that the client can't initialize max LOV EA size
30488 # from OSC notifications
30489 mount_client $MOUNT || error "mount failed"
30490 # delay OST starting to keep this 0 max EA size for a while
30491 test_820_start_ost &
30493 # create a directory on MDS2
30494 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
30495 error "Failed to create directory"
30496 # open intent should update default EA size
30497 # see mdc_update_max_ea_from_body()
30498 # notice this is the very first RPC to MDS2
30499 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
30502 # With SSK, this situation can lead to -EPERM being returned.
30503 # In that case, simply retry.
30504 if [ $ret -ne 0 ] && $SHARED_KEY; then
30505 if echo "$out" | grep -q "not permitted"; then
30506 cp /etc/services $DIR/$tdir/mds2
30510 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
30512 run_test 820 "update max EA from open intent"
30515 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
30516 local OST_MAX_PRECREATE=20000
30518 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
30519 skip "Need MDS version at least 2.14.56"
30521 save_lustre_params mds1 \
30522 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
30523 do_facet $SINGLEMDS "$LCTL set_param -n \
30524 osp.$FSNAME-OST*MDT0000.max_create_count=0"
30525 do_facet $SINGLEMDS "$LCTL set_param -n \
30526 osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE"
30528 stack_trap "restore_lustre_params < $p; rm $p"
30530 do_facet $SINGLEMDS "$LCTL set_param -n \
30531 osp.$FSNAME-OST*-osc-MDT*.create_count=100200"
30533 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
30534 osp.$FSNAME-OST0000*MDT0000.create_count")
30535 local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \
30536 osp.$FSNAME-OST0000*MDT0000.max_create_count")
30537 local expect_count=$(((($max/2)/256) * 256))
30539 log "setting create_count to 100200:"
30540 log " -result- count: $count with max: $max, expecting: $expect_count"
30542 [[ $count -eq expect_count ]] ||
30543 error "Create count not set to max precreate."
30545 run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum"
30548 [[ $MDS1_VERSION -lt $(version_code 2.14.56) ]] &&
30549 skip "Need MDS version 2.14.56"
30551 local sync_changes=$(do_facet $SINGLEMDS \
30552 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
30554 [ "$sync_changes" -gt 100 ] &&
30555 skip "Sync changes $sync_changes > 100 already"
30557 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
30559 $LFS mkdir -i 0 $DIR/$tdir
30560 $LFS setstripe -c 1 -i 0 $DIR/$tdir
30562 save_lustre_params mds1 \
30563 "osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes" > $p
30564 save_lustre_params mds1 \
30565 "osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress" >> $p
30567 do_facet mds1 "$LCTL set_param -n \
30568 osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes=100 \
30569 osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress=128"
30570 stack_trap "restore_lustre_params < $p" EXIT
30572 createmany -o $DIR/$tdir/f- 1000
30573 unlinkmany $DIR/$tdir/f- 1000 &
30574 local UNLINK_PID=$!
30577 sync_changes=$(do_facet mds1 \
30578 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
30579 # the check in the code is racy, fail the test
30580 # if the value above the limit by 10.
30581 [ $sync_changes -gt 110 ] && {
30582 kill -2 $UNLINK_PID
30584 error "osp changes throttling failed, $sync_changes>110"
30586 kill -0 $UNLINK_PID 2> /dev/null || break
30590 run_test 831 "throttling unlink/setattr queuing on OSP"
30593 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
30594 (( $MDS1_VERSION >= $(version_code 2.15.52) )) ||
30595 skip "Need MDS version 2.15.52+"
30596 is_rmentry_supported || skip "rm_entry not supported"
30598 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
30599 mkdir $DIR/$tdir/local_dir || error "mkdir local_dir failed"
30600 mkdir_on_mdt -i 1 $DIR/$tdir/remote_dir ||
30601 error "mkdir remote_dir failed"
30602 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/striped_dir ||
30603 error "mkdir striped_dir failed"
30604 touch $DIR/$tdir/file || error "touch file failed"
30605 $LFS rm_entry $DIR/$tdir/* || error "lfs rm_entry $tdir/* failed"
30606 [ -z "$(ls -A $DIR/$tdir)" ] || error "$tdir not empty"
30608 run_test 832 "lfs rm_entry"
30611 local file=$DIR/$tfile
30613 stack_trap "rm -f $file" EXIT
30614 dd if=/dev/zero of=$file bs=1M count=50 || error "Write $file failed"
30620 # Buffered I/O write
30622 while [ ! -e $DIR/sanity.833.lck ]; do
30623 dd if=/dev/zero of=$file bs=1M count=50 conv=notrunc ||
30624 error "failed to write $file"
30625 sleep 0.$((RANDOM % 4 + 1))
30630 # Buffered I/O read
30632 while [ ! -e $DIR/sanity.833.lck ]; do
30633 dd if=$file of=/dev/null bs=1M count=50 ||
30634 error "failed to read $file"
30635 sleep 0.$((RANDOM % 4 + 1))
30642 while [ ! -e $DIR/sanity.833.lck ]; do
30643 dd if=$file of=/dev/null bs=1M count=50 iflag=direct ||
30644 error "failed to read $file in direct I/O mode"
30645 sleep 0.$((RANDOM % 4 + 1))
30651 touch $DIR/sanity.833.lck
30652 wait $wpid || error "$?: buffered write failed"
30653 wait $rpid || error "$?: buffered read failed"
30654 wait $rpid2 || error "$?: direct read failed"
30656 run_test 833 "Mixed buffered/direct read and write should not return -EIO"
30659 # tests that do cleanup/setup should be run at the end
30663 [ $PARALLEL == "yes" ] && skip "skip parallel run"
30666 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
30667 $LCTL set_param fail_loc=0x903
30669 cancel_lru_locks MGC
30671 FAIL_ON_ERROR=true cleanup
30672 FAIL_ON_ERROR=true setup
30674 run_test 900 "umount should not race with any mgc requeue thread"
30676 # LUS-6253/LU-11185
30684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
30686 # some get_param have a bug to handle dot in param name
30687 cancel_lru_locks MGC
30688 old=$(mount -t lustre | wc -l)
30696 while [ $old -ne $oldc ]; do
30697 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
30700 if [ $count -ge $TIMEOUT ]; then
30701 error "too large timeout"
30704 umount_client $MOUNT || error "umount failed"
30705 mount_client $MOUNT || error "mount failed"
30706 cancel_lru_locks MGC
30707 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
30709 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
30713 run_test 901 "don't leak a mgc lock on client umount"
30717 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
30718 skip "client does not have LU-13377 fix"
30719 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
30720 $LCTL set_param fail_loc=0x1415
30721 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
30722 cancel_lru_locks osc
30725 run_test 902 "test short write doesn't hang lustre"
30729 $LFS setstripe -i 0 -c 1 $DIR/$tfile $DIR/${tfile}-2
30730 echo "blah" > $DIR/${tfile}-2
30731 dd if=/dev/zero of=$DIR/$tfile bs=1M count=6 conv=fsync
30732 #define OBD_FAIL_OSC_SLOW_PAGE_EVICT 0x417
30733 $LCTL set_param fail_loc=0x417 fail_val=20
30735 mv $DIR/${tfile}-2 $DIR/$tfile # Destroys the big object
30736 sleep 1 # To start the destroy
30737 wait_destroy_complete 150 || error "Destroy taking too long"
30738 cat $DIR/$tfile > /dev/null || error "Evicted"
30740 run_test 903 "Test long page discard does not cause evictions"
30743 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
30744 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
30745 grep -q project || skip "skip project quota not supported"
30747 local testfile="$DIR/$tdir/$tfile"
30748 local xattr="trusted.projid"
30750 local mdts=$(comma_list $(mdts_nodes))
30751 local saved=$(do_facet mds1 $LCTL get_param -n \
30752 osd-ldiskfs.*MDT0000.enable_projid_xattr)
30754 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=0
30755 stack_trap "do_nodes $mdts $LCTL set_param \
30756 osd-ldiskfs.*MDT*.enable_projid_xattr=$saved"
30758 mkdir -p $DIR/$tdir
30760 #hide projid xattr on server
30761 $LFS project -p 1 $testfile ||
30762 error "set $testfile project id failed"
30763 getfattr -m - $testfile | grep $xattr &&
30764 error "do not show trusted.projid when disabled on server"
30765 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=1
30766 #should be hidden when projid is 0
30767 $LFS project -p 0 $testfile ||
30768 error "set $testfile project id failed"
30769 getfattr -m - $testfile | grep $xattr &&
30770 error "do not show trusted.projid with project ID 0"
30772 #still can getxattr explicitly
30773 projid=$(getfattr -n $xattr $testfile |
30774 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
30775 [ $projid == "0" ] ||
30776 error "projid expected 0 not $projid"
30778 #set the projid via setxattr
30779 setfattr -n $xattr -v "1000" $testfile ||
30780 error "setattr failed with $?"
30781 projid=($($LFS project $testfile))
30782 [ ${projid[0]} == "1000" ] ||
30783 error "projid expected 1000 not $projid"
30785 #check the new projid via getxattr
30786 $LFS project -p 1001 $testfile ||
30787 error "set $testfile project id failed"
30788 getfattr -m - $testfile | grep $xattr ||
30789 error "should show trusted.projid when project ID != 0"
30790 projid=$(getfattr -n $xattr $testfile |
30791 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
30792 [ $projid == "1001" ] ||
30793 error "projid expected 1001 not $projid"
30795 #try to set invalid projid
30796 setfattr -n $xattr -v "4294967295" $testfile &&
30797 error "set invalid projid should fail"
30799 #remove the xattr means setting projid to 0
30800 setfattr -x $xattr $testfile ||
30801 error "setfattr failed with $?"
30802 projid=($($LFS project $testfile))
30803 [ ${projid[0]} == "0" ] ||
30804 error "projid expected 0 not $projid"
30806 #should be hidden when parent has inherit flag and same projid
30807 $LFS project -srp 1002 $DIR/$tdir ||
30808 error "set $tdir project id failed"
30809 getfattr -m - $testfile | grep $xattr &&
30810 error "do not show trusted.projid with inherit flag"
30812 #still can getxattr explicitly
30813 projid=$(getfattr -n $xattr $testfile |
30814 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
30815 [ $projid == "1002" ] ||
30816 error "projid expected 1002 not $projid"
30818 run_test 904 "virtual project ID xattr"
30822 (( $OST1_VERSION >= $(version_code 2.15.50.220) )) ||
30823 skip "need OST version >= 2.15.50.220 for fail_loc"
30825 remote_ost_nodsh && skip "remote OST with nodsh"
30826 $LFS setstripe -c -1 -i 0 $DIR/$tfile || error "setstripe failed"
30828 $LFS ladvise -a willread $DIR/$tfile || error "ladvise does not work"
30830 #define OBD_FAIL_OST_OPCODE 0x253
30832 do_facet ost1 "$LCTL set_param fail_val=21 fail_loc=0x0253"
30833 $LFS ladvise -a willread $DIR/$tfile &&
30834 error "unexpected success of ladvise with fault injection"
30835 $LFS ladvise -a willread $DIR/$tfile |&
30836 grep -q "Operation not supported"
30837 (( $? == 0 )) || error "unexpected stderr of ladvise with fault injection"
30839 run_test 905 "bad or new opcode should not stuck client"
30842 grep -q io_uring_setup /proc/kallsyms ||
30843 skip "Client OS does not support io_uring I/O engine"
30844 io_uring_probe || skip "kernel does not support io_uring fully"
30845 which fio || skip_env "no fio installed"
30846 fio --enghelp | grep -q io_uring ||
30847 skip_env "fio does not support io_uring I/O engine"
30849 local file=$DIR/$tfile
30850 local ioengine="io_uring"
30854 fio --name=seqwrite --ioengine=$ioengine \
30855 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
30856 --iodepth=64 --size=$size --filename=$file --rw=write ||
30857 error "fio seqwrite $file failed"
30859 fio --name=seqread --ioengine=$ioengine \
30860 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
30861 --iodepth=64 --size=$size --filename=$file --rw=read ||
30862 error "fio seqread $file failed"
30864 rm -f $file || error "rm -f $file failed"
30866 run_test 906 "Simple test for io_uring I/O engine via fio"
30869 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
30871 # set stripe size to max rpc size
30872 $LFS setstripe -i 0 -c 2 -S $((max_pages * PAGE_SIZE)) $DIR/$tfile
30873 $LFS getstripe $DIR/$tfile
30874 #define OBD_FAIL_OST_EROFS 0x216
30875 do_facet ost1 "$LCTL set_param fail_val=3 fail_loc=0x80000216"
30877 local bs=$((max_pages * PAGE_SIZE / 16))
30879 # write full one stripe and one block
30880 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=17 || error "dd failed"
30882 rm $DIR/$tfile || error "rm failed"
30884 run_test 907 "write rpc error during unlink"
30886 complete_test $SECONDS
30887 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
30888 check_and_cleanup_lustre
30889 if [ "$I_MOUNTED" != "yes" ]; then
30890 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true