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
47 always_except LU-17127 39o
50 # skip the grant tests for ARM until they are fixed
51 if [[ $(uname -m) = aarch64 ]]; then
52 always_except LU-11671 45
55 # skip nfs tests on kernels >= 4.12.0 until they are fixed
56 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
57 always_except LU-12661 817
59 # skip cgroup tests on RHEL8.1 kernels until they are fixed
60 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
61 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
62 always_except LU-13063 411a
65 # skip cgroup tests for kernels < v4.18.0
66 if (( $LINUX_VERSION_CODE < $(version_code 4.18.0) )); then
67 always_except LU-13063 411b
71 [[ "$SLOW" = "no" ]] && EXCEPT_SLOW="27m 60i 64b 68 71 135 136 230d 300o"
73 if [[ "$mds1_FSTYPE" == "zfs" ]]; then
75 [[ "$SLOW" == "no" ]] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
78 if [[ "$ost1_FSTYPE" = "zfs" ]]; then
79 always_except LU-1941 130b 130c 130d 130e 130f 130g
80 always_except LU-9054 312
83 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
85 # Get the SLES distro version
87 # Returns a version string that should only be used in comparing
88 # strings returned by version_code()
91 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
93 # All SuSE Linux versions have one decimal. version_code expects two
94 local sles_version=$version.0
95 version_code $sles_version
98 # Check if we are running on Ubuntu or SLES so we can make decisions on
100 if [ -r /etc/SuSE-release ] || [ -r /etc/SUSE-brand ]; then
101 sles_version=$(sles_version_code)
102 [ $sles_version -lt $(version_code 11.4.0) ] &&
103 always_except LU-4341 170
105 [ $sles_version -lt $(version_code 12.0.0) ] &&
106 always_except LU-3703 234
107 elif [ -r /etc/os-release ]; then
108 if grep -qi ubuntu /etc/os-release; then
109 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
110 -e 's/^VERSION=//p' \
114 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
115 always_except LU-10366 410
125 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
126 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
135 check_swap_layouts_support()
137 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
138 skip "Does not support layout lock."
141 check_swap_layout_no_dom()
144 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
145 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
148 check_and_setup_lustre
152 MAXFREE=${MAXFREE:-$((300000 * $OSTCOUNT))}
154 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
155 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
156 rm -rf $DIR/[Rdfs][0-9]*
158 # $RUNAS_ID may get set incorrectly somewhere else
159 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
160 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
162 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
164 if [ "${ONLY}" = "MOUNT" ] ; then
165 echo "Lustre is up, please go on"
169 echo "preparing for tests involving mounts"
170 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
172 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
173 echo # add a newline after mke2fs.
177 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
179 # ensure all internal functions know we want full debug
181 lctl set_param debug=$PTLDEBUG 2> /dev/null || true
185 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
187 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
189 run_test 0a "touch; rm ====================="
192 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
193 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
195 run_test 0b "chmod 0755 $DIR ============================="
198 $LCTL get_param mdc.*.import | grep "state: FULL" ||
199 error "import not FULL"
200 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
203 run_test 0c "check import proc"
205 test_0d() { # LU-3397
206 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
207 skip "proc exports not supported before 2.10.57"
209 local mgs_exp="mgs.MGS.exports"
210 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
212 local exp_client_version
215 local temp_imp=$DIR/$tfile.import
216 local temp_exp=$DIR/$tfile.export
218 # save mgc import file to $temp_imp
219 $LCTL get_param mgc.*.import | tee $temp_imp
220 # Check if client uuid is found in MGS export
221 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
222 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
226 # save mgs export file to $temp_exp
227 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
229 # Compare the value of field "connect_flags"
230 imp_val=$(grep "connect_flags" $temp_imp)
231 exp_val=$(grep "connect_flags" $temp_exp)
232 [ "$exp_val" == "$imp_val" ] ||
233 error "export flags '$exp_val' != import flags '$imp_val'"
235 # Compare client versions. Only compare top-3 fields for compatibility
236 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
237 exp_val=$(version_code $(cut -d. -f1,2,3 <<<$exp_client_version))
238 imp_val=$(version_code $(lustre_build_version client | cut -d. -f1,2,3))
239 [ "$exp_val" == "$imp_val" ] ||
240 error "exp version '$exp_client_version'($exp_val) != " \
241 "'$(lustre_build_version client)'($imp_val)"
243 run_test 0d "check export proc ============================="
245 test_0e() { # LU-13417
246 (( $MDSCOUNT > 1 )) ||
247 skip "We need at least 2 MDTs for this test"
249 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
250 skip "Need server version at least 2.14.51"
252 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
253 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
255 [ $default_lmv_count -eq 1 ] ||
256 error "$MOUNT default stripe count $default_lmv_count"
258 [ $default_lmv_index -eq -1 ] ||
259 error "$MOUNT default stripe index $default_lmv_index"
261 mkdir $MOUNT/$tdir.1 || error "mkdir $MOUNT/$tdir.1 failed"
262 mkdir $MOUNT/$tdir.2 || error "mkdir $MOUNT/$tdir.2 failed"
264 local mdt_index1=$($LFS getdirstripe -i $MOUNT/$tdir.1)
265 local mdt_index2=$($LFS getdirstripe -i $MOUNT/$tdir.2)
267 [ $mdt_index1 -eq $mdt_index2 ] &&
268 error "directories are on the same MDT $mdt_index1=$mdt_index2"
270 rmdir $MOUNT/$tdir.1 $MOUNT/$tdir.2
272 run_test 0e "Enable DNE MDT balancing for mkdir in the ROOT"
275 test_mkdir $DIR/$tdir
276 test_mkdir $DIR/$tdir/d2
277 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
278 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
281 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
283 run_test 1 "mkdir; remkdir; rmdir"
286 test_mkdir $DIR/$tdir
287 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
288 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
290 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
292 run_test 2 "mkdir; touch; rmdir; check file"
295 test_mkdir $DIR/$tdir
296 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
297 touch $DIR/$tdir/$tfile
298 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
300 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
302 run_test 3 "mkdir; touch; rmdir; check dir"
304 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
306 test_mkdir -i 1 $DIR/$tdir
308 touch $DIR/$tdir/$tfile ||
309 error "Create file under remote directory failed"
312 error "Expect error removing in-use dir $DIR/$tdir"
314 test -d $DIR/$tdir || error "Remote directory disappeared"
316 rm -rf $DIR/$tdir || error "remove remote dir error"
318 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
321 test_mkdir $DIR/$tdir
322 test_mkdir $DIR/$tdir/d2
323 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
324 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
325 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
327 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
330 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
331 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
332 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
333 error "$tfile does not have perm 0666 or UID $UID"
334 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
335 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
336 error "$tfile should be 0666 and owned by UID $UID"
338 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
341 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
344 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
345 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
346 error "$tfile should be owned by UID $RUNAS_ID"
347 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
348 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
349 error "$tfile should be owned by UID $RUNAS_ID"
351 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
354 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
357 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
358 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
359 error "$tfile should be owned by GID $UID"
360 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
361 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
362 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
364 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
367 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
369 test_mkdir $DIR/$tdir
370 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
371 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
372 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
373 test_mkdir $DIR/$tdir/d/subdir
374 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
375 error "$tdir/d/subdir should be GID $RUNAS_GID"
376 if [[ $MDSCOUNT -gt 1 ]]; then
377 # check remote dir sgid inherite
378 $LFS mkdir -i 0 $DIR/$tdir.local ||
379 error "mkdir $tdir.local failed"
380 chmod g+s $DIR/$tdir.local ||
381 error "chmod $tdir.local failed"
382 chgrp $RUNAS_GID $DIR/$tdir.local ||
383 error "chgrp $tdir.local failed"
384 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
385 error "mkdir $tdir.remote failed"
386 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
387 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
388 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
389 error "$tdir.remote should be mode 02755"
392 run_test 6g "verify new dir in sgid dir inherits group"
394 test_6h() { # bug 7331
395 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
397 touch $DIR/$tfile || error "touch failed"
398 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
399 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
400 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
401 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
402 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
404 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
407 test_mkdir $DIR/$tdir
408 $MCREATE $DIR/$tdir/$tfile
409 chmod 0666 $DIR/$tdir/$tfile
410 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
411 error "$tdir/$tfile should be mode 0666"
413 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
416 if [ ! -d $DIR/$tdir ]; then
417 test_mkdir $DIR/$tdir
419 $MCREATE $DIR/$tdir/$tfile
420 echo -n foo > $DIR/$tdir/$tfile
421 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
422 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
424 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
427 test_mkdir $DIR/$tdir
428 touch $DIR/$tdir/$tfile
429 chmod 0666 $DIR/$tdir/$tfile
430 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
431 error "$tfile mode not 0666"
433 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
436 test_mkdir $DIR/$tdir
437 test_mkdir $DIR/$tdir/d2
438 test_mkdir $DIR/$tdir/d2/d3
439 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
441 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
444 test_mkdir $DIR/$tdir
445 test_mkdir $DIR/$tdir/d2
446 touch $DIR/$tdir/d2/$tfile
447 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
448 error "$tdir/d2/$tfile not a file"
450 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
453 test_mkdir $DIR/$tdir
454 test_mkdir $DIR/$tdir/d2
455 chmod 0666 $DIR/$tdir/d2
456 chmod 0705 $DIR/$tdir/d2
457 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
458 error "$tdir/d2 mode not 0705"
460 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
463 test_mkdir $DIR/$tdir
464 touch $DIR/$tdir/$tfile
465 chmod 0666 $DIR/$tdir/$tfile
466 chmod 0654 $DIR/$tdir/$tfile
467 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
468 error "$tdir/d2 mode not 0654"
470 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
473 test_mkdir $DIR/$tdir
474 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
476 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
477 error "$tdir/$tfile size not 0 after truncate"
479 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
482 test_mkdir $DIR/$tdir
483 touch $DIR/$tdir/$tfile
485 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
487 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
490 test_mkdir $DIR/$tdir
491 touch $DIR/$tdir/$tfile
492 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
493 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
494 error "$tdir/${tfile_2} not a file after rename"
495 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
497 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
500 test_mkdir $DIR/$tdir
501 touch $DIR/$tdir/$tfile
502 rm -rf $DIR/$tdir/$tfile
503 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
505 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
508 test_mkdir $DIR/$tdir
509 touch $DIR/$tdir/$tfile
510 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
512 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
513 error "$tdir/l-exist not a symlink"
514 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
515 error "$tdir/l-exist not referencing a file"
516 rm -f $DIR/$tdir/l-exist
517 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
519 run_test 17a "symlinks: create, remove (real)"
522 test_mkdir $DIR/$tdir
523 ln -s no-such-file $DIR/$tdir/l-dangle
525 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
526 error "$tdir/l-dangle not referencing no-such-file"
527 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
528 error "$tdir/l-dangle not referencing non-existent file"
529 rm -f $DIR/$tdir/l-dangle
530 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
532 run_test 17b "symlinks: create, remove (dangling)"
534 test_17c() { # bug 3440 - don't save failed open RPC for replay
535 test_mkdir $DIR/$tdir
536 ln -s foo $DIR/$tdir/$tfile
537 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
539 run_test 17c "symlinks: open dangling (should return error)"
542 test_mkdir $DIR/$tdir
543 ln -s foo $DIR/$tdir/$tfile
544 touch $DIR/$tdir/$tfile || error "creating to new symlink"
546 run_test 17d "symlinks: create dangling"
549 test_mkdir $DIR/$tdir
550 local foo=$DIR/$tdir/$tfile
551 ln -s $foo $foo || error "create symlink failed"
552 ls -l $foo || error "ls -l failed"
553 ls $foo && error "ls not failed" || true
555 run_test 17e "symlinks: create recursive symlink (should return error)"
558 test_mkdir $DIR/$tdir
559 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
560 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
561 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
562 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
563 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
564 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
567 run_test 17f "symlinks: long and very long symlink name"
569 # str_repeat(S, N) generate a string that is string S repeated N times
574 while [ $((n -= 1)) -ge 0 ]; do
580 # Long symlinks and LU-2241
582 test_mkdir $DIR/$tdir
583 local TESTS="59 60 61 4094 4095"
585 # Fix for inode size boundary in 2.1.4
586 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
589 # Patch not applied to 2.2 or 2.3 branches
590 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
591 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
595 local SYMNAME=$(str_repeat 'x' $i)
596 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
597 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
600 run_test 17g "symlinks: really long symlink name and inode boundaries"
602 test_17h() { #bug 17378
603 [ $PARALLEL == "yes" ] && skip "skip parallel run"
604 remote_mds_nodsh && skip "remote MDS with nodsh"
608 test_mkdir $DIR/$tdir
609 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
610 $LFS setstripe -c -1 $DIR/$tdir
611 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
612 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
613 touch $DIR/$tdir/$tfile || true
615 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
617 test_17i() { #bug 20018
618 [ $PARALLEL == "yes" ] && skip "skip parallel run"
619 remote_mds_nodsh && skip "remote MDS with nodsh"
621 local foo=$DIR/$tdir/$tfile
624 test_mkdir -c1 $DIR/$tdir
625 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
626 ln -s $foo $foo || error "create symlink failed"
627 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
628 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
629 ls -l $foo && error "error not detected"
632 run_test 17i "don't panic on short symlink (should return error)"
634 test_17k() { #bug 22301
635 [ $PARALLEL == "yes" ] && skip "skip parallel run"
636 [[ -z "$(which rsync 2>/dev/null)" ]] &&
637 skip "no rsync command"
638 rsync --help | grep -q xattr ||
639 skip_env "$(rsync --version | head -n1) does not support xattrs"
640 test_mkdir $DIR/$tdir
641 test_mkdir $DIR/$tdir.new
642 touch $DIR/$tdir/$tfile
643 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
644 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
645 error "rsync failed with xattrs enabled"
647 run_test 17k "symlinks: rsync with xattrs enabled"
649 test_17l() { # LU-279
650 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
651 skip "no getfattr command"
653 test_mkdir $DIR/$tdir
654 touch $DIR/$tdir/$tfile
655 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
656 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
657 # -h to not follow symlinks. -m '' to list all the xattrs.
658 # grep to remove first line: '# file: $path'.
659 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
661 lgetxattr_size_check $path $xattr ||
662 error "lgetxattr_size_check $path $xattr failed"
666 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
670 [ $PARALLEL == "yes" ] && skip "skip parallel run"
671 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
672 remote_mds_nodsh && skip "remote MDS with nodsh"
673 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
674 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
675 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
677 local short_sym="0123456789"
678 local wdir=$DIR/$tdir
683 # create a long symlink file
684 for ((i = 0; i < 4; ++i)); do
685 long_sym=${long_sym}${long_sym}
688 echo "create 512 short and long symlink files under $wdir"
689 for ((i = 0; i < 256; ++i)); do
690 ln -sf ${long_sym}"a5a5" $wdir/long-$i
691 ln -sf ${short_sym}"a5a5" $wdir/short-$i
697 wait_delete_completed
699 echo "recreate the 512 symlink files with a shorter string"
700 for ((i = 0; i < 512; ++i)); do
701 # rewrite the symlink file with a shorter string
702 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
703 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
706 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
708 echo "stop and checking mds${mds_index}:"
709 # e2fsck should not return error
711 local devname=$(mdsdevname $mds_index)
712 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
715 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
716 error "start mds${mds_index} failed"
717 df $MOUNT > /dev/null 2>&1
719 error "e2fsck detected error for short/long symlink: rc=$rc"
722 run_test 17m "run e2fsck against MDT which contains short/long symlink"
724 check_fs_consistency_17n() {
728 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
729 # so it only check MDT1/MDT2 instead of all of MDTs.
730 for mdt_index in 1 2; do
731 # e2fsck should not return error
733 local devname=$(mdsdevname $mdt_index)
734 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
737 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
738 error "mount mds$mdt_index failed"
739 df $MOUNT > /dev/null 2>&1
745 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
746 [ $PARALLEL == "yes" ] && skip "skip parallel run"
747 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
748 remote_mds_nodsh && skip "remote MDS with nodsh"
749 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
750 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
751 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
755 test_mkdir $DIR/$tdir
756 for ((i=0; i<10; i++)); do
757 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
758 error "create remote dir error $i"
759 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
760 error "create files under remote dir failed $i"
763 check_fs_consistency_17n ||
764 error "e2fsck report error after create files under remote dir"
766 for ((i = 0; i < 10; i++)); do
767 rm -rf $DIR/$tdir/remote_dir_${i} ||
768 error "destroy remote dir error $i"
771 check_fs_consistency_17n ||
772 error "e2fsck report error after unlink files under remote dir"
774 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
775 skip "lustre < 2.4.50 does not support migrate mv"
777 for ((i = 0; i < 10; i++)); do
778 mkdir -p $DIR/$tdir/remote_dir_${i}
779 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
780 error "create files under remote dir failed $i"
781 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
782 error "migrate remote dir error $i"
784 check_fs_consistency_17n || error "e2fsck report error after migration"
786 for ((i = 0; i < 10; i++)); do
787 rm -rf $DIR/$tdir/remote_dir_${i} ||
788 error "destroy remote dir error $i"
791 check_fs_consistency_17n || error "e2fsck report error after unlink"
793 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
796 remote_mds_nodsh && skip "remote MDS with nodsh"
797 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
798 skip "Need MDS version at least 2.3.64"
800 local wdir=$DIR/${tdir}o
806 mdt_index=$($LFS getstripe -m $wdir/$tfile)
807 mdt_index=$((mdt_index + 1))
810 #fail mds will wait the failover finish then set
811 #following fail_loc to avoid interfer the recovery process.
814 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
815 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
816 ls -l $wdir/$tfile && rc=1
817 do_facet mds${mdt_index} lctl set_param fail_loc=0
818 [[ $rc -eq 0 ]] || error "stat file should fail"
820 run_test 17o "stat file with incompat LMA feature"
823 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
824 ls $DIR || error "Failed to ls $DIR: $?"
826 run_test 18 "touch .../f ; ls ... =============================="
832 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
834 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
837 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
839 run_test 19b "ls -l .../f19 (should return error) =============="
842 [ $RUNAS_ID -eq $UID ] &&
843 skip_env "RUNAS_ID = UID = $UID -- skipping"
845 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
847 run_test 19c "$RUNAS touch .../f19 (should return error) =="
850 cat $DIR/f19 && error || true
852 run_test 19d "cat .../f19 (should return error) =============="
861 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
863 run_test 20 "touch .../f ; ls -l ..."
866 test_mkdir $DIR/$tdir
867 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
868 ln -s dangle $DIR/$tdir/link
869 echo foo >> $DIR/$tdir/link
870 cat $DIR/$tdir/dangle
871 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
872 $CHECKSTAT -f -t file $DIR/$tdir/link ||
873 error "$tdir/link not linked to a file"
875 run_test 21 "write to dangling link"
878 local wdir=$DIR/$tdir
880 chown $RUNAS_ID:$RUNAS_GID $wdir
881 (cd $wdir || error "cd $wdir failed";
882 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
884 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
885 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
886 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
887 error "checkstat -u failed"
889 run_test 22 "unpack tar archive as non-root user"
893 test_mkdir $DIR/$tdir
894 local file=$DIR/$tdir/$tfile
896 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
897 openfile -f O_CREAT:O_EXCL $file &&
898 error "$file recreate succeeded" || true
900 run_test 23a "O_CREAT|O_EXCL in subdir"
902 test_23b() { # bug 18988
903 test_mkdir $DIR/$tdir
904 local file=$DIR/$tdir/$tfile
907 echo foo > $file || error "write filed"
908 echo bar >> $file || error "append filed"
909 $CHECKSTAT -s 8 $file || error "wrong size"
912 run_test 23b "O_APPEND check"
914 # LU-9409, size with O_APPEND and tiny writes
916 local file=$DIR/$tfile
919 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
920 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
924 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
925 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
927 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
930 #racing tiny & normal writes
931 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
932 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
934 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
937 #racing tiny & normal writes 2, ugly numbers
938 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
939 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
941 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
944 run_test 23c "O_APPEND size checks for tiny writes"
946 # LU-11069 file offset is correct after appending writes
948 local file=$DIR/$tfile
951 echo CentaurHauls > $file
952 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
953 if ((offset != 26)); then
954 error "wrong offset, expected 26, got '$offset'"
957 run_test 23d "file offset is correct after appending writes"
961 echo '-- same directory rename'
962 test_mkdir $DIR/$tdir
963 touch $DIR/$tdir/$tfile.1
964 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
965 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
967 run_test 24a "rename file to non-existent target"
970 test_mkdir $DIR/$tdir
971 touch $DIR/$tdir/$tfile.{1,2}
972 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
973 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
974 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
976 run_test 24b "rename file to existing target"
979 test_mkdir $DIR/$tdir
980 test_mkdir $DIR/$tdir/d$testnum.1
981 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
982 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
983 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
985 run_test 24c "rename directory to non-existent target"
988 test_mkdir -c1 $DIR/$tdir
989 test_mkdir -c1 $DIR/$tdir/d$testnum.1
990 test_mkdir -c1 $DIR/$tdir/d$testnum.2
991 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
992 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
993 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
995 run_test 24d "rename directory to existing target"
998 echo '-- cross directory renames --'
1002 mv $DIR/R5a/f $DIR/R5b/g
1003 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
1004 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
1006 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
1011 touch $DIR/R6a/f $DIR/R6b/g
1012 mv $DIR/R6a/f $DIR/R6b/g
1013 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
1014 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
1016 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
1021 test_mkdir $DIR/R7a/d
1022 mv $DIR/R7a/d $DIR/R7b/e
1023 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
1024 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
1026 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1029 test_mkdir -c1 $DIR/R8a
1030 test_mkdir -c1 $DIR/R8b
1031 test_mkdir -c1 $DIR/R8a/d
1032 test_mkdir -c1 $DIR/R8b/e
1033 mrename $DIR/R8a/d $DIR/R8b/e
1034 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1035 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1037 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1040 echo "-- rename error cases"
1042 test_mkdir $DIR/R9/a
1044 mrename $DIR/R9/f $DIR/R9/a
1045 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1046 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1047 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1049 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1053 mrename $DIR/R10/f $DIR/R10/g
1054 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1055 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1056 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1058 run_test 24j "source does not exist ============================"
1061 test_mkdir $DIR/R11a
1062 test_mkdir $DIR/R11a/d
1064 mv $DIR/R11a/f $DIR/R11a/d
1065 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1066 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1068 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1070 # bug 2429 - rename foo foo foo creates invalid file
1073 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1075 run_test 24l "Renaming a file to itself ========================"
1079 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1080 # on ext3 this does not remove either the source or target files
1081 # though the "expected" operation would be to remove the source
1082 $CHECKSTAT -t file ${f} || error "${f} missing"
1083 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1085 run_test 24m "Renaming a file to a hard link to itself ========="
1089 # this stats the old file after it was renamed, so it should fail
1091 $CHECKSTAT ${f} || error "${f} missing"
1093 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1094 $CHECKSTAT -a ${f} || error "${f} exists"
1096 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1099 test_mkdir $DIR/$tdir
1100 rename_many -s random -v -n 10 $DIR/$tdir
1102 run_test 24o "rename of files during htree split"
1105 test_mkdir $DIR/R12a
1106 test_mkdir $DIR/R12b
1107 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1108 mrename $DIR/R12a $DIR/R12b
1109 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1110 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1111 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1112 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1114 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1116 cleanup_multiop_pause() {
1118 kill -USR1 $MULTIPID
1122 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1124 test_mkdir $DIR/R13a
1125 test_mkdir $DIR/R13b
1126 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1127 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1130 trap cleanup_multiop_pause EXIT
1131 mrename $DIR/R13a $DIR/R13b
1132 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1133 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1134 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1135 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1136 cleanup_multiop_pause
1137 wait $MULTIPID || error "multiop close failed"
1139 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1141 test_24r() { #bug 3789
1142 test_mkdir $DIR/R14a
1143 test_mkdir $DIR/R14a/b
1144 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1145 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1146 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1148 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1151 test_mkdir $DIR/R15a
1152 test_mkdir $DIR/R15a/b
1153 test_mkdir $DIR/R15a/b/c
1154 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1155 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1156 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1158 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1161 test_mkdir $DIR/R16a
1162 test_mkdir $DIR/R16a/b
1163 test_mkdir $DIR/R16a/b/c
1164 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1165 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1166 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1168 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1170 test_24u() { # bug12192
1171 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1172 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1174 run_test 24u "create stripe file"
1176 simple_cleanup_common() {
1180 [[ -z "$DIR" || -z "$tdir" || ! -d "$DIR/$tdir" ]] && return 0
1182 local start=$SECONDS
1184 [[ -n "$createmany" ]] && unlinkmany $DIR/$tdir/$tfile $createmany
1185 rm -rf $DIR/$tdir || error "cleanup $DIR/$tdir failed"
1187 wait_delete_completed
1188 echo "cleanup time $((SECONDS - start))"
1192 max_pages_per_rpc() {
1193 local mdtname="$(printf "MDT%04x" ${1:-0})"
1194 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1198 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1200 local nrfiles=${COUNT:-100000}
1201 local fname="$DIR/$tdir/$tfile"
1203 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1204 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1206 test_mkdir "$(dirname $fname)"
1207 # assume MDT0000 has the fewest inodes
1208 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1209 local free_inodes=$(($(mdt_free_inodes 0) * ${stripes/#0/1}))
1210 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1212 stack_trap "simple_cleanup_common $nrfiles"
1214 createmany -m "$fname" $nrfiles
1216 cancel_lru_locks mdc
1217 lctl set_param mdc.*.stats clear
1219 # was previously test_24D: LU-6101
1220 # readdir() returns correct number of entries after cursor reload
1221 local num_ls=$(ls $DIR/$tdir | wc -l)
1222 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1223 local num_all=$(ls -a $DIR/$tdir | wc -l)
1224 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1225 [ $num_all -ne $((nrfiles + 2)) ]; then
1226 error "Expected $nrfiles files, got $num_ls " \
1227 "($num_uniq unique $num_all .&..)"
1229 # LU-5 large readdir
1230 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1231 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1232 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1233 # take into account of overhead in lu_dirpage header and end mark in
1234 # each page, plus one in rpc_num calculation.
1235 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1236 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1237 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1238 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1239 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1240 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1241 echo "readpages: $mds_readpage rpc_max: $rpc_max-2/+1"
1242 (( $mds_readpage >= $rpc_max - 2 && $mds_readpage <= $rpc_max + 1)) ||
1243 error "large readdir doesn't take effect: " \
1244 "$mds_readpage should be about $rpc_max"
1246 run_test 24v "list large directory (test hash collision, b=17560)"
1248 test_24w() { # bug21506
1250 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1251 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1252 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1253 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1254 [[ "$SZ1" -eq "$SZ2" ]] ||
1255 error "Error reading at the end of the file $tfile"
1257 run_test 24w "Reading a file larger than 4Gb"
1260 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1261 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1262 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1263 skip "Need MDS version at least 2.7.56"
1266 local remote_dir=$DIR/$tdir/remote_dir
1268 test_mkdir $DIR/$tdir
1269 $LFS mkdir -i $MDTIDX $remote_dir ||
1270 error "create remote directory failed"
1272 test_mkdir $DIR/$tdir/src_dir
1273 touch $DIR/$tdir/src_file
1274 test_mkdir $remote_dir/tgt_dir
1275 touch $remote_dir/tgt_file
1277 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1278 error "rename dir cross MDT failed!"
1280 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1281 error "rename file cross MDT failed!"
1283 touch $DIR/$tdir/ln_file
1284 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1285 error "ln file cross MDT failed"
1287 rm -rf $DIR/$tdir || error "Can not delete directories"
1289 run_test 24x "cross MDT rename/link"
1292 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1293 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1295 local remote_dir=$DIR/$tdir/remote_dir
1298 test_mkdir $DIR/$tdir
1299 $LFS mkdir -i $mdtidx $remote_dir ||
1300 error "create remote directory failed"
1302 test_mkdir $remote_dir/src_dir
1303 touch $remote_dir/src_file
1304 test_mkdir $remote_dir/tgt_dir
1305 touch $remote_dir/tgt_file
1307 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1308 error "rename subdir in the same remote dir failed!"
1310 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1311 error "rename files in the same remote dir failed!"
1313 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1314 error "link files in the same remote dir failed!"
1316 rm -rf $DIR/$tdir || error "Can not delete directories"
1318 run_test 24y "rename/link on the same dir should succeed"
1321 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1322 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1323 skip "Need MDS version at least 2.12.51"
1327 for index in 0 1; do
1328 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1329 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1332 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1334 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1335 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1337 local mdts=$(comma_list $(mdts_nodes))
1339 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1340 stack_trap "do_nodes $mdts $LCTL \
1341 set_param mdt.*.enable_remote_rename=1" EXIT
1343 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1345 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1346 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1348 run_test 24z "cross-MDT rename is done as cp"
1350 test_24A() { # LU-3182
1353 test_mkdir $DIR/$tdir
1354 stack_trap "simple_cleanup_common $NFILES"
1355 createmany -m $DIR/$tdir/$tfile $NFILES
1356 local t=$(ls $DIR/$tdir | wc -l)
1357 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1358 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1360 (( $t == $NFILES && $u == $NFILES && $v == NFILES + 2 )) ||
1361 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1363 run_test 24A "readdir() returns correct number of entries."
1365 test_24B() { # LU-4805
1366 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1370 test_mkdir $DIR/$tdir
1371 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir/ ||
1372 error "create striped dir failed"
1374 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1375 [ $count -eq 2 ] || error "Expected 2, got $count"
1377 touch $DIR/$tdir/striped_dir/a
1379 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1380 [ $count -eq 3 ] || error "Expected 3, got $count"
1382 touch $DIR/$tdir/striped_dir/.f
1384 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1385 [ $count -eq 4 ] || error "Expected 4, got $count"
1387 rm -rf $DIR/$tdir || error "Can not delete directories"
1389 run_test 24B "readdir for striped dir return correct number of entries"
1392 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1398 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1399 error "create striped dir failed"
1401 cd $DIR/$tdir/d0/striped_dir
1403 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1404 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1405 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1407 [ "$d0_ino" = "$parent_ino" ] ||
1408 error ".. wrong, expect $d0_ino, get $parent_ino"
1410 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1411 error "mv striped dir failed"
1413 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1415 [ "$d1_ino" = "$parent_ino" ] ||
1416 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1418 run_test 24C "check .. in striped dir"
1421 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1422 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1425 mkdir $DIR/$tdir/src_dir
1426 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1427 error "create remote source failed"
1429 touch $DIR/$tdir/src_dir/src_child/a
1431 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1432 error "create remote target dir failed"
1434 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1435 error "create remote target child failed"
1437 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1438 error "rename dir cross MDT failed!"
1442 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1443 error "src_child still exists after rename"
1445 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1446 error "missing file(a) after rename"
1448 rm -rf $DIR/$tdir || error "Can not delete directories"
1450 run_test 24E "cross MDT rename/link"
1453 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1456 [ "$SLOW" = "no" ] && repeats=100
1460 echo "$repeats repeats"
1461 for ((i = 0; i < repeats; i++)); do
1462 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1463 touch $DIR/$tdir/test/a || error "touch fails"
1464 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1465 rm -rf $DIR/$tdir/test || error "rmdir fails"
1470 run_test 24F "hash order vs readdir (LU-11330)"
1473 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1478 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1479 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1480 touch $DIR/$tdir-0/f1 || error "touch f1"
1481 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1482 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1483 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1484 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1485 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1487 run_test 24G "migrate symlink in rename"
1490 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1491 [[ $(hostname) != $(facet_active_host mds2) ]] ||
1492 skip "MDT1 should be on another node"
1494 test_mkdir -i 1 -c 1 $DIR/$tdir
1495 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
1496 do_facet mds2 $LCTL set_param fail_loc=0x80001103
1497 touch $DIR/$tdir/$tfile || error "touch failed"
1499 run_test 24H "repeat FLD_QUERY rpc"
1502 echo '== symlink sanity ============================================='
1506 touch $DIR/s25/foo ||
1507 error "File creation in symlinked directory failed"
1509 run_test 25a "create file in symlinked directory ==============="
1512 [ ! -d $DIR/d25 ] && test_25a
1513 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1515 run_test 25b "lookup file in symlinked directory ==============="
1519 test_mkdir $DIR/d26/d26-2
1520 ln -s d26/d26-2 $DIR/s26
1521 touch $DIR/s26/foo || error "File creation failed"
1523 run_test 26a "multiple component symlink ======================="
1526 test_mkdir -p $DIR/$tdir/d26-2
1527 ln -s $tdir/d26-2/foo $DIR/s26-2
1528 touch $DIR/s26-2 || error "File creation failed"
1530 run_test 26b "multiple component symlink at end of lookup ======"
1533 test_mkdir $DIR/d26.2
1534 touch $DIR/d26.2/foo
1535 ln -s d26.2 $DIR/s26.2-1
1536 ln -s s26.2-1 $DIR/s26.2-2
1537 ln -s s26.2-2 $DIR/s26.2-3
1538 chmod 0666 $DIR/s26.2-3/foo
1540 run_test 26c "chain of symlinks"
1542 # recursive symlinks (bug 439)
1544 ln -s d26-3/foo $DIR/d26-3
1546 run_test 26d "create multiple component recursive symlink"
1549 [ ! -h $DIR/d26-3 ] && test_26d
1552 run_test 26e "unlink multiple component recursive symlink"
1554 # recursive symlinks (bug 7022)
1556 test_mkdir $DIR/$tdir
1557 test_mkdir $DIR/$tdir/$tfile
1558 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1559 test_mkdir -p lndir/bar1
1560 test_mkdir $DIR/$tdir/$tfile/$tfile
1561 cd $tfile || error "cd $tfile failed"
1562 ln -s .. dotdot || error "ln dotdot failed"
1563 ln -s dotdot/lndir lndir || error "ln lndir failed"
1564 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1565 output=`ls $tfile/$tfile/lndir/bar1`
1566 [ "$output" = bar1 ] && error "unexpected output"
1567 rm -r $tfile || error "rm $tfile failed"
1568 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1570 run_test 26f "rm -r of a directory which has recursive symlink"
1573 test_mkdir $DIR/$tdir
1574 $LFS getstripe $DIR/$tdir
1575 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1576 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1577 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1579 run_test 27a "one stripe file"
1582 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1584 test_mkdir $DIR/$tdir
1585 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1586 $LFS getstripe -c $DIR/$tdir/$tfile
1587 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1588 error "two-stripe file doesn't have two stripes"
1590 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1592 run_test 27b "create and write to two stripe file"
1594 # 27c family tests specific striping, setstripe -o
1596 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1597 test_mkdir -p $DIR/$tdir
1600 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1601 $LFS getstripe -i $DIR/$tdir/$tfile
1602 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1603 error "stripe not on specified OST"
1605 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1607 run_test 27ca "one stripe on specified OST"
1610 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1611 test_mkdir -p $DIR/$tdir
1613 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1614 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1617 # Strip getstripe output to a space separated list of OSTs
1618 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1619 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1620 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1621 error "stripes not on specified OSTs"
1623 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1625 run_test 27cb "two stripes on specified OSTs"
1628 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1629 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1630 skip "server does not support overstriping"
1632 test_mkdir -p $DIR/$tdir
1634 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1635 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1638 # Strip getstripe output to a space separated list of OSTs
1639 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1640 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1641 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1642 error "stripes not on specified OSTs"
1644 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1646 run_test 27cc "two stripes on the same OST"
1649 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1650 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1651 skip "server does not support overstriping"
1652 test_mkdir -p $DIR/$tdir
1653 local osts="0,1,1,0"
1654 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1655 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1658 # Strip getstripe output to a space separated list of OSTs
1659 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1660 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1661 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1662 error "stripes not on specified OSTs"
1664 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1666 run_test 27cd "four stripes on two OSTs"
1669 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1670 skip_env "too many osts, skipping"
1671 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1672 skip "server does not support overstriping"
1673 # We do one more stripe than we have OSTs
1674 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1675 skip_env "ea_inode feature disabled"
1677 test_mkdir -p $DIR/$tdir
1679 for i in $(seq 0 $OSTCOUNT);
1682 if [ $i -ne $OSTCOUNT ]; then
1686 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1687 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1690 # Strip getstripe output to a space separated list of OSTs
1691 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1692 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1693 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1694 error "stripes not on specified OSTs"
1696 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1698 run_test 27ce "more stripes than OSTs with -o"
1701 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1704 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1705 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1706 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1707 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1708 error "failed to set $osp_proc=0"
1710 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1713 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1714 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1715 error "failed to set $osp_proc=1"
1718 error "should return error due to $osp_proc=0"
1720 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1723 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1724 skip "server does not support overstriping"
1725 [[ $mds1_FSTYPE != "ldiskfs" ]] && skip_env "ldiskfs only test"
1726 large_xattr_enabled || skip_env "ea_inode feature disabled"
1730 for ((i=1;i<1000;i++)); do
1731 osts+=",$((i % OSTCOUNT))"
1734 local mdts=$(comma_list $(mdts_nodes))
1735 local before=$(do_nodes $mdts \
1736 "$LCTL get_param -n osd-ldiskfs.*MDT*.stats" |
1737 awk '/many credits/{print $3}' |
1740 $LFS setstripe -o $osts $DIR/$tfile || error "setstripe failed"
1741 $LFS getstripe $DIR/$tfile | grep stripe
1743 rm -f $DIR/$tfile || error "can't unlink"
1745 after=$(do_nodes $mdts \
1746 "$LCTL get_param -n osd-ldiskfs.*MDT*.stats" |
1747 awk '/many credits/{print $3}' |
1750 (( before == after )) ||
1751 error "too many credits happened: $after > $before"
1753 run_test 27cg "1000 shouldn't cause too many credits"
1756 test_mkdir $DIR/$tdir
1757 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1758 error "setstripe failed"
1759 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1760 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1762 run_test 27d "create file with default settings"
1765 # LU-5839 adds check for existed layout before setting it
1766 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1767 skip "Need MDS version at least 2.7.56"
1769 test_mkdir $DIR/$tdir
1770 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1771 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1772 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1774 run_test 27e "setstripe existing file (should return error)"
1777 test_mkdir $DIR/$tdir
1778 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1779 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1780 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1781 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1782 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1783 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1785 run_test 27f "setstripe with bad stripe size (should return error)"
1788 test_mkdir $DIR/$tdir
1789 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1790 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1791 error "$DIR/$tdir/$tfile has object"
1793 run_test 27g "$LFS getstripe with no objects"
1796 test_mkdir $DIR/$tdir
1797 touch $DIR/$tdir/$tfile || error "touch failed"
1798 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1799 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1801 (( rc == 2 )) || error "getstripe did not return ENOENT"
1803 run_test 27ga "$LFS getstripe with missing file (should return error)"
1806 test_mkdir $DIR/$tdir
1807 touch $DIR/$tdir/$tfile || error "touch failed"
1808 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1809 error "missing objects"
1811 run_test 27i "$LFS getstripe with some objects"
1814 test_mkdir $DIR/$tdir
1815 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1816 error "setstripe failed" || true
1818 run_test 27j "setstripe with bad stripe offset (should return error)"
1820 test_27k() { # bug 2844
1821 test_mkdir $DIR/$tdir
1822 local file=$DIR/$tdir/$tfile
1823 local ll_max_blksize=$((4 * 1024 * 1024))
1824 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1825 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1826 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1827 dd if=/dev/zero of=$file bs=4k count=1
1828 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1829 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1831 run_test 27k "limit i_blksize for broken user apps"
1834 mcreate $DIR/$tfile || error "creating file"
1835 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1836 error "setstripe should have failed" || true
1838 run_test 27l "check setstripe permissions (should return error)"
1841 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1843 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1844 skip_env "multiple clients -- skipping"
1846 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1848 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1849 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1851 stack_trap simple_cleanup_common
1852 test_mkdir $DIR/$tdir
1853 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1854 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1855 error "dd should fill OST0"
1857 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1859 [ $i -gt 256 ] && break
1862 touch $DIR/$tdir/$tfile.$i
1863 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1864 awk '{print $1}'| grep -w "0") ] &&
1865 error "OST0 was full but new created file still use it"
1867 touch $DIR/$tdir/$tfile.$i
1868 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1869 awk '{print $1}'| grep -w "0") ] &&
1870 error "OST0 was full but new created file still use it" || true
1872 run_test 27m "create file while OST0 was full"
1874 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1875 # if the OST isn't full anymore.
1877 local ostidx=${1:-""}
1882 local list=$(comma_list $(osts_nodes))
1883 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1885 do_nodes $list lctl set_param fail_loc=0
1886 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1887 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1888 awk '{print $1 * 2;exit;}')
1889 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1891 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1895 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1896 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1897 remote_mds_nodsh && skip "remote MDS with nodsh"
1898 remote_ost_nodsh && skip "remote OST with nodsh"
1901 rm -f $DIR/$tdir/$tfile
1902 exhaust_precreations 0 0x80000215
1903 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1904 touch $DIR/$tdir/$tfile || error "touch failed"
1905 $LFS getstripe $DIR/$tdir/$tfile
1908 run_test 27n "create file with some full OSTs"
1911 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1912 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1913 remote_mds_nodsh && skip "remote MDS with nodsh"
1914 remote_ost_nodsh && skip "remote OST with nodsh"
1917 rm -f $DIR/$tdir/$tfile
1918 exhaust_all_precreations 0x215
1920 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1925 run_test 27o "create file with all full OSTs (should error)"
1927 function create_and_checktime() {
1932 for ((i=0; i < $loops; i++)); do
1933 local start=$SECONDS
1934 multiop $fname-$i Oc
1935 ((SECONDS-start < TIMEOUT)) ||
1936 error "creation took " $((SECONDS-$start)) && return 1
1941 local mdts=$(comma_list $(mdts_nodes))
1943 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1944 skip "Need MDS version at least 2.13.57"
1946 local f0=$DIR/${tfile}-0
1947 local f1=$DIR/${tfile}-1
1949 wait_delete_completed
1951 # refill precreated objects
1952 $LFS setstripe -i0 -c1 $f0
1954 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1955 # force QoS allocation policy
1956 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1957 stack_trap "do_nodes $mdts $LCTL set_param \
1958 lov.*.qos_threshold_rr=$saved" EXIT
1961 # one OST is unavailable, but still have few objects preallocated
1963 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1964 rm -rf $f1 $DIR/$tdir*" EXIT
1966 for ((i=0; i < 7; i++)); do
1967 mkdir $DIR/$tdir$i || error "can't create dir"
1968 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1969 error "can't set striping"
1971 for ((i=0; i < 7; i++)); do
1972 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1976 run_test 27oo "don't let few threads to reserve too many objects"
1979 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1980 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1981 remote_mds_nodsh && skip "remote MDS with nodsh"
1982 remote_ost_nodsh && skip "remote OST with nodsh"
1985 rm -f $DIR/$tdir/$tfile
1986 test_mkdir $DIR/$tdir
1988 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1989 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1990 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1992 exhaust_precreations 0 0x80000215
1993 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1994 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1995 $LFS getstripe $DIR/$tdir/$tfile
1999 run_test 27p "append to a truncated file with some full OSTs"
2002 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2003 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2004 remote_mds_nodsh && skip "remote MDS with nodsh"
2005 remote_ost_nodsh && skip "remote OST with nodsh"
2008 rm -f $DIR/$tdir/$tfile
2010 mkdir_on_mdt0 $DIR/$tdir
2011 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
2012 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
2013 error "truncate $DIR/$tdir/$tfile failed"
2014 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
2016 exhaust_all_precreations 0x215
2018 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
2019 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
2023 run_test 27q "append to truncated file with all OSTs full (should error)"
2026 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2027 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2028 remote_mds_nodsh && skip "remote MDS with nodsh"
2029 remote_ost_nodsh && skip "remote OST with nodsh"
2032 rm -f $DIR/$tdir/$tfile
2033 exhaust_precreations 0 0x80000215
2035 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
2039 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
2041 test_27s() { # bug 10725
2042 test_mkdir $DIR/$tdir
2043 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2044 local stripe_count=0
2045 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2046 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2047 error "stripe width >= 2^32 succeeded" || true
2050 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2052 test_27t() { # bug 10864
2057 $WLFS getstripe $tfile
2060 run_test 27t "check that utils parse path correctly"
2062 test_27u() { # bug 4900
2063 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2064 remote_mds_nodsh && skip "remote MDS with nodsh"
2067 local list=$(comma_list $(mdts_nodes))
2069 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2070 do_nodes $list $LCTL set_param fail_loc=0x139
2071 test_mkdir -p $DIR/$tdir
2072 stack_trap "simple_cleanup_common 1000"
2073 createmany -o $DIR/$tdir/$tfile 1000
2074 do_nodes $list $LCTL set_param fail_loc=0
2076 TLOG=$TMP/$tfile.getstripe
2077 $LFS getstripe $DIR/$tdir > $TLOG
2078 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2079 [[ $OBJS -gt 0 ]] &&
2080 error "$OBJS objects created on OST-0. See $TLOG" ||
2083 run_test 27u "skip object creation on OSC w/o objects"
2085 test_27v() { # bug 4900
2086 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2088 remote_mds_nodsh && skip "remote MDS with nodsh"
2089 remote_ost_nodsh && skip "remote OST with nodsh"
2091 exhaust_all_precreations 0x215
2094 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2096 touch $DIR/$tdir/$tfile
2097 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2099 for (( i=1; i < OSTCOUNT; i++ )); do
2100 do_facet ost$i lctl set_param fail_loc=0x705
2102 local START=`date +%s`
2103 createmany -o $DIR/$tdir/$tfile 32
2105 local FINISH=`date +%s`
2106 local TIMEOUT=`lctl get_param -n timeout`
2107 local PROCESS=$((FINISH - START))
2108 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2109 error "$FINISH - $START >= $TIMEOUT / 2"
2110 sleep $((TIMEOUT / 2 - PROCESS))
2113 run_test 27v "skip object creation on slow OST"
2115 test_27w() { # bug 10997
2116 test_mkdir $DIR/$tdir
2117 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2118 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2119 error "stripe size $size != 65536" || true
2120 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2121 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2123 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2126 [[ $OSTCOUNT -lt 2 ]] &&
2127 skip_env "skipping multiple stripe count/offset test"
2129 test_mkdir $DIR/$tdir
2130 for i in $(seq 1 $OSTCOUNT); do
2132 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2133 error "setstripe -c $i -i $offset failed"
2134 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2135 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2136 [ $count -ne $i ] && error "stripe count $count != $i" || true
2137 [ $index -ne $offset ] &&
2138 error "stripe offset $index != $offset" || true
2141 run_test 27wa "check $LFS setstripe -c -i options"
2144 remote_ost_nodsh && skip "remote OST with nodsh"
2145 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2146 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2148 OFFSET=$(($OSTCOUNT - 1))
2150 local OST=$(ostname_from_index $OSTIDX)
2152 test_mkdir $DIR/$tdir
2153 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2154 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2156 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2157 for i in $(seq 0 $OFFSET); do
2158 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2159 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2160 error "OST0 was degraded but new created file still use it"
2162 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2164 run_test 27x "create files while OST0 is degraded"
2167 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2168 remote_mds_nodsh && skip "remote MDS with nodsh"
2169 remote_ost_nodsh && skip "remote OST with nodsh"
2170 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2172 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2173 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2174 osp.$mdtosc.prealloc_last_id)
2175 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2176 osp.$mdtosc.prealloc_next_id)
2177 local fcount=$((last_id - next_id))
2178 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2179 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2181 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2182 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2183 local OST_DEACTIVE_IDX=-1
2188 for OSC in $MDS_OSCS; do
2189 OST=$(osc_to_ost $OSC)
2190 OSTIDX=$(index_from_ostuuid $OST)
2191 if [ $OST_DEACTIVE_IDX == -1 ]; then
2192 OST_DEACTIVE_IDX=$OSTIDX
2194 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2195 echo $OSC "is Deactivated:"
2196 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2200 OSTIDX=$(index_from_ostuuid $OST)
2201 test_mkdir $DIR/$tdir
2202 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2204 for OSC in $MDS_OSCS; do
2205 OST=$(osc_to_ost $OSC)
2206 OSTIDX=$(index_from_ostuuid $OST)
2207 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2208 echo $OST "is degraded:"
2209 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2210 obdfilter.$OST.degraded=1
2215 createmany -o $DIR/$tdir/$tfile $fcount
2217 for OSC in $MDS_OSCS; do
2218 OST=$(osc_to_ost $OSC)
2219 OSTIDX=$(index_from_ostuuid $OST)
2220 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2221 echo $OST "is recovered from degraded:"
2222 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2223 obdfilter.$OST.degraded=0
2225 do_facet $SINGLEMDS lctl --device %$OSC activate
2229 # all osp devices get activated, hence -1 stripe count restored
2230 local stripe_count=0
2232 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2233 # devices get activated.
2235 $LFS setstripe -c -1 $DIR/$tfile
2236 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2238 [ $stripe_count -ne $OSTCOUNT ] &&
2239 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2242 run_test 27y "create files while OST0 is degraded and the rest inactive"
2248 lmm_count=$($LFS getstripe -c $1)
2249 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2250 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2252 local old_ifs="$IFS"
2254 fid=($($LFS path2fid $1))
2257 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2258 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2260 # compare lmm_seq and lu_fid->f_seq
2261 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2262 # compare lmm_object_id and lu_fid->oid
2263 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2265 # check the trusted.fid attribute of the OST objects of the file
2266 local have_obdidx=false
2268 $LFS getstripe $1 | while read obdidx oid hex seq; do
2269 # skip lines up to and including "obdidx"
2270 [ -z "$obdidx" ] && break
2271 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2272 $have_obdidx || continue
2274 local ost=$((obdidx + 1))
2275 local dev=$(ostdevname $ost)
2278 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2280 seq=$(echo $seq | sed -e "s/^0x//g")
2281 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2282 oid_hex=$(echo $oid)
2284 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2286 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2290 # Don't unmount/remount the OSTs if we don't need to do that.
2291 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2292 # update too, until that use mount/ll_decode_filter_fid/mount.
2293 # Re-enable when debugfs will understand new filter_fid.
2295 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2296 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2297 $dev 2>/dev/null" | grep "parent=")
2299 if [ -z "$ff" ]; then
2301 mount_fstype ost$ost
2302 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2303 $(facet_mntpt ost$ost)/$obj_file)
2304 unmount_fstype ost$ost
2305 start ost$ost $dev $OST_MOUNT_OPTS
2309 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2311 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2313 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2314 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2316 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2317 # stripe_size=1048576 component_id=1 component_start=0 \
2318 # component_end=33554432
2319 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2320 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2321 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2323 if grep -q 'stripe=' <<<$ff; then
2324 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2326 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2327 # into f_ver in this case. See comment on ff_parent.
2328 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2331 # compare lmm_seq and filter_fid->ff_parent.f_seq
2332 [ $ff_pseq = $lmm_seq ] ||
2333 error "FF parent SEQ $ff_pseq != $lmm_seq"
2334 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2335 [ $ff_poid = $lmm_oid ] ||
2336 error "FF parent OID $ff_poid != $lmm_oid"
2337 (($ff_pstripe == $stripe_nr)) ||
2338 error "FF stripe $ff_pstripe != $stripe_nr"
2340 stripe_nr=$((stripe_nr + 1))
2341 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2343 if grep -q 'stripe_count=' <<<$ff; then
2344 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2345 -e 's/ .*//' <<<$ff)
2346 [ $lmm_count = $ff_scnt ] ||
2347 error "FF stripe count $lmm_count != $ff_scnt"
2353 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2354 remote_ost_nodsh && skip "remote OST with nodsh"
2356 test_mkdir $DIR/$tdir
2357 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2358 { error "setstripe -c -1 failed"; return 1; }
2359 # We need to send a write to every object to get parent FID info set.
2360 # This _should_ also work for setattr, but does not currently.
2361 # touch $DIR/$tdir/$tfile-1 ||
2362 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2363 { error "dd $tfile-1 failed"; return 2; }
2364 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2365 { error "setstripe -c -1 failed"; return 3; }
2366 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2367 { error "dd $tfile-2 failed"; return 4; }
2369 # make sure write RPCs have been sent to OSTs
2372 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2373 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2375 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2377 test_27A() { # b=19102
2378 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2380 save_layout_restore_at_exit $MOUNT
2381 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2382 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2383 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2384 local default_size=$($LFS getstripe -S $MOUNT)
2385 local default_offset=$($LFS getstripe -i $MOUNT)
2386 local dsize=$(do_facet $SINGLEMDS \
2387 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2388 [ $default_size -eq $dsize ] ||
2389 error "stripe size $default_size != $dsize"
2390 [ $default_offset -eq -1 ] ||
2391 error "stripe offset $default_offset != -1"
2393 run_test 27A "check filesystem-wide default LOV EA values"
2395 test_27B() { # LU-2523
2396 test_mkdir $DIR/$tdir
2397 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2399 # open f1 with O_LOV_DELAY_CREATE
2401 # call setstripe ioctl on open file descriptor for f1
2403 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2407 # open f1 with O_LOV_DELAY_CREATE
2409 # call setstripe ioctl on open file descriptor for f1
2411 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2413 # Allow multiop to fail in imitation of NFS's busted semantics.
2416 run_test 27B "call setstripe on open unlinked file/rename victim"
2418 # 27C family tests full striping and overstriping
2419 test_27Ca() { #LU-2871
2420 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2428 test_mkdir $DIR/$tdir
2430 for i in $(seq 0 $((OSTCOUNT - 1))); do
2431 # set stripe across all OSTs starting from OST$i
2432 $LFS setstripe -i $i -c -1 $tfile$i
2433 # get striping information
2434 ost_idx=($($LFS getstripe $tfile$i |
2435 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2436 echo "OST Index: ${ost_idx[*]}"
2439 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2440 error "${#ost_idx[@]} != $OSTCOUNT"
2442 for index in $(seq 0 $((OSTCOUNT - 1))); do
2444 for j in "${ost_idx[@]}"; do
2445 if [ $index -eq $j ]; then
2451 error "Can not find $index in ${ost_idx[*]}"
2455 run_test 27Ca "check full striping across all OSTs"
2458 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2459 skip "server does not support overstriping"
2460 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2461 skip_env "too many osts, skipping"
2463 test_mkdir -p $DIR/$tdir
2464 local setcount=$(($OSTCOUNT * 2))
2465 [ $setcount -lt 160 ] || large_xattr_enabled ||
2466 skip_env "ea_inode feature disabled"
2468 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2469 error "setstripe failed"
2471 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2472 [ $count -eq $setcount ] ||
2473 error "stripe count $count, should be $setcount"
2475 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2476 error "overstriped should be set in pattern"
2478 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2481 run_test 27Cb "more stripes than OSTs with -C"
2484 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2485 skip "server does not support overstriping"
2486 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2488 test_mkdir -p $DIR/$tdir
2489 local setcount=$(($OSTCOUNT - 1))
2491 [ $setcount -lt 160 ] || large_xattr_enabled ||
2492 skip_env "ea_inode feature disabled"
2494 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2495 error "setstripe failed"
2497 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2498 [ $count -eq $setcount ] ||
2499 error "stripe count $count, should be $setcount"
2501 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2502 error "overstriped should not be set in pattern"
2504 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2507 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2510 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2511 skip "server does not support overstriping"
2512 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2513 large_xattr_enabled || skip_env "ea_inode feature disabled"
2517 test_mkdir -p $DIR/$tdir
2518 local setcount=$LOV_MAX_STRIPE_COUNT
2520 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2521 error "setstripe failed"
2523 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2524 [ $count -eq $setcount ] ||
2525 error "stripe count $count, should be $setcount"
2527 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2528 error "overstriped should be set in pattern"
2530 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2533 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2535 run_test 27Cd "test maximum stripe count"
2538 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2539 skip "server does not support overstriping"
2540 test_mkdir -p $DIR/$tdir
2542 pool_add $TESTNAME || error "Pool creation failed"
2543 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2547 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2548 error "setstripe failed"
2550 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2551 [ $count -eq $setcount ] ||
2552 error "stripe count $count, should be $setcount"
2554 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2555 error "overstriped should be set in pattern"
2557 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2560 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2562 run_test 27Ce "test pool with overstriping"
2565 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2566 skip "server does not support overstriping"
2567 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2568 skip_env "too many osts, skipping"
2570 test_mkdir -p $DIR/$tdir
2572 local setcount=$(($OSTCOUNT * 2))
2573 [ $setcount -lt 160 ] || large_xattr_enabled ||
2574 skip_env "ea_inode feature disabled"
2576 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2577 error "setstripe failed"
2579 echo 1 > $DIR/$tdir/$tfile
2581 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2582 [ $count -eq $setcount ] ||
2583 error "stripe count $count, should be $setcount"
2585 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2586 error "overstriped should be set in pattern"
2588 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2591 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2593 run_test 27Cf "test default inheritance with overstriping"
2596 (( MDS1_VERSION >= $(version_code v2_15_55-80-gd96b98ee6b) )) ||
2597 skip "need MDS version at least v2_15_55-80-gd96b98ee6b for fix"
2599 $LFS setstripe -o 0,$OSTCOUNT $DIR/$tfile
2600 (( $? != 0 )) || error "must be an error for not existent OST#"
2602 run_test 27Cg "test setstripe with wrong OST idx"
2605 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2606 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2607 remote_mds_nodsh && skip "remote MDS with nodsh"
2609 local POOL=${POOL:-testpool}
2611 local last_ost=$(($OSTCOUNT - 1))
2613 local ost_list=$(seq $first_ost $ost_step $last_ost)
2614 local ost_range="$first_ost $last_ost $ost_step"
2616 test_mkdir $DIR/$tdir
2617 pool_add $POOL || error "pool_add failed"
2618 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2621 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2623 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2624 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2625 skip27D+=" -s 30,31"
2626 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2627 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2628 skip27D+=" -s 32,33"
2629 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2631 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2632 error "llapi_layout_test failed"
2634 destroy_test_pools || error "destroy test pools failed"
2636 run_test 27D "validate llapi_layout API"
2638 # Verify that default_easize is increased from its initial value after
2639 # accessing a widely striped file.
2641 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2642 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2643 skip "client does not have LU-3338 fix"
2645 # 72 bytes is the minimum space required to store striping
2646 # information for a file striped across one OST:
2647 # (sizeof(struct lov_user_md_v3) +
2648 # sizeof(struct lov_user_ost_data_v1))
2650 $LCTL set_param -n llite.*.default_easize $min_easize ||
2651 error "lctl set_param failed"
2652 local easize=$($LCTL get_param -n llite.*.default_easize)
2654 [ $easize -eq $min_easize ] ||
2655 error "failed to set default_easize"
2657 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2658 error "setstripe failed"
2659 # In order to ensure stat() call actually talks to MDS we need to
2660 # do something drastic to this file to shake off all lock, e.g.
2661 # rename it (kills lookup lock forcing cache cleaning)
2662 mv $DIR/$tfile $DIR/${tfile}-1
2663 ls -l $DIR/${tfile}-1
2666 easize=$($LCTL get_param -n llite.*.default_easize)
2668 [ $easize -gt $min_easize ] ||
2669 error "default_easize not updated"
2671 run_test 27E "check that default extended attribute size properly increases"
2673 test_27F() { # LU-5346/LU-7975
2674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2675 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2676 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2677 skip "Need MDS version at least 2.8.51"
2678 remote_ost_nodsh && skip "remote OST with nodsh"
2680 test_mkdir $DIR/$tdir
2682 $LFS setstripe -c 2 $DIR/$tdir
2684 # stop all OSTs to reproduce situation for LU-7975 ticket
2685 for num in $(seq $OSTCOUNT); do
2689 # open/create f0 with O_LOV_DELAY_CREATE
2690 # truncate f0 to a non-0 size
2692 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2694 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2695 # open/write it again to force delayed layout creation
2696 cat /etc/hosts > $DIR/$tdir/f0 &
2700 for num in $(seq $OSTCOUNT); do
2701 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2702 error "ost$num failed to start"
2705 wait $catpid || error "cat failed"
2707 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2708 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2709 error "wrong stripecount"
2712 run_test 27F "Client resend delayed layout creation with non-zero size"
2714 test_27G() { #LU-10629
2715 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2716 skip "Need MDS version at least 2.11.51"
2717 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2718 remote_mds_nodsh && skip "remote MDS with nodsh"
2719 local POOL=${POOL:-testpool}
2720 local ostrange="0 0 1"
2722 test_mkdir $DIR/$tdir
2723 touch $DIR/$tdir/$tfile.nopool
2724 pool_add $POOL || error "pool_add failed"
2725 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2726 $LFS setstripe -p $POOL $DIR/$tdir
2728 local pool=$($LFS getstripe -p $DIR/$tdir)
2730 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2731 touch $DIR/$tdir/$tfile.default
2732 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2733 $LFS find $DIR/$tdir -type f --pool $POOL
2734 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2735 [[ "$found" == "2" ]] ||
2736 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2738 $LFS setstripe -d $DIR/$tdir
2740 pool=$($LFS getstripe -p -d $DIR/$tdir)
2742 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2744 run_test 27G "Clear OST pool from stripe"
2747 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2748 skip "Need MDS version newer than 2.11.54"
2749 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2750 test_mkdir $DIR/$tdir
2751 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2752 touch $DIR/$tdir/$tfile
2753 $LFS getstripe -c $DIR/$tdir/$tfile
2754 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2755 error "two-stripe file doesn't have two stripes"
2757 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2758 $LFS getstripe -y $DIR/$tdir/$tfile
2759 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2760 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2761 error "expected l_ost_idx: [02]$ not matched"
2763 # make sure ost list has been cleared
2764 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2765 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2766 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2768 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2770 run_test 27H "Set specific OSTs stripe"
2773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2774 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2775 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2776 skip "Need MDS version newer than 2.12.52"
2777 local pool=$TESTNAME
2778 local ostrange="1 1 1"
2780 save_layout_restore_at_exit $MOUNT
2781 $LFS setstripe -c 2 -i 0 $MOUNT
2782 pool_add $pool || error "pool_add failed"
2783 pool_add_targets $pool $ostrange ||
2784 error "pool_add_targets failed"
2785 test_mkdir $DIR/$tdir
2786 $LFS setstripe -p $pool $DIR/$tdir
2787 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2788 $LFS getstripe $DIR/$tdir/$tfile
2790 run_test 27I "check that root dir striping does not break parent dir one"
2793 (( $MDS1_VERSION > $(version_code 2.12.51) )) ||
2794 skip "Need MDS version newer than 2.12.51"
2796 # skip basic ops on file with foreign LOV tests on 5.12-6.2 kernels
2797 # until the filemap_read() issue is fixed by v6.2-rc4-61-g5956592ce337
2798 (( $LINUX_VERSION_CODE < $(version_code 5.12.0) ||
2799 $LINUX_VERSION_CODE >= $(version_code 6.2.0) )) ||
2800 skip "Need kernel < 5.12.0 or >= 6.2.0 for filemap_read() fix"
2802 test_mkdir $DIR/$tdir
2803 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2804 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2806 # create foreign file (raw way)
2807 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2808 error "creating $tfile w/ hex flags w/o --foreign should fail"
2810 ! $LFS setstripe --foreign --flags foo \
2811 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2812 error "creating $tfile with '--flags foo' should fail"
2814 ! $LFS setstripe --foreign --flags 0xffffffff \
2815 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2816 error "creating $tfile w/ 0xffffffff flags should fail"
2818 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2819 -t 1 -F 0xda08 || error "create_foreign_file failed"
2821 # verify foreign file (raw way)
2822 parse_foreign_file -f $DIR/$tdir/$tfile |
2823 grep "lov_foreign_magic: 0x0BD70BD0" ||
2824 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2825 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2826 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2827 parse_foreign_file -f $DIR/$tdir/$tfile |
2828 grep "lov_foreign_size: 73" ||
2829 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2830 parse_foreign_file -f $DIR/$tdir/$tfile |
2831 grep "lov_foreign_type: 1" ||
2832 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2833 parse_foreign_file -f $DIR/$tdir/$tfile |
2834 grep "lov_foreign_flags: 0x0000DA08" ||
2835 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2836 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2837 grep "lov_foreign_value: 0x" |
2838 sed -e 's/lov_foreign_value: 0x//')
2839 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2840 [[ $lov = ${lov2// /} ]] ||
2841 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2843 # create foreign file (lfs + API)
2844 $LFS setstripe --foreign=none --flags 0xda08 \
2845 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2846 error "$DIR/$tdir/${tfile}2: create failed"
2848 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2849 grep "lfm_magic:.*0x0BD70BD0" ||
2850 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2851 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2852 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2853 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2854 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2855 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2856 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2857 grep "lfm_flags:.*0x0000DA08" ||
2858 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2859 $LFS getstripe $DIR/$tdir/${tfile}2 |
2860 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2861 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2863 # modify striping should fail
2864 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2865 error "$DIR/$tdir/$tfile: setstripe should fail"
2866 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2867 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2870 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2871 cat $DIR/$tdir/${tfile}2 &&
2872 error "$DIR/$tdir/${tfile}2: read should fail"
2873 cat /etc/passwd > $DIR/$tdir/$tfile &&
2874 error "$DIR/$tdir/$tfile: write should fail"
2875 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2876 error "$DIR/$tdir/${tfile}2: write should fail"
2879 chmod 222 $DIR/$tdir/$tfile ||
2880 error "$DIR/$tdir/$tfile: chmod failed"
2881 chmod 222 $DIR/$tdir/${tfile}2 ||
2882 error "$DIR/$tdir/${tfile}2: chmod failed"
2885 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2886 error "$DIR/$tdir/$tfile: chown failed"
2887 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2888 error "$DIR/$tdir/${tfile}2: chown failed"
2890 # rename should work
2891 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2892 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2893 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2894 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2896 #remove foreign file
2897 rm $DIR/$tdir/${tfile}.new ||
2898 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2899 rm $DIR/$tdir/${tfile}2.new ||
2900 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2902 run_test 27J "basic ops on file with foreign LOV"
2905 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2906 skip "Need MDS version newer than 2.12.49"
2908 test_mkdir $DIR/$tdir
2909 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2910 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2912 # create foreign dir (raw way)
2913 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2914 error "creating $tdir w/ hex flags w/o --foreign should fail"
2916 ! $LFS setdirstripe --foreign --flags foo \
2917 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2918 error "creating $tdir with '--flags foo' should fail"
2920 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2921 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2922 error "creating $tdir w/ 0xffffffff flags should fail"
2924 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2925 error "create_foreign_dir FAILED"
2927 # verify foreign dir (raw way)
2928 parse_foreign_dir -d $DIR/$tdir/$tdir |
2929 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2930 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2931 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2932 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2933 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2934 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2935 parse_foreign_dir -d $DIR/$tdir/$tdir |
2936 grep "lmv_foreign_flags: 55813$" ||
2937 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2938 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2939 grep "lmv_foreign_value: 0x" |
2940 sed 's/lmv_foreign_value: 0x//')
2941 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2943 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2945 # create foreign dir (lfs + API)
2946 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2947 $DIR/$tdir/${tdir}2 ||
2948 error "$DIR/$tdir/${tdir}2: create failed"
2950 $LFS getdirstripe -v $DIR/$tdir/${tdir}2
2952 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2953 grep "lfm_magic:.*0x0CD50CD0" ||
2954 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2955 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2956 # - sizeof(lfm_type) - sizeof(lfm_flags)
2957 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2958 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2959 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2960 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2961 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2962 grep "lfm_flags:.*0x0000DA05" ||
2963 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2964 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2965 grep "lfm_value.*${uuid1}@${uuid2}" ||
2966 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2968 # file create in dir should fail
2969 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
2970 touch $DIR/$tdir/${tdir}2/$tfile &&
2971 error "$DIR/${tdir}2: file create should fail"
2974 chmod 777 $DIR/$tdir/$tdir ||
2975 error "$DIR/$tdir: chmod failed"
2976 chmod 777 $DIR/$tdir/${tdir}2 ||
2977 error "$DIR/${tdir}2: chmod failed"
2980 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2981 error "$DIR/$tdir: chown failed"
2982 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2983 error "$DIR/${tdir}2: chown failed"
2985 # rename should work
2986 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2987 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2988 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2989 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2992 rmdir $DIR/$tdir/${tdir}.new ||
2993 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2994 rmdir $DIR/$tdir/${tdir}2.new ||
2995 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2997 run_test 27K "basic ops on dir with foreign LMV"
3000 remote_mds_nodsh && skip "remote MDS with nodsh"
3002 local POOL=${POOL:-$TESTNAME}
3004 pool_add $POOL || error "pool_add failed"
3006 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
3007 error "pool_list does not contain ${FSNAME}.${POOL}:" \
3008 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
3010 run_test 27L "lfs pool_list gives correct pool name"
3013 (( $MDS1_VERSION >= $(version_code 2.12.57) )) ||
3014 skip "Need MDS version >= than 2.12.57"
3015 remote_mds_nodsh && skip "remote MDS with nodsh"
3016 (( $OSTCOUNT > 1 )) || skip "need > 1 OST"
3018 # Set default striping on directory
3021 local mdts=$(comma_list $(mdts_nodes))
3023 # if we run against a 2.12 server which lacks overstring support
3024 # then the connect_flag will not report overstriping, even if client
3026 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
3027 stripe_opt="-C $setcount"
3028 elif (( $OSTCOUNT >= $setcount )); then
3029 stripe_opt="-c $setcount"
3031 skip "server does not support overstriping"
3034 test_mkdir $DIR/$tdir
3036 # Validate existing append_* params and ensure restore
3037 local pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3038 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3039 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3041 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3042 ((orig_count == 1)) || error "expected append_stripe_count == 1, got $orig_count"
3043 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1"
3045 $LFS setstripe $stripe_opt $DIR/$tdir
3047 echo 1 > $DIR/$tdir/${tfile}.1
3048 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
3049 (( $count == $setcount )) ||
3050 error "(1) stripe count $count, should be $setcount"
3052 local appendcount=$orig_count
3053 echo 1 >> $DIR/$tdir/${tfile}.2_append
3054 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
3055 (( $count == $appendcount )) ||
3056 error "(2)stripe count $count, should be $appendcount for append"
3058 # Disable O_APPEND striping, verify it works
3059 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3061 # Should now get the default striping, which is 4
3063 echo 1 >> $DIR/$tdir/${tfile}.3_append
3064 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3065 (( $count == $setcount )) ||
3066 error "(3) stripe count $count, should be $setcount"
3068 # Try changing the stripe count for append files
3069 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3071 # Append striping is now 2 (directory default is still 4)
3073 echo 1 >> $DIR/$tdir/${tfile}.4_append
3074 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3075 (( $count == $appendcount )) ||
3076 error "(4) stripe count $count, should be $appendcount for append"
3078 # Test append stripe count of -1
3079 # Exercise LU-16872 patch with specific striping, only if MDS has fix
3080 (( $MDS1_VERSION > $(version_code 2.15.56.46) )) &&
3081 $LFS setstripe -o 0,$((OSTCOUNT - 1)) $DIR/$tdir &&
3082 touch $DIR/$tdir/$tfile.specific.{1..128}
3083 stack_trap "rm -f $DIR/$tdir/$tfile.*"
3085 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3086 appendcount=$OSTCOUNT
3087 echo 1 >> $DIR/$tdir/${tfile}.5
3088 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3089 (( $count == $appendcount )) ||
3090 error "(5) stripe count $count, should be $appendcount for append"
3092 # Set append striping back to default of 1
3093 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3095 # Try a new default striping, PFL + DOM
3096 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3098 # Create normal DOM file, DOM returns stripe count == 0
3100 touch $DIR/$tdir/${tfile}.6
3101 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3102 (( $count == $setcount )) ||
3103 error "(6) stripe count $count, should be $setcount"
3107 echo 1 >> $DIR/$tdir/${tfile}.7_append
3108 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3109 (( $count == $appendcount )) ||
3110 error "(7) stripe count $count, should be $appendcount for append"
3112 # Clean up DOM layout
3113 $LFS setstripe -d $DIR/$tdir
3115 save_layout_restore_at_exit $MOUNT
3116 # Now test that append striping works when layout is from root
3117 $LFS setstripe -c 2 $MOUNT
3118 # Make a special directory for this
3119 mkdir $DIR/${tdir}/${tdir}.2
3121 # Verify for normal file
3123 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3124 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3125 (( $count == $setcount )) ||
3126 error "(8) stripe count $count, should be $setcount"
3129 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3130 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3131 (( $count == $appendcount )) ||
3132 error "(9) stripe count $count, should be $appendcount for append"
3134 # Now test O_APPEND striping with pools
3135 pool_add $TESTNAME || error "pool creation failed"
3136 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3137 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3139 echo 1 >> $DIR/$tdir/${tfile}.10_append
3141 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3142 [[ "$pool" == "$TESTNAME" ]] || error "(10) incorrect pool: $pool"
3144 # Check that count is still correct
3146 echo 1 >> $DIR/$tdir/${tfile}.11_append
3147 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3148 (( $count == $appendcount )) ||
3149 error "(11) stripe count $count, should be $appendcount for append"
3151 # Disable O_APPEND stripe count, verify pool works separately
3152 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3154 echo 1 >> $DIR/$tdir/${tfile}.12_append
3156 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3157 [[ "$pool" == "$TESTNAME" ]] || error "(12) incorrect pool: $pool"
3159 # Remove pool setting, verify it's not applied
3160 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3162 echo 1 >> $DIR/$tdir/${tfile}.13_append
3164 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3165 [[ -z "$pool" ]] || error "(13) pool found: $pool"
3167 run_test 27M "test O_APPEND striping"
3170 combined_mgs_mds && skip "needs separate MGS/MDT"
3172 pool_add $TESTNAME || error "pool_add failed"
3173 do_facet mgs "$LCTL pool_list $FSNAME" |
3174 grep -Fx "${FSNAME}.${TESTNAME}" ||
3175 error "lctl pool_list on MGS failed"
3177 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3179 clean_foreign_symlink() {
3181 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3182 for i in $DIR/$tdir/* ; do
3183 $LFS unlink_foreign $i || true
3188 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3189 skip "Need MDS version newer than 2.12.51"
3191 test_mkdir $DIR/$tdir
3192 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3193 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3195 trap clean_foreign_symlink EXIT
3197 # enable foreign_symlink behaviour
3198 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3200 # foreign symlink LOV format is a partial path by default
3202 # create foreign file (lfs + API)
3203 $LFS setstripe --foreign=symlink --flags 0xda05 \
3204 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3205 error "$DIR/$tdir/${tfile}: create failed"
3207 $LFS getstripe -v $DIR/$tdir/${tfile} |
3208 grep "lfm_magic:.*0x0BD70BD0" ||
3209 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3210 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3211 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3212 $LFS getstripe -v $DIR/$tdir/${tfile} |
3213 grep "lfm_flags:.*0x0000DA05" ||
3214 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3215 $LFS getstripe $DIR/$tdir/${tfile} |
3216 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3217 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3219 # modify striping should fail
3220 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3221 error "$DIR/$tdir/$tfile: setstripe should fail"
3223 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3224 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3225 cat /etc/passwd > $DIR/$tdir/$tfile &&
3226 error "$DIR/$tdir/$tfile: write should fail"
3228 # rename should succeed
3229 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3230 error "$DIR/$tdir/$tfile: rename has failed"
3232 #remove foreign_symlink file should fail
3233 rm $DIR/$tdir/${tfile}.new &&
3234 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3237 mkdir /tmp/${uuid1} ||
3238 error "/tmp/${uuid1}: mkdir has failed"
3239 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3240 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3241 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3242 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3243 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3244 #read should succeed now
3245 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3246 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3247 #write should succeed now
3248 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3249 error "$DIR/$tdir/${tfile}.new: write should succeed"
3250 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3251 error "$DIR/$tdir/${tfile}.new: diff has failed"
3252 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3253 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3255 #check that getstripe still works
3256 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3257 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3259 # chmod should still succeed
3260 chmod 644 $DIR/$tdir/${tfile}.new ||
3261 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3263 # chown should still succeed
3264 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3265 error "$DIR/$tdir/${tfile}.new: chown has failed"
3267 # rename should still succeed
3268 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3269 error "$DIR/$tdir/${tfile}.new: rename has failed"
3271 #remove foreign_symlink file should still fail
3272 rm $DIR/$tdir/${tfile} &&
3273 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3275 #use special ioctl() to unlink foreign_symlink file
3276 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3277 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3280 run_test 27O "basic ops on foreign file of symlink type"
3283 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3284 skip "Need MDS version newer than 2.12.49"
3286 test_mkdir $DIR/$tdir
3287 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3288 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3290 trap clean_foreign_symlink EXIT
3292 # enable foreign_symlink behaviour
3293 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3295 # foreign symlink LMV format is a partial path by default
3297 # create foreign dir (lfs + API)
3298 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3299 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3300 error "$DIR/$tdir/${tdir}: create failed"
3302 $LFS getdirstripe -v $DIR/$tdir/${tdir}
3304 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3305 grep "lfm_magic:.*0x0CD50CD0" ||
3306 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3307 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3308 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3309 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3310 grep "lfm_flags:.*0x0000DA05" ||
3311 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3312 $LFS getdirstripe $DIR/$tdir/${tdir} |
3313 grep "lfm_value.*${uuid1}/${uuid2}" ||
3314 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3316 # file create in dir should fail
3317 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3318 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
3320 # rename should succeed
3321 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3322 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3324 #remove foreign_symlink dir should fail
3325 rmdir $DIR/$tdir/${tdir}.new &&
3326 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3329 mkdir -p /tmp/${uuid1}/${uuid2} ||
3330 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3331 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3332 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3333 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3334 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3335 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3336 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3337 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3339 #check that getstripe fails now that foreign_symlink enabled
3340 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3341 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3343 # file create in dir should work now
3344 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3345 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3346 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3347 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3348 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3349 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3351 # chmod should still succeed
3352 chmod 755 $DIR/$tdir/${tdir}.new ||
3353 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3355 # chown should still succeed
3356 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3357 error "$DIR/$tdir/${tdir}.new: chown has failed"
3359 # rename should still succeed
3360 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3361 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3363 #remove foreign_symlink dir should still fail
3364 rmdir $DIR/$tdir/${tdir} &&
3365 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3367 #use special ioctl() to unlink foreign_symlink file
3368 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3369 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3371 #created file should still exist
3372 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3373 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3374 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3375 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3377 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3380 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3381 stack_trap "rm -f $TMP/$tfile*"
3383 test_mkdir $DIR/$tdir-1
3384 test_mkdir $DIR/$tdir-2
3386 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3387 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3389 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3390 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3392 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3393 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3395 # Create some bad symlinks and ensure that we don't loop
3396 # forever or something. These should return ELOOP (40) and
3397 # ENOENT (2) but I don't want to test for that because there's
3398 # always some weirdo architecture that needs to ruin
3399 # everything by defining these error numbers differently.
3401 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3402 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3404 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3405 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3409 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3412 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
3413 skip "need MDS 2.14.55 or later"
3414 (( $OSTCOUNT >= 2 )) || skip_env "needs at least 2 OSTs"
3416 local testdir="$DIR/$tdir"
3417 test_mkdir -p $testdir
3418 stack_trap "rm -rf $testdir"
3419 $LFS setstripe -c -1 $testdir || error "setstripe failed"
3421 local f1="$testdir/f1"
3422 touch $f1 || error "failed to touch $f1"
3423 local count=$($LFS getstripe -c $f1)
3424 (( $count == $OSTCOUNT )) || error "wrong stripe count"
3426 do_facet $SINGLEMDS $LCTL set_param lod.*.max_stripecount=-1
3427 (( $? == 34 )) || error "setting max_stripecount to -1 should fail and return ERANGE"
3429 local maxcount=$(($OSTCOUNT - 1))
3430 local mdts=$(comma_list $(mdts_nodes))
3431 do_nodes $mdts $LCTL set_param lod.*.max_stripecount=$maxcount
3432 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_stripecount=0"
3434 local f2="$testdir/f2"
3435 touch $f2 || error "failed to touch $f2"
3436 local count=$($LFS getstripe -c $f2)
3437 (( $count == $maxcount )) || error "wrong stripe count"
3439 run_test 27R "test max_stripecount limitation when stripe count is set to -1"
3442 [ $(facet_host client) == $(facet_host ost1) ] &&
3443 skip "need ost1 and client on different nodes"
3445 #define OBD_FAIL_OSC_NO_GRANT 0x411
3446 $LCTL set_param fail_loc=0x20000411 fail_val=1
3447 #define OBD_FAIL_OST_ENOSPC 0x215
3448 do_facet ost1 "$LCTL set_param fail_loc=0x80000215"
3449 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3450 $MULTIOP $DIR/$tfile oO_WRONLY:P$((4 * 1024 * 1024 + 10 * 4096))c ||
3451 error "multiop failed"
3453 run_test 27T "no eio on close on partial write due to enosp"
3456 local dir=$DIR/$tdir
3457 local file=$dir/$tfile
3458 local append_pool=${TESTNAME}-append
3459 local normal_pool=${TESTNAME}-normal
3463 local mdts=$(comma_list $(mdts_nodes))
3465 (( $MDS1_VERSION >= $(version_code 2.15.51) )) ||
3466 skip "Need MDS version at least 2.15.51 for append pool feature"
3468 # Validate existing append_* params and ensure restore
3469 pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3470 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3471 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3473 stripe_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3474 ((stripe_count == 1)) || error "expected append_stripe_count != 0, got $stripe_count"
3475 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$stripe_count"
3477 pool_add $append_pool || error "pool creation failed"
3478 pool_add_targets $append_pool 0 1 || error "Pool add targets failed"
3480 pool_add $normal_pool || error "pool creation failed"
3481 pool_add_targets $normal_pool 0 1 || error "Pool add targets failed"
3484 $LFS setstripe -E 1M -c 1 -p $normal_pool -E 2M -c 2 -p $normal_pool -E eof -c -1 $dir
3487 $LFS getstripe $file.1
3489 pool=$($LFS getstripe -p $file.1)
3490 [[ "$pool" == "$normal_pool" ]] || error "got pool '$pool', expected '$normal_pool'"
3492 stripe_count2=$($LFS getstripe -c $file.1)
3493 ((stripe_count2 == stripe_count)) ||
3494 error "got stripe_count '$stripe_count2', expected '$stripe_count'"
3496 do_nodes $mdts $LCTL set_param mdd.*.append_pool=$append_pool
3499 $LFS getstripe $file.2
3501 pool=$($LFS getstripe -p $file.2)
3502 [[ "$pool" == "$append_pool" ]] || error "got pool '$pool', expected '$append_pool'"
3504 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3507 $LFS getstripe $file.3
3509 stripe_count2=$($LFS getstripe -c $file.3)
3510 ((stripe_count2 == 2)) || error "got stripe_count '$stripe_count2', expected 2"
3512 run_test 27U "append pool and stripe count work with composite default layout"
3515 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3516 (( $OSTCOUNT >= 4 )) || skip_env "needs >= 4 OSTs"
3518 local dir=$DIR/$tdir
3519 local osp_param=osp.$FSNAME-OST0000-osc-MDT0000.max_create_count
3520 local lod_param=lod.$FSNAME-MDT0000-mdtlov.qos_threshold_rr
3521 local saved_max=$(do_facet mds1 $LCTL get_param -n $osp_param)
3522 local saved_qos=$(do_facet mds1 $LCTL get_param -n $lod_param)
3525 stack_trap "do_facet mds1 $LCTL set_param $osp_param=$saved_max"
3527 do_facet mds1 $LCTL set_param $lod_param=0
3528 stack_trap "do_facet mds1 $LCTL set_param $lod_param=$saved_qos"
3530 $LFS setdirstripe --mdt-count=1 --mdt-index=0 $dir
3531 stack_trap "rm -rf $dir"
3533 # exercise race in LU-16981 with deactivating OST while creating a file
3536 do_facet mds1 $LCTL set_param $osp_param=0 > /dev/null
3539 $LCTL set_param $osp_param=$saved_max > /dev/null
3544 stack_trap "kill -9 $pid"
3546 # errors here are OK so ignore them (just don't want to crash)
3547 $LFS setstripe -c -1 $dir/f.{1..200} 2> /dev/null
3551 run_test 27V "creating widely striped file races with deactivating OST"
3553 # createtest also checks that device nodes are created and
3554 # then visible correctly (#2091)
3555 test_28() { # bug 2091
3557 $CREATETEST $DIR/d28/ct || error "createtest failed"
3559 run_test 28 "create/mknod/mkdir with bad file types ============"
3562 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3564 [ $MDS1_VERSION -ge $(version_code 2.14.51) ] && {
3566 stack_trap "restore_opencache"
3569 sync; sleep 1; sync # flush out any dirty pages from previous tests
3576 local locks_orig=$(total_used_locks mdc)
3577 (( $locks_orig != 0 )) || error "No mdc lock count"
3579 local locks_unused_orig=$(total_unused_locks mdc)
3585 local locks_current=$(total_used_locks mdc)
3587 local locks_unused_current=$(total_unused_locks mdc)
3589 if (( $locks_current > $locks_orig )); then
3590 $LCTL set_param -n ldlm.dump_namespaces ""
3591 error "CURRENT: $locks_current > $locks_orig"
3593 if (( $locks_unused_current > $locks_unused_orig )); then
3594 error "UNUSED: $locks_unused_current > $locks_unused_orig"
3597 run_test 29 "IT_GETATTR regression ============================"
3599 test_30a() { # was test_30
3600 cp $(which ls) $DIR || cp /bin/ls $DIR
3601 $DIR/ls / || error "Can't execute binary from lustre"
3604 run_test 30a "execute binary from Lustre (execve) =============="
3607 cp `which ls` $DIR || cp /bin/ls $DIR
3609 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3612 run_test 30b "execute binary from Lustre as non-root ==========="
3614 test_30c() { # b=22376
3615 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3617 cp $(which ls) $DIR || cp /bin/ls $DIR
3619 cancel_lru_locks mdc
3620 cancel_lru_locks osc
3621 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3624 run_test 30c "execute binary from Lustre without read perms ===="
3627 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3629 for i in {1..10}; do
3630 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3633 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3634 wait $PID || error "executing dd from Lustre failed"
3640 run_test 30d "execute binary from Lustre while clear locks"
3643 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3644 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3646 run_test 31a "open-unlink file =================================="
3649 touch $DIR/f31 || error "touch $DIR/f31 failed"
3650 ln $DIR/f31 $DIR/f31b || error "ln failed"
3651 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3652 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3654 run_test 31b "unlink file with multiple links while open ======="
3657 touch $DIR/f31 || error "touch $DIR/f31 failed"
3658 ln $DIR/f31 $DIR/f31c || error "ln failed"
3659 multiop_bg_pause $DIR/f31 O_uc ||
3660 error "multiop_bg_pause for $DIR/f31 failed"
3662 $MULTIOP $DIR/f31c Ouc
3663 kill -USR1 $MULTIPID
3666 run_test 31c "open-unlink file with multiple links ============="
3669 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3670 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3672 run_test 31d "remove of open directory ========================="
3674 test_31e() { # bug 2904
3675 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3677 run_test 31e "remove of open non-empty directory ==============="
3679 test_31f() { # bug 4554
3680 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3683 test_mkdir $DIR/d31f
3684 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3685 cp /etc/hosts $DIR/d31f
3687 $LFS getstripe $DIR/d31f/hosts
3688 multiop_bg_pause $DIR/d31f D_c || return 1
3691 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3692 test_mkdir $DIR/d31f
3693 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3694 cp /etc/hosts $DIR/d31f
3696 $LFS getstripe $DIR/d31f/hosts
3697 multiop_bg_pause $DIR/d31f D_c || return 1
3700 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3701 wait $MULTIPID || error "first opendir $MULTIPID failed"
3705 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3706 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3709 run_test 31f "remove of open directory with open-unlink file ==="
3712 echo "-- cross directory link --"
3713 test_mkdir -c1 $DIR/${tdir}ga
3714 test_mkdir -c1 $DIR/${tdir}gb
3715 touch $DIR/${tdir}ga/f
3716 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3717 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3718 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3719 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3720 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3722 run_test 31g "cross directory link==============="
3725 echo "-- cross directory link --"
3726 test_mkdir -c1 $DIR/${tdir}
3727 test_mkdir -c1 $DIR/${tdir}/dir
3728 touch $DIR/${tdir}/f
3729 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3730 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3731 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3732 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3733 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3735 run_test 31h "cross directory link under child==============="
3738 echo "-- cross directory link --"
3739 test_mkdir -c1 $DIR/$tdir
3740 test_mkdir -c1 $DIR/$tdir/dir
3741 touch $DIR/$tdir/dir/f
3742 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3743 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3744 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3745 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3746 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3748 run_test 31i "cross directory link under parent==============="
3751 test_mkdir -c1 -p $DIR/$tdir
3752 test_mkdir -c1 -p $DIR/$tdir/dir1
3753 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3754 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3755 link $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "link to the same dir"
3758 run_test 31j "link for directory"
3761 test_mkdir -c1 -p $DIR/$tdir
3763 touch $DIR/$tdir/exist
3764 link $DIR/$tdir/s $DIR/$tdir/t || error "link"
3765 link $DIR/$tdir/s $DIR/$tdir/exist && error "link to exist file"
3766 link $DIR/$tdir/s $DIR/$tdir/s && error "link to the same file"
3767 link $DIR/$tdir/s $DIR/$tdir && error "link to parent dir"
3768 link $DIR/$tdir $DIR/$tdir/s && error "link parent dir to target"
3769 link $DIR/$tdir/not-exist $DIR/$tdir/foo && error "link non-existing to new"
3770 link $DIR/$tdir/not-exist $DIR/$tdir/s && error "link non-existing to exist"
3773 run_test 31k "link to file: the same, non-existing, dir"
3776 local ln_ver=$(ln --version | awk '/coreutils/ { print $4 }')
3778 (( $(version_code $ln_ver) < $(version_code 8.31) )) ||
3779 (( $(version_code $(uname -r)) >= $(version_code 5.18) )) ||
3780 skip "need coreutils < 8.31 or kernel >= 5.18 for ln"
3782 touch $DIR/$tfile || error "create failed"
3783 mkdir $DIR/$tdir || error "mkdir failed"
3784 ln $DIR/$tfile $DIR/$tdir/ || error "ln to '$tdir/' failed"
3786 run_test 31l "link to file: target dir has trailing slash"
3792 touch $DIR/d31m2/exist
3793 link $DIR/d31m/s $DIR/d31m2/t || error "link"
3794 link $DIR/d31m/s $DIR/d31m2/exist && error "link to exist file"
3795 link $DIR/d31m/s $DIR/d31m2 && error "link to parent dir"
3796 link $DIR/d31m2 $DIR/d31m/s && error "link parent dir to target"
3797 link $DIR/d31m/not-exist $DIR/d31m2/foo && error "link non-existing to new"
3798 link $DIR/d31m/not-exist $DIR/d31m2/s && error "link non-existing to exist"
3801 run_test 31m "link to file: the same, non-existing, dir"
3804 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3805 nlink=$(stat --format=%h $DIR/$tfile)
3806 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3808 local cmd="exec $fd<$DIR/$tfile"
3811 trap "eval $cmd" EXIT
3812 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3813 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3814 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3815 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3816 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3819 run_test 31n "check link count of unlinked file"
3822 local tempfile=$(mktemp $1_XXXXXX)
3823 link $tempfile $1 2> /dev/null &&
3824 echo "$BASHPID: link $tempfile to $1 succeeded"
3828 test_31o() { # LU-2901
3829 test_mkdir $DIR/$tdir
3830 for LOOP in $(seq 100); do
3831 rm -f $DIR/$tdir/$tfile*
3832 for THREAD in $(seq 8); do
3833 link_one $DIR/$tdir/$tfile.$LOOP &
3836 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3837 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3838 error "$LINKS duplicate links to $tfile.$LOOP" &&
3842 run_test 31o "duplicate hard links with same filename"
3845 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3847 test_mkdir $DIR/$tdir
3848 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3849 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3851 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3852 error "open unlink test1 failed"
3853 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3854 error "open unlink test2 failed"
3856 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3857 error "test1 still exists"
3858 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3859 error "test2 still exists"
3861 run_test 31p "remove of open striped directory"
3864 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3866 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3867 index=$($LFS getdirstripe -i $DIR/$tdir)
3868 [ $index -eq 3 ] || error "first stripe index $index != 3"
3869 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3870 [ $index -eq 1 ] || error "second stripe index $index != 1"
3872 # when "-c <stripe_count>" is set, the number of MDTs specified after
3873 # "-i" should equal to the stripe count
3874 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3876 run_test 31q "create striped directory on specific MDTs"
3880 touch $DIR/$tfile.target
3881 touch $DIR/$tfile.source
3883 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
3884 $LCTL set_param fail_loc=0x1419 fail_val=3
3885 cat $DIR/$tfile.target &
3888 # Guarantee open is waiting before we get here
3890 mv $DIR/$tfile.source $DIR/$tfile.target
3894 if [[ $RC -ne 0 ]]; then
3895 error "open with cat failed, rc=$RC"
3898 run_test 31r "open-rename(replace) race"
3900 cleanup_test32_mount() {
3903 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3904 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3905 losetup -d $loopdev || true
3911 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3913 echo "== more mountpoints and symlinks ================="
3914 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3915 trap cleanup_test32_mount EXIT
3916 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3917 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3918 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3919 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3920 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3921 cleanup_test32_mount
3923 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3926 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3928 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3929 trap cleanup_test32_mount EXIT
3930 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3931 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3932 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3933 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3934 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3935 cleanup_test32_mount
3937 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3940 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3942 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3943 trap cleanup_test32_mount EXIT
3944 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3945 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3946 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3947 test_mkdir -p $DIR/$tdir/d2/test_dir
3948 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3949 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3950 cleanup_test32_mount
3952 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3955 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3957 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3958 trap cleanup_test32_mount EXIT
3959 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3960 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3961 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3962 test_mkdir -p $DIR/$tdir/d2/test_dir
3963 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3964 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3965 cleanup_test32_mount
3967 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3971 test_mkdir -p $DIR/$tdir/tmp
3972 local tmp_dir=$DIR/$tdir/tmp
3973 ln -s $DIR/$tdir $tmp_dir/symlink11
3974 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3975 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3976 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3978 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3982 test_mkdir -p $DIR/$tdir/tmp
3983 local tmp_dir=$DIR/$tdir/tmp
3984 ln -s $DIR/$tdir $tmp_dir/symlink11
3985 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3986 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3987 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3989 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3992 local tmp_dir=$DIR/$tdir/tmp
3993 test_mkdir -p $tmp_dir
3994 test_mkdir $DIR/${tdir}2
3995 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3996 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3997 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3998 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3999 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
4000 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
4002 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
4005 rm -fr $DIR/$tdir $DIR/${tdir}2
4006 tmp_dir=$DIR/$tdir/tmp
4007 test_mkdir -p $tmp_dir
4008 test_mkdir $DIR/${tdir}2
4009 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
4010 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
4011 ls $tmp_dir/symlink12 || error "listing symlink12"
4012 ls $DIR/$tdir/symlink02 || error "listing symlink02"
4014 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
4017 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4019 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4020 trap cleanup_test32_mount EXIT
4021 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4022 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4023 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4024 touch $DIR/$tdir/test_file
4025 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
4026 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
4027 cleanup_test32_mount
4029 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
4032 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4034 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4035 trap cleanup_test32_mount EXIT
4036 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4037 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4038 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4039 touch $DIR/$tdir/test_file
4040 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
4041 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
4042 cleanup_test32_mount
4044 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
4047 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4050 trap cleanup_test32_mount EXIT
4051 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4052 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4053 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4054 test_mkdir -p $DIR/$tdir/d2
4055 touch $DIR/$tdir/d2/test_file || error "touch failed"
4056 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
4057 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
4058 cleanup_test32_mount
4060 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
4063 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4066 trap cleanup_test32_mount EXIT
4067 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4068 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4069 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4070 test_mkdir -p $DIR/$tdir/d2
4071 touch $DIR/$tdir/d2/test_file || error "touch failed"
4072 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
4073 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
4074 cleanup_test32_mount
4076 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
4080 test_mkdir -p $DIR/d32m/tmp
4081 TMP_DIR=$DIR/d32m/tmp
4082 ln -s $DIR $TMP_DIR/symlink11
4083 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
4084 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
4085 error "symlink11 not a link"
4086 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
4087 error "symlink01 not a link"
4089 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
4093 test_mkdir -p $DIR/d32n/tmp
4094 TMP_DIR=$DIR/d32n/tmp
4095 ln -s $DIR $TMP_DIR/symlink11
4096 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
4097 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
4098 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
4100 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
4104 test_mkdir -p $DIR/d32o/tmp
4105 TMP_DIR=$DIR/d32o/tmp
4106 ln -s $DIR/$tfile $TMP_DIR/symlink12
4107 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4108 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
4109 error "symlink12 not a link"
4110 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
4111 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
4112 error "$DIR/d32o/tmp/symlink12 not file type"
4113 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
4114 error "$DIR/d32o/symlink02 not file type"
4116 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
4126 test_mkdir -p $DIR/d32p/tmp
4128 TMP_DIR=$DIR/d32p/tmp
4130 ln -s $DIR/$tfile $TMP_DIR/symlink12
4132 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4134 cat $DIR/d32p/tmp/symlink12 ||
4135 error "Can't open $DIR/d32p/tmp/symlink12"
4137 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
4140 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
4143 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4145 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4146 trap cleanup_test32_mount EXIT
4147 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4148 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4149 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4150 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4151 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
4152 cleanup_test32_mount
4154 run_test 32q "stat follows mountpoints in Lustre (should return error)"
4157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4159 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4160 trap cleanup_test32_mount EXIT
4161 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4162 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4163 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4164 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4165 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
4166 cleanup_test32_mount
4168 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
4173 chmod 444 $DIR/$tfile
4174 chown $RUNAS_ID $DIR/$tfile
4176 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4179 run_test 33aa "write file with mode 444 (should return error)"
4183 test_mkdir $DIR/$tdir
4184 chown $RUNAS_ID $DIR/$tdir
4185 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
4186 error "$RUNAS create $tdir/$tfile failed"
4187 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4188 error "open RDWR" || true
4190 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4194 test_mkdir $DIR/$tdir
4195 chown $RUNAS_ID $DIR/$tdir
4196 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4198 run_test 33b "test open file with malformed flags (No panic)"
4201 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4202 remote_ost_nodsh && skip "remote OST with nodsh"
4210 test_mkdir $DIR/$tdir
4211 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4214 for ostnum in $(seq $OSTCOUNT); do
4215 # test-framework's OST numbering is one-based, while Lustre's
4217 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4218 # check if at least some write_bytes stats are counted
4219 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4220 obdfilter.$ostname.stats |
4221 awk '/^write_bytes/ {print $7}' )
4222 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4223 if (( ${write_bytes:-0} > 0 )); then
4229 $all_zeros || return 0
4232 echo foo > $DIR/$tdir/bar
4236 # Total up write_bytes after writing. We'd better find non-zeros.
4237 for ostnum in $(seq $OSTCOUNT); do
4238 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4239 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4240 obdfilter/$ostname/stats |
4241 awk '/^write_bytes/ {print $7}' )
4242 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4243 if (( ${write_bytes:-0} > 0 )); then
4250 for ostnum in $(seq $OSTCOUNT); do
4251 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4252 echo "Check write_bytes is in obdfilter.*.stats:"
4253 do_facet ost$ostnum lctl get_param -n \
4254 obdfilter.$ostname.stats
4256 error "OST not keeping write_bytes stats (b=22312)"
4259 run_test 33c "test write_bytes stats"
4262 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4263 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4266 local remote_dir=$DIR/$tdir/remote_dir
4268 test_mkdir $DIR/$tdir
4269 $LFS mkdir -i $MDTIDX $remote_dir ||
4270 error "create remote directory failed"
4272 touch $remote_dir/$tfile
4273 chmod 444 $remote_dir/$tfile
4274 chown $RUNAS_ID $remote_dir/$tfile
4276 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4278 chown $RUNAS_ID $remote_dir
4279 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4280 error "create" || true
4281 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4282 error "open RDWR" || true
4283 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4285 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4288 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4292 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4293 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4294 mkdir $DIR/$tdir/local_dir
4296 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4297 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4298 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4300 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4301 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4303 rmdir $DIR/$tdir/* || error "rmdir failed"
4306 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4307 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4308 mkdir $DIR/$tdir/local_dir
4310 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4311 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4312 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4314 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4315 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4317 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4320 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4321 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4322 mkdir $DIR/$tdir/local_dir
4324 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4325 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4326 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4328 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4329 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4331 run_test 33e "mkdir and striped directory should have same mode"
4335 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4339 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4340 remote_mds_nodsh && skip "remote MDS with nodsh"
4343 chmod go+rwx $DIR/$tdir
4344 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4345 trap cleanup_33f EXIT
4347 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4348 error "cannot create striped directory"
4350 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4351 error "cannot create files in striped directory"
4353 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4354 error "cannot remove files in striped directory"
4356 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4357 error "cannot remove striped directory"
4361 run_test 33f "nonroot user can create, access, and remove a striped directory"
4364 mkdir -p $DIR/$tdir/dir2
4366 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4368 [[ $err =~ "exists" ]] || error "Not exists error"
4370 run_test 33g "nonroot user create already existing root created file"
4376 test_mkdir -c $MDSCOUNT -H $hash_type $DIR/$tdir ||
4377 error "lfs mkdir -H $hash_type $tdir failed"
4378 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4380 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4384 for fname in $DIR/$tdir/$tfile.bak \
4385 $DIR/$tdir/$tfile.SAV \
4386 $DIR/$tdir/$tfile.orig \
4387 $DIR/$tdir/$tfile~; do
4388 touch $fname || error "touch $fname failed"
4389 index2=$($LFS getstripe -m $fname)
4390 (( $index == $index2 )) ||
4391 error "$fname MDT index mismatch $index != $index2"
4395 local patterns=(".$tfile.XXXXXX" "$tfile.XXXXXXXX")
4398 for pattern in ${patterns[*]}; do
4399 echo "pattern $pattern"
4400 fname=$DIR/$tdir/$pattern
4401 for (( i = 0; i < $count; i++ )); do
4402 fname=$(mktemp $DIR/$tdir/$pattern) ||
4403 error "mktemp $DIR/$tdir/$pattern failed"
4404 index2=$($LFS getstripe -m $fname)
4405 (( $index == $index2 )) && continue
4407 failed=$((failed + 1))
4408 echo "$fname MDT index mismatch $index != $index2"
4412 echo "$failed/$count MDT index mismatches, expect ~2-4"
4413 (( failed < 10 )) || error "MDT index mismatch $failed/$count times"
4418 # verify that "crush" is still broken with all files on same MDT,
4419 # crush2 should have about 1/MDSCOUNT files on each MDT, with margin
4420 [[ "$hash_type" == "crush" ]] && expect=$count ||
4421 expect=$((count / MDSCOUNT))
4423 # crush2 doesn't put all-numeric suffixes on the same MDT,
4424 # filename like $tfile.12345678 should *not* be considered temp
4425 for pattern in ${patterns[*]}; do
4426 local base=${pattern%%X*}
4427 local suff=${pattern#$base}
4429 echo "pattern $pattern"
4430 for (( i = 0; i < $count; i++ )); do
4431 fname=$DIR/$tdir/$base$((${suff//X/1} + i))
4432 touch $fname || error "touch $fname failed"
4433 index2=$($LFS getstripe -m $fname)
4434 (( $index != $index2 )) && continue
4440 # the number of "bad" hashes is random, as it depends on the random
4441 # filenames generated by "mktemp". Allow some margin in the results.
4442 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4443 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4444 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4445 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4448 # crush2 doesn't put suffixes with special characters on the same MDT
4449 # filename like $tfile.txt.1234 should *not* be considered temp
4450 for pattern in ${patterns[*]}; do
4451 local base=${pattern%%X*}
4452 local suff=${pattern#$base}
4454 pattern=$base...${suff/XXX}
4455 echo "pattern=$pattern"
4456 for (( i = 0; i < $count; i++ )); do
4457 fname=$(mktemp $DIR/$tdir/$pattern) ||
4458 error "touch $fname failed"
4459 index2=$($LFS getstripe -m $fname)
4460 (( $index != $index2 )) && continue
4466 # the number of "bad" hashes is random, as it depends on the random
4467 # filenames generated by "mktemp". Allow some margin in the results.
4468 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4469 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4470 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4471 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4475 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4476 (( $MDS1_VERSION >= $(version_code 2.13.50) )) ||
4477 skip "Need MDS version at least 2.13.50"
4481 run_test 33h "temp file is located on the same MDT as target (crush)"
4484 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4485 echo "MDS1_VERSION=$MDS1_VERSION version_code=$(version_code 2.15.0)"
4486 (( $MDS1_VERSION > $(version_code 2.15.0) )) ||
4487 skip "Need MDS version at least 2.15.0 for crush2"
4491 run_test 33hh "temp file is located on the same MDT as target (crush2)"
4495 (( MDSCOUNT < 2 )) && skip "needs >= 2 MDTs"
4497 local FNAME=$(str_repeat 'f' 250)
4499 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
4500 createmany -o $DIR/$tdir/$FNAME 1000 || error "createmany failed"
4505 count=$($LFS getstripe -m $DIR/$tdir/* | grep -cw 1)
4507 local MDC=$(lctl dl | awk '/MDT0001-mdc-[^M]/ { print $4 }')
4509 lctl --device %$MDC deactivate
4510 stack_trap "lctl --device %$MDC activate"
4511 ls $DIR/$tdir > /dev/null && error "ls should return an error"
4512 total=$(\ls -l $DIR/$tdir | wc -l)
4513 # "ls -l" will list total in the first line
4514 total=$((total - 1))
4515 (( total + count == 1000 )) ||
4516 error "ls list $total files, $count files on MDT1"
4518 run_test 33i "striped directory can be accessed when one MDT is down"
4521 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4523 mkdir -p $DIR/$tdir/
4525 $LFS setdirstripe -D -i0,1 $DIR/$tdir/striped_dir_a &&
4526 error "setdirstripe -D -i0,1 incorrectly succeeded"
4528 $LFS setdirstripe -D -i0,1 -c1 $DIR/$tdir/striped_dir_b &&
4529 error "setdirstripe -D -i0,1 -c1 incorrectly succeeded"
4531 $LFS setdirstripe -D -i0,1 -c3 $DIR/$tdir/striped_dir_c &&
4532 error "setdirstripe -D -i0,1 -c3 incorrectly succeeded"
4534 $LFS setdirstripe -i0,1 $DIR/$tdir/striped_dir_e ||
4535 error "-D was not specified, but still failed"
4537 run_test 33j "lfs setdirstripe -D -i x,y,x should fail"
4539 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4542 $MCREATE $DIR/f34 || error "mcreate failed"
4543 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4544 error "getstripe failed"
4545 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4546 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4547 error "getstripe failed"
4548 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4549 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4551 run_test 34a "truncate file that has not been opened ==========="
4554 [ ! -f $DIR/f34 ] && test_34a
4555 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4556 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4557 $OPENFILE -f O_RDONLY $DIR/f34
4558 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4559 error "getstripe failed"
4560 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4561 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4563 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4566 [ ! -f $DIR/f34 ] && test_34a
4567 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4568 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4569 $OPENFILE -f O_RDWR $DIR/f34
4570 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4571 error "$LFS getstripe failed"
4572 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4573 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4575 run_test 34c "O_RDWR opening file-with-size works =============="
4578 [ ! -f $DIR/f34 ] && test_34a
4579 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4581 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4582 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4585 run_test 34d "write to sparse file ============================="
4589 $MCREATE $DIR/f34e || error "mcreate failed"
4590 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4591 $CHECKSTAT -s 1000 $DIR/f34e ||
4592 error "Size of $DIR/f34e not equal to 1000 bytes"
4593 $OPENFILE -f O_RDWR $DIR/f34e
4594 $CHECKSTAT -s 1000 $DIR/f34e ||
4595 error "Size of $DIR/f34e not equal to 1000 bytes"
4597 run_test 34e "create objects, some with size and some without =="
4599 test_34f() { # bug 6242, 6243
4600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4604 $MCREATE $DIR/f34f || error "mcreate failed"
4605 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4606 dd if=$DIR/f34f of=$TMP/f34f
4607 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4608 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4609 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4610 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4611 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4613 run_test 34f "read from a file with no objects until EOF ======="
4616 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4618 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4620 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4621 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4622 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4623 cancel_lru_locks osc
4624 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4625 error "wrong size after lock cancel"
4627 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4628 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4629 error "expanding truncate failed"
4630 cancel_lru_locks osc
4631 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4632 error "wrong expanded size after lock cancel"
4634 run_test 34g "truncate long file ==============================="
4637 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4642 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4643 sync # Flush the cache so that multiop below does not block on cache
4644 # flush when getting the group lock
4645 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4648 # Since just timed wait is not good enough, let's do a sync write
4649 # that way we are sure enough time for a roundtrip + processing
4650 # passed + 2 seconds of extra margin.
4651 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4655 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4656 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4660 local nsz=`stat -c %s $DIR/$tfile`
4661 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4663 run_test 34h "ftruncate file under grouplock should not block"
4666 cp /bin/sh $DIR/f35a
4668 chown $RUNAS_ID $DIR/f35a
4669 $RUNAS $DIR/f35a && error || true
4672 run_test 35a "exec file with mode 444 (should return and not leak)"
4676 utime $DIR/f36 || error "utime failed for MDS"
4678 run_test 36a "MDS utime check (mknod, utime)"
4682 utime $DIR/f36 || error "utime failed for OST"
4684 run_test 36b "OST utime check (open, utime)"
4689 chown $RUNAS_ID $DIR/d36
4690 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4692 run_test 36c "non-root MDS utime check (mknod, utime)"
4695 [ ! -d $DIR/d36 ] && test_36c
4696 echo "" > $DIR/d36/f36
4697 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4699 run_test 36d "non-root OST utime check (open, utime)"
4702 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4704 test_mkdir $DIR/$tdir
4705 touch $DIR/$tdir/$tfile
4706 $RUNAS utime $DIR/$tdir/$tfile &&
4707 error "utime worked, expected failure" || true
4709 run_test 36e "utime on non-owned file (should return error)"
4713 local LANG_SAVE=$LANG
4714 local LC_LANG_SAVE=$LC_LANG
4715 export LANG=C LC_LANG=C # for date language
4717 DATESTR="Dec 20 2000"
4718 test_mkdir $DIR/$tdir
4719 lctl set_param fail_loc=$fl
4721 cp /etc/hosts $DIR/$tdir/$tfile
4722 sync & # write RPC generated with "current" inode timestamp, but delayed
4724 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4725 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4726 cancel_lru_locks $OSC
4727 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4729 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4730 echo "BEFORE: $LS_BEFORE" && \
4731 echo "AFTER : $LS_AFTER" && \
4732 echo "WANT : $DATESTR" && \
4733 error "$DIR/$tdir/$tfile timestamps changed" || true
4735 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4739 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4741 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4742 subr_36fh "0x80000214"
4744 run_test 36f "utime on file racing with OST BRW write =========="
4747 remote_ost_nodsh && skip "remote OST with nodsh"
4748 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4749 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4750 skip "Need MDS version at least 2.12.51"
4755 local tgt="obdfilter"
4757 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4759 test_mkdir $DIR/$tdir
4760 fmd_max_age=$(do_facet $facet \
4761 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4764 echo "FMD max age: ${fmd_max_age}s"
4765 touch $DIR/$tdir/$tfile
4766 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4767 gawk '{cnt=cnt+$1} END{print cnt}')
4768 echo "FMD before: $fmd"
4770 error "FMD wasn't create by touch"
4771 sleep $((fmd_max_age + 12))
4772 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4773 gawk '{cnt=cnt+$1} END{print cnt}')
4774 echo "FMD after: $fmd"
4776 error "FMD wasn't expired by ping"
4778 run_test 36g "FMD cache expiry ====================="
4781 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4783 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4784 subr_36fh "0x80000227"
4786 run_test 36h "utime on file racing with OST BRW write =========="
4789 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4791 test_mkdir $DIR/$tdir
4792 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4794 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4795 local new_mtime=$((mtime + 200))
4797 #change Modify time of striped dir
4798 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4799 error "change mtime failed"
4801 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4803 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4805 run_test 36i "change mtime on striped directory"
4807 # test_37 - duplicate with tests 32q 32r
4810 local file=$DIR/$tfile
4812 openfile -f O_DIRECTORY $file
4815 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4816 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4818 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4820 test_39a() { # was test_39
4822 touch $DIR/${tfile}2
4823 # ls -l $DIR/$tfile $DIR/${tfile}2
4824 # ls -lu $DIR/$tfile $DIR/${tfile}2
4825 # ls -lc $DIR/$tfile $DIR/${tfile}2
4827 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4828 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4830 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4832 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4834 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4835 error "O_TRUNC didn't change timestamps"
4838 run_test 39a "mtime changed on create"
4841 test_mkdir -c1 $DIR/$tdir
4842 cp -p /etc/passwd $DIR/$tdir/fopen
4843 cp -p /etc/passwd $DIR/$tdir/flink
4844 cp -p /etc/passwd $DIR/$tdir/funlink
4845 cp -p /etc/passwd $DIR/$tdir/frename
4846 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4849 echo "aaaaaa" >> $DIR/$tdir/fopen
4850 echo "aaaaaa" >> $DIR/$tdir/flink
4851 echo "aaaaaa" >> $DIR/$tdir/funlink
4852 echo "aaaaaa" >> $DIR/$tdir/frename
4854 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4855 local link_new=`stat -c %Y $DIR/$tdir/flink`
4856 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4857 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4859 cat $DIR/$tdir/fopen > /dev/null
4860 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4861 rm -f $DIR/$tdir/funlink2
4862 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4864 for (( i=0; i < 2; i++ )) ; do
4865 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4866 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4867 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4868 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4870 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4871 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4872 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4873 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4875 cancel_lru_locks $OSC
4876 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4879 run_test 39b "mtime change on open, link, unlink, rename ======"
4881 # this should be set to past
4882 TEST_39_MTIME=`date -d "1 year ago" +%s`
4888 local mtime0=`stat -c %Y $DIR1/$tfile`
4890 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4891 local mtime1=`stat -c %Y $DIR1/$tfile`
4892 [ "$mtime1" = $TEST_39_MTIME ] || \
4893 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4896 echo hello >> $DIR1/$tfile
4898 local mtime2=`stat -c %Y $DIR1/$tfile`
4899 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4900 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4902 mv $DIR1/$tfile $DIR1/$tfile-1
4904 for (( i=0; i < 2; i++ )) ; do
4905 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4906 [ "$mtime2" = "$mtime3" ] || \
4907 error "mtime ($mtime2) changed (to $mtime3) on rename"
4909 cancel_lru_locks $OSC
4910 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4913 run_test 39c "mtime change on rename ==========================="
4917 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4920 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4922 for (( i=0; i < 2; i++ )) ; do
4923 local mtime=`stat -c %Y $DIR1/$tfile`
4924 [ $mtime = $TEST_39_MTIME ] || \
4925 error "mtime($mtime) is not set to $TEST_39_MTIME"
4927 cancel_lru_locks $OSC
4928 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4931 run_test 39d "create, utime, stat =============================="
4935 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4938 local mtime1=`stat -c %Y $DIR1/$tfile`
4940 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4942 for (( i=0; i < 2; i++ )) ; do
4943 local mtime2=`stat -c %Y $DIR1/$tfile`
4944 [ $mtime2 = $TEST_39_MTIME ] || \
4945 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4947 cancel_lru_locks $OSC
4948 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4951 run_test 39e "create, stat, utime, stat ========================"
4955 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4958 mtime1=`stat -c %Y $DIR1/$tfile`
4961 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4963 for (( i=0; i < 2; i++ )) ; do
4964 local mtime2=`stat -c %Y $DIR1/$tfile`
4965 [ $mtime2 = $TEST_39_MTIME ] || \
4966 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4968 cancel_lru_locks $OSC
4969 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4972 run_test 39f "create, stat, sleep, utime, stat ================="
4976 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4978 echo hello >> $DIR1/$tfile
4979 local mtime1=`stat -c %Y $DIR1/$tfile`
4982 chmod o+r $DIR1/$tfile
4984 for (( i=0; i < 2; i++ )) ; do
4985 local mtime2=`stat -c %Y $DIR1/$tfile`
4986 [ "$mtime1" = "$mtime2" ] || \
4987 error "lost mtime: $mtime2, should be $mtime1"
4989 cancel_lru_locks $OSC
4990 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4993 run_test 39g "write, chmod, stat ==============================="
4997 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5003 echo hello >> $DIR1/$tfile
5004 local mtime1=`stat -c %Y $DIR1/$tfile`
5006 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
5008 if [ "$d1" != "$d2" ]; then
5009 echo "write and touch not within one second"
5011 for (( i=0; i < 2; i++ )) ; do
5012 local mtime2=`stat -c %Y $DIR1/$tfile`
5013 [ "$mtime2" = $TEST_39_MTIME ] || \
5014 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
5016 cancel_lru_locks $OSC
5017 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5021 run_test 39h "write, utime within one second, stat ============="
5024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5029 echo hello >> $DIR1/$tfile
5030 local mtime1=`stat -c %Y $DIR1/$tfile`
5032 mv $DIR1/$tfile $DIR1/$tfile-1
5034 for (( i=0; i < 2; i++ )) ; do
5035 local mtime2=`stat -c %Y $DIR1/$tfile-1`
5037 [ "$mtime1" = "$mtime2" ] || \
5038 error "lost mtime: $mtime2, should be $mtime1"
5040 cancel_lru_locks $OSC
5041 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5044 run_test 39i "write, rename, stat =============================="
5047 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5049 start_full_debug_logging
5053 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
5054 lctl set_param fail_loc=0x80000412
5055 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
5056 error "multiop failed"
5058 local mtime1=`stat -c %Y $DIR1/$tfile`
5060 mv $DIR1/$tfile $DIR1/$tfile-1
5062 kill -USR1 $multipid
5063 wait $multipid || error "multiop close failed"
5065 for (( i=0; i < 2; i++ )) ; do
5066 local mtime2=`stat -c %Y $DIR1/$tfile-1`
5067 [ "$mtime1" = "$mtime2" ] ||
5068 error "mtime is lost on close: $mtime2, " \
5072 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5074 lctl set_param fail_loc=0
5075 stop_full_debug_logging
5077 run_test 39j "write, rename, close, stat ======================="
5080 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5085 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
5087 local mtime1=`stat -c %Y $DIR1/$tfile`
5089 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
5091 kill -USR1 $multipid
5092 wait $multipid || error "multiop close failed"
5094 for (( i=0; i < 2; i++ )) ; do
5095 local mtime2=`stat -c %Y $DIR1/$tfile`
5097 [ "$mtime2" = $TEST_39_MTIME ] || \
5098 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
5101 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5104 run_test 39k "write, utime, close, stat ========================"
5106 # this should be set to future
5107 TEST_39_ATIME=`date -d "1 year" +%s`
5110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5111 remote_mds_nodsh && skip "remote MDS with nodsh"
5113 local atime_diff=$(do_facet $SINGLEMDS \
5114 lctl get_param -n mdd.*MDT0000*.atime_diff)
5116 mkdir_on_mdt0 $DIR/$tdir
5118 # test setting directory atime to future
5119 touch -a -d @$TEST_39_ATIME $DIR/$tdir
5120 local atime=$(stat -c %X $DIR/$tdir)
5121 [ "$atime" = $TEST_39_ATIME ] ||
5122 error "atime is not set to future: $atime, $TEST_39_ATIME"
5124 # test setting directory atime from future to now
5125 local now=$(date +%s)
5126 touch -a -d @$now $DIR/$tdir
5128 atime=$(stat -c %X $DIR/$tdir)
5129 [ "$atime" -eq "$now" ] ||
5130 error "atime is not updated from future: $atime, $now"
5132 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
5135 # test setting directory atime when now > dir atime + atime_diff
5136 local d1=$(date +%s)
5138 local d2=$(date +%s)
5139 cancel_lru_locks mdc
5140 atime=$(stat -c %X $DIR/$tdir)
5141 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5142 error "atime is not updated : $atime, should be $d2"
5144 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
5147 # test not setting directory atime when now < dir atime + atime_diff
5149 cancel_lru_locks mdc
5150 atime=$(stat -c %X $DIR/$tdir)
5151 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5152 error "atime is updated to $atime, should remain $d1<atime<$d2"
5154 do_facet $SINGLEMDS \
5155 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5157 run_test 39l "directory atime update ==========================="
5160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5164 local far_past_mtime=$(date -d "May 29 1953" +%s)
5165 local far_past_atime=$(date -d "Dec 17 1903" +%s)
5167 touch -m -d @$far_past_mtime $DIR1/$tfile
5168 touch -a -d @$far_past_atime $DIR1/$tfile
5170 for (( i=0; i < 2; i++ )) ; do
5171 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
5172 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
5173 error "atime or mtime set incorrectly"
5175 cancel_lru_locks $OSC
5176 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5179 run_test 39m "test atime and mtime before 1970"
5181 test_39n() { # LU-3832
5182 remote_mds_nodsh && skip "remote MDS with nodsh"
5184 local atime_diff=$(do_facet $SINGLEMDS \
5185 lctl get_param -n mdd.*MDT0000*.atime_diff)
5190 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
5193 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
5194 atime0=$(stat -c %X $DIR/$tfile)
5197 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5198 atime1=$(stat -c %X $DIR/$tfile)
5201 cancel_lru_locks mdc
5202 cancel_lru_locks osc
5203 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5204 atime2=$(stat -c %X $DIR/$tfile)
5206 do_facet $SINGLEMDS \
5207 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5209 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
5210 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
5212 run_test 39n "check that O_NOATIME is honored"
5215 TESTDIR=$DIR/$tdir/$tfile
5216 [ -e $TESTDIR ] && rm -rf $TESTDIR
5223 links2=$(stat -c %h .)
5224 [ $(($links1 + 2)) != $links2 ] &&
5225 error "wrong links count $(($links1 + 2)) != $links2"
5227 links3=$(stat -c %h .)
5228 [ $(($links1 + 1)) != $links3 ] &&
5229 error "wrong links count $links1 != $links3"
5232 run_test 39o "directory cached attributes updated after create"
5235 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
5238 TESTDIR=$DIR/$tdir/$tdir
5239 [ -e $TESTDIR ] && rm -rf $TESTDIR
5240 test_mkdir -p $TESTDIR
5244 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
5245 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
5247 links2=$(stat -c %h .)
5248 [ $(($links1 + 2)) != $links2 ] &&
5249 error "wrong links count $(($links1 + 2)) != $links2"
5251 links3=$(stat -c %h .)
5252 [ $(($links1 + 1)) != $links3 ] &&
5253 error "wrong links count $links1 != $links3"
5256 run_test 39p "remote directory cached attributes updated after create ========"
5259 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
5260 skip "no atime update on old OST"
5261 if [ "$ost1_FSTYPE" != ldiskfs ]; then
5262 skip_env "ldiskfs only test"
5266 saved_adiff=$(do_facet ost1 \
5267 lctl get_param -n obdfilter.*OST0000.atime_diff)
5268 stack_trap "do_facet ost1 \
5269 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
5271 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
5273 $LFS setstripe -i 0 $DIR/$tfile
5274 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
5275 error "can't write initial file"
5276 cancel_lru_locks osc
5278 # exceed atime_diff and access file
5280 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
5281 error "can't udpate atime"
5283 local atime_cli=$(stat -c %X $DIR/$tfile)
5284 echo "client atime: $atime_cli"
5285 # allow atime update to be written to device
5286 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
5289 local ostdev=$(ostdevname 1)
5290 local fid=($($LFS getstripe $DIR/$tfile | grep 0x))
5291 local seq=${fid[3]#0x}
5295 if [ $seq == 0 ]; then
5298 oid_hex=${fid[2]#0x}
5300 local objpath="O/$seq/d$(($oid % 32))/$oid_hex"
5301 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
5303 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
5304 local atime_ost=$(do_facet ost1 "$cmd" |&
5305 awk -F'[: ]' '/atime:/ { print $4 }')
5306 (( atime_cli == atime_ost )) ||
5307 error "atime on client $atime_cli != ost $atime_ost"
5309 run_test 39r "lazy atime update on OST"
5311 test_39q() { # LU-8041
5312 local testdir=$DIR/$tdir
5314 multiop_bg_pause $testdir D_c || error "multiop failed"
5316 cancel_lru_locks mdc
5317 kill -USR1 $multipid
5318 local atime=$(stat -c %X $testdir)
5319 [ "$atime" -ne 0 ] || error "atime is zero"
5321 run_test 39q "close won't zero out atime"
5330 umount_client $MOUNT
5331 mount_client $MOUNT relatime
5333 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer conv=fsync
5334 atime0=$(stat -c %X $DIR/$tfile)
5336 # First read updates atime
5338 cat $DIR/$tfile >/dev/null
5339 atime1=$(stat -c %X $DIR/$tfile) # (atime = atime0 + 1)
5341 # Next reads do not update atime
5343 cat $DIR/$tfile >/dev/null
5344 atime2=$(stat -c %X $DIR/$tfile) # (atime = atime0 + 1)
5346 # If mtime is greater than atime, atime is updated
5348 touch -m $DIR/$tfile # (mtime = now)
5350 cat $DIR/$tfile >/dev/null # (atime is updated because atime < mtime)
5351 atime3=$(stat -c %X $DIR/$tfile) # (atime = mtime = atime0 + 3)
5353 # Next reads do not update atime
5355 cat $DIR/$tfile >/dev/null
5356 atime4=$(stat -c %X $DIR/$tfile)
5358 # Remount the client to clear 'relatime' option
5359 remount_client $MOUNT
5361 (( atime0 < atime1 )) ||
5362 error "atime $atime0 should be smaller than $atime1"
5363 (( atime1 == atime2 )) ||
5364 error "atime $atime1 was updated to $atime2"
5365 (( atime1 < atime3 )) || error "atime1 $atime1 != atime3 $atime3"
5366 (( atime3 == atime4 )) || error "atime3 $atime3 != atime4 $atime4"
5368 run_test 39s "relatime is supported"
5371 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5372 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5373 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5374 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5375 error "$tfile is not 4096 bytes in size"
5377 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5381 small_write $DIR/f41 18
5383 run_test 41 "test small file write + fstat ====================="
5385 count_ost_writes() {
5386 lctl get_param -n ${OSC}.*.stats |
5387 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5388 END { printf("%0.0f", writes) }'
5395 BG_DIRTY_RATIO_SAVE=10
5396 MAX_BG_DIRTY_RATIO=25
5400 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5401 # dirty_ratio, dirty_background_ratio
5402 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5403 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5404 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5405 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5407 # if file not here, we are a 2.4 kernel
5408 kill -CONT `pidof kupdated`
5413 # setup the trap first, so someone cannot exit the test at the
5414 # exact wrong time and mess up a machine
5415 trap start_writeback EXIT
5416 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5417 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5418 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5419 sysctl -w vm.dirty_writeback_centisecs=0
5420 sysctl -w vm.dirty_writeback_centisecs=0
5421 # save and increase /proc/sys/vm/dirty_ratio
5422 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5423 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5424 # save and increase /proc/sys/vm/dirty_background_ratio
5425 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5426 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5428 # if file not here, we are a 2.4 kernel
5429 kill -STOP `pidof kupdated`
5433 # ensure that all stripes have some grant before we test client-side cache
5435 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5436 dd if=/dev/zero of=$i bs=4k count=1
5441 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5442 # file truncation, and file removal.
5444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5447 cancel_lru_locks $OSC
5449 sync; sleep 1; sync # just to be safe
5450 BEFOREWRITES=`count_ost_writes`
5451 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5452 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5453 AFTERWRITES=`count_ost_writes`
5454 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5455 error "$BEFOREWRITES < $AFTERWRITES"
5458 run_test 42a "ensure that we don't flush on close"
5461 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5464 cancel_lru_locks $OSC
5467 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5468 BEFOREWRITES=$(count_ost_writes)
5469 unlink $DIR/f42b || error "unlink $DIR/f42b: $?"
5470 AFTERWRITES=$(count_ost_writes)
5471 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5472 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5474 BEFOREWRITES=$(count_ost_writes)
5475 sync || error "sync: $?"
5476 AFTERWRITES=$(count_ost_writes)
5477 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5478 error "$BEFOREWRITES < $AFTERWRITES on sync"
5480 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5484 run_test 42b "test destroy of file with cached dirty data ======"
5486 # if these tests just want to test the effect of truncation,
5487 # they have to be very careful. consider:
5488 # - the first open gets a {0,EOF}PR lock
5489 # - the first write conflicts and gets a {0, count-1}PW
5490 # - the rest of the writes are under {count,EOF}PW
5491 # - the open for truncate tries to match a {0,EOF}PR
5492 # for the filesize and cancels the PWs.
5493 # any number of fixes (don't get {0,EOF} on open, match
5494 # composite locks, do smarter file size management) fix
5495 # this, but for now we want these tests to verify that
5496 # the cancellation with truncate intent works, so we
5497 # start the file with a full-file pw lock to match against
5498 # until the truncate.
5503 cancel_lru_locks $OSC
5505 # prime the file with 0,EOF PW to match
5509 # now the real test..
5510 dd if=/dev/zero of=$file bs=1024 count=100
5511 BEFOREWRITES=`count_ost_writes`
5512 $TRUNCATE $file $offset
5513 cancel_lru_locks $OSC
5514 AFTERWRITES=`count_ost_writes`
5519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5522 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5523 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5526 run_test 42c "test partial truncate of file with cached dirty data"
5529 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5531 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
5532 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
5533 $LCTL set_param debug=+cache
5536 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5537 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5540 run_test 42d "test complete truncate of file with cached dirty data"
5542 test_42e() { # bug22074
5543 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5545 local TDIR=$DIR/${tdir}e
5546 local pages=16 # hardcoded 16 pages, don't change it.
5547 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5548 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5552 test_mkdir $DIR/${tdir}e
5553 $LFS setstripe -c 1 $TDIR
5554 createmany -o $TDIR/f $files
5556 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5558 # we assume that with $OSTCOUNT files, at least one of them will
5559 # be allocated on OST0.
5560 warmup_files=$((OSTCOUNT * max_dirty_mb))
5561 createmany -o $TDIR/w $warmup_files
5563 # write a large amount of data into one file and sync, to get good
5564 # avail_grant number from OST.
5565 for ((i=0; i<$warmup_files; i++)); do
5566 idx=$($LFS getstripe -i $TDIR/w$i)
5567 [ $idx -ne 0 ] && continue
5568 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5571 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5573 $LCTL get_param $proc_osc0/cur_dirty_bytes
5574 $LCTL get_param $proc_osc0/cur_grant_bytes
5576 # create as much dirty pages as we can while not to trigger the actual
5577 # RPCs directly. but depends on the env, VFS may trigger flush during this
5578 # period, hopefully we are good.
5579 for ((i=0; i<$warmup_files; i++)); do
5580 idx=$($LFS getstripe -i $TDIR/w$i)
5581 [ $idx -ne 0 ] && continue
5582 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5584 $LCTL get_param $proc_osc0/cur_dirty_bytes
5585 $LCTL get_param $proc_osc0/cur_grant_bytes
5587 # perform the real test
5588 $LCTL set_param $proc_osc0/rpc_stats 0
5589 for ((;i<$files; i++)); do
5590 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5591 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5594 $LCTL get_param $proc_osc0/rpc_stats
5597 local have_ppr=false
5598 $LCTL get_param $proc_osc0/rpc_stats |
5599 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5600 # skip lines until we are at the RPC histogram data
5601 [ "$PPR" == "pages" ] && have_ppr=true && continue
5602 $have_ppr || continue
5604 # we only want the percent stat for < 16 pages
5605 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5607 percent=$((percent + WPCT))
5608 if [[ $percent -gt 15 ]]; then
5609 error "less than 16-pages write RPCs" \
5616 run_test 42e "verify sub-RPC writes are not done synchronously"
5618 test_43A() { # was test_43
5619 test_mkdir $DIR/$tdir
5620 cp -p /bin/ls $DIR/$tdir/$tfile
5621 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5623 # give multiop a chance to open
5626 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5628 # Wait for multiop to exit
5631 run_test 43A "execution of file opened for write should return -ETXTBSY"
5634 test_mkdir $DIR/$tdir
5635 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5636 $DIR/$tdir/sleep 60 &
5638 # Make sure exec of $tdir/sleep wins race with truncate
5640 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5643 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5648 test_mkdir $DIR/$tdir
5649 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5650 $DIR/$tdir/sleep 60 &
5652 # Make sure exec of $tdir/sleep wins race with truncate
5654 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5657 run_test 43b "truncate of file being executed should return -ETXTBSY"
5660 local testdir="$DIR/$tdir"
5663 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5664 ( cd $testdir && md5sum -c )
5666 run_test 43c "md5sum of copy into lustre"
5668 test_44A() { # was test_44
5669 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5671 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5672 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5674 run_test 44A "zero length read from a sparse stripe"
5677 local nstripe=$($LFS getstripe -c -d $DIR)
5678 [ -z "$nstripe" ] && skip "can't get stripe info"
5679 [[ $nstripe -gt $OSTCOUNT ]] &&
5680 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5682 local stride=$($LFS getstripe -S -d $DIR)
5683 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5684 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5687 OFFSETS="0 $((stride/2)) $((stride-1))"
5688 for offset in $OFFSETS; do
5689 for i in $(seq 0 $((nstripe-1))); do
5690 local GLOBALOFFSETS=""
5692 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5693 local myfn=$DIR/d44a-$size
5694 echo "--------writing $myfn at $size"
5695 ll_sparseness_write $myfn $size ||
5696 error "ll_sparseness_write"
5697 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5698 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5699 error "ll_sparseness_verify $GLOBALOFFSETS"
5701 for j in $(seq 0 $((nstripe-1))); do
5703 size=$((((j + $nstripe )*$stride + $offset)))
5704 ll_sparseness_write $myfn $size ||
5705 error "ll_sparseness_write"
5706 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5708 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5709 error "ll_sparseness_verify $GLOBALOFFSETS"
5714 run_test 44a "test sparse pwrite ==============================="
5718 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5724 before=`dirty_osc_total`
5725 echo executing "\"$*\""
5727 after=`dirty_osc_total`
5728 echo before $before, after $after
5731 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5734 # Obtain grants from OST if it supports it
5735 echo blah > ${f}_grant
5738 do_dirty_record "echo blah > $f"
5739 [[ $before -eq $after ]] && error "write wasn't cached"
5740 do_dirty_record "> $f"
5741 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5742 do_dirty_record "echo blah > $f"
5743 [[ $before -eq $after ]] && error "write wasn't cached"
5744 do_dirty_record "sync"
5745 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5746 do_dirty_record "echo blah > $f"
5747 [[ $before -eq $after ]] && error "write wasn't cached"
5748 do_dirty_record "cancel_lru_locks osc"
5749 [[ $before -gt $after ]] ||
5750 error "lock cancellation didn't lower dirty count"
5753 run_test 45 "osc io page accounting ============================"
5755 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5756 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5757 # objects offset and an assert hit when an rpc was built with 1023's mapped
5758 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5760 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5765 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5767 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5768 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5772 run_test 46 "dirtying a previously written page ================"
5774 # test_47 is removed "Device nodes check" is moved to test_28
5776 test_48a() { # bug 2399
5777 [ "$mds1_FSTYPE" = "zfs" ] &&
5778 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5779 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5781 test_mkdir $DIR/$tdir
5783 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5784 test_mkdir $DIR/$tdir
5785 touch foo || error "'touch foo' failed after recreating cwd"
5787 touch .foo || error "'touch .foo' failed after recreating cwd"
5789 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5790 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5791 cd . || error "'cd .' failed after recreating cwd"
5792 mkdir . && error "'mkdir .' worked after recreating cwd"
5793 rmdir . && error "'rmdir .' worked after recreating cwd"
5794 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5795 cd .. || error "'cd ..' failed after recreating cwd"
5797 run_test 48a "Access renamed working dir (should return errors)="
5799 test_48b() { # bug 2399
5801 test_mkdir $DIR/$tdir
5803 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5804 touch foo && error "'touch foo' worked after removing cwd"
5805 mkdir foo && error "'mkdir foo' worked after removing cwd"
5806 touch .foo && error "'touch .foo' worked after removing cwd"
5807 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5808 ls . > /dev/null && error "'ls .' worked after removing cwd"
5809 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5810 mkdir . && error "'mkdir .' worked after removing cwd"
5811 rmdir . && error "'rmdir .' worked after removing cwd"
5812 ln -s . foo && error "'ln -s .' worked after removing cwd"
5813 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5815 run_test 48b "Access removed working dir (should return errors)="
5817 test_48c() { # bug 2350
5818 #lctl set_param debug=-1
5821 test_mkdir -p $DIR/$tdir/dir
5823 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5824 $TRACE touch foo && error "touch foo worked after removing cwd"
5825 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5826 touch .foo && error "touch .foo worked after removing cwd"
5827 mkdir .foo && error "mkdir .foo worked after removing cwd"
5828 $TRACE ls . && error "'ls .' worked after removing cwd"
5829 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5830 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5831 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5832 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5833 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5835 run_test 48c "Access removed working subdir (should return errors)"
5837 test_48d() { # bug 2350
5838 #lctl set_param debug=-1
5841 test_mkdir -p $DIR/$tdir/dir
5843 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5844 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5845 $TRACE touch foo && error "'touch foo' worked after removing parent"
5846 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5847 touch .foo && error "'touch .foo' worked after removing parent"
5848 mkdir .foo && error "mkdir .foo worked after removing parent"
5849 $TRACE ls . && error "'ls .' worked after removing parent"
5850 $TRACE ls .. && error "'ls ..' worked after removing parent"
5851 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5852 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5853 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5856 run_test 48d "Access removed parent subdir (should return errors)"
5858 test_48e() { # bug 4134
5859 #lctl set_param debug=-1
5862 test_mkdir -p $DIR/$tdir/dir
5864 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5865 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5866 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5867 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5868 # On a buggy kernel addition of "touch foo" after cd .. will
5869 # produce kernel oops in lookup_hash_it
5870 touch ../foo && error "'cd ..' worked after recreate parent"
5872 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5874 run_test 48e "Access to recreated parent subdir (should return errors)"
5877 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5878 skip "need MDS >= 2.13.55"
5879 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5880 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5881 skip "needs different host for mdt1 mdt2"
5882 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5884 $LFS mkdir -i0 $DIR/$tdir
5885 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5887 for d in sub1 sub2 sub3; do
5888 #define OBD_FAIL_OSD_REF_DEL 0x19c
5889 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5890 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5893 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5895 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5897 test_49() { # LU-1030
5898 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5899 remote_ost_nodsh && skip "remote OST with nodsh"
5901 # get ost1 size - $FSNAME-OST0000
5902 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5904 # write 800M at maximum
5905 [[ $ost1_size -lt 2 ]] && ost1_size=2
5906 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5908 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5909 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5912 # change max_pages_per_rpc while writing the file
5913 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5914 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5915 # loop until dd process exits
5916 while ps ax -opid | grep -wq $dd_pid; do
5917 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5918 sleep $((RANDOM % 5 + 1))
5920 # restore original max_pages_per_rpc
5921 $LCTL set_param $osc1_mppc=$orig_mppc
5922 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5924 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5928 test_mkdir $DIR/$tdir
5930 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5932 run_test 50 "special situations: /proc symlinks ==============="
5934 test_51a() { # was test_51
5935 # bug 1516 - create an empty entry right after ".." then split dir
5936 test_mkdir -c1 $DIR/$tdir
5937 touch $DIR/$tdir/foo
5938 $MCREATE $DIR/$tdir/bar
5940 createmany -m $DIR/$tdir/longfile 201
5942 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5943 $MCREATE $DIR/$tdir/longfile$FNUM
5948 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5950 run_test 51a "special situations: split htree with empty entry =="
5952 cleanup_print_lfs_df () {
5959 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5961 local dir=$DIR/$tdir
5962 local nrdirs=$((65536 + 100))
5964 # cleanup the directory
5967 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5971 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5972 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5973 [[ $numfree -lt $nrdirs ]] &&
5974 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5976 # need to check free space for the directories as well
5977 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5978 numfree=$(( blkfree / $(fs_inode_ksize) ))
5979 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5981 trap cleanup_print_lfs_df EXIT
5984 createmany -d $dir/d $nrdirs || {
5985 unlinkmany $dir/d $nrdirs
5986 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5990 nrdirs=$(ls -U $dir | wc -l)
5992 # unlink all but 100 subdirectories, then check it still works
5994 local delete=$((nrdirs - left))
5999 # for ldiskfs the nlink count should be 1, but this is OSD specific
6000 # and so this is listed for informational purposes only
6001 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
6002 unlinkmany -d $dir/d $delete ||
6003 error "unlink of first $delete subdirs failed"
6005 echo "nlink between: $(stat -c %h $dir)"
6006 local found=$(ls -U $dir | wc -l)
6007 [ $found -ne $left ] &&
6008 error "can't find subdirs: found only $found, expected $left"
6010 unlinkmany -d $dir/d $delete $left ||
6011 error "unlink of second $left subdirs failed"
6012 # regardless of whether the backing filesystem tracks nlink accurately
6013 # or not, the nlink count shouldn't be more than "." and ".." here
6014 local after=$(stat -c %h $dir)
6015 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
6016 echo "nlink after: $after"
6018 cleanup_print_lfs_df
6020 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
6023 local stripecount=$1
6026 log "create files with stripecount=$stripecount"
6027 $LFS setstripe -C $stripecount $DIR/$tdir
6028 createmany -o $DIR/$tdir/t- $nfiles
6029 $LFS getstripe $DIR/$tdir > $TMP/$tfile
6030 for ((n = 0; n < $OSTCOUNT; n++)); do
6031 objs[$n]=$(awk -vobjs=0 '($1 == '$n') { objs += 1 } \
6032 END { printf("%0.0f", objs) }' $TMP/$tfile)
6033 objs0[$n]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
6034 '($1 == '$n') { objs += 1 } \
6035 END { printf("%0.0f", objs) }')
6036 log "OST$n has ${objs[$n]} objects, ${objs0[$n]} are index 0"
6038 unlinkmany $DIR/$tdir/t- $nfiles
6043 local max=6 # allow variance of (1 - $min/$max) = 33% by default
6045 # For some combinations of stripecount and OSTCOUNT current code
6046 # is not ideal, and allocates 50% fewer *first* objects to some OSTs
6047 # than others. Rather than skipping this test entirely, check that
6048 # and keep testing to ensure imbalance does not get worse. LU-15282
6049 (( (OSTCOUNT == 6 && stripecount == 4) ||
6050 (OSTCOUNT == 10 && (stripecount == 4 || stripecount == 8)) ||
6051 (OSTCOUNT == 12 && (stripecount == 8 || stripecount == 9)))) && max=9
6052 for ((nlast=0, n = 1; n < $OSTCOUNT; nlast=n,n++)); do
6053 (( ${objs[$n]} > ${objs[$nlast]} * 4 / 5 )) ||
6054 { $LFS df && $LFS df -i &&
6055 error "stripecount=$stripecount: " \
6056 "OST $n has fewer objects vs. OST $nlast " \
6057 "(${objs[$n]} < ${objs[$nlast]} x 4/5)"; }
6058 (( ${objs[$n]} < ${objs[$nlast]} * 5 / 4 )) ||
6059 { $LFS df && $LFS df -i &&
6060 error "stripecount=$stripecount: " \
6061 "OST $n has more objects vs. OST $nlast " \
6062 "(${objs[$n]} > ${objs[$nlast]} x 5/4)"; }
6064 (( ${objs0[$n]} > ${objs0[$nlast]} * $min / $max )) ||
6065 { $LFS df && $LFS df -i &&
6066 error "stripecount=$stripecount: " \
6067 "OST $n has fewer #0 objects vs. OST $nlast " \
6068 "(${objs0[$n]} < ${objs0[$nlast]} x $min/$max)"; }
6069 (( ${objs0[$n]} < ${objs0[$nlast]} * $max / $min )) ||
6070 { $LFS df && $LFS df -i &&
6071 error "stripecount=$stripecount: " \
6072 "OST $n has more #0 objects vs. OST $nlast " \
6073 "(${objs0[$n]} > ${objs0[$nlast]} x $max/$min)"; }
6078 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6079 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
6083 local nfiles=$((per_ost * OSTCOUNT))
6084 local mdts=$(comma_list $(mdts_nodes))
6085 local param="osp.*.create_count"
6086 local qos_old=$(do_facet mds1 \
6087 "$LCTL get_param -n lod.$FSNAME-*.qos_threshold_rr" | head -n 1)
6090 "$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=100"
6091 stack_trap "do_nodes $mdts \
6092 '$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=${qos_old%%%}'"
6094 test_mkdir $DIR/$tdir
6095 local dirstripes=$(lfs getdirstripe -c $DIR/$tdir)
6096 (( dirstripes > 0 )) || dirstripes=1
6098 # Ensure enough OST objects precreated for tests to pass without
6099 # running out of objects. This is an LOV r-r OST algorithm test,
6100 # not an OST object precreation test.
6101 local old=$(do_facet mds1 "$LCTL get_param -n $param" | head -n 1)
6102 (( old >= nfiles )) ||
6104 local create_count=$((nfiles * OSTCOUNT / dirstripes))
6106 do_nodes $mdts "$LCTL set_param $param=$create_count"
6107 stack_trap "do_nodes $mdts $LCTL set_param $param=$old"
6109 # trigger precreation from all MDTs for all OSTs
6110 for ((i = 0; i < $MDSCOUNT * 2; i++ )); do
6111 $LFS setstripe -c -1 $DIR/$tdir/wide.$i
6115 for ((stripecount = 3; stripecount <= $OSTCOUNT; stripecount++)); do
6116 sleep 8 # allow object precreation to catch up
6117 test_51d_sub $stripecount $nfiles
6120 run_test 51d "check LOV round-robin OST object distribution"
6123 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6124 skip_env "ldiskfs only test"
6127 test_mkdir -c1 $DIR/$tdir
6128 test_mkdir -c1 $DIR/$tdir/d0
6130 touch $DIR/$tdir/d0/foo
6131 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
6132 error "file exceed 65000 nlink limit!"
6133 unlinkmany $DIR/$tdir/d0/f- 65001
6136 run_test 51e "check file nlink limit"
6139 test_mkdir $DIR/$tdir
6142 local ulimit_old=$(ulimit -n)
6143 local spare=20 # number of spare fd's for scripts/libraries, etc.
6144 local mdt=$($LFS getstripe -m $DIR/$tdir)
6145 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
6147 echo "MDT$mdt numfree=$numfree, max=$max"
6148 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
6149 if [ $((numfree + spare)) -gt $ulimit_old ]; then
6150 while ! ulimit -n $((numfree + spare)); do
6151 numfree=$((numfree * 3 / 4))
6153 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
6155 echo "left ulimit at $ulimit_old"
6158 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
6159 unlinkmany $DIR/$tdir/f $numfree
6160 error "create+open $numfree files in $DIR/$tdir failed"
6162 ulimit -n $ulimit_old
6164 # if createmany exits at 120s there will be fewer than $numfree files
6165 unlinkmany $DIR/$tdir/f $numfree || true
6167 run_test 51f "check many open files limit"
6170 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
6171 test_mkdir $DIR/$tdir
6172 touch $DIR/$tdir/foo
6173 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
6174 echo bar >> $DIR/$tdir/foo || error "append bar failed"
6175 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6176 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6177 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6179 echo foo >> $DIR/$tdir/foo || error "append foo failed"
6180 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6181 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
6183 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
6184 cp -r $DIR/$tdir $TMP/
6185 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
6187 run_test 52a "append-only flag test (should return errors)"
6190 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
6191 test_mkdir $DIR/$tdir
6192 touch $DIR/$tdir/foo
6193 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
6194 cat test > $DIR/$tdir/foo && error "cat test worked"
6195 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6196 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6197 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6199 echo foo >> $DIR/$tdir/foo && error "echo worked"
6200 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6201 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
6202 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
6203 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
6205 chattr -i $DIR/$tdir/foo || error "chattr failed"
6207 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
6209 run_test 52b "immutable flag test (should return errors) ======="
6212 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6213 remote_mds_nodsh && skip "remote MDS with nodsh"
6214 remote_ost_nodsh && skip "remote OST with nodsh"
6227 local support_last_seq=true
6229 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
6230 support_last_seq=false
6233 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
6235 for value in $(do_facet $SINGLEMDS \
6236 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
6237 param=$(echo ${value[0]} | cut -d "=" -f1)
6238 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
6240 if $support_last_seq; then
6241 param_seq=$(echo $param |
6242 sed -e s/prealloc_last_id/prealloc_last_seq/g)
6243 mds_last_seq=$(do_facet $SINGLEMDS \
6244 $LCTL get_param -n $param_seq)
6246 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
6248 ostnum=$(index_from_ostuuid ${ostname}_UUID)
6249 node=$(facet_active_host ost$((ostnum+1)))
6250 param="obdfilter.$ostname.last_id"
6251 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
6252 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
6253 ost_last_id=$ost_last
6255 if $support_last_seq; then
6256 ost_last_id=$(echo $ost_last |
6257 awk -F':' '{print $2}' |
6259 ost_last_seq=$(echo $ost_last |
6260 awk -F':' '{print $1}')
6261 [[ $ost_last_seq = $mds_last_seq ]] || continue
6264 if [[ $ost_last_id != $mds_last ]]; then
6265 error "$ost_last_id != $mds_last"
6272 $found || error "can not match last_seq/last_id for $mdtosc"
6275 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
6278 LANG=C perl -MSocket -e ';' || skip "no Socket perl module installed"
6280 LANG=C $SOCKETSERVER $DIR/socket ||
6281 error "$SOCKETSERVER $DIR/socket failed: $?"
6282 LANG=C $SOCKETCLIENT $DIR/socket ||
6283 error "$SOCKETCLIENT $DIR/socket failed: $?"
6284 unlink $DIR/socket || error "unlink $DIR/socket failed: $?"
6286 run_test 54a "unix domain socket test =========================="
6292 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
6294 run_test 54b "char device works in lustre ======================"
6297 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
6298 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
6299 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
6301 for i in $(seq 3 7); do
6302 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
6311 loopdev="$DIR/loop54c"
6314 $UMOUNT $DIR/$tdir || rc=$?
6315 losetup -d $loopdev || true
6316 losetup -d $LOOPDEV || true
6317 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
6322 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6324 loopdev="$DIR/loop54c"
6327 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
6328 trap cleanup_54c EXIT
6329 mknod $loopdev b 7 $LOOPNUM
6330 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
6331 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
6332 losetup $loopdev $DIR/$tfile ||
6333 error "can't set up $loopdev for $DIR/$tfile"
6334 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
6335 test_mkdir $DIR/$tdir
6336 mount -t ext2 $loopdev $DIR/$tdir ||
6337 error "error mounting $loopdev on $DIR/$tdir"
6338 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
6341 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
6345 run_test 54c "block device works in lustre ====================="
6348 local pipe="$DIR/$tfile.pipe"
6349 local string="aaaaaa"
6352 echo -n "$string" > $pipe &
6353 local result=$(cat $pipe)
6354 [[ "$result" == "$string" ]] || error "$result != $string"
6356 run_test 54d "fifo device works in lustre ======================"
6361 cp -aL /dev/console $f
6362 echo $string > $f || error "echo $string to $f failed"
6364 run_test 54e "console/tty device works in lustre ======================"
6367 local dev_path="/sys/kernel/debug/lustre/devices"
6369 load_module obdclass/obd_test verbose=2 || error "load_module failed"
6371 # This must be run in iteractive mode, since attach and setup
6373 eval "$LCTL <<-EOF || error 'OBD device creation failed'
6374 attach obd_test obd_name obd_uuid
6379 cat "$dev_path" | tail -n 10
6381 $LCTL --device "obd_name" cleanup
6382 $LCTL --device "obd_name" detach
6384 dmesg | tail -n 25 | grep "Lustre: OBD:.*FAIL" &&
6385 error "OBD unit test failed"
6387 rmmod -v obd_test ||
6388 error "rmmod failed (may trigger a failure in a later test)"
6390 run_test 55a "OBD device life cycle unit tests"
6393 local dev_path="/sys/kernel/debug/lustre/devices"
6394 local dev_count="$(wc -l $dev_path | awk '{print $1}')"
6396 # Set up a large number of devices, using the number
6397 # that can be set up in about a minute (based on prior
6398 # testing). We don't want to run this test forever.
6399 local num_dev_to_create="$(( 24000 - $dev_count))"
6401 load_module obdclass/obd_test || error "load_module failed"
6403 local start=$SECONDS
6405 # This must be run in iteractive mode, since attach and setup
6407 for ((i = 1; i <= num_dev_to_create; i++)); do
6408 echo "attach obd_test obd_name_$i obd_uuid_$i"
6409 echo "setup obd_test_$i"
6410 done | $LCTL || error "OBD device creation failed"
6412 echo "Load time: $((SECONDS - start))"
6414 cat "$dev_path" | tail -n 10
6416 for ((i = 1; i <= num_dev_to_create; i++)); do
6417 echo "--device obd_name_$i cleanup"
6418 echo "--device obd_name_$i detach"
6419 done | $LCTL || error "OBD device cleanup failed"
6421 echo "Unload time: $((SECONDS - start))"
6423 rmmod -v obd_test ||
6424 error "rmmod failed (may trigger a failure in a later test)"
6426 run_test 55b "Load and unload max OBD devices"
6431 local dir=$DIR/$tdir
6434 test_mkdir -p $dir/dir
6435 for i in $(seq $numfiles); do
6437 touch $dir/dir/file$i
6440 local numcomp=$($LFS getstripe --component-count $dir)
6442 [[ $numcomp == 0 ]] && numcomp=1
6444 # test lfs getstripe with --recursive
6445 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
6447 [[ $filenum -eq $((numfiles * 2)) ]] ||
6448 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
6449 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
6450 [[ $filenum -eq $numfiles ]] ||
6451 error "$LFS getstripe $dir: found $filenum, not $numfiles"
6452 echo "$LFS getstripe showed obdidx or l_ost_idx"
6454 # test lfs getstripe with file instead of dir
6455 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
6456 [[ $filenum -eq 1 ]] ||
6457 error "$LFS getstripe $dir/file1: found $filenum, not 1"
6458 echo "$LFS getstripe file1 passed"
6460 #test lfs getstripe with --verbose
6461 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
6462 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
6463 error "$LFS getstripe --verbose $dir: "\
6464 "got $filenum want $((numfiles * numcomp)) lmm_magic"
6465 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
6466 error "$LFS getstripe $dir: showed lmm_magic"
6468 #test lfs getstripe with -v prints lmm_fid
6469 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
6470 local countfids=$((numdirs + numfiles * numcomp))
6471 [[ $filenum -eq $countfids ]] ||
6472 error "$LFS getstripe -v $dir: "\
6473 "got $filenum want $countfids lmm_fid"
6474 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
6475 error "$LFS getstripe $dir: showed lmm_fid by default"
6476 echo "$LFS getstripe --verbose passed"
6478 #check for FID information
6479 local fid1=$($LFS getstripe --fid $dir/file1)
6480 local fid2=$($LFS getstripe --verbose $dir/file1 |
6481 awk '/lmm_fid: / { print $2; exit; }')
6482 local fid3=$($LFS path2fid $dir/file1)
6484 [ "$fid1" != "$fid2" ] &&
6485 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
6486 [ "$fid1" != "$fid3" ] &&
6487 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
6488 echo "$LFS getstripe --fid passed"
6490 #test lfs getstripe with --obd
6491 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6492 error "$LFS getstripe --obd wrong_uuid: should return error"
6494 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6497 local obduuid=$(ostuuid_from_index $ostidx)
6498 local found=$($LFS getstripe -r --obd $obduuid $dir |
6499 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6501 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6502 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6504 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6507 [[ $found -eq $filenum ]] ||
6508 error "$LFS getstripe --obd: found $found expect $filenum"
6509 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6510 sed '/^[ ]*'${ostidx}'[ ]/d' |
6511 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6512 error "$LFS getstripe --obd: should not show file on other obd"
6513 echo "$LFS getstripe --obd passed"
6515 run_test 56a "check $LFS getstripe"
6518 local dir=$DIR/$tdir
6522 for i in $(seq $numdirs); do
6523 test_mkdir $dir/dir$i
6526 # test lfs getdirstripe default mode is non-recursion, which is
6527 # different from lfs getstripe
6528 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6530 [[ $dircnt -eq 1 ]] ||
6531 error "$LFS getdirstripe: found $dircnt, not 1"
6532 dircnt=$($LFS getdirstripe --recursive $dir |
6533 grep -c lmv_stripe_count)
6534 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6535 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6537 run_test 56b "check $LFS getdirstripe"
6540 verify_yaml_available || skip_env "YAML verification not installed"
6541 local output_file=$DIR/$tfile.out
6543 $LFS getdirstripe -v -D -y $DIR 1> $output_file
6546 cat $output_file | verify_yaml || error "layout is not valid YAML"
6548 run_test 56bb "check $LFS getdirstripe layout is YAML"
6551 remote_ost_nodsh && skip "remote OST with nodsh"
6554 local ost_name=$(ostname_from_index $ost_idx)
6555 local old_status=$(ost_dev_status $ost_idx)
6556 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6558 [[ -z "$old_status" ]] ||
6559 skip_env "OST $ost_name is in $old_status status"
6561 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6562 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6563 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6564 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6565 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6566 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6569 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6570 error "$LFS df -v showing inactive devices"
6573 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6575 [[ "$new_status" =~ "D" ]] ||
6576 error "$ost_name status is '$new_status', missing 'D'"
6577 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6578 [[ "$new_status" =~ "N" ]] ||
6579 error "$ost_name status is '$new_status', missing 'N'"
6581 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6582 [[ "$new_status" =~ "f" ]] ||
6583 error "$ost_name status is '$new_status', missing 'f'"
6586 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6587 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6588 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6589 [[ -z "$p" ]] && restore_lustre_params < $p || true
6592 new_status=$(ost_dev_status $ost_idx)
6593 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6594 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6595 # can't check 'f' as devices may actually be on flash
6597 run_test 56c "check 'lfs df' showing device status"
6600 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6601 local osts=$($LFS df -v $MOUNT | grep -c OST)
6605 (( mdts == MDSCOUNT )) ||
6606 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6607 (( osts == OSTCOUNT )) ||
6608 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6610 run_test 56d "'lfs df -v' prints only configured devices"
6613 err_enoent=2 # No such file or directory
6614 err_eopnotsupp=95 # Operation not supported
6616 enoent_mnt=/pmt1 # Invalid dentry. Path not present
6617 notsup_mnt=/tmp # Valid dentry, but Not a lustreFS
6619 # Check for handling of path not exists
6620 output=$($LFS df $enoent_mnt 2>&1)
6623 fs=$(echo $output | awk -F: '{print $2}' | awk '{print $3}' | tr -d \')
6624 [[ $fs = $enoent_mnt && $ret -eq $err_enoent ]] ||
6625 error "expect failure $err_enoent, not $ret"
6627 # Check for handling of non-Lustre FS
6628 output=$($LFS df $notsup_mnt)
6631 fs=$(echo $output | awk '{print $1}' | awk -F: '{print $2}')
6632 [[ $fs = $notsup_mnt && $ret -eq $err_eopnotsupp ]] ||
6633 error "expect success $err_eopnotsupp, not $ret"
6635 # Check for multiple LustreFS argument
6636 output=$($LFS df $MOUNT $MOUNT $MOUNT | grep -c "filesystem_summary:")
6639 [[ $output -eq 3 && $ret -eq 0 ]] ||
6640 error "expect success 3, not $output, rc = $ret"
6642 # Check for correct non-Lustre FS handling among multiple
6644 output=$($LFS df $MOUNT $notsup_mnt $MOUNT |
6645 grep -c "filesystem_summary:"; exit ${PIPESTATUS[0]})
6648 [[ $output -eq 2 && $ret -eq $err_eopnotsupp ]] ||
6649 error "expect success 2, not $output, rc = $ret"
6651 run_test 56e "'lfs df' Handle non LustreFS & multiple LustreFS"
6656 local local_tdir="$1"
6657 local local_numfiles="$2"
6658 local local_numdirs="$3"
6659 local dir_params="$4"
6660 local dir_stripe_params="$5"
6662 if [ ! -d "$local_tdir" ] ; then
6663 test_mkdir -p $dir_stripe_params $local_tdir
6664 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6665 for i in $(seq $local_numfiles) ; do
6666 touch $local_tdir/file$i
6668 for i in $(seq $local_numdirs) ; do
6669 test_mkdir $dir_stripe_params $local_tdir/dir$i
6670 for j in $(seq $local_numfiles) ; do
6671 touch $local_tdir/dir$i/file$j
6677 setup_56_special() {
6679 local local_numfiles=$2
6680 local local_numdirs=$3
6682 setup_56 $local_tdir $local_numfiles $local_numdirs
6684 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6685 for i in $(seq $local_numfiles) ; do
6686 mknod $local_tdir/loop${i}b b 7 $i
6687 mknod $local_tdir/null${i}c c 1 3
6688 ln -s $local_tdir/file1 $local_tdir/link${i}
6690 for i in $(seq $local_numdirs) ; do
6691 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6692 mknod $local_tdir/dir$i/null${i}c c 1 3
6693 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6699 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6700 local expected=$(($NUMDIRS + 2))
6702 setup_56 $dir $NUMFILES $NUMDIRS
6704 # test lfs find with -name
6705 for i in $(seq $NUMFILES) ; do
6706 local nums=$($LFS find -name "*$i" $dir | wc -l)
6708 [ $nums -eq $expected ] ||
6709 error "lfs find -name '*$i' $dir wrong: "\
6710 "found $nums, expected $expected"
6713 run_test 56g "check lfs find -name"
6716 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6717 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6719 setup_56 $dir $NUMFILES $NUMDIRS
6721 # test lfs find with ! -name
6722 for i in $(seq $NUMFILES) ; do
6723 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6725 [ $nums -eq $expected ] ||
6726 error "lfs find ! -name '*$i' $dir wrong: "\
6727 "found $nums, expected $expected"
6730 run_test 56h "check lfs find ! -name"
6733 local dir=$DIR/$tdir
6737 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6740 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6742 run_test 56i "check 'lfs find -ost UUID' skips directories"
6745 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6747 setup_56_special $dir $NUMFILES $NUMDIRS
6749 local expected=$((NUMDIRS + 1))
6750 local cmd="$LFS find -type d $dir"
6751 local nums=$($cmd | wc -l)
6753 [ $nums -eq $expected ] ||
6754 error "'$cmd' wrong: found $nums, expected $expected"
6756 run_test 56j "check lfs find -type d"
6759 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6761 setup_56_special $dir $NUMFILES $NUMDIRS
6763 local expected=$(((NUMDIRS + 1) * NUMFILES))
6764 local cmd="$LFS find -type f $dir"
6765 local nums=$($cmd | wc -l)
6767 [ $nums -eq $expected ] ||
6768 error "'$cmd' wrong: found $nums, expected $expected"
6770 run_test 56k "check lfs find -type f"
6773 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6775 setup_56_special $dir $NUMFILES $NUMDIRS
6777 local expected=$((NUMDIRS + NUMFILES))
6778 local cmd="$LFS find -type b $dir"
6779 local nums=$($cmd | wc -l)
6781 [ $nums -eq $expected ] ||
6782 error "'$cmd' wrong: found $nums, expected $expected"
6784 run_test 56l "check lfs find -type b"
6787 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6789 setup_56_special $dir $NUMFILES $NUMDIRS
6791 local expected=$((NUMDIRS + NUMFILES))
6792 local cmd="$LFS find -type c $dir"
6793 local nums=$($cmd | wc -l)
6794 [ $nums -eq $expected ] ||
6795 error "'$cmd' wrong: found $nums, expected $expected"
6797 run_test 56m "check lfs find -type c"
6800 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6801 setup_56_special $dir $NUMFILES $NUMDIRS
6803 local expected=$((NUMDIRS + NUMFILES))
6804 local cmd="$LFS find -type l $dir"
6805 local nums=$($cmd | wc -l)
6807 [ $nums -eq $expected ] ||
6808 error "'$cmd' wrong: found $nums, expected $expected"
6810 run_test 56n "check lfs find -type l"
6813 local dir=$DIR/$tdir
6815 setup_56 $dir $NUMFILES $NUMDIRS
6816 utime $dir/file1 > /dev/null || error "utime (1)"
6817 utime $dir/file2 > /dev/null || error "utime (2)"
6818 utime $dir/dir1 > /dev/null || error "utime (3)"
6819 utime $dir/dir2 > /dev/null || error "utime (4)"
6820 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6821 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6824 local nums=$($LFS find -mtime +0 $dir | wc -l)
6826 [ $nums -eq $expected ] ||
6827 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6830 cmd="$LFS find -mtime 0 $dir"
6831 nums=$($cmd | wc -l)
6832 [ $nums -eq $expected ] ||
6833 error "'$cmd' wrong: found $nums, expected $expected"
6835 run_test 56o "check lfs find -mtime for old files"
6838 local dir=$DIR/$tdir
6842 # just to make sure there is something that won't be found
6844 touch $dir/$tfile.now
6846 for age in year week day hour min; do
6847 count=$((count + 1))
6849 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6850 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6851 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6853 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6854 local nums=$($cmd | wc -l)
6855 [ $nums -eq $expected ] ||
6856 error "'$cmd' wrong: found $nums, expected $expected"
6858 cmd="$LFS find $dir -atime $count${age:0:1}"
6859 nums=$($cmd | wc -l)
6860 [ $nums -eq $expected ] ||
6861 error "'$cmd' wrong: found $nums, expected $expected"
6865 cmd="$LFS find $dir -ctime +1s -type f"
6866 nums=$($cmd | wc -l)
6867 (( $nums == $count * 2 + 1)) ||
6868 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6870 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6872 test_newerXY_base() {
6875 local dir=$DIR/$tdir
6879 if [ $y == "t" ]; then
6880 if [ $x == "b" ]; then
6881 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6883 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6886 ref=$DIR/$tfile.newer.$x$y
6887 touch $ref || error "touch $ref failed"
6890 echo "before = $ref"
6892 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6894 if [ $y == "t" ]; then
6895 if [ $x == "b" ]; then
6896 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6898 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6901 negref=$DIR/$tfile.negnewer.$x$y
6902 touch $negref || error "touch $negref failed"
6905 echo "after = $negref"
6906 local cmd="$LFS find $dir -newer$x$y $ref"
6907 local nums=$(eval $cmd | wc -l)
6908 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6910 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6911 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6913 cmd="$LFS find $dir ! -newer$x$y $negref"
6914 nums=$(eval $cmd | wc -l)
6915 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6916 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6918 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6919 nums=$(eval $cmd | wc -l)
6920 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6921 error "'$cmd' wrong: found $nums between, expected $expected"; }
6927 test_newerXY_base "a" "a"
6928 test_newerXY_base "a" "m"
6929 test_newerXY_base "a" "c"
6930 test_newerXY_base "m" "a"
6931 test_newerXY_base "m" "m"
6932 test_newerXY_base "m" "c"
6933 test_newerXY_base "c" "a"
6934 test_newerXY_base "c" "m"
6935 test_newerXY_base "c" "c"
6937 test_newerXY_base "a" "t"
6938 test_newerXY_base "m" "t"
6939 test_newerXY_base "c" "t"
6941 (( $MDS1_VERSION >= $(version_code v2_13_53-145-g186b97e68a) &&
6942 $CLIENT_VERSION >= $(version_code v2_13_53-145-g186b97e68a) )) ||
6943 { echo "btime needs v2_13_53-145-g186b97e68a"; return 0; }
6945 test_newerXY_base "b" "b"
6946 test_newerXY_base "b" "t"
6948 run_test 56oc "check lfs find -newerXY work"
6951 (( $MDS1_VERSION >= $(version_code v2_13_53-145-g186b97e68a) )) ||
6952 skip "btime unsupported on MDS < v2_13_53-145-g186b97e68a"
6954 (( $CLIENT_VERSION >= $(version_code v2_13_53-145-g186b97e68a) )) ||
6955 skip "btime unsupported on clients < v2_13_53-145-g186b97e68a"
6957 local dir=$DIR/$tdir
6958 local ref=$DIR/$tfile.ref
6959 local negref=$DIR/$tfile.negref
6961 mkdir $dir || error "mkdir $dir failed"
6962 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6963 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6964 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6965 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6966 touch $ref || error "touch $ref failed"
6967 # sleep 3 seconds at least
6970 local before=$(do_facet mds1 date +%s)
6971 local skew=$(($(date +%s) - before + 1))
6973 if (( skew < 0 && skew > -5 )); then
6974 sleep $((0 - skew + 1))
6978 # Set the dir stripe params to limit files all on MDT0,
6979 # otherwise we need to calc the max clock skew between
6980 # the client and MDTs.
6981 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6983 touch $negref || error "touch $negref failed"
6985 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6986 local nums=$($cmd | wc -l)
6987 local expected=$(((NUMFILES + 1) * NUMDIRS))
6989 [ $nums -eq $expected ] ||
6990 error "'$cmd' wrong: found $nums, expected $expected"
6992 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6993 nums=$($cmd | wc -l)
6994 expected=$((NUMFILES + 1))
6995 [ $nums -eq $expected ] ||
6996 error "'$cmd' wrong: found $nums, expected $expected"
6998 [ $skew -lt 0 ] && return
7000 local after=$(do_facet mds1 date +%s)
7001 local age=$((after - before + 1 + skew))
7003 cmd="$LFS find $dir -btime -${age}s -type f"
7004 nums=$($cmd | wc -l)
7005 expected=$(((NUMFILES + 1) * NUMDIRS))
7007 echo "Clock skew between client and server: $skew, age:$age"
7008 [ $nums -eq $expected ] ||
7009 error "'$cmd' wrong: found $nums, expected $expected"
7011 expected=$(($NUMDIRS + 1))
7012 cmd="$LFS find $dir -btime -${age}s -type d"
7013 nums=$($cmd | wc -l)
7014 [ $nums -eq $expected ] ||
7015 error "'$cmd' wrong: found $nums, expected $expected"
7016 rm -f $ref $negref || error "Failed to remove $ref $negref"
7018 run_test 56od "check lfs find -btime with units"
7021 [ $RUNAS_ID -eq $UID ] &&
7022 skip_env "RUNAS_ID = UID = $UID -- skipping"
7024 local dir=$DIR/$tdir
7026 setup_56 $dir $NUMFILES $NUMDIRS
7027 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
7029 local expected=$NUMFILES
7030 local cmd="$LFS find -uid $RUNAS_ID $dir"
7031 local nums=$($cmd | wc -l)
7033 [ $nums -eq $expected ] ||
7034 error "'$cmd' wrong: found $nums, expected $expected"
7036 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
7037 cmd="$LFS find ! -uid $RUNAS_ID $dir"
7038 nums=$($cmd | wc -l)
7039 [ $nums -eq $expected ] ||
7040 error "'$cmd' wrong: found $nums, expected $expected"
7042 run_test 56p "check lfs find -uid and ! -uid"
7045 [ $RUNAS_ID -eq $UID ] &&
7046 skip_env "RUNAS_ID = UID = $UID -- skipping"
7048 local dir=$DIR/$tdir
7050 setup_56 $dir $NUMFILES $NUMDIRS
7051 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
7053 local expected=$NUMFILES
7054 local cmd="$LFS find -gid $RUNAS_GID $dir"
7055 local nums=$($cmd | wc -l)
7057 [ $nums -eq $expected ] ||
7058 error "'$cmd' wrong: found $nums, expected $expected"
7060 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
7061 cmd="$LFS find ! -gid $RUNAS_GID $dir"
7062 nums=$($cmd | wc -l)
7063 [ $nums -eq $expected ] ||
7064 error "'$cmd' wrong: found $nums, expected $expected"
7066 run_test 56q "check lfs find -gid and ! -gid"
7069 local dir=$DIR/$tdir
7071 setup_56 $dir $NUMFILES $NUMDIRS
7074 local cmd="$LFS find -size 0 -type f -lazy $dir"
7075 local nums=$($cmd | wc -l)
7077 [ $nums -eq $expected ] ||
7078 error "'$cmd' wrong: found $nums, expected $expected"
7079 cmd="$LFS find -size 0 -type f $dir"
7080 nums=$($cmd | wc -l)
7081 [ $nums -eq $expected ] ||
7082 error "'$cmd' wrong: found $nums, expected $expected"
7085 cmd="$LFS find ! -size 0 -type f -lazy $dir"
7086 nums=$($cmd | wc -l)
7087 [ $nums -eq $expected ] ||
7088 error "'$cmd' wrong: found $nums, expected $expected"
7089 cmd="$LFS find ! -size 0 -type f $dir"
7090 nums=$($cmd | wc -l)
7091 [ $nums -eq $expected ] ||
7092 error "'$cmd' wrong: found $nums, expected $expected"
7094 echo "test" > $dir/$tfile
7095 echo "test2" > $dir/$tfile.2 && sync
7097 cmd="$LFS find -size 5 -type f -lazy $dir"
7098 nums=$($cmd | wc -l)
7099 [ $nums -eq $expected ] ||
7100 error "'$cmd' wrong: found $nums, expected $expected"
7101 cmd="$LFS find -size 5 -type f $dir"
7102 nums=$($cmd | wc -l)
7103 [ $nums -eq $expected ] ||
7104 error "'$cmd' wrong: found $nums, expected $expected"
7107 cmd="$LFS find -size +5 -type f -lazy $dir"
7108 nums=$($cmd | wc -l)
7109 [ $nums -eq $expected ] ||
7110 error "'$cmd' wrong: found $nums, expected $expected"
7111 cmd="$LFS find -size +5 -type f $dir"
7112 nums=$($cmd | wc -l)
7113 [ $nums -eq $expected ] ||
7114 error "'$cmd' wrong: found $nums, expected $expected"
7117 cmd="$LFS find -size +0 -type f -lazy $dir"
7118 nums=$($cmd | wc -l)
7119 [ $nums -eq $expected ] ||
7120 error "'$cmd' wrong: found $nums, expected $expected"
7121 cmd="$LFS find -size +0 -type f $dir"
7122 nums=$($cmd | wc -l)
7123 [ $nums -eq $expected ] ||
7124 error "'$cmd' wrong: found $nums, expected $expected"
7127 cmd="$LFS find ! -size -5 -type f -lazy $dir"
7128 nums=$($cmd | wc -l)
7129 [ $nums -eq $expected ] ||
7130 error "'$cmd' wrong: found $nums, expected $expected"
7131 cmd="$LFS find ! -size -5 -type f $dir"
7132 nums=$($cmd | wc -l)
7133 [ $nums -eq $expected ] ||
7134 error "'$cmd' wrong: found $nums, expected $expected"
7137 cmd="$LFS find -size -5 -type f -lazy $dir"
7138 nums=$($cmd | wc -l)
7139 [ $nums -eq $expected ] ||
7140 error "'$cmd' wrong: found $nums, expected $expected"
7141 cmd="$LFS find -size -5 -type f $dir"
7142 nums=$($cmd | wc -l)
7143 [ $nums -eq $expected ] ||
7144 error "'$cmd' wrong: found $nums, expected $expected"
7146 run_test 56r "check lfs find -size works"
7153 cancel_lru_locks $OSC
7155 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
7156 local nums=$($cmd | wc -l)
7158 [ $nums -eq $expected ] ||
7159 error "'$cmd' wrong: found $nums, expected $expected"
7161 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
7163 if (( rpcs_before + glimpses != rpcs_after )); then
7164 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
7165 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
7167 if [[ $glimpses == 0 ]]; then
7168 error "'$cmd' should not send glimpse RPCs to OST"
7170 error "'$cmd' should send $glimpses glimpse RPCs to OST"
7176 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
7177 skip "MDS < 2.12.58 doesn't return LSOM data"
7178 local dir=$DIR/$tdir
7179 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
7181 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
7183 # statahead_agl may cause extra glimpse which confuses results. LU-13017
7184 $LCTL set_param -n llite.*.statahead_agl=0
7185 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
7187 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7188 # open and close all files to ensure LSOM is updated
7189 cancel_lru_locks $OSC
7190 find $dir -type f | xargs cat > /dev/null
7192 # expect_found glimpse_rpcs command_to_run
7193 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
7194 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
7195 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
7196 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
7198 echo "test" > $dir/$tfile
7199 echo "test2" > $dir/$tfile.2 && sync
7200 cancel_lru_locks $OSC
7201 cat $dir/$tfile $dir/$tfile.2 > /dev/null
7203 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
7204 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
7205 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
7206 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
7208 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
7209 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
7210 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
7211 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
7212 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
7213 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
7215 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
7218 local dir=$DIR/$tdir
7219 local tmp=$TMP/$tfile.log
7222 test_mkdir -p $dir || error "failed to mkdir $dir"
7223 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
7224 error "failed to setstripe $dir/$tfile"
7225 mdt_idx=$($LFS getdirstripe -i $dir)
7226 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
7228 stack_trap "rm -f $tmp" EXIT
7229 $LFS find --size +100K --ost 0 $dir |& tee $tmp
7230 ! grep -q obd_uuid $tmp ||
7231 error "failed to find --size +100K --ost 0 $dir"
7232 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
7233 ! grep -q obd_uuid $tmp ||
7234 error "failed to find --size +100K --mdt $mdt_idx $dir"
7236 run_test 56rb "check lfs find --size --ost/--mdt works"
7239 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
7240 local dir=$DIR/$tdir
7243 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
7244 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
7245 (( $MDSCOUNT > 2 )) &&
7246 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
7247 mkdir $dir/$tdir-{1..10}
7248 touch $dir/$tfile-{1..10}
7250 found=$($LFS find $dir --mdt-count 2 | wc -l)
7252 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
7254 found=$($LFS find $dir -T +1 | wc -l)
7255 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
7256 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
7258 found=$($LFS find $dir --mdt-hash all_char | wc -l)
7260 (( $found == $expect )) || error "found $found all_char, expect $expect"
7262 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
7263 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
7264 (( $found == $expect )) || error "found $found all_char, expect $expect"
7266 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
7269 local dir=$DIR/$tdir
7274 mkfifo $dir/fifo || error "failed to create fifo file"
7275 $LFS find $dir -t p --printf "%p %y %LP\n" ||
7276 error "should not fail even cannot get projid from pipe file"
7277 found=$($LFS find $dir -t p --printf "%y")
7278 [[ "p" == $found ]] || error "found $found, expect p"
7280 mknod $dir/chardev c 1 5 ||
7281 error "failed to create character device file"
7282 $LFS find $dir -t c --printf "%p %y %LP\n" ||
7283 error "should not fail even cannot get projid from chardev file"
7284 found=$($LFS find $dir -t c --printf "%y")
7285 [[ "c" == $found ]] || error "found $found, expect c"
7287 found=$($LFS find $dir ! -type d --printf "%p %y %LP\n" | wc -l)
7288 (( found == 2 )) || error "unable to list all files"
7290 run_test 56rd "check lfs find --printf special files"
7292 test_56s() { # LU-611 #LU-9369
7293 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
7295 local dir=$DIR/$tdir
7296 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
7298 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7299 for i in $(seq $NUMDIRS); do
7300 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
7303 local expected=$NUMDIRS
7304 local cmd="$LFS find -c $OSTCOUNT $dir"
7305 local nums=$($cmd | wc -l)
7307 [ $nums -eq $expected ] || {
7308 $LFS getstripe -R $dir
7309 error "'$cmd' wrong: found $nums, expected $expected"
7312 expected=$((NUMDIRS + onestripe))
7313 cmd="$LFS find -stripe-count +0 -type f $dir"
7314 nums=$($cmd | wc -l)
7315 [ $nums -eq $expected ] || {
7316 $LFS getstripe -R $dir
7317 error "'$cmd' wrong: found $nums, expected $expected"
7321 cmd="$LFS find -stripe-count 1 -type f $dir"
7322 nums=$($cmd | wc -l)
7323 [ $nums -eq $expected ] || {
7324 $LFS getstripe -R $dir
7325 error "'$cmd' wrong: found $nums, expected $expected"
7328 cmd="$LFS find -stripe-count -2 -type f $dir"
7329 nums=$($cmd | wc -l)
7330 [ $nums -eq $expected ] || {
7331 $LFS getstripe -R $dir
7332 error "'$cmd' wrong: found $nums, expected $expected"
7336 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
7337 nums=$($cmd | wc -l)
7338 [ $nums -eq $expected ] || {
7339 $LFS getstripe -R $dir
7340 error "'$cmd' wrong: found $nums, expected $expected"
7343 run_test 56s "check lfs find -stripe-count works"
7345 test_56t() { # LU-611 #LU-9369
7346 local dir=$DIR/$tdir
7348 setup_56 $dir 0 $NUMDIRS
7349 for i in $(seq $NUMDIRS); do
7350 $LFS setstripe -S 8M $dir/dir$i/$tfile
7353 local expected=$NUMDIRS
7354 local cmd="$LFS find -S 8M $dir"
7355 local nums=$($cmd | wc -l)
7357 [ $nums -eq $expected ] || {
7358 $LFS getstripe -R $dir
7359 error "'$cmd' wrong: found $nums, expected $expected"
7363 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
7365 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
7367 expected=$(((NUMDIRS + 1) * NUMFILES))
7368 cmd="$LFS find -stripe-size 512k -type f $dir"
7369 nums=$($cmd | wc -l)
7370 [ $nums -eq $expected ] ||
7371 error "'$cmd' wrong: found $nums, expected $expected"
7373 cmd="$LFS find -stripe-size +320k -type f $dir"
7374 nums=$($cmd | wc -l)
7375 [ $nums -eq $expected ] ||
7376 error "'$cmd' wrong: found $nums, expected $expected"
7378 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
7379 cmd="$LFS find -stripe-size +200k -type f $dir"
7380 nums=$($cmd | wc -l)
7381 [ $nums -eq $expected ] ||
7382 error "'$cmd' wrong: found $nums, expected $expected"
7384 cmd="$LFS find -stripe-size -640k -type f $dir"
7385 nums=$($cmd | wc -l)
7386 [ $nums -eq $expected ] ||
7387 error "'$cmd' wrong: found $nums, expected $expected"
7390 cmd="$LFS find -stripe-size 256k -type f $dir"
7391 nums=$($cmd | wc -l)
7392 [ $nums -eq $expected ] ||
7393 error "'$cmd' wrong: found $nums, expected $expected"
7395 cmd="$LFS find -stripe-size -320k -type f $dir"
7396 nums=$($cmd | wc -l)
7397 [ $nums -eq $expected ] ||
7398 error "'$cmd' wrong: found $nums, expected $expected"
7401 cmd="$LFS find -stripe-size 1024k -type f $dir"
7402 nums=$($cmd | wc -l)
7403 [ $nums -eq $expected ] ||
7404 error "'$cmd' wrong: found $nums, expected $expected"
7406 run_test 56t "check lfs find -stripe-size works"
7408 test_56u() { # LU-611
7409 local dir=$DIR/$tdir
7411 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
7413 if [[ $OSTCOUNT -gt 1 ]]; then
7414 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
7420 local expected=$(((NUMDIRS + 1) * NUMFILES))
7421 local cmd="$LFS find -stripe-index 0 -type f $dir"
7422 local nums=$($cmd | wc -l)
7424 [ $nums -eq $expected ] ||
7425 error "'$cmd' wrong: found $nums, expected $expected"
7428 cmd="$LFS find -stripe-index 1 -type f $dir"
7429 nums=$($cmd | wc -l)
7430 [ $nums -eq $expected ] ||
7431 error "'$cmd' wrong: found $nums, expected $expected"
7433 cmd="$LFS find ! -stripe-index 0 -type f $dir"
7434 nums=$($cmd | wc -l)
7435 [ $nums -eq $expected ] ||
7436 error "'$cmd' wrong: found $nums, expected $expected"
7439 # This should produce an error and not return any files
7440 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
7441 nums=$($cmd 2>/dev/null | wc -l)
7442 [ $nums -eq $expected ] ||
7443 error "'$cmd' wrong: found $nums, expected $expected"
7445 if [[ $OSTCOUNT -gt 1 ]]; then
7446 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
7447 cmd="$LFS find -stripe-index 0,1 -type f $dir"
7448 nums=$($cmd | wc -l)
7449 [ $nums -eq $expected ] ||
7450 error "'$cmd' wrong: found $nums, expected $expected"
7453 run_test 56u "check lfs find -stripe-index works"
7457 local dir=$DIR/$tdir
7459 setup_56 $dir $NUMFILES $NUMDIRS
7461 UUID=$(mdtuuid_from_index $mdt_idx $dir)
7462 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
7464 for file in $($LFS find -m $UUID $dir); do
7465 file_midx=$($LFS getstripe -m $file)
7466 [ $file_midx -eq $mdt_idx ] ||
7467 error "lfs find -m $UUID != getstripe -m $file_midx"
7470 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
7473 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
7474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7476 local dir=$DIR/$tdir
7478 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
7479 stack_trap "rm -rf $dir"
7481 local stripe_size=$($LFS getstripe -S -d $dir) ||
7482 error "$LFS getstripe -S -d $dir failed"
7483 stripe_size=${stripe_size%% *}
7485 local file_size=$((stripe_size * OSTCOUNT))
7486 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
7487 local required_space=$((file_num * file_size))
7488 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
7490 (( free_space >= required_space / 1024 )) ||
7491 skip_env "need $required_space, have $free_space kbytes"
7494 local dd_count=$((file_size / dd_bs))
7496 # write data into the files
7501 for ((i = 1; i <= NUMFILES; i++ )); do
7503 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7504 error "write data into $file failed"
7506 for ((i = 1; i <= NUMDIRS; i++ )); do
7507 for ((j = 1; j <= NUMFILES; j++ )); do
7508 file=$dir/dir$i/file$j
7509 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7510 error "write data into $file failed"
7514 # $LFS_MIGRATE will fail if hard link migration is unsupported
7515 if (( MDS1_VERSION > $(version_code 2.5.55) )); then
7516 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
7517 error "creating links to $dir/dir1/file1 failed"
7522 (( OSTCOUNT <= 1 )) || expected=$((OSTCOUNT - 1))
7525 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
7528 eval $cmd || error "$cmd failed"
7530 check_stripe_count $dir/file1 $expected
7532 if (( $MDS1_VERSION >= $(version_code 2.6.90) )); then
7533 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
7534 # OST 1 if it is on OST 0. This file is small enough to
7535 # be on only one stripe.
7536 file=$dir/migr_1_ost
7537 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
7538 error "write data into $file failed"
7539 local obdidx=$($LFS getstripe -i $file)
7540 local oldmd5=$(md5sum $file)
7543 (( obdidx != 0 )) || newobdidx=1
7544 cmd="$LFS migrate -i $newobdidx $file"
7546 eval $cmd || error "$cmd failed"
7548 local realobdix=$($LFS getstripe -i $file)
7549 local newmd5=$(md5sum $file)
7551 (( $newobdidx == $realobdix )) ||
7552 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
7553 [[ "$oldmd5" == "$newmd5" ]] ||
7554 error "md5sum differ: $oldmd5, $newmd5"
7558 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7560 eval $cmd || error "$cmd failed"
7562 for (( j = 1; j <= NUMFILES; j++ )); do
7563 check_stripe_count $dir/dir1/file$j $expected
7566 # lfs_migrate works with lfs find
7567 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7568 $LFS_MIGRATE -y -c $expected"
7570 eval $cmd || error "$cmd failed"
7572 for (( i = 2; i <= NUMFILES; i++ )); do
7573 check_stripe_count $dir/file$i $expected
7575 for (( i = 2; i <= NUMDIRS; i++ )); do
7576 for (( j = 1; j <= NUMFILES; j++ )); do
7577 check_stripe_count $dir/dir$i/file$j $expected
7581 run_test 56wa "check lfs_migrate -c stripe_count works"
7584 local file1=$DIR/$tdir/file1
7585 local create_pool=false
7586 local initial_pool=$($LFS getstripe -p $DIR)
7590 echo -n "Creating test dir..."
7591 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7594 echo -n "Creating test file..."
7595 touch $file1 || error "cannot create file"
7598 echo -n "Detecting existing pools..."
7599 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7601 if [ ${#pool_list[@]} -gt 0 ]; then
7602 echo "${pool_list[@]}"
7603 for thispool in "${pool_list[@]}"; do
7604 if [[ -z "$initial_pool" ||
7605 "$initial_pool" != "$thispool" ]]; then
7607 echo "Using existing pool '$pool'"
7612 echo "none detected."
7614 if [ -z "$pool" ]; then
7615 pool=${POOL:-testpool}
7616 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7617 echo -n "Creating pool '$pool'..."
7619 pool_add $pool &> /dev/null ||
7620 error "pool_add failed"
7623 echo -n "Adding target to pool..."
7624 pool_add_targets $pool 0 0 1 &> /dev/null ||
7625 error "pool_add_targets failed"
7629 echo -n "Setting pool using -p option..."
7630 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7631 error "migrate failed rc = $?"
7634 echo -n "Verifying test file is in pool after migrating..."
7635 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7636 error "file was not migrated to pool $pool"
7639 echo -n "Removing test file from pool '$pool'..."
7640 # "lfs migrate $file" won't remove the file from the pool
7641 # until some striping information is changed.
7642 $LFS migrate -c 1 $file1 &> /dev/null ||
7643 error "cannot remove from pool"
7644 [ "$($LFS getstripe -p $file1)" ] &&
7645 error "pool still set"
7648 echo -n "Setting pool using --pool option..."
7649 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7650 error "migrate failed rc = $?"
7655 if $create_pool; then
7656 destroy_test_pools 2> /dev/null ||
7657 error "destroy test pools failed"
7660 run_test 56wb "check lfs_migrate pool support"
7663 local file1="$DIR/$tdir/$tfile"
7673 echo -n "Creating test dir..."
7674 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7675 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7676 error "cannot set stripe by '-S 1M -c 1'"
7679 echo -n "Setting initial stripe for test file..."
7680 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7681 error "cannot set stripe"
7682 cur_ssize=$($LFS getstripe -S "$file1")
7683 (( cur_ssize == 524288 )) || error "setstripe -S $cur_ssize != 524288"
7686 dd if=/dev/urandom of=$file1 bs=1M count=12 || error "dd $file1 failed"
7687 stack_trap "rm -f $file1"
7688 md5="$(md5sum $file1)"
7690 # File currently set to -S 512K -c 1
7692 # Ensure -c and -S options are rejected when -R is set
7693 echo -n "Verifying incompatible options are detected..."
7694 $LFS_MIGRATE -R -c 1 "$file1" &&
7695 error "incompatible -R and -c options not detected"
7696 $LFS_MIGRATE -R -S 1M "$file1" &&
7697 error "incompatible -R and -S options not detected"
7698 $LFS_MIGRATE -R -p pool "$file1" &&
7699 error "incompatible -R and -p options not detected"
7700 $LFS_MIGRATE -R -E eof -c 1 "$file1" &&
7701 error "incompatible -R and -E options not detected"
7702 $LFS_MIGRATE -R -A "$file1" &&
7703 error "incompatible -R and -A options not detected"
7704 $LFS_MIGRATE -A -c 1 "$file1" &&
7705 error "incompatible -A and -c options not detected"
7706 $LFS_MIGRATE -A -S 1M "$file1" &&
7707 error "incompatible -A and -S options not detected"
7708 $LFS_MIGRATE -A -p pool "$file1" &&
7709 error "incompatible -A and -p options not detected"
7710 $LFS_MIGRATE -A -E eof -c 1 "$file1" &&
7711 error "incompatible -A and -E options not detected"
7714 # Ensure unrecognized options are passed through to 'lfs migrate'
7715 echo -n "Verifying -S option is passed through to lfs migrate..."
7716 $LFS_MIGRATE -y -S 1M "$file1" || error "migration failed"
7717 cur_ssize=$($LFS getstripe -S "$file1")
7718 (( cur_ssize == 1048576 )) || error "migrate -S $cur_ssize != 1048576"
7719 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (1)"
7722 # File currently set to -S 1M -c 1
7724 # Ensure long options are supported
7725 echo -n "Verifying long options supported..."
7726 $LFS_MIGRATE --non-block "$file1" ||
7727 error "long option without argument not supported"
7728 $LFS_MIGRATE --stripe-size 512K "$file1" ||
7729 error "long option with argument not supported"
7730 cur_ssize=$($LFS getstripe -S "$file1")
7731 (( cur_ssize == 524288 )) ||
7732 error "migrate --stripe-size $cur_ssize != 524288"
7733 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (2)"
7736 # File currently set to -S 512K -c 1
7738 if (( OSTCOUNT > 1 )); then
7739 echo -n "Verifying explicit stripe count can be set..."
7740 $LFS_MIGRATE -c 2 "$file1" || error "migrate failed"
7741 cur_scount=$($LFS getstripe -c "$file1")
7742 (( cur_scount == 2 )) || error "migrate -c $cur_scount != 2"
7743 [[ "$(md5sum $file1)" == "$md5" ]] ||
7744 error "file data has changed (3)"
7748 # File currently set to -S 512K -c 1 or -S 512K -c 2
7750 # Ensure parent striping is used if -R is set, and no stripe
7751 # count or size is specified
7752 echo -n "Setting stripe for parent directory..."
7753 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7754 error "cannot set stripe '-S 2M -c 1'"
7755 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (4)"
7758 echo -n "Verifying restripe option uses parent stripe settings..."
7759 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7760 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7761 $LFS_MIGRATE -R "$file1" || error "migrate failed"
7762 cur_ssize=$($LFS getstripe -S "$file1")
7763 (( cur_ssize == parent_ssize )) ||
7764 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7765 cur_scount=$($LFS getstripe -c "$file1")
7766 (( cur_scount == parent_scount )) ||
7767 error "migrate -R stripe_count $cur_scount != $parent_scount"
7768 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (5)"
7771 # File currently set to -S 1M -c 1
7773 # Ensure striping is preserved if -R is not set, and no stripe
7774 # count or size is specified
7775 echo -n "Verifying striping size preserved when not specified..."
7776 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7777 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7778 error "cannot set stripe on parent directory"
7779 $LFS_MIGRATE "$file1" || error "migrate failed"
7780 cur_ssize=$($LFS getstripe -S "$file1")
7781 (( cur_ssize == orig_ssize )) ||
7782 error "migrate by default $cur_ssize != $orig_ssize"
7783 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (6)"
7786 # Ensure file name properly detected when final option has no argument
7787 echo -n "Verifying file name properly detected..."
7788 $LFS_MIGRATE "$file1" ||
7789 error "file name interpreted as option argument"
7790 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (7)"
7793 # Ensure PFL arguments are passed through properly
7794 echo -n "Verifying PFL options passed through..."
7795 new_scount=$(((OSTCOUNT + 1) / 2))
7796 $LFS_MIGRATE -E 1M -c 1 -E 16M -c $new_scount -E eof -c -1 "$file1" ||
7797 error "migrate PFL arguments failed"
7798 cur_comp=$($LFS getstripe --comp-count $file1)
7799 (( cur_comp == 3 )) || error "component count '$cur_comp' != 3"
7800 cur_scount=$($LFS getstripe --stripe-count $file1)
7801 (( cur_scount == new_scount)) ||
7802 error "PFL stripe count $cur_scount != $new_scount"
7803 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (8)"
7806 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7809 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
7811 local file1=$DIR/$tdir/$tfile
7813 echo -n "Creating test dir..."
7814 test_mkdir $DIR/$tdir || error "cannot create dir"
7817 echo -n "Creating test file..."
7818 echo "$tfile" > $file1
7821 # Ensure 'lfs migrate' will fail by using a non-existent option,
7822 # and make sure rsync is not called to recover
7823 echo -n "Make sure --no-rsync option works..."
7824 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7825 grep -q 'refusing to fall back to rsync' ||
7826 error "rsync was called with --no-rsync set"
7829 # Ensure rsync is called without trying 'lfs migrate' first
7830 echo -n "Make sure --rsync option works..."
7831 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7832 grep -q 'falling back to rsync' &&
7833 error "lfs migrate was called with --rsync set"
7836 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7842 test_mkdir $td || error "cannot create $td"
7843 touch $tf || error "cannot touch $tf"
7845 echo -n "Make sure --non-direct|-D works..."
7846 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7847 grep -q "lfs migrate --non-direct" ||
7848 error "--non-direct option cannot work correctly"
7849 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7850 grep -q "lfs migrate -D" ||
7851 error "-D option cannot work correctly"
7854 run_test 56we "check lfs_migrate --non-direct|-D support"
7857 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7858 check_swap_layouts_support
7860 local dir=$DIR/$tdir
7861 local ref1=/etc/passwd
7862 local file1=$dir/file1
7864 test_mkdir $dir || error "creating dir $dir"
7865 $LFS setstripe -c 2 $file1
7867 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7868 stripe=$($LFS getstripe -c $file1)
7869 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7870 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7875 run_test 56x "lfs migration support"
7878 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7879 check_swap_layouts_support
7881 local dir=$DIR/$tdir/$testnum
7885 local ref1=/etc/passwd
7886 local file1=$dir/file1
7888 $LFS setstripe -c 2 $file1
7890 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7892 local stripe=$($LFS getstripe -c $file1)
7894 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7895 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7900 run_test 56xa "lfs migration --block support"
7902 check_migrate_links() {
7903 [[ "$1" == "--rsync" ]] && local opts="--rsync -y" && shift
7905 local file1="$dir/file1"
7909 local total_count=$(($begin + $count - 1))
7910 local symlink_count=10
7913 if [ ! -f "$file1" ]; then
7914 echo -n "creating initial file..."
7915 $LFS setstripe -c 1 -S "512k" "$file1" ||
7916 error "cannot setstripe initial file"
7919 echo -n "creating symlinks..."
7920 for s in $(seq 1 $symlink_count); do
7921 ln -s "$file1" "$dir/slink$s" ||
7922 error "cannot create symlinks"
7926 echo -n "creating nonlinked files..."
7927 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7928 error "cannot create nonlinked files"
7933 if [ ! -f "$dir/file$total_count" ]; then
7934 echo -n "creating hard links $begin:$total_count..."
7935 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7936 /dev/null || error "cannot create hard links"
7940 echo -n "checking number of hard links listed in xattrs..."
7941 local fid=$($LFS getstripe -F "$file1")
7942 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7945 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7946 skip "hard link list has unexpected size, skipping test"
7948 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7949 error "link names should exceed xattrs size"
7952 echo -n "migrating files..."
7953 local migrate_out=$($runas $LFS_MIGRATE $opts -S '1m' $dir)
7955 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7958 # make sure all links have been properly migrated
7959 echo -n "verifying files..."
7960 fid=$($LFS getstripe -F "$file1") ||
7961 error "cannot get fid for file $file1"
7962 for i in $(seq 2 $total_count); do
7963 local fid2=$($LFS getstripe -F $dir/file$i)
7965 [ "$fid2" == "$fid" ] ||
7966 error "migrated hard link has mismatched FID"
7969 # make sure hard links were properly detected, and migration was
7970 # performed only once for the entire link set; nonlinked files should
7972 local actual=$(grep -c 'done' <<< "$migrate_out")
7973 local expected=$(($uniq_count + 1))
7975 [ "$actual" -eq "$expected" ] ||
7976 error "hard links individually migrated ($actual != $expected)"
7978 # make sure the correct number of hard links are present
7979 local hardlinks=$(stat -c '%h' "$file1")
7981 [ $hardlinks -eq $total_count ] ||
7982 error "num hard links $hardlinks != $total_count"
7989 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7990 skip "Need MDS version at least 2.10.55"
7992 local dir="$DIR/$tdir"
7994 test_mkdir "$dir" || error "cannot create dir $dir"
7996 echo "testing lfs migrate mode when all links fit within xattrs"
7997 check_migrate_links "$dir" 2 99
7999 echo "testing rsync mode when all links fit within xattrs"
8000 check_migrate_links --rsync "$dir" 2 99
8002 echo "testing lfs migrate mode when all links do not fit within xattrs"
8003 check_migrate_links "$dir" 101 100
8005 echo "testing rsync mode when all links do not fit within xattrs"
8006 check_migrate_links --rsync "$dir" 101 100
8008 chown -R $RUNAS_ID $dir
8009 echo "testing non-root lfs migrate mode when not all links are in xattr"
8010 check_migrate_links "$dir" 101 100 "$RUNAS"
8015 run_test 56xb "lfs migration hard link support"
8018 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8020 local dir="$DIR/$tdir"
8022 test_mkdir "$dir" || error "cannot create dir $dir"
8024 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
8025 echo -n "Setting initial stripe for 20MB test file..."
8026 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
8027 error "cannot setstripe 20MB file"
8029 echo -n "Sizing 20MB test file..."
8030 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
8032 echo -n "Verifying small file autostripe count is 1..."
8033 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
8034 error "cannot migrate 20MB file"
8035 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
8036 error "cannot get stripe for $dir/20mb"
8037 [ $stripe_count -eq 1 ] ||
8038 error "unexpected stripe count $stripe_count for 20MB file"
8042 # Test 2: File is small enough to fit within the available space on
8043 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
8044 # have at least an additional 1KB for each desired stripe for test 3
8045 echo -n "Setting stripe for 1GB test file..."
8046 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
8048 echo -n "Sizing 1GB test file..."
8049 # File size is 1GB + 3KB
8050 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
8053 # need at least 512MB per OST for 1GB file to fit in 2 stripes
8054 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
8055 if (( avail > 524288 * OSTCOUNT )); then
8056 echo -n "Migrating 1GB file..."
8057 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
8058 error "cannot migrate 1GB file"
8060 echo -n "Verifying autostripe count is sqrt(n) + 1..."
8061 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
8062 error "cannot getstripe for 1GB file"
8063 [ $stripe_count -eq 2 ] ||
8064 error "unexpected stripe count $stripe_count != 2"
8068 # Test 3: File is too large to fit within the available space on
8069 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
8070 if [ $OSTCOUNT -ge 3 ]; then
8071 # The required available space is calculated as
8072 # file size (1GB + 3KB) / OST count (3).
8073 local kb_per_ost=349526
8075 echo -n "Migrating 1GB file with limit..."
8076 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
8077 error "cannot migrate 1GB file with limit"
8080 stripe_count=$($LFS getstripe -c "$dir/1gb")
8081 echo -n "Verifying 1GB autostripe count with limited space..."
8082 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
8083 error "unexpected stripe count $stripe_count (min 3)"
8090 run_test 56xc "lfs migration autostripe"
8093 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8095 local dir=$DIR/$tdir
8096 local f_mgrt=$dir/$tfile.mgrt
8097 local f_yaml=$dir/$tfile.yaml
8098 local f_copy=$dir/$tfile.copy
8099 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
8100 local layout_copy="-c 2 -S 2M -i 1"
8101 local yamlfile=$dir/yamlfile
8102 local layout_before;
8105 test_mkdir "$dir" || error "cannot create dir $dir"
8106 stack_trap "rm -rf $dir"
8107 $LFS setstripe $layout_yaml $f_yaml ||
8108 error "cannot setstripe $f_yaml with layout $layout_yaml"
8109 $LFS getstripe --yaml $f_yaml > $yamlfile
8110 $LFS setstripe $layout_copy $f_copy ||
8111 error "cannot setstripe $f_copy with layout $layout_copy"
8113 dd if=/dev/zero of=$f_mgrt bs=1M count=4
8115 # 1. test option --yaml
8116 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
8117 error "cannot migrate $f_mgrt with --yaml $yamlfile"
8118 layout_before=$(get_layout_param $f_yaml)
8119 layout_after=$(get_layout_param $f_mgrt)
8120 [ "$layout_after" == "$layout_before" ] ||
8121 error "lfs_migrate --yaml: $layout_after != $layout_before"
8123 # 2. test option --copy
8124 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
8125 error "cannot migrate $f_mgrt with --copy $f_copy"
8126 layout_before=$(SKIP_INDEX=yes get_layout_param $f_copy)
8127 layout_after=$(SKIP_INDEX=yes get_layout_param $f_mgrt)
8128 [ "$layout_after" == "$layout_before" ] ||
8129 error "lfs_migrate --copy: $layout_after != $layout_before"
8131 run_test 56xd "check lfs_migrate --yaml and --copy support"
8134 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8136 local dir=$DIR/$tdir
8137 local f_comp=$dir/$tfile
8138 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
8139 local layout_before=""
8140 local layout_after=""
8142 test_mkdir "$dir" || error "cannot create dir $dir"
8143 stack_trap "rm -rf $dir"
8144 $LFS setstripe $layout $f_comp ||
8145 error "cannot setstripe $f_comp with layout $layout"
8146 layout_before=$(SKIP_INDEX=yes get_layout_param $f_comp)
8147 dd if=/dev/zero of=$f_comp bs=1M count=4
8149 # 1. migrate a comp layout file by lfs_migrate
8150 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
8151 layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
8152 [ "$layout_before" == "$layout_after" ] ||
8153 error "lfs_migrate: $layout_before != $layout_after"
8155 # 2. migrate a comp layout file by lfs migrate
8156 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
8157 layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
8158 [ "$layout_before" == "$layout_after" ] ||
8159 error "lfs migrate: $layout_before != $layout_after"
8161 run_test 56xe "migrate a composite layout file"
8164 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
8166 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
8167 skip "Need server version at least 2.13.53"
8169 local dir=$DIR/$tdir
8170 local f_comp=$dir/$tfile
8171 local layout="-E 1M -c1 -E -1 -c2"
8175 test_mkdir "$dir" || error "cannot create dir $dir"
8176 stack_trap "rm -rf $dir"
8177 $LFS setstripe $layout $f_comp ||
8178 error "cannot setstripe $f_comp with layout $layout"
8179 fid_before=$($LFS getstripe --fid $f_comp)
8180 dd if=/dev/zero of=$f_comp bs=1M count=4
8182 # 1. migrate a comp layout file to a comp layout
8183 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
8184 fid_after=$($LFS getstripe --fid $f_comp)
8185 [ "$fid_before" == "$fid_after" ] ||
8186 error "comp-to-comp migrate: $fid_before != $fid_after"
8188 # 2. migrate a comp layout file to a plain layout
8189 $LFS migrate -c2 $f_comp ||
8190 error "cannot migrate $f_comp by lfs migrate"
8191 fid_after=$($LFS getstripe --fid $f_comp)
8192 [ "$fid_before" == "$fid_after" ] ||
8193 error "comp-to-plain migrate: $fid_before != $fid_after"
8195 # 3. migrate a plain layout file to a comp layout
8196 $LFS migrate $layout $f_comp ||
8197 error "cannot migrate $f_comp by lfs migrate"
8198 fid_after=$($LFS getstripe --fid $f_comp)
8199 [ "$fid_before" == "$fid_after" ] ||
8200 error "plain-to-comp migrate: $fid_before != $fid_after"
8202 run_test 56xf "FID is not lost during migration of a composite layout file"
8204 check_file_ost_range() {
8211 file_range=($($LFS getstripe -y "$file" |
8212 awk '/l_ost_idx:/ { print $NF }'))
8214 if [[ "${#file_range[@]}" = 0 ]]; then
8215 echo "No osts found for $file"
8219 for idx in "${file_range[@]}"; do
8220 [[ " $range " =~ " $idx " ]] ||
8228 local stripe_opt="$1"
8231 local pool_ostidx="$(seq $* | tr '\n' ' ')"
8233 $LFS migrate $stripe_opt -p $pool $DIR/$tfile ||
8234 error "Fail to migrate $tfile on $pool"
8235 [[ "$($LFS getstripe -p $DIR/$tfile)" = "$pool" ]] ||
8236 error "$tfile is not in pool $pool"
8237 check_file_ost_range "$DIR/$tfile" $pool_ostidx ||
8238 error "$tfile osts mismatch with pool $pool (osts $pool_ostidx)"
8242 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
8243 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
8244 [[ $MDS1_VERSION -gt $(version_code 2.14.52) ]] ||
8245 skip "Need MDS version newer than 2.14.52"
8247 local -a pool_names=("${TESTNAME}_0" "${TESTNAME}_1" "${TESTNAME}_2")
8248 local -a pool_ranges=("0 0" "1 1" "0 1")
8251 for i in "${!pool_names[@]}"; do
8252 pool_add ${pool_names[$i]} ||
8253 error "pool_add failed (pool: ${pool_names[$i]})"
8254 pool_add_targets ${pool_names[$i]} ${pool_ranges[$i]} ||
8255 error "pool_add_targets failed (pool: ${pool_names[$i]})"
8258 # init the file to migrate
8259 $LFS setstripe -c1 -i1 $DIR/$tfile ||
8260 error "Unable to create $tfile on OST1"
8261 stack_trap "rm -f $DIR/$tfile"
8262 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=4 status=none ||
8263 error "Unable to write on $tfile"
8265 echo "1. migrate $tfile on pool ${pool_names[0]}"
8266 sub_test_56xg "-c-1" "${pool_names[0]}" ${pool_ranges[0]}
8268 echo "2. migrate $tfile on pool ${pool_names[2]}"
8269 sub_test_56xg "-c-1 -S2M" "${pool_names[2]}" ${pool_ranges[2]}
8271 echo "3. migrate $tfile on pool ${pool_names[1]}"
8272 sub_test_56xg "-n -c-1" "${pool_names[1]}" ${pool_ranges[1]}
8274 echo "4. migrate $tfile on pool ${pool_names[2]} with default stripe parameters"
8275 sub_test_56xg "" "${pool_names[2]}" ${pool_ranges[2]}
8279 destroy_test_pools ||
8280 error "pool_destroy failed"
8282 run_test 56xg "lfs migrate pool support"
8285 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8288 local file1=$DIR/$tfile
8289 local tmp1=$TMP/$tfile.tmp
8291 $LFS setstripe -c 2 $file1
8293 stack_trap "rm -f $file1 $tmp1"
8294 dd if=/dev/urandom of=$tmp1 bs=1M count=$size_mb ||
8295 error "error creating $tmp1"
8299 local start=$SECONDS
8301 $LFS migrate --stats --stats-interval=1 -W 1M -c 1 $file1 ||
8302 error "migrate failed rc = $?"
8304 local elapsed=$((SECONDS - start))
8306 # with 1MB/s, elapsed should equal size_mb
8307 (( elapsed >= size_mb * 95 / 100 )) ||
8308 error "'lfs migrate -W' too fast ($elapsed < 0.95 * $size_mb)?"
8310 (( elapsed <= size_mb * 120 / 100 )) ||
8311 error_not_in_vm "'lfs migrate -W' slow ($elapsed > 1.2 * $size_mb)"
8313 (( elapsed <= size_mb * 350 / 100 )) ||
8314 error "'lfs migrate -W' too slow in VM ($elapsed > 3.5 * $size_mb)"
8316 stripe=$($LFS getstripe -c $file1)
8317 (( $stripe == 1 )) || error "stripe of $file1 is $stripe != 1"
8318 cmp $file1 $tmp1 || error "content mismatch $file1 differs from $tmp1"
8320 # Clean up file (since it is multiple MB)
8323 run_test 56xh "lfs migrate bandwidth limitation support"
8326 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8327 verify_yaml_available || skip_env "YAML verification not installed"
8330 local file1=$DIR/$tfile.1
8331 local file2=$DIR/$tfile.2
8332 local file3=$DIR/$tfile.3
8333 local output_file=$DIR/$tfile.out
8334 local tmp1=$TMP/$tfile.tmp
8336 $LFS setstripe -c 2 $file1
8337 $LFS setstripe -c 2 $file2
8338 $LFS setstripe -c 2 $file3
8340 stack_trap "rm -f $file1 $file2 $file3 $tmp1 $output_file"
8341 dd if=/dev/urandom of=$tmp1 bs=1M count=$size_mb ||
8342 error "error creating $tmp1"
8348 $LFS migrate --stats --stats-interval=1 \
8349 -c 1 $file1 $file2 $file3 1> $output_file ||
8350 error "migrate failed rc = $?"
8353 cat $output_file | verify_yaml || error "rename_stats is not valid YAML"
8355 # Clean up file (since it is multiple MB)
8356 rm -f $file1 $file2 $file3 $tmp1 $output_file
8358 run_test 56xi "lfs migrate stats support"
8360 test_56xj() { # LU-16571 "lfs migrate -b" can cause thread starvation on OSS
8361 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8363 local file=$DIR/$tfile
8364 local linkdir=$DIR/$tdir
8366 test_mkdir $linkdir || error "fail to create $linkdir"
8367 $LFS setstripe -i 0 -c 1 -S1M $file
8368 stack_trap "rm -rf $file $linkdir"
8369 dd if=/dev/urandom of=$file bs=1M count=10 ||
8370 error "fail to create $file"
8377 thread_max=$(do_facet ost1 "$LCTL get_param -n ost.OSS.ost.threads_max")
8378 cpts=$(do_facet ost1 "$LCTL get_param -n cpu_partition_table | wc -l")
8379 (( nlinks = thread_max * 3 / 2 / cpts))
8381 echo "create $nlinks hard links of $file"
8382 createmany -l $file $linkdir/link $nlinks
8384 # Parallel migrates (should not block)
8386 for ((i = 0; i < nlinks; i++)); do
8387 echo $linkdir/link$i
8388 done | xargs -n1 -P $nlinks $LFS migrate -c2
8391 stripe_count=$($LFS getstripe -c $file) ||
8392 error "fail to get stripe count on $file"
8394 ((stripe_count == 2)) ||
8395 error "fail to migrate $file (stripe_count = $stripe_count)"
8397 run_test 56xj "lfs migrate -b should not cause starvation of threads on OSS"
8400 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8403 local file1=$DIR/$tfile
8405 stack_trap "rm -f $file1"
8406 $LFS setstripe -c 1 $file1
8407 dd if=/dev/zero of=$file1 bs=1M count=$size_mb ||
8408 error "error creating $file1"
8409 $LFS mirror extend -N $file1 || error "can't mirror"
8410 dd if=/dev/zero of=$file1 bs=4k count=1 conv=notrunc ||
8412 $LFS getstripe $file1 | grep stale ||
8413 error "one component must be stale"
8415 local start=$SECONDS
8416 $LFS mirror resync --stats --stats-interval=1 -W 1M $file1 ||
8417 error "migrate failed rc = $?"
8418 local elapsed=$((SECONDS - start))
8419 $LFS getstripe $file1 | grep stale &&
8420 error "all components must be sync"
8422 # with 1MB/s, elapsed should equal size_mb
8423 (( elapsed >= size_mb * 95 / 100 )) ||
8424 error "'lfs mirror resync -W' too fast ($elapsed < 0.95 * $size_mb)?"
8426 (( elapsed <= size_mb * 120 / 100 )) ||
8427 error_not_in_vm "'lfs mirror resync -W' slow ($elapsed > 1.2 * $size_mb)"
8429 (( elapsed <= size_mb * 350 / 100 )) ||
8430 error "'lfs mirror resync -W' too slow in VM ($elapsed > 3.5 * $size_mb)"
8432 run_test 56xk "lfs mirror resync bandwidth limitation support"
8435 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8436 verify_yaml_available || skip_env "YAML verification not installed"
8439 local file1=$DIR/$tfile.1
8440 local output_file=$DIR/$tfile.out
8442 stack_trap "rm -f $file1"
8443 $LFS setstripe -c 1 $file1
8444 dd if=/dev/zero of=$file1 bs=1M count=$size_mb ||
8445 error "error creating $file1"
8446 $LFS mirror extend -N $file1 || error "can't mirror"
8447 dd if=/dev/zero of=$file1 bs=4k count=1 conv=notrunc ||
8449 $LFS getstripe $file1 | grep stale ||
8450 error "one component must be stale"
8451 $LFS getstripe $file1
8453 $LFS mirror resync --stats --stats-interval=1 $file1 >$output_file ||
8454 error "resync failed rc = $?"
8455 $LFS getstripe $file1 | grep stale &&
8456 error "all components must be sync"
8459 cat $output_file | verify_yaml || error "stats is not valid YAML"
8461 run_test 56xl "lfs mirror resync stats support"
8464 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
8465 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
8468 local dir=$DIR/$tdir
8472 test_mkdir -p $dir || error "creating dir $dir"
8473 touch $f1 || error "creating std file $f1"
8474 $MULTIOP $f2 H2c || error "creating released file $f2"
8476 # a directory can be raid0, so ask only for files
8477 res=$($LFS find $dir -L raid0 -type f | wc -l)
8478 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
8480 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
8481 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
8483 # only files can be released, so no need to force file search
8484 res=$($LFS find $dir -L released)
8485 [[ $res == $f2 ]] || error "search released: found $res != $f2"
8487 res=$($LFS find $dir -type f \! -L released)
8488 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
8490 run_test 56y "lfs find -L raid0|released"
8492 test_56z() { # LU-4824
8493 # This checks to make sure 'lfs find' continues after errors
8494 # There are two classes of errors that should be caught:
8495 # - If multiple paths are provided, all should be searched even if one
8497 # - If errors are encountered during the search, it should not terminate
8499 local dir=$DIR/$tdir
8503 for i in d{0..9}; do
8505 touch $dir/$i/$tfile
8507 $LFS find $DIR/non_existent_dir $dir &&
8508 error "$LFS find did not return an error"
8509 # Make a directory unsearchable. This should NOT be the last entry in
8510 # directory order. Arbitrarily pick the 6th entry
8511 chmod 700 $($LFS find $dir -type d | sed '6!d')
8513 $RUNAS $LFS find $DIR/non_existent $dir
8514 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
8516 # The user should be able to see 10 directories and 9 files
8517 (( count == 19 )) ||
8518 error "$LFS find found $count != 19 entries after error"
8520 run_test 56z "lfs find should continue after an error"
8522 test_56aa() { # LU-5937
8523 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
8525 local dir=$DIR/$tdir
8528 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
8530 createmany -o $dir/striped_dir/${tfile}- 1024
8531 local dirs=$($LFS find --size +8k $dir/)
8533 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
8535 run_test 56aa "lfs find --size under striped dir"
8537 test_56ab() { # LU-10705
8538 test_mkdir $DIR/$tdir
8539 dd if=/dev/urandom of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
8540 dd if=/dev/urandom of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
8541 dd if=/dev/urandom of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
8542 # Flush writes to ensure valid blocks. Need to be more thorough for
8543 # ZFS, since blocks are not allocated/returned to client immediately.
8545 wait_zfs_commit ost1 2
8546 cancel_lru_locks osc
8549 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
8551 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
8553 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
8554 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
8556 rm -f $DIR/$tdir/$tfile.[123]
8558 run_test 56ab "lfs find --blocks"
8562 local dir="$DIR/$tdir"
8563 local perms=(001 002 003 004 005 006 007
8564 010 020 030 040 050 060 070
8565 100 200 300 400 500 600 700
8566 111 222 333 444 555 666 777)
8567 local perm_minus=(8 8 4 8 4 4 2
8571 local perm_slash=(8 8 12 8 12 12 14
8574 16 16 24 16 24 24 28)
8577 for perm in ${perms[*]}; do
8578 touch "$dir/$tfile.$perm"
8579 chmod $perm "$dir/$tfile.$perm"
8582 for ((i = 0; i < ${#perms[*]}; i++)); do
8583 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
8585 error "lfs find -perm ${perms[i]}:"\
8588 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
8589 (( $num == ${perm_minus[i]} )) ||
8590 error "lfs find -perm -${perms[i]}:"\
8591 "$num != ${perm_minus[i]}"
8593 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
8594 (( $num == ${perm_slash[i]} )) ||
8595 error "lfs find -perm /${perms[i]}:"\
8596 "$num != ${perm_slash[i]}"
8599 run_test 56aca "check lfs find -perm with octal representation"
8602 local dir=$DIR/$tdir
8603 # p is the permission of write and execute for user, group and other
8604 # without the umask. It is used to test +wx.
8605 local p=$(printf "%o" "$((0333 & ~$(umask)))")
8606 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
8607 local symbolic=(+t a+t u+t g+t o+t
8613 o=r,ug+o,u+w u=r,a+u,u+w
8614 g=r,ugo=g,u+w u+x,+X +X
8615 u+x,u+X u+X u+x,g+X o+r,+X
8619 for perm in ${perms[*]}; do
8620 touch "$dir/$tfile.$perm"
8621 chmod $perm "$dir/$tfile.$perm"
8624 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
8625 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
8628 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
8631 run_test 56acb "check lfs find -perm with symbolic representation"
8634 local dir=$DIR/$tdir
8635 local tests="17777 787 789 abcd
8636 ug=uu ug=a ug=gu uo=ou urw
8640 for err in $tests; do
8641 if $LFS find $dir -perm $err 2>/dev/null; then
8642 error "lfs find -perm $err: parsing should have failed"
8646 run_test 56acc "check parsing error for lfs find -perm"
8649 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
8650 skip "Need MDS version at least 2.10.50"
8652 # Create composite files with one component
8653 local dir=$DIR/$tdir
8655 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
8656 # Create composite files with three components
8657 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
8658 # LU-16904 Create plain layout files
8659 lfs setstripe -c 1 $dir/$tfile-{1..10}
8661 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
8663 [[ $nfiles == 10 ]] ||
8664 error "lfs find -E 1M found $nfiles != 10 files"
8666 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
8667 [[ $nfiles == 25 ]] ||
8668 error "lfs find ! -E 1M found $nfiles != 25 files"
8670 # All files have a component that starts at 0
8671 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
8672 [[ $nfiles == 35 ]] ||
8673 error "lfs find --component-start 0 - $nfiles != 35 files"
8675 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
8676 [[ $nfiles == 15 ]] ||
8677 error "lfs find --component-start 2M - $nfiles != 15 files"
8679 # All files created here have a componenet that does not starts at 2M
8680 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
8681 [[ $nfiles == 35 ]] ||
8682 error "lfs find ! --component-start 2M - $nfiles != 35 files"
8684 # Find files with a specified number of components
8685 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
8686 [[ $nfiles == 15 ]] ||
8687 error "lfs find --component-count 3 - $nfiles != 15 files"
8689 # Remember non-composite files have a component count of zero
8690 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
8691 [[ $nfiles == 10 ]] ||
8692 error "lfs find --component-count 0 - $nfiles != 10 files"
8694 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
8695 [[ $nfiles == 20 ]] ||
8696 error "lfs find ! --component-count 3 - $nfiles != 20 files"
8698 # All files have a flag called "init"
8699 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
8700 [[ $nfiles == 35 ]] ||
8701 error "lfs find --component-flags init - $nfiles != 35 files"
8703 # Multi-component files will have a component not initialized
8704 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
8705 [[ $nfiles == 15 ]] ||
8706 error "lfs find !--component-flags init - $nfiles != 15 files"
8711 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
8714 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
8715 skip "Need MDS version at least 2.10.57"
8725 # create mirrored directories and mirrored files
8726 mkdir $td || error "mkdir $td failed"
8727 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
8728 createmany -o $tf- 10 || error "create $tf- failed"
8730 for i in $(seq 2); do
8732 mkdir $dir || error "mkdir $dir failed"
8733 $LFS mirror create -N$((3 + i)) $dir ||
8734 error "create mirrored dir $dir failed"
8735 createmany -o $dir/$tfile- 10 ||
8736 error "create $dir/$tfile- failed"
8739 # change the states of some mirrored files
8741 for i in $(seq 2); do
8743 for j in $(seq 4 9); do
8744 echo foo > $dir/$tfile-$j
8748 # find mirrored files with specific mirror count
8749 cmd="$LFS find --mirror-count 3 --type f $td"
8750 nfiles=$($cmd | wc -l)
8751 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
8753 cmd="$LFS find ! --mirror-count 3 --type f $td"
8754 nfiles=$($cmd | wc -l)
8755 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
8757 cmd="$LFS find --mirror-count +2 --type f $td"
8758 nfiles=$($cmd | wc -l)
8759 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8761 cmd="$LFS find --mirror-count -6 --type f $td"
8762 nfiles=$($cmd | wc -l)
8763 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8765 # find mirrored files with specific file state
8766 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
8767 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
8769 cmd="$LFS find --mirror-state=ro --type f $td"
8770 nfiles=$($cmd | wc -l)
8771 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
8773 cmd="$LFS find ! --mirror-state=ro --type f $td"
8774 nfiles=$($cmd | wc -l)
8775 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8777 cmd="$LFS find --mirror-state=wp --type f $td"
8778 nfiles=$($cmd | wc -l)
8779 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8781 cmd="$LFS find ! --mirror-state=sp --type f $td"
8782 nfiles=$($cmd | wc -l)
8783 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8785 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
8787 test_56da() { # LU-14179
8788 local path=$DIR/$tdir
8793 local longdir=$(str_repeat 'a' 255)
8795 for i in {1..15}; do
8802 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
8807 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
8810 touch $(str_repeat 'f' 255)
8812 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
8813 error "lfs find reported an error"
8817 run_test 56da "test lfs find with long paths"
8819 test_56ea() { #LU-10378
8820 local path=$DIR/$tdir
8821 local pool=$TESTNAME
8824 pool_add $pool || error "pool_add $pool failed"
8825 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8826 error "adding targets to $pool failed"
8828 # Set default pool on directory before creating file
8829 mkdir $path || error "mkdir $path failed"
8830 $LFS setstripe -p $pool $path ||
8831 error "set OST pool on $pool failed"
8832 touch $path/$tfile || error "touch $path/$tfile failed"
8834 # Compare basic file attributes from -printf and stat
8835 local attr_printf=$($LFS find $path/$tfile -printf "%A@ %T@ %C@ %U %G %n")
8836 local attr_stat=$(stat -c "%X %Y %Z %u %g %h" $path/$tfile)
8838 [[ "${attr_printf}" == "${attr_stat}" ]] ||
8839 error "Attrs from lfs find and stat don't match"
8841 # Compare Lustre attributes from lfs find and lfs getstripe
8842 local lattr_printf=$($LFS find $path/$tfile -printf "%Lc %LS %Li %Lp")
8843 local str_cnt=$($LFS getstripe --stripe-count $path/$tfile)
8844 local str_size=$($LFS getstripe --stripe-size $path/$tfile)
8845 local str_idx=$($LFS getstripe --stripe-index $path/$tfile)
8846 local fpool=$($LFS getstripe --pool $path/$tfile)
8847 local lattr_getstr="${str_cnt} ${str_size} ${str_idx} ${fpool}"
8849 [[ "${lattr_printf}" == "${lattr_getstr}" ]] ||
8850 error "Attrs from lfs find and lfs getstripe don't match"
8852 # Verify behavior for unknown escape/format sequences
8853 local esc_printf=$($LFS find $path/$tfile -printf '\\ %% \Q %Q')
8855 [[ "${esc_printf}" == '\ % \Q %Q' ]] ||
8856 error "Escape/format codes don't match"
8858 run_test 56ea "test lfs find -printf option"
8861 local dir=$DIR/$tdir
8862 local subdir_1=$dir/subdir_1
8864 test_mkdir -p $subdir_1
8865 ln -s subdir_1 $dir/link_1
8867 $LFS getstripe $dir | grep "^$dir/link_1$" -A1 ||
8868 error "symlink is not followed"
8870 $LFS getstripe --no-follow $dir |
8871 grep "^$dir/link_1 has no stripe info$" ||
8872 error "symlink should not have stripe info"
8875 ln -s testfile $dir/file_link_2
8877 $LFS getstripe $dir | grep "^$dir/file_link_2$" -A1 ||
8878 error "symlink is not followed"
8880 $LFS getstripe --no-follow $dir |
8881 grep "^$dir/file_link_2 has no stripe info$" ||
8882 error "symlink should not have stripe info"
8884 run_test 56eb "check lfs getstripe on symlink"
8887 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8888 local dir=$DIR/$tdir
8889 local srcfile=$dir/srcfile
8890 local srcyaml=$dir/srcyaml
8891 local destfile=$dir/destfile
8895 $LFS setstripe -i 1 $srcfile
8896 $LFS getstripe --hex-idx --yaml $srcfile > $srcyaml
8897 # if the setstripe yaml parsing fails for any reason, the command can
8898 # randomly assign the correct OST index, leading to an erroneous
8899 # success. but the chance of false success is low enough that a
8900 # regression should still be quickly caught.
8901 $LFS setstripe --yaml=$srcyaml $destfile
8903 local srcindex=$($LFS getstripe -i $srcfile)
8904 local destindex=$($LFS getstripe -i $destfile)
8906 if [[ ! $srcindex -eq $destindex ]]; then
8907 error "setstripe did not set OST index correctly"
8910 run_test 56ec "check lfs getstripe,setstripe --hex --yaml"
8913 local dir=$DIR/$tdir
8914 local subdir=$dir/subdir
8915 local file1=$dir/$tfile
8916 local file2=$dir/$tfile\2
8917 local link=$dir/$tfile-link
8921 $LFS setdirstripe -c1 $subdir
8926 nfiles=$($LFS find --links 1 $dir | wc -l)
8927 (( $nfiles == 1 )) ||
8928 error "lfs find --links expected 1 file, got $nfiles"
8930 nfiles=$($LFS find --type f --links 2 $dir | wc -l)
8931 (( $nfiles == 2 )) ||
8932 error "lfs find --links expected 2 files, got $nfiles"
8934 nfiles=$($LFS find --type d --links 2 $dir | wc -l)
8935 (( $nfiles == 1 )) ||
8936 error "lfs find --links expected 1 directory, got $nfiles"
8938 run_test 56eda "check lfs find --links"
8941 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
8943 local dir=$DIR/$tdir
8944 local stripedir=$dir/stripedir
8949 $LFS setdirstripe -c2 $stripedir
8951 $LFS getdirstripe $stripedir
8953 nfiles=$($LFS find --type d --links 2 $stripedir | wc -l)
8954 (( $nfiles == 1 )) ||
8955 error "lfs find --links expected 1 directory, got $nfiles"
8957 run_test 56edb "check lfs find --links for directory striped on multiple MDTs"
8960 local dir=$DIR/$tdir
8973 nfiles=$($LFS find $dir1 $dir2 ! -type d | wc -l)
8974 (( $nfiles == 2 )) ||
8975 error "(1) lfs find expected 2 files, got $nfiles"
8977 nfiles=$($LFS find $dir1 $dir2 -type f | wc -l)
8978 (( $nfiles == 2 )) ||
8979 error "(2) lfs find expected 2 files, got $nfiles"
8981 nfiles=$($LFS find -type f $dir1 $dir2 | wc -l)
8982 (( $nfiles == 2 )) ||
8983 error "(3) lfs find expected 2 files, got $nfiles"
8985 run_test 56ef "lfs find with multiple paths"
8988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8989 # note test will not do anything if MDS is not local
8990 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8991 skip_env "ldiskfs only test"
8993 remote_mds_nodsh && skip "remote MDS with nodsh"
8995 local MNTDEV="osd*.*MDT*.mntdev"
8996 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
8997 [ -z "$DEV" ] && error "can't access $MNTDEV"
8998 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
8999 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
9000 error "can't access $DEV"
9001 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
9002 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
9006 run_test 57a "verify MDS filesystem created with large inodes =="
9009 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9010 if [ "$mds1_FSTYPE" != ldiskfs ]; then
9011 skip_env "ldiskfs only test"
9013 remote_mds_nodsh && skip "remote MDS with nodsh"
9015 local dir=$DIR/$tdir
9018 local fileN=$dir/f$filecount
9020 rm -rf $dir || error "removing $dir"
9022 local mdtidx=$($LFS getstripe -m $dir)
9023 local mdtname=MDT$(printf %04x $mdtidx)
9024 local facet=mds$((mdtidx + 1))
9026 echo "mcreating $filecount files"
9027 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
9029 # verify that files do not have EAs yet
9030 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
9031 error "$file1 has an EA"
9032 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
9033 error "$fileN has an EA"
9037 df $dir #make sure we get new statfs data
9038 local mdsfree=$(do_facet $facet \
9039 lctl get_param -n osd*.*$mdtname.kbytesfree)
9040 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
9043 echo "opening files to create objects/EAs"
9044 for file in $(seq -f $dir/f%g 1 $filecount); do
9045 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
9046 error "opening $file"
9049 # verify that files have EAs now
9050 $LFS getstripe -y $file1 | grep -q "l_ost_idx" ||
9051 error "$file1 missing EA"
9052 $LFS getstripe -y $fileN | grep -q "l_ost_idx" ||
9053 error "$fileN missing EA"
9055 sleep 1 #make sure we get new statfs data
9057 local mdsfree2=$(do_facet $facet \
9058 lctl get_param -n osd*.*$mdtname.kbytesfree)
9059 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
9061 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
9062 if [ "$mdsfree" != "$mdsfree2" ]; then
9063 error "MDC before $mdcfree != after $mdcfree2"
9065 echo "MDC before $mdcfree != after $mdcfree2"
9066 echo "unable to confirm if MDS has large inodes"
9071 run_test 57b "default LOV EAs are stored inside large inodes ==="
9074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9075 [ -z "$(which wiretest 2>/dev/null)" ] &&
9076 skip_env "could not find wiretest"
9080 run_test 58 "verify cross-platform wire constants =============="
9083 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9085 echo "touch 130 files"
9086 createmany -o $DIR/f59- 130
9088 unlinkmany $DIR/f59- 130
9090 # wait for commitment of removal
9091 wait_delete_completed
9093 run_test 59 "verify cancellation of llog records async ========="
9095 TEST60_HEAD="test_60 run $RANDOM"
9097 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9098 remote_mgs_nodsh && skip "remote MGS with nodsh"
9099 do_facet mgs "! which run-llog.sh &> /dev/null" &&
9100 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
9101 skip_env "missing subtest run-llog.sh"
9103 log "$TEST60_HEAD - from kernel mode"
9104 do_facet mgs "$LCTL dk > /dev/null"
9105 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
9106 do_facet mgs $LCTL dk > $TMP/$tfile
9108 # LU-6388: test llog_reader
9109 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
9110 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
9111 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
9112 skip_env "missing llog_reader"
9113 local fstype=$(facet_fstype mgs)
9114 [ $fstype != ldiskfs -a $fstype != zfs ] &&
9115 skip_env "Only for ldiskfs or zfs type mgs"
9117 local mntpt=$(facet_mntpt mgs)
9118 local mgsdev=$(mgsdevname 1)
9130 #get fid and record list
9131 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
9133 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
9135 #remount mgs as ldiskfs or zfs type
9136 stop mgs || error "stop mgs failed"
9137 mount_fstype mgs || error "remount mgs failed"
9138 for ((i = 0; i < ${#fid_list[@]}; i++)); do
9141 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
9142 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
9147 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
9149 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
9151 echo "obj_file is $obj_file"
9152 do_facet mgs $llog_reader $obj_file
9154 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
9155 awk '{ print $3 }' | sed -e "s/^type=//g")
9156 if [ $rec_type != $rec ]; then
9157 echo "FAILED test_60a wrong record type $rec_type," \
9163 #check obj path if record type is LLOG_LOGID_MAGIC
9164 if [ "$rec" == "1064553b" ]; then
9165 path=$(do_facet mgs $llog_reader $obj_file |
9166 grep "path=" | awk '{ print $NF }' |
9167 sed -e "s/^path=//g")
9168 if [ $obj_file != $mntpt/$path ]; then
9169 echo "FAILED test_60a wrong obj path" \
9170 "$montpt/$path, should be $obj_file"
9177 #restart mgs before "error", otherwise it will block the next test
9178 stop mgs || error "stop mgs failed"
9179 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
9180 $pass || error "test failed, see FAILED test_60a messages for specifics"
9182 run_test 60a "llog_test run from kernel module and test llog_reader"
9184 test_60b() { # bug 6411
9185 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9188 LLOG_COUNT=$(do_facet mgs dmesg |
9189 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
9190 /llog_[a-z]*.c:[0-9]/ {
9202 [[ $LLOG_COUNT -gt 120 ]] &&
9203 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
9205 run_test 60b "limit repeated messages from CERROR/CWARN"
9208 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9210 echo "create 5000 files"
9211 createmany -o $DIR/f60c- 5000
9212 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
9213 lctl set_param fail_loc=0x80000137
9214 unlinkmany $DIR/f60c- 5000
9215 lctl set_param fail_loc=0
9217 run_test 60c "unlink file when mds full"
9220 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9222 SAVEPRINTK=$(lctl get_param -n printk)
9223 # verify "lctl mark" is even working"
9224 MESSAGE="test message ID $RANDOM $$"
9225 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
9226 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
9228 lctl set_param printk=0 || error "set lnet.printk failed"
9229 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
9230 MESSAGE="new test message ID $RANDOM $$"
9231 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
9232 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
9233 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
9235 lctl set_param -n printk="$SAVEPRINTK"
9237 run_test 60d "test printk console message masking"
9240 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9241 remote_mds_nodsh && skip "remote MDS with nodsh"
9244 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
9245 do_facet mds1 lctl set_param fail_loc=0x15b
9248 run_test 60e "no space while new llog is being created"
9251 local old_path=$($LCTL get_param -n debug_path)
9253 stack_trap "$LCTL set_param debug_path=$old_path"
9254 stack_trap "rm -f $TMP/$tfile*"
9255 rm -f $TMP/$tfile* 2> /dev/null
9256 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
9257 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
9258 test_mkdir $DIR/$tdir
9259 # retry in case the open is cached and not released
9260 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
9261 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
9265 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
9267 run_test 60f "change debug_path works"
9273 test_mkdir -c $MDSCOUNT $DIR/$tdir
9278 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
9279 -c $MDSCOUNT $DIR/$tdir/subdir$index \
9281 mkdir $DIR/$tdir/subdir$index 2>/dev/null
9282 rmdir $DIR/$tdir/subdir$index 2>/dev/null
9283 index=$((index + 1))
9289 for i in {0..100}; do
9290 # define OBD_FAIL_OSD_TXN_START 0x19a
9291 local index=$((i % MDSCOUNT + 1))
9293 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
9300 for i in $(seq $MDSCOUNT); do
9301 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
9304 mkdir $DIR/$tdir/new || error "mkdir failed"
9305 rmdir $DIR/$tdir/new || error "rmdir failed"
9307 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
9309 for i in $(seq $MDSCOUNT); do
9310 wait_update_facet mds$i "$LCTL get_param -n \
9311 mdd.$(facet_svc mds$i).lfsck_namespace |
9312 awk '/^status/ { print \\\$2 }'" "completed"
9316 rm -rf $DIR/$tdir || error "rmdir failed"
9318 run_test 60g "transaction abort won't cause MDT hung"
9321 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
9322 skip "Need MDS version at least 2.12.52"
9323 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
9327 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
9328 #define OBD_FAIL_MDS_STRIPE_FID 0x189
9329 for fail_loc in 0x80000188 0x80000189; do
9330 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
9331 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
9332 error "mkdir $dir-$fail_loc failed"
9333 for i in {0..10}; do
9334 # create may fail on missing stripe
9335 echo $i > $DIR/$tdir-$fail_loc/$i
9337 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
9338 error "getdirstripe $tdir-$fail_loc failed"
9339 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
9340 error "migrate $tdir-$fail_loc failed"
9341 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
9342 error "getdirstripe $tdir-$fail_loc failed"
9343 pushd $DIR/$tdir-$fail_loc
9345 echo $f | cmp $f - || error "$f data mismatch"
9348 rm -rf $DIR/$tdir-$fail_loc
9351 run_test 60h "striped directory with missing stripes can be accessed"
9353 function t60i_load() {
9355 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
9356 $LCTL set_param fail_loc=0x131c fail_val=1
9357 for ((i=0; i<5000; i++)); do
9358 touch $DIR/$tdir/f$i
9363 changelog_register || error "changelog_register failed"
9364 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
9365 changelog_users $SINGLEMDS | grep -q $cl_user ||
9366 error "User $cl_user not found in changelog_users"
9367 changelog_chmask "ALL"
9370 for((i=0; i<100; i++)); do
9371 changelog_dump >/dev/null ||
9372 error "can't read changelog"
9376 changelog_deregister || error "changelog_deregister failed"
9377 $LCTL set_param fail_loc=0
9379 run_test 60i "llog: new record vs reader race"
9382 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
9383 skip "need MDS version at least 2.15.50"
9384 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9385 remote_mds_nodsh && skip "remote MDS with nodsh"
9386 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
9388 changelog_users $SINGLEMDS | grep "^cl" &&
9389 skip "active changelog user"
9391 local llog_reader=$(do_facet $SINGLEMDS "which llog_reader 2> /dev/null")
9393 [[ -z $(do_facet $SINGLEMDS ls -d $llog_reader 2> /dev/null) ]] &&
9394 skip_env "missing llog_reader"
9396 mkdir_on_mdt0 $DIR/$tdir
9398 local f=$DIR/$tdir/$tfile
9403 changelog_register || error "cannot register changelog user"
9405 # set changelog_mask to ALL
9406 changelog_chmask "ALL"
9409 createmany -o ${f}- 100 || error "createmany failed as $RUNAS_ID"
9410 unlinkmany ${f}- 100 || error "unlinkmany failed"
9412 tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
9413 mdt_dev=$(facet_device $SINGLEMDS)
9415 do_facet $SINGLEMDS sync
9416 plain=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'dump changelog_catalog \
9417 $tmpfile' $mdt_dev; $llog_reader $tmpfile" |
9418 awk '{match($0,"path=([^ ]+)",a)}END{print a[1]}')
9420 stack_trap "do_facet $SINGLEMDS rm -f $tmpfile"
9422 # if $tmpfile is not on EXT3 filesystem for some reason
9423 [[ ${plain:0:1} == 'O' ]] ||
9424 skip "path $plain is not in 'O/1/d<n>/<n>' format"
9426 size=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'dump $plain $tmpfile' \
9427 $mdt_dev; stat -c %s $tmpfile")
9428 echo "Truncate llog from $size to $((size - size % 8192))"
9429 size=$((size - size % 8192))
9430 do_facet $SINGLEMDS $TRUNCATE $tmpfile $size
9431 errs=$(do_facet $SINGLEMDS "$llog_reader $tmpfile" |
9432 grep -c 'in bitmap only')
9433 (( $errs > 0 )) || error "llog_reader didn't find lost records"
9435 size=$((size - 9000))
9436 echo "Corrupt llog in the middle at $size"
9437 do_facet $SINGLEMDS dd if=/dev/urandom of=$tmpfile bs=1 seek=$size \
9438 count=333 conv=notrunc
9439 errs=$(do_facet $SINGLEMDS "$llog_reader $tmpfile" |
9440 grep -c 'next chunk')
9441 (( $errs > 0 )) || error "llog_reader didn't skip bad chunk"
9443 run_test 60j "llog_reader reports corruptions"
9446 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9449 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
9450 cancel_lru_locks osc
9451 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
9454 run_test 61a "mmap() writes don't make sync hang ================"
9457 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
9459 run_test 61b "mmap() of unstriped file is successful"
9461 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
9462 # Though this test is irrelevant anymore, it helped to reveal some
9463 # other grant bugs (LU-4482), let's keep it.
9464 test_63a() { # was test_63
9465 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9467 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
9469 for i in `seq 10` ; do
9470 dd if=/dev/zero of=$DIR/f63 bs=8k &
9476 rm -f $DIR/f63 || true
9478 run_test 63a "Verify oig_wait interruption does not crash ======="
9480 # bug 2248 - async write errors didn't return to application on sync
9481 # bug 3677 - async write errors left page locked
9483 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9486 lctl set_param debug=-1
9488 # ensure we have a grant to do async writes
9489 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
9492 sync # sync lest earlier test intercept the fail_loc
9494 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9495 lctl set_param fail_loc=0x80000406
9496 $MULTIOP $DIR/$tfile Owy && \
9497 error "sync didn't return ENOMEM"
9498 sync; sleep 2; sync # do a real sync this time to flush page
9499 lctl get_param -n llite.*.dump_page_cache | grep locked && \
9500 error "locked page left in cache after async error" || true
9503 run_test 63b "async write errors should be returned to fsync ==="
9506 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9509 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
9511 run_test 64a "verify filter grant calculations (in kernel) ====="
9514 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9516 bash oos.sh $MOUNT || error "oos.sh failed: $?"
9518 run_test 64b "check out-of-space detection on client"
9521 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
9523 run_test 64c "verify grant shrink"
9529 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
9532 # this does exactly what osc_request.c:osc_announce_cached() does in
9533 # order to calculate max amount of grants to ask from server
9537 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
9538 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
9540 ((rpc_in_flight++));
9541 nrpages=$((nrpages * rpc_in_flight))
9543 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
9545 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
9547 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
9548 local undirty=$((nrpages * PAGE_SIZE))
9550 local max_extent_pages
9551 max_extent_pages=$(import_param $tgt grant_max_extent_size)
9552 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
9553 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
9554 local grant_extent_tax
9555 grant_extent_tax=$(import_param $tgt grant_extent_tax)
9557 undirty=$((undirty + nrextents * grant_extent_tax))
9562 # this is size of unit for grant allocation. It should be equal to
9563 # what tgt_grant.c:tgt_grant_chunk() calculates
9567 local grant_extent_tax
9569 max_brw_size=$(import_param $tgt max_brw_size)
9571 grant_extent_tax=$(import_param $tgt grant_extent_tax)
9573 echo $(((max_brw_size + grant_extent_tax) * 2))
9577 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
9578 skip "OST < 2.10.55 doesn't limit grants enough"
9580 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
9582 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
9583 skip "no grant_param connect flag"
9585 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9587 $LCTL set_param -n -n debug="$OLDDEBUG" || true
9588 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9591 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
9592 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
9594 $LFS setstripe $DIR/$tfile -i 0 -c 1
9595 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
9598 while kill -0 $ddpid; do
9599 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
9601 if [[ $cur_grant -gt $max_cur_granted ]]; then
9603 error "cur_grant $cur_grant > $max_cur_granted"
9609 run_test 64d "check grant limit exceed"
9615 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
9617 ((cur_grants == expected)) ||
9618 error "$msg: grants mismatch: $cur_grants, expected $expected"
9622 echo $((($1 + $2 - 1) & ~($2 - 1)))
9626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9627 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
9628 skip "Need OSS version at least 2.11.56"
9630 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9631 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9632 $LCTL set_param debug=+cache
9634 # Remount client to reset grant
9635 remount_client $MOUNT || error "failed to remount client"
9636 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9638 local init_grants=$(import_param $osc_tgt initial_grant)
9640 check_grants $osc_tgt $init_grants "init grants"
9642 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9643 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9644 local gbs=$(import_param $osc_tgt grant_block_size)
9646 # write random number of bytes from max_brw_size / 4 to max_brw_size
9647 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9648 # align for direct io
9649 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9650 # round to grant consumption unit
9651 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9653 local grants=$((wb_round_up + extent_tax))
9655 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9656 stack_trap "rm -f $DIR/$tfile"
9658 # define OBD_FAIL_TGT_NO_GRANT 0x725
9659 # make the server not grant more back
9660 do_facet ost1 $LCTL set_param fail_loc=0x725
9661 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
9663 do_facet ost1 $LCTL set_param fail_loc=0
9665 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
9667 rm -f $DIR/$tfile || error "rm failed"
9669 # Remount client to reset grant
9670 remount_client $MOUNT || error "failed to remount client"
9671 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9673 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9675 # define OBD_FAIL_TGT_NO_GRANT 0x725
9676 # make the server not grant more back
9677 do_facet ost1 $LCTL set_param fail_loc=0x725
9678 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
9679 do_facet ost1 $LCTL set_param fail_loc=0
9681 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
9683 run_test 64e "check grant consumption (no grant allocation)"
9686 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9688 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9689 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9690 $LCTL set_param debug=+cache
9692 # Remount client to reset grant
9693 remount_client $MOUNT || error "failed to remount client"
9694 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9696 local init_grants=$(import_param $osc_tgt initial_grant)
9697 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9698 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9699 local gbs=$(import_param $osc_tgt grant_block_size)
9700 local chunk=$(grant_chunk $osc_tgt)
9702 # write random number of bytes from max_brw_size / 4 to max_brw_size
9703 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9704 # align for direct io
9705 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9706 # round to grant consumption unit
9707 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9709 local grants=$((wb_round_up + extent_tax))
9711 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9712 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
9713 error "error writing to $DIR/$tfile"
9715 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9716 "direct io with grant allocation"
9718 rm -f $DIR/$tfile || error "rm failed"
9720 # Remount client to reset grant
9721 remount_client $MOUNT || error "failed to remount client"
9722 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9724 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9726 # Testing that buffered IO consumes grant on the client
9728 # Delay the RPC on the server so it's guaranteed to not complete even
9729 # if the RPC is sent from the client
9730 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
9731 $LCTL set_param fail_loc=0x50a fail_val=3
9732 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 conv=notrunc ||
9733 error "error writing to $DIR/$tfile with buffered IO"
9735 check_grants $osc_tgt $((init_grants - grants)) \
9736 "buffered io, not write rpc"
9738 # Clear the fail loc and do a sync on the client
9739 $LCTL set_param fail_loc=0 fail_val=0
9742 # RPC is now known to have sent
9743 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9744 "buffered io, one RPC"
9746 run_test 64f "check grant consumption (with grant allocation)"
9749 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
9750 skip "Need MDS version at least 2.14.56"
9752 local mdts=$(comma_list $(mdts_nodes))
9754 local old=$($LCTL get_param mdc.$FSNAME-*.grant_shrink_interval |
9756 stack_trap "$LCTL set_param $old"
9758 # generate dirty pages and increase dirty granted on MDT
9759 stack_trap "rm -f $DIR/$tfile-*"
9760 for (( i = 0; i < 10; i++)); do
9761 $LFS setstripe -E 1M -L mdt $DIR/$tfile-$i ||
9762 error "can't set stripe"
9763 dd if=/dev/zero of=$DIR/$tfile-$i bs=128k count=1 ||
9765 $LFS getstripe $DIR/$tfile-$i | grep -q pattern.*mdt || {
9766 $LFS getstripe $DIR/$tfile-$i
9767 error "not DoM file"
9774 # wait until grant shrink reset grant dirty on MDTs
9775 for ((i = 0; i < 120; i++)); do
9776 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9777 awk '{sum=sum+$1} END {print sum}')
9778 vm_dirty=$(awk '/Dirty:/{print $2}' /proc/meminfo)
9779 echo "$grant_dirty grants, $vm_dirty pages"
9780 (( grant_dirty + vm_dirty == 0 )) && break
9781 (( i == 3 )) && sync &&
9782 $LCTL set_param mdc.$FSNAME-*.grant_shrink_interval=5
9786 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9787 awk '{sum=sum+$1} END {print sum}')
9788 (( grant_dirty == 0 )) || error "$grant_dirty on MDT"
9790 run_test 64g "grant shrink on MDT"
9793 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9794 skip "need OST at least 2.14.56 to avoid grant shrink on read"
9796 local instance=$($LFS getname -i $DIR)
9797 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9798 local num_exps=$(do_facet ost1 \
9799 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
9800 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9801 local avail=$($LCTL get_param -n osc.*OST0000-osc-$instance.kbytesavail)
9802 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9804 # 10MiB is for file to be written, max_brw_size * 16 *
9805 # num_exps is space reserve so that tgt_grant_shrink() decided
9807 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
9808 (( avail * 1024 < expect )) &&
9809 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
9811 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
9812 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
9813 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
9814 $LCTL set_param osc.*OST0000*.grant_shrink=1
9815 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
9817 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9818 stack_trap "rm -f $DIR/$tfile"
9819 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
9821 # drop cache so that coming read would do rpc
9822 cancel_lru_locks osc
9824 # shrink interval is set to 10, pause for 7 seconds so that
9825 # grant thread did not wake up yet but coming read entered
9826 # shrink mode for rpc (osc_should_shrink_grant())
9829 declare -a cur_grant_bytes
9830 declare -a tot_granted
9831 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9832 tot_granted[0]=$(do_facet ost1 \
9833 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9835 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
9837 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9838 tot_granted[1]=$(do_facet ost1 \
9839 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9841 # grant change should be equal on both sides
9842 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
9843 tot_granted[0] - tot_granted[1])) ||
9844 error "grant change mismatch, " \
9845 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
9846 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
9848 run_test 64h "grant shrink on read"
9851 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9852 skip "need OST at least 2.14.56 to avoid grant shrink on replay"
9854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9855 remote_ost_nodsh && skip "remote OSTs with nodsh"
9857 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9858 stack_trap "rm -f $DIR/$tfile"
9860 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
9862 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
9863 local instance=$($LFS getname -i $DIR)
9865 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9866 local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
9868 # shrink grants and simulate rpc loss
9869 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
9870 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
9871 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
9875 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
9877 local testid=$(echo $TESTNAME | tr '_' ' ')
9879 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
9880 grep "GRANT, real grant" &&
9881 error "client has more grants then it owns" || true
9883 run_test 64i "shrink on reconnect"
9885 # bug 1414 - set/get directories' stripe info
9887 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9889 test_mkdir $DIR/$tdir
9891 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
9893 run_test 65a "directory with no stripe info"
9896 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9898 test_mkdir $DIR/$tdir
9899 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9901 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9904 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
9906 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
9909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9910 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
9912 test_mkdir $DIR/$tdir
9913 local stripesize=$($LFS getstripe -S $DIR/$tdir)
9915 $LFS setstripe -S $((stripesize * 4)) -i 1 \
9916 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
9918 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
9920 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
9923 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9925 test_mkdir $DIR/$tdir
9926 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
9927 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9929 if [[ $STRIPECOUNT -le 0 ]]; then
9931 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
9932 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
9933 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
9935 sc=$(($STRIPECOUNT - 1))
9937 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
9938 touch $DIR/$tdir/f4 $DIR/$tdir/f5
9939 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
9940 error "lverify failed"
9942 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
9945 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9947 # LU-16904 delete layout when root is set as PFL layout
9948 save_layout_restore_at_exit $MOUNT
9949 $LFS setstripe -d $MOUNT || error "setstripe failed"
9951 test_mkdir $DIR/$tdir
9953 $LFS setstripe $DIR/$tdir || error "setstripe"
9954 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9955 error "no stripe info failed"
9957 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
9959 run_test 65e "directory setstripe defaults"
9962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9964 test_mkdir $DIR/${tdir}f
9965 $RUNAS $LFS setstripe $DIR/${tdir}f &&
9966 error "setstripe succeeded" || true
9968 run_test 65f "dir setstripe permission (should return error) ==="
9971 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9973 # LU-16904 delete layout when root is set as PFL layout
9974 save_layout_restore_at_exit $MOUNT
9975 $LFS setstripe -d $MOUNT || error "setstripe failed"
9977 test_mkdir $DIR/$tdir
9978 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9980 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9981 error "setstripe -S failed"
9982 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
9983 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9984 error "delete default stripe failed"
9986 run_test 65g "directory setstripe -d"
9989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9991 test_mkdir $DIR/$tdir
9992 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9994 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9995 error "setstripe -S failed"
9996 test_mkdir $DIR/$tdir/dd1
9997 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
9998 error "stripe info inherit failed"
10000 run_test 65h "directory stripe info inherit ===================="
10003 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10005 save_layout_restore_at_exit $MOUNT
10007 # bug6367: set non-default striping on root directory
10008 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
10010 # bug12836: getstripe on -1 default directory striping
10011 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
10013 # bug12836: getstripe -v on -1 default directory striping
10014 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
10016 # bug12836: new find on -1 default directory striping
10017 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
10019 run_test 65i "various tests to set root directory striping"
10021 test_65j() { # bug6367
10022 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10026 # if we aren't already remounting for each test, do so for this test
10027 if [ "$I_MOUNTED" = "yes" ]; then
10028 cleanup || error "failed to unmount"
10032 save_layout_restore_at_exit $MOUNT
10034 $LFS setstripe -d $MOUNT || error "setstripe failed"
10036 run_test 65j "set default striping on root directory (bug 6367)="
10040 wait_delete_completed
10041 do_facet $SINGLEMDS "lctl set_param -n \
10042 osp.$ost*MDT0000.max_create_count=$max_count"
10043 do_facet $SINGLEMDS "lctl set_param -n \
10044 osp.$ost*MDT0000.create_count=$count"
10045 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
10046 echo $INACTIVE_OSC "is Activate"
10048 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
10051 test_65k() { # bug11679
10052 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10053 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10054 remote_mds_nodsh && skip "remote MDS with nodsh"
10056 local disable_precreate=true
10057 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
10058 disable_precreate=false
10060 echo "Check OST status: "
10061 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
10062 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
10064 for OSC in $MDS_OSCS; do
10065 echo $OSC "is active"
10066 do_facet $SINGLEMDS lctl --device %$OSC activate
10069 for INACTIVE_OSC in $MDS_OSCS; do
10070 local ost=$(osc_to_ost $INACTIVE_OSC)
10071 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
10072 lov.*md*.target_obd |
10073 awk -F: /$ost/'{ print $1 }' | head -n 1)
10075 mkdir -p $DIR/$tdir
10076 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
10077 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
10079 echo "Deactivate: " $INACTIVE_OSC
10080 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
10082 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
10083 osp.$ost*MDT0000.create_count")
10084 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
10085 osp.$ost*MDT0000.max_create_count")
10086 $disable_precreate &&
10087 do_facet $SINGLEMDS "lctl set_param -n \
10088 osp.$ost*MDT0000.max_create_count=0"
10090 for idx in $(seq 0 $((OSTCOUNT - 1))); do
10091 [ -f $DIR/$tdir/$idx ] && continue
10092 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
10093 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
10095 error "setstripe $idx should succeed"; }
10096 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
10098 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
10101 do_facet $SINGLEMDS "lctl set_param -n \
10102 osp.$ost*MDT0000.max_create_count=$max_count"
10103 do_facet $SINGLEMDS "lctl set_param -n \
10104 osp.$ost*MDT0000.create_count=$count"
10105 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
10106 echo $INACTIVE_OSC "is Activate"
10108 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
10111 run_test 65k "validate manual striping works properly with deactivated OSCs"
10113 test_65l() { # bug 12836
10114 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10116 test_mkdir -p $DIR/$tdir/test_dir
10117 $LFS setstripe -c -1 $DIR/$tdir/test_dir
10118 $LFS find -mtime -1 $DIR/$tdir >/dev/null
10120 run_test 65l "lfs find on -1 stripe dir ========================"
10123 local layout=$(save_layout $MOUNT)
10124 $RUNAS $LFS setstripe -c 2 $MOUNT && {
10125 restore_layout $MOUNT $layout
10126 error "setstripe should fail by non-root users"
10130 run_test 65m "normal user can't set filesystem default stripe"
10133 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
10134 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
10135 skip "Need MDS version at least 2.12.50"
10136 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
10138 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
10139 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
10140 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
10142 save_layout_restore_at_exit $MOUNT
10144 # new subdirectory under root directory should not inherit
10145 # the default layout from root
10146 # LU-16904 check if the root is set as PFL layout
10147 local numcomp=$($LFS getstripe --component-count $MOUNT)
10149 if [[ $numcomp -eq 0 ]]; then
10150 local dir1=$MOUNT/$tdir-1
10151 mkdir $dir1 || error "mkdir $dir1 failed"
10152 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
10153 error "$dir1 shouldn't have LOV EA"
10156 # delete the default layout on root directory
10157 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
10159 local dir2=$MOUNT/$tdir-2
10160 mkdir $dir2 || error "mkdir $dir2 failed"
10161 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
10162 error "$dir2 shouldn't have LOV EA"
10164 # set a new striping pattern on root directory
10165 local def_stripe_size=$($LFS getstripe -S $MOUNT)
10166 local new_def_stripe_size=$((def_stripe_size * 2))
10167 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
10168 error "set stripe size on $MOUNT failed"
10170 # new file created in $dir2 should inherit the new stripe size from
10171 # the filesystem default
10172 local file2=$dir2/$tfile-2
10173 touch $file2 || error "touch $file2 failed"
10175 local file2_stripe_size=$($LFS getstripe -S $file2)
10176 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
10178 echo "file2_stripe_size: '$file2_stripe_size'"
10179 echo "new_def_stripe_size: '$new_def_stripe_size'"
10180 error "$file2 didn't inherit stripe size $new_def_stripe_size"
10183 local dir3=$MOUNT/$tdir-3
10184 mkdir $dir3 || error "mkdir $dir3 failed"
10185 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
10186 # the root layout, which is the actual default layout that will be used
10187 # when new files are created in $dir3.
10188 local dir3_layout=$(get_layout_param $dir3)
10189 local root_dir_layout=$(get_layout_param $MOUNT)
10190 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
10192 echo "dir3_layout: '$dir3_layout'"
10193 echo "root_dir_layout: '$root_dir_layout'"
10194 error "$dir3 should show the default layout from $MOUNT"
10197 # set OST pool on root directory
10198 local pool=$TESTNAME
10199 pool_add $pool || error "add $pool failed"
10200 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
10201 error "add targets to $pool failed"
10203 $LFS setstripe -p $pool $MOUNT ||
10204 error "set OST pool on $MOUNT failed"
10206 # new file created in $dir3 should inherit the pool from
10207 # the filesystem default
10208 local file3=$dir3/$tfile-3
10209 touch $file3 || error "touch $file3 failed"
10211 local file3_pool=$($LFS getstripe -p $file3)
10212 [[ "$file3_pool" = "$pool" ]] ||
10213 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
10215 local dir4=$MOUNT/$tdir-4
10216 mkdir $dir4 || error "mkdir $dir4 failed"
10217 local dir4_layout=$(get_layout_param $dir4)
10218 root_dir_layout=$(get_layout_param $MOUNT)
10219 echo "$LFS getstripe -d $dir4"
10220 $LFS getstripe -d $dir4
10221 echo "$LFS getstripe -d $MOUNT"
10222 $LFS getstripe -d $MOUNT
10223 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
10225 echo "dir4_layout: '$dir4_layout'"
10226 echo "root_dir_layout: '$root_dir_layout'"
10227 error "$dir4 should show the default layout from $MOUNT"
10230 # new file created in $dir4 should inherit the pool from
10231 # the filesystem default
10232 local file4=$dir4/$tfile-4
10233 touch $file4 || error "touch $file4 failed"
10235 local file4_pool=$($LFS getstripe -p $file4)
10236 [[ "$file4_pool" = "$pool" ]] ||
10237 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
10239 # new subdirectory under non-root directory should inherit
10240 # the default layout from its parent directory
10241 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
10242 error "set directory layout on $dir4 failed"
10244 local dir5=$dir4/$tdir-5
10245 mkdir $dir5 || error "mkdir $dir5 failed"
10247 dir4_layout=$(get_layout_param $dir4)
10248 local dir5_layout=$(get_layout_param $dir5)
10249 [[ "$dir4_layout" = "$dir5_layout" ]] ||
10251 echo "dir4_layout: '$dir4_layout'"
10252 echo "dir5_layout: '$dir5_layout'"
10253 error "$dir5 should inherit the default layout from $dir4"
10256 # though subdir under ROOT doesn't inherit default layout, but
10257 # its sub dir/file should be created with default layout.
10258 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
10259 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
10260 skip "Need MDS version at least 2.12.59"
10262 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
10263 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
10264 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
10266 if [ $default_lmv_hash == "none" ]; then
10267 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
10269 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
10270 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
10273 $LFS setdirstripe -D -c 2 $MOUNT ||
10274 error "setdirstripe -D -c 2 failed"
10275 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
10276 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
10277 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
10279 # $dir4 layout includes pool
10280 $LFS setstripe -S $((new_def_stripe_size * 2)) $dir4
10281 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
10282 error "pool lost on setstripe"
10283 $LFS setstripe -E -1 -S $new_def_stripe_size $dir4
10284 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
10285 error "pool lost on compound layout setstripe"
10287 run_test 65n "don't inherit default layout from root for new subdirectories"
10290 (( $MDS1_VERSION >= $(version_code 2.14.57) )) ||
10291 skip "need MDS version at least 2.14.57"
10293 # set OST pool on root directory
10294 local pool=$TESTNAME
10296 pool_add $pool || error "add $pool failed"
10297 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
10298 error "add targets to $pool failed"
10300 local dir1=$MOUNT/$tdir
10302 mkdir $dir1 || error "mkdir $dir1 failed"
10304 # set a new striping pattern on root directory
10305 local def_stripe_size=$($LFS getstripe -S $MOUNT)
10307 $LFS setstripe -p $pool $dir1 ||
10308 error "set directory layout on $dir1 failed"
10310 # $dir1 layout includes pool
10311 $LFS setstripe -S $((def_stripe_size * 2)) $dir1
10312 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
10313 error "pool lost on setstripe"
10314 $LFS setstripe -E 1M -L mdt -E -1 -c 1 $dir1
10315 $LFS getstripe $dir1
10316 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
10317 error "pool lost on compound layout setstripe"
10319 $LFS setdirstripe -i 0 -c 2 $dir1/dir2 ||
10320 error "setdirstripe failed on sub-dir with inherited pool"
10321 $LFS getstripe $dir1/dir2
10322 [[ "$pool" = $($LFS getstripe -p -d $dir1/dir2) ]] ||
10323 error "pool lost on compound layout setdirstripe"
10325 $LFS setstripe -E -1 -c 1 $dir1
10326 $LFS getstripe -d $dir1
10327 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
10328 error "pool lost on setstripe"
10330 run_test 65o "pool inheritance for mdt component"
10332 test_65p () { # LU-16152
10333 local src_dir=$DIR/$tdir/src_dir
10334 local dst_dir=$DIR/$tdir/dst_dir
10335 local yaml_file=$DIR/$tdir/layout.yaml
10338 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
10339 skip "Need at least version 2.15.51"
10341 test_mkdir -p $src_dir
10342 $LFS setstripe -E 2048M -c 4 -E EOF -c 8 $src_dir ||
10343 error "failed to setstripe"
10344 $LFS getstripe --yaml -d $src_dir > $yaml_file ||
10345 error "failed to getstripe"
10347 test_mkdir -p $dst_dir
10348 $LFS setstripe --yaml $yaml_file $dst_dir ||
10349 error "failed to setstripe with yaml file"
10350 border=$($LFS getstripe -d $dst_dir |
10351 awk '/lcme_extent.e_end:/ { print $2; exit; }') ||
10352 error "failed to getstripe"
10354 # 2048M is 0x80000000, or 2147483648
10355 (( $border == 2147483648 )) ||
10356 error "failed to handle huge number in yaml layout"
10358 run_test 65p "setstripe with yaml file and huge number"
10360 test_65p () { # LU-16194
10361 local src_dir=$DIR/$tdir/src_dir
10363 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
10364 skip "Need at least version 2.15.51"
10366 test_mkdir -p $src_dir
10367 # 8E is 0x8000 0000 0000 0000, which is negative as s64
10368 $LFS setstripe -E 8E -c 4 -E EOF -c 8 $src_dir &&
10369 error "should fail if extent start/end >=8E"
10371 # EOF should work as before
10372 $LFS setstripe -E 8M -c 4 -E EOF -c 8 $src_dir ||
10373 error "failed to setstripe normally"
10375 run_test 65p "setstripe with >=8E offset should fail"
10377 # bug 2543 - update blocks count on client
10379 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10381 local COUNT=${COUNT:-8}
10382 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
10383 sync; sync_all_data; sync; sync_all_data
10384 cancel_lru_locks osc
10385 local BLOCKS=$(ls -s --block-size=1k $DIR/f66 | awk '{ print $1 }')
10386 (( BLOCKS >= COUNT )) || error "$DIR/f66 blocks $BLOCKS < $COUNT"
10388 run_test 66 "update inode blocks count on client ==============="
10391 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
10395 swapon -s | awk '($1 == "'$1'") { print $4 }'
10398 # bug5265, obdfilter oa2dentry return -ENOENT
10399 # #define OBD_FAIL_SRV_ENOENT 0x217
10401 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10402 remote_ost_nodsh && skip "remote OST with nodsh"
10405 $LFS setstripe -c 1 -i 0 $f
10406 stack_trap "rm -f $f ${f}.2"
10408 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
10410 do_facet ost1 lctl set_param fail_loc=0x217
10411 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
10412 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
10414 do_facet ost1 lctl set_param fail_loc=0
10415 $DIRECTIO write $f 0 2 || error "write error"
10417 cancel_lru_locks osc
10418 $DIRECTIO read $f 0 1 || error "read error"
10420 do_facet ost1 lctl set_param fail_loc=0x217
10421 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
10423 do_facet ost1 lctl set_param fail_loc=0
10425 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
10428 test_mkdir $DIR/$tdir
10429 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
10430 bash rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
10432 run_test 71 "Running dbench on lustre (don't segment fault) ===="
10434 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
10435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10436 [ "$RUNAS_ID" = "$UID" ] &&
10437 skip_env "RUNAS_ID = UID = $UID -- skipping"
10438 # Check that testing environment is properly set up. Skip if not
10439 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
10440 skip_env "User $RUNAS_ID does not exist - skipping"
10443 chmod 777 $DIR/$tfile
10444 chmod ug+s $DIR/$tfile
10445 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
10446 error "$RUNAS dd $DIR/$tfile failed"
10447 # See if we are still setuid/sgid
10448 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
10449 error "S/gid is not dropped on write"
10450 # Now test that MDS is updated too
10451 cancel_lru_locks mdc
10452 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
10453 error "S/gid is not dropped on MDS"
10456 run_test 72a "Test that remove suid works properly (bug5695) ===="
10458 test_72b() { # bug 24226 -- keep mode setting when size is not changing
10461 [ "$RUNAS_ID" = "$UID" ] &&
10462 skip_env "RUNAS_ID = UID = $UID -- skipping"
10463 [ "$RUNAS_ID" -eq 0 ] &&
10464 skip_env "RUNAS_ID = 0 -- skipping"
10465 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10466 # Check that testing environment is properly set up. Skip if not
10467 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
10468 skip_env "User $RUNAS_ID does not exist - skipping"
10470 touch $DIR/${tfile}-f{g,u}
10471 test_mkdir $DIR/${tfile}-dg
10472 test_mkdir $DIR/${tfile}-du
10473 chmod 770 $DIR/${tfile}-{f,d}{g,u}
10474 chmod g+s $DIR/${tfile}-{f,d}g
10475 chmod u+s $DIR/${tfile}-{f,d}u
10476 for perm in 777 2777 4777; do
10477 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
10478 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
10479 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
10480 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
10484 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
10486 # bug 3462 - multiple simultaneous MDC requests
10488 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10490 test_mkdir $DIR/d73-1
10491 test_mkdir $DIR/d73-2
10492 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
10495 lctl set_param fail_loc=0x80000129
10496 $MULTIOP $DIR/d73-1/f73-2 Oc &
10498 lctl set_param fail_loc=0
10500 $MULTIOP $DIR/d73-2/f73-3 Oc &
10504 wait $pid1 || return 1
10508 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
10509 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
10510 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
10514 run_test 73 "multiple MDC requests (should not deadlock)"
10516 test_74a() { # bug 6149, 6184
10517 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10520 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
10522 # very important to OR with CFS_FAIL_ONCE (0x80000000) -- otherwise it
10523 # will spin in a tight reconnection loop
10524 $LCTL set_param fail_loc=0x8000030e
10525 # get any lock that won't be difficult - lookup works.
10527 $LCTL set_param fail_loc=0
10531 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
10533 test_74b() { # bug 13310
10534 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10536 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
10538 # very important to OR with CFS_FAIL_ONCE (0x80000000) -- otherwise it
10539 # will spin in a tight reconnection loop
10540 $LCTL set_param fail_loc=0x8000030e
10541 # get a "difficult" lock
10543 $LCTL set_param fail_loc=0
10547 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
10550 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10552 #define OBD_FAIL_LDLM_NEW_LOCK
10553 $LCTL set_param fail_loc=0x319
10554 touch $DIR/$tfile && error "touch successful"
10555 $LCTL set_param fail_loc=0
10558 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
10560 slab_lic=/sys/kernel/slab/lustre_inode_cache
10562 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
10563 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
10564 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
10567 test_76a() { # Now for b=20433, added originally in b=1443
10568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10570 cancel_lru_locks osc
10571 # there may be some slab objects cached per core
10572 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
10573 local before=$(num_objects)
10574 local count=$((512 * cpus))
10575 [ "$SLOW" = "no" ] && count=$((128 * cpus))
10576 local margin=$((count / 10))
10577 if [[ -f $slab_lic/aliases ]]; then
10578 local aliases=$(cat $slab_lic/aliases)
10579 (( aliases > 0 )) && margin=$((margin * aliases))
10582 echo "before slab objects: $before"
10583 for i in $(seq $count); do
10587 cancel_lru_locks osc
10588 local after=$(num_objects)
10589 echo "created: $count, after slab objects: $after"
10590 # shared slab counts are not very accurate, allow significant margin
10591 # the main goal is that the cache growth is not permanently > $count
10592 while (( after > before + margin )); do
10594 after=$(num_objects)
10596 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
10597 if (( wait > 60 )); then
10598 error "inode slab grew from $before+$margin to $after"
10602 run_test 76a "confirm clients recycle inodes properly ===="
10605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10606 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
10609 local before=$(num_objects)
10611 for i in $(seq $count); do
10616 local after=$(num_objects)
10619 while (( after > before )); do
10621 after=$(num_objects)
10623 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
10624 if (( wait > 60 )); then
10625 error "inode slab grew from $before to $after"
10629 echo "slab objects before: $before, after: $after"
10631 run_test 76b "confirm clients recycle directory inodes properly ===="
10633 export ORIG_CSUM=""
10636 # Note: in sptlrpc modes which enable its own bulk checksum, the
10637 # original crc32_le bulk checksum will be automatically disabled,
10638 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
10639 # will be checked by sptlrpc code against sptlrpc bulk checksum.
10640 # In this case set_checksums() will not be no-op, because sptlrpc
10641 # bulk checksum will be enabled all through the test.
10643 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
10644 lctl set_param -n osc.*.checksums $1
10648 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
10649 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
10650 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
10651 tr -d [] | head -n1)}
10652 set_checksum_type()
10654 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
10656 log "set checksum type to $1, rc = $rc"
10660 get_osc_checksum_type()
10662 # arugment 1: OST name, like OST0000
10664 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
10665 sed 's/.*\[\(.*\)\].*/\1/g')
10667 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
10668 echo $checksum_type
10671 F77_TMP=$TMP/f77-temp
10674 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
10675 error "error writing to $F77_TMP"
10678 test_77a() { # bug 10889
10679 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10680 $GSS && skip_env "could not run with gss"
10682 [ ! -f $F77_TMP ] && setup_f77
10684 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
10688 run_test 77a "normal checksum read/write operation"
10690 test_77b() { # bug 10889
10691 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10692 $GSS && skip_env "could not run with gss"
10694 [ ! -f $F77_TMP ] && setup_f77
10695 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10696 $LCTL set_param fail_loc=0x80000409
10699 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10700 error "dd error: $?"
10701 $LCTL set_param fail_loc=0
10703 for algo in $CKSUM_TYPES; do
10704 cancel_lru_locks osc
10705 set_checksum_type $algo
10706 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10707 $LCTL set_param fail_loc=0x80000408
10708 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
10709 $LCTL set_param fail_loc=0
10712 set_checksum_type $ORIG_CSUM_TYPE
10715 run_test 77b "checksum error on client write, read"
10720 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
10722 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
10723 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
10724 $check_ost && [ -n "$ost_file_prefix" ] &&
10725 do_facet ost1 rm -f ${ost_file_prefix}\*
10729 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10730 $GSS && skip_env "could not run with gss"
10731 remote_ost_nodsh && skip "remote OST with nodsh"
10734 local osc_file_prefix
10736 local check_ost=false
10737 local ost_file_prefix
10743 # ensure corruption will occur on first OSS/OST
10744 $LFS setstripe -i 0 $DIR/$tfile
10746 [ ! -f $F77_TMP ] && setup_f77
10747 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10748 error "dd write error: $?"
10749 fid=$($LFS path2fid $DIR/$tfile)
10751 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
10754 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
10755 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
10757 echo "OSS do not support bulk pages dump upon error"
10760 osc_file_prefix=$($LCTL get_param -n debug_path)
10761 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
10763 trap cleanup_77c EXIT
10766 # enable bulk pages dump upon error on Client
10767 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
10768 # enable bulk pages dump upon error on OSS
10770 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
10772 # flush Client cache to allow next read to reach OSS
10773 cancel_lru_locks osc
10775 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10776 $LCTL set_param fail_loc=0x80000408
10777 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
10778 $LCTL set_param fail_loc=0
10782 # check cksum dump on Client
10783 osc_file=$(ls ${osc_file_prefix}*)
10784 [ -n "$osc_file" ] || error "no checksum dump file on Client"
10785 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
10786 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
10787 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
10788 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
10790 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
10791 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10792 error "dump content does not match on Client"
10794 $check_ost || skip "No need to check cksum dump on OSS"
10796 # check cksum dump on OSS
10797 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
10798 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
10799 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
10800 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
10801 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10802 error "dump content does not match on OSS"
10806 run_test 77c "checksum error on client read with debug"
10808 test_77d() { # bug 10889
10809 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10810 $GSS && skip_env "could not run with gss"
10812 stack_trap "rm -f $DIR/$tfile"
10813 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10814 $LCTL set_param fail_loc=0x80000409
10816 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10817 error "direct write: rc=$?"
10818 $LCTL set_param fail_loc=0
10821 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10822 $LCTL set_param fail_loc=0x80000408
10824 cancel_lru_locks osc
10825 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10826 error "direct read: rc=$?"
10827 $LCTL set_param fail_loc=0
10830 run_test 77d "checksum error on OST direct write, read"
10832 test_77f() { # bug 10889
10833 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10834 $GSS && skip_env "could not run with gss"
10837 stack_trap "rm -f $DIR/$tfile"
10838 for algo in $CKSUM_TYPES; do
10839 cancel_lru_locks osc
10840 set_checksum_type $algo
10841 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10842 $LCTL set_param fail_loc=0x409
10843 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
10844 error "direct write succeeded"
10845 $LCTL set_param fail_loc=0
10847 set_checksum_type $ORIG_CSUM_TYPE
10850 run_test 77f "repeat checksum error on write (expect error)"
10852 test_77g() { # bug 10889
10853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10854 $GSS && skip_env "could not run with gss"
10855 remote_ost_nodsh && skip "remote OST with nodsh"
10857 [ ! -f $F77_TMP ] && setup_f77
10859 local file=$DIR/$tfile
10860 stack_trap "rm -f $file" EXIT
10862 $LFS setstripe -c 1 -i 0 $file
10863 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
10864 do_facet ost1 lctl set_param fail_loc=0x8000021a
10866 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
10867 error "write error: rc=$?"
10868 do_facet ost1 lctl set_param fail_loc=0
10871 cancel_lru_locks osc
10872 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
10873 do_facet ost1 lctl set_param fail_loc=0x8000021b
10875 cmp $F77_TMP $file || error "file compare failed"
10876 do_facet ost1 lctl set_param fail_loc=0
10879 run_test 77g "checksum error on OST write, read"
10881 test_77k() { # LU-10906
10882 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10883 $GSS && skip_env "could not run with gss"
10885 local cksum_param="osc.$FSNAME*.checksums"
10886 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
10890 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
10891 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
10892 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
10895 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
10896 error "failed to set checksum=$i on MGS"
10897 wait_update $HOSTNAME "$get_checksum" $i
10899 echo "remount client, checksum should be $i"
10900 remount_client $MOUNT || error "failed to remount client"
10901 checksum=$(eval $get_checksum)
10902 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10904 # remove persistent param to avoid races with checksum mountopt below
10905 do_facet mgs $LCTL set_param -P -d $cksum_param ||
10906 error "failed to delete checksum on MGS"
10908 for opt in "checksum" "nochecksum"; do
10909 #remount with mount option
10910 echo "remount client with option $opt, checksum should be $i"
10911 umount_client $MOUNT || error "failed to umount client"
10912 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
10913 error "failed to mount client with option '$opt'"
10914 checksum=$(eval $get_checksum)
10915 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10919 remount_client $MOUNT || error "failed to remount client"
10921 run_test 77k "enable/disable checksum correctly"
10924 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10925 $GSS && skip_env "could not run with gss"
10928 stack_trap "set_checksums $ORIG_CSUM" EXIT
10929 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10931 set_checksum_type invalid && error "unexpected success of invalid checksum type"
10933 $LFS setstripe -c 1 -i 0 $DIR/$tfile
10934 for algo in $CKSUM_TYPES; do
10935 set_checksum_type $algo || error "fail to set checksum type $algo"
10936 osc_algo=$(get_osc_checksum_type OST0000)
10937 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
10939 # no locks, no reqs to let the connection idle
10940 cancel_lru_locks osc
10941 lru_resize_disable osc
10942 wait_osc_import_state client ost1 IDLE
10944 # ensure ost1 is connected
10945 stat $DIR/$tfile >/dev/null || error "can't stat"
10946 wait_osc_import_state client ost1 FULL
10948 osc_algo=$(get_osc_checksum_type OST0000)
10949 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
10953 run_test 77l "preferred checksum type is remembered after reconnected"
10955 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
10960 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
10961 skip "Need at least version 2.14.52"
10962 local param=checksum_speed
10964 $LCTL get_param $param || error "reading $param failed"
10966 csum_speeds=$($LCTL get_param -n $param)
10968 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
10969 error "known checksum types are missing"
10971 run_test 77m "Verify checksum_speed is correctly read"
10973 check_filefrag_77n() {
10978 while read extidx a b start end rest; do
10979 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
10980 nr_ext=$(( $nr_ext + 1 ))
10981 starts+=( ${start%..} )
10984 done < <( filefrag -sv $1 )
10986 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
10991 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
10994 $TRUNCATE $DIR/$tfile 0
10995 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
10996 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
10997 check_filefrag_77n $DIR/$tfile ||
10998 skip "$tfile blocks not contiguous around hole"
11001 stack_trap "set_checksums $ORIG_CSUM" EXIT
11002 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
11003 stack_trap "rm -f $DIR/$tfile"
11005 for algo in $CKSUM_TYPES; do
11006 if [[ "$algo" =~ ^t10 ]]; then
11007 set_checksum_type $algo ||
11008 error "fail to set checksum type $algo"
11009 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
11010 error "fail to read $tfile with $algo"
11016 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
11019 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
11020 skip "Need MDS version at least 2.14.55"
11021 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
11022 skip "Need OST version at least 2.14.55"
11023 local ofd=obdfilter
11026 # print OST checksum_type
11027 echo "$ofd.$FSNAME-*.checksum_type:"
11028 do_nodes $(comma_list $(osts_nodes)) \
11029 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type
11031 # print MDT checksum_type
11032 echo "$mdt.$FSNAME-*.checksum_type:"
11033 do_nodes $(comma_list $(mdts_nodes)) \
11034 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type
11036 local o_count=$(do_nodes $(comma_list $(osts_nodes)) \
11037 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l)
11039 (( $o_count == $OSTCOUNT )) ||
11040 error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT"
11042 local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \
11043 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l)
11045 (( $m_count == $MDSCOUNT )) ||
11046 error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT"
11048 run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))"
11050 cleanup_test_78() {
11055 test_78() { # bug 10901
11056 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11057 remote_ost || skip_env "local OST"
11060 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
11061 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
11062 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
11063 echo "MemTotal: $MEMTOTAL"
11065 # reserve 256MB of memory for the kernel and other running processes,
11066 # and then take 1/2 of the remaining memory for the read/write buffers.
11067 if [ $MEMTOTAL -gt 512 ] ;then
11068 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
11070 # for those poor memory-starved high-end clusters...
11071 MEMTOTAL=$((MEMTOTAL / 2))
11073 echo "Mem to use for directio: $MEMTOTAL"
11075 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
11076 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
11077 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
11078 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
11080 echo "Smallest OST: $SMALLESTOST"
11081 [[ $SMALLESTOST -lt 10240 ]] &&
11082 skip "too small OSTSIZE, useless to run large O_DIRECT test"
11084 trap cleanup_test_78 EXIT
11086 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
11087 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
11089 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
11090 echo "File size: $F78SIZE"
11091 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
11092 for i in $(seq 1 $NSEQ); do
11093 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
11094 echo directIO rdwr round $i of $NSEQ
11095 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
11100 run_test 78 "handle large O_DIRECT writes correctly ============"
11102 test_79() { # bug 12743
11103 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11105 wait_delete_completed
11107 BKTOTAL=$(calc_osc_kbytes kbytestotal)
11108 BKFREE=$(calc_osc_kbytes kbytesfree)
11109 BKAVAIL=$(calc_osc_kbytes kbytesavail)
11111 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
11112 DFTOTAL=`echo $STRING | cut -d, -f1`
11113 DFUSED=`echo $STRING | cut -d, -f2`
11114 DFAVAIL=`echo $STRING | cut -d, -f3`
11115 DFFREE=$(($DFTOTAL - $DFUSED))
11117 ALLOWANCE=$((64 * $OSTCOUNT))
11119 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
11120 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
11121 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
11123 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
11124 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
11125 error "df free($DFFREE) mismatch OST free($BKFREE)"
11127 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
11128 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
11129 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
11132 run_test 79 "df report consistency check ======================="
11134 test_80() { # bug 10718
11135 remote_ost_nodsh && skip "remote OST with nodsh"
11136 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11138 # relax strong synchronous semantics for slow backends like ZFS
11139 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
11140 local soc="obdfilter.*.sync_lock_cancel"
11141 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
11143 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
11144 if [ -z "$save" ]; then
11145 soc="obdfilter.*.sync_on_lock_cancel"
11146 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
11149 if [ "$save" != "never" ]; then
11150 local hosts=$(comma_list $(osts_nodes))
11152 do_nodes $hosts $LCTL set_param $soc=never
11153 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
11157 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
11158 sync; sleep 1; sync
11159 local before=$(date +%s)
11160 cancel_lru_locks osc
11161 local after=$(date +%s)
11162 local diff=$((after - before))
11163 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
11167 run_test 80 "Page eviction is equally fast at high offsets too"
11169 test_81a() { # LU-456
11170 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11171 remote_ost_nodsh && skip "remote OST with nodsh"
11173 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
11174 # MUST OR with the CFS_FAIL_ONCE (0x80000000)
11175 do_facet ost1 lctl set_param fail_loc=0x80000228
11177 # write should trigger a retry and success
11178 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11179 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11181 if [ $RC -ne 0 ] ; then
11182 error "write should success, but failed for $RC"
11185 run_test 81a "OST should retry write when get -ENOSPC ==============="
11187 test_81b() { # LU-456
11188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11189 remote_ost_nodsh && skip "remote OST with nodsh"
11191 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
11192 # Don't OR with the CFS_FAIL_ONCE (0x80000000)
11193 do_facet ost1 lctl set_param fail_loc=0x228
11195 # write should retry several times and return -ENOSPC finally
11196 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11197 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11200 if [ $RC -ne $ENOSPC ] ; then
11201 error "dd should fail for -ENOSPC, but succeed."
11204 run_test 81b "OST should return -ENOSPC when retry still fails ======="
11207 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
11209 test_mkdir $DIR/$tdir.cvsroot
11210 chown $RUNAS_ID $DIR/$tdir.cvsroot
11213 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
11216 # some versions of cvs import exit(1) when asked to import links or
11217 # files they can't read. ignore those files.
11218 local toignore=$(find . -type l -printf '-I %f\n' -o \
11219 ! -perm /4 -printf '-I %f\n')
11220 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
11221 $tdir.reposname vtag rtag
11224 test_mkdir $DIR/$tdir.reposname
11225 chown $RUNAS_ID $DIR/$tdir.reposname
11226 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
11228 cd $DIR/$tdir.reposname
11230 $RUNAS cvs add -m 'addmsg' foo99
11232 $RUNAS cvs commit -m 'nomsg' foo99
11233 rm -fr $DIR/$tdir.cvsroot
11235 run_test 99 "cvs strange file/directory operations"
11238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11239 [[ "$NETTYPE" =~ tcp ]] ||
11240 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
11241 [[ -n "$(type -p ss)" ]] || skip_env "ss not available"
11242 remote_ost_nodsh && skip "remote OST with nodsh"
11243 remote_mds_nodsh && skip "remote MDS with nodsh"
11244 remote_servers || skip "useless for local single node setup"
11246 ss -tna | ( rc=1; while read STATE SND RCV LOCAL REMOTE STAT; do
11247 [[ "${REMOTE/*:/}" == "$ACCEPTOR_PORT" ]] || continue
11250 if (( ${LOCAL/*:/} >= 1024 )); then
11251 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
11253 error "local: ${LOCAL/*:/} > 1024 remote: ${REMOTE/*:/}"
11256 (( $rc == 0 )) || error "privileged port not found" )
11258 run_test 100 "check local port using privileged port"
11260 function get_named_value()
11264 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
11268 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11273 local cache_limit=32
11275 $LCTL set_param -n osc.*-osc*.rpc_stats=0
11276 $LCTL set_param -n llite.*.read_ahead_stats=0
11277 local max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
11278 awk '/^max_cached_mb/ { print $2 }')
11279 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$max_cached_mb"
11280 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
11283 # randomly read 10000 of 64K chunks from file 3x 32MB in size
11285 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
11286 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
11289 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
11290 get_named_value 'read.but.discarded'); do
11291 discard=$(($discard + $s))
11294 $LCTL get_param osc.*-osc*.rpc_stats
11295 $LCTL get_param llite.*.read_ahead_stats
11297 # Discard is generally zero, but sometimes a few random reads line up
11298 # and trigger larger readahead, which is wasted & leads to discards.
11299 if [[ $(($discard)) -gt $nreads ]]; then
11300 error "too many ($discard) discarded pages"
11302 rm -f $DIR/$tfile || true
11304 run_test 101a "check read-ahead for random reads"
11306 setup_test101bc() {
11307 test_mkdir $DIR/$tdir
11309 local FILE_LENGTH=$2
11312 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
11314 local list=$(comma_list $(osts_nodes))
11315 set_osd_param $list '' read_cache_enable 0
11316 set_osd_param $list '' writethrough_cache_enable 0
11318 trap cleanup_test101bc EXIT
11319 # prepare the read-ahead file
11320 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
11322 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
11323 count=$FILE_SIZE_MB 2> /dev/null
11327 cleanup_test101bc() {
11332 local list=$(comma_list $(osts_nodes))
11333 set_osd_param $list '' read_cache_enable 1
11334 set_osd_param $list '' writethrough_cache_enable 1
11339 local stripe_size=$2
11340 local stride_length=$((stripe_size / read_size))
11341 local stride_width=$((stride_length * OSTCOUNT))
11342 local discard_limit=$(( ((stride_length - 1) * 3 / stride_width) *
11343 (stride_width - stride_length) ))
11344 local discard=$($LCTL get_param -n llite.*.read_ahead_stats |
11345 get_named_value 'read.but.discarded' | calc_sum)
11347 if [[ $discard -gt $discard_limit ]]; then
11348 $LCTL get_param llite.*.read_ahead_stats
11349 error "($discard limit ${discard_limit}) discarded pages with size (${read_size})"
11351 echo "Read-ahead success for size ${read_size}"
11356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11357 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11359 local STRIPE_SIZE=1048576
11360 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
11362 if [ $SLOW == "yes" ]; then
11363 local FILE_LENGTH=$((STRIDE_SIZE * 64))
11365 local FILE_LENGTH=$((STRIDE_SIZE * 8))
11368 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
11370 # prepare the read-ahead file
11371 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
11372 cancel_lru_locks osc
11373 for BIDX in 2 4 8 16 32 64 128 256
11375 local BSIZE=$((BIDX*4096))
11376 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
11377 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
11378 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
11379 $LCTL set_param -n llite.*.read_ahead_stats=0
11380 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
11381 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
11382 cancel_lru_locks osc
11383 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
11388 run_test 101b "check stride-io mode read-ahead ================="
11391 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11393 local STRIPE_SIZE=1048576
11394 local FILE_LENGTH=$((STRIPE_SIZE*100))
11397 local osc_rpc_stats
11399 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
11401 cancel_lru_locks osc
11402 $LCTL set_param osc.*.rpc_stats=0
11403 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
11404 $LCTL get_param osc.*.rpc_stats
11405 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
11406 local stats=$($LCTL get_param -n $osc_rpc_stats)
11407 local lines=$(echo "$stats" | awk 'END {print NR;}')
11410 if [ $lines -le 20 ]; then
11411 echo "continue debug"
11414 for size in 1 2 4 8; do
11415 local rpc=$(echo "$stats" |
11416 awk '($1 == "'$size':") {print $2; exit; }')
11417 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
11418 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
11420 echo "$osc_rpc_stats check passed!"
11425 run_test 101c "check stripe_size aligned read-ahead"
11428 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11430 local file=$DIR/$tfile
11431 local sz_MB=${FILESIZE_101d:-80}
11432 local ra_MB=${READAHEAD_MB:-40}
11434 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
11435 [ $free_MB -lt $sz_MB ] &&
11436 skip "Need free space ${sz_MB}M, have ${free_MB}M"
11438 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
11439 $LFS setstripe -c -1 $file || error "setstripe failed"
11441 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
11442 echo Cancel LRU locks on lustre client to flush the client cache
11443 cancel_lru_locks osc
11445 echo Disable read-ahead
11446 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
11447 $LCTL set_param -n llite.*.max_read_ahead_mb=0
11448 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
11449 $LCTL get_param -n llite.*.max_read_ahead_mb
11451 echo "Reading the test file $file with read-ahead disabled"
11452 local sz_KB=$((sz_MB * 1024 / 4))
11453 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
11454 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
11455 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
11456 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
11458 echo "Cancel LRU locks on lustre client to flush the client cache"
11459 cancel_lru_locks osc
11460 echo Enable read-ahead with ${ra_MB}MB
11461 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
11463 echo "Reading the test file $file with read-ahead enabled"
11464 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
11465 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
11467 echo "read-ahead disabled time read $raOFF"
11468 echo "read-ahead enabled time read $raON"
11471 wait_delete_completed
11473 # use awk for this check instead of bash because it handles decimals
11474 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
11475 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
11477 run_test 101d "file read with and without read-ahead enabled"
11480 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11482 local file=$DIR/$tfile
11483 local size_KB=500 #KB
11487 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
11488 local need_KB=$((count * size_KB))
11489 [[ $free_KB -le $need_KB ]] &&
11490 skip_env "Need free space $need_KB, have $free_KB"
11492 echo "Creating $count ${size_KB}K test files"
11493 for ((i = 0; i < $count; i++)); do
11494 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
11497 echo "Cancel LRU locks on lustre client to flush the client cache"
11498 cancel_lru_locks $OSC
11500 echo "Reset readahead stats"
11501 $LCTL set_param -n llite.*.read_ahead_stats=0
11503 for ((i = 0; i < $count; i++)); do
11504 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
11507 $LCTL get_param llite.*.max_cached_mb
11508 $LCTL get_param llite.*.read_ahead_stats
11509 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11510 get_named_value 'misses' | calc_sum)
11512 for ((i = 0; i < $count; i++)); do
11513 rm -rf $file.$i 2>/dev/null
11516 #10000 means 20% reads are missing in readahead
11517 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
11519 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
11522 which iozone || skip_env "no iozone installed"
11524 local old_debug=$($LCTL get_param debug)
11525 old_debug=${old_debug#*=}
11526 $LCTL set_param debug="reada mmap"
11528 # create a test file
11529 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
11531 echo Cancel LRU locks on lustre client to flush the client cache
11532 cancel_lru_locks osc
11534 echo Reset readahead stats
11535 $LCTL set_param -n llite.*.read_ahead_stats=0
11537 echo mmap read the file with small block size
11538 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
11541 echo checking missing pages
11542 $LCTL get_param llite.*.read_ahead_stats
11543 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11544 get_named_value 'misses' | calc_sum)
11546 $LCTL set_param debug="$old_debug"
11547 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
11550 run_test 101f "check mmap read performance"
11552 test_101g_brw_size_test() {
11554 local pages=$((mb * 1048576 / PAGE_SIZE))
11555 local file=$DIR/$tfile
11557 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
11558 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
11559 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
11560 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
11564 stack_trap "rm -f $file" EXIT
11565 $LCTL set_param -n osc.*.rpc_stats=0
11567 # 10 RPCs should be enough for the test
11569 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
11570 { error "dd write ${mb} MB blocks failed"; return 3; }
11571 cancel_lru_locks osc
11572 dd of=/dev/null if=$file bs=${mb}M count=$count ||
11573 { error "dd write ${mb} MB blocks failed"; return 4; }
11575 # calculate number of full-sized read and write RPCs
11576 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
11577 sed -n '/pages per rpc/,/^$/p' |
11578 awk '/'$pages':/ { reads += $2; writes += $6 }; \
11579 END { print reads,writes }'))
11580 # allow one extra full-sized read RPC for async readahead
11581 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
11582 { error "${rpcs[0]} != $count read RPCs"; return 5; }
11583 [[ ${rpcs[1]} == $count ]] ||
11584 { error "${rpcs[1]} != $count write RPCs"; return 6; }
11588 remote_ost_nodsh && skip "remote OST with nodsh"
11591 local osts=$(get_facets OST)
11592 local list=$(comma_list $(osts_nodes))
11593 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11594 local brw_size="obdfilter.*.brw_size"
11596 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11598 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
11600 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
11601 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
11602 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
11603 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
11604 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
11605 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
11607 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
11610 if [[ $orig_mb -lt 16 ]]; then
11611 save_lustre_params $osts "$brw_size" > $p
11612 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
11613 error "set 16MB RPC size failed"
11615 echo "remount client to enable new RPC size"
11616 remount_client $MOUNT || error "remount_client failed"
11619 test_101g_brw_size_test 16 || error "16MB RPC test failed"
11620 # should be able to set brw_size=12, but no rpc_stats for that
11621 test_101g_brw_size_test 8 || error "8MB RPC test failed"
11624 test_101g_brw_size_test 4 || error "4MB RPC test failed"
11626 if [[ $orig_mb -lt 16 ]]; then
11627 restore_lustre_params < $p
11628 remount_client $MOUNT || error "remount_client restore failed"
11631 rm -f $p $DIR/$tfile
11633 run_test 101g "Big bulk(4/16 MiB) readahead"
11636 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11638 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
11639 error "dd 70M file failed"
11640 echo Cancel LRU locks on lustre client to flush the client cache
11641 cancel_lru_locks osc
11643 echo "Reset readahead stats"
11644 $LCTL set_param -n llite.*.read_ahead_stats 0
11646 echo "Read 10M of data but cross 64M bundary"
11647 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
11648 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11649 get_named_value 'misses' | calc_sum)
11650 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
11651 rm -f $p $DIR/$tfile
11653 run_test 101h "Readahead should cover current read window"
11656 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
11657 error "dd 10M file failed"
11659 local max_per_file_mb=$($LCTL get_param -n \
11660 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
11661 cancel_lru_locks osc
11662 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
11663 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
11664 error "set max_read_ahead_per_file_mb to 1 failed"
11666 echo "Reset readahead stats"
11667 $LCTL set_param llite.*.read_ahead_stats=0
11669 dd if=$DIR/$tfile of=/dev/null bs=2M
11671 $LCTL get_param llite.*.read_ahead_stats
11672 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11673 awk '/misses/ { print $2 }')
11674 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
11677 run_test 101i "allow current readahead to exceed reservation"
11680 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
11681 error "setstripe $DIR/$tfile failed"
11682 local file_size=$((1048576 * 16))
11683 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
11684 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
11686 echo Disable read-ahead
11687 $LCTL set_param -n llite.*.max_read_ahead_mb=0
11689 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
11690 for blk in $PAGE_SIZE 1048576 $file_size; do
11691 cancel_lru_locks osc
11692 echo "Reset readahead stats"
11693 $LCTL set_param -n llite.*.read_ahead_stats=0
11694 local count=$(($file_size / $blk))
11695 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
11696 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11697 get_named_value 'failed.to.fast.read' | calc_sum)
11698 $LCTL get_param -n llite.*.read_ahead_stats
11699 [ $miss -eq $count ] || error "expected $count got $miss"
11702 rm -f $p $DIR/$tfile
11704 run_test 101j "A complete read block should be submitted when no RA"
11706 test_readahead_base() {
11707 local file=$DIR/$tfile
11713 $LCTL set_param -n llite.*.read_ahead_stats=0
11714 # The first page is not accounted into readahead
11715 ramax=$(((size + PAGE_SIZE - 1) / PAGE_SIZE - 1))
11716 iosz=$(((size + 1048575) / 1048576 * 1048576))
11717 echo "Test readahead: size=$size ramax=$ramx iosz=$iosz"
11719 $LCTL mark "Test readahead: size=$size ramax=$ramx iosz=$iosz"
11720 fallocate -l $size $file || error "failed to fallocate $file"
11721 cancel_lru_locks osc
11722 $MULTIOP $file or${iosz}c || error "failed to read $file"
11723 $LCTL get_param -n llite.*.read_ahead_stats
11724 ranum=$($LCTL get_param -n llite.*.read_ahead_stats |
11725 awk '/readahead.pages/ { print $7 }' | calc_sum)
11726 (( $ranum <= $ramax )) ||
11727 error "read-ahead pages is $ranum more than $ramax"
11728 rm -rf $file || error "failed to remove $file"
11733 local file=$DIR/$tfile
11739 check_set_fallocate_or_skip
11740 stack_trap "rm -f $file" EXIT
11742 test_readahead_base 4096
11744 # file size: 16K = 16384
11745 test_readahead_base 16384
11746 test_readahead_base 16385
11747 test_readahead_base 16383
11749 # file size: 1M + 1 = 1048576 + 1
11750 test_readahead_base 1048577
11751 # file size: 1M + 16K
11752 test_readahead_base $((1048576 + 16384))
11754 # file size: stripe_size * (stripe_count - 1) + 16K
11755 $LFS setstripe -c -1 $file || error "failed to setstripe $file"
11756 test_readahead_base $((1048576 * (OSTCOUNT - 1) + 16384))
11757 # file size: stripe_size * stripe_count + 16K
11758 $LFS setstripe -c -1 $file || error "failed to setstripe $file"
11759 test_readahead_base $((1048576 * OSTCOUNT + 16384))
11760 # file size: 2 * stripe_size * stripe_count + 16K
11761 $LFS setstripe -c -1 $file || error "failed to setstripe $file"
11762 test_readahead_base $((2 * 1048576 * OSTCOUNT + 16384))
11764 run_test 101m "read ahead for small file and last stripe of the file"
11767 test_mkdir $DIR/$tdir
11768 chown $RUNAS_ID $DIR/$tdir
11771 STRIPE_COUNT=$OSTCOUNT
11772 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
11774 trap cleanup_test102 EXIT
11776 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
11778 for num in 1 2 3 4; do
11779 for count in $(seq 1 $STRIPE_COUNT); do
11780 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
11781 local size=`expr $STRIPE_SIZE \* $num`
11782 local file=file"$num-$idx-$count"
11783 $1 $LFS setstripe -S $size -i $idx -c $count $file
11789 $1 tar cf $TMP/f102.tar $tdir --xattrs
11792 cleanup_test102() {
11794 rm -f $TMP/f102.tar
11795 rm -rf $DIR/d0.sanity/d102
11799 [ "$UID" != 0 ] && skip "must run as root"
11800 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
11801 skip_env "must have user_xattr"
11803 [ -z "$(which setfattr 2>/dev/null)" ] &&
11804 skip_env "could not find setfattr"
11806 local testfile=$DIR/$tfile
11809 echo "set/get xattr..."
11810 setfattr -n trusted.name1 -v value1 $testfile ||
11811 error "setfattr -n trusted.name1=value1 $testfile failed"
11812 getfattr -n trusted.name1 $testfile 2> /dev/null |
11813 grep "trusted.name1=.value1" ||
11814 error "$testfile missing trusted.name1=value1"
11816 setfattr -n user.author1 -v author1 $testfile ||
11817 error "setfattr -n user.author1=author1 $testfile failed"
11818 getfattr -n user.author1 $testfile 2> /dev/null |
11819 grep "user.author1=.author1" ||
11820 error "$testfile missing trusted.author1=author1"
11822 echo "listxattr..."
11823 setfattr -n trusted.name2 -v value2 $testfile ||
11824 error "$testfile unable to set trusted.name2"
11825 setfattr -n trusted.name3 -v value3 $testfile ||
11826 error "$testfile unable to set trusted.name3"
11827 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
11828 grep "trusted.name" | wc -l) -eq 3 ] ||
11829 error "$testfile missing 3 trusted.name xattrs"
11831 setfattr -n user.author2 -v author2 $testfile ||
11832 error "$testfile unable to set user.author2"
11833 setfattr -n user.author3 -v author3 $testfile ||
11834 error "$testfile unable to set user.author3"
11835 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
11836 grep "user.author" | wc -l) -eq 3 ] ||
11837 error "$testfile missing 3 user.author xattrs"
11839 echo "remove xattr..."
11840 setfattr -x trusted.name1 $testfile ||
11841 error "$testfile error deleting trusted.name1"
11842 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
11843 error "$testfile did not delete trusted.name1 xattr"
11845 setfattr -x user.author1 $testfile ||
11846 error "$testfile error deleting user.author1"
11847 echo "set lustre special xattr ..."
11848 $LFS setstripe -c1 $testfile
11849 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
11850 awk -F "=" '/trusted.lov/ { print $2 }' )
11851 setfattr -n "trusted.lov" -v $lovea $testfile ||
11852 error "$testfile doesn't ignore setting trusted.lov again"
11853 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
11854 error "$testfile allow setting invalid trusted.lov"
11857 run_test 102a "user xattr test =================================="
11859 check_102b_layout() {
11861 local testfile=$DIR/$tfile
11863 echo "test layout '$layout'"
11864 $LFS setstripe $layout $testfile || error "setstripe failed"
11865 $LFS getstripe -y $testfile
11867 echo "get/set/list trusted.lov xattr ..." # b=10930
11868 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
11869 [[ "$value" =~ "trusted.lov" ]] ||
11870 error "can't get trusted.lov from $testfile"
11871 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
11872 error "getstripe failed"
11874 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
11876 value=$(cut -d= -f2 <<<$value)
11877 # LU-13168: truncated xattr should fail if short lov_user_md header
11878 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
11879 lens="${#value}" || lens="$(seq 4 2 ${#value})"
11880 for len in $lens; do
11881 echo "setfattr $len $testfile.2"
11882 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
11883 [ $len -lt 66 ] && error "short xattr len=$len worked"
11885 local stripe_size=$($LFS getstripe -S $testfile.2)
11886 local stripe_count=$($LFS getstripe -c $testfile.2)
11887 [[ $stripe_size -eq 65536 ]] ||
11888 error "stripe size $stripe_size != 65536"
11889 [[ $stripe_count -eq $stripe_count_orig ]] ||
11890 error "stripe count $stripe_count != $stripe_count_orig"
11891 rm $testfile $testfile.2
11895 [ -z "$(which setfattr 2>/dev/null)" ] &&
11896 skip_env "could not find setfattr"
11897 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11899 # check plain layout
11900 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
11902 # and also check composite layout
11903 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
11906 run_test 102b "getfattr/setfattr for trusted.lov EAs"
11909 [ -z "$(which setfattr 2>/dev/null)" ] &&
11910 skip_env "could not find setfattr"
11911 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11913 # b10930: get/set/list lustre.lov xattr
11914 echo "get/set/list lustre.lov xattr ..."
11915 test_mkdir $DIR/$tdir
11916 chown $RUNAS_ID $DIR/$tdir
11917 local testfile=$DIR/$tdir/$tfile
11918 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
11919 error "setstripe failed"
11920 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
11921 error "getstripe failed"
11922 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
11923 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
11925 local testfile2=${testfile}2
11926 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
11927 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
11929 $RUNAS $MCREATE $testfile2
11930 $RUNAS setfattr -n lustre.lov -v $value $testfile2
11931 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
11932 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
11933 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
11934 [ $stripe_count -eq $STRIPECOUNT ] ||
11935 error "stripe count $stripe_count != $STRIPECOUNT"
11937 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
11939 compare_stripe_info1() {
11940 local stripe_index_all_zero=true
11942 for num in 1 2 3 4; do
11943 for count in $(seq 1 $STRIPE_COUNT); do
11944 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
11945 local size=$((STRIPE_SIZE * num))
11946 local file=file"$num-$offset-$count"
11947 stripe_size=$($LFS getstripe -S $PWD/$file)
11948 [[ $stripe_size -ne $size ]] &&
11949 error "$file: size $stripe_size != $size"
11950 stripe_count=$($LFS getstripe -c $PWD/$file)
11951 # allow fewer stripes to be created, ORI-601
11952 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
11953 error "$file: count $stripe_count != $count"
11954 stripe_index=$($LFS getstripe -i $PWD/$file)
11955 [[ $stripe_index -ne 0 ]] &&
11956 stripe_index_all_zero=false
11960 $stripe_index_all_zero &&
11961 error "all files are being extracted starting from OST index 0"
11965 have_xattrs_include() {
11966 tar --help | grep -q xattrs-include &&
11967 echo --xattrs-include="lustre.*"
11971 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11972 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11974 XINC=$(have_xattrs_include)
11976 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11977 cd $DIR/$tdir/$tdir
11978 compare_stripe_info1
11980 run_test 102d "tar restore stripe info from tarfile,not keep osts"
11983 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11984 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11986 XINC=$(have_xattrs_include)
11988 test_mkdir $DIR/$tdir.restore
11990 tar cf - --xattrs $tdir | tar xf - \
11991 -C $DIR/$tdir.restore --xattrs $XINC
11992 cd $DIR/$tdir.restore/$tdir
11993 compare_stripe_info1
11995 run_test 102f "tar copy files, not keep osts"
11998 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
11999 skip "must have user_xattr"
12000 [ -z "$(which setfattr 2>/dev/null)" ] &&
12001 skip_env "could not find setfattr"
12002 [ -z "$(which getfattr 2>/dev/null)" ] &&
12003 skip_env "could not find getfattr"
12005 local xsize=${1:-1024} # in bytes
12006 local file=$DIR/$tfile
12007 local value="$(generate_string $xsize)"
12008 local xbig=trusted.big
12012 log "save $xbig on $file"
12013 if [ -z "$toobig" ]
12015 setfattr -n $xbig -v $value $file ||
12016 error "saving $xbig on $file failed"
12018 setfattr -n $xbig -v $value $file &&
12019 error "saving $xbig on $file succeeded"
12023 local orig=$(get_xattr_value $xbig $file)
12024 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
12026 local xsml=trusted.sml
12027 log "save $xsml on $file"
12028 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
12030 local new=$(get_xattr_value $xbig $file)
12031 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
12033 log "grow $xsml on $file"
12034 setfattr -n $xsml -v "$value" $file ||
12035 error "growing $xsml on $file failed"
12037 new=$(get_xattr_value $xbig $file)
12038 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
12039 log "$xbig still valid after growing $xsml"
12044 test_102h() { # bug 15777
12047 run_test 102h "grow xattr from inside inode to external block"
12050 large_xattr_enabled || skip_env "ea_inode feature disabled"
12052 echo "setting xattr of max xattr size: $(max_xattr_size)"
12053 grow_xattr $(max_xattr_size)
12055 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
12056 echo "This should fail:"
12057 grow_xattr $(($(max_xattr_size) + 10)) 1
12059 run_test 102ha "grow xattr from inside inode to external inode"
12061 test_102i() { # bug 17038
12062 [ -z "$(which getfattr 2>/dev/null)" ] &&
12063 skip "could not find getfattr"
12066 ln -s $DIR/$tfile $DIR/${tfile}link
12067 getfattr -n trusted.lov $DIR/$tfile ||
12068 error "lgetxattr on $DIR/$tfile failed"
12069 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
12070 grep -i "no such attr" ||
12071 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
12072 rm -f $DIR/$tfile $DIR/${tfile}link
12074 run_test 102i "lgetxattr test on symbolic link ============"
12077 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12078 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12080 XINC=$(have_xattrs_include)
12081 setup_test102 "$RUNAS"
12082 chown $RUNAS_ID $DIR/$tdir
12083 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
12084 cd $DIR/$tdir/$tdir
12085 compare_stripe_info1 "$RUNAS"
12087 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
12090 [ -z "$(which setfattr 2>/dev/null)" ] &&
12091 skip "could not find setfattr"
12094 # b22187 just check that does not crash for regular file.
12095 setfattr -n trusted.lov $DIR/$tfile
12096 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
12097 local test_kdir=$DIR/$tdir
12098 test_mkdir $test_kdir
12099 local default_size=$($LFS getstripe -S $test_kdir)
12100 local default_count=$($LFS getstripe -c $test_kdir)
12101 local default_offset=$($LFS getstripe -i $test_kdir)
12102 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
12103 error 'dir setstripe failed'
12104 setfattr -n trusted.lov $test_kdir
12105 local stripe_size=$($LFS getstripe -S $test_kdir)
12106 local stripe_count=$($LFS getstripe -c $test_kdir)
12107 local stripe_offset=$($LFS getstripe -i $test_kdir)
12108 [ $stripe_size -eq $default_size ] ||
12109 error "stripe size $stripe_size != $default_size"
12110 [ $stripe_count -eq $default_count ] ||
12111 error "stripe count $stripe_count != $default_count"
12112 [ $stripe_offset -eq $default_offset ] ||
12113 error "stripe offset $stripe_offset != $default_offset"
12114 rm -rf $DIR/$tfile $test_kdir
12116 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
12119 [ -z "$(which getfattr 2>/dev/null)" ] &&
12120 skip "could not find getfattr"
12122 # LU-532 trusted. xattr is invisible to non-root
12123 local testfile=$DIR/$tfile
12127 echo "listxattr as user..."
12128 chown $RUNAS_ID $testfile
12129 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
12130 grep -q "trusted" &&
12131 error "$testfile trusted xattrs are user visible"
12135 run_test 102l "listxattr size test =================================="
12137 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
12138 local path=$DIR/$tfile
12141 listxattr_size_check $path || error "listattr_size_check $path failed"
12143 run_test 102m "Ensure listxattr fails on small bufffer ========"
12147 getxattr() { # getxattr path name
12148 # Return the base64 encoding of the value of xattr name on path.
12152 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
12154 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
12156 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
12158 getfattr --absolute-names --encoding=base64 --name=$name $path |
12159 awk -F= -v name=$name '$1 == name {
12160 print substr($0, index($0, "=") + 1);
12164 test_102n() { # LU-4101 mdt: protect internal xattrs
12165 [ -z "$(which setfattr 2>/dev/null)" ] &&
12166 skip "could not find setfattr"
12167 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
12169 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
12172 local file0=$DIR/$tfile.0
12173 local file1=$DIR/$tfile.1
12174 local xattr0=$TMP/$tfile.0
12175 local xattr1=$TMP/$tfile.1
12176 local namelist="lov lma lmv link fid version som hsm"
12180 rm -rf $file0 $file1 $xattr0 $xattr1
12181 touch $file0 $file1
12183 # Get 'before' xattrs of $file1.
12184 getfattr --absolute-names --dump --match=- $file1 > $xattr0
12186 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
12187 namelist+=" lfsck_namespace"
12188 for name in $namelist; do
12189 # Try to copy xattr from $file0 to $file1.
12190 value=$(getxattr $file0 trusted.$name 2> /dev/null)
12192 setfattr --name=trusted.$name --value="$value" $file1 ||
12193 error "setxattr 'trusted.$name' failed"
12195 # Try to set a garbage xattr.
12196 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
12198 if [[ x$name == "xlov" ]]; then
12199 setfattr --name=trusted.lov --value="$value" $file1 &&
12200 error "setxattr invalid 'trusted.lov' success"
12202 setfattr --name=trusted.$name --value="$value" $file1 ||
12203 error "setxattr invalid 'trusted.$name' failed"
12206 # Try to remove the xattr from $file1. We don't care if this
12207 # appears to succeed or fail, we just don't want there to be
12208 # any changes or crashes.
12209 setfattr --remove=$trusted.$name $file1 2> /dev/null
12212 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
12215 # Try to copy xattr from $file0 to $file1.
12216 value=$(getxattr $file0 trusted.$name 2> /dev/null)
12218 setfattr --name=trusted.$name --value="$value" $file1 ||
12219 error "setxattr 'trusted.$name' failed"
12221 # Try to set a garbage xattr.
12222 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
12224 setfattr --name=trusted.$name --value="$value" $file1 ||
12225 error "setxattr 'trusted.$name' failed"
12227 # Try to remove the xattr from $file1. We don't care if this
12228 # appears to succeed or fail, we just don't want there to be
12229 # any changes or crashes.
12230 setfattr --remove=$trusted.$name $file1 2> /dev/null
12233 # Get 'after' xattrs of file1.
12234 getfattr --absolute-names --dump --match=- $file1 > $xattr1
12236 if ! diff $xattr0 $xattr1; then
12237 error "before and after xattrs of '$file1' differ"
12240 rm -rf $file0 $file1 $xattr0 $xattr1
12244 run_test 102n "silently ignore setxattr on internal trusted xattrs"
12246 test_102p() { # LU-4703 setxattr did not check ownership
12247 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
12248 skip "MDS needs to be at least 2.5.56"
12250 local testfile=$DIR/$tfile
12254 echo "setfacl as user..."
12255 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
12256 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
12258 echo "setfattr as user..."
12259 setfacl -m "u:$RUNAS_ID:---" $testfile
12260 $RUNAS setfattr -x system.posix_acl_access $testfile
12261 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
12263 run_test 102p "check setxattr(2) correctly fails without permission"
12266 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
12267 skip "MDS needs to be at least 2.6.92"
12269 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
12271 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
12274 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
12275 skip "MDS needs to be at least 2.6.93"
12277 touch $DIR/$tfile || error "touch"
12278 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
12279 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
12280 rm $DIR/$tfile || error "rm"
12283 mkdir -p $DIR/$tdir || error "mkdir"
12284 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
12285 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
12286 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
12287 error "$testfile error deleting user.author1"
12288 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
12289 grep "user.$(basename $tdir)" &&
12290 error "$tdir did not delete user.$(basename $tdir)"
12291 rmdir $DIR/$tdir || error "rmdir"
12294 test_mkdir $DIR/$tdir
12295 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
12296 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
12297 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
12298 error "$testfile error deleting user.author1"
12299 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
12300 grep "user.$(basename $tdir)" &&
12301 error "$tdir did not delete user.$(basename $tdir)"
12302 rmdir $DIR/$tdir || error "rm striped dir"
12304 run_test 102r "set EAs with empty values"
12307 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
12308 skip "MDS needs to be at least 2.11.52"
12310 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12312 save_lustre_params client "llite.*.xattr_cache" > $save
12314 for cache in 0 1; do
12315 lctl set_param llite.*.xattr_cache=$cache
12318 touch $DIR/$tfile || error "touch"
12319 for prefix in lustre security system trusted user; do
12320 # Note getxattr() may fail with 'Operation not
12321 # supported' or 'No such attribute' depending
12322 # on prefix and cache.
12323 getfattr -n $prefix.n102s $DIR/$tfile &&
12324 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
12328 restore_lustre_params < $save
12330 run_test 102s "getting nonexistent xattrs should fail"
12333 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
12334 skip "MDS needs to be at least 2.11.52"
12336 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12338 save_lustre_params client "llite.*.xattr_cache" > $save
12340 for cache in 0 1; do
12341 lctl set_param llite.*.xattr_cache=$cache
12343 for buf_size in 0 256; do
12345 touch $DIR/$tfile || error "touch"
12346 setfattr -n user.multiop $DIR/$tfile
12347 $MULTIOP $DIR/$tfile oa$buf_size ||
12348 error "cannot get zero length xattr value (buf_size = $buf_size)"
12352 restore_lustre_params < $save
12354 run_test 102t "zero length xattr values handled correctly"
12358 local test=$LUSTRE/tests/acl/$1.test
12359 local tmp=$(mktemp -t $1-XXXXXX).test
12367 local sedusers="-e s/bin/$bin/g -e s/daemon/$dmn/g"
12368 local sedgroups="-e s/:users/:$grp/g"
12369 [[ -z "$nbd" ]] || sedusers+=" -e s/nobody/$nbd/g"
12371 sed $sedusers $sedgroups < $test > $tmp
12372 stack_trap "rm -f $tmp"
12373 [[ -s $tmp ]] || error "sed failed to create test script"
12375 echo "performing $1 with bin='$bin' daemon='$dmn' users='$grp'..."
12376 $LUSTRE/tests/acl/run $tmp || error "run_acl_subtest '$1' failed"
12380 [ "$UID" != 0 ] && skip "must run as root"
12381 $GSS && skip_env "could not run under gss"
12382 [[ "$(lctl get_param -n mdc.*-mdc-*.connect_flags)" =~ "acl" ]] ||
12383 skip_env "must have acl enabled"
12384 which setfacl || skip_env "could not find setfacl"
12385 remote_mds_nodsh && skip "remote MDS with nodsh"
12387 local mdts=$(comma_list $(mdts_nodes))
12388 local saved=$(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.job_xattr)
12390 [[ -z "$saved" ]] || do_nodes $mdts $LCTL set_param mdt.*.job_xattr=NONE
12391 stack_trap "[[ -z \"$saved\" ]] || \
12392 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=$saved" EXIT
12394 ACLBIN=${ACLBIN:-"bin"}
12395 ACLDMN=${ACLDMN:-"daemon"}
12396 ACLGRP=${ACLGRP:-"users"}
12397 ACLNBD=${ACLNBD:-"nobody"}
12400 [[ "$(id -u $ACLBIN)" != "$(do_facet mds1 id -u $ACLBIN)" ]]; then
12401 echo "bad 'bin' user '$ACLBIN', using '$USER0'"
12403 if ! id $ACLBIN ; then
12405 skip_env "can't find suitable ACL 'bin' $ACLBIN"
12408 if ! id $ACLDMN || (( $(id -u $ACLDMN) < $(id -u $ACLBIN) )) ||
12409 [[ "$(id -u $ACLDMN)" != "$(do_facet mds1 id -u $ACLDMN)" ]]; then
12410 echo "bad 'daemon' user '$ACLDMN', using '$USER1'"
12412 if ! id $ACLDMN ; then
12414 skip_env "can't find suitable ACL 'daemon' $ACLDMN"
12417 if ! getent group $ACLGRP; then
12418 echo "missing 'users' group '$ACLGRP', using '$TSTUSR'"
12420 if ! getent group $ACLGRP; then
12421 echo "cannot find group '$ACLGRP', adding it"
12423 add_group 60000 $ACLGRP
12427 local bingid=$(getent group $ACLBIN | cut -d: -f 3)
12428 local dmngid=$(getent group $ACLDMN | cut -d: -f 3)
12429 local grpgid=$(getent group $ACLGRP | cut -d: -f 3)
12431 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
12432 echo "group '$ACLGRP' has low gid=$grpgid, use '$TSTUSR'"
12434 if ! getent group $ACLGRP; then
12435 echo "cannot find group '$ACLGRP', adding it"
12437 add_group 60000 $ACLGRP
12439 grpgid=$(getent group $ACLGRP | cut -d: -f 3)
12440 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
12442 skip_env "$ACLGRP gid=$grpgid less than $bingid|$dmngid"
12446 gpasswd -a $ACLDMN $ACLBIN ||
12447 error "setting client group failed" # LU-5641
12448 do_facet mds1 gpasswd -a $ACLDMN $ACLBIN ||
12449 error "setting MDS group failed" # LU-5641
12451 declare -a identity_old
12453 for ((num = 1; num <= $MDSCOUNT; num++)); do
12454 switch_identity $num true || identity_old[$num]=$?
12457 SAVE_UMASK=$(umask)
12459 mkdir -p $DIR/$tdir
12462 run_acl_subtest cp $ACLBIN $ACLDMN $ACLGRP
12463 run_acl_subtest getfacl-noacl $ACLBIN $ACLDMN $ACLGRP
12464 run_acl_subtest misc $ACLBIN $ACLDMN $ACLGRP
12465 run_acl_subtest permissions $ACLBIN $ACLDMN $ACLGRP
12466 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
12467 # CentOS7- uses nobody=99, while newer distros use nobody=65534
12468 if ! id -u $ACLNBD ||
12469 (( $(id -u nobody) != $(do_facet mds1 id -u nobody) )); then
12471 if ! id -u $ACLNBD; then
12475 if [[ -n "$ACLNBD" ]] && ! getent group $ACLNBD; then
12476 add_group $(id -u $ACLNBD) $ACLNBD
12477 if ! getent group $ACLNBD; then
12481 if (( $MDS1_VERSION > $(version_code 2.8.55) )) &&
12482 [[ -n "$ACLNBD" ]] && which setfattr; then
12483 run_acl_subtest permissions_xattr \
12484 $ACLBIN $ACLDMN $ACLGRP $ACLNBD
12485 elif [[ -z "$ACLNBD" ]]; then
12486 echo "skip 'permission_xattr' test - missing 'nobody' user/grp"
12488 echo "skip 'permission_xattr' test - missing setfattr command"
12490 run_acl_subtest setfacl $ACLBIN $ACLDMN $ACLGRP
12492 # inheritance test got from HP
12493 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
12494 chmod +x make-tree || error "chmod +x failed"
12495 run_acl_subtest inheritance $ACLBIN $ACLDMN $ACLGRP
12498 echo "LU-974 ignore umask when acl is enabled..."
12499 run_acl_subtest 974 $ACLBIN $ACLDMN $ACLGRP
12500 if [ $MDSCOUNT -ge 2 ]; then
12501 run_acl_subtest 974_remote $ACLBIN $ACLDMN $ACLGRP
12504 echo "LU-2561 newly created file is same size as directory..."
12505 if [ "$mds1_FSTYPE" != "zfs" ]; then
12506 run_acl_subtest 2561 $ACLBIN $ACLDMN $ACLGRP
12508 run_acl_subtest 2561_zfs $ACLBIN $ACLDMN $ACLGRP
12511 run_acl_subtest 4924 $ACLBIN $ACLDMN $ACLGRP
12516 for ((num = 1; num <= $MDSCOUNT; num++)); do
12517 if [[ "${identity_old[$num]}" == 1 ]]; then
12518 switch_identity $num false || identity_old[$num]=$?
12522 run_test 103a "acl test"
12528 stack_trap "rm -f $DIR/$tfile.*"
12529 for U in {0..511}; do
12531 local O=$(printf "%04o" $U)
12533 umask $(printf "%04o" $((511 ^ $O)))
12534 $LFS setstripe -c 1 $DIR/$tfile.s$O
12535 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
12537 (( $S == ($O & 0666) )) ||
12538 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
12540 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
12541 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
12542 (( $S == ($O & 0666) )) ||
12543 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
12545 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
12546 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
12547 (( $S == ($O & 0666) )) ||
12548 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
12549 rm -f $DIR/$tfile.[smp]$0
12553 # limit the concurrently running threads to 64. LU-11878
12554 local idx=$((U % 64))
12555 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
12560 run_test 103b "umask lfs setstripe"
12563 mkdir -p $DIR/$tdir
12564 cp -rp $DIR/$tdir $DIR/$tdir.bak
12566 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
12567 error "$DIR/$tdir shouldn't contain default ACL"
12568 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
12569 error "$DIR/$tdir.bak shouldn't contain default ACL"
12572 run_test 103c "'cp -rp' won't set empty acl"
12577 local saved_debug=$($LCTL get_param -n debug)
12579 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
12580 skip "MDS needs to be at least 2.14.52"
12582 large_xattr_enabled || skip_env "ea_inode feature disabled"
12584 mkdir -p $DIR/$tdir
12585 # add big LOV EA to cause reply buffer overflow earlier
12586 $LFS setstripe -C 1000 $DIR/$tdir
12587 lctl set_param mdc.*-mdc*.stats=clear
12589 $LCTL set_param debug=0
12590 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
12591 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
12593 # add a large number of default ACLs (expect 8000+ for 2.13+)
12594 for U in {2..7000}; do
12595 setfacl -d -m user:$U:rwx $DIR/$tdir ||
12596 error "Able to add just $U default ACLs"
12598 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
12599 echo "$numacl default ACLs created"
12601 stat $DIR/$tdir || error "Cannot stat directory"
12602 # check file creation
12603 touch $DIR/$tdir/$tfile ||
12604 error "failed to create $tfile with $numacl default ACLs"
12605 stat $DIR/$tdir/$tfile || error "Cannot stat file"
12606 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12607 echo "$fileacl ACLs were inherited"
12608 (( $fileacl == $numacl )) ||
12609 error "Not all default ACLs were inherited: $numacl != $fileacl"
12610 # check that new ACLs creation adds new ACLs to inherited ACLs
12611 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
12612 error "Cannot set new ACL"
12613 numacl=$((numacl + 1))
12614 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12615 (( $fileacl == $numacl )) ||
12616 error "failed to add new ACL: $fileacl != $numacl as expected"
12617 # adds more ACLs to a file to reach their maximum at 8000+
12619 for U in {20000..25000}; do
12620 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
12621 numacl=$((numacl + 1))
12623 echo "Added $numacl more ACLs to the file"
12624 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12625 echo "Total $fileacl ACLs in file"
12626 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
12627 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
12628 rmdir $DIR/$tdir || error "Cannot remove directory"
12630 run_test 103e "inheritance of big amount of default ACLs"
12633 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
12634 skip "MDS needs to be at least 2.14.51"
12636 large_xattr_enabled || skip_env "ea_inode feature disabled"
12638 # enable changelog to consume more internal MDD buffers
12641 mkdir -p $DIR/$tdir
12643 $LFS setstripe -C 1000 $DIR/$tdir
12644 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
12645 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
12646 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
12647 rmdir $DIR/$tdir || error "Cannot remove directory"
12649 run_test 103f "changelog doesn't interfere with default ACLs buffers"
12652 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12655 lfs df || error "lfs df failed"
12656 lfs df -ih || error "lfs df -ih failed"
12657 lfs df -h $DIR || error "lfs df -h $DIR failed"
12658 lfs df -i $DIR || error "lfs df -i $DIR failed"
12659 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
12660 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
12662 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
12663 lctl --device %$OSC deactivate
12664 lfs df || error "lfs df with deactivated OSC failed"
12665 lctl --device %$OSC activate
12666 # wait the osc back to normal
12667 wait_osc_import_ready client ost
12669 lfs df || error "lfs df with reactivated OSC failed"
12672 run_test 104a "lfs df [-ih] [path] test ========================="
12675 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12676 [ $RUNAS_ID -eq $UID ] &&
12677 skip_env "RUNAS_ID = UID = $UID -- skipping"
12679 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
12680 grep "Permission denied" | wc -l)))
12681 if [ $denied_cnt -ne 0 ]; then
12682 error "lfs check servers test failed"
12685 run_test 104b "$RUNAS lfs check servers test ===================="
12688 # Verify $1 is within range of $2.
12689 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
12690 # $1 is <= 2% of $2. Else Fail.
12693 # Strip all units (M, G, T)
12694 actual=$(echo $1 | tr -d A-Z)
12695 expect=$(echo $2 | tr -d A-Z)
12697 expect_lo=$(($expect * 98 / 100)) # 2% below
12698 expect_hi=$(($expect * 102 / 100)) # 2% above
12700 # permit 2% drift above and below
12701 (( $actual >= $expect_lo && $actual <= $expect_hi ))
12705 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12706 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
12708 local ost_param="osd-zfs.$FSNAME-OST0000."
12709 local mdt_param="osd-zfs.$FSNAME-MDT0000."
12710 local ofacets=$(get_facets OST)
12711 local mfacets=$(get_facets MDS)
12712 local saved_ost_blocks=
12713 local saved_mdt_blocks=
12715 echo "Before recordsize change"
12716 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
12717 df=($(df -h | grep "$MOUNT"$))
12720 echo "lfs output : ${lfs_df[*]}"
12721 echo "df output : ${df[*]}"
12723 for facet in ${ofacets//,/ }; do
12724 if [ -z $saved_ost_blocks ]; then
12725 saved_ost_blocks=$(do_facet $facet \
12726 lctl get_param -n $ost_param.blocksize)
12727 echo "OST Blocksize: $saved_ost_blocks"
12729 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12730 do_facet $facet zfs set recordsize=32768 $ost
12733 # BS too small. Sufficient for functional testing.
12734 for facet in ${mfacets//,/ }; do
12735 if [ -z $saved_mdt_blocks ]; then
12736 saved_mdt_blocks=$(do_facet $facet \
12737 lctl get_param -n $mdt_param.blocksize)
12738 echo "MDT Blocksize: $saved_mdt_blocks"
12740 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12741 do_facet $facet zfs set recordsize=32768 $mdt
12744 # Give new values chance to reflect change
12747 echo "After recordsize change"
12748 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
12749 df_after=($(df -h | grep "$MOUNT"$))
12752 echo "lfs output : ${lfs_df_after[*]}"
12753 echo "df output : ${df_after[*]}"
12756 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
12757 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
12758 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
12759 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
12760 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
12761 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
12764 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
12765 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
12766 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
12767 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
12768 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
12769 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
12771 # Restore MDT recordize back to original
12772 for facet in ${mfacets//,/ }; do
12773 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12774 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
12777 # Restore OST recordize back to original
12778 for facet in ${ofacets//,/ }; do
12779 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12780 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
12785 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
12788 (( $RUNAS_ID != $UID )) ||
12789 skip_env "RUNAS_ID = UID = $UID -- skipping"
12791 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
12792 skip "lustre version doesn't support lctl dl with non-root"
12794 # debugfs only allows root users to access files, so the
12795 # previous move of the "devices" file to debugfs broke
12796 # "lctl dl" for non-root users. The LU-9680 Netlink
12797 # interface again allows non-root users to list devices.
12798 [ "$($RUNAS $LCTL dl | wc -l)" -ge 3 ] ||
12799 error "lctl dl doesn't work for non root"
12801 ost_count="$($RUNAS $LCTL dl | grep $FSNAME-OST* | wc -l)"
12802 [ "$ost_count" -eq $OSTCOUNT ] ||
12803 error "lctl dl reports wrong number of OST devices"
12805 mdt_count="$($RUNAS $LCTL dl | grep $FSNAME-MDT* | wc -l)"
12806 [ "$mdt_count" -eq $MDSCOUNT ] ||
12807 error "lctl dl reports wrong number of MDT devices"
12809 run_test 104d "$RUNAS lctl dl test"
12812 # doesn't work on 2.4 kernels
12814 if $(flock_is_enabled); then
12815 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
12817 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
12821 run_test 105a "flock when mounted without -o flock test ========"
12825 if $(flock_is_enabled); then
12826 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
12828 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
12832 run_test 105b "fcntl when mounted without -o flock test ========"
12836 if $(flock_is_enabled); then
12837 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
12839 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
12843 run_test 105c "lockf when mounted without -o flock test"
12845 test_105d() { # bug 15924
12846 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12848 test_mkdir $DIR/$tdir
12849 flock_is_enabled || skip_env "mount w/o flock enabled"
12850 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
12851 $LCTL set_param fail_loc=0x80000315
12852 flocks_test 2 $DIR/$tdir
12854 run_test 105d "flock race (should not freeze) ========"
12856 test_105e() { # bug 22660 && 22040
12857 flock_is_enabled || skip_env "mount w/o flock enabled"
12860 flocks_test 3 $DIR/$tfile
12862 run_test 105e "Two conflicting flocks from same process"
12864 test_106() { #bug 10921
12865 test_mkdir $DIR/$tdir
12866 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
12867 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
12869 run_test 106 "attempt exec of dir followed by chown of that dir"
12872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12880 local save_pattern=$(sysctl -n kernel.core_pattern)
12881 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
12882 sysctl -w kernel.core_pattern=$file
12883 sysctl -w kernel.core_uses_pid=0
12885 ulimit -c unlimited
12891 kill -s 11 $SLEEPPID
12893 if [ -e $file ]; then
12894 size=`stat -c%s $file`
12895 [ $size -eq 0 ] && error "Fail to create core file $file"
12897 error "Fail to create core file $file"
12900 sysctl -w kernel.core_pattern=$save_pattern
12901 sysctl -w kernel.core_uses_pid=$save_uses_pid
12904 run_test 107 "Coredump on SIG"
12907 test_mkdir $DIR/$tdir
12908 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
12909 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
12910 error "mkdir with 256 char should fail, but did not"
12911 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
12912 error "create with 255 char failed"
12913 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
12914 error "create with 256 char should fail, but did not"
12919 run_test 110 "filename length checking"
12921 test_116a() { # was previously test_116()
12922 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12923 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12924 remote_mds_nodsh && skip "remote MDS with nodsh"
12926 echo -n "Free space priority "
12927 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
12932 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
12933 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
12934 stack_trap simple_cleanup_common
12936 # Check if we need to generate uneven OSTs
12937 test_mkdir -p $DIR/$tdir/OST${MINI}
12938 local FILL=$((MINV / 4))
12939 local DIFF=$((MAXV - MINV))
12940 local DIFF2=$((DIFF * 100 / MINV))
12942 local threshold=$(do_facet $SINGLEMDS \
12943 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
12944 threshold=${threshold%%%}
12945 echo -n "Check for uneven OSTs: "
12946 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
12948 if [[ $DIFF2 -gt $threshold ]]; then
12950 echo "Don't need to fill OST$MINI"
12952 # generate uneven OSTs. Write 2% over the QOS threshold value
12954 DIFF=$((threshold - DIFF2 + 2))
12955 DIFF2=$((MINV * DIFF / 100))
12956 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
12957 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
12958 error "setstripe failed"
12959 DIFF=$((DIFF2 / 2048))
12961 while [ $i -lt $DIFF ]; do
12963 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
12964 bs=2M count=1 2>/dev/null
12973 DIFF=$((MAXV - MINV))
12974 DIFF2=$((DIFF * 100 / MINV))
12975 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
12976 if [ $DIFF2 -gt $threshold ]; then
12979 skip "QOS imbalance criteria not met"
12987 # now fill using QOS
12988 $LFS setstripe -c 1 $DIR/$tdir
12989 FILL=$((FILL / 200))
12990 if [ $FILL -gt 600 ]; then
12993 echo "writing $FILL files to QOS-assigned OSTs"
12995 while [ $i -lt $FILL ]; do
12997 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
12998 count=1 2>/dev/null
13001 echo "wrote $i 200k files"
13005 echo "Note: free space may not be updated, so measurements might be off"
13007 DIFF2=$((MAXV - MINV))
13008 echo "free space delta: orig $DIFF final $DIFF2"
13009 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
13010 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
13011 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
13012 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
13013 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
13014 if [[ $DIFF -gt 0 ]]; then
13015 FILL=$((DIFF2 * 100 / DIFF - 100))
13016 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
13019 # Figure out which files were written where
13020 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
13021 awk '/'$MINI1': / {print $2; exit}')
13023 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
13024 echo "$MINC files created on smaller OST $MINI1"
13025 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
13026 awk '/'$MAXI1': / {print $2; exit}')
13028 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
13029 echo "$MAXC files created on larger OST $MAXI1"
13030 if [[ $MINC -gt 0 ]]; then
13031 FILL=$((MAXC * 100 / MINC - 100))
13032 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
13034 [[ $MAXC -gt $MINC ]] ||
13035 error_ignore LU-9 "stripe QOS didn't balance free space"
13037 run_test 116a "stripe QOS: free space balance ==================="
13039 test_116b() { # LU-2093
13040 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13041 remote_mds_nodsh && skip "remote MDS with nodsh"
13043 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
13044 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
13045 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
13046 [ -z "$old_rr" ] && skip "no QOS"
13047 do_facet $SINGLEMDS lctl set_param \
13048 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
13049 mkdir -p $DIR/$tdir
13050 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
13051 createmany -o $DIR/$tdir/f- 20 || error "can't create"
13052 do_facet $SINGLEMDS lctl set_param fail_loc=0
13054 do_facet $SINGLEMDS lctl set_param \
13055 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
13057 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
13059 test_117() # bug 10891
13061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13063 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
13064 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
13065 lctl set_param fail_loc=0x21e
13066 > $DIR/$tfile || error "truncate failed"
13067 lctl set_param fail_loc=0
13068 echo "Truncate succeeded."
13071 run_test 117 "verify osd extend =========="
13073 NO_SLOW_RESENDCOUNT=4
13074 export OLD_RESENDCOUNT=""
13075 set_resend_count () {
13076 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
13077 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
13078 lctl set_param -n $PROC_RESENDCOUNT $1
13079 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
13082 # for reduce test_118* time (b=14842)
13083 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
13085 # Reset async IO behavior after error case
13087 FILE=$DIR/reset_async
13089 # Ensure all OSCs are cleared
13090 $LFS setstripe -c -1 $FILE
13091 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
13096 test_118a() #bug 11710
13098 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13102 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13103 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13104 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
13106 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13107 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13112 run_test 118a "verify O_SYNC works =========="
13116 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13117 remote_ost_nodsh && skip "remote OST with nodsh"
13121 #define OBD_FAIL_SRV_ENOENT 0x217
13122 set_nodes_failloc "$(osts_nodes)" 0x217
13123 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13125 set_nodes_failloc "$(osts_nodes)" 0
13126 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13127 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13130 if [[ $RC -eq 0 ]]; then
13131 error "Must return error due to dropped pages, rc=$RC"
13135 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13136 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13140 echo "Dirty pages not leaked on ENOENT"
13142 # Due to the above error the OSC will issue all RPCs syncronously
13143 # until a subsequent RPC completes successfully without error.
13144 $MULTIOP $DIR/$tfile Ow4096yc
13149 run_test 118b "Reclaim dirty pages on fatal error =========="
13153 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13155 # for 118c, restore the original resend count, LU-1940
13156 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
13157 set_resend_count $OLD_RESENDCOUNT
13158 remote_ost_nodsh && skip "remote OST with nodsh"
13162 #define OBD_FAIL_OST_EROFS 0x216
13163 set_nodes_failloc "$(osts_nodes)" 0x216
13165 # multiop should block due to fsync until pages are written
13166 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
13170 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
13171 error "Multiop failed to block on fsync, pid=$MULTIPID"
13174 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13176 if [[ $WRITEBACK -eq 0 ]]; then
13177 error "No page in writeback, writeback=$WRITEBACK"
13180 set_nodes_failloc "$(osts_nodes)" 0
13183 if [[ $RC -ne 0 ]]; then
13184 error "Multiop fsync failed, rc=$RC"
13187 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13188 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13190 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13191 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13195 echo "Dirty pages flushed via fsync on EROFS"
13198 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
13200 # continue to use small resend count to reduce test_118* time (b=14842)
13201 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
13205 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13206 remote_ost_nodsh && skip "remote OST with nodsh"
13210 #define OBD_FAIL_OST_BRW_PAUSE_BULK
13211 set_nodes_failloc "$(osts_nodes)" 0x214
13212 # multiop should block due to fsync until pages are written
13213 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
13217 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
13218 error "Multiop failed to block on fsync, pid=$MULTIPID"
13221 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13223 if [[ $WRITEBACK -eq 0 ]]; then
13224 error "No page in writeback, writeback=$WRITEBACK"
13227 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
13228 set_nodes_failloc "$(osts_nodes)" 0
13230 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13231 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13233 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13234 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13238 echo "Dirty pages gaurenteed flushed via fsync"
13241 run_test 118d "Fsync validation inject a delay of the bulk =========="
13244 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13248 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
13249 lctl set_param fail_loc=0x8000040a
13251 # Should simulate EINVAL error which is fatal
13252 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13254 if [[ $RC -eq 0 ]]; then
13255 error "Must return error due to dropped pages, rc=$RC"
13258 lctl set_param fail_loc=0x0
13260 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13261 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13262 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13264 if [[ $LOCKED -ne 0 ]]; then
13265 error "Locked pages remain in cache, locked=$LOCKED"
13268 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13269 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13273 echo "No pages locked after fsync"
13278 run_test 118f "Simulate unrecoverable OSC side error =========="
13281 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13285 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
13286 lctl set_param fail_loc=0x406
13288 # simulate local -ENOMEM
13289 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13292 lctl set_param fail_loc=0
13293 if [[ $RC -eq 0 ]]; then
13294 error "Must return error due to dropped pages, rc=$RC"
13297 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13298 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13299 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13301 if [[ $LOCKED -ne 0 ]]; then
13302 error "Locked pages remain in cache, locked=$LOCKED"
13305 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13306 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13310 echo "No pages locked after fsync"
13315 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
13318 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13319 remote_ost_nodsh && skip "remote OST with nodsh"
13323 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
13324 set_nodes_failloc "$(osts_nodes)" 0x20e
13325 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
13326 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13329 set_nodes_failloc "$(osts_nodes)" 0
13330 if [[ $RC -eq 0 ]]; then
13331 error "Must return error due to dropped pages, rc=$RC"
13334 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13335 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13336 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13338 if [[ $LOCKED -ne 0 ]]; then
13339 error "Locked pages remain in cache, locked=$LOCKED"
13342 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13343 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13347 echo "No pages locked after fsync"
13351 run_test 118h "Verify timeout in handling recoverables errors =========="
13353 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
13356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13357 remote_ost_nodsh && skip "remote OST with nodsh"
13361 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
13362 set_nodes_failloc "$(osts_nodes)" 0x20e
13364 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
13365 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
13368 set_nodes_failloc "$(osts_nodes)" 0
13372 if [[ $RC -ne 0 ]]; then
13373 error "got error, but should be not, rc=$RC"
13376 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13377 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13378 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
13379 if [[ $LOCKED -ne 0 ]]; then
13380 error "Locked pages remain in cache, locked=$LOCKED"
13383 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13384 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13388 echo "No pages locked after fsync"
13392 run_test 118i "Fix error before timeout in recoverable error =========="
13394 [ "$SLOW" = "no" ] && set_resend_count 4
13397 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13398 remote_ost_nodsh && skip "remote OST with nodsh"
13402 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
13403 set_nodes_failloc "$(osts_nodes)" 0x220
13405 # return -EIO from OST
13406 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13408 set_nodes_failloc "$(osts_nodes)" 0x0
13409 if [[ $RC -eq 0 ]]; then
13410 error "Must return error due to dropped pages, rc=$RC"
13413 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13414 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13415 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
13416 if [[ $LOCKED -ne 0 ]]; then
13417 error "Locked pages remain in cache, locked=$LOCKED"
13420 # in recoverable error on OST we want resend and stay until it finished
13421 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13422 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13426 echo "No pages locked after fsync"
13430 run_test 118j "Simulate unrecoverable OST side error =========="
13434 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13435 remote_ost_nodsh && skip "remote OSTs with nodsh"
13437 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
13438 set_nodes_failloc "$(osts_nodes)" 0x20e
13439 test_mkdir $DIR/$tdir
13441 for ((i=0;i<10;i++)); do
13442 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
13443 error "dd to $DIR/$tdir/$tfile-$i failed" )&
13450 set_nodes_failloc "$(osts_nodes)" 0
13453 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
13455 test_118l() # LU-646
13457 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13459 test_mkdir $DIR/$tdir
13460 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
13463 run_test 118l "fsync dir"
13465 test_118m() # LU-3066
13467 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13469 test_mkdir $DIR/$tdir
13470 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
13473 run_test 118m "fdatasync dir ========="
13475 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
13482 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13483 remote_ost_nodsh && skip "remote OSTs with nodsh"
13485 # Sleep to avoid a cached response.
13486 #define OBD_STATFS_CACHE_SECONDS 1
13489 # Inject a 10 second delay in the OST_STATFS handler.
13490 #define OBD_FAIL_OST_STATFS_DELAY 0x242
13491 set_nodes_failloc "$(osts_nodes)" 0x242
13494 stat --file-system $MOUNT > /dev/null
13497 set_nodes_failloc "$(osts_nodes)" 0
13499 if ((end - begin > 20)); then
13500 error "statfs took $((end - begin)) seconds, expected 10"
13503 run_test 118n "statfs() sends OST_STATFS requests in parallel"
13505 test_119a() # bug 11737
13507 BSIZE=$((512 * 1024))
13508 directio write $DIR/$tfile 0 1 $BSIZE
13509 # We ask to read two blocks, which is more than a file size.
13510 # directio will indicate an error when requested and actual
13511 # sizes aren't equeal (a normal situation in this case) and
13512 # print actual read amount.
13513 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
13514 if [ "$NOB" != "$BSIZE" ]; then
13515 error "read $NOB bytes instead of $BSIZE"
13519 run_test 119a "Short directIO read must return actual read amount"
13521 test_119b() # bug 11737
13523 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13525 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
13526 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
13528 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
13529 error "direct read failed"
13532 run_test 119b "Sparse directIO read must return actual read amount"
13534 test_119c() # bug 13099
13537 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
13538 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
13541 run_test 119c "Testing for direct read hitting hole"
13543 # Note: test 119d was removed, skipping 119d for new tests to avoid polluting
13544 # Maloo test history
13548 (( $MDS1_VERSION >= $(version_code 2.15.58) )) ||
13549 skip "Need server version at least 2.15.58"
13550 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13552 local stripe_size=$((1024 * 1024)) #1 MiB
13553 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13554 local file_size=$((25 * stripe_size))
13557 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13558 stack_trap "rm -f $DIR/$tfile*"
13560 # Just a bit bigger than the largest size in the test set below
13561 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
13562 error "buffered i/o to create file failed"
13564 # trivial test of unaligned DIO
13565 dd if=$DIR/$tfile.1 bs=4095 of=$DIR/$tfile.2 count=4 \
13566 iflag=direct oflag=direct ||
13567 error "trivial unaligned dio failed"
13569 # Test of disabling unaligned DIO support
13570 $LCTL set_param llite.*.unaligned_dio=0
13571 stack_trap "$LCTL set_param llite.*.unaligned_dio=1"
13572 echo "testing disabling unaligned DIO - 'invalid argument' expected:"
13573 dd if=$DIR/$tfile.1 bs=1024 of=$DIR/$tfile.2 count=4 \
13574 iflag=direct oflag=direct &&
13575 error "unaligned dio succeeded when disabled"
13576 $LCTL set_param llite.*.unaligned_dio=1
13578 # Clean up before next part of test
13579 rm -f $DIR/$tfile.2
13581 if zfs_or_rotational; then
13582 # DIO on ZFS can take up to 2 seconds per IO
13583 # rotational is better, but still slow.
13584 # Limit testing on those media to larger sizes
13585 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
13586 $((stripe_size + 1024))"
13588 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
13589 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
13590 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
13591 $((stripe_size - 1)) $stripe_size \
13592 $((stripe_size + 1)) $((stripe_size * 3/2)) \
13593 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
13596 for bs in $bsizes; do
13597 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13598 echo "Read/write with DIO at size $bs"
13599 # Read and write with DIO from source to dest
13600 dd if=$DIR/$tfile.1 bs=$bs of=$DIR/$tfile.2 \
13601 iflag=direct oflag=direct ||
13604 ls -la $DIR/$tfile.1 $DIR/$tfile.2
13605 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
13606 error "size incorrect, file copy read/write bsize: $bs"
13607 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13608 error "files differ, bsize $bs"
13609 rm -f $DIR/$tfile.2
13612 run_test 119e "Basic tests of dio read and write at various sizes"
13616 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13618 local stripe_size=$((1024 * 1024)) #1 MiB
13619 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13620 local file_size=$((25 * stripe_size))
13623 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13624 stack_trap "rm -f $DIR/$tfile*"
13626 # Just a bit bigger than the largest size in the test set below
13627 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
13628 error "buffered i/o to create file failed"
13630 if zfs_or_rotational; then
13631 # DIO on ZFS can take up to 2 seconds per IO
13632 # rotational is better, but still slow.
13633 # Limit testing on those media to larger sizes
13634 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
13635 $((stripe_size + 1024))"
13637 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
13638 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
13639 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
13640 $((stripe_size - 1)) $stripe_size \
13641 $((stripe_size + 1)) $((stripe_size * 3/2)) \
13642 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
13645 for bs in $bsizes; do
13646 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13647 # Read and write with DIO from source to dest in two
13648 # threads - should give correct copy of file
13651 dd if=$DIR/$tfile.1 bs=$bs of=$DIR/$tfile.2 iflag=direct \
13652 oflag=direct conv=notrunc &
13654 # Note block size is different here for a more interesting race
13655 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 \
13656 iflag=direct oflag=direct conv=notrunc &
13662 if (( rc1 != 0 )); then
13663 error "dio copy 1 w/bsize $bs failed: $rc1"
13665 if (( rc2 != 0 )); then
13666 error "dio copy 2 w/bsize $bs failed: $rc2"
13670 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
13671 error "size incorrect, file copy read/write bsize: $bs"
13672 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13673 error "files differ, bsize $bs"
13674 rm -f $DIR/$tfile.2
13677 run_test 119f "dio vs dio race"
13681 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13683 local stripe_size=$((1024 * 1024)) #1 MiB
13684 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13685 local file_size=$((25 * stripe_size))
13688 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13689 stack_trap "rm -f $DIR/$tfile*"
13691 # Just a bit bigger than the largest size in the test set below
13692 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
13693 error "buffered i/o to create file failed"
13695 if zfs_or_rotational; then
13696 # DIO on ZFS can take up to 2 seconds per IO
13697 # rotational is better, but still slow.
13698 # Limit testing on those media to larger sizes
13699 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
13700 $((stripe_size + 1024))"
13702 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
13703 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
13704 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
13705 $((stripe_size - 1)) $stripe_size \
13706 $((stripe_size + 1)) $((stripe_size * 3/2)) \
13707 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
13710 for bs in $bsizes; do
13711 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13713 dd if=$DIR/$tfile.1 bs=$bs of=$DIR/$tfile.2 iflag=direct \
13714 oflag=direct conv=notrunc &
13716 # Buffered I/O with similar but not the same block size
13717 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 &
13723 if (( rc1 != 0 )); then
13724 error "dio copy 1 w/bsize $bs failed: $rc1"
13726 if (( rc2 != 0 )); then
13727 error "buffered copy 2 w/bsize $bs failed: $rc2"
13730 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
13731 error "size incorrect"
13732 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13733 error "files differ, bsize $bs"
13734 rm -f $DIR/$tfile.2
13737 run_test 119g "dio vs buffered I/O race"
13741 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13743 local stripe_size=$((1024 * 1024)) #1 MiB
13744 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13745 local file_size=$((25 * stripe_size))
13748 stack_trap "rm -f $DIR/$tfile.*"
13750 if zfs_or_rotational; then
13751 # DIO on ZFS can take up to 2 seconds per IO
13752 # rotational is better, but still slow.
13753 # Limit testing on those media to larger sizes
13754 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
13755 $((stripe_size + 1024))"
13757 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
13758 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
13759 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
13760 $((stripe_size - 1)) $stripe_size \
13761 $((stripe_size + 1)) $((stripe_size * 3/2)) \
13762 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
13765 for bs in $bsizes; do
13766 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13767 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13768 echo "unaligned writes of blocksize: $bs"
13769 # Write a file with unaligned DIO and regular DIO, and compare
13771 # with 'u', multiop randomly unaligns the io from the buffer
13772 $MULTIOP $DIR/$tfile.1 \
13773 oO_CREAT:O_RDWR:O_DIRECT:wu${bs}wu${bs}wu${bs}wu${bs}wu${bs} ||
13774 error "multiop memory unaligned write failed, $bs"
13775 $MULTIOP $DIR/$tfile.2 \
13776 oO_CREAT:O_RDWR:O_DIRECT:w${bs}w${bs}w${bs}w${bs}w${bs} ||
13777 error "multiop memory aligned write failed, $bs"
13779 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13780 error "files differ, bsize $bs"
13781 rm -f $DIR/$tfile.*
13784 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13785 dd if=/dev/zero bs=$((stripe_size * 5)) of=$DIR/$tfile.1 count=5 ||
13786 error "dd to create source file for read failed"
13788 # Just a few quick tests to make sure unaligned DIO reads don't crash
13789 for bs in $bsizes; do
13791 echo "unaligned reads of blocksize: $bs"
13792 # with 'u', multiop randomly unaligns the io from the buffer
13793 $MULTIOP $DIR/$tfile.1 \
13794 oO_CREAT:O_RDWR:O_DIRECT:ru${bs}ru${bs}ru${bs}ru${bs}ru${bs} ||
13795 error "multiop memory unaligned read failed, $bs"
13800 run_test 119h "basic tests of memory unaligned dio"
13802 # aiocp with the '-a' option makes testing memory unaligned aio trivial
13805 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13806 which aiocp || skip_env "no aiocp installed"
13808 local stripe_size=$((1024 * 1024)) #1 MiB
13809 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13810 local file_size=$((25 * stripe_size))
13813 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13814 stack_trap "rm -f $DIR/$tfile.*"
13816 # Just a bit bigger than the largest size in the test set below
13817 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
13818 error "buffered i/o to create file failed"
13820 if zfs_or_rotational; then
13821 # DIO on ZFS can take up to 2 seconds per IO
13822 # rotational is better, but still slow.
13823 # Limit testing on those media to larger sizes
13824 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
13825 $((stripe_size + 1024))"
13827 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
13828 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
13829 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
13830 $((stripe_size - 1)) $stripe_size \
13831 $((stripe_size + 1)) $((stripe_size * 3/2)) \
13832 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
13835 # Do page aligned and NOT page aligned AIO
13836 for align in 8 512 $((PAGE_SIZE)); do
13837 # Deliberately includes a few aligned sizes
13838 for bs in $bsizes; do
13839 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13841 echo "bs: $bs, align: $align, file_size $file_size"
13842 aiocp -a $align -b $bs -s $file_size -f O_DIRECT \
13843 $DIR/$tfile.1 $DIR/$tfile.2 ||
13844 error "unaligned aio failed, bs: $bs, align: $align"
13846 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
13847 error "size incorrect"
13848 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13849 error "files differ"
13850 rm -f $DIR/$tfile.2
13854 run_test 119i "test unaligned aio at varying sizes"
13857 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13858 remote_mds_nodsh && skip "remote MDS with nodsh"
13859 test_mkdir -i0 -c1 $DIR/$tdir
13860 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13861 skip_env "no early lock cancel on server"
13863 lru_resize_disable mdc
13864 lru_resize_disable osc
13865 cancel_lru_locks mdc
13866 # asynchronous object destroy at MDT could cause bl ast to client
13867 cancel_lru_locks osc
13869 stat $DIR/$tdir > /dev/null
13870 can1=$(do_facet mds1 \
13871 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13872 awk '/ldlm_cancel/ {print $2}')
13873 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13874 awk '/ldlm_bl_callback/ {print $2}')
13875 test_mkdir -i0 -c1 $DIR/$tdir/d1
13876 can2=$(do_facet mds1 \
13877 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13878 awk '/ldlm_cancel/ {print $2}')
13879 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13880 awk '/ldlm_bl_callback/ {print $2}')
13881 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13882 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13883 lru_resize_enable mdc
13884 lru_resize_enable osc
13886 run_test 120a "Early Lock Cancel: mkdir test"
13889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13890 remote_mds_nodsh && skip "remote MDS with nodsh"
13891 test_mkdir $DIR/$tdir
13892 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13893 skip_env "no early lock cancel on server"
13895 lru_resize_disable mdc
13896 lru_resize_disable osc
13897 cancel_lru_locks mdc
13898 stat $DIR/$tdir > /dev/null
13899 can1=$(do_facet $SINGLEMDS \
13900 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13901 awk '/ldlm_cancel/ {print $2}')
13902 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13903 awk '/ldlm_bl_callback/ {print $2}')
13904 touch $DIR/$tdir/f1
13905 can2=$(do_facet $SINGLEMDS \
13906 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13907 awk '/ldlm_cancel/ {print $2}')
13908 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13909 awk '/ldlm_bl_callback/ {print $2}')
13910 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13911 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13912 lru_resize_enable mdc
13913 lru_resize_enable osc
13915 run_test 120b "Early Lock Cancel: create test"
13918 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13919 remote_mds_nodsh && skip "remote MDS with nodsh"
13920 test_mkdir -i0 -c1 $DIR/$tdir
13921 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13922 skip "no early lock cancel on server"
13924 lru_resize_disable mdc
13925 lru_resize_disable osc
13926 test_mkdir -i0 -c1 $DIR/$tdir/d1
13927 test_mkdir -i0 -c1 $DIR/$tdir/d2
13928 touch $DIR/$tdir/d1/f1
13929 cancel_lru_locks mdc
13930 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
13931 can1=$(do_facet mds1 \
13932 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13933 awk '/ldlm_cancel/ {print $2}')
13934 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13935 awk '/ldlm_bl_callback/ {print $2}')
13936 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13937 can2=$(do_facet mds1 \
13938 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13939 awk '/ldlm_cancel/ {print $2}')
13940 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13941 awk '/ldlm_bl_callback/ {print $2}')
13942 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13943 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13944 lru_resize_enable mdc
13945 lru_resize_enable osc
13947 run_test 120c "Early Lock Cancel: link test"
13950 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13951 remote_mds_nodsh && skip "remote MDS with nodsh"
13952 test_mkdir -i0 -c1 $DIR/$tdir
13953 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13954 skip_env "no early lock cancel on server"
13956 lru_resize_disable mdc
13957 lru_resize_disable osc
13959 cancel_lru_locks mdc
13960 stat $DIR/$tdir > /dev/null
13961 can1=$(do_facet mds1 \
13962 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13963 awk '/ldlm_cancel/ {print $2}')
13964 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13965 awk '/ldlm_bl_callback/ {print $2}')
13966 chmod a+x $DIR/$tdir
13967 can2=$(do_facet mds1 \
13968 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13969 awk '/ldlm_cancel/ {print $2}')
13970 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13971 awk '/ldlm_bl_callback/ {print $2}')
13972 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13973 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13974 lru_resize_enable mdc
13975 lru_resize_enable osc
13977 run_test 120d "Early Lock Cancel: setattr test"
13980 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13981 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13982 skip_env "no early lock cancel on server"
13983 remote_mds_nodsh && skip "remote MDS with nodsh"
13985 local dlmtrace_set=false
13987 test_mkdir -i0 -c1 $DIR/$tdir
13988 lru_resize_disable mdc
13989 lru_resize_disable osc
13990 ! $LCTL get_param debug | grep -q dlmtrace &&
13991 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
13992 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
13993 cancel_lru_locks mdc
13994 cancel_lru_locks osc
13995 dd if=$DIR/$tdir/f1 of=/dev/null
13996 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
13997 # XXX client can not do early lock cancel of OST lock
13998 # during unlink (LU-4206), so cancel osc lock now.
14000 cancel_lru_locks osc
14001 can1=$(do_facet mds1 \
14002 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14003 awk '/ldlm_cancel/ {print $2}')
14004 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14005 awk '/ldlm_bl_callback/ {print $2}')
14006 unlink $DIR/$tdir/f1
14008 can2=$(do_facet mds1 \
14009 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14010 awk '/ldlm_cancel/ {print $2}')
14011 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14012 awk '/ldlm_bl_callback/ {print $2}')
14013 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
14014 $LCTL dk $TMP/cancel.debug.txt
14015 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
14016 $LCTL dk $TMP/blocking.debug.txt
14017 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
14018 lru_resize_enable mdc
14019 lru_resize_enable osc
14021 run_test 120e "Early Lock Cancel: unlink test"
14024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14025 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
14026 skip_env "no early lock cancel on server"
14027 remote_mds_nodsh && skip "remote MDS with nodsh"
14029 test_mkdir -i0 -c1 $DIR/$tdir
14030 lru_resize_disable mdc
14031 lru_resize_disable osc
14032 test_mkdir -i0 -c1 $DIR/$tdir/d1
14033 test_mkdir -i0 -c1 $DIR/$tdir/d2
14034 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
14035 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
14036 cancel_lru_locks mdc
14037 cancel_lru_locks osc
14038 dd if=$DIR/$tdir/d1/f1 of=/dev/null
14039 dd if=$DIR/$tdir/d2/f2 of=/dev/null
14040 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
14041 # XXX client can not do early lock cancel of OST lock
14042 # during rename (LU-4206), so cancel osc lock now.
14044 cancel_lru_locks osc
14045 can1=$(do_facet mds1 \
14046 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14047 awk '/ldlm_cancel/ {print $2}')
14048 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14049 awk '/ldlm_bl_callback/ {print $2}')
14050 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
14052 can2=$(do_facet mds1 \
14053 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14054 awk '/ldlm_cancel/ {print $2}')
14055 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14056 awk '/ldlm_bl_callback/ {print $2}')
14057 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
14058 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
14059 lru_resize_enable mdc
14060 lru_resize_enable osc
14062 run_test 120f "Early Lock Cancel: rename test"
14065 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14066 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
14067 skip_env "no early lock cancel on server"
14068 remote_mds_nodsh && skip "remote MDS with nodsh"
14070 lru_resize_disable mdc
14071 lru_resize_disable osc
14073 echo create $count files
14074 test_mkdir $DIR/$tdir
14075 cancel_lru_locks mdc
14076 cancel_lru_locks osc
14079 can0=$(do_facet $SINGLEMDS \
14080 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14081 awk '/ldlm_cancel/ {print $2}')
14082 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14083 awk '/ldlm_bl_callback/ {print $2}')
14084 createmany -o $DIR/$tdir/f $count
14086 can1=$(do_facet $SINGLEMDS \
14087 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14088 awk '/ldlm_cancel/ {print $2}')
14089 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14090 awk '/ldlm_bl_callback/ {print $2}')
14092 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
14093 echo rm $count files
14096 can2=$(do_facet $SINGLEMDS \
14097 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14098 awk '/ldlm_cancel/ {print $2}')
14099 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14100 awk '/ldlm_bl_callback/ {print $2}')
14102 echo total: $count removes in $((t2-t1))
14103 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
14105 # wait for commitment of removal
14106 lru_resize_enable mdc
14107 lru_resize_enable osc
14109 run_test 120g "Early Lock Cancel: performance test"
14111 test_121() { #bug #10589
14112 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14115 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
14116 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
14117 lctl set_param fail_loc=0x310
14118 cancel_lru_locks osc > /dev/null
14119 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
14120 lctl set_param fail_loc=0
14121 [[ $reads -eq $writes ]] ||
14122 error "read $reads blocks, must be $writes blocks"
14124 run_test 121 "read cancel race ========="
14126 test_123a_base() { # was test 123, statahead(bug 11401)
14129 ost_set_temp_seq_width_all $DATA_SEQ_MAX_WIDTH
14132 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
14133 log "testing UP system. Performance may be lower than expected."
14136 running_in_vm && SLOWOK=1
14138 $LCTL set_param mdc.*.batch_stats=0
14141 test_mkdir $DIR/$tdir
14142 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
14143 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
14145 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
14146 createmany -o $DIR/$tdir/$tfile $j $((i - j))
14148 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
14149 lctl set_param -n llite.*.statahead_max 0
14150 lctl get_param llite.*.statahead_max
14151 cancel_lru_locks mdc
14152 cancel_lru_locks osc
14154 time $lsx $DIR/$tdir | wc -l
14156 delta=$((etime - stime))
14157 log "$lsx $i files without statahead: $delta sec"
14158 lctl set_param llite.*.statahead_max=$max
14160 swrong=$(lctl get_param -n llite.*.statahead_stats |
14161 awk '/statahead.wrong:/ { print $NF }')
14162 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
14163 cancel_lru_locks mdc
14164 cancel_lru_locks osc
14166 time $lsx $DIR/$tdir | wc -l
14168 delta_sa=$((etime - stime))
14169 log "$lsx $i files with statahead: $delta_sa sec"
14170 lctl get_param -n llite.*.statahead_stats
14171 ewrong=$(lctl get_param -n llite.*.statahead_stats |
14172 awk '/statahead.wrong:/ { print $NF }')
14174 [[ $swrong -lt $ewrong ]] &&
14175 log "statahead was stopped, maybe too many locks held!"
14176 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
14178 if (( $delta_sa*100 > $delta*105 && $delta_sa > $delta+2)); then
14179 max=$(lctl get_param -n llite.*.statahead_max |
14181 lctl set_param -n llite.*.statahead_max 0
14182 lctl get_param llite.*.statahead_max
14183 cancel_lru_locks mdc
14184 cancel_lru_locks osc
14186 time $lsx $DIR/$tdir | wc -l
14188 delta=$((etime - stime))
14189 log "$lsx $i files again without statahead: $delta sec"
14190 lctl set_param llite.*.statahead_max=$max
14191 if (( $delta_sa*100 > delta*105 && delta_sa > delta+2 )); then
14192 if [ $SLOWOK -eq 0 ]; then
14193 error "$lsx $i files is slower with statahead!"
14195 log "$lsx $i files is slower with statahead!"
14201 [ $delta -gt 20 ] && break
14202 [ $delta -gt 8 ] && MULT=$((50 / delta))
14203 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
14211 delta=$((etime - stime))
14212 log "rm -r $DIR/$tdir/: $delta seconds"
14214 lctl get_param -n llite.*.statahead_stats
14215 $LCTL get_param mdc.*.batch_stats
14219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14221 test_123a_base "ls -l"
14223 run_test 123aa "verify statahead work"
14226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14228 statx_supported || skip_env "Test must be statx() syscall supported"
14230 test_123a_base "$STATX -l"
14232 run_test 123ab "verify statahead work by using statx"
14235 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14237 statx_supported || skip_env "Test must be statx() syscall supported"
14244 cancel_lru_locks $OSC
14245 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
14246 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
14247 awk '/agl.total:/ { print $NF }')
14248 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
14249 test_123a_base "$STATX --cached=always -D"
14250 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
14251 awk '/agl.total:/ { print $NF }')
14252 [ $agl_before -eq $agl_after ] ||
14253 error "Should not trigger AGL thread - $agl_before:$agl_after"
14254 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
14255 [ $rpcs_after -eq $rpcs_before ] ||
14256 error "$STATX should not send glimpse RPCs to $OSC"
14258 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
14260 test_batch_statahead() {
14268 echo -e "\nbatching: statahead_max=$max statahead_batch_max=$batch_max"
14269 $LCTL set_param mdc.*.batch_stats=0
14270 $LCTL set_param llite.*.statahead_max=$max
14271 $LCTL set_param llite.*.statahead_batch_max=$batch_max
14272 # Verify that batched statahead is faster than one without statahead
14273 test_123a_base "ls -l"
14275 stack_trap "rm -rf $DIR/$tdir" EXIT
14276 mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
14277 createmany -o $DIR/$tdir/$tfile $num || error "failed to create files"
14279 # unbatched statahead
14280 $LCTL set_param llite.*.statahead_batch_max=0
14281 $LCTL set_param llite.*.statahead_stats=clear
14282 $LCTL set_param mdc.*.stats=clear
14283 cancel_lru_locks mdc
14284 cancel_lru_locks osc
14285 time ls -l $DIR/$tdir | wc -l
14286 unbatch_rpcs=$(calc_stats mdc.*.stats ldlm_ibits_enqueue)
14288 hit_total=$($LCTL get_param -n llite.*.statahead_stats |
14289 awk '/hit.total:/ { print $NF }')
14290 # hit ratio should be larger than 75% (7500).
14291 (( $hit_total > 7500 )) ||
14292 error "unbatched statahead hit count ($hit_total) is too low"
14294 # batched statahead
14295 $LCTL set_param llite.*.statahead_batch_max=$batch_max
14296 $LCTL set_param llite.*.statahead_stats=clear
14297 $LCTL set_param mdc.*.batch_stats=clear
14298 $LCTL set_param mdc.*.stats=clear
14299 cancel_lru_locks mdc
14300 cancel_lru_locks osc
14301 time ls -l $DIR/$tdir | wc -l
14302 batch_rpcs=$(calc_stats mdc.*.stats mds_batch)
14303 # wait for statahead thread to quit and update statahead stats
14305 hit_total=$($LCTL get_param -n llite.*.statahead_stats |
14306 awk '/hit.total:/ { print $NF }')
14307 # hit ratio should be larger than 75% (7500).
14308 (( $hit_total > 7500 )) ||
14309 error "batched statahead hit count ($hit_total) is too low"
14311 echo "unbatched RPCs: $unbatch_rpcs, batched RPCs: $batch_rpcs"
14312 (( $unbatch_rpcs > $batch_rpcs )) ||
14313 error "batched statahead does not reduce RPC count"
14314 $LCTL get_param mdc.*.batch_stats
14318 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14320 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
14321 skip "Need server version at least 2.15.53"
14326 max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
14327 batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
14329 stack_trap "$LCTL set_param llite.*.statahead_max=$max" EXIT
14330 stack_trap "$LCTL set_param llite.*.statahead_batch_max=$batch_max" EXIT
14332 test_batch_statahead 32 32
14333 test_batch_statahead 2048 256
14335 run_test 123ad "Verify batching statahead works correctly"
14337 test_123b () { # statahead(bug 15027)
14338 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14340 test_mkdir $DIR/$tdir
14341 createmany -o $DIR/$tdir/$tfile-%d 1000
14343 cancel_lru_locks mdc
14344 cancel_lru_locks osc
14346 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
14347 lctl set_param fail_loc=0x80000803
14348 ls -lR $DIR/$tdir > /dev/null
14350 lctl set_param fail_loc=0x0
14351 lctl get_param -n llite.*.statahead_stats
14356 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
14359 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
14361 test_mkdir -i 0 -c 1 $DIR/$tdir.0
14362 test_mkdir -i 1 -c 1 $DIR/$tdir.1
14363 touch $DIR/$tdir.1/{1..3}
14364 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
14366 remount_client $MOUNT
14368 $MULTIOP $DIR/$tdir.0 Q
14370 # let statahead to complete
14371 ls -l $DIR/$tdir.0 > /dev/null
14373 testid=$(echo $TESTNAME | tr '_' ' ')
14374 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
14375 error "statahead warning" || true
14377 run_test 123c "Can not initialize inode warning on DNE statahead"
14384 test_mkdir -c -1 $DIR/$tdir || error "test_mkdir $DIR/$tdir failed"
14385 $LFS setdirstripe -D -c $MDSCOUNT $DIR/$tdir ||
14386 error "setdirstripe $DIR/$tdir failed"
14387 createmany -d $DIR/$tdir/$tfile $num || error "createmany $num failed"
14388 remount_client $MOUNT
14389 $LCTL get_param llite.*.statahead_max
14390 $LCTL set_param llite.*.statahead_stats=0 ||
14391 error "clear statahead_stats failed"
14392 swrong=$(lctl get_param -n llite.*.statahead_stats |
14393 awk '/statahead.wrong:/ { print $NF }')
14394 ls -l $DIR/$tdir || error "ls -l $DIR/$tdir failed"
14395 # wait for statahead thread finished to update hit/miss stats.
14397 $LCTL get_param -n llite.*.statahead_stats
14398 ewrong=$(lctl get_param -n llite.*.statahead_stats |
14399 awk '/statahead.wrong:/ { print $NF }')
14400 (( $swrong == $ewrong )) ||
14401 log "statahead was stopped, maybe too many locks held!"
14403 run_test 123d "Statahead on striped directories works correctly"
14408 local dir=$DIR/$tdir
14410 mkdir $dir || error "mkdir $dir failed"
14411 $LFS setstripe -C 32 $dir || error "setstripe $dir failed"
14412 stack_trap "rm -rf $dir"
14414 touch $dir/$tfile.{0..1000} || error "touch 1000 files failed"
14416 max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
14417 batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
14418 stack_trap "$LCTL set_param llite.*.statahead_max=$max" EXIT
14419 stack_trap "$LCTL set_param llite.*.statahead_batch_max=$batch_max" EXIT
14421 $LCTL set_param llite.*.statahead_max=2048
14422 $LCTL set_param llite.*.statahead_batch_max=1024
14425 $LCTL get_param mdc.*.batch_stats
14426 $LCTL get_param llite.*.statahead_*
14428 run_test 123e "statahead with large wide striping"
14433 local dir=$DIR/$tdir
14435 mkdir $dir || error "mkdir $dir failed"
14436 $LFS setstripe -C 1000 $dir || error "setstripe $dir failed"
14437 stack_trap "rm -rf $dir"
14439 touch $dir/$tfile.{0..200} || error "touch 200 files failed"
14441 max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
14442 batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
14444 $LCTL set_param llite.*.statahead_max=64
14445 $LCTL set_param llite.*.statahead_batch_max=64
14448 lctl get_param mdc.*.batch_stats
14449 lctl get_param llite.*.statahead_*
14451 $LCTL set_param llite.*.statahead_max=$max
14452 $LCTL set_param llite.*.statahead_batch_max=$batch_max
14454 run_test 123f "Retry mechanism with large wide striping files"
14457 local dir=$DIR/$tdir
14460 mkdir $dir || error "failed to mkdir $dir"
14461 createmany -o $dir/$tfile $num || error "failed creatmany files"
14462 cancel_lru_locks mdc
14463 cancel_lru_locks osc
14465 $LCTL set_param llite.*.statahead_stats=clear
14466 $LCTL set_param mdc.*.batch_stats=clear
14467 aheadmany -c stat -s 0 -e $num -b $tfile -d $dir ||
14468 error "aheadmany $dir with $tfile failed"
14469 wait_update_facet client "pgrep ll_sa" "" 35 ||
14470 error "ll_sa thread is still running"
14471 $LCTL get_param -n llite.*.statahead_stats
14472 $LCTL get_param -n mdc.*.batch_stats
14476 count=$($LCTL get_param -n llite.*.statahead_stats |
14477 awk '/hit.total:/ {print $2}')
14478 echo "Hit total: $count"
14479 # Hit ratio should be >= 75%
14480 (( $count > num * 75 / 100)) ||
14481 error "hit total $count is be > 75% of $num"
14483 run_test 123g "Test for stat-ahead advise"
14486 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14487 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14488 skip_env "no lru resize on server"
14492 test_mkdir $DIR/$tdir
14494 log "create $NR files at $DIR/$tdir"
14495 createmany -o $DIR/$tdir/f $NR ||
14496 error "failed to create $NR files in $DIR/$tdir"
14498 cancel_lru_locks mdc
14499 ls -l $DIR/$tdir > /dev/null
14503 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
14504 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
14505 LRU_SIZE=$($LCTL get_param -n $PARAM)
14506 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
14507 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
14509 log "NS=$(basename $NSDIR)"
14514 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
14515 skip "Not enough cached locks created!"
14517 log "LRU=$LRU_SIZE"
14521 # We know that lru resize allows one client to hold $LIMIT locks
14522 # for 10h. After that locks begin to be killed by client.
14524 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
14526 if [ $LIMIT -lt $LRU_SIZE ]; then
14527 skip "Limit is too small $LIMIT"
14530 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
14531 # killing locks. Some time was spent for creating locks. This means
14532 # that up to the moment of sleep finish we must have killed some of
14533 # them (10-100 locks). This depends on how fast ther were created.
14534 # Many of them were touched in almost the same moment and thus will
14535 # be killed in groups.
14536 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
14538 # Use $LRU_SIZE_B here to take into account real number of locks
14539 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
14540 local LRU_SIZE_B=$LRU_SIZE
14542 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
14543 log "OLD_LVF=$OLD_LVF"
14544 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
14546 # Let's make sure that we really have some margin. Client checks
14547 # cached locks every 10 sec.
14548 SLEEP=$((SLEEP+20))
14549 log "Sleep ${SLEEP} sec"
14551 while ((SEC<$SLEEP)); do
14555 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
14556 echo -n "$LRU_SIZE"
14559 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
14560 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
14562 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
14563 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
14564 unlinkmany $DIR/$tdir/f $NR
14568 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
14569 log "unlink $NR files at $DIR/$tdir"
14570 unlinkmany $DIR/$tdir/f $NR
14572 run_test 124a "lru resize ======================================="
14574 get_max_pool_limit()
14576 local limit=$($LCTL get_param \
14577 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
14579 for l in $limit; do
14580 if [[ $l -gt $max ]]; then
14588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14589 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14590 skip_env "no lru resize on server"
14592 LIMIT=$(get_max_pool_limit)
14594 NR=$(($(default_lru_size)*20))
14595 if [[ $NR -gt $LIMIT ]]; then
14596 log "Limit lock number by $LIMIT locks"
14600 IFree=$(mdsrate_inodes_available)
14601 if [ $IFree -lt $NR ]; then
14602 log "Limit lock number by $IFree inodes"
14606 lru_resize_disable mdc
14607 test_mkdir -p $DIR/$tdir/disable_lru_resize
14609 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
14610 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
14611 cancel_lru_locks mdc
14614 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
14617 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
14620 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
14624 nolruresize_delta=$((etime-stime))
14625 log "ls -la time: $nolruresize_delta seconds"
14626 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
14627 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
14629 lru_resize_enable mdc
14630 test_mkdir -p $DIR/$tdir/enable_lru_resize
14632 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
14633 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
14634 cancel_lru_locks mdc
14637 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
14640 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
14643 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
14647 lruresize_delta=$((etime-stime))
14648 log "ls -la time: $lruresize_delta seconds"
14649 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
14651 if [ $lruresize_delta -gt $nolruresize_delta ]; then
14652 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
14653 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
14654 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
14656 log "lru resize performs the same with no lru resize"
14658 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
14660 run_test 124b "lru resize (performance test) ======================="
14663 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14664 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14665 skip_env "no lru resize on server"
14667 # cache ununsed locks on client
14669 cancel_lru_locks mdc
14670 test_mkdir $DIR/$tdir
14671 createmany -o $DIR/$tdir/f $nr ||
14672 error "failed to create $nr files in $DIR/$tdir"
14673 ls -l $DIR/$tdir > /dev/null
14675 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14676 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14677 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
14678 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
14679 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
14681 # set lru_max_age to 1 sec
14682 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
14683 echo "sleep $((recalc_p * 2)) seconds..."
14684 sleep $((recalc_p * 2))
14686 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
14687 # restore lru_max_age
14688 $LCTL set_param -n $nsdir.lru_max_age $max_age
14689 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
14690 unlinkmany $DIR/$tdir/f $nr
14692 run_test 124c "LRUR cancel very aged locks"
14695 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14696 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14697 skip_env "no lru resize on server"
14699 # cache ununsed locks on client
14702 lru_resize_disable mdc
14703 stack_trap "lru_resize_enable mdc" EXIT
14705 cancel_lru_locks mdc
14707 # asynchronous object destroy at MDT could cause bl ast to client
14708 test_mkdir $DIR/$tdir
14709 createmany -o $DIR/$tdir/f $nr ||
14710 error "failed to create $nr files in $DIR/$tdir"
14711 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
14713 ls -l $DIR/$tdir > /dev/null
14715 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14716 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14717 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
14718 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
14720 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
14722 # set lru_max_age to 1 sec
14723 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
14724 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
14726 echo "sleep $((recalc_p * 2)) seconds..."
14727 sleep $((recalc_p * 2))
14729 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
14731 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
14733 run_test 124d "cancel very aged locks if lru-resize disabled"
14735 test_125() { # 13358
14736 $LCTL get_param -n llite.*.client_type | grep -q local ||
14737 skip "must run as local client"
14738 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
14739 skip_env "must have acl enabled"
14740 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
14741 id $USER0 || skip_env "missing user $USER0"
14743 test_mkdir $DIR/$tdir
14744 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
14745 setfacl -R -m u:$USER0:rwx $DIR/$tdir ||
14746 error "setfacl $DIR/$tdir failed"
14747 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
14749 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
14751 test_126() { # bug 12829/13455
14752 $GSS && skip_env "must run as gss disabled"
14753 $LCTL get_param -n llite.*.client_type | grep -q local ||
14754 skip "must run as local client"
14755 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
14757 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
14758 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
14760 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
14762 run_test 126 "check that the fsgid provided by the client is taken into account"
14764 test_127a() { # bug 15521
14765 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14766 local name count samp unit min max sum sumsq
14767 local tmpfile=$TMP/$tfile.tmp
14769 # enable stats header if it is disabled
14770 $LCTL set_param enable_stats_header=1
14772 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
14773 echo "stats before reset"
14774 stack_trap "rm -f $tmpfile"
14775 local now=$(date +%s)
14777 $LCTL get_param osc.*.stats | tee $tmpfile
14779 local snapshot_time=$(awk '/snapshot_time/ { print $2; exit }' $tmpfile)
14780 local start_time=$(awk '/start_time/ { print $2; exit }' $tmpfile)
14781 local elapsed=$(awk '/elapsed_time/ { print $2; exit }' $tmpfile)
14782 local uptime=$(awk '{ print $1 }' /proc/uptime)
14784 # snapshot_time should match POSIX epoch time, allow some delta for VMs
14785 (( ${snapshot_time%\.*} >= $now - 5 &&
14786 ${snapshot_time%\.*} <= $now + 5 )) ||
14787 error "snapshot_time=$snapshot_time != now=$now"
14788 # elapsed _should_ be from mount, but at least less than uptime
14789 (( ${elapsed%\.*} < ${uptime%\.*} )) ||
14790 error "elapsed=$elapsed > uptime=$uptime"
14791 (( ${snapshot_time%\.*} - ${start_time%\.*} >= ${elapsed%\.*} - 2 &&
14792 ${snapshot_time%\.*} - ${start_time%\.*} <= ${elapsed%\.*} + 2 )) ||
14793 error "elapsed=$elapsed != $snapshot_time - $start_time"
14795 $LCTL set_param osc.*.stats=0
14796 local reset=$(date +%s)
14797 local fsize=$((2048 * 1024))
14799 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
14800 cancel_lru_locks osc
14801 dd if=$DIR/$tfile of=/dev/null bs=$fsize
14804 $LCTL get_param osc.*0000-osc-*.stats > $tmpfile
14805 while read name count samp unit min max sum sumsq; do
14806 [[ "$samp" == "samples" ]] || continue
14808 echo "got name=$name count=$count unit=$unit min=$min max=$max"
14809 [ ! $min ] && error "Missing min value for $name proc entry"
14810 eval $name=$count || error "Wrong proc format"
14813 read_bytes|write_bytes)
14814 [[ "$unit" =~ "bytes" ]] ||
14815 error "unit is not 'bytes': $unit"
14816 (( $min >= 4096 )) || error "min is too small: $min"
14817 (( $min <= $fsize )) || error "min is too big: $min"
14818 (( $max >= 4096 )) || error "max is too small: $max"
14819 (( $max <= $fsize )) || error "max is too big: $max"
14820 (( $sum == $fsize )) || error "sum is wrong: $sum"
14821 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
14822 error "sumsquare is too small: $sumsq"
14823 (( $sumsq <= $fsize * $fsize )) ||
14824 error "sumsquare is too big: $sumsq"
14826 ost_read|ost_write)
14827 [[ "$unit" =~ "usec" ]] ||
14828 error "unit is not 'usec': $unit"
14834 #check that we actually got some stats
14835 [ "$read_bytes" ] || error "Missing read_bytes stats"
14836 [ "$write_bytes" ] || error "Missing write_bytes stats"
14837 [ "$read_bytes" != 0 ] || error "no read done"
14838 [ "$write_bytes" != 0 ] || error "no write done"
14840 snapshot_time=$(awk '/snapshot_time/ { print $2; exit }' $tmpfile)
14841 start_time=$(awk '/start_time/ { print $2; exit }' $tmpfile)
14842 elapsed=$(awk '/elapsed_time/ { print $2; exit }' $tmpfile)
14844 # snapshot_time should match POSIX epoch time, allow some delta for VMs
14845 (( ${snapshot_time%\.*} >= $now - 5 &&
14846 ${snapshot_time%\.*} <= $now + 5 )) ||
14847 error "reset snapshot_time=$snapshot_time != now=$now"
14848 # elapsed should be from time of stats reset
14849 (( ${elapsed%\.*} >= $now - $reset - 2 &&
14850 ${elapsed%\.*} <= $now - $reset + 2 )) ||
14851 error "reset elapsed=$elapsed > $now - $reset"
14852 (( ${snapshot_time%\.*} - ${start_time%\.*} >= ${elapsed%\.*} - 2 &&
14853 ${snapshot_time%\.*} - ${start_time%\.*} <= ${elapsed%\.*} + 2 )) ||
14854 error "reset elapsed=$elapsed != $snapshot_time - $start_time"
14856 run_test 127a "verify the client stats are sane"
14858 test_127b() { # bug LU-333
14859 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14860 local name count samp unit min max sum sumsq
14862 echo "stats before reset"
14863 $LCTL get_param llite.*.stats
14864 $LCTL set_param llite.*.stats=0
14866 # perform 2 reads and writes so MAX is different from SUM.
14867 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
14868 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
14869 cancel_lru_locks osc
14870 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
14871 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
14873 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
14874 stack_trap "rm -f $TMP/$tfile.tmp"
14875 while read name count samp unit min max sum sumsq; do
14876 echo "got name=$name count=$count unit=$unit min=$min max=$max"
14877 eval $name=$count || error "Wrong proc format"
14880 read_bytes|write_bytes)
14881 [[ "$unit" =~ "bytes" ]] ||
14882 error "unit is not 'bytes': $unit"
14883 (( $count == 2 )) || error "count is not 2: $count"
14884 (( $min == $PAGE_SIZE )) ||
14885 error "min is not $PAGE_SIZE: $min"
14886 (( $max == $PAGE_SIZE )) ||
14887 error "max is not $PAGE_SIZE: $max"
14888 (( $sum == $PAGE_SIZE * 2 )) ||
14889 error "sum is not $((PAGE_SIZE * 2)): $sum"
14892 [[ "$unit" =~ "usec" ]] ||
14893 error "unit is not 'usec': $unit"
14897 done < $TMP/$tfile.tmp
14899 #check that we actually got some stats
14900 [ "$read_bytes" ] || error "Missing read_bytes stats"
14901 [ "$write_bytes" ] || error "Missing write_bytes stats"
14902 [ "$read_bytes" != 0 ] || error "no read done"
14903 [ "$write_bytes" != 0 ] || error "no write done"
14905 run_test 127b "verify the llite client stats are sane"
14907 test_127c() { # LU-12394
14908 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
14915 $LCTL set_param llite.*.extents_stats=1
14916 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
14918 # Use two stripes so there is enough space in default config
14919 $LFS setstripe -c 2 $DIR/$tfile
14921 # Extent stats start at 0-4K and go in power of two buckets
14922 # LL_HIST_START = 12 --> 2^12 = 4K
14923 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
14924 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
14926 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
14928 # Write and read, 2x each, second time at a non-zero offset
14929 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
14930 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
14931 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
14932 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
14936 $LCTL get_param llite.*.extents_stats
14939 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
14941 local bucket=$($LCTL get_param -n llite.*.extents_stats |
14943 reads=$(echo $bucket | awk '{print $5}')
14944 writes=$(echo $bucket | awk '{print $9}')
14945 [ "$reads" -eq $count ] ||
14946 error "$reads reads in < $bsize bucket, expect $count"
14947 [ "$writes" -eq $count ] ||
14948 error "$writes writes in < $bsize bucket, expect $count"
14951 # Test mmap write and read
14952 $LCTL set_param llite.*.extents_stats=c
14954 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
14955 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
14956 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
14958 $LCTL get_param llite.*.extents_stats
14960 count=$(((size*1024) / PAGE_SIZE))
14962 bsize=$((2 * PAGE_SIZE / 1024))K
14964 bucket=$($LCTL get_param -n llite.*.extents_stats |
14966 reads=$(echo $bucket | awk '{print $5}')
14967 writes=$(echo $bucket | awk '{print $9}')
14968 # mmap writes fault in the page first, creating an additonal read
14969 [ "$reads" -eq $((2 * count)) ] ||
14970 error "$reads reads in < $bsize bucket, expect $count"
14971 [ "$writes" -eq $count ] ||
14972 error "$writes writes in < $bsize bucket, expect $count"
14974 run_test 127c "test llite extent stats with regular & mmap i/o"
14976 test_128() { # bug 15212
14978 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
14983 result=$(grep error $TMP/$tfile.log)
14984 rm -f $DIR/$tfile $TMP/$tfile.log
14985 [ -z "$result" ] ||
14986 error "consecutive find's under interactive lfs failed"
14988 run_test 128 "interactive lfs for 2 consecutive find's"
14990 set_dir_limits () {
14995 local ldproc=/proc/fs/ldiskfs
14996 local facets=$(get_facets MDS)
14998 for facet in ${facets//,/ }; do
14999 canondev=$(ldiskfs_canon \
15000 *.$(convert_facet2label $facet).mntdev $facet)
15001 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
15002 ldproc=/sys/fs/ldiskfs
15003 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
15004 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
15008 check_mds_dmesg() {
15009 local facets=$(get_facets MDS)
15010 for facet in ${facets//,/ }; do
15011 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
15017 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15018 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
15019 skip "Need MDS version with at least 2.5.56"
15020 if [ "$mds1_FSTYPE" != ldiskfs ]; then
15021 skip_env "ldiskfs only test"
15023 remote_mds_nodsh && skip "remote MDS with nodsh"
15026 local has_warning=false
15029 mkdir -p $DIR/$tdir
15031 # block size of mds1
15032 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
15033 set_dir_limits $maxsize $((maxsize * 6 / 8))
15034 stack_trap "set_dir_limits 0 0"
15035 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
15036 local dirsize=$(stat -c%s "$DIR/$tdir")
15038 while (( $dirsize <= $maxsize )); do
15039 $MCREATE $DIR/$tdir/file_base_$nfiles
15041 # check two errors:
15042 # ENOSPC for ext4 max_dir_size, which has been used since
15043 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
15044 if (( rc == ENOSPC )); then
15046 echo "rc=$rc returned as expected after $nfiles files"
15048 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
15049 error "create failed w/o dir size limit"
15051 # messages may be rate limited if test is run repeatedly
15052 check_mds_dmesg '"is approaching max"' ||
15053 echo "warning message should be output"
15054 check_mds_dmesg '"has reached max"' ||
15055 echo "reached message should be output"
15057 dirsize=$(stat -c%s "$DIR/$tdir")
15059 [[ $dirsize -ge $maxsize ]] && return 0
15060 error "dirsize $dirsize < $maxsize after $nfiles files"
15061 elif (( rc != 0 )); then
15064 nfiles=$((nfiles + 1))
15065 dirsize=$(stat -c%s "$DIR/$tdir")
15068 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
15070 run_test 129 "test directory size limit ========================"
15080 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
15081 [[ -z "$filefrag_op" ]] || skip_env "filefrag does not support FIEMAP"
15083 trap cleanup_130 EXIT RETURN
15085 local fm_file=$DIR/$tfile
15086 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
15087 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
15088 error "dd failed for $fm_file"
15090 # LU-1795: test filefrag/FIEMAP once, even if unsupported on ZFS
15091 filefrag -ves $fm_file
15093 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15094 skip "LU-1941: FIEMAP unimplemented on ZFS"
15095 (( $rc == 0 )) || error "filefrag $fm_file failed"
15097 filefrag_op=$(filefrag -ve -k $fm_file |
15098 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15099 local lun=$($LFS getstripe -i $fm_file)
15101 local start_blk=$(echo $filefrag_op | cut -d: -f2 | cut -d. -f1)
15104 for line in $filefrag_op; do
15105 local frag_lun=$(echo $line | cut -d: -f5)
15106 local ext_len=$(echo $line | cut -d: -f4)
15108 if (( $frag_lun != $lun )); then
15109 error "FIEMAP on 1-stripe file($fm_file) failed"
15112 (( tot_len += ext_len ))
15115 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
15116 error "FIEMAP on 1-stripe file($fm_file) failed"
15120 echo "FIEMAP on single striped file succeeded"
15122 run_test 130a "FIEMAP (1-stripe file)"
15125 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
15127 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15128 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15129 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15130 skip "LU-1941: FIEMAP unimplemented on ZFS"
15132 trap cleanup_130 EXIT RETURN
15134 local fm_file=$DIR/$tfile
15135 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
15136 error "setstripe on $fm_file"
15138 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
15139 error "dd failed on $fm_file"
15141 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15142 filefrag_op=$(filefrag -ve -k $fm_file |
15143 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15145 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
15146 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15152 for line in $filefrag_op; do
15153 local frag_lun=$(echo $line | cut -d: -f5 |
15154 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15155 local ext_len=$(echo $line | cut -d: -f4)
15156 if (( $frag_lun != $last_lun )); then
15157 if (( tot_len != 1024 )); then
15158 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
15161 (( num_luns += 1 ))
15165 (( tot_len += ext_len ))
15168 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
15169 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
15173 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
15175 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
15178 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
15180 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15181 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15182 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15183 skip "LU-1941: FIEMAP unimplemented on ZFS"
15185 trap cleanup_130 EXIT RETURN
15187 local fm_file=$DIR/$tfile
15188 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
15190 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
15191 error "dd failed on $fm_file"
15193 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15194 filefrag_op=$(filefrag -ve -k $fm_file |
15195 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15197 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
15198 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15203 for line in $filefrag_op; do
15204 local frag_lun=$(echo $line | cut -d: -f5 |
15205 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15206 local ext_len=$(echo $line | cut -d: -f4)
15207 if (( $frag_lun != $last_lun )); then
15208 local logical=$(echo $line | cut -d: -f2 | cut -d. -f1)
15209 if (( logical != 512 )); then
15210 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
15213 if (( tot_len != 512 )); then
15214 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
15217 (( num_luns += 1 ))
15221 (( tot_len += ext_len ))
15224 if (( num_luns != 2 || tot_len != 512 )); then
15225 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
15229 echo "FIEMAP on 2-stripe file with hole succeeded"
15231 run_test 130c "FIEMAP (2-stripe file with hole)"
15234 (( $OSTCOUNT >= 3 )) || skip "needs >= 3 OSTs"
15236 filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15237 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15238 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15239 skip "LU-1941: FIEMAP unimplemented on ZFS"
15241 trap cleanup_130 EXIT RETURN
15243 local fm_file=$DIR/$tfile
15244 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
15245 error "setstripe on $fm_file"
15247 local actual_stripe_count=$($LFS getstripe -c $fm_file)
15248 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
15249 error "dd failed on $fm_file"
15251 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15252 filefrag_op=$(filefrag -ve -k $fm_file |
15253 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15255 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
15256 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15261 for line in $filefrag_op; do
15262 local frag_lun=$(echo $line | cut -d: -f5 |
15263 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15264 local ext_len=$(echo $line | cut -d: -f4)
15265 if (( $frag_lun != $last_lun )); then
15266 if (( tot_len != 1024 )); then
15267 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
15270 (( num_luns += 1 ))
15274 (( tot_len += ext_len ))
15277 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
15278 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
15282 echo "FIEMAP on N-stripe file succeeded"
15284 run_test 130d "FIEMAP (N-stripe file)"
15287 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
15289 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15290 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15291 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15292 skip "LU-1941: FIEMAP unimplemented on ZFS"
15294 trap cleanup_130 EXIT RETURN
15296 local fm_file=$DIR/$tfile
15297 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
15298 stack_trap "rm -f $fm_file"
15301 local expected_len=$(( (num_blks / 2) * 64 ))
15302 for ((i = 0; i < $num_blks; i++)); do
15303 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
15304 conv=notrunc > /dev/null 2>&1
15307 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15308 filefrag_op=$(filefrag -ve -k $fm_file |
15309 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15311 local last_lun=$(echo $filefrag_op | cut -d: -f5)
15316 for line in $filefrag_op; do
15317 local frag_lun=$(echo $line | cut -d: -f5)
15318 local ext_len=$(echo $line | cut -d: -f4)
15319 if (( $frag_lun != $last_lun )); then
15320 if (( tot_len != $expected_len )); then
15321 error "OST$last_lun $tot_len != $expected_len"
15323 (( num_luns += 1 ))
15327 (( tot_len += ext_len ))
15330 if (( num_luns != 2 || tot_len != $expected_len )); then
15331 error "OST$last_lun $num_luns != 2, $tot_len != $expected_len"
15334 echo "FIEMAP with continuation calls succeeded"
15336 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
15339 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15340 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15341 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15342 skip "LU-1941: FIEMAP unimplemented on ZFS"
15344 local fm_file=$DIR/$tfile
15345 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
15346 error "multiop create with lov_delay_create on $fm_file"
15348 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15349 filefrag_extents=$(filefrag -vek $fm_file |
15350 awk '/extents? found/ { print $2 }')
15351 if (( $filefrag_extents != 0 )); then
15352 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
15357 run_test 130f "FIEMAP (unstriped file)"
15360 (( $MDS1_VERSION >= $(version_code 2.12.53) )) ||
15361 skip "Need MDS version with at least 2.12.53 for overstriping"
15362 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15363 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15364 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15365 skip "LU-1941: FIEMAP unimplemented on ZFS"
15367 local file=$DIR/$tfile
15368 local nr=$((OSTCOUNT * 100))
15370 $LFS setstripe -C $nr -S1M $file ||
15371 error "failed to setstripe -C $nr $file"
15373 stack_trap "rm -f $file"
15374 dd if=/dev/zero of=$file count=$nr bs=1M
15376 nr=$($LFS getstripe -c $file)
15378 local extents=$(filefrag -v $file |
15379 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
15381 echo "filefrag list $extents extents in file with stripecount $nr"
15382 if (( extents < nr )); then
15383 $LFS getstripe $file
15385 error "filefrag printed $extents < $nr extents"
15388 run_test 130g "FIEMAP (overstripe file)"
15390 # Test for writev/readv
15392 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
15393 error "writev test failed"
15394 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
15395 error "readv failed"
15398 run_test 131a "test iov's crossing stripe boundary for writev/readv"
15401 local fsize=$((524288 + 1048576 + 1572864))
15402 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
15403 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
15404 error "append writev test failed"
15406 ((fsize += 1572864 + 1048576))
15407 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
15408 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
15409 error "append writev test failed"
15412 run_test 131b "test append writev"
15415 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
15418 run_test 131c "test read/write on file w/o objects"
15421 rwv -f $DIR/$tfile -w -n 1 1572864
15422 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
15423 if [ "$NOB" != 1572864 ]; then
15424 error "Short read filed: read $NOB bytes instead of 1572864"
15428 run_test 131d "test short read"
15431 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
15432 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
15433 error "read hitting hole failed"
15436 run_test 131e "test read hitting hole"
15444 # open 11 samples [usecs] 468 4793 13658 35791898
15446 mds*) res=($(do_facet $facet \
15447 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op"))
15449 ost*) res=($(do_facet $facet \
15450 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op"))
15452 *) error "Wrong facet '$facet'" ;;
15454 [[ -n "$res" ]] || error "counter for $op on $facet not incremented"
15455 # if $want is zero, it means any stat increment is ok.
15456 if (( $want > 0 )); then
15457 local count=${res[1]}
15459 if (( $count != $want )); then
15460 if [[ $facet =~ "mds" ]]; then
15461 do_nodes $(comma_list $(mdts_nodes)) \
15462 $LCTL get_param mdt.*.md_stats
15464 do_nodes $(comma_list $(osts-nodes)) \
15465 $LCTL get_param obdfilter.*.stats
15467 error "The $op counter on $facet is $count, not $want"
15473 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15474 remote_ost_nodsh && skip "remote OST with nodsh"
15475 remote_mds_nodsh && skip "remote MDS with nodsh"
15476 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
15477 skip_env "MDS doesn't support rename stats"
15479 local testdir=$DIR/${tdir}/stats_testdir
15481 mkdir -p $DIR/${tdir}
15484 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15485 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
15487 # verify mdt stats first.
15488 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
15489 check_stats $SINGLEMDS "mkdir" 1
15491 # clear "open" from "lfs mkdir" above
15492 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15493 touch ${testdir}/${tfile} || error "touch failed"
15494 check_stats $SINGLEMDS "open" 1
15495 check_stats $SINGLEMDS "close" 1
15496 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
15497 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
15498 check_stats $SINGLEMDS "mknod" 2
15500 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
15501 check_stats $SINGLEMDS "unlink" 1
15502 rm -f ${testdir}/${tfile} || error "file remove failed"
15503 check_stats $SINGLEMDS "unlink" 2
15505 # remove working dir and check mdt stats again.
15506 rmdir ${testdir} || error "rmdir failed"
15507 check_stats $SINGLEMDS "rmdir" 1
15509 local testdir1=$DIR/${tdir}/stats_testdir1
15510 mkdir_on_mdt0 -p ${testdir}
15511 mkdir_on_mdt0 -p ${testdir1}
15512 touch ${testdir1}/test1
15513 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
15514 check_stats $SINGLEMDS "crossdir_rename" 1
15516 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
15517 check_stats $SINGLEMDS "samedir_rename" 1
15519 rm -rf $DIR/${tdir}
15521 run_test 133a "Verifying MDT stats ========================================"
15526 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15527 remote_ost_nodsh && skip "remote OST with nodsh"
15528 remote_mds_nodsh && skip "remote MDS with nodsh"
15530 local testdir=$DIR/${tdir}/stats_testdir
15532 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
15533 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
15534 touch ${testdir}/${tfile} || error "touch failed"
15535 cancel_lru_locks mdc
15538 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15539 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
15541 # extra mdt stats verification.
15542 chmod 444 ${testdir}/${tfile} || error "chmod failed"
15543 check_stats $SINGLEMDS "setattr" 1
15544 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15545 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
15547 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
15548 check_stats $SINGLEMDS "getattr" 1
15550 rm -rf $DIR/${tdir}
15552 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
15553 # so the check below is not reliable
15554 [ $MDSCOUNT -eq 1 ] || return 0
15556 # Sleep to avoid a cached response.
15557 #define OBD_STATFS_CACHE_SECONDS 1
15559 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15560 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
15561 $LFS df || error "lfs failed"
15562 check_stats $SINGLEMDS "statfs" 1
15564 # check aggregated statfs (LU-10018)
15565 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
15567 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
15570 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15571 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
15573 check_stats $SINGLEMDS "statfs" 1
15575 # We want to check that the client didn't send OST_STATFS to
15576 # ost1 but the MDT also uses OST_STATFS for precreate. So some
15577 # extra care is needed here.
15578 if remote_mds; then
15579 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
15580 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
15582 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
15583 [ "$res" ] && error "OST got STATFS"
15588 run_test 133b "Verifying extra MDT stats =================================="
15591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15592 remote_ost_nodsh && skip "remote OST with nodsh"
15593 remote_mds_nodsh && skip "remote MDS with nodsh"
15595 local testdir=$DIR/$tdir/stats_testdir
15597 test_mkdir -p $testdir
15599 # verify obdfilter stats.
15600 $LFS setstripe -c 1 -i 0 $testdir/$tfile
15602 cancel_lru_locks osc
15603 wait_delete_completed
15606 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15607 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
15609 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
15612 cancel_lru_locks osc
15613 check_stats ost1 "write" 1
15615 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
15616 check_stats ost1 "read" 1
15618 > $testdir/$tfile || error "truncate failed"
15619 check_stats ost1 "punch" 1
15621 rm -f $testdir/$tfile || error "file remove failed"
15622 wait_delete_completed
15623 check_stats ost1 "destroy" 1
15627 run_test 133c "Verifying OST stats ========================================"
15634 while [ $value -ge 2 ]; do
15639 if [ $orig -gt $order ]; then
15647 local size=('K' 'M' 'G' 'T');
15649 local size_string=$value
15651 while [ $value -ge 1024 ]; do
15652 if [ $i -gt 3 ]; then
15653 #T is the biggest unit we get here, if that is bigger,
15655 size_string=${value}T
15658 value=$((value >> 10))
15659 if [ $value -lt 1024 ]; then
15660 size_string=${value}${size[$i]}
15669 get_rename_size() {
15671 local context=${2:-.}
15672 local sample=$(do_facet $SINGLEMDS $LCTL \
15673 get_param mdt.$FSNAME-MDT0000.rename_stats |
15674 grep -A1 $context |
15675 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
15680 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15681 remote_ost_nodsh && skip "remote OST with nodsh"
15682 remote_mds_nodsh && skip "remote MDS with nodsh"
15683 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
15684 skip_env "MDS doesn't support rename stats"
15686 local testdir1=$DIR/${tdir}/stats_testdir1
15687 local testdir2=$DIR/${tdir}/stats_testdir2
15688 mkdir -p $DIR/${tdir} || error "mkdir $tdir failed"
15690 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
15692 mkdir_on_mdt0 ${testdir1} || error "mkdir $testdir1 failed"
15693 mkdir_on_mdt0 ${testdir2} || error "mkdir $testdir2 failed"
15695 createmany -o $testdir1/test 512 || error "createmany failed"
15697 # check samedir rename size
15698 mv ${testdir1}/test0 ${testdir1}/test_0
15700 local testdir1_size=$(ls -l $DIR/${tdir} |
15701 awk '/stats_testdir1/ {print $5}')
15702 local testdir2_size=$(ls -l $DIR/${tdir} |
15703 awk '/stats_testdir2/ {print $5}')
15705 testdir1_size=$(order_2 $testdir1_size)
15706 testdir2_size=$(order_2 $testdir2_size)
15708 testdir1_size=$(size_in_KMGT $testdir1_size)
15709 testdir2_size=$(size_in_KMGT $testdir2_size)
15711 echo "source rename dir size: ${testdir1_size}"
15712 echo "target rename dir size: ${testdir2_size}"
15714 local cmd="do_facet $SINGLEMDS $LCTL "
15715 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
15717 eval $cmd || error "$cmd failed"
15718 local samedir=$($cmd | grep 'same_dir')
15719 local same_sample=$(get_rename_size $testdir1_size)
15720 [ -z "$samedir" ] && error "samedir_rename_size count error"
15721 [[ $same_sample -eq 1 ]] ||
15722 error "samedir_rename_size error $same_sample"
15723 echo "Check same dir rename stats success"
15725 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
15727 # check crossdir rename size
15728 mv ${testdir1}/test_0 ${testdir2}/test_0
15730 testdir1_size=$(ls -l $DIR/${tdir} |
15731 awk '/stats_testdir1/ {print $5}')
15732 testdir2_size=$(ls -l $DIR/${tdir} |
15733 awk '/stats_testdir2/ {print $5}')
15735 testdir1_size=$(order_2 $testdir1_size)
15736 testdir2_size=$(order_2 $testdir2_size)
15738 testdir1_size=$(size_in_KMGT $testdir1_size)
15739 testdir2_size=$(size_in_KMGT $testdir2_size)
15741 echo "source rename dir size: ${testdir1_size}"
15742 echo "target rename dir size: ${testdir2_size}"
15744 eval $cmd || error "$cmd failed"
15745 local crossdir=$($cmd | grep 'crossdir')
15746 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
15747 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
15748 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
15749 [[ $src_sample -eq 1 ]] ||
15750 error "crossdir_rename_size error $src_sample"
15751 [[ $tgt_sample -eq 1 ]] ||
15752 error "crossdir_rename_size error $tgt_sample"
15753 echo "Check cross dir rename stats success"
15754 rm -rf $DIR/${tdir}
15756 run_test 133d "Verifying rename_stats ========================================"
15759 remote_mds_nodsh && skip "remote MDS with nodsh"
15760 remote_ost_nodsh && skip "remote OST with nodsh"
15761 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15763 local testdir=$DIR/${tdir}/stats_testdir
15764 local ctr f0 f1 bs=32768 count=42 sum
15766 mkdir -p ${testdir} || error "mkdir failed"
15768 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
15770 for ctr in {write,read}_bytes; do
15772 cancel_lru_locks osc
15774 do_facet ost1 $LCTL set_param -n \
15775 "obdfilter.*.exports.clear=clear"
15777 if [ $ctr = write_bytes ]; then
15779 f1=${testdir}/${tfile}
15781 f0=${testdir}/${tfile}
15785 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
15788 cancel_lru_locks osc
15790 sum=$(do_facet ost1 $LCTL get_param \
15791 "obdfilter.*.exports.*.stats" |
15792 awk -v ctr=$ctr 'BEGIN { sum = 0 }
15793 $1 == ctr { sum += $7 }
15794 END { printf("%0.0f", sum) }')
15796 if ((sum != bs * count)); then
15797 error "Bad $ctr sum, expected $((bs * count)), got $sum"
15801 rm -rf $DIR/${tdir}
15803 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
15806 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
15807 skip "too old lustre for get_param -R ($facet_ver)"
15809 # verifying readability.
15810 $LCTL get_param -R '*' &> /dev/null
15812 # Verifing writability with badarea_io.
15813 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
15814 local skipped_params='force_lbug|changelog_mask|daemon_file'
15815 $LCTL list_param -FR '*' | grep '=' | tr -d = |
15816 egrep -v "$skipped_params" |
15817 xargs -n 1 find $proc_dirs -name |
15818 xargs -n 1 badarea_io ||
15819 error "client badarea_io failed"
15821 # remount the FS in case writes/reads /proc break the FS
15822 cleanup || error "failed to unmount"
15823 setup || error "failed to setup"
15825 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
15828 remote_mds_nodsh && skip "remote MDS with nodsh"
15829 remote_ost_nodsh && skip "remote OST with nodsh"
15831 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
15832 local proc_dirs_str=$(eval echo $proc_dirs)
15833 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
15835 for facet in mds1 ost1; do
15836 local facet_ver=$(lustre_version_code $facet)
15837 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
15838 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
15840 log "$facet: too old lustre for get_param -R"
15842 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
15843 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
15844 tr -d = | egrep -v $skipped_params |
15845 xargs -n 1 find $proc_dirs_str -name |
15846 xargs -n 1 badarea_io" ||
15847 error "$facet badarea_io failed"
15849 skip_noexit "$facet: too old lustre for get_param -R"
15853 # remount the FS in case writes/reads /proc break the FS
15854 cleanup || error "failed to unmount"
15855 setup || error "failed to setup"
15857 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
15860 remote_mds_nodsh && skip "remote MDS with nodsh"
15861 remote_ost_nodsh && skip "remote OST with nodsh"
15862 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
15863 skip "Need MDS version at least 2.9.54"
15866 for facet in client mds1 ost1; do
15867 # Get the list of files that are missing the terminating newline
15868 local plist=$(do_facet $facet
15869 $LCTL list_param -FR '*' | grep '=' | tr -d =)
15871 for ent in $plist; do
15872 local missing=$(do_facet $facet $LCTL get_param $ent \|\
15873 awk -v FS='\v' -v RS='\v\v' \
15874 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
15875 print FILENAME}'" 2>/dev/null)
15876 [ -z $missing ] || {
15877 do_facet $facet $LCTL get_param $ent | od -An -tx1
15878 error "file does not end with newline: $facet-$ent"
15883 run_test 133h "Proc files should end with newlines"
15886 remote_mds_nodsh && skip "remote MDS with nodsh"
15887 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
15888 skip "Need MDS version at least 2.7.54"
15890 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
15891 cancel_lru_locks mdc
15893 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
15894 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
15895 [ $unused -eq 0 ] || error "$unused locks are not cleared"
15898 createmany -o $DIR/$tdir/f $nr ||
15899 error "failed to create $nr files in $DIR/$tdir"
15900 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
15902 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
15903 do_facet mds1 $LCTL set_param fail_loc=0x327
15904 do_facet mds1 $LCTL set_param fail_val=500
15907 echo "sleep 10 seconds ..."
15909 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
15911 do_facet mds1 $LCTL set_param fail_loc=0
15912 do_facet mds1 $LCTL set_param fail_val=0
15913 [ $lck_cnt -lt $unused ] ||
15914 error "No locks reclaimed, before:$unused, after:$lck_cnt"
15917 unlinkmany $DIR/$tdir/f $nr
15919 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
15922 remote_mds_nodsh && skip "remote MDS with nodsh"
15923 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
15924 skip "Need MDS version at least 2.7.54"
15926 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
15927 cancel_lru_locks mdc
15929 local low_wm=$(do_facet mds1 $LCTL get_param -n \
15930 ldlm.lock_reclaim_threshold_mb)
15931 # disable reclaim temporarily
15932 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
15934 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
15935 do_facet mds1 $LCTL set_param fail_loc=0x328
15936 do_facet mds1 $LCTL set_param fail_val=500
15938 $LCTL set_param debug=+trace
15941 createmany -o $DIR/$tdir/f $nr &
15942 local create_pid=$!
15944 echo "Sleep $TIMEOUT seconds ..."
15946 if ! ps -p $create_pid > /dev/null 2>&1; then
15947 do_facet mds1 $LCTL set_param fail_loc=0
15948 do_facet mds1 $LCTL set_param fail_val=0
15949 do_facet mds1 $LCTL set_param \
15950 ldlm.lock_reclaim_threshold_mb=${low_wm}m
15951 error "createmany finished incorrectly!"
15953 do_facet mds1 $LCTL set_param fail_loc=0
15954 do_facet mds1 $LCTL set_param fail_val=0
15955 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
15956 wait $create_pid || return 1
15958 unlinkmany $DIR/$tdir/f $nr
15960 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
15963 remote_mds_nodsh && skip "remote MDS with nodsh"
15964 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
15965 skip "Need MDS version at least 2.13.50"
15968 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
15970 #define OBD_FAIL_PLAIN_RECORDS 0x1319
15971 #set only one record at plain llog
15972 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
15974 ost_set_temp_seq_width_all $DATA_SEQ_MAX_WIDTH
15976 #fill already existed plain llog each 64767
15977 #wrapping whole catalog
15978 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
15980 createmany -o $DIR/$tdir/$tfile_ 64700
15981 for (( i = 0; i < 64700; i = i + 2 ))
15983 rm $DIR/$tdir/$tfile_$i &
15984 rm $DIR/$tdir/$tfile_$((i + 1)) &
15989 #waiting osp synchronization
15990 wait_delete_completed
15992 run_test 135 "Race catalog processing"
15995 remote_mds_nodsh && skip "remote MDS with nodsh"
15996 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
15997 skip "Need MDS version at least 2.13.50"
16000 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
16001 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
16002 #set only one record at plain llog
16003 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
16004 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
16006 ost_set_temp_seq_width_all $DATA_SEQ_MAX_WIDTH
16008 #fill already existed 2 plain llogs each 64767
16009 #wrapping whole catalog
16010 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
16011 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
16012 wait_delete_completed
16014 createmany -o $DIR/$tdir/$tfile_ 10
16017 do_facet $SINGLEMDS $LCTL set_param fail_val=3
16018 for (( i = 0; i < 10; i = i + 3 ))
16020 rm $DIR/$tdir/$tfile_$i &
16021 rm $DIR/$tdir/$tfile_$((i + 1)) &
16025 rm $DIR/$tdir/$tfile_$((i + 2)) &
16028 #waiting osp synchronization
16029 wait_delete_completed
16031 run_test 136 "Race catalog processing 2"
16033 test_140() { #bug-17379
16034 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16036 test_mkdir $DIR/$tdir
16037 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
16038 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
16040 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
16041 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
16043 while i=$((i + 1)); do
16045 cd $i || error "Changing to $i"
16046 ln -s ../stat stat || error "Creating stat symlink"
16047 # Read the symlink until ELOOP present,
16048 # not LBUGing the system is considered success,
16049 # we didn't overrun the stack.
16050 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
16051 if [ $ret -ne 0 ]; then
16052 if [ $ret -eq 40 ]; then
16055 error "Open stat symlink"
16061 echo "The symlink depth = $i"
16062 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
16063 error "Invalid symlink depth"
16065 # Test recursive symlink
16066 ln -s symlink_self symlink_self
16067 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
16068 echo "open symlink_self returns $ret"
16069 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
16071 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
16074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16076 local TF="$TMP/$tfile"
16078 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16079 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
16081 cancel_lru_locks $OSC
16082 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
16083 remount_client $MOUNT
16085 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
16088 $TRUNCATE $DIR/$tfile 6000
16089 cancel_lru_locks $OSC
16090 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
16093 echo "12345" >>$DIR/$tfile
16094 cancel_lru_locks $OSC
16095 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
16098 echo "12345" >>$DIR/$tfile
16099 cancel_lru_locks $OSC
16100 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
16102 run_test 150a "truncate/append tests"
16105 check_set_fallocate_or_skip
16109 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16110 out=$(check_fallocate $DIR/$tfile 2>&1) ||
16111 skip_eopnotsupp "$out|check_fallocate failed"
16113 run_test 150b "Verify fallocate (prealloc) functionality"
16116 check_set_fallocate_or_skip
16119 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16120 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
16122 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
16123 # precomputed md5sum for 20MB of zeroes
16124 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
16125 local sum=($(md5sum $DIR/$tfile))
16127 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
16129 check_set_fallocate 1
16132 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
16133 sum=($(md5sum $DIR/$tfile))
16135 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
16137 run_test 150bb "Verify fallocate modes both zero space"
16140 check_set_fallocate_or_skip
16141 local striping="-c2"
16143 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16144 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
16145 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
16146 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
16147 local want=$((OSTCOUNT * 1048576))
16149 # Must allocate all requested space, not more than 5% extra
16150 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
16151 error "bytes $bytes is not $want"
16155 echo "verify fallocate on PFL file"
16157 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
16159 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
16160 error "Create $DIR/$tfile failed"
16161 fallocate -l $((1048576 * 512)) $DIR/$tfile || error "fallocate failed"
16162 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
16163 want=$((512 * 1048576))
16165 # Must allocate all requested space, not more than 5% extra
16166 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
16167 error "bytes $bytes is not $want"
16169 run_test 150c "Verify fallocate Size and Blocks"
16172 check_set_fallocate_or_skip
16173 local striping="-c2"
16175 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
16177 stack_trap "rm -f $DIR/$tdir; wait_delete_completed"
16178 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
16179 error "setstripe failed"
16180 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
16181 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
16182 local want=$((OSTCOUNT * 1048576))
16184 # Must allocate all requested space, not more than 5% extra
16185 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
16186 error "bytes $bytes is not $want"
16188 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
16191 check_set_fallocate_or_skip
16195 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16196 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
16197 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
16199 # Find OST with Minimum Size
16200 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
16201 sort -un | head -1)
16203 # Get 100MB per OST of the available space to reduce run time
16204 # else 60% of the available space if we are running SLOW tests
16205 if [ $SLOW == "no" ]; then
16206 local space=$((1024 * 100 * OSTCOUNT))
16208 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
16211 fallocate -l${space}k $DIR/$tfile ||
16212 error "fallocate ${space}k $DIR/$tfile failed"
16213 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
16215 # get size immediately after fallocate. This should be correctly
16217 local size=$(stat -c '%s' $DIR/$tfile)
16218 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
16220 # Sleep for a while for statfs to get updated. And not pull from cache.
16223 echo "df after fallocate:"
16226 (( size / 1024 == space )) || error "size $size != requested $space"
16227 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
16228 error "used $used < space $space"
16230 rm $DIR/$tfile || error "rm failed"
16232 wait_delete_completed
16234 echo "df after unlink:"
16237 run_test 150e "Verify 60% of available OST space consumed by fallocate"
16242 local want_size_before=20480 # in bytes
16243 local want_blocks_before=40 # 512 sized blocks
16244 local want_blocks_after=24 # 512 sized blocks
16245 local length=$(((want_blocks_before - want_blocks_after) * 512))
16247 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
16248 skip "need at least 2.14.0 for fallocate punch"
16250 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
16251 skip "LU-14160: punch mode is not implemented on OSD ZFS"
16254 check_set_fallocate_or_skip
16255 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16257 [[ "x$DOM" == "xyes" ]] &&
16258 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
16260 echo "Verify fallocate punch: Range within the file range"
16261 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
16262 error "dd failed for bs 4096 and count 5"
16264 # Call fallocate with punch range which is within the file range
16265 out=$(fallocate -p --offset 4096 -l $length $DIR/$tfile 2>&1) ||
16266 skip_eopnotsupp "$out|fallocate: offset 4096 and length $length"
16267 # client must see changes immediately after fallocate
16268 size=$(stat -c '%s' $DIR/$tfile)
16269 blocks=$(stat -c '%b' $DIR/$tfile)
16271 # Verify punch worked.
16272 (( blocks == want_blocks_after )) ||
16273 error "punch failed: blocks $blocks != $want_blocks_after"
16275 (( size == want_size_before )) ||
16276 error "punch failed: size $size != $want_size_before"
16278 # Verify there is hole in file
16279 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
16280 # precomputed md5sum
16281 local expect="4a9a834a2db02452929c0a348273b4aa"
16283 cksum=($(md5sum $DIR/$tfile))
16284 [[ "${cksum[0]}" == "$expect" ]] ||
16285 error "unexpected MD5SUM after punch: ${cksum[0]}"
16287 # Start second sub-case for fallocate punch.
16288 echo "Verify fallocate punch: Range overlapping and less than blocksize"
16289 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
16290 error "dd failed for bs 4096 and count 5"
16292 # Punch range less than block size will have no change in block count
16293 want_blocks_after=40 # 512 sized blocks
16295 # Punch overlaps two blocks and less than blocksize
16296 out=$(fallocate -p --offset 4000 -l 3000 $DIR/$tfile 2>&1) ||
16297 skip_eopnotsupp "$out|fallocate: offset 4000 length 3000"
16298 size=$(stat -c '%s' $DIR/$tfile)
16299 blocks=$(stat -c '%b' $DIR/$tfile)
16301 # Verify punch worked.
16302 (( blocks == want_blocks_after )) ||
16303 error "punch failed: blocks $blocks != $want_blocks_after"
16305 (( size == want_size_before )) ||
16306 error "punch failed: size $size != $want_size_before"
16308 # Verify if range is really zero'ed out. We expect Zeros.
16309 # precomputed md5sum
16310 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
16311 cksum=($(md5sum $DIR/$tfile))
16312 [[ "${cksum[0]}" == "$expect" ]] ||
16313 error "unexpected MD5SUM after punch: ${cksum[0]}"
16315 run_test 150f "Verify fallocate punch functionality"
16323 local BS=4096 # Block size in bytes
16325 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
16326 skip "need at least 2.14.0 for fallocate punch"
16328 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
16329 skip "LU-14160: punch mode is not implemented on OSD ZFS"
16332 check_set_fallocate_or_skip
16333 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16335 if [[ "x$DOM" == "xyes" ]]; then
16336 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
16337 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
16339 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
16340 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
16343 # Get 100MB per OST of the available space to reduce run time
16344 # else 60% of the available space if we are running SLOW tests
16345 if [ $SLOW == "no" ]; then
16346 space=$((1024 * 100 * OSTCOUNT))
16348 # Find OST with Minimum Size
16349 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
16350 sort -un | head -1)
16351 echo "min size OST: $space"
16352 space=$(((space * 60)/100 * OSTCOUNT))
16354 # space in 1k units, round to 4k blocks
16355 local blkcount=$((space * 1024 / $BS))
16357 echo "Verify fallocate punch: Very large Range"
16358 fallocate -l${space}k $DIR/$tfile ||
16359 error "fallocate ${space}k $DIR/$tfile failed"
16360 # write 1M at the end, start and in the middle
16361 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
16362 error "dd failed: bs $BS count 256"
16363 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
16364 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
16365 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
16366 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
16369 size=$(stat -c '%s' $DIR/$tfile)
16371 # gather punch length.
16372 local punch_size=$((size - (BS * 2)))
16374 echo "punch_size = $punch_size"
16375 echo "size - punch_size: $((size - punch_size))"
16376 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
16378 # Call fallocate to punch all except 2 blocks. We leave the
16379 # first and the last block
16380 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
16381 out=$(fallocate -p --offset $BS -l $punch_size $DIR/$tfile 2>&1) ||
16382 skip_eopnotsupp "$out|fallocate: offset $BS length $punch_size"
16384 size_after=$(stat -c '%s' $DIR/$tfile)
16385 blocks_after=$(stat -c '%b' $DIR/$tfile)
16387 # Verify punch worked.
16388 # Size should be kept
16389 (( size == size_after )) ||
16390 error "punch failed: size $size != $size_after"
16392 # two 4k data blocks to remain plus possible 1 extra extent block
16393 (( blocks_after <= ((BS / 512) * 3) )) ||
16394 error "too many blocks remains: $blocks_after"
16396 # Verify that file has hole between the first and the last blocks
16397 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
16398 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
16400 echo "Hole at [$hole_start, $hole_end)"
16401 (( hole_start == BS )) ||
16402 error "no hole at offset $BS after punch"
16404 (( hole_end == BS + punch_size )) ||
16405 error "data at offset $hole_end < $((BS + punch_size))"
16407 run_test 150g "Verify fallocate punch on large range"
16410 local file=$DIR/$tfile
16413 check_set_fallocate_or_skip
16414 statx_supported || skip_env "Test must be statx() syscall supported"
16416 # fallocate() does not update the size information on the MDT
16417 fallocate -l 16K $file || error "failed to fallocate $file"
16418 cancel_lru_locks $OSC
16419 # STATX with cached-always mode will not send glimpse RPCs to OST,
16420 # it uses the caching attrs on the client side as much as possible.
16421 size=$($STATX --cached=always -c %s $file)
16422 [ $size == 16384 ] ||
16423 error "size after fallocate() is $size, expected 16384"
16425 run_test 150h "Verify extend fallocate updates the file size"
16427 #LU-2902 roc_hit was not able to read all values from lproc
16428 function roc_hit_init() {
16429 local list=$(comma_list $(osts_nodes))
16430 local dir=$DIR/$tdir-check
16431 local file=$dir/$tfile
16437 #use setstripe to do a write to every ost
16438 for i in $(seq 0 $((OSTCOUNT-1))); do
16439 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
16440 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
16441 idx=$(printf %04x $i)
16442 BEFORE=$(get_osd_param $list *OST*$idx stats |
16443 awk '$1 == "cache_access" {sum += $7}
16444 END { printf("%0.0f", sum) }')
16446 cancel_lru_locks osc
16447 cat $file >/dev/null
16449 AFTER=$(get_osd_param $list *OST*$idx stats |
16450 awk '$1 == "cache_access" {sum += $7}
16451 END { printf("%0.0f", sum) }')
16453 echo BEFORE:$BEFORE AFTER:$AFTER
16454 if ! let "AFTER - BEFORE == 4"; then
16456 error "roc_hit is not safe to use"
16464 function roc_hit() {
16465 local list=$(comma_list $(osts_nodes))
16466 echo $(get_osd_param $list '' stats |
16467 awk '$1 == "cache_hit" {sum += $7}
16468 END { printf("%0.0f", sum) }')
16471 function set_cache() {
16474 if [ "$2" == "off" ]; then
16477 local list=$(comma_list $(osts_nodes))
16478 set_osd_param $list '' $1_cache_enable $on
16480 cancel_lru_locks osc
16484 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16485 remote_ost_nodsh && skip "remote OST with nodsh"
16486 (( CLIENT_VERSION == OST1_VERSION )) ||
16487 skip "LU-13081: no interop testing for OSS cache"
16490 local list=$(comma_list $(osts_nodes))
16492 # check whether obdfilter is cache capable at all
16493 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
16494 skip "not cache-capable obdfilter"
16497 # check cache is enabled on all obdfilters
16498 if get_osd_param $list '' read_cache_enable | grep 0; then
16499 skip "oss cache is disabled"
16502 set_osd_param $list '' writethrough_cache_enable 1
16504 # check write cache is enabled on all obdfilters
16505 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
16506 skip "oss write cache is NOT enabled"
16511 #define OBD_FAIL_OBD_NO_LRU 0x609
16512 do_nodes $list $LCTL set_param fail_loc=0x609
16514 # pages should be in the case right after write
16515 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
16518 local BEFORE=$(roc_hit)
16519 cancel_lru_locks osc
16520 cat $DIR/$tfile >/dev/null
16521 local AFTER=$(roc_hit)
16523 do_nodes $list $LCTL set_param fail_loc=0
16525 if ! let "AFTER - BEFORE == CPAGES"; then
16526 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
16529 cancel_lru_locks osc
16530 # invalidates OST cache
16531 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
16532 set_osd_param $list '' read_cache_enable 0
16533 cat $DIR/$tfile >/dev/null
16535 # now data shouldn't be found in the cache
16537 cancel_lru_locks osc
16538 cat $DIR/$tfile >/dev/null
16540 if let "AFTER - BEFORE != 0"; then
16541 error "IN CACHE: before: $BEFORE, after: $AFTER"
16544 set_osd_param $list '' read_cache_enable 1
16547 run_test 151 "test cache on oss and controls ==============================="
16550 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16552 local TF="$TMP/$tfile"
16554 # simulate ENOMEM during write
16555 #define OBD_FAIL_OST_NOMEM 0x226
16556 lctl set_param fail_loc=0x80000226
16557 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
16559 sync || error "sync failed"
16560 lctl set_param fail_loc=0
16562 # discard client's cache
16563 cancel_lru_locks osc
16565 # simulate ENOMEM during read
16566 lctl set_param fail_loc=0x80000226
16567 cmp $TF $DIR/$tfile || error "cmp failed"
16568 lctl set_param fail_loc=0
16572 run_test 152 "test read/write with enomem ============================"
16575 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
16577 run_test 153 "test if fdatasync does not crash ======================="
16579 dot_lustre_fid_permission_check() {
16581 local ffid=$MOUNT/.lustre/fid/$fid
16584 echo "stat fid $fid"
16585 stat $ffid || error "stat $ffid failed."
16586 echo "touch fid $fid"
16587 touch $ffid || error "touch $ffid failed."
16588 echo "write to fid $fid"
16589 cat /etc/hosts > $ffid || error "write $ffid failed."
16590 echo "read fid $fid"
16591 diff /etc/hosts $ffid || error "read $ffid failed."
16592 echo "append write to fid $fid"
16593 cat /etc/hosts >> $ffid || error "append write $ffid failed."
16594 echo "rename fid $fid"
16595 mv $ffid $test_dir/$tfile.1 &&
16596 error "rename $ffid to $tfile.1 should fail."
16597 touch $test_dir/$tfile.1
16598 mv $test_dir/$tfile.1 $ffid &&
16599 error "rename $tfile.1 to $ffid should fail."
16600 rm -f $test_dir/$tfile.1
16601 echo "truncate fid $fid"
16602 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
16603 echo "link fid $fid"
16604 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
16605 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
16606 id $USER0 || skip_env "missing user $USER0"
16607 echo "setfacl fid $fid"
16608 setfacl -R -m u:$USER0:rwx $ffid ||
16609 error "setfacl $ffid failed"
16610 echo "getfacl fid $fid"
16611 getfacl $ffid || error "getfacl $ffid failed."
16613 echo "unlink fid $fid"
16614 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
16615 echo "mknod fid $fid"
16616 mknod $ffid c 1 3 && error "mknod $ffid should fail."
16618 fid=[0xf00000400:0x1:0x0]
16619 ffid=$MOUNT/.lustre/fid/$fid
16621 echo "stat non-exist fid $fid"
16622 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
16623 echo "write to non-exist fid $fid"
16624 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
16625 echo "link new fid $fid"
16626 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
16628 mkdir -p $test_dir/$tdir
16629 touch $test_dir/$tdir/$tfile
16630 fid=$($LFS path2fid $test_dir/$tdir)
16633 error "error: could not get fid for $test_dir/$dir/$tfile."
16635 ffid=$MOUNT/.lustre/fid/$fid
16638 ls $ffid || error "ls $ffid failed."
16639 echo "touch $fid/$tfile.1"
16640 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
16642 echo "touch $MOUNT/.lustre/fid/$tfile"
16643 touch $MOUNT/.lustre/fid/$tfile && \
16644 error "touch $MOUNT/.lustre/fid/$tfile should fail."
16646 echo "setxattr to $MOUNT/.lustre/fid"
16647 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
16649 echo "listxattr for $MOUNT/.lustre/fid"
16650 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
16652 echo "delxattr from $MOUNT/.lustre/fid"
16653 setfattr -x trusted.name1 $MOUNT/.lustre/fid
16655 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
16656 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
16657 error "touch invalid fid should fail."
16659 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
16660 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
16661 error "touch non-normal fid should fail."
16663 echo "rename $tdir to $MOUNT/.lustre/fid"
16664 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
16665 error "rename to $MOUNT/.lustre/fid should fail."
16667 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
16669 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
16670 local new_obf_mode=777
16672 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
16673 chmod $new_obf_mode $DIR/.lustre/fid ||
16674 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
16676 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
16677 [ $obf_mode -eq $new_obf_mode ] ||
16678 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
16680 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
16681 chmod $old_obf_mode $DIR/.lustre/fid ||
16682 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
16685 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
16686 fid=$($LFS path2fid $test_dir/$tfile-2)
16688 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
16690 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
16691 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
16692 error "create lov data thru .lustre failed"
16694 echo "cp /etc/passwd $test_dir/$tfile-2"
16695 cp /etc/passwd $test_dir/$tfile-2 ||
16696 error "copy to $test_dir/$tfile-2 failed."
16697 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
16698 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
16699 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
16701 rm -rf $test_dir/tfile.lnk
16702 rm -rf $test_dir/$tfile-2
16706 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
16707 skip "Need MDS version at least 2.4.1"
16709 local tf=$DIR/$tfile
16712 local fid=$($LFS path2fid $tf)
16713 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
16715 # check that we get the same pathname back
16718 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
16719 echo "$rootpath $fid"
16720 found=$($LFS fid2path $rootpath "$fid")
16721 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
16722 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
16725 # check wrong root path format
16726 rootpath=$MOUNT"_wrong"
16727 found=$($LFS fid2path $rootpath "$fid")
16728 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
16730 run_test 154A "lfs path2fid and fid2path basic checks"
16733 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
16734 skip "Need MDS version at least 2.4.1"
16736 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
16737 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
16738 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
16739 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
16741 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
16742 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
16744 # check that we get the same pathname
16745 echo "PFID: $PFID, name: $name"
16746 local FOUND=$($LFS fid2path $MOUNT "$PFID")
16747 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
16748 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
16749 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
16751 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
16753 run_test 154B "verify the ll_decode_linkea tool"
16756 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16757 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16758 (( $MDS1_VERSION >= $(version_code 2.2.51) )) ||
16759 skip "Need MDS version at least 2.2.51"
16760 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
16762 cp /etc/hosts $DIR/$tfile
16764 fid=$($LFS path2fid $DIR/$tfile)
16766 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
16768 dot_lustre_fid_permission_check "$fid" $DIR ||
16769 error "dot lustre permission check $fid failed"
16771 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
16773 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
16775 touch $MOUNT/.lustre/file &&
16776 error "creation is not allowed under .lustre"
16778 mkdir $MOUNT/.lustre/dir &&
16779 error "mkdir is not allowed under .lustre"
16783 run_test 154a "Open-by-FID"
16786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16787 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16788 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16789 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
16790 skip "Need MDS version at least 2.2.51"
16792 local remote_dir=$DIR/$tdir/remote_dir
16796 mkdir -p $DIR/$tdir
16797 $LFS mkdir -i $MDTIDX $remote_dir ||
16798 error "create remote directory failed"
16800 cp /etc/hosts $remote_dir/$tfile
16802 fid=$($LFS path2fid $remote_dir/$tfile)
16804 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
16806 dot_lustre_fid_permission_check "$fid" $remote_dir ||
16807 error "dot lustre permission check $fid failed"
16810 run_test 154b "Open-by-FID for remote directory"
16813 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
16814 skip "Need MDS version at least 2.4.1"
16816 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
16817 local FID1=$($LFS path2fid $DIR/$tfile.1)
16818 local FID2=$($LFS path2fid $DIR/$tfile.2)
16819 local FID3=$($LFS path2fid $DIR/$tfile.3)
16822 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
16823 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
16824 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
16826 [ "$FID" = "${!want}" ] ||
16827 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
16831 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
16833 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
16834 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
16838 run_test 154c "lfs path2fid and fid2path multiple arguments"
16841 remote_mds_nodsh && skip "remote MDS with nodsh"
16842 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
16843 skip "Need MDS version at least 2.5.53"
16845 if remote_mds; then
16846 nid=$($LCTL list_nids | sed "s/\./\\\./g")
16850 local proc_ofile="mdt.*.exports.'$nid'.open_files"
16857 local fid=$($LFS path2fid $DIR/$tfile)
16860 cmd="exec $fd<$DIR/$tfile"
16862 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
16863 echo "$fid_list" | grep "$fid"
16866 cmd="exec $fd>/dev/null"
16868 if [ $rc -ne 0 ]; then
16869 error "FID $fid not found in open files list $fid_list"
16872 run_test 154d "Verify open file fid"
16876 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
16877 skip "Need MDS version at least 2.6.50"
16879 if ls -a $MOUNT | grep -q '^\.lustre$'; then
16880 error ".lustre returned by readdir"
16883 run_test 154e ".lustre is not returned by readdir"
16886 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16888 # create parent directory on a single MDT to avoid cross-MDT hardlinks
16889 mkdir_on_mdt0 $DIR/$tdir
16890 # test dirs inherit from its stripe
16891 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
16892 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
16893 cp /etc/hosts $DIR/$tdir/foo1/$tfile
16894 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
16897 # get fid of parents
16898 local FID0=$($LFS path2fid $DIR/$tdir)
16899 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
16900 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
16901 local FID3=$($LFS path2fid $DIR)
16903 # check that path2fid --parents returns expected <parent_fid>/name
16904 # 1) test for a directory (single parent)
16905 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
16906 [ "$parent" == "$FID0/foo1" ] ||
16907 error "expected parent: $FID0/foo1, got: $parent"
16909 # 2) test for a file with nlink > 1 (multiple parents)
16910 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
16911 echo "$parent" | grep -F "$FID1/$tfile" ||
16912 error "$FID1/$tfile not returned in parent list"
16913 echo "$parent" | grep -F "$FID2/link" ||
16914 error "$FID2/link not returned in parent list"
16916 # 3) get parent by fid
16917 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
16918 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16919 echo "$parent" | grep -F "$FID1/$tfile" ||
16920 error "$FID1/$tfile not returned in parent list (by fid)"
16921 echo "$parent" | grep -F "$FID2/link" ||
16922 error "$FID2/link not returned in parent list (by fid)"
16924 # 4) test for entry in root directory
16925 parent=$($LFS path2fid --parents $DIR/f)
16926 echo "$parent" | grep -F "$FID3/f" ||
16927 error "$FID3/f not returned in parent list"
16929 # 5) test it on root directory
16930 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
16931 error "$MOUNT should not have parents"
16933 # enable xattr caching and check that linkea is correctly updated
16934 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
16935 save_lustre_params client "llite.*.xattr_cache" > $save
16936 lctl set_param llite.*.xattr_cache 1
16938 # 6.1) linkea update on rename
16939 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
16941 # get parents by fid
16942 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16943 # foo1 should no longer be returned in parent list
16944 echo "$parent" | grep -F "$FID1" &&
16945 error "$FID1 should no longer be in parent list"
16946 # the new path should appear
16947 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
16948 error "$FID2/$tfile.moved is not in parent list"
16950 # 6.2) linkea update on unlink
16951 rm -f $DIR/$tdir/foo2/link
16952 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16953 # foo2/link should no longer be returned in parent list
16954 echo "$parent" | grep -F "$FID2/link" &&
16955 error "$FID2/link should no longer be in parent list"
16959 restore_lustre_params < $save
16962 run_test 154f "get parent fids by reading link ea"
16966 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
16967 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
16968 skip "Need MDS version at least 2.6.92"
16970 mkdir_on_mdt0 $DIR/$tdir
16971 llapi_fid_test -d $DIR/$tdir
16973 run_test 154g "various llapi FID tests"
16977 (( $CLIENT_VERSION >= $(version_code 2.15.55.1) )) ||
16978 skip "Need client at least version 2.15.55.1"
16980 # Create an empty file
16983 # Get FID (interactive mode) and save under $TMP/$tfile.log
16984 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
16985 path2fid $DIR/$tfile
16988 fid=$(cat $TMP/$tfile.log)
16989 # $fid should not be empty
16990 [[ ! -z $fid ]] || error "FID is empty"
16991 $LFS rmfid $DIR "$fid" || error "rmfid failed for $fid"
16993 run_test 154h "Verify interactive path2fid"
16995 test_155_small_load() {
16996 local temp=$TMP/$tfile
16997 local file=$DIR/$tfile
16999 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
17000 error "dd of=$temp bs=6096 count=1 failed"
17002 cancel_lru_locks $OSC
17003 cmp $temp $file || error "$temp $file differ"
17005 $TRUNCATE $temp 6000
17006 $TRUNCATE $file 6000
17007 cmp $temp $file || error "$temp $file differ (truncate1)"
17009 echo "12345" >>$temp
17010 echo "12345" >>$file
17011 cmp $temp $file || error "$temp $file differ (append1)"
17013 echo "12345" >>$temp
17014 echo "12345" >>$file
17015 cmp $temp $file || error "$temp $file differ (append2)"
17021 test_155_big_load() {
17022 remote_ost_nodsh && skip "remote OST with nodsh"
17024 local temp=$TMP/$tfile
17025 local file=$DIR/$tfile
17028 local cache_size=$(do_facet ost$((MAXI+1)) \
17029 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
17031 # LU-16042: can not get the cache size on Arm64 VM here, fallback to a
17033 if [ -z "$cache_size" ]; then
17036 local large_file_size=$((cache_size * 2))
17038 echo "OSS cache size: $cache_size KB"
17039 echo "Large file size: $large_file_size KB"
17041 [ $MAXV -le $large_file_size ] &&
17042 skip_env "max available OST size needs > $large_file_size KB"
17044 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
17046 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
17047 error "dd of=$temp bs=$large_file_size count=1k failed"
17050 cancel_lru_locks osc
17051 cmp $temp $file || error "$temp $file differ"
17057 save_writethrough() {
17058 local facets=$(get_facets OST)
17060 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
17064 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17066 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17068 save_writethrough $p
17071 set_cache writethrough on
17072 test_155_small_load
17073 restore_lustre_params < $p
17076 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
17079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17081 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17083 save_writethrough $p
17086 set_cache writethrough off
17087 test_155_small_load
17088 restore_lustre_params < $p
17091 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
17094 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17096 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17098 save_writethrough $p
17101 set_cache writethrough on
17102 test_155_small_load
17103 restore_lustre_params < $p
17106 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
17109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17111 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17113 save_writethrough $p
17116 set_cache writethrough off
17117 test_155_small_load
17118 restore_lustre_params < $p
17121 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
17124 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17126 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17128 save_writethrough $p
17131 set_cache writethrough on
17133 restore_lustre_params < $p
17136 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
17139 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17141 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17143 save_writethrough $p
17146 set_cache writethrough off
17148 restore_lustre_params < $p
17151 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
17154 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17156 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17158 save_writethrough $p
17161 set_cache writethrough on
17163 restore_lustre_params < $p
17166 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
17169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17171 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17173 save_writethrough $p
17176 set_cache writethrough off
17178 restore_lustre_params < $p
17181 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
17184 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17185 remote_ost_nodsh && skip "remote OST with nodsh"
17186 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
17187 skip "stats not implemented on old servers"
17188 [ "$ost1_FSTYPE" = "zfs" ] &&
17189 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
17190 (( CLIENT_VERSION == OST1_VERSION )) ||
17191 skip "LU-13081: no interop testing for OSS cache"
17196 local file="$DIR/$tfile"
17197 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17199 save_writethrough $p
17202 log "Turn on read and write cache"
17204 set_cache writethrough on
17206 log "Write data and read it back."
17207 log "Read should be satisfied from the cache."
17208 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
17210 cancel_lru_locks osc
17211 cat $file >/dev/null
17213 if ! let "AFTER - BEFORE == CPAGES"; then
17214 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
17216 log "cache hits: before: $BEFORE, after: $AFTER"
17219 log "Read again; it should be satisfied from the cache."
17221 cancel_lru_locks osc
17222 cat $file >/dev/null
17224 if ! let "AFTER - BEFORE == CPAGES"; then
17225 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
17227 log "cache hits:: before: $BEFORE, after: $AFTER"
17230 log "Turn off the read cache and turn on the write cache"
17232 set_cache writethrough on
17234 log "Read again; it should be satisfied from the cache."
17236 cancel_lru_locks osc
17237 cat $file >/dev/null
17239 if ! let "AFTER - BEFORE == CPAGES"; then
17240 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
17242 log "cache hits:: before: $BEFORE, after: $AFTER"
17245 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
17246 # > 2.12.56 uses pagecache if cached
17247 log "Read again; it should not be satisfied from the cache."
17249 cancel_lru_locks osc
17250 cat $file >/dev/null
17252 if ! let "AFTER - BEFORE == 0"; then
17253 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
17255 log "cache hits:: before: $BEFORE, after: $AFTER"
17259 log "Write data and read it back."
17260 log "Read should be satisfied from the cache."
17261 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
17263 cancel_lru_locks osc
17264 cat $file >/dev/null
17266 if ! let "AFTER - BEFORE == CPAGES"; then
17267 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
17269 log "cache hits:: before: $BEFORE, after: $AFTER"
17272 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
17273 # > 2.12.56 uses pagecache if cached
17274 log "Read again; it should not be satisfied from the cache."
17276 cancel_lru_locks osc
17277 cat $file >/dev/null
17279 if ! let "AFTER - BEFORE == 0"; then
17280 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
17282 log "cache hits:: before: $BEFORE, after: $AFTER"
17286 log "Turn off read and write cache"
17288 set_cache writethrough off
17290 log "Write data and read it back"
17291 log "It should not be satisfied from the cache."
17293 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
17294 cancel_lru_locks osc
17296 cat $file >/dev/null
17298 if ! let "AFTER - BEFORE == 0"; then
17299 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
17301 log "cache hits:: before: $BEFORE, after: $AFTER"
17304 log "Turn on the read cache and turn off the write cache"
17306 set_cache writethrough off
17308 log "Write data and read it back"
17309 log "It should not be satisfied from the cache."
17311 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
17313 cancel_lru_locks osc
17314 cat $file >/dev/null
17316 if ! let "AFTER - BEFORE == 0"; then
17317 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
17319 log "cache hits:: before: $BEFORE, after: $AFTER"
17322 log "Read again; it should be satisfied from the cache."
17324 cancel_lru_locks osc
17325 cat $file >/dev/null
17327 if ! let "AFTER - BEFORE == CPAGES"; then
17328 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
17330 log "cache hits:: before: $BEFORE, after: $AFTER"
17333 restore_lustre_params < $p
17336 run_test 156 "Verification of tunables"
17339 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17340 remote_mds_nodsh && skip "remote MDS with nodsh"
17341 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
17342 skip "Need MDS version at least 2.2.0"
17344 changelog_register || error "changelog_register failed"
17345 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17346 changelog_users $SINGLEMDS | grep -q $cl_user ||
17347 error "User $cl_user not found in changelog_users"
17349 mkdir_on_mdt0 $DIR/$tdir
17352 test_mkdir -p $DIR/$tdir/pics/2008/zachy
17353 changelog_clear 0 || error "changelog_clear failed"
17354 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
17355 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
17356 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
17357 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
17358 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
17359 rm $DIR/$tdir/pics/desktop.jpg
17361 echo "verifying changelog mask"
17362 changelog_chmask "-MKDIR"
17363 changelog_chmask "-CLOSE"
17365 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
17366 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
17368 changelog_chmask "+MKDIR"
17369 changelog_chmask "+CLOSE"
17371 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
17372 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
17374 MKDIRS=$(changelog_dump | grep -c "MKDIR")
17375 CLOSES=$(changelog_dump | grep -c "CLOSE")
17376 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
17377 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
17380 echo "verifying target fid"
17381 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
17382 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
17383 [ "$fidc" == "$fidf" ] ||
17384 error "changelog '$tfile' fid $fidc != file fid $fidf"
17385 echo "verifying parent fid"
17386 # The FID returned from the Changelog may be the directory shard on
17387 # a different MDT, and not the FID returned by path2fid on the parent.
17388 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
17389 # since this is what will matter when recreating this file in the tree.
17390 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
17391 local pathp=$($LFS fid2path $MOUNT "$fidp")
17392 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
17393 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
17395 echo "getting records for $cl_user"
17396 changelog_users $SINGLEMDS
17397 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
17399 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
17400 error "changelog_clear failed"
17401 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
17402 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
17403 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
17404 error "user index expect $user_rec1 + $nclr != $user_rec2"
17406 local min0_rec=$(changelog_users $SINGLEMDS |
17407 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
17408 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
17409 awk '{ print $1; exit; }')
17411 changelog_dump | tail -n 5
17412 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
17413 [ $first_rec == $((min0_rec + 1)) ] ||
17414 error "first index should be $min0_rec + 1 not $first_rec"
17416 # LU-3446 changelog index reset on MDT restart
17417 local cur_rec1=$(changelog_users $SINGLEMDS |
17418 awk '/^current.index:/ { print $NF }')
17419 changelog_clear 0 ||
17420 error "clear all changelog records for $cl_user failed"
17421 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
17422 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
17423 error "Fail to start $SINGLEMDS"
17424 local cur_rec2=$(changelog_users $SINGLEMDS |
17425 awk '/^current.index:/ { print $NF }')
17426 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
17427 [ $cur_rec1 == $cur_rec2 ] ||
17428 error "current index should be $cur_rec1 not $cur_rec2"
17430 echo "verifying users from this test are deregistered"
17431 changelog_deregister || error "changelog_deregister failed"
17432 changelog_users $SINGLEMDS | grep -q $cl_user &&
17433 error "User '$cl_user' still in changelog_users"
17435 # lctl get_param -n mdd.*.changelog_users
17436 # current_index: 144
17437 # ID index (idle seconds)
17438 # cl3 144 (2) mask=<list>
17439 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
17440 # this is the normal case where all users were deregistered
17441 # make sure no new records are added when no users are present
17442 local last_rec1=$(changelog_users $SINGLEMDS |
17443 awk '/^current.index:/ { print $NF }')
17444 touch $DIR/$tdir/chloe
17445 local last_rec2=$(changelog_users $SINGLEMDS |
17446 awk '/^current.index:/ { print $NF }')
17447 echo "verify changelogs are off: $last_rec1 == $last_rec2"
17448 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
17450 # any changelog users must be leftovers from a previous test
17451 changelog_users $SINGLEMDS
17452 echo "other changelog users; can't verify off"
17455 run_test 160a "changelog sanity"
17457 test_160b() { # LU-3587
17458 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17459 remote_mds_nodsh && skip "remote MDS with nodsh"
17460 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
17461 skip "Need MDS version at least 2.2.0"
17463 changelog_register || error "changelog_register failed"
17464 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17465 changelog_users $SINGLEMDS | grep -q $cl_user ||
17466 error "User '$cl_user' not found in changelog_users"
17468 local longname1=$(str_repeat a 255)
17469 local longname2=$(str_repeat b 255)
17472 echo "creating very long named file"
17473 touch $longname1 || error "create of '$longname1' failed"
17474 echo "renaming very long named file"
17475 mv $longname1 $longname2
17477 changelog_dump | grep RENME | tail -n 5
17480 run_test 160b "Verify that very long rename doesn't crash in changelog"
17483 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17484 remote_mds_nodsh && skip "remote MDS with nodsh"
17486 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
17487 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
17488 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
17489 skip "Need MDS version at least 2.5.58 or 2.5.2+"
17493 # Registration step
17494 changelog_register || error "changelog_register failed"
17497 mkdir -p $DIR/$tdir
17498 $MCREATE $DIR/$tdir/foo_160c
17499 changelog_chmask "-TRUNC"
17500 $TRUNCATE $DIR/$tdir/foo_160c 200
17501 changelog_chmask "+TRUNC"
17502 $TRUNCATE $DIR/$tdir/foo_160c 199
17503 changelog_dump | tail -n 5
17504 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
17505 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
17507 run_test 160c "verify that changelog log catch the truncate event"
17510 remote_mds_nodsh && skip "remote MDS with nodsh"
17511 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17512 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17513 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
17514 skip "Need MDS version at least 2.7.60"
17516 # Registration step
17517 changelog_register || error "changelog_register failed"
17519 mkdir -p $DIR/$tdir/migrate_dir
17520 changelog_clear 0 || error "changelog_clear failed"
17522 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
17523 changelog_dump | tail -n 5
17524 local migrates=$(changelog_dump | grep -c "MIGRT")
17525 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
17527 run_test 160d "verify that changelog log catch the migrate event"
17530 remote_mds_nodsh && skip "remote MDS with nodsh"
17533 changelog_register || error "changelog_register failed"
17535 local MDT0=$(facet_svc $SINGLEMDS)
17538 # No user (expect fail)
17539 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
17541 if [ $rc -eq 0 ]; then
17542 error "Should fail without user"
17543 elif [ $rc -ne 4 ]; then
17544 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
17547 # Delete a future user (expect fail)
17548 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
17550 if [ $rc -eq 0 ]; then
17551 error "Deleted non-existant user cl77"
17552 elif [ $rc -ne 2 ]; then
17553 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
17556 # Clear to a bad index (1 billion should be safe)
17557 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
17560 if [ $rc -eq 0 ]; then
17561 error "Successfully cleared to invalid CL index"
17562 elif [ $rc -ne 22 ]; then
17563 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
17566 run_test 160e "changelog negative testing (should return errors)"
17569 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17570 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
17571 skip "Need MDS version at least 2.10.56"
17573 local mdts=$(comma_list $(mdts_nodes))
17576 changelog_register || error "first changelog_register failed"
17577 changelog_register || error "second changelog_register failed"
17579 declare -A cl_user1
17580 declare -A cl_user2
17585 # generate some changelog records to accumulate on each MDT
17586 # use all_char because created files should be evenly distributed
17587 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17588 error "test_mkdir $tdir failed"
17589 log "$(date +%s): creating first files"
17590 for ((i = 0; i < MDSCOUNT * 2; i++)); do
17591 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
17592 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
17595 # check changelogs have been generated
17596 local start=$SECONDS
17597 local idle_time=$((MDSCOUNT * 5 + 5))
17598 local nbcl=$(changelog_dump | wc -l)
17599 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17601 for param in "changelog_max_idle_time=$idle_time" \
17603 "changelog_min_gc_interval=2" \
17604 "changelog_min_free_cat_entries=3"; do
17605 local MDT0=$(facet_svc $SINGLEMDS)
17606 local var="${param%=*}"
17607 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17609 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17610 do_nodes $mdts $LCTL set_param mdd.*.$param
17613 # force cl_user2 to be idle (1st part), but also cancel the
17614 # cl_user1 records so that it is not evicted later in the test.
17615 local sleep1=$((idle_time / 2))
17616 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
17619 # simulate changelog catalog almost full
17620 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
17621 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
17623 for i in $(seq $MDSCOUNT); do
17624 cl_users=(${CL_USERS[mds$i]})
17625 cl_user1[mds$i]="${cl_users[0]}"
17626 cl_user2[mds$i]="${cl_users[1]}"
17628 [ -n "${cl_user1[mds$i]}" ] ||
17629 error "mds$i: no user registered"
17630 [ -n "${cl_user2[mds$i]}" ] ||
17631 error "mds$i: only ${cl_user2[mds$i]} is registered"
17633 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17634 [ -n "$user_rec1" ] ||
17635 error "mds$i: User ${cl_user1[mds$i]} not registered"
17636 __changelog_clear mds$i ${cl_user1[mds$i]} +2
17637 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17638 [ -n "$user_rec2" ] ||
17639 error "mds$i: User ${cl_user1[mds$i]} not registered"
17640 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
17641 "$user_rec1 + 2 == $user_rec2"
17642 [ $((user_rec1 + 2)) == $user_rec2 ] ||
17643 error "mds$i: user ${cl_user1[mds$i]} index expected " \
17644 "$user_rec1 + 2, but is $user_rec2"
17645 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
17646 [ -n "$user_rec2" ] ||
17647 error "mds$i: User ${cl_user2[mds$i]} not registered"
17648 [ $user_rec1 == $user_rec2 ] ||
17649 error "mds$i: user ${cl_user2[mds$i]} index expected " \
17650 "$user_rec1, but is $user_rec2"
17653 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
17654 local sleep2=$((idle_time - (SECONDS - start) + 1))
17655 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
17658 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
17659 # cl_user1 should be OK because it recently processed records.
17660 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
17661 for ((i = 0; i < MDSCOUNT * 2; i++)); do
17662 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
17663 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
17666 # ensure gc thread is done
17667 for i in $(mdts_nodes); do
17668 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
17669 error "$i: GC-thread not done"
17673 for (( i = 1; i <= MDSCOUNT; i++ )); do
17674 # check cl_user1 still registered
17675 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
17676 error "mds$i: User ${cl_user1[mds$i]} not registered"
17677 # check cl_user2 unregistered
17678 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
17679 error "mds$i: User ${cl_user2[mds$i]} still registered"
17681 # check changelogs are present and starting at $user_rec1 + 1
17682 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17683 [ -n "$user_rec1" ] ||
17684 error "mds$i: User ${cl_user1[mds$i]} not registered"
17685 first_rec=$($LFS changelog $(facet_svc mds$i) |
17686 awk '{ print $1; exit; }')
17688 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
17689 [ $((user_rec1 + 1)) == $first_rec ] ||
17690 error "mds$i: rec $first_rec != $user_rec1 + 1"
17693 run_test 160f "changelog garbage collect (timestamped users)"
17696 remote_mds_nodsh && skip "remote MDS with nodsh"
17697 [[ $MDS1_VERSION -ge $(version_code 2.14.55) ]] ||
17698 skip "Need MDS version at least 2.14.55"
17700 local mdts=$(comma_list $(mdts_nodes))
17703 changelog_register || error "first changelog_register failed"
17704 changelog_register || error "second changelog_register failed"
17706 declare -A cl_user1
17707 declare -A cl_user2
17712 # generate some changelog records to accumulate on each MDT
17713 # use all_char because created files should be evenly distributed
17714 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17715 error "test_mkdir $tdir failed"
17716 for ((i = 0; i < MDSCOUNT; i++)); do
17717 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17718 error "create $DIR/$tdir/d$i.1 failed"
17721 # check changelogs have been generated
17722 local nbcl=$(changelog_dump | wc -l)
17723 (( $nbcl > 0 )) || error "no changelogs found"
17725 # reduce the max_idle_indexes value to make sure we exceed it
17726 for param in "changelog_max_idle_indexes=2" \
17728 "changelog_min_gc_interval=2"; do
17729 local MDT0=$(facet_svc $SINGLEMDS)
17730 local var="${param%=*}"
17731 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17733 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17734 do_nodes $mdts $LCTL set_param mdd.*.$param ||
17735 error "unable to set mdd.*.$param"
17738 local start=$SECONDS
17739 for i in $(seq $MDSCOUNT); do
17740 cl_users=(${CL_USERS[mds$i]})
17741 cl_user1[mds$i]="${cl_users[0]}"
17742 cl_user2[mds$i]="${cl_users[1]}"
17744 [ -n "${cl_user1[mds$i]}" ] ||
17745 error "mds$i: user1 is not registered"
17746 [ -n "${cl_user2[mds$i]}" ] ||
17747 error "mds$i: only ${cl_user1[mds$i]} is registered"
17749 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17750 [ -n "$user_rec1" ] ||
17751 error "mds$i: user1 ${cl_user1[mds$i]} not found"
17752 __changelog_clear mds$i ${cl_user1[mds$i]} +2
17753 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17754 [ -n "$user_rec2" ] ||
17755 error "mds$i: user1 ${cl_user1[mds$i]} not found (2)"
17756 echo "mds$i: verifying user1 ${cl_user1[mds$i]} clear: " \
17757 "$user_rec1 + 2 == $user_rec2"
17758 [ $((user_rec1 + 2)) == $user_rec2 ] ||
17759 error "mds$i: user1 ${cl_user1[mds$i]} index " \
17760 "expected $user_rec1 + 2, but is $user_rec2"
17761 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
17762 [ -n "$user_rec2" ] ||
17763 error "mds$i: user2 ${cl_user2[mds$i]} not found"
17764 [ $user_rec1 == $user_rec2 ] ||
17765 error "mds$i: user2 ${cl_user2[mds$i]} index " \
17766 "expected $user_rec1, but is $user_rec2"
17769 # ensure we are past the previous changelog_min_gc_interval set above
17770 local sleep2=$((start + 2 - SECONDS))
17771 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17772 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
17773 # cl_user1 should be OK because it recently processed records.
17774 for ((i = 0; i < MDSCOUNT; i++)); do
17775 $LFS mkdir -i $i $DIR/$tdir/d$i.3 ||
17776 error "create $DIR/$tdir/d$i.3 failed"
17779 # ensure gc thread is done
17780 for i in $(mdts_nodes); do
17781 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
17782 error "$i: GC-thread not done"
17786 for (( i = 1; i <= MDSCOUNT; i++ )); do
17787 # check cl_user1 still registered
17788 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
17789 error "mds$i: user1 ${cl_user1[mds$i]} not found (3)"
17790 # check cl_user2 unregistered
17791 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
17792 error "mds$i: user2 ${cl_user2[mds$i]} is registered"
17794 # check changelogs are present and starting at $user_rec1 + 1
17795 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17796 [ -n "$user_rec1" ] ||
17797 error "mds$i: user1 ${cl_user1[mds$i]} not found (4)"
17798 first_rec=$($LFS changelog $(facet_svc mds$i) |
17799 awk '{ print $1; exit; }')
17801 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
17802 [ $((user_rec1 + 1)) == $first_rec ] ||
17803 error "mds$i: rec $first_rec != $user_rec1 + 1"
17806 run_test 160g "changelog garbage collect on idle records"
17809 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17810 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
17811 skip "Need MDS version at least 2.10.56"
17813 local mdts=$(comma_list $(mdts_nodes))
17816 changelog_register || error "first changelog_register failed"
17817 changelog_register || error "second changelog_register failed"
17819 declare -A cl_user1
17820 declare -A cl_user2
17825 # generate some changelog records to accumulate on each MDT
17826 # use all_char because created files should be evenly distributed
17827 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17828 error "test_mkdir $tdir failed"
17829 for ((i = 0; i < MDSCOUNT; i++)); do
17830 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17831 error "create $DIR/$tdir/d$i.1 failed"
17834 # check changelogs have been generated
17835 local nbcl=$(changelog_dump | wc -l)
17836 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17838 for param in "changelog_max_idle_time=10" \
17840 "changelog_min_gc_interval=2"; do
17841 local MDT0=$(facet_svc $SINGLEMDS)
17842 local var="${param%=*}"
17843 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17845 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17846 do_nodes $mdts $LCTL set_param mdd.*.$param
17849 # force cl_user2 to be idle (1st part)
17852 for i in $(seq $MDSCOUNT); do
17853 cl_users=(${CL_USERS[mds$i]})
17854 cl_user1[mds$i]="${cl_users[0]}"
17855 cl_user2[mds$i]="${cl_users[1]}"
17857 [ -n "${cl_user1[mds$i]}" ] ||
17858 error "mds$i: no user registered"
17859 [ -n "${cl_user2[mds$i]}" ] ||
17860 error "mds$i: only ${cl_user2[mds$i]} is registered"
17862 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17863 [ -n "$user_rec1" ] ||
17864 error "mds$i: User ${cl_user1[mds$i]} not registered"
17865 __changelog_clear mds$i ${cl_user1[mds$i]} +2
17866 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17867 [ -n "$user_rec2" ] ||
17868 error "mds$i: User ${cl_user1[mds$i]} not registered"
17869 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
17870 "$user_rec1 + 2 == $user_rec2"
17871 [ $((user_rec1 + 2)) == $user_rec2 ] ||
17872 error "mds$i: user ${cl_user1[mds$i]} index expected " \
17873 "$user_rec1 + 2, but is $user_rec2"
17874 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
17875 [ -n "$user_rec2" ] ||
17876 error "mds$i: User ${cl_user2[mds$i]} not registered"
17877 [ $user_rec1 == $user_rec2 ] ||
17878 error "mds$i: user ${cl_user2[mds$i]} index expected " \
17879 "$user_rec1, but is $user_rec2"
17882 # force cl_user2 to be idle (2nd part) and to reach
17883 # changelog_max_idle_time
17886 # force each GC-thread start and block then
17887 # one per MDT/MDD, set fail_val accordingly
17888 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
17889 do_nodes $mdts $LCTL set_param fail_loc=0x1316
17891 # generate more changelogs to trigger fail_loc
17892 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
17893 error "create $DIR/$tdir/${tfile}bis failed"
17895 # stop MDT to stop GC-thread, should be done in back-ground as it will
17896 # block waiting for the thread to be released and exit
17897 declare -A stop_pids
17898 for i in $(seq $MDSCOUNT); do
17900 stop_pids[mds$i]=$!
17903 for i in $(mdts_nodes); do
17906 local facets=$(facets_up_on_host $i)
17908 for facet in ${facets//,/ }; do
17909 if [[ $facet == mds* ]]; then
17913 # ensure each MDS's gc threads are still present and all in "R"
17914 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
17915 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
17916 error "$i: expected $nb GC-thread"
17918 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
17920 error "$i: GC-thread not found in R-state"
17921 # check umounts of each MDT on MDS have reached kthread_stop()
17922 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
17923 error "$i: expected $nb umount"
17925 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
17926 error "$i: umount not found in D-state"
17929 # release all GC-threads
17930 do_nodes $mdts $LCTL set_param fail_loc=0
17932 # wait for MDT stop to complete
17933 for i in $(seq $MDSCOUNT); do
17934 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
17938 # may try to check if any orphan changelog records are present
17939 # via ldiskfs/zfs and llog_reader...
17941 # re-start/mount MDTs
17942 for i in $(seq $MDSCOUNT); do
17943 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
17944 error "Fail to start mds$i"
17948 for i in $(seq $MDSCOUNT); do
17949 # check cl_user1 still registered
17950 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
17951 error "mds$i: User ${cl_user1[mds$i]} not registered"
17952 # check cl_user2 unregistered
17953 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
17954 error "mds$i: User ${cl_user2[mds$i]} still registered"
17956 # check changelogs are present and starting at $user_rec1 + 1
17957 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17958 [ -n "$user_rec1" ] ||
17959 error "mds$i: User ${cl_user1[mds$i]} not registered"
17960 first_rec=$($LFS changelog $(facet_svc mds$i) |
17961 awk '{ print $1; exit; }')
17963 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
17964 [ $((user_rec1 + 1)) == $first_rec ] ||
17965 error "mds$i: first index should be $user_rec1 + 1, " \
17966 "but is $first_rec"
17969 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
17974 local mdts=$(comma_list $(mdts_nodes))
17976 changelog_register || error "first changelog_register failed"
17978 # generate some changelog records to accumulate on each MDT
17979 # use all_char because created files should be evenly distributed
17980 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17981 error "test_mkdir $tdir failed"
17982 for ((i = 0; i < MDSCOUNT; i++)); do
17983 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17984 error "create $DIR/$tdir/d$i.1 failed"
17987 # check changelogs have been generated
17988 local nbcl=$(changelog_dump | wc -l)
17989 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17991 # simulate race between register and unregister
17992 # XXX as fail_loc is set per-MDS, with DNE configs the race
17993 # simulation will only occur for one MDT per MDS and for the
17994 # others the normal race scenario will take place
17995 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
17996 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
17997 do_nodes $mdts $LCTL set_param fail_val=1
17999 # unregister 1st user
18000 changelog_deregister &
18002 # wait some time for deregister work to reach race rdv
18004 # register 2nd user
18005 changelog_register || error "2nd user register failed"
18007 wait $pid1 || error "1st user deregister failed"
18011 declare -A LAST_REC
18012 for i in $(seq $MDSCOUNT); do
18013 if changelog_users mds$i | grep "^cl"; then
18014 # make sure new records are added with one user present
18015 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
18016 awk '/^current.index:/ { print $NF }')
18018 error "mds$i has no user registered"
18022 # generate more changelog records to accumulate on each MDT
18023 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
18024 error "create $DIR/$tdir/${tfile}bis failed"
18026 for i in $(seq $MDSCOUNT); do
18027 last_rec=$(changelog_users $SINGLEMDS |
18028 awk '/^current.index:/ { print $NF }')
18029 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
18030 [ $last_rec != ${LAST_REC[mds$i]} ] ||
18031 error "changelogs are off on mds$i"
18034 run_test 160i "changelog user register/unregister race"
18037 remote_mds_nodsh && skip "remote MDS with nodsh"
18038 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
18039 skip "Need MDS version at least 2.12.56"
18041 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
18042 stack_trap "umount $MOUNT2" EXIT
18044 changelog_register || error "first changelog_register failed"
18045 stack_trap "changelog_deregister" EXIT
18047 # generate some changelog
18048 # use all_char because created files should be evenly distributed
18049 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
18050 error "mkdir $tdir failed"
18051 for ((i = 0; i < MDSCOUNT; i++)); do
18052 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
18053 error "create $DIR/$tdir/d$i.1 failed"
18056 # open the changelog device
18057 exec 3>/dev/changelog-$FSNAME-MDT0000
18058 stack_trap "exec 3>&-" EXIT
18059 exec 4</dev/changelog-$FSNAME-MDT0000
18060 stack_trap "exec 4<&-" EXIT
18062 # umount the first lustre mount
18064 stack_trap "mount_client $MOUNT" EXIT
18066 # read changelog, which may or may not fail, but should not crash
18070 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
18071 changelog_users $SINGLEMDS | grep -q $cl_user ||
18072 error "User $cl_user not found in changelog_users"
18074 printf 'clear:'$cl_user':0' >&3
18076 run_test 160j "client can be umounted while its chanangelog is being used"
18079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18080 remote_mds_nodsh && skip "remote MDS with nodsh"
18082 mkdir -p $DIR/$tdir/1/1
18084 changelog_register || error "changelog_register failed"
18085 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
18087 changelog_users $SINGLEMDS | grep -q $cl_user ||
18088 error "User '$cl_user' not found in changelog_users"
18089 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
18090 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
18091 rmdir $DIR/$tdir/1/1 & sleep 1
18093 touch $DIR/$tdir/2/2
18094 rm -rf $DIR/$tdir/2
18099 changelog_dump | grep rmdir || error "rmdir not recorded"
18101 run_test 160k "Verify that changelog records are not lost"
18103 # Verifies that a file passed as a parameter has recently had an operation
18104 # performed on it that has generated an MTIME changelog which contains the
18105 # correct parent FID. As files might reside on a different MDT from the
18106 # parent directory in DNE configurations, the FIDs are translated to paths
18107 # before being compared, which should be identical
18108 compare_mtime_changelog() {
18116 mdtidx=$($LFS getstripe --mdt-index $file)
18117 mdtidx=$(printf "%04x" $mdtidx)
18119 # Obtain the parent FID from the MTIME changelog
18120 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
18121 [ -z "$mtime" ] && error "MTIME changelog not recorded"
18123 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
18124 [ -z "$cl_fid" ] && error "parent FID not present"
18126 # Verify that the path for the parent FID is the same as the path for
18127 # the test directory
18128 pdir=$($LFS fid2path $MOUNT "$cl_fid")
18132 [[ "${pdir%/}" == "$dir" ]] ||
18133 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
18137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18139 remote_mds_nodsh && skip "remote MDS with nodsh"
18140 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
18141 skip "Need MDS version at least 2.13.55"
18145 changelog_register || error "changelog_register failed"
18146 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
18148 changelog_users $SINGLEMDS | grep -q $cl_user ||
18149 error "User '$cl_user' not found in changelog_users"
18151 # Clear some types so that MTIME changelogs are generated
18152 changelog_chmask "-CREAT"
18153 changelog_chmask "-CLOSE"
18155 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
18157 # Test CL_MTIME during setattr
18158 touch $DIR/$tdir/$tfile
18159 compare_mtime_changelog $DIR/$tdir/$tfile
18161 # Test CL_MTIME during close
18162 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
18163 compare_mtime_changelog $DIR/$tdir/${tfile}_2
18165 run_test 160l "Verify that MTIME changelog records contain the parent FID"
18168 remote_mds_nodsh && skip "remote MDS with nodsh" && return
18169 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
18170 skip "Need MDS version at least 2.14.51"
18177 changelog_register || error "first changelog_register failed"
18178 changelog_register || error "second changelog_register failed"
18180 cl_users=(${CL_USERS[mds1]})
18181 cl_user1="${cl_users[0]}"
18182 cl_user2="${cl_users[1]}"
18183 # generate some changelog records to accumulate on MDT0
18184 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
18185 createmany -m $DIR/$tdir/$tfile 50 ||
18186 error "create $DIR/$tdir/$tfile failed"
18187 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
18190 # check changelogs have been generated
18191 local nbcl=$(changelog_dump | wc -l)
18192 [[ $nbcl -eq 0 ]] && error "no changelogs found"
18194 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
18195 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
18197 __changelog_clear mds1 $cl_user1 +10
18198 __changelog_clear mds1 $cl_user2 0 &
18201 __changelog_clear mds1 $cl_user1 0 ||
18202 error "fail to cancel record for $cl_user1"
18204 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
18206 run_test 160m "Changelog clear race"
18209 remote_mds_nodsh && skip "remote MDS with nodsh" && return
18210 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
18211 skip "Need MDS version at least 2.14.51"
18220 changelog_register || error "first changelog_register failed"
18222 cl_users=(${CL_USERS[mds1]})
18223 cl_user1="${cl_users[0]}"
18225 # generate some changelog records to accumulate on MDT0
18226 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
18227 first_rec=$(changelog_users $SINGLEMDS |
18228 awk '/^current.index:/ { print $NF }')
18229 while (( last_rec < (( first_rec + 65000)) )); do
18230 createmany -m $DIR/$tdir/$tfile 10000 ||
18231 error "create $DIR/$tdir/$tfile failed"
18233 for i in $(seq 0 10000); do
18234 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
18238 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
18239 error "unlinkmany failed unlink"
18240 last_rec=$(changelog_users $SINGLEMDS |
18241 awk '/^current.index:/ { print $NF }')
18242 echo last record $last_rec
18243 (( last_rec == 0 )) && error "no changelog found"
18246 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
18247 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
18249 __changelog_clear mds1 $cl_user1 0 &
18252 __changelog_clear mds1 $cl_user1 0 ||
18253 error "fail to cancel record for $cl_user1"
18255 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
18257 run_test 160n "Changelog destroy race"
18260 local mdt="$(facet_svc $SINGLEMDS)"
18262 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
18263 remote_mds_nodsh && skip "remote MDS with nodsh"
18264 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
18265 skip "Need MDS version at least 2.14.52"
18267 changelog_register --user test_160o -m unlnk+close+open ||
18268 error "changelog_register failed"
18270 do_facet $SINGLEMDS $LCTL --device $mdt \
18271 changelog_register -u "Tt3_-#" &&
18272 error "bad symbols in name should fail"
18274 do_facet $SINGLEMDS $LCTL --device $mdt \
18275 changelog_register -u test_160o &&
18276 error "the same name registration should fail"
18278 do_facet $SINGLEMDS $LCTL --device $mdt \
18279 changelog_register -u test_160toolongname &&
18280 error "too long name registration should fail"
18282 changelog_chmask "MARK+HSM"
18283 lctl get_param mdd.*.changelog*mask
18284 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
18285 changelog_users $SINGLEMDS | grep -q $cl_user ||
18286 error "User $cl_user not found in changelog_users"
18288 echo $cl_user | grep -q test_160o ||
18289 error "User $cl_user has no specific name 'test160o'"
18292 changelog_clear 0 || error "changelog_clear failed"
18293 # generate some changelog records to accumulate on MDT0
18294 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
18295 touch $DIR/$tdir/$tfile # open 1
18297 OPENS=$(changelog_dump | grep -c "OPEN")
18298 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
18300 # must be no MKDIR it wasn't set as user mask
18301 MKDIR=$(changelog_dump | grep -c "MKDIR")
18302 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
18304 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
18305 mdd.$mdt.changelog_current_mask -n)
18306 # register maskless user
18307 changelog_register || error "changelog_register failed"
18308 # effective mask should be not changed because it is not minimal
18309 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18310 mdd.$mdt.changelog_current_mask -n)
18311 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
18312 # set server mask to minimal value
18313 changelog_chmask "MARK"
18314 # check effective mask again, should be treated as DEFMASK now
18315 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18316 mdd.$mdt.changelog_current_mask -n)
18317 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
18319 if (( $MDS1_VERSION >= $(version_code 2.15.52) )) ; then
18320 # set server mask back to some value
18321 changelog_chmask "CLOSE,UNLNK"
18322 # check effective mask again, should not remain as DEFMASK
18323 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18324 mdd.$mdt.changelog_current_mask -n)
18325 [[ $mask != *"HLINK"* ]] || error "mask is still DEFMASK"
18328 do_facet $SINGLEMDS $LCTL --device $mdt \
18329 changelog_deregister -u test_160o ||
18330 error "cannot deregister by name"
18332 run_test 160o "changelog user name and mask"
18335 remote_mds_nodsh && skip "remote MDS with nodsh" && return
18336 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
18337 skip "Need MDS version at least 2.14.51"
18338 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
18344 changelog_register || error "first changelog_register failed"
18346 cl_users=(${CL_USERS[mds1]})
18347 cl_user1="${cl_users[0]}"
18349 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
18350 createmany -m $DIR/$tdir/$tfile 50 ||
18351 error "create $DIR/$tdir/$tfile failed"
18352 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
18355 # check changelogs have been generated
18356 entry_count=$(changelog_dump | wc -l)
18357 ((entry_count != 0)) || error "no changelog entries found"
18359 # remove changelog_users and check that orphan entries are removed
18361 local dev=$(mdsdevname 1)
18362 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $dev"
18363 start mds1 $dev $MDS_MOUNT_OPTS || error "cannot start mds1"
18364 entry_count=$(changelog_dump | wc -l)
18365 ((entry_count == 0)) ||
18366 error "found $entry_count changelog entries, expected none"
18368 run_test 160p "Changelog orphan cleanup with no users"
18371 local mdt="$(facet_svc $SINGLEMDS)"
18374 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
18375 remote_mds_nodsh && skip "remote MDS with nodsh"
18376 [ $MDS1_VERSION -ge $(version_code 2.14.54) ] ||
18377 skip "Need MDS version at least 2.14.54"
18379 # set server mask to minimal value like server init does
18380 changelog_chmask "MARK"
18381 clu=$(do_facet $SINGLEMDS $LCTL --device $mdt changelog_register -n) ||
18382 error "changelog_register failed"
18383 # check effective mask again, should be treated as DEFMASK now
18384 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18385 mdd.$mdt.changelog_current_mask -n)
18386 do_facet $SINGLEMDS $LCTL --device $mdt changelog_deregister $clu ||
18387 error "changelog_deregister failed"
18388 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
18390 run_test 160q "changelog effective mask is DEFMASK if not set"
18393 remote_mds_nodsh && skip "remote MDS with nodsh"
18394 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
18395 skip "Need MDS version at least 2.14.55"
18397 local mdts=$(comma_list $(mdts_nodes))
18399 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
18400 do_nodes $mdts $LCTL set_param fail_loc=0x1314 \
18401 fail_val=$((24 * 3600 * 10))
18403 # Create a user which is 10 days old
18404 changelog_register || error "first changelog_register failed"
18406 declare -A cl_user1
18409 # generate some changelog records to accumulate on each MDT
18410 # use all_char because created files should be evenly distributed
18411 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
18412 error "test_mkdir $tdir failed"
18413 for ((i = 0; i < MDSCOUNT; i++)); do
18414 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
18415 error "create $DIR/$tdir/d$i.1 failed"
18418 # check changelogs have been generated
18419 local nbcl=$(changelog_dump | wc -l)
18420 (( nbcl > 0 )) || error "no changelogs found"
18422 # reduce the max_idle_indexes value to make sure we exceed it
18423 for param in "changelog_max_idle_indexes=2097446912" \
18424 "changelog_max_idle_time=2592000" \
18426 "changelog_min_gc_interval=2"; do
18427 local MDT0=$(facet_svc $SINGLEMDS)
18428 local var="${param%=*}"
18429 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
18431 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
18432 do_nodes $mdts $LCTL set_param mdd.*.$param ||
18433 error "unable to set mdd.*.$param"
18436 local start=$SECONDS
18437 for i in $(seq $MDSCOUNT); do
18438 cl_users=(${CL_USERS[mds$i]})
18439 cl_user1[mds$i]="${cl_users[0]}"
18441 [[ -n "${cl_user1[mds$i]}" ]] ||
18442 error "mds$i: no user registered"
18445 #define OBD_FAIL_MDS_CHANGELOG_IDX_PUMP 0x16d
18446 do_nodes $mdts $LCTL set_param fail_loc=0x16d fail_val=500000000
18448 # ensure we are past the previous changelog_min_gc_interval set above
18449 local sleep2=$((start + 2 - SECONDS))
18450 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
18452 # Generate one more changelog to trigger GC
18453 for ((i = 0; i < MDSCOUNT; i++)); do
18454 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
18455 error "create $DIR/$tdir/d$i.3 failed"
18458 # ensure gc thread is done
18459 for node in $(mdts_nodes); do
18460 wait_update $node "pgrep chlg_gc_thread" "" 20 ||
18461 error "$node: GC-thread not done"
18464 do_nodes $mdts $LCTL set_param fail_loc=0
18466 for (( i = 1; i <= MDSCOUNT; i++ )); do
18467 # check cl_user1 is purged
18468 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" &&
18469 error "mds$i: User ${cl_user1[mds$i]} is registered"
18473 run_test 160s "changelog garbage collect on idle records * time"
18476 remote_mds_nodsh && skip "remote MDS with nodsh"
18477 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
18478 skip "Need MDS version at least 2.15.50"
18480 local MDT0=$(facet_svc $SINGLEMDS)
18486 changelog_register --user user1 -m all ||
18487 error "user1 failed to register"
18489 mkdir_on_mdt0 $DIR/$tdir
18490 # create default overstripe to maximize changelog size
18491 $LFS setstripe -C 8 $DIR/$tdir || error "setstripe failed"
18492 createmany -o $DIR/$tdir/u1_ 2000 || error "createmany for user1 failed"
18493 llog_size1=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
18495 # user2 consumes less records so less space
18496 changelog_register --user user2 || error "user2 failed to register"
18497 createmany -o $DIR/$tdir/u2_ 500 || error "createmany for user2 failed"
18498 llog_size2=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
18500 # check changelogs have been generated
18501 local nbcl=$(changelog_dump | wc -l)
18502 (( nbcl > 0 )) || error "no changelogs found"
18504 # reduce the changelog_min_gc_interval to force check
18505 for param in "changelog_gc=1" "changelog_min_gc_interval=2"; do
18506 local var="${param%=*}"
18507 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
18509 stack_trap "do_facet mds1 $LCTL set_param mdd.$MDT0.$var=$old"
18510 do_facet mds1 $LCTL set_param mdd.$MDT0.$param ||
18511 error "unable to set mdd.*.$param"
18515 cl_users=(${CL_USERS[mds1]})
18516 cl_user1="${cl_users[0]}"
18517 cl_user2="${cl_users[1]}"
18519 [[ -n $cl_user1 ]] ||
18520 error "mds1: user #1 isn't registered"
18521 [[ -n $cl_user2 ]] ||
18522 error "mds1: user #2 isn't registered"
18524 # ensure we are past the previous changelog_min_gc_interval set above
18525 local sleep2=$((start + 2 - SECONDS))
18526 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
18528 #define OBD_FAIL_MDS_CHANGELOG_ENOSPC 0x018c
18529 do_facet mds1 $LCTL set_param fail_loc=0x018c \
18530 fail_val=$(((llog_size1 + llog_size2) / 2))
18532 # Generate more changelog to trigger GC
18533 createmany -o $DIR/$tdir/u3_ 4 ||
18534 error "create failed for more files"
18536 # ensure gc thread is done
18537 wait_update_facet mds1 "pgrep chlg_gc_thread" "" 20 ||
18538 error "mds1: GC-thread not done"
18540 do_facet mds1 $LCTL set_param fail_loc=0
18542 # check cl_user1 is purged
18543 changelog_users mds1 | grep -q "$cl_user1" &&
18544 error "User $cl_user1 is registered"
18545 # check cl_user2 is not purged
18546 changelog_users mds1 | grep -q "$cl_user2" ||
18547 error "User $cl_user2 is not registered"
18549 run_test 160t "changelog garbage collect on lack of space"
18552 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18554 test_mkdir -c1 $DIR/$tdir
18555 cp /etc/hosts $DIR/$tdir/$tfile
18556 test_mkdir -c1 $DIR/$tdir/foo1
18557 test_mkdir -c1 $DIR/$tdir/foo2
18558 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
18559 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
18560 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
18561 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
18562 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
18563 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
18564 $LFS fid2path $DIR $FID
18565 error "bad link ea"
18568 rm $DIR/$tdir/foo2/zachary
18570 rm $DIR/$tdir/foo2/thor
18572 rm $DIR/$tdir/$tfile
18574 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
18575 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
18576 { $LFS fid2path $DIR $FID; error "bad link rename"; }
18577 rm $DIR/$tdir/foo2/maggie
18580 local longname=$tfile.avg_len_is_thirty_two_
18581 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
18582 error_noexit 'failed to unlink many hardlinks'" EXIT
18583 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
18584 error "failed to hardlink many files"
18585 links=$($LFS fid2path $DIR $FID | wc -l)
18586 echo -n "${links}/1000 links in link EA"
18587 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
18589 run_test 161a "link ea sanity"
18592 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18593 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
18596 local remote_dir=$DIR/$tdir/remote_dir
18598 mkdir -p $DIR/$tdir
18599 $LFS mkdir -i $MDTIDX $remote_dir ||
18600 error "create remote directory failed"
18602 cp /etc/hosts $remote_dir/$tfile
18603 mkdir -p $remote_dir/foo1
18604 mkdir -p $remote_dir/foo2
18605 ln $remote_dir/$tfile $remote_dir/foo1/sofia
18606 ln $remote_dir/$tfile $remote_dir/foo2/zachary
18607 ln $remote_dir/$tfile $remote_dir/foo1/luna
18608 ln $remote_dir/$tfile $remote_dir/foo2/thor
18610 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
18612 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
18613 $LFS fid2path $DIR $FID
18614 error "bad link ea"
18617 rm $remote_dir/foo2/zachary
18619 rm $remote_dir/foo2/thor
18621 rm $remote_dir/$tfile
18623 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
18624 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
18625 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
18626 $LFS fid2path $DIR $FID
18627 error "bad link rename"
18629 rm $remote_dir/foo2/maggie
18632 local longname=filename_avg_len_is_thirty_two_
18633 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
18634 error "failed to hardlink many files"
18635 links=$($LFS fid2path $DIR $FID | wc -l)
18636 echo -n "${links}/1000 links in link EA"
18637 [[ ${links} -gt 60 ]] ||
18638 error "expected at least 60 links in link EA"
18639 unlinkmany $remote_dir/foo2/$longname 1000 ||
18640 error "failed to unlink many hardlinks"
18642 run_test 161b "link ea sanity under remote directory"
18645 remote_mds_nodsh && skip "remote MDS with nodsh"
18646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18647 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
18648 skip "Need MDS version at least 2.1.5"
18650 # define CLF_RENAME_LAST 0x0001
18651 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
18652 changelog_register || error "changelog_register failed"
18655 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
18656 touch $DIR/$tdir/foo_161c
18657 touch $DIR/$tdir/bar_161c
18658 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
18659 changelog_dump | grep RENME | tail -n 5
18660 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
18661 changelog_clear 0 || error "changelog_clear failed"
18662 if [ x$flags != "x0x1" ]; then
18663 error "flag $flags is not 0x1"
18666 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
18667 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
18668 touch $DIR/$tdir/foo_161c
18669 touch $DIR/$tdir/bar_161c
18670 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
18671 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
18672 changelog_dump | grep RENME | tail -n 5
18673 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
18674 changelog_clear 0 || error "changelog_clear failed"
18675 if [ x$flags != "x0x0" ]; then
18676 error "flag $flags is not 0x0"
18678 echo "rename overwrite a target having nlink > 1," \
18679 "changelog record has flags of $flags"
18681 # rename doesn't overwrite a target (changelog flag 0x0)
18682 touch $DIR/$tdir/foo_161c
18683 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
18684 changelog_dump | grep RENME | tail -n 5
18685 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
18686 changelog_clear 0 || error "changelog_clear failed"
18687 if [ x$flags != "x0x0" ]; then
18688 error "flag $flags is not 0x0"
18690 echo "rename doesn't overwrite a target," \
18691 "changelog record has flags of $flags"
18693 # define CLF_UNLINK_LAST 0x0001
18694 # unlink a file having nlink = 1 (changelog flag 0x1)
18695 rm -f $DIR/$tdir/foo2_161c
18696 changelog_dump | grep UNLNK | tail -n 5
18697 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
18698 changelog_clear 0 || error "changelog_clear failed"
18699 if [ x$flags != "x0x1" ]; then
18700 error "flag $flags is not 0x1"
18702 echo "unlink a file having nlink = 1," \
18703 "changelog record has flags of $flags"
18705 # unlink a file having nlink > 1 (changelog flag 0x0)
18706 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
18707 rm -f $DIR/$tdir/foobar_161c
18708 changelog_dump | grep UNLNK | tail -n 5
18709 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
18710 changelog_clear 0 || error "changelog_clear failed"
18711 if [ x$flags != "x0x0" ]; then
18712 error "flag $flags is not 0x0"
18714 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
18716 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
18719 remote_mds_nodsh && skip "remote MDS with nodsh"
18720 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
18725 changelog_register || error "changelog_register failed"
18727 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
18728 # interfer with $MOUNT/.lustre/fid/ access
18730 [[ $? -eq 0 ]] || error "mkdir failed"
18732 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | CFS_FAIL_ONCE
18733 $LCTL set_param fail_loc=0x8000140c
18735 $LCTL set_param fail_val=5
18738 echo foofoo > $DIR/$tdir/$tfile &
18741 # wait for create to be delayed
18745 [[ $? -eq 0 ]] || error "create should be blocked"
18747 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
18748 stack_trap "rm -f $tempfile"
18749 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
18750 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
18751 # some delay may occur during ChangeLog publishing and file read just
18752 # above, that could allow file write to happen finally
18753 [[ -s $tempfile ]] && echo "file should be empty"
18755 $LCTL set_param fail_loc=0
18758 [[ $? -eq 0 ]] || error "create failed"
18760 run_test 161d "create with concurrent .lustre/fid access"
18763 local expected="$1"
18768 path=$($LFS fid2path "$@")
18771 if [ $rc -ne 0 ]; then
18772 error "path looked up of '$expected' failed: rc=$rc"
18773 elif [ "$path" != "$expected" ]; then
18774 error "path looked up '$path' instead of '$expected'"
18776 echo "FID '$fid' resolves to path '$path' as expected"
18780 test_162a() { # was test_162
18781 test_mkdir -p -c1 $DIR/$tdir/d2
18782 touch $DIR/$tdir/d2/$tfile
18783 touch $DIR/$tdir/d2/x1
18784 touch $DIR/$tdir/d2/x2
18785 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
18786 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
18788 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
18789 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
18792 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
18793 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
18794 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
18796 # softlink to wrong file
18797 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
18798 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
18799 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
18802 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
18803 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
18804 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
18805 # fid2path dir/fsname should both work
18806 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
18807 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
18809 # hardlink count: check that there are 2 links
18810 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
18811 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
18813 # hardlink indexing: remove the first link
18814 rm $DIR/$tdir/d2/p/q/r/hlink
18815 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
18817 run_test 162a "path lookup sanity"
18820 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18821 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18824 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18825 error "create striped dir failed"
18827 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
18828 tail -n 1 | awk '{print $2}')
18829 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
18831 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
18832 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
18835 for ((i=0;i<5;i++)); do
18836 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
18837 error "get fid for f$i failed"
18838 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
18840 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
18841 error "get fid for d$i failed"
18842 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
18847 run_test 162b "striped directory path lookup sanity"
18849 # LU-4239: Verify fid2path works with paths 100 or more directories deep
18851 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
18852 skip "Need MDS version at least 2.7.51"
18854 local lpath=$tdir.local
18855 local rpath=$tdir.remote
18857 test_mkdir $DIR/$lpath
18858 test_mkdir $DIR/$rpath
18860 for ((i = 0; i <= 101; i++)); do
18863 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
18864 error "get fid for local directory $DIR/$lpath failed"
18865 check_path "$DIR/$lpath" $MOUNT $FID --link 0
18868 test_mkdir $DIR/$rpath
18869 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
18870 error "get fid for remote directory $DIR/$rpath failed"
18871 check_path "$DIR/$rpath" $MOUNT $FID --link 0
18876 run_test 162c "fid2path works with paths 100 or more directories deep"
18878 oalr_event_count() {
18882 awk -v name="${FSNAME}-OST0000" \
18883 -v event="${event}" \
18884 '$1 == "TRACE" && $2 == event && $3 == name' \
18889 oalr_expect_event_count() {
18892 local expect="${3}"
18895 count=$(oalr_event_count "${event}" "${trace}")
18896 if ((count == expect)); then
18900 error_noexit "${event} event count was '${count}', expected ${expect}"
18906 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
18908 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
18912 sync # Flush previous IOs so we can count log entries.
18913 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
18914 stack_trap cleanup_165 EXIT
18918 local trace="/tmp/${tfile}.trace"
18922 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18923 skip "OFD access log unsupported"
18926 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18929 do_facet ost1 ofd_access_log_reader --list
18932 do_facet ost1 killall -TERM ofd_access_log_reader
18936 if ((rc != 0)); then
18937 error "ofd_access_log_reader exited with rc = '${rc}'"
18940 # Parse trace file for discovery events:
18941 oalr_expect_event_count alr_log_add "${trace}" 1
18942 oalr_expect_event_count alr_log_eof "${trace}" 1
18943 oalr_expect_event_count alr_log_free "${trace}" 1
18945 run_test 165a "ofd access log discovery"
18948 local trace="/tmp/${tfile}.trace"
18949 local file="${DIR}/${tfile}"
18958 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18959 skip "OFD access log unsupported"
18962 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18965 do_facet ost1 ofd_access_log_reader --list
18967 lfs setstripe -c 1 -i 0 "${file}"
18968 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18969 error "cannot create '${file}'"
18972 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 oalr_expect_event_count alr_log_entry "${trace}" 1
18982 pfid1=$($LFS path2fid "${file}")
18984 # 1 2 3 4 5 6 7 8 9 10
18985 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
18986 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
18988 echo "entry = '${entry[*]}'" >&2
18991 if [[ "${pfid1}" != "${pfid2}" ]]; then
18992 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
18996 if ((size != 1048576)); then
18997 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
19001 if [[ "${flags}" != "w" ]]; then
19002 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
19005 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
19008 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
19009 error "cannot read '${file}'"
19012 do_facet ost1 killall -TERM ofd_access_log_reader
19016 if ((rc != 0)); then
19017 error "ofd_access_log_reader exited with rc = '${rc}'"
19020 oalr_expect_event_count alr_log_entry "${trace}" 1
19022 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
19023 echo "entry = '${entry[*]}'" >&2
19026 if [[ "${pfid1}" != "${pfid2}" ]]; then
19027 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
19031 if ((size != 524288)); then
19032 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
19036 if [[ "${flags}" != "r" ]]; then
19037 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
19040 run_test 165b "ofd access log entries are produced and consumed"
19043 local trace="/tmp/${tfile}.trace"
19044 local file="${DIR}/${tdir}/${tfile}"
19046 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
19047 skip "OFD access log unsupported"
19049 test_mkdir "${DIR}/${tdir}"
19052 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
19055 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
19057 # 4096 / 64 = 64. Create twice as many entries.
19058 for ((i = 0; i < 128; i++)); do
19059 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
19060 error "cannot create file"
19065 do_facet ost1 killall -TERM ofd_access_log_reader
19068 if ((rc != 0)); then
19069 error "ofd_access_log_reader exited with rc = '${rc}'"
19072 unlinkmany "${file}-%d" 128
19074 run_test 165c "full ofd access logs do not block IOs"
19076 oal_get_read_count() {
19079 # STATS lustre-OST0001 alr_read_count 1
19081 do_facet ost1 cat "${stats}" |
19082 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
19083 END { print count; }'
19086 oal_expect_read_count() {
19091 # Ask ofd_access_log_reader to write stats.
19092 do_facet ost1 killall -USR1 ofd_access_log_reader
19094 # Allow some time for things to happen.
19097 count=$(oal_get_read_count "${stats}")
19098 if ((count == expect)); then
19102 error_noexit "bad read count, got ${count}, expected ${expect}"
19103 do_facet ost1 cat "${stats}" >&2
19108 local stats="/tmp/${tfile}.stats"
19109 local file="${DIR}/${tdir}/${tfile}"
19110 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
19112 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
19113 skip "OFD access log unsupported"
19115 test_mkdir "${DIR}/${tdir}"
19118 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
19121 lfs setstripe -c 1 -i 0 "${file}"
19123 do_facet ost1 lctl set_param "${param}=rw"
19124 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
19125 error "cannot create '${file}'"
19126 oal_expect_read_count "${stats}" 1
19128 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
19129 error "cannot read '${file}'"
19130 oal_expect_read_count "${stats}" 2
19132 do_facet ost1 lctl set_param "${param}=r"
19133 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
19134 error "cannot create '${file}'"
19135 oal_expect_read_count "${stats}" 2
19137 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
19138 error "cannot read '${file}'"
19139 oal_expect_read_count "${stats}" 3
19141 do_facet ost1 lctl set_param "${param}=w"
19142 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
19143 error "cannot create '${file}'"
19144 oal_expect_read_count "${stats}" 4
19146 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
19147 error "cannot read '${file}'"
19148 oal_expect_read_count "${stats}" 4
19150 do_facet ost1 lctl set_param "${param}=0"
19151 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
19152 error "cannot create '${file}'"
19153 oal_expect_read_count "${stats}" 4
19155 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
19156 error "cannot read '${file}'"
19157 oal_expect_read_count "${stats}" 4
19159 do_facet ost1 killall -TERM ofd_access_log_reader
19162 if ((rc != 0)); then
19163 error "ofd_access_log_reader exited with rc = '${rc}'"
19166 run_test 165d "ofd_access_log mask works"
19169 local stats="/tmp/${tfile}.stats"
19170 local file0="${DIR}/${tdir}-0/${tfile}"
19171 local file1="${DIR}/${tdir}-1/${tfile}"
19173 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
19174 skip "OFD access log unsupported"
19176 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
19178 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
19179 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
19181 lfs setstripe -c 1 -i 0 "${file0}"
19182 lfs setstripe -c 1 -i 0 "${file1}"
19185 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
19188 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
19189 error "cannot create '${file0}'"
19191 oal_expect_read_count "${stats}" 0
19193 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
19194 error "cannot create '${file1}'"
19196 oal_expect_read_count "${stats}" 1
19198 do_facet ost1 killall -TERM ofd_access_log_reader
19201 if ((rc != 0)); then
19202 error "ofd_access_log_reader exited with rc = '${rc}'"
19205 run_test 165e "ofd_access_log MDT index filter works"
19208 local trace="/tmp/${tfile}.trace"
19213 do_facet ost1 timeout 60 ofd_access_log_reader \
19214 --exit-on-close --debug=- --trace=- > "${trace}" &
19221 if ((rc != 0)); then
19222 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
19227 run_test 165f "ofd_access_log_reader --exit-on-close works"
19230 # do directio so as not to populate the page cache
19231 log "creating a 10 Mb file"
19232 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
19233 error "multiop failed while creating a file"
19234 log "starting reads"
19235 dd if=$DIR/$tfile of=/dev/null bs=4096 &
19236 log "truncating the file"
19237 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
19238 error "multiop failed while truncating the file"
19240 kill %+ || true # reads might have finished
19241 echo "wait until dd is finished"
19243 log "removing the temporary file"
19244 rm -rf $DIR/$tfile || error "tmp file removal failed"
19246 run_test 169 "parallel read and truncate should not deadlock"
19249 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19251 $LCTL clear # bug 18514
19252 $LCTL debug_daemon start $TMP/${tfile}_log_good
19254 $LCTL debug_daemon stop
19255 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
19256 error "sed failed to read log_good"
19258 $LCTL debug_daemon start $TMP/${tfile}_log_good
19260 $LCTL debug_daemon stop
19262 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
19263 error "lctl df log_bad failed"
19265 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
19266 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
19268 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
19269 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
19271 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
19272 error "bad_line good_line1 good_line2 are empty"
19274 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
19275 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
19276 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
19278 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
19279 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
19280 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
19282 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
19283 error "bad_line_new good_line_new are empty"
19285 local expected_good=$((good_line1 + good_line2*2))
19287 rm -f $TMP/${tfile}*
19288 # LU-231, short malformed line may not be counted into bad lines
19289 if [ $bad_line -ne $bad_line_new ] &&
19290 [ $bad_line -ne $((bad_line_new - 1)) ]; then
19291 error "expected $bad_line bad lines, but got $bad_line_new"
19295 if [ $expected_good -ne $good_line_new ]; then
19296 error "expected $expected_good good lines, but got $good_line_new"
19301 run_test 170 "test lctl df to handle corrupted log ====================="
19303 test_171() { # bug20592
19304 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19306 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
19307 $LCTL set_param fail_loc=0x50e
19308 $LCTL set_param fail_val=3000
19309 multiop_bg_pause $DIR/$tfile O_s || true
19311 kill -USR1 $MULTIPID
19315 if dmesg | grep "recursive fault"; then
19316 error "caught a recursive fault"
19318 $LCTL set_param fail_loc=0
19321 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
19325 #define OBD_FAIL_OBD_CLEANUP 0x60e
19326 $LCTL set_param fail_loc=0x60e
19327 umount $MOUNT || error "umount $MOUNT failed"
19328 stack_trap "mount_client $MOUNT"
19330 (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )) ||
19331 error "no client OBDs are remained"
19333 $LCTL dl | while read devno state type name foo; do
19336 $LCTL --device $name cleanup
19337 $LCTL --device $name detach
19340 # skip server devices
19345 if (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )); then
19346 $LCTL dl | egrep " osc | lov | lmv | mdc "
19347 error "some client OBDs are still remained"
19351 run_test 172 "manual device removal with lctl cleanup/detach ======"
19353 # it would be good to share it with obdfilter-survey/iokit-libecho code
19354 setup_obdecho_osc () {
19357 local obdfilter_name=$2
19358 echo "Creating new osc for $obdfilter_name on $ost_nid"
19359 # make sure we can find loopback nid
19360 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
19362 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
19363 ${obdfilter_name}_osc_UUID || rc=2; }
19364 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
19365 ${obdfilter_name}_UUID $ost_nid || rc=3; }
19369 cleanup_obdecho_osc () {
19370 local obdfilter_name=$1
19371 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
19372 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
19379 local pages=${3:-64}
19384 local obd_size=$(get_obd_size $node $OBD)
19385 local page_size=$(get_page_size $node)
19386 if [[ -n "$obd_size" ]]; then
19387 local new_count=$((obd_size / (pages * page_size / 1024)))
19388 [[ $new_count -ge $count ]] || count=$new_count
19391 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
19392 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
19394 if [ $rc -eq 0 ]; then
19395 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
19396 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
19398 echo "New object id is $id"
19399 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
19401 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
19402 "test_brw $count w v $pages $id" || rc=4; }
19403 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
19405 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
19406 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
19407 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
19408 { do_facet $node "$LCTL --device ec detach" || rc=6; }
19409 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
19414 skip "obdecho on osc is no longer supported"
19416 run_test 180a "test obdecho on osc"
19419 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19420 remote_ost_nodsh && skip "remote OST with nodsh"
19422 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
19423 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
19424 error "failed to load module obdecho"
19426 local target=$(do_facet ost1 $LCTL dl |
19427 awk '/obdfilter/ { print $4; exit; }')
19429 if [ -n "$target" ]; then
19430 obdecho_test $target ost1 || error "obdecho_test failed with $?"
19432 do_facet ost1 $LCTL dl
19433 error "there is no obdfilter target on ost1"
19436 run_test 180b "test obdecho directly on obdfilter"
19438 test_180c() { # LU-2598
19439 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19440 remote_ost_nodsh && skip "remote OST with nodsh"
19441 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
19442 skip "Need MDS version at least 2.4.0"
19444 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
19445 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
19446 error "failed to load module obdecho"
19448 local target=$(do_facet ost1 $LCTL dl |
19449 awk '/obdfilter/ { print $4; exit; }')
19451 if [ -n "$target" ]; then
19452 local pages=16384 # 64MB bulk I/O RPC size
19454 obdecho_test "$target" ost1 "$pages" ||
19455 error "obdecho_test with pages=$pages failed with $?"
19457 do_facet ost1 $LCTL dl
19458 error "there is no obdfilter target on ost1"
19461 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
19463 test_181() { # bug 22177
19464 test_mkdir $DIR/$tdir
19465 # create enough files to index the directory
19466 createmany -o $DIR/$tdir/foobar 4000
19467 # print attributes for debug purpose
19470 multiop_bg_pause $DIR/$tdir D_Sc || return 1
19472 # remove the files & current working dir
19473 unlinkmany $DIR/$tdir/foobar 4000
19475 kill -USR1 $MULTIPID
19477 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
19480 run_test 181 "Test open-unlinked dir ========================"
19486 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
19488 $LCTL set_param mdc.*.rpc_stats=clear
19490 for (( i = 0; i < $tcount; i++ )) ; do
19491 mkdir $DIR/$tdir/$i
19494 for (( i = 0; i < $tcount; i++ )) ; do
19495 createmany -o $DIR/$tdir/$i/f- $fcount &
19499 for (( i = 0; i < $tcount; i++ )) ; do
19500 unlinkmany $DIR/$tdir/$i/f- $fcount &
19504 $LCTL get_param mdc.*.rpc_stats
19508 run_test 182a "Test parallel modify metadata operations from mdc"
19511 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
19512 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19519 do_facet mds1 $LCTL list_param \
19520 osp.$FSNAME-MDT*-osp-MDT*.rpc_stats ||
19521 skip "MDS lacks parallel RPC handling"
19523 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
19525 rpc_count=$(do_facet mds1 $LCTL get_param -n \
19526 osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight)
19529 createmany -i 0 -d $DIR/$tdir/t- $tcount
19531 for (( i = 0; i < $tcount; i++ )) ; do
19532 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
19536 delta=$((etime - stime))
19537 echo "Time for file creation $delta sec for $rpc_count parallel RPCs"
19540 for (( i = 0; i < $tcount; i++ )) ; do
19541 unlinkmany -d $DIR/$tdir/$i/d- $dcount &
19545 delta=$((etime - stime))
19546 echo "Time for file removal $delta sec for $rpc_count parallel RPCs"
19550 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
19552 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=1
19555 createmany -i 0 -d $DIR/$tdir/t- $tcount
19557 for (( i = 0; i < $tcount; i++ )) ; do
19558 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
19562 delta=$((etime - stime))
19563 echo "Time for file creation $delta sec for 1 RPC sent at a time"
19566 for (( i = 0; i < $tcount; i++ )) ; do
19567 unlinkmany -d $DIR/$tdir/t-$i/d- $dcount &
19571 delta=$((etime - stime))
19572 echo "Time for file removal $delta sec for 1 RPC sent at a time"
19574 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=$rpc_count
19576 run_test 182b "Test parallel modify metadata operations from osp"
19578 test_183() { # LU-2275
19579 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19580 remote_mds_nodsh && skip "remote MDS with nodsh"
19581 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
19582 skip "Need MDS version at least 2.3.56"
19584 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
19585 echo aaa > $DIR/$tdir/$tfile
19587 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
19588 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
19590 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
19591 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
19593 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
19595 # Flush negative dentry cache
19596 touch $DIR/$tdir/$tfile
19598 # We are not checking for any leaked references here, they'll
19599 # become evident next time we do cleanup with module unload.
19602 run_test 183 "No crash or request leak in case of strange dispositions ========"
19604 # test suite 184 is for LU-2016, LU-2017
19606 check_swap_layouts_support
19608 dir0=$DIR/$tdir/$testnum
19609 test_mkdir -p -c1 $dir0
19614 $LFS setstripe -c1 $file1
19616 $LFS setstripe -c2 $file2
19618 gen1=$($LFS getstripe -g $file1)
19619 gen2=$($LFS getstripe -g $file2)
19621 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
19622 gen=$($LFS getstripe -g $file1)
19623 [[ $gen1 != $gen ]] ||
19624 error "Layout generation on $file1 does not change"
19625 gen=$($LFS getstripe -g $file2)
19626 [[ $gen2 != $gen ]] ||
19627 error "Layout generation on $file2 does not change"
19629 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
19630 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
19632 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
19634 run_test 184a "Basic layout swap"
19637 check_swap_layouts_support
19639 dir0=$DIR/$tdir/$testnum
19640 mkdir -p $dir0 || error "creating dir $dir0"
19647 $LFS setstripe -c1 $file1
19648 $LFS setstripe -c2 $file2
19649 $LFS setstripe -c1 $file3
19650 chown $RUNAS_ID $file3
19651 gen1=$($LFS getstripe -g $file1)
19652 gen2=$($LFS getstripe -g $file2)
19654 $LFS swap_layouts $dir1 $dir2 &&
19655 error "swap of directories layouts should fail"
19656 $LFS swap_layouts $dir1 $file1 &&
19657 error "swap of directory and file layouts should fail"
19658 $RUNAS $LFS swap_layouts $file1 $file2 &&
19659 error "swap of file we cannot write should fail"
19660 $LFS swap_layouts $file1 $file3 &&
19661 error "swap of file with different owner should fail"
19662 /bin/true # to clear error code
19664 run_test 184b "Forbidden layout swap (will generate errors)"
19667 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
19668 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
19669 check_swap_layouts_support
19670 check_swap_layout_no_dom $DIR
19672 local dir0=$DIR/$tdir/$testnum
19673 mkdir -p $dir0 || error "creating dir $dir0"
19675 local ref1=$dir0/ref1
19676 local ref2=$dir0/ref2
19677 local file1=$dir0/file1
19678 local file2=$dir0/file2
19679 # create a file large enough for the concurrent test
19680 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
19681 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
19682 echo "ref file size: ref1($(stat -c %s $ref1))," \
19683 "ref2($(stat -c %s $ref2))"
19686 dd if=$ref1 of=$file1 bs=16k &
19689 # Make sure dd starts to copy file, but wait at most 5 seconds
19691 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
19693 $LFS swap_layouts $file1 $file2
19696 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
19697 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
19699 # how many bytes copied before swapping layout
19700 local copied=$(stat -c %s $file2)
19701 local remaining=$(stat -c %s $ref1)
19702 remaining=$((remaining - copied))
19703 echo "Copied $copied bytes before swapping layout..."
19705 cmp -n $copied $file1 $ref2 | grep differ &&
19706 error "Content mismatch [0, $copied) of ref2 and file1"
19707 cmp -n $copied $file2 $ref1 ||
19708 error "Content mismatch [0, $copied) of ref1 and file2"
19709 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
19710 error "Content mismatch [$copied, EOF) of ref1 and file1"
19713 rm -f $ref1 $ref2 $file1 $file2
19715 run_test 184c "Concurrent write and layout swap"
19718 check_swap_layouts_support
19719 check_swap_layout_no_dom $DIR
19720 [ -z "$(which getfattr 2>/dev/null)" ] &&
19721 skip_env "no getfattr command"
19723 local file1=$DIR/$tdir/$tfile-1
19724 local file2=$DIR/$tdir/$tfile-2
19725 local file3=$DIR/$tdir/$tfile-3
19729 mkdir -p $DIR/$tdir
19730 touch $file1 || error "create $file1 failed"
19731 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
19732 error "create $file2 failed"
19733 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
19734 error "create $file3 failed"
19735 lovea1=$(get_layout_param $file1)
19737 $LFS swap_layouts $file2 $file3 ||
19738 error "swap $file2 $file3 layouts failed"
19739 $LFS swap_layouts $file1 $file2 ||
19740 error "swap $file1 $file2 layouts failed"
19742 lovea2=$(get_layout_param $file2)
19745 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
19747 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
19748 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
19750 run_test 184d "allow stripeless layouts swap"
19753 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
19754 skip "Need MDS version at least 2.6.94"
19755 check_swap_layouts_support
19756 check_swap_layout_no_dom $DIR
19757 [ -z "$(which getfattr 2>/dev/null)" ] &&
19758 skip_env "no getfattr command"
19760 local file1=$DIR/$tdir/$tfile-1
19761 local file2=$DIR/$tdir/$tfile-2
19762 local file3=$DIR/$tdir/$tfile-3
19765 mkdir -p $DIR/$tdir
19766 touch $file1 || error "create $file1 failed"
19767 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
19768 error "create $file2 failed"
19769 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
19770 error "create $file3 failed"
19772 $LFS swap_layouts $file1 $file2 ||
19773 error "swap $file1 $file2 layouts failed"
19775 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
19776 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
19778 echo 123 > $file1 || error "Should be able to write into $file1"
19780 $LFS swap_layouts $file1 $file3 ||
19781 error "swap $file1 $file3 layouts failed"
19783 echo 123 > $file1 || error "Should be able to write into $file1"
19785 rm -rf $file1 $file2 $file3
19787 run_test 184e "Recreate layout after stripeless layout swaps"
19790 # Create a file with name longer than sizeof(struct stat) ==
19791 # 144 to see if we can get chars from the file name to appear
19792 # in the returned striping. Note that 'f' == 0x66.
19793 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
19795 mkdir -p $DIR/$tdir
19796 mcreate $DIR/$tdir/$file
19797 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
19798 error "IOC_MDC_GETFILEINFO returned garbage striping"
19801 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
19803 test_185() { # LU-2441
19804 # LU-3553 - no volatile file support in old servers
19805 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
19806 skip "Need MDS version at least 2.3.60"
19808 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
19809 touch $DIR/$tdir/spoo
19810 local mtime1=$(stat -c "%Y" $DIR/$tdir)
19811 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
19812 error "cannot create/write a volatile file"
19813 [ "$FILESET" == "" ] &&
19814 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
19815 error "FID is still valid after close"
19817 multiop_bg_pause $DIR/$tdir Vw4096_c
19824 # assume that the next FID for this client is sequential, since stdout
19825 # is unfortunately eaten by multiop_bg_pause
19826 local n=$((${fidv[1]} + 1))
19827 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
19828 if [ "$FILESET" == "" ]; then
19829 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
19830 error "FID is missing before close"
19832 kill -USR1 $multi_pid
19833 # 1 second delay, so if mtime change we will see it
19835 local mtime2=$(stat -c "%Y" $DIR/$tdir)
19836 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
19838 run_test 185 "Volatile file support"
19840 function create_check_volatile() {
19844 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
19847 local FID=$(cat /tmp/${tfile}.fid)
19848 [ "$FID" == "" ] && error "can't get FID for volatile"
19849 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
19850 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
19851 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
19855 cancel_lru_locks mdc # flush opencache
19856 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
19861 # LU-12516 - volatile creation via .lustre
19862 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
19863 skip "Need MDS version at least 2.3.55"
19865 create_check_volatile 0
19866 [ $MDSCOUNT -lt 2 ] && return 0
19869 create_check_volatile 1
19873 run_test 185a "Volatile file creation in .lustre/fid/"
19876 remote_mds_nodsh && skip "remote MDS with nodsh"
19877 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
19878 skip "Need MDS version at least 2.3.0"
19880 local dir0=$DIR/$tdir/$testnum
19881 mkdir -p $dir0 || error "creating dir $dir0"
19883 local file=$dir0/file1
19884 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
19885 stack_trap "rm -f $file"
19886 local dv1=$($LFS data_version $file)
19887 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
19888 local dv2=$($LFS data_version $file)
19889 [[ $dv1 != $dv2 ]] ||
19890 error "data version did not change on write $dv1 == $dv2"
19892 run_test 187a "Test data version change"
19895 remote_mds_nodsh && skip "remote MDS with nodsh"
19896 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
19897 skip "Need MDS version at least 2.3.0"
19899 local dir0=$DIR/$tdir/$testnum
19900 mkdir -p $dir0 || error "creating dir $dir0"
19902 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
19903 [[ ${DV[0]} != ${DV[1]} ]] ||
19904 error "data version did not change on write"\
19905 " ${DV[0]} == ${DV[1]}"
19910 run_test 187b "Test data version change on volatile file"
19913 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19914 remote_mgs_nodsh && skip "remote MGS with nodsh"
19915 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
19917 local POOL=${POOL:-cea1}
19918 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
19919 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
19922 local last_ost=$(($OSTCOUNT - 1))
19924 local ost_list=$(seq $first_ost $ost_step $last_ost)
19925 local ost_range="$first_ost $last_ost $ost_step"
19926 local test_path=$POOL_ROOT/$POOL_DIR_NAME
19927 local file_dir=$POOL_ROOT/file_tst
19928 local subdir=$test_path/subdir
19932 # former test_200a test_200b
19933 pool_add $POOL || { rc=$? ; break; }
19934 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
19935 # former test_200c test_200d
19936 mkdir -p $test_path
19937 pool_set_dir $POOL $test_path || { rc=$? ; break; }
19938 pool_check_dir $POOL $test_path || { rc=$? ; break; }
19940 pool_check_dir $POOL $subdir || { rc=$? ; break; }
19941 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
19942 || { rc=$? ; break; }
19943 # former test_200e test_200f
19944 local files=$((OSTCOUNT*3))
19945 pool_alloc_files $POOL $test_path $files "$ost_list" \
19946 || { rc=$? ; break; }
19947 pool_create_files $POOL $file_dir $files "$ost_list" \
19948 || { rc=$? ; break; }
19949 # former test_200g test_200h
19950 pool_lfs_df $POOL || { rc=$? ; break; }
19951 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
19953 # former test_201a test_201b test_201c
19954 pool_remove_first_target $POOL || { rc=$? ; break; }
19956 local f=$test_path/$tfile
19957 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
19958 pool_remove $POOL $f || { rc=$? ; break; }
19966 run_test 200 "OST pools"
19968 # usage: default_attr <count | size | offset>
19970 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
19973 # usage: check_default_stripe_attr
19974 check_default_stripe_attr() {
19975 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
19978 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
19980 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
19984 error "unknown getstripe attr '$1'"
19987 [ $ACTUAL == $EXPECTED ] ||
19988 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
19992 test_mkdir $DIR/$tdir
19993 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
19995 check_default_stripe_attr --stripe-count
19996 check_default_stripe_attr --stripe-size
19997 check_default_stripe_attr --stripe-index
19999 run_test 204a "Print default stripe attributes"
20002 test_mkdir $DIR/$tdir
20003 $LFS setstripe --stripe-count 1 $DIR/$tdir
20005 check_default_stripe_attr --stripe-size
20006 check_default_stripe_attr --stripe-index
20008 run_test 204b "Print default stripe size and offset"
20011 test_mkdir $DIR/$tdir
20012 $LFS setstripe --stripe-size 65536 $DIR/$tdir
20014 check_default_stripe_attr --stripe-count
20015 check_default_stripe_attr --stripe-index
20017 run_test 204c "Print default stripe count and offset"
20020 test_mkdir $DIR/$tdir
20021 $LFS setstripe --stripe-index 0 $DIR/$tdir
20023 check_default_stripe_attr --stripe-count
20024 check_default_stripe_attr --stripe-size
20026 run_test 204d "Print default stripe count and size"
20029 test_mkdir $DIR/$tdir
20030 $LFS setstripe -d $DIR/$tdir
20032 # LU-16904 check if root is set as PFL layout
20033 local numcomp=$($LFS getstripe --component-count $MOUNT)
20035 if [[ $numcomp -gt 0 ]]; then
20036 check_default_stripe_attr --stripe-count
20038 check_default_stripe_attr --stripe-count --raw
20040 check_default_stripe_attr --stripe-size --raw
20041 check_default_stripe_attr --stripe-index --raw
20043 run_test 204e "Print raw stripe attributes"
20046 test_mkdir $DIR/$tdir
20047 $LFS setstripe --stripe-count 1 $DIR/$tdir
20049 check_default_stripe_attr --stripe-size --raw
20050 check_default_stripe_attr --stripe-index --raw
20052 run_test 204f "Print raw stripe size and offset"
20055 test_mkdir $DIR/$tdir
20056 $LFS setstripe --stripe-size 65536 $DIR/$tdir
20058 check_default_stripe_attr --stripe-count --raw
20059 check_default_stripe_attr --stripe-index --raw
20061 run_test 204g "Print raw stripe count and offset"
20064 test_mkdir $DIR/$tdir
20065 $LFS setstripe --stripe-index 0 $DIR/$tdir
20067 check_default_stripe_attr --stripe-count --raw
20068 check_default_stripe_attr --stripe-size --raw
20070 run_test 204h "Print raw stripe count and size"
20072 # Figure out which job scheduler is being used, if any,
20073 # or use a fake one
20074 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
20075 JOBENV=SLURM_JOB_ID
20076 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
20078 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
20080 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
20081 JOBENV=LOADL_STEP_ID
20082 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
20085 $LCTL list_param jobid_name > /dev/null 2>&1
20086 if [ $? -eq 0 ]; then
20092 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
20094 verify_jobstats() {
20099 # we don't really need to clear the stats for this test to work, since each
20100 # command has a unique jobid, but it makes debugging easier if needed.
20101 # for facet in $facets; do
20102 # local dev=$(convert_facet2label $facet)
20103 # # clear old jobstats
20104 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
20107 # use a new JobID for each test, or we might see an old one
20108 [ "$JOBENV" = "FAKE_JOBID" ] &&
20109 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
20111 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
20113 [ "$JOBENV" = "nodelocal" ] && {
20114 FAKE_JOBID=id.$testnum.%e.$RANDOM
20115 $LCTL set_param jobid_name=$FAKE_JOBID
20116 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
20119 log "Test: ${cmd[*]}"
20120 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
20122 if [ $JOBENV = "FAKE_JOBID" ]; then
20123 FAKE_JOBID=$JOBVAL ${cmd[*]}
20128 # all files are created on OST0000
20129 for facet in $facets; do
20130 local stats="*.$(convert_facet2label $facet).job_stats"
20132 # strip out libtool wrappers for in-tree executables
20133 if (( $(do_facet $facet lctl get_param $stats |
20134 sed -e 's/\.lt-/./' | grep -cw $JOBVAL) != 1 )); then
20135 do_facet $facet lctl get_param $stats
20136 error "No jobstats for $JOBVAL found on $facet::$stats"
20142 local new_jobenv=$1
20144 set_persistent_param_and_check client "jobid_var" \
20145 "$FSNAME.sys.jobid_var" $new_jobenv
20148 test_205a() { # Job stats
20149 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20150 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
20151 skip "Need MDS version with at least 2.7.1"
20152 remote_mgs_nodsh && skip "remote MGS with nodsh"
20153 remote_mds_nodsh && skip "remote MDS with nodsh"
20154 remote_ost_nodsh && skip "remote OST with nodsh"
20155 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
20156 skip "Server doesn't support jobstats"
20157 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
20159 local old_jobenv=$($LCTL get_param -n jobid_var)
20160 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
20161 stack_trap "jobstats_set $old_jobenv" EXIT
20165 local old_jobid_name=$($LCTL get_param jobid_name)
20166 stack_trap "$LCTL set_param $old_jobid_name" EXIT
20168 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
20169 mdt.*.job_cleanup_interval | head -n 1)
20170 local new_interval=5
20171 do_facet $SINGLEMDS \
20172 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
20173 stack_trap "do_facet $SINGLEMDS \
20174 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
20175 local start=$SECONDS
20179 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
20180 verify_jobstats "$cmd" "$SINGLEMDS"
20182 cmd="rmdir $DIR/$tdir"
20183 verify_jobstats "$cmd" "$SINGLEMDS"
20184 # mkdir on secondary MDT
20185 if [ $MDSCOUNT -gt 1 ]; then
20186 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
20187 verify_jobstats "$cmd" "mds2"
20190 cmd="mknod $DIR/$tfile c 1 3"
20191 verify_jobstats "$cmd" "$SINGLEMDS"
20193 cmd="rm -f $DIR/$tfile"
20194 verify_jobstats "$cmd" "$SINGLEMDS"
20195 # create all files on OST0000 so verify_jobstats can find OST stats
20197 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
20198 verify_jobstats "$cmd" "$SINGLEMDS"
20200 cmd="touch $DIR/$tfile"
20201 verify_jobstats "$cmd" "$SINGLEMDS ost1"
20203 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
20204 verify_jobstats "$cmd" "ost1"
20206 cancel_lru_locks osc
20207 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
20208 verify_jobstats "$cmd" "ost1"
20210 cmd="$TRUNCATE $DIR/$tfile 0"
20211 verify_jobstats "$cmd" "$SINGLEMDS ost1"
20213 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
20214 verify_jobstats "$cmd" "$SINGLEMDS"
20215 # jobstats expiry - sleep until old stats should be expired
20216 local left=$((new_interval + 5 - (SECONDS - start)))
20217 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
20218 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
20220 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
20221 verify_jobstats "$cmd" "$SINGLEMDS"
20222 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
20223 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
20225 # Ensure that jobid are present in changelog (if supported by MDS)
20226 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
20227 changelog_dump | tail -10
20228 jobids=$(changelog_dump | tail -9 | grep -c "j=")
20229 [ $jobids -eq 9 ] ||
20230 error "Wrong changelog jobid count $jobids != 9"
20234 jobstats_set $JOBENV
20236 changelog_dump | grep $tfile
20237 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
20238 [ $jobids -eq 0 ] ||
20239 error "Unexpected jobids when jobid_var=$JOBENV"
20242 # test '%j' access to environment variable - if supported
20243 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
20244 JOBENV="JOBCOMPLEX"
20245 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
20247 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
20250 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
20251 JOBENV="JOBCOMPLEX"
20252 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
20254 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
20257 # test '%j' access to per-session jobid - if supported
20258 if lctl list_param jobid_this_session > /dev/null 2>&1
20260 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
20261 lctl set_param jobid_this_session=$USER
20263 JOBENV="JOBCOMPLEX"
20264 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
20266 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
20269 run_test 205a "Verify job stats"
20271 # LU-13117, LU-13597, LU-16599
20273 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
20274 skip "Need MDS version at least 2.13.54.91"
20276 local job_stats="mdt.*.job_stats"
20277 local old_jobid=$(do_facet mds1 $LCTL get_param jobid_var)
20279 do_facet mds1 $LCTL set_param $job_stats=clear
20281 # Setting jobid_var to USER might not be supported
20282 [[ -n "$old_jobid" ]] && stack_trap "$LCTL set_param $old_jobid"
20283 $LCTL set_param jobid_var=USER || true
20284 stack_trap "$LCTL set_param $($LCTL get_param jobid_name)"
20285 $LCTL set_param jobid_name="%j.%e.%u"
20287 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
20288 do_facet mds1 $LCTL get_param $job_stats | grep "job_id:.*foolish" &&
20289 { do_facet mds1 $LCTL get_param $job_stats;
20290 error "Unexpected jobid found"; }
20291 do_facet mds1 $LCTL get_param $job_stats | grep "open:.*min.*max.*sum"||
20292 { do_facet mds1 $LCTL get_param $job_stats;
20293 error "wrong job_stats format found"; }
20295 (( $MDS1_VERSION <= $(version_code 2.15.0) )) &&
20296 echo "MDS does not yet escape jobid" && return 0
20298 mkdir_on_mdt0 $DIR/$tdir
20299 $LCTL set_param jobid_var=TEST205b
20300 env -i TEST205b="has sp" touch $DIR/$tdir/$tfile.2
20301 local jobid=$(do_facet mds1 $LCTL get_param $job_stats |
20302 awk '/has\\x20sp/ {print $3}')
20303 [[ -n "$jobid" ]] || { do_facet mds1 $LCTL get_param $job_stats;
20304 error "jobid not escaped"; }
20306 if (( $MDS1_VERSION >= $(version_code 2.15.53.139) )); then
20307 # need to run such a command on mds1:
20308 # lctl set_param mdt.$FSNAME-MDT0000.job_stats='"has\x20sp.touch.0"'
20310 # there might be multiple MDTs on single mds server, so need to
20311 # specifiy MDT0000. Or the command will fail due to other MDTs
20312 do_facet_vp mds1 $LCTL set_param mdt.$FSNAME-MDT0000.job_stats=$jobid ||
20313 error "cannot clear escaped jobid in job_stats";
20315 echo "MDS does not support clearing escaped jobid"
20318 run_test 205b "Verify job stats jobid and output format"
20322 $LCTL set_param llite.*.stats=0
20323 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
20324 $LCTL get_param llite.*.stats
20325 $LCTL get_param llite.*.stats | grep \
20326 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
20327 error "wrong client stats format found"
20329 run_test 205c "Verify client stats format"
20332 local file=$DIR/$tdir/$tfile
20334 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
20335 skip "need lustre >= 2.15.53 for lljobstat"
20336 (( $OST1_VERSION >= $(version_code 2.15.53) )) ||
20337 skip "need lustre >= 2.15.53 for lljobstat"
20338 verify_yaml_available || skip_env "YAML verification not installed"
20340 test_mkdir -i 0 $DIR/$tdir
20341 $LFS setstripe -E 1M -L mdt -E -1 $file || error "create file failed"
20342 stack_trap "rm -rf $DIR/$tdir"
20344 dd if=/dev/zero of=$file bs=1M count=10 conv=sync ||
20345 error "failed to write data to $file"
20348 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats"
20349 echo -n 'verify rename_stats...'
20350 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats" |
20351 verify_yaml || error "rename_stats is not valid YAML"
20354 echo -n 'verify mdt job_stats...'
20355 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.job_stats" |
20356 verify_yaml || error "job_stats on mds1 is not valid YAML"
20359 echo -n 'verify ost job_stats...'
20360 do_facet ost1 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.job_stats" |
20361 verify_yaml || error "job_stats on ost1 is not valid YAML"
20364 run_test 205d "verify the format of some stats files"
20368 local file=$DIR/$tdir/$tfile
20369 local -a cli_params
20371 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
20372 skip "need lustre >= 2.15.53 for lljobstat"
20373 (( $OST1_VERSION >= $(version_code 2.15.53) )) ||
20374 skip "need lustre >= 2.15.53 for lljobstat"
20375 verify_yaml_available || skip_env "YAML verification not installed"
20377 cli_params=( $($LCTL get_param jobid_name jobid_var) )
20378 $LCTL set_param jobid_var=nodelocal jobid_name=205e.%e.%u
20379 stack_trap "$LCTL set_param ${cli_params[*]}" EXIT
20381 mkdir_on_mdt0 $DIR/$tdir || error "failed to create dir"
20382 stack_trap "rm -rf $DIR/$tdir"
20384 $LFS setstripe -E EOF -i 0 -c 1 $file ||
20385 error "failed to create $file on ost1"
20386 dd if=/dev/zero of=$file bs=1M count=10 oflag=sync ||
20387 error "failed to write data to $file"
20389 do_facet mds1 "$LCTL get_param *.*.job_stats"
20390 do_facet ost1 "$LCTL get_param *.*.job_stats"
20392 do_facet ost1 "lljobstat -n 1 -i 0 -c 1000"
20393 do_facet ost1 "lljobstat -n 1 -i 0 -c 1000" | verify_yaml ||
20394 error "The output of lljobstat is not an valid YAML"
20396 # verify that job dd.0 does exist and has some ops on ost1
20397 # typically this line is like:
20398 # - 205e.dd.0: {ops: 20, ...}
20399 ops_comma=$(do_facet ost1 "lljobstat -n 1 -i 0 -c 1000" |
20400 awk '$2=="205e.dd.0:" {print $4}')
20402 (( ${ops_comma%,} >= 10 )) ||
20403 error "cannot find job 205e.dd.0 with ops >= 10"
20405 run_test 205e "verify the output of lljobstat"
20408 verify_yaml_available || skip_env "YAML verification not installed"
20410 # check both qos_ost_weights and qos_mdt_weights
20411 do_facet mds1 $LCTL get_param -n lod.*.qos*weights
20412 do_facet mds1 $LCTL get_param -n lod.*.qos*weights | verify_yaml ||
20413 error "qos_ost_weights is not valid YAML"
20415 run_test 205f "verify qos_ost_weights YAML format "
20417 __test_205_jobstats_dump() {
20419 local nbr_instance=$1
20422 if (( ${#pids[@]} >= nbr_instance )); then
20427 do_facet mds1 "$LCTL get_param mdt.*.job_stats > /dev/null" &
20432 __test_205_cleanup() {
20434 # Clear all job entries
20435 do_facet mds1 "$LCTL set_param mdt.*.job_stats=clear"
20439 local -a mds1_params
20440 local -a cli_params
20444 mds1_params=( $(do_facet mds1 $LCTL get_param mdt.*.job_cleanup_interval) )
20445 do_facet mds1 $LCTL set_param mdt.*.job_cleanup_interval=$interval
20446 stack_trap "do_facet mds1 $LCTL set_param ${mds1_params[*]}" EXIT
20448 cli_params=( $($LCTL get_param jobid_name jobid_var) )
20449 $LCTL set_param jobid_var=TEST205G_ID jobid_name=%j.%p
20450 stack_trap "$LCTL set_param ${cli_params[*]}" EXIT
20453 export TEST205G_ID=205g
20454 stack_trap "unset TEST205G_ID" EXIT
20456 printf $DIR/$tfile.{0001..1000} | xargs -P10 -n1 touch
20459 __test_205_jobstats_dump 4 & pids+="$! "
20460 stack_trap "__test_205_cleanup $pids" EXIT INT
20462 [[ $SLOW == "no" ]] && sleep 90 || sleep 240
20464 run_test 205g "stress test for job_stats procfile"
20467 (( $MDS1_VERSION >= $(version_code 2.15.57.7) )) ||
20468 skip "Need MDS >= v2_15_57-7-g23a2db28dc for jobid xattr"
20469 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
20471 local dir=$DIR/$tdir
20472 local f=$dir/$tfile
20473 local f2=$dir/$tfile-2
20474 local f3=$dir/$tfile-3
20475 local subdir=$DIR/dir
20478 local mdts=$(comma_list $(mdts_nodes))
20479 local mds_saved=$(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.job_xattr)
20480 local client_saved=$($LCTL get_param -n jobid_var)
20482 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.job_xattr=$mds_saved" EXIT
20483 stack_trap "$LCTL set_param jobid_var=$client_saved" EXIT
20485 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.job ||
20486 error "failed to set job_xattr parameter to user.job"
20487 $LCTL set_param jobid_var=procname.uid ||
20488 error "failed to set jobid_var parameter"
20493 val=$(getfattr -n user.job $f | grep user.job)
20494 [[ $val = user.job=\"touch.0\" ]] ||
20495 error "expected user.job=\"touch.0\", got '$val'"
20498 val=$(getfattr -n user.job $subdir | grep user.job)
20499 [[ $val = user.job=\"mkdir.0\" ]] ||
20500 error "expected user.job=\"mkdir.0\", got '$val'"
20502 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=NONE ||
20503 error "failed to set job_xattr parameter to NONE"
20506 val=$(getfattr -d $f2)
20508 error "expected no user xattr, got '$val'"
20510 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=trusted.job ||
20511 error "failed to set job_xattr parameter to trusted.job"
20514 val=$(getfattr -n trusted.job $f3 | grep trusted.job)
20515 [[ $val = trusted.job=\"touch.0\" ]] ||
20516 error "expected trusted.job=\"touch.0\", got '$val'"
20518 run_test 205h "check jobid xattr is stored correctly"
20521 (( $MDS1_VERSION >= $(version_code 2.15.57.7) )) ||
20522 skip "Need MDS >= v2_15_57-7-g23a2db28dc for jobid xattr"
20524 local mdts=$(comma_list $(mdts_nodes))
20525 local mds_saved=$(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.job_xattr)
20527 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.job_xattr=$mds_saved" EXIT
20529 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.1234567 ||
20530 error "failed to set mdt.*.job_xattr to user.1234567"
20532 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.12345678 &&
20533 error "failed to reject too long job_xattr name"
20535 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=userjob &&
20536 error "failed to reject job_xattr name in bad format"
20538 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.job/ &&
20539 error "failed to reject job_xattr name with invalid character"
20541 do_nodes $mdts "printf 'mdt.*.job_xattr=user.job\x80' |
20542 xargs $LCTL set_param" &&
20543 error "failed to reject job_xattr name with non-ascii character"
20547 run_test 205i "check job_xattr parameter accepts and rejects values correctly"
20549 # LU-1480, LU-1773 and LU-1657
20551 mkdir -p $DIR/$tdir
20552 $LFS setstripe -c -1 $DIR/$tdir
20553 #define OBD_FAIL_LOV_INIT 0x1403
20554 $LCTL set_param fail_loc=0xa0001403
20555 $LCTL set_param fail_val=1
20556 touch $DIR/$tdir/$tfile || true
20558 run_test 206 "fail lov_init_raid0() doesn't lbug"
20561 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
20562 local fsz=`stat -c %s $DIR/$tfile`
20563 cancel_lru_locks mdc
20565 # do not return layout in getattr intent
20566 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
20567 $LCTL set_param fail_loc=0x170
20568 local sz=`stat -c %s $DIR/$tfile`
20570 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
20574 run_test 207a "can refresh layout at glimpse"
20577 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
20578 local cksum=`md5sum $DIR/$tfile`
20579 local fsz=`stat -c %s $DIR/$tfile`
20580 cancel_lru_locks mdc
20581 cancel_lru_locks osc
20583 # do not return layout in getattr intent
20584 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
20585 $LCTL set_param fail_loc=0x171
20587 # it will refresh layout after the file is opened but before read issues
20588 echo checksum is "$cksum"
20589 echo "$cksum" |md5sum -c --quiet || error "file differs"
20593 run_test 207b "can refresh layout at open"
20596 # FIXME: in this test suite, only RD lease is used. This is okay
20597 # for now as only exclusive open is supported. After generic lease
20598 # is done, this test suite should be revised. - Jinshan
20600 remote_mds_nodsh && skip "remote MDS with nodsh"
20601 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
20602 skip "Need MDS version at least 2.4.52"
20604 echo "==== test 1: verify get lease work"
20605 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
20607 echo "==== test 2: verify lease can be broken by upcoming open"
20608 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
20612 $MULTIOP $DIR/$tfile oO_RDWR:c
20613 kill -USR1 $PID && wait $PID || error "break lease error"
20615 echo "==== test 3: verify lease can't be granted if an open already exists"
20616 $MULTIOP $DIR/$tfile oO_RDWR:_c &
20620 $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
20621 kill -USR1 $PID && wait $PID || error "open file error"
20623 echo "==== test 4: lease can sustain over recovery"
20624 $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
20630 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
20632 echo "==== test 5: lease broken can't be regained by replay"
20633 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
20637 # open file to break lease and then recovery
20638 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
20641 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
20645 run_test 208 "Exclusive open"
20648 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
20649 skip_env "must have disp_stripe"
20652 sync; sleep 5; sync;
20654 echo 3 > /proc/sys/vm/drop_caches
20655 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
20656 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
20657 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
20659 # open/close 500 times
20660 for i in $(seq 500); do
20664 echo 3 > /proc/sys/vm/drop_caches
20665 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
20666 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
20667 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
20669 echo "before: $req_before, after: $req_after"
20670 [ $((req_after - req_before)) -ge 300 ] &&
20671 error "open/close requests are not freed"
20674 run_test 209 "read-only open/close requests should be freed promptly"
20679 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
20683 $LFS getstripe $DIR/$tfile
20685 wait $pid || error "multiop failed"
20687 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
20691 $LFS getstripe $DIR/$tfile
20693 wait $pid || error "multiop failed"
20695 run_test 210 "lfs getstripe does not break leases"
20697 function test_211() {
20702 stack_trap "rm -f $DIR/$tfile" EXIT
20703 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=10 oflag=direct ||
20704 error "can't create file"
20705 $LFS mirror extend -N $DIR/$tfile ||
20706 error "can't create a replica"
20707 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
20708 $LFS getstripe $DIR/$tfile
20709 stale=$($LFS getstripe $DIR/$tfile | grep stale | wc -l)
20710 (( $stale != 1 )) && error "expected 1 stale, found $stale"
20712 $MULTIOP $DIR/$tfile OeW_E+eUc &
20716 id=$($LFS getstripe $DIR/$tfile |
20717 awk '/lcme_mirror_id:/{id=$2}/lcme_flags.*init$/{print id}')
20718 $LFS mirror split -d --mirror-id $id $DIR/$tfile &&
20719 error "removed last in-sync replica?"
20723 (( $? == 0 )) || error "failed split broke the lease"
20725 run_test 211 "failed mirror split doesn't break write lease"
20729 size=$((size % 8192 + 1))
20730 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
20731 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
20732 rm -f $DIR/f212 $DIR/f212.xyz
20734 run_test 212 "Sendfile test ============================================"
20737 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
20738 cancel_lru_locks osc
20739 lctl set_param fail_loc=0x8000040f
20740 # generate a read lock
20741 cat $DIR/$tfile > /dev/null
20742 # write to the file, it will try to cancel the above read lock.
20743 cat /etc/hosts >> $DIR/$tfile
20745 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
20747 test_214() { # for bug 20133
20748 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
20749 for (( i=0; i < 340; i++ )) ; do
20750 touch $DIR/$tdir/d214c/a$i
20753 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
20754 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
20755 ls $DIR/d214c || error "ls $DIR/d214c failed"
20756 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
20757 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
20759 run_test 214 "hash-indexed directory test - bug 20133"
20761 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
20762 create_lnet_proc_files() {
20763 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
20766 # counterpart of create_lnet_proc_files
20767 remove_lnet_proc_files() {
20768 rm -f $TMP/lnet_$1.sys
20771 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
20772 # 3rd arg as regexp for body
20773 check_lnet_proc_stats() {
20774 local l=$(cat "$TMP/lnet_$1" |wc -l)
20775 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
20777 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
20780 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
20781 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
20782 # optional and can be regexp for 2nd line (lnet.routes case)
20783 check_lnet_proc_entry() {
20784 local blp=2 # blp stands for 'position of 1st line of body'
20785 [ -z "$5" ] || blp=3 # lnet.routes case
20787 local l=$(cat "$TMP/lnet_$1" |wc -l)
20788 # subtracting one from $blp because the body can be empty
20789 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
20791 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
20792 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
20794 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
20795 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
20797 # bail out if any unexpected line happened
20798 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
20799 [ "$?" != 0 ] || error "$2 misformatted"
20802 test_215() { # for bugs 18102, 21079, 21517
20803 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20805 local N='(0|[1-9][0-9]*)' # non-negative numeric
20806 local P='[1-9][0-9]*' # positive numeric
20807 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
20808 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
20809 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
20810 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
20812 local L1 # regexp for 1st line
20813 local L2 # regexp for 2nd line (optional)
20814 local BR # regexp for the rest (body)
20816 # lnet.stats should look as 11 space-separated non-negative numerics
20817 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
20818 create_lnet_proc_files "stats"
20819 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
20820 remove_lnet_proc_files "stats"
20822 # lnet.routes should look like this:
20823 # Routing disabled/enabled
20824 # net hops priority state router
20825 # where net is a string like tcp0, hops > 0, priority >= 0,
20826 # state is up/down,
20827 # router is a string like 192.168.1.1@tcp2
20828 L1="^Routing (disabled|enabled)$"
20829 L2="^net +hops +priority +state +router$"
20830 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
20831 create_lnet_proc_files "routes"
20832 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
20833 remove_lnet_proc_files "routes"
20835 # lnet.routers should look like this:
20836 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
20837 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
20838 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
20839 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
20840 L1="^ref +rtr_ref +alive +router$"
20841 BR="^$P +$P +(up|down) +$NID$"
20842 create_lnet_proc_files "routers"
20843 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
20844 remove_lnet_proc_files "routers"
20846 # lnet.peers should look like this:
20847 # nid refs state last max rtr min tx min queue
20848 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
20849 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
20850 # numeric (0 or >0 or <0), queue >= 0.
20851 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
20852 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
20853 create_lnet_proc_files "peers"
20854 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
20855 remove_lnet_proc_files "peers"
20857 # lnet.buffers should look like this:
20858 # pages count credits min
20859 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
20860 L1="^pages +count +credits +min$"
20861 BR="^ +$N +$N +$I +$I$"
20862 create_lnet_proc_files "buffers"
20863 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
20864 remove_lnet_proc_files "buffers"
20866 # lnet.nis should look like this:
20867 # nid status alive refs peer rtr max tx min
20868 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
20869 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
20870 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
20871 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
20872 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
20873 create_lnet_proc_files "nis"
20874 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
20875 remove_lnet_proc_files "nis"
20877 # can we successfully write to lnet.stats?
20878 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
20880 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
20882 test_216() { # bug 20317
20883 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20884 remote_ost_nodsh && skip "remote OST with nodsh"
20887 local facets=$(get_facets OST)
20888 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
20890 save_lustre_params client "osc.*.contention_seconds" > $p
20891 save_lustre_params $facets \
20892 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
20893 save_lustre_params $facets \
20894 "ldlm.namespaces.filter-*.contended_locks" >> $p
20895 save_lustre_params $facets \
20896 "ldlm.namespaces.filter-*.contention_seconds" >> $p
20897 clear_stats osc.*.osc_stats
20899 # agressive lockless i/o settings
20900 do_nodes $(comma_list $(osts_nodes)) \
20901 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
20902 ldlm.namespaces.filter-*.contended_locks=0 \
20903 ldlm.namespaces.filter-*.contention_seconds=60"
20904 lctl set_param -n osc.*.contention_seconds=60
20906 $DIRECTIO write $DIR/$tfile 0 10 4096
20907 $CHECKSTAT -s 40960 $DIR/$tfile
20909 # disable lockless i/o
20910 do_nodes $(comma_list $(osts_nodes)) \
20911 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
20912 ldlm.namespaces.filter-*.contended_locks=32 \
20913 ldlm.namespaces.filter-*.contention_seconds=0"
20914 lctl set_param -n osc.*.contention_seconds=0
20915 clear_stats osc.*.osc_stats
20917 dd if=/dev/zero of=$DIR/$tfile count=0
20918 $CHECKSTAT -s 0 $DIR/$tfile
20920 restore_lustre_params <$p
20924 run_test 216 "check lockless direct write updates file size and kms correctly"
20926 test_217() { # bug 22430
20927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20931 for node in $(nodes_list); do
20932 local nid=$(host_nids_address $node $NETTYPE)
20933 local node_ip=$(do_node $node getent ahostsv4 $node |
20934 awk '{ print $1; exit; }')
20936 echo "node: '$node', nid: '$nid', node_ip='$node_ip'"
20937 # if hostname matches any NID, use hostname for better testing
20938 if [[ -z "$nid" || "$nid" =~ "$node_ip" ]]; then
20939 echo "lctl ping node $node@$NETTYPE"
20940 lctl ping $node@$NETTYPE
20941 else # otherwise, at least test 'lctl ping' is working
20942 echo "lctl ping nid $(h2nettype $nid)"
20943 lctl ping $(h2nettype $nid)
20944 echo "skipping $node (no hyphen detected)"
20948 run_test 217 "check lctl ping for hostnames with embedded hyphen ('-')"
20951 # do directio so as not to populate the page cache
20952 log "creating a 10 Mb file"
20953 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
20954 error "multiop failed while creating a file"
20955 log "starting reads"
20956 dd if=$DIR/$tfile of=/dev/null bs=4096 &
20957 log "truncating the file"
20958 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
20959 error "multiop failed while truncating the file"
20961 kill %+ || true # reads might have finished
20962 echo "wait until dd is finished"
20964 log "removing the temporary file"
20965 rm -rf $DIR/$tfile || error "tmp file removal failed"
20967 run_test 218 "parallel read and truncate should not deadlock"
20970 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20972 # write one partial page
20973 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
20974 # set no grant so vvp_io_commit_write will do sync write
20975 $LCTL set_param fail_loc=0x411
20976 # write a full page at the end of file
20977 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
20979 $LCTL set_param fail_loc=0
20980 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
20981 $LCTL set_param fail_loc=0x411
20982 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
20985 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
20986 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
20988 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
20990 test_220() { #LU-325
20991 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20992 remote_ost_nodsh && skip "remote OST with nodsh"
20993 remote_mds_nodsh && skip "remote MDS with nodsh"
20994 remote_mgs_nodsh && skip "remote MGS with nodsh"
20998 # create on MDT0000 so the last_id and next_id are correct
20999 mkdir_on_mdt0 $DIR/$tdir
21000 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
21004 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
21005 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
21006 osp.$mdtosc_proc1.prealloc_last_id)
21007 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
21008 osp.$mdtosc_proc1.prealloc_next_id)
21012 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
21013 #define OBD_FAIL_OST_ENOINO 0x229
21014 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
21015 create_pool $FSNAME.$TESTNAME || return 1
21016 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
21018 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
21020 MDSOBJS=$((last_id - next_id))
21021 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
21023 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
21024 echo "OST still has $count kbytes free"
21026 echo "create $MDSOBJS files @next_id..."
21027 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
21029 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
21030 osp.$mdtosc_proc1.prealloc_last_id)
21031 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
21032 osp.$mdtosc_proc1.prealloc_next_id)
21034 echo "after creation, last_id=$last_id2, next_id=$next_id2"
21039 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
21040 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
21042 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
21043 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
21044 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
21045 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
21046 echo "unlink $MDSOBJS files @$next_id..."
21047 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
21049 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
21052 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21054 dd if=`which date` of=$MOUNT/date oflag=sync
21055 chmod +x $MOUNT/date
21057 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
21058 $LCTL set_param fail_loc=0x80001401
21060 $MOUNT/date > /dev/null
21063 run_test 221 "make sure fault and truncate race to not cause OOM"
21066 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21069 test_mkdir $DIR/$tdir
21070 $LFS setstripe -c 1 -i 0 $DIR/$tdir
21071 createmany -o $DIR/$tdir/$tfile 10
21072 cancel_lru_locks mdc
21073 cancel_lru_locks osc
21074 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
21075 $LCTL set_param fail_loc=0x31a
21076 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
21077 $LCTL set_param fail_loc=0
21080 run_test 222a "AGL for ls should not trigger CLIO lock failure"
21083 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21086 test_mkdir $DIR/$tdir
21087 $LFS setstripe -c 1 -i 0 $DIR/$tdir
21088 createmany -o $DIR/$tdir/$tfile 10
21089 cancel_lru_locks mdc
21090 cancel_lru_locks osc
21091 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
21092 $LCTL set_param fail_loc=0x31a
21093 rm -r $DIR/$tdir || error "AGL for rmdir failed"
21094 $LCTL set_param fail_loc=0
21096 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
21099 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21102 test_mkdir $DIR/$tdir
21103 $LFS setstripe -c 1 -i 0 $DIR/$tdir
21104 createmany -o $DIR/$tdir/$tfile 10
21105 cancel_lru_locks mdc
21106 cancel_lru_locks osc
21107 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
21108 $LCTL set_param fail_loc=0x31b
21109 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
21110 $LCTL set_param fail_loc=0
21113 run_test 223 "osc reenqueue if without AGL lock granted ======================="
21115 test_224a() { # LU-1039, MRP-303
21116 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21117 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
21118 $LCTL set_param fail_loc=0x508
21119 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fsync
21120 $LCTL set_param fail_loc=0
21123 run_test 224a "Don't panic on bulk IO failure"
21125 test_224bd_sub() { # LU-1039, MRP-303
21126 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21130 dd if=/dev/urandom of=$TMP/$tfile bs=1M count=1
21132 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21134 dd if=$TMP/$tfile of=$DIR/$tfile bs=1M count=1
21135 cancel_lru_locks osc
21137 stack_trap "set_checksums $ORIG_CSUM" EXIT
21138 local at_max_saved=0
21140 # adaptive timeouts may prevent seeing the issue
21141 if at_is_enabled; then
21142 at_max_saved=$(at_max_get mds)
21143 at_max_set 0 mds client
21144 stack_trap "at_max_set $at_max_saved mds client" EXIT
21147 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
21148 do_facet ost1 $LCTL set_param fail_val=$timeout fail_loc=0x80000515
21149 dd of=$TMP/$tfile.new if=$DIR/$tfile bs=1M count=1 || "$@"
21151 do_facet ost1 $LCTL set_param fail_loc=0
21152 cmp $TMP/$tfile $TMP/$tfile.new || error "file contents wrong"
21157 test_224bd_sub 3 error "dd failed"
21159 run_test 224b "Don't panic on bulk IO failure"
21161 test_224c() { # LU-6441
21162 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21163 remote_mds_nodsh && skip "remote MDS with nodsh"
21165 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
21166 save_writethrough $p
21167 set_cache writethrough on
21169 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
21170 local at_max=$($LCTL get_param -n at_max)
21171 local timeout=$($LCTL get_param -n timeout)
21172 local test_at="at_max"
21173 local param_at="$FSNAME.sys.at_max"
21174 local test_timeout="timeout"
21175 local param_timeout="$FSNAME.sys.timeout"
21177 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
21179 set_persistent_param_and_check client "$test_at" "$param_at" 0
21180 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
21182 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
21183 do_facet ost1 "$LCTL set_param fail_loc=0x520"
21184 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21185 stack_trap "rm -f $DIR/$tfile"
21186 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
21188 do_facet ost1 "$LCTL set_param fail_loc=0"
21190 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
21191 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
21194 $LCTL set_param -n $pages_per_rpc
21195 restore_lustre_params < $p
21198 run_test 224c "Don't hang if one of md lost during large bulk RPC"
21200 test_224d() { # LU-11169
21201 test_224bd_sub $((TIMEOUT + 2)) error "dd failed"
21203 run_test 224d "Don't corrupt data on bulk IO timeout"
21205 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
21207 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21208 if [ -z ${MDSSURVEY} ]; then
21209 skip_env "mds-survey not found"
21211 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
21212 skip "Need MDS version at least 2.2.51"
21214 local mds=$(facet_host $SINGLEMDS)
21215 local target=$(do_nodes $mds 'lctl dl' |
21216 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
21218 local cmd1="file_count=1000 thrhi=4"
21219 local cmd2="dir_count=2 layer=mdd stripe_count=0"
21220 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
21221 local cmd="$cmd1 $cmd2 $cmd3"
21223 rm -f ${TMP}/mds_survey*
21225 eval $cmd || error "mds-survey with zero-stripe failed"
21226 cat ${TMP}/mds_survey*
21227 rm -f ${TMP}/mds_survey*
21229 run_test 225a "Metadata survey sanity with zero-stripe"
21232 if [ -z ${MDSSURVEY} ]; then
21233 skip_env "mds-survey not found"
21235 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
21236 skip "Need MDS version at least 2.2.51"
21237 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21238 remote_mds_nodsh && skip "remote MDS with nodsh"
21239 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
21240 skip_env "Need to mount OST to test"
21243 local mds=$(facet_host $SINGLEMDS)
21244 local target=$(do_nodes $mds 'lctl dl' |
21245 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
21247 local cmd1="file_count=1000 thrhi=4"
21248 local cmd2="dir_count=2 layer=mdd stripe_count=1"
21249 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
21250 local cmd="$cmd1 $cmd2 $cmd3"
21252 rm -f ${TMP}/mds_survey*
21254 eval $cmd || error "mds-survey with stripe_count failed"
21255 cat ${TMP}/mds_survey*
21256 rm -f ${TMP}/mds_survey*
21258 run_test 225b "Metadata survey sanity with stripe_count = 1"
21260 mcreate_path2fid () {
21266 local path=$DIR/$tdir/$name
21271 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
21272 error "cannot create $desc"
21274 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
21276 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
21278 fid_path=$($LFS fid2path $MOUNT $fid)
21280 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
21282 [ "$path" == "$fid_path" ] ||
21283 error "fid2path returned $fid_path, expected $path"
21285 echo "pass with $path and $fid"
21290 mkdir -p $DIR/$tdir
21292 mcreate_path2fid 0010666 0 0 fifo "FIFO"
21293 mcreate_path2fid 0020666 1 3 null "character special file (null)"
21294 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
21295 mcreate_path2fid 0040666 0 0 dir "directory"
21296 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
21297 mcreate_path2fid 0100666 0 0 file "regular file"
21298 mcreate_path2fid 0120666 0 0 link "symbolic link"
21299 mcreate_path2fid 0140666 0 0 sock "socket"
21301 run_test 226a "call path2fid and fid2path on files of all type"
21304 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21309 mkdir -p $DIR/$tdir
21310 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
21311 error "create remote directory failed"
21312 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
21313 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
21314 "character special file (null)"
21315 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
21316 "character special file (no device)"
21317 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
21318 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
21319 "block special file (loop)"
21320 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
21321 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
21322 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
21324 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
21327 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21328 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
21329 skip "Need MDS version at least 2.13.55"
21331 local submnt=/mnt/submnt
21332 local srcfile=/etc/passwd
21333 local dstfile=$submnt/passwd
21339 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
21340 error "create remote directory failed"
21341 mkdir -p $submnt || error "create $submnt failed"
21342 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
21343 error "mount $submnt failed"
21344 stack_trap "umount $submnt" EXIT
21346 cp $srcfile $dstfile
21347 fid=$($LFS path2fid $dstfile)
21348 path=$($LFS fid2path $submnt "$fid")
21349 [ "$path" = "$dstfile" ] ||
21350 error "fid2path $submnt $fid failed ($path != $dstfile)"
21352 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
21355 (( $CLIENT_VERSION >= $(version_code 2.15.57) )) ||
21356 skip "Need client at least version 2.15.57"
21358 # Define First test dataset
21359 local testdirs_01=$DIR/$tdir
21360 local testdata_01=$testdirs_01/${tdir}_01
21361 local testresult_01=${tdir}_01
21362 # Define Second test dataset
21363 local testdirs_02=$DIR/$tdir/$tdir
21364 local testdata_02=$testdirs_02/${tdir}_02
21365 local testresult_02=${tdir}_02
21366 # Define third test dataset (top level)
21367 local testdata_03=$DIR/${tdir}_03
21368 local testresult_03=${tdir}_03
21370 # Create first test dataset
21371 mkdir -p $testdirs_01 || error "cannot create dir $testdirs_01"
21372 touch $testdata_01 || error "cannot create file $testdata_01"
21374 # Create second test dataset
21375 mkdir -p $testdirs_02 || error "cannot create dir $testdirs_02"
21376 touch $testdata_02 || error "cannot create file $testdata_02"
21378 # Create third test dataset
21379 touch $testdata_03 || error "cannot create file $testdata_03"
21381 local fid01=$($LFS getstripe -F "$testdata_01") ||
21382 error "getstripe failed on $testdata_01"
21383 local fid02=$($LFS getstripe -F "$testdata_02") ||
21384 error "getstripe failed on $testdata_01"
21385 local fid03=$($LFS getstripe -F "$testdata_03") ||
21386 error "getstripe failed on $testdata_03"
21388 # Verify only -n option
21389 local out1=$($LFS fid2path -n $DIR $fid01) ||
21390 error "fid2path failed on $fid01"
21391 local out2=$($LFS fid2path -n $DIR $fid02) ||
21392 error "fid2path failed on $fid02"
21393 local out3=$($LFS fid2path -n $DIR $fid03) ||
21394 error "fid2path failed on $fid03"
21396 [[ "$out1" == "$testresult_01" ]] ||
21397 error "fid2path failed: Expected $testresult_01 got $out1"
21398 [[ "$out2" == "$testresult_02" ]] ||
21399 error "fid2path failed: Expected $testresult_02 got $out2"
21400 [[ "$out3" == "$testresult_03" ]] ||
21401 error "fid2path failed: Expected $testresult_03 got $out3"
21403 # Verify with option -fn together
21404 out1=$($LFS fid2path -fn $DIR $fid01) ||
21405 error "fid2path -fn failed on $fid01"
21406 out2=$($LFS fid2path -fn $DIR $fid02) ||
21407 error "fid2path -fn failed on $fid02"
21408 out3=$($LFS fid2path -fn $DIR $fid03) ||
21409 error "fid2path -fn failed on $fid03"
21411 local tmpout=$(echo $out1 | cut -d" " -f2)
21412 [[ "$tmpout" == "$testresult_01" ]] ||
21413 error "fid2path -fn failed: Expected $testresult_01 got $out1"
21415 tmpout=$(echo $out2 | cut -d" " -f2)
21416 [[ "$tmpout" == "$testresult_02" ]] ||
21417 error "fid2path -fn failed: Expected $testresult_02 got $out2"
21419 tmpout=$(echo $out3 | cut -d" " -f2)
21420 [[ "$tmpout" == "$testresult_03" ]] ||
21421 error "fid2path -fn failed: Expected $testresult_03 got $out3"
21423 run_test 226d "verify fid2path with -n and -fn option"
21426 (( $CLIENT_VERSION >= $(version_code 2.15.56) )) ||
21427 skip "Need client at least version 2.15.56"
21429 # Define filename with 'newline' and a space
21430 local testfile="Test"$'\n'"file 01"
21431 # Define link name with multiple 'newline' and a space
21432 local linkfile="Link"$'\n'"file "$'\n'"01"
21433 # Remove prior hard link
21434 rm -f $DIR/"$linkfile"
21437 touch $DIR/"$testfile"
21439 ln $DIR/"$testfile" $DIR/"$linkfile"
21441 local fid=$($LFS getstripe -F "$DIR/$testfile") ||
21442 error "getstripe failed on $DIR/$testfile"
21444 # Call with -0 option
21445 local out1=$($LFS fid2path -0 $DIR $fid | xargs --null -n1 \
21446 echo "FILE:" | grep -c "FILE:")
21448 # With -0 option the output should be exactly 2 lines.
21449 (( $out1 == 2 )) || error "fid2path -0 failed on $fid, $out1"
21451 run_test 226e "Verify path2fid -0 option with newline and space"
21453 # LU-1299 Executing or running ldd on a truncated executable does not
21454 # cause an out-of-memory condition.
21456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21457 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
21459 dd if=$(which date) of=$MOUNT/date bs=1k count=1
21460 chmod +x $MOUNT/date
21462 $MOUNT/date > /dev/null
21463 ldd $MOUNT/date > /dev/null
21466 run_test 227 "running truncated executable does not cause OOM"
21468 # LU-1512 try to reuse idle OI blocks
21470 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21471 remote_mds_nodsh && skip "remote MDS with nodsh"
21472 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21474 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
21475 local myDIR=$DIR/$tdir
21478 #define OBD_FAIL_SEQ_EXHAUST 0x1002
21479 $LCTL set_param fail_loc=0x80001002
21480 createmany -o $myDIR/t- 10000
21481 $LCTL set_param fail_loc=0
21482 # The guard is current the largest FID holder
21484 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
21486 local IDX=$(($SEQ % 64))
21488 do_facet $SINGLEMDS sync
21489 # Make sure journal flushed.
21491 local blk1=$(do_facet $SINGLEMDS \
21492 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21493 grep Blockcount | awk '{print $4}')
21495 # Remove old files, some OI blocks will become idle.
21496 unlinkmany $myDIR/t- 10000
21497 # Create new files, idle OI blocks should be reused.
21498 createmany -o $myDIR/t- 2000
21499 do_facet $SINGLEMDS sync
21500 # Make sure journal flushed.
21502 local blk2=$(do_facet $SINGLEMDS \
21503 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21504 grep Blockcount | awk '{print $4}')
21506 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
21508 run_test 228a "try to reuse idle OI blocks"
21511 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21512 remote_mds_nodsh && skip "remote MDS with nodsh"
21513 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21515 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
21516 local myDIR=$DIR/$tdir
21519 #define OBD_FAIL_SEQ_EXHAUST 0x1002
21520 $LCTL set_param fail_loc=0x80001002
21521 createmany -o $myDIR/t- 10000
21522 $LCTL set_param fail_loc=0
21523 # The guard is current the largest FID holder
21525 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
21527 local IDX=$(($SEQ % 64))
21529 do_facet $SINGLEMDS sync
21530 # Make sure journal flushed.
21532 local blk1=$(do_facet $SINGLEMDS \
21533 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21534 grep Blockcount | awk '{print $4}')
21536 # Remove old files, some OI blocks will become idle.
21537 unlinkmany $myDIR/t- 10000
21540 stop $SINGLEMDS || error "Fail to stop MDT."
21542 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
21543 error "Fail to start MDT."
21545 client_up || error "Fail to df."
21546 # Create new files, idle OI blocks should be reused.
21547 createmany -o $myDIR/t- 2000
21548 do_facet $SINGLEMDS sync
21549 # Make sure journal flushed.
21551 local blk2=$(do_facet $SINGLEMDS \
21552 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21553 grep Blockcount | awk '{print $4}')
21555 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
21557 run_test 228b "idle OI blocks can be reused after MDT restart"
21561 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21562 remote_mds_nodsh && skip "remote MDS with nodsh"
21563 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21565 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
21566 local myDIR=$DIR/$tdir
21569 #define OBD_FAIL_SEQ_EXHAUST 0x1002
21570 $LCTL set_param fail_loc=0x80001002
21571 # 20000 files can guarantee there are index nodes in the OI file
21572 createmany -o $myDIR/t- 20000
21573 $LCTL set_param fail_loc=0
21574 # The guard is current the largest FID holder
21576 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
21578 local IDX=$(($SEQ % 64))
21580 do_facet $SINGLEMDS sync
21581 # Make sure journal flushed.
21583 local blk1=$(do_facet $SINGLEMDS \
21584 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21585 grep Blockcount | awk '{print $4}')
21587 # Remove old files, some OI blocks will become idle.
21588 unlinkmany $myDIR/t- 20000
21590 # The OI file should become empty now
21592 # Create new files, idle OI blocks should be reused.
21593 createmany -o $myDIR/t- 2000
21594 do_facet $SINGLEMDS sync
21595 # Make sure journal flushed.
21597 local blk2=$(do_facet $SINGLEMDS \
21598 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21599 grep Blockcount | awk '{print $4}')
21601 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
21603 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
21605 test_229() { # LU-2482, LU-3448
21606 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21607 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
21608 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
21609 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
21613 # Create a file with a released layout and stripe count 2.
21614 $MULTIOP $DIR/$tfile H2c ||
21615 error "failed to create file with released layout"
21617 $LFS getstripe -v $DIR/$tfile
21619 local pattern=$($LFS getstripe -L $DIR/$tfile)
21620 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
21622 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
21624 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
21625 stat $DIR/$tfile || error "failed to stat released file"
21627 chown $RUNAS_ID $DIR/$tfile ||
21628 error "chown $RUNAS_ID $DIR/$tfile failed"
21630 chgrp $RUNAS_ID $DIR/$tfile ||
21631 error "chgrp $RUNAS_ID $DIR/$tfile failed"
21633 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
21634 rm $DIR/$tfile || error "failed to remove released file"
21636 run_test 229 "getstripe/stat/rm/attr changes work on released files"
21639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21640 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21641 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21642 skip "Need MDS version at least 2.11.52"
21646 test_mkdir $DIR/$tdir
21647 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
21648 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
21649 [ $mdt_idx -ne 0 ] &&
21650 error "create local directory on wrong MDT $mdt_idx"
21652 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
21653 error "create remote directory failed"
21654 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
21655 [ $mdt_idx -ne $MDTIDX ] &&
21656 error "create remote directory on wrong MDT $mdt_idx"
21658 createmany -o $DIR/$tdir/test_230/t- 10 ||
21659 error "create files on remote directory failed"
21660 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
21661 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
21662 rm -r $DIR/$tdir || error "unlink remote directory failed"
21664 run_test 230a "Create remote directory and files under the remote directory"
21667 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21668 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21669 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21670 skip "Need MDS version at least 2.11.52"
21678 local migrate_dir=$DIR/$tdir/migrate_dir
21679 local other_dir=$DIR/$tdir/other_dir
21681 test_mkdir $DIR/$tdir
21682 test_mkdir -i0 -c1 $migrate_dir
21683 test_mkdir -i0 -c1 $other_dir
21684 for ((i=0; i<10; i++)); do
21685 mkdir -p $migrate_dir/dir_${i}
21686 createmany -o $migrate_dir/dir_${i}/f 10 ||
21687 error "create files under remote dir failed $i"
21690 cp /etc/passwd $migrate_dir/$tfile
21691 cp /etc/passwd $other_dir/$tfile
21692 chattr +SAD $migrate_dir
21693 chattr +SAD $migrate_dir/$tfile
21695 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
21696 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
21697 local old_dir_mode=$(stat -c%f $migrate_dir)
21698 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
21700 mkdir -p $migrate_dir/dir_default_stripe2
21701 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
21702 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
21704 mkdir -p $other_dir
21705 ln $migrate_dir/$tfile $other_dir/luna
21706 ln $migrate_dir/$tfile $migrate_dir/sofia
21707 ln $other_dir/$tfile $migrate_dir/david
21708 ln -s $migrate_dir/$tfile $other_dir/zachary
21709 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
21710 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
21716 for len in 58 59 60; do
21717 lnktgt=$(str_repeat 'l' $len)
21718 touch $migrate_dir/$lnktgt
21719 ln -s $lnktgt $migrate_dir/${len}char_ln
21723 for len in 4094 4095; do
21724 lnktgt=$(str_repeat 'l' $len)
21725 ln -s $lnktgt $migrate_dir/${len}char_ln
21729 for len in 254 255; do
21730 touch $migrate_dir/$(str_repeat 'l' $len)
21733 $LFS migrate -m $MDTIDX $migrate_dir ||
21734 error "fails on migrating remote dir to MDT1"
21736 echo "migratate to MDT1, then checking.."
21737 for ((i = 0; i < 10; i++)); do
21738 for file in $(find $migrate_dir/dir_${i}); do
21739 mdt_index=$($LFS getstripe -m $file)
21740 # broken symlink getstripe will fail
21741 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
21742 error "$file is not on MDT${MDTIDX}"
21746 # the multiple link file should still in MDT0
21747 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
21748 [ $mdt_index == 0 ] ||
21749 error "$file is not on MDT${MDTIDX}"
21751 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
21752 [ "$old_dir_flag" = "$new_dir_flag" ] ||
21753 error " expect $old_dir_flag get $new_dir_flag"
21755 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
21756 [ "$old_file_flag" = "$new_file_flag" ] ||
21757 error " expect $old_file_flag get $new_file_flag"
21759 local new_dir_mode=$(stat -c%f $migrate_dir)
21760 [ "$old_dir_mode" = "$new_dir_mode" ] ||
21761 error "expect mode $old_dir_mode get $new_dir_mode"
21763 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
21764 [ "$old_file_mode" = "$new_file_mode" ] ||
21765 error "expect mode $old_file_mode get $new_file_mode"
21767 diff /etc/passwd $migrate_dir/$tfile ||
21768 error "$tfile different after migration"
21770 diff /etc/passwd $other_dir/luna ||
21771 error "luna different after migration"
21773 diff /etc/passwd $migrate_dir/sofia ||
21774 error "sofia different after migration"
21776 diff /etc/passwd $migrate_dir/david ||
21777 error "david different after migration"
21779 diff /etc/passwd $other_dir/zachary ||
21780 error "zachary different after migration"
21782 diff /etc/passwd $migrate_dir/${tfile}_ln ||
21783 error "${tfile}_ln different after migration"
21785 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
21786 error "${tfile}_ln_other different after migration"
21788 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
21789 [ $stripe_count = 2 ] ||
21790 error "dir strpe_count $d != 2 after migration."
21792 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
21793 [ $stripe_count = 2 ] ||
21794 error "file strpe_count $d != 2 after migration."
21796 #migrate back to MDT0
21799 $LFS migrate -m $MDTIDX $migrate_dir ||
21800 error "fails on migrating remote dir to MDT0"
21802 echo "migrate back to MDT0, checking.."
21803 for file in $(find $migrate_dir); do
21804 mdt_index=$($LFS getstripe -m $file)
21805 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
21806 error "$file is not on MDT${MDTIDX}"
21809 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
21810 [ "$old_dir_flag" = "$new_dir_flag" ] ||
21811 error " expect $old_dir_flag get $new_dir_flag"
21813 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
21814 [ "$old_file_flag" = "$new_file_flag" ] ||
21815 error " expect $old_file_flag get $new_file_flag"
21817 local new_dir_mode=$(stat -c%f $migrate_dir)
21818 [ "$old_dir_mode" = "$new_dir_mode" ] ||
21819 error "expect mode $old_dir_mode get $new_dir_mode"
21821 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
21822 [ "$old_file_mode" = "$new_file_mode" ] ||
21823 error "expect mode $old_file_mode get $new_file_mode"
21825 diff /etc/passwd ${migrate_dir}/$tfile ||
21826 error "$tfile different after migration"
21828 diff /etc/passwd ${other_dir}/luna ||
21829 error "luna different after migration"
21831 diff /etc/passwd ${migrate_dir}/sofia ||
21832 error "sofia different after migration"
21834 diff /etc/passwd ${other_dir}/zachary ||
21835 error "zachary different after migration"
21837 diff /etc/passwd $migrate_dir/${tfile}_ln ||
21838 error "${tfile}_ln different after migration"
21840 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
21841 error "${tfile}_ln_other different after migration"
21843 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
21844 [ $stripe_count = 2 ] ||
21845 error "dir strpe_count $d != 2 after migration."
21847 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
21848 [ $stripe_count = 2 ] ||
21849 error "file strpe_count $d != 2 after migration."
21851 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21853 run_test 230b "migrate directory"
21856 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21857 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21858 remote_mds_nodsh && skip "remote MDS with nodsh"
21859 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21860 skip "Need MDS version at least 2.11.52"
21866 local migrate_dir=$DIR/$tdir/migrate_dir
21868 #If migrating directory fails in the middle, all entries of
21869 #the directory is still accessiable.
21870 test_mkdir $DIR/$tdir
21871 test_mkdir -i0 -c1 $migrate_dir
21872 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
21874 createmany -o $migrate_dir/f $total ||
21875 error "create files under ${migrate_dir} failed"
21877 # fail after migrating top dir, and this will fail only once, so the
21878 # first sub file migration will fail (currently f3), others succeed.
21879 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
21880 do_facet mds1 lctl set_param fail_loc=0x1801
21881 local t=$(ls $migrate_dir | wc -l)
21882 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
21883 error "migrate should fail"
21884 local u=$(ls $migrate_dir | wc -l)
21885 [ "$u" == "$t" ] || error "$u != $t during migration"
21887 # add new dir/file should succeed
21888 mkdir $migrate_dir/dir ||
21889 error "mkdir failed under migrating directory"
21890 touch $migrate_dir/file ||
21891 error "create file failed under migrating directory"
21893 # add file with existing name should fail
21894 for file in $migrate_dir/f*; do
21895 stat $file > /dev/null || error "stat $file failed"
21896 $OPENFILE -f O_CREAT:O_EXCL $file &&
21897 error "open(O_CREAT|O_EXCL) $file should fail"
21898 $MULTIOP $file m && error "create $file should fail"
21899 touch $DIR/$tdir/remote_dir/$tfile ||
21900 error "touch $tfile failed"
21901 ln $DIR/$tdir/remote_dir/$tfile $file &&
21902 error "link $file should fail"
21903 mdt_index=$($LFS getstripe -m $file)
21904 if [ $mdt_index == 0 ]; then
21905 # file failed to migrate is not allowed to rename to
21906 mv $DIR/$tdir/remote_dir/$tfile $file &&
21907 error "rename to $file should fail"
21909 mv $DIR/$tdir/remote_dir/$tfile $file ||
21910 error "rename to $file failed"
21912 echo hello >> $file || error "write $file failed"
21915 # resume migration with different options should fail
21916 $LFS migrate -m 0 $migrate_dir &&
21917 error "migrate -m 0 $migrate_dir should fail"
21919 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
21920 error "migrate -c 2 $migrate_dir should fail"
21922 # resume migration should succeed
21923 $LFS migrate -m $MDTIDX $migrate_dir ||
21924 error "migrate $migrate_dir failed"
21926 echo "Finish migration, then checking.."
21927 for file in $(find $migrate_dir); do
21928 mdt_index=$($LFS getstripe -m $file)
21929 [ $mdt_index == $MDTIDX ] ||
21930 error "$file is not on MDT${MDTIDX}"
21933 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21935 run_test 230c "check directory accessiblity if migration failed"
21938 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21939 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21940 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21941 skip "Need MDS version at least 2.11.52"
21943 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
21945 local migrate_dir=$DIR/$tdir/migrate_dir
21955 old_index=$((RANDOM % MDSCOUNT))
21956 old_count=$((MDSCOUNT - old_index))
21957 new_index=$((RANDOM % MDSCOUNT))
21958 new_count=$((MDSCOUNT - new_index))
21959 new_hash=1 # for all_char
21961 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
21962 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
21964 test_mkdir $DIR/$tdir
21965 test_mkdir -i $old_index -c $old_count $migrate_dir
21967 for ((i=0; i<100; i++)); do
21968 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
21969 createmany -o $migrate_dir/dir_${i}/f 100 ||
21970 error "create files under remote dir failed $i"
21973 echo -n "Migrate from MDT$old_index "
21974 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
21975 echo -n "to MDT$new_index"
21976 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
21979 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
21980 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
21981 error "migrate remote dir error"
21983 echo "Finish migration, then checking.."
21984 for file in $(find $migrate_dir -maxdepth 1); do
21985 mdt_index=$($LFS getstripe -m $file)
21986 if [ $mdt_index -lt $new_index ] ||
21987 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
21988 error "$file is on MDT$mdt_index"
21992 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21994 run_test 230d "check migrate big directory"
21997 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21998 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21999 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22000 skip "Need MDS version at least 2.11.52"
22007 mkdir_on_mdt0 $DIR/$tdir
22008 mkdir $DIR/$tdir/migrate_dir
22009 mkdir $DIR/$tdir/other_dir
22010 touch $DIR/$tdir/migrate_dir/a
22011 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
22012 ls $DIR/$tdir/other_dir
22014 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
22015 error "migrate dir fails"
22017 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
22018 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
22020 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
22021 [ $mdt_index == 0 ] || error "a is not on MDT0"
22023 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
22024 error "migrate dir fails"
22026 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
22027 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
22029 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
22030 [ $mdt_index == 1 ] || error "a is not on MDT1"
22032 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
22033 [ $mdt_index == 1 ] || error "b is not on MDT1"
22035 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
22036 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
22038 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
22040 rm -rf $DIR/$tdir || error "rm dir failed after migration"
22042 run_test 230e "migrate mulitple local link files"
22045 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22046 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22047 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22048 skip "Need MDS version at least 2.11.52"
22053 mkdir -p $DIR/$tdir
22054 mkdir $DIR/$tdir/migrate_dir
22055 $LFS mkdir -i1 $DIR/$tdir/other_dir
22056 touch $DIR/$tdir/migrate_dir/a
22057 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
22058 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
22059 ls $DIR/$tdir/other_dir
22061 # a should be migrated to MDT1, since no other links on MDT0
22062 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
22063 error "#1 migrate dir fails"
22064 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
22065 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
22066 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
22067 [ $mdt_index == 1 ] || error "a is not on MDT1"
22069 # a should stay on MDT1, because it is a mulitple link file
22070 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
22071 error "#2 migrate dir fails"
22072 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
22073 [ $mdt_index == 1 ] || error "a is not on MDT1"
22075 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
22076 error "#3 migrate dir fails"
22078 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
22079 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
22080 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
22082 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
22083 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
22085 # a should be migrated to MDT0, since no other links on MDT1
22086 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
22087 error "#4 migrate dir fails"
22088 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
22089 [ $mdt_index == 0 ] || error "a is not on MDT0"
22091 rm -rf $DIR/$tdir || error "rm dir failed after migration"
22093 run_test 230f "migrate mulitple remote link files"
22096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22097 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22098 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22099 skip "Need MDS version at least 2.11.52"
22101 mkdir -p $DIR/$tdir/migrate_dir
22103 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
22104 error "migrating dir to non-exist MDT succeeds"
22107 run_test 230g "migrate dir to non-exist MDT"
22110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22111 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22112 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22113 skip "Need MDS version at least 2.11.52"
22117 mkdir -p $DIR/$tdir/migrate_dir
22119 $LFS migrate -m1 $DIR &&
22120 error "migrating mountpoint1 should fail"
22122 $LFS migrate -m1 $DIR/$tdir/.. &&
22123 error "migrating mountpoint2 should fail"
22126 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
22127 error "migrating $tdir/migrate_dir/.. should fail"
22131 run_test 230h "migrate .. and root"
22134 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22135 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22136 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22137 skip "Need MDS version at least 2.11.52"
22139 mkdir -p $DIR/$tdir/migrate_dir
22141 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
22142 error "migration fails with a tailing slash"
22144 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
22145 error "migration fails with two tailing slashes"
22147 run_test 230i "lfs migrate -m tolerates trailing slashes"
22150 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22151 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
22152 skip "Need MDS version at least 2.11.52"
22154 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
22155 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
22156 error "create $tfile failed"
22157 cat /etc/passwd > $DIR/$tdir/$tfile
22159 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
22161 cmp /etc/passwd $DIR/$tdir/$tfile ||
22162 error "DoM file mismatch after migration"
22164 run_test 230j "DoM file data not changed after dir migration"
22167 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
22168 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22169 skip "Need MDS version at least 2.11.56"
22172 local files_on_starting_mdt=0
22174 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
22175 $LFS getdirstripe $DIR/$tdir
22176 for i in $(seq $total); do
22177 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
22178 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
22179 files_on_starting_mdt=$((files_on_starting_mdt + 1))
22182 echo "$files_on_starting_mdt files on MDT0"
22184 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
22185 $LFS getdirstripe $DIR/$tdir
22187 files_on_starting_mdt=0
22188 for i in $(seq $total); do
22189 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
22190 error "file $tfile.$i mismatch after migration"
22191 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
22192 files_on_starting_mdt=$((files_on_starting_mdt + 1))
22195 echo "$files_on_starting_mdt files on MDT1 after migration"
22196 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
22198 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
22199 $LFS getdirstripe $DIR/$tdir
22201 files_on_starting_mdt=0
22202 for i in $(seq $total); do
22203 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
22204 error "file $tfile.$i mismatch after 2nd migration"
22205 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
22206 files_on_starting_mdt=$((files_on_starting_mdt + 1))
22209 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
22210 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
22214 run_test 230k "file data not changed after dir migration"
22217 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22218 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22219 skip "Need MDS version at least 2.11.56"
22221 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
22222 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
22223 error "create files under remote dir failed $i"
22224 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
22226 run_test 230l "readdir between MDTs won't crash"
22229 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22230 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22231 skip "Need MDS version at least 2.11.56"
22234 local mig_dir=$DIR/$tdir/migrate_dir
22235 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
22239 echo "Creating files and dirs with xattrs"
22240 test_mkdir $DIR/$tdir
22241 test_mkdir -i0 -c1 $mig_dir
22243 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
22244 error "cannot set xattr attr1 on dir"
22245 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
22246 error "cannot set xattr attr2 on dir"
22247 touch $mig_dir/dir/f0
22248 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
22249 error "cannot set xattr attr1 on file"
22250 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
22251 error "cannot set xattr attr2 on file"
22252 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
22253 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
22254 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
22255 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
22256 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
22257 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
22258 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
22259 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
22260 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
22262 echo "Migrating to MDT1"
22263 $LFS migrate -m $MDTIDX $mig_dir ||
22264 error "fails on migrating dir to MDT1"
22266 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
22267 echo "Checking xattrs"
22268 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
22269 [ "$val" = $longstr ] ||
22270 error "expecting xattr1 $longstr on dir, found $val"
22271 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
22272 [ "$val" = $shortstr ] ||
22273 error "expecting xattr2 $shortstr on dir, found $val"
22274 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
22275 [ "$val" = $longstr ] ||
22276 error "expecting xattr1 $longstr on file, found $val"
22277 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
22278 [ "$val" = $shortstr ] ||
22279 error "expecting xattr2 $shortstr on file, found $val"
22281 run_test 230m "xattrs not changed after dir migration"
22284 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22285 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
22286 skip "Need MDS version at least 2.13.53"
22288 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
22289 cat /etc/hosts > $DIR/$tdir/$tfile
22290 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
22291 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
22293 cmp /etc/hosts $DIR/$tdir/$tfile ||
22294 error "File data mismatch after migration"
22296 run_test 230n "Dir migration with mirrored file"
22299 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
22300 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
22301 skip "Need MDS version at least 2.13.52"
22303 local mdts=$(comma_list $(mdts_nodes))
22305 local restripe_status
22309 [[ $mds1_FSTYPE == zfs ]] && timeout=300
22311 # in case "crush" hash type is not set
22312 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
22314 restripe_status=$(do_facet mds1 $LCTL get_param -n \
22315 mdt.*MDT0000.enable_dir_restripe)
22316 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
22317 stack_trap "do_nodes $mdts $LCTL set_param \
22318 mdt.*.enable_dir_restripe=$restripe_status"
22321 createmany -m $DIR/$tdir/f 100 ||
22322 error "create files under remote dir failed $i"
22323 createmany -d $DIR/$tdir/d 100 ||
22324 error "create dirs under remote dir failed $i"
22326 for i in $(seq 2 $MDSCOUNT); do
22327 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
22328 $LFS setdirstripe -c $i $DIR/$tdir ||
22329 error "split -c $i $tdir failed"
22330 wait_update $HOSTNAME \
22331 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
22332 error "dir split not finished"
22333 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
22334 awk '/migrate/ {sum += $2} END { print sum }')
22335 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
22336 # delta is around total_files/stripe_count
22337 (( $delta < 200 / (i - 1) + 4 )) ||
22338 error "$delta files migrated >= $((200 / (i - 1) + 4))"
22341 run_test 230o "dir split"
22344 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22345 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
22346 skip "Need MDS version at least 2.13.52"
22348 local mdts=$(comma_list $(mdts_nodes))
22350 local restripe_status
22354 [[ $mds1_FSTYPE == zfs ]] && timeout=300
22356 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
22358 restripe_status=$(do_facet mds1 $LCTL get_param -n \
22359 mdt.*MDT0000.enable_dir_restripe)
22360 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
22361 stack_trap "do_nodes $mdts $LCTL set_param \
22362 mdt.*.enable_dir_restripe=$restripe_status"
22364 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
22365 createmany -m $DIR/$tdir/f 100 ||
22366 error "create files under remote dir failed"
22367 createmany -d $DIR/$tdir/d 100 ||
22368 error "create dirs under remote dir failed"
22370 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
22371 local mdt_hash="crush"
22373 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
22374 $LFS setdirstripe -c $c $DIR/$tdir ||
22375 error "split -c $c $tdir failed"
22376 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
22377 mdt_hash="$mdt_hash,fixed"
22378 elif [ $c -eq 1 ]; then
22381 wait_update $HOSTNAME \
22382 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
22383 error "dir merge not finished"
22384 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
22385 awk '/migrate/ {sum += $2} END { print sum }')
22386 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
22387 # delta is around total_files/stripe_count
22388 (( delta < 200 / c + 4 )) ||
22389 error "$delta files migrated >= $((200 / c + 4))"
22392 run_test 230p "dir merge"
22395 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
22396 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
22397 skip "Need MDS version at least 2.13.52"
22399 local mdts=$(comma_list $(mdts_nodes))
22400 local saved_threshold=$(do_facet mds1 \
22401 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
22402 local saved_delta=$(do_facet mds1 \
22403 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
22404 local threshold=100
22407 local stripe_count=0
22412 # test with fewer files on ZFS
22413 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
22415 stack_trap "do_nodes $mdts $LCTL set_param \
22416 mdt.*.dir_split_count=$saved_threshold"
22417 stack_trap "do_nodes $mdts $LCTL set_param \
22418 mdt.*.dir_split_delta=$saved_delta"
22419 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
22420 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
22421 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
22422 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
22423 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
22424 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
22426 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
22427 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
22429 create=$((threshold * 3 / 2))
22430 while [ $stripe_count -lt $MDSCOUNT ]; do
22431 createmany -m $DIR/$tdir/f $total $create ||
22432 error "create sub files failed"
22433 stat $DIR/$tdir > /dev/null
22434 total=$((total + create))
22435 stripe_count=$((stripe_count + delta))
22436 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
22438 wait_update $HOSTNAME \
22439 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
22440 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
22442 wait_update $HOSTNAME \
22443 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
22444 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
22446 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
22447 echo "$nr_files/$total files on MDT$stripe_index after split"
22448 # allow 10% margin of imbalance with crush hash
22449 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
22450 error "$nr_files files on MDT$stripe_index after split"
22452 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
22453 [ $nr_files -eq $total ] ||
22454 error "total sub files $nr_files != $total"
22457 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
22459 echo "fixed layout directory won't auto split"
22460 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
22461 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
22462 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
22463 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
22464 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
22466 run_test 230q "dir auto split"
22469 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
22470 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
22471 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
22472 skip "Need MDS version at least 2.13.54"
22474 # maximum amount of local locks:
22475 # parent striped dir - 2 locks
22476 # new stripe in parent to migrate to - 1 lock
22477 # source and target - 2 locks
22478 # Total 5 locks for regular file
22479 mkdir -p $DIR/$tdir
22480 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
22481 touch $DIR/$tdir/dir1/eee
22483 # create 4 hardlink for 4 more locks
22484 # Total: 9 locks > RS_MAX_LOCKS (8)
22485 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
22486 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
22487 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
22488 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
22489 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
22490 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
22491 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
22492 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
22494 cancel_lru_locks mdc
22496 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
22497 error "migrate dir fails"
22499 rm -rf $DIR/$tdir || error "rm dir failed after migration"
22501 run_test 230r "migrate with too many local locks"
22504 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
22505 skip "Need MDS version at least 2.14.52"
22507 local mdts=$(comma_list $(mdts_nodes))
22508 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
22509 mdt.*MDT0000.enable_dir_restripe)
22511 stack_trap "do_nodes $mdts $LCTL set_param \
22512 mdt.*.enable_dir_restripe=$restripe_status"
22516 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
22517 test_mkdir $DIR/$tdir
22518 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
22519 error "$LFS mkdir should return EEXIST if target exists"
22523 run_test 230s "lfs mkdir should return -EEXIST if target exists"
22527 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
22528 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
22529 skip "Need MDS version at least 2.14.50"
22531 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
22532 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
22533 $LFS project -p 1 -s $DIR/$tdir ||
22534 error "set $tdir project id failed"
22535 $LFS project -p 2 -s $DIR/$tdir/subdir ||
22536 error "set subdir project id failed"
22537 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
22539 run_test 230t "migrate directory with project ID set"
22543 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
22544 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
22545 skip "Need MDS version at least 2.14.53"
22549 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
22550 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
22551 $LFS migrate -m -1 $DIR/$tdir/sub{0..99} || error "migrate sub failed"
22552 for i in $(seq 0 $((MDSCOUNT - 1))); do
22553 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
22554 echo "$count dirs migrated to MDT$i"
22556 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
22557 (( count >= MDSCOUNT - 1 )) || error "dirs migrated to $count MDTs"
22559 run_test 230u "migrate directory by QOS"
22563 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
22564 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
22565 skip "Need MDS version at least 2.14.53"
22569 mkdir $DIR/$tdir || error "mkdir $tdir failed"
22570 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
22571 $LFS migrate -m 0,2,1 $DIR/$tdir || error "migrate $tdir failed"
22572 for i in $(seq 0 $((MDSCOUNT - 1))); do
22573 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
22574 echo "$count subdirs migrated to MDT$i"
22575 (( i == 3 )) && (( count > 0 )) &&
22576 error "subdir shouldn't be migrated to MDT3"
22578 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
22579 (( count == 3 )) || error "dirs migrated to $count MDTs"
22581 run_test 230v "subdir migrated to the MDT where its parent is located"
22584 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22585 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
22586 skip "Need MDS version at least 2.15.0"
22588 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
22589 createmany -o $DIR/$tdir/f 10 || error "create files failed"
22590 createmany -d $DIR/$tdir/d 10 || error "create dirs failed"
22592 $LFS migrate -m 1 -c $MDSCOUNT -d $DIR/$tdir ||
22593 error "migrate failed"
22595 (( $($LFS getdirstripe -c $DIR/$tdir) == MDSCOUNT )) ||
22596 error "$tdir stripe count mismatch"
22598 for i in $(seq 0 9); do
22599 (( $($LFS getdirstripe -c $DIR/$tdir/d$i) == 0 )) ||
22600 error "d$i is striped"
22603 run_test 230w "non-recursive mode dir migration"
22606 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22607 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
22608 skip "Need MDS version at least 2.15.0"
22610 mkdir -p $DIR/$tdir || error "mkdir failed"
22611 createmany -d $DIR/$tdir/sub 100 || error "createmany failed"
22613 local mdt_name=$(mdtname_from_index 0)
22614 local low=$(do_facet mds2 $LCTL get_param -n \
22615 osp.*$mdt_name-osp-MDT0001.reserved_ino_low)
22616 local high=$(do_facet mds2 $LCTL get_param -n \
22617 osp.*$mdt_name-osp-MDT0001.reserved_ino_high)
22618 local ffree=$($LFS df -i $MOUNT | awk "/$mdt_name/ { print \$4 }")
22619 local maxage=$(do_facet mds2 $LCTL get_param -n \
22620 osp.*$mdt_name-osp-MDT0001.maxage)
22622 stack_trap "do_facet mds2 $LCTL set_param -n \
22623 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low \
22624 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high" EXIT
22625 stack_trap "do_facet mds2 $LCTL set_param -n \
22626 osp.*$mdt_name-osp-MDT0001.maxage=$maxage" EXIT
22628 do_facet mds2 $LCTL set_param -n \
22629 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$((ffree + 1))
22630 do_facet mds2 $LCTL set_param -n osp.*$mdt_name-osp-MDT0001.maxage=1
22632 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir &&
22633 error "migrate $tdir should fail"
22635 do_facet mds2 $LCTL set_param -n \
22636 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low
22637 do_facet mds2 $LCTL set_param -n \
22638 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high
22640 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir ||
22641 error "migrate failed"
22642 (( $($LFS getdirstripe -c $DIR/$tdir) == $MDSCOUNT )) ||
22643 error "$tdir stripe count mismatch"
22645 run_test 230x "dir migration check space"
22648 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22649 (( MDS1_VERSION >= $(version_code 2.15.55.45) )) ||
22650 skip "Need MDS version at least 2.15.55.45"
22654 test_mkdir -c -1 $DIR/$tdir || error "mkdir $tdir failed"
22655 $LFS getdirstripe $DIR/$tdir
22656 createmany -d $DIR/$tdir/d 100 || error "createmany failed"
22657 $LFS migrate -m 1 -c 2 $DIR/$tdir &
22661 #OBD_FAIL_MIGRATE_BAD_HASH 0x1802
22662 do_facet mds2 lctl set_param fail_loc=0x1802
22665 do_facet mds2 lctl set_param fail_loc=0
22666 $LFS getdirstripe $DIR/$tdir
22667 unlinkmany -d $DIR/$tdir/d 100 || error "unlinkmany failed"
22668 rmdir $DIR/$tdir || error "rmdir $tdir failed"
22670 run_test 230y "unlink dir with bad hash type"
22673 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22674 (( MDS1_VERSION >= $(version_code 2.15.55.45) )) ||
22675 skip "Need MDS version at least 2.15.55.45"
22679 test_mkdir -c -1 $DIR/$tdir || error "mkdir $tdir failed"
22680 $LFS getdirstripe $DIR/$tdir
22681 createmany -d $DIR/$tdir/d 100 || error "createmany failed"
22682 $LFS migrate -m 1 -c 2 -H fnv_1a_64 $DIR/$tdir &
22686 #OBD_FAIL_MIGRATE_BAD_HASH 0x1802
22687 do_facet mds2 lctl set_param fail_loc=0x1802
22690 do_facet mds2 lctl set_param fail_loc=0
22691 $LFS getdirstripe $DIR/$tdir
22694 $LFS migrate -m 1 -c 2 -H fnv_1a_64 $DIR/$tdir ||
22695 error "resume migration failed"
22696 $LFS getdirstripe $DIR/$tdir
22697 [ $($LFS getdirstripe -H $DIR/$tdir) == "fnv_1a_64,fixed" ] ||
22698 error "migration is not finished"
22700 run_test 230z "resume dir migration with bad hash type"
22704 # For simplicity this test assumes that max_pages_per_rpc
22705 # is the same across all OSCs
22706 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
22707 local bulk_size=$((max_pages * PAGE_SIZE))
22708 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
22711 mkdir -p $DIR/$tdir
22712 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
22713 error "failed to set stripe with -S ${brw_size}M option"
22714 stack_trap "rm -rf $DIR/$tdir"
22716 # clear the OSC stats
22717 $LCTL set_param osc.*.stats=0 &>/dev/null
22720 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
22721 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
22722 oflag=direct &>/dev/null || error "dd failed"
22724 sync; sleep 1; sync # just to be safe
22725 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
22726 if [ x$nrpcs != "x1" ]; then
22727 $LCTL get_param osc.*.stats
22728 error "found $nrpcs ost_write RPCs, not 1 as expected"
22732 # Drop the OSC cache, otherwise we will read from it
22733 cancel_lru_locks osc
22735 # clear the OSC stats
22736 $LCTL set_param osc.*.stats=0 &>/dev/null
22738 # Client reads $bulk_size.
22739 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
22740 iflag=direct &>/dev/null || error "dd failed"
22742 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
22743 if [ x$nrpcs != "x1" ]; then
22744 $LCTL get_param osc.*.stats
22745 error "found $nrpcs ost_read RPCs, not 1 as expected"
22748 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
22751 mkdir -p $DIR/$tdir
22752 stack_trap "rm -rf $DIR/$tdir"
22754 for i in {0..1023}; do
22755 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
22756 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
22757 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
22761 run_test 231b "must not assert on fully utilized OST request buffer"
22764 mkdir -p $DIR/$tdir
22765 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
22767 #define OBD_FAIL_LDLM_OST_LVB 0x31c
22768 do_facet ost1 $LCTL set_param fail_loc=0x31c
22770 # ignore dd failure
22771 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
22772 stack_trap "rm -f $DIR/$tdir/$tfile"
22774 do_facet ost1 $LCTL set_param fail_loc=0
22775 umount_client $MOUNT || error "umount failed"
22776 mount_client $MOUNT || error "mount failed"
22777 stop ost1 || error "cannot stop ost1"
22778 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22780 run_test 232a "failed lock should not block umount"
22783 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
22784 skip "Need MDS version at least 2.10.58"
22786 mkdir -p $DIR/$tdir
22787 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
22788 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
22789 stack_trap "rm -f $DIR/$tdir/$tfile"
22791 cancel_lru_locks osc
22793 #define OBD_FAIL_LDLM_OST_LVB 0x31c
22794 do_facet ost1 $LCTL set_param fail_loc=0x31c
22797 $LFS data_version $DIR/$tdir/$tfile || true
22799 do_facet ost1 $LCTL set_param fail_loc=0
22800 umount_client $MOUNT || error "umount failed"
22801 mount_client $MOUNT || error "mount failed"
22802 stop ost1 || error "cannot stop ost1"
22803 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22805 run_test 232b "failed data version lock should not block umount"
22808 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
22809 skip "Need MDS version at least 2.3.64"
22810 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
22812 local fid=$($LFS path2fid $MOUNT)
22814 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
22815 error "cannot access $MOUNT using its FID '$fid'"
22817 run_test 233a "checking that OBF of the FS root succeeds"
22820 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
22821 skip "Need MDS version at least 2.5.90"
22822 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
22824 local fid=$($LFS path2fid $MOUNT/.lustre)
22826 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
22827 error "cannot access $MOUNT/.lustre using its FID '$fid'"
22829 fid=$($LFS path2fid $MOUNT/.lustre/fid)
22830 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
22831 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
22833 run_test 233b "checking that OBF of the FS .lustre succeeds"
22836 local p="$TMP/sanityN-$TESTNAME.parameters"
22837 save_lustre_params client "llite.*.xattr_cache" > $p
22838 lctl set_param llite.*.xattr_cache 1 ||
22839 skip_env "xattr cache is not supported"
22841 mkdir -p $DIR/$tdir || error "mkdir failed"
22842 touch $DIR/$tdir/$tfile || error "touch failed"
22843 # OBD_FAIL_LLITE_XATTR_ENOMEM
22844 $LCTL set_param fail_loc=0x1405
22845 getfattr -n user.attr $DIR/$tdir/$tfile &&
22846 error "getfattr should have failed with ENOMEM"
22847 $LCTL set_param fail_loc=0x0
22850 restore_lustre_params < $p
22853 run_test 234 "xattr cache should not crash on ENOMEM"
22856 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
22857 skip "Need MDS version at least 2.4.52"
22859 flock_deadlock $DIR/$tfile
22864 124) error "process hangs on a deadlock"
22866 *) error "error executing flock_deadlock $DIR/$tfile"
22870 run_test 235 "LU-1715: flock deadlock detection does not work properly"
22874 check_swap_layouts_support
22876 local ref1=/etc/passwd
22877 local ref2=/etc/group
22878 local file1=$DIR/$tdir/f1
22879 local file2=$DIR/$tdir/f2
22881 test_mkdir -c1 $DIR/$tdir
22882 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
22883 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
22884 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
22885 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
22886 local fd=$(free_fd)
22887 local cmd="exec $fd<>$file2"
22890 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
22891 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
22894 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
22899 run_test 236 "Layout swap on open unlinked file"
22901 # LU-4659 linkea consistency
22903 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
22904 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
22905 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
22906 skip "Need MDS version at least 2.5.58 or 2.5.2+"
22909 ln $DIR/$tfile $DIR/$tfile.lnk
22910 touch $DIR/$tfile.new
22911 mv $DIR/$tfile.new $DIR/$tfile
22912 local fid1=$($LFS path2fid $DIR/$tfile)
22913 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
22914 local path1=$($LFS fid2path $FSNAME "$fid1")
22915 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
22916 local path2=$($LFS fid2path $FSNAME "$fid2")
22917 [ $tfile.lnk == $path2 ] ||
22918 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
22921 run_test 238 "Verify linkea consistency"
22923 test_239A() { # was test_239
22924 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
22925 skip "Need MDS version at least 2.5.60"
22927 local list=$(comma_list $(mdts_nodes))
22929 mkdir -p $DIR/$tdir
22930 createmany -o $DIR/$tdir/f- 5000
22931 unlinkmany $DIR/$tdir/f- 5000
22932 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
22933 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
22934 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
22935 osp.*MDT*.sync_in_flight" | calc_sum)
22936 [ "$changes" -eq 0 ] || error "$changes not synced"
22938 run_test 239A "osp_sync test"
22940 test_239a() { #LU-5297
22941 remote_mds_nodsh && skip "remote MDS with nodsh"
22944 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
22945 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
22946 chgrp $RUNAS_GID $DIR/$tfile
22947 wait_delete_completed
22949 run_test 239a "process invalid osp sync record correctly"
22951 test_239b() { #LU-5297
22952 remote_mds_nodsh && skip "remote MDS with nodsh"
22955 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
22956 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
22957 chgrp $RUNAS_GID $DIR/$tfile1
22958 wait_delete_completed
22959 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
22961 chgrp $RUNAS_GID $DIR/$tfile2
22962 wait_delete_completed
22964 run_test 239b "process osp sync record with ENOMEM error correctly"
22967 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22968 remote_mds_nodsh && skip "remote MDS with nodsh"
22970 mkdir -p $DIR/$tdir
22972 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
22973 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
22974 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
22975 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
22977 umount_client $MOUNT || error "umount failed"
22978 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
22979 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
22980 mount_client $MOUNT || error "failed to mount client"
22982 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
22983 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
22985 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
22991 for LOOP in $(seq $count); do
22992 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
22993 cancel_lru_locks $OSC || true
23001 for LOOP in $(seq $1); do
23002 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
23007 test_241a() { # was test_241
23008 local bsize=$PAGE_SIZE
23010 (( bsize < 40960 )) && bsize=40960
23011 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
23013 cancel_lru_locks $OSC
23014 test_241_bio 1000 $bsize &
23016 test_241_dio 1000 $bsize
23019 run_test 241a "bio vs dio"
23022 local bsize=$PAGE_SIZE
23024 (( bsize < 40960 )) && bsize=40960
23025 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
23027 test_241_dio 1000 $bsize &
23029 test_241_dio 1000 $bsize
23032 run_test 241b "dio vs dio"
23035 remote_mds_nodsh && skip "remote MDS with nodsh"
23037 mkdir_on_mdt0 $DIR/$tdir
23038 touch $DIR/$tdir/$tfile
23040 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
23041 do_facet mds1 lctl set_param fail_loc=0x105
23042 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
23044 do_facet mds1 lctl set_param fail_loc=0
23045 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
23047 run_test 242 "mdt_readpage failure should not cause directory unreadable"
23051 test_mkdir $DIR/$tdir
23052 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
23054 run_test 243 "various group lock tests"
23058 test_mkdir $DIR/$tdir
23059 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
23060 sendfile_grouplock $DIR/$tdir/$tfile || \
23061 error "sendfile+grouplock failed"
23064 run_test 244a "sendfile with group lock tests"
23068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
23071 local size=$((1024*1024))
23073 test_mkdir $DIR/$tdir
23074 for i in $(seq 1 $threads); do
23075 local file=$DIR/$tdir/file_$((i / 10))
23076 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
23079 for i in $(seq 1 $threads); do
23083 run_test 244b "multi-threaded write with group lock"
23086 local flagname="multi_mod_rpcs"
23087 local connect_data_name="max_mod_rpcs"
23090 # check if multiple modify RPCs flag is set
23091 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
23092 grep "connect_flags:")
23095 echo "$out" | grep -qw $flagname
23096 if [ $? -ne 0 ]; then
23097 echo "connect flag $flagname is not set"
23101 # check if multiple modify RPCs data is set
23102 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
23105 echo "$out" | grep -qw $connect_data_name ||
23106 error "import should have connect data $connect_data_name"
23108 run_test 245a "check mdc connection flag/data: multiple modify RPCs"
23111 local flagname="multi_mod_rpcs"
23112 local connect_data_name="max_mod_rpcs"
23115 remote_mds_nodsh && skip "remote MDS with nodsh"
23116 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
23118 # check if multiple modify RPCs flag is set
23119 out=$(do_facet mds1 \
23120 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import |
23121 grep "connect_flags:")
23124 [[ "$out" =~ $flagname ]] || skip "connect flag $flagname is not set"
23126 # check if multiple modify RPCs data is set
23127 out=$(do_facet mds1 \
23128 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import)
23130 [[ "$out" =~ $connect_data_name ]] ||
23133 error "missing connect data $connect_data_name"
23136 run_test 245b "check osp connection flag/data: multiple modify RPCs"
23142 umount_client $submount
23147 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
23149 skip_env "Fileset feature is not supported"
23151 local submount=${MOUNT}_$tdir
23154 mkdir -p $submount || error "mkdir $submount failed"
23155 FILESET="$FILESET/$tdir" mount_client $submount ||
23156 error "mount $submount failed"
23157 trap "cleanup_247 $submount" EXIT
23158 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
23159 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
23160 error "read $MOUNT/$tdir/$tfile failed"
23161 cleanup_247 $submount
23163 run_test 247a "mount subdir as fileset"
23166 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
23167 skip_env "Fileset feature is not supported"
23169 local submount=${MOUNT}_$tdir
23171 rm -rf $MOUNT/$tdir
23172 mkdir -p $submount || error "mkdir $submount failed"
23174 FILESET="$FILESET/$tdir" mount_client $submount &&
23175 error "mount $submount should fail"
23178 run_test 247b "mount subdir that dose not exist"
23181 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
23182 skip_env "Fileset feature is not supported"
23184 local submount=${MOUNT}_$tdir
23186 mkdir -p $MOUNT/$tdir/dir1
23187 mkdir -p $submount || error "mkdir $submount failed"
23188 trap "cleanup_247 $submount" EXIT
23189 FILESET="$FILESET/$tdir" mount_client $submount ||
23190 error "mount $submount failed"
23191 local fid=$($LFS path2fid $MOUNT/)
23192 $LFS fid2path $submount $fid && error "fid2path should fail"
23193 cleanup_247 $submount
23195 run_test 247c "running fid2path outside subdirectory root"
23198 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
23199 skip "Fileset feature is not supported"
23201 local submount=${MOUNT}_$tdir
23203 mkdir -p $MOUNT/$tdir/dir1
23204 mkdir -p $submount || error "mkdir $submount failed"
23205 FILESET="$FILESET/$tdir" mount_client $submount ||
23206 error "mount $submount failed"
23207 trap "cleanup_247 $submount" EXIT
23209 local td=$submount/dir1
23210 local fid=$($LFS path2fid $td)
23211 [ -z "$fid" ] && error "path2fid unable to get $td FID"
23213 # check that we get the same pathname back
23216 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
23217 echo "$rootpath $fid"
23218 found=$($LFS fid2path $rootpath "$fid")
23219 [ -n "$found" ] || error "fid2path should succeed"
23220 [ "$found" == "$td" ] || error "fid2path $found != $td"
23222 # check wrong root path format
23223 rootpath=$submount"_wrong"
23224 found=$($LFS fid2path $rootpath "$fid")
23225 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
23227 cleanup_247 $submount
23229 run_test 247d "running fid2path inside subdirectory root"
23233 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
23235 skip "Fileset feature is not supported"
23237 local submount=${MOUNT}_$tdir
23240 mkdir -p $submount || error "mkdir $submount failed"
23241 FILESET="$FILESET/.." mount_client $submount &&
23242 error "mount $submount should fail"
23245 run_test 247e "mount .. as fileset"
23248 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
23249 (( $MDS1_VERSION >= $(version_code 2.14.50.162) )) ||
23250 skip "Need at least version 2.14.50.162"
23251 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
23252 skip "Fileset feature is not supported"
23254 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
23255 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
23256 error "mkdir remote failed"
23257 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
23258 error "mkdir remote/subdir failed"
23259 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
23260 error "mkdir striped failed"
23261 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
23263 local submount=${MOUNT}_$tdir
23265 mkdir -p $submount || error "mkdir $submount failed"
23266 stack_trap "rmdir $submount"
23269 local fileset=$FILESET
23270 local mdts=$(comma_list $(mdts_nodes))
23272 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
23273 for dir in $tdir/remote $tdir/remote/subdir $tdir/striped \
23274 $tdir/striped/subdir $tdir/striped/.; do
23275 FILESET="$fileset/$dir" mount_client $submount ||
23276 error "mount $dir failed"
23277 umount_client $submount
23280 run_test 247f "mount striped or remote directory as fileset"
23282 test_subdir_mount_lock()
23285 local submount=${MOUNT}_$(basename $testdir)
23287 touch $DIR/$testdir/$tfile || error "touch $tfile failed"
23289 mkdir -p $submount || error "mkdir $submount failed"
23290 stack_trap "rmdir $submount"
23292 FILESET="$fileset/$testdir" mount_client $submount ||
23293 error "mount $FILESET failed"
23294 stack_trap "umount $submount"
23296 local mdts=$(comma_list $(mdts_nodes))
23300 stat $submount > /dev/null || error "stat $submount failed"
23301 cancel_lru_locks $MDC
23302 stat $submount > /dev/null || error "stat $submount failed"
23303 stat $submount/$tfile > /dev/null || error "stat $tfile failed"
23304 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
23305 stat $submount/$tfile > /dev/null || error "stat $tfile failed"
23306 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
23307 awk '/getattr/ {sum += $2} END {print sum}')
23309 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
23313 (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
23315 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
23316 error "mkdir $tdir failed"
23317 test_subdir_mount_lock $tdir
23319 run_test 247g "striped directory submount revalidate ROOT from cache"
23322 (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
23323 (( $MDS1_VERSION >= $(version_code 2.15.51) )) ||
23324 skip "Need MDS version at least 2.15.51"
23326 $LFS mkdir -i 1 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
23327 test_subdir_mount_lock $tdir
23328 mkdir_on_mdt -i 0 $DIR/$tdir/$tdir.0 || error "mkdir $tdir.0 failed"
23329 mkdir_on_mdt -i 1 $DIR/$tdir/$tdir.0/$tdir.1 ||
23330 error "mkdir $tdir.1 failed"
23331 test_subdir_mount_lock $tdir/$tdir.0/$tdir.1
23333 run_test 247h "remote directory submount revalidate ROOT from cache"
23336 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
23337 [ -z "$fast_read_sav" ] && skip "no fast read support"
23339 # create a large file for fast read verification
23340 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
23342 # make sure the file is created correctly
23343 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
23344 { rm -f $DIR/$tfile; skip "file creation error"; }
23346 echo "Test 1: verify that fast read is 4 times faster on cache read"
23348 # small read with fast read enabled
23349 $LCTL set_param -n llite.*.fast_read=1
23350 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
23351 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23352 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23353 # small read with fast read disabled
23354 $LCTL set_param -n llite.*.fast_read=0
23355 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
23356 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23357 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23359 # verify that fast read is 4 times faster for cache read
23360 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
23361 error_not_in_vm "fast read was not 4 times faster: " \
23362 "$t_fast vs $t_slow"
23364 echo "Test 2: verify the performance between big and small read"
23365 $LCTL set_param -n llite.*.fast_read=1
23367 # 1k non-cache read
23368 cancel_lru_locks osc
23369 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
23370 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23371 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23373 # 1M non-cache read
23374 cancel_lru_locks osc
23375 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
23376 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23377 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23379 # verify that big IO is not 4 times faster than small IO
23380 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
23381 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
23383 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
23386 run_test 248a "fast read verification"
23389 # Default short_io_bytes=16384, try both smaller and larger sizes.
23390 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
23391 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
23392 echo "bs=53248 count=113 normal buffered write"
23393 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
23394 error "dd of initial data file failed"
23395 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
23397 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
23398 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
23399 error "dd with sync normal writes failed"
23400 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
23402 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
23403 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
23404 error "dd with sync small writes failed"
23405 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
23407 cancel_lru_locks osc
23409 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
23410 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
23411 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
23412 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
23413 iflag=direct || error "dd with O_DIRECT small read failed"
23414 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
23415 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
23416 error "compare $TMP/$tfile.1 failed"
23418 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
23419 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
23421 # just to see what the maximum tunable value is, and test parsing
23422 echo "test invalid parameter 2MB"
23423 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
23424 error "too-large short_io_bytes allowed"
23425 echo "test maximum parameter 512KB"
23426 # if we can set a larger short_io_bytes, run test regardless of version
23427 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
23428 # older clients may not allow setting it this large, that's OK
23429 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
23430 skip "Need at least client version 2.13.50"
23431 error "medium short_io_bytes failed"
23433 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
23434 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
23436 echo "test large parameter 64KB"
23437 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
23438 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
23440 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
23441 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
23442 error "dd with sync large writes failed"
23443 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
23445 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
23446 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
23447 num=$((113 * 4096 / PAGE_SIZE))
23448 echo "bs=$size count=$num oflag=direct large write $tfile.3"
23449 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
23450 error "dd with O_DIRECT large writes failed"
23451 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
23452 error "compare $DIR/$tfile.3 failed"
23454 cancel_lru_locks osc
23456 echo "bs=$size count=$num iflag=direct large read $tfile.2"
23457 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
23458 error "dd with O_DIRECT large read failed"
23459 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
23460 error "compare $TMP/$tfile.2 failed"
23462 echo "bs=$size count=$num iflag=direct large read $tfile.3"
23463 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
23464 error "dd with O_DIRECT large read failed"
23465 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
23466 error "compare $TMP/$tfile.3 failed"
23468 run_test 248b "test short_io read and write for both small and large sizes"
23470 test_249() { # LU-7890
23471 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
23472 skip "Need at least version 2.8.54"
23475 $LFS setstripe -c 1 $DIR/$tfile
23476 # Offset 2T == 4k * 512M
23477 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
23478 error "dd to 2T offset failed"
23480 run_test 249 "Write above 2T file size"
23483 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
23484 && skip "no 16TB file size limit on ZFS"
23486 $LFS setstripe -c 1 $DIR/$tfile
23487 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
23488 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
23489 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
23490 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
23491 conv=notrunc,fsync && error "append succeeded"
23494 run_test 250 "Write above 16T limit"
23497 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
23499 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
23500 #Skip once - writing the first stripe will succeed
23501 $LCTL set_param fail_loc=0xa0001407 fail_val=1
23502 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
23503 error "short write happened"
23505 $LCTL set_param fail_loc=0xa0001407 fail_val=1
23506 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
23507 error "short read happened"
23511 run_test 251 "Handling short read and write correctly"
23514 remote_mds_nodsh && skip "remote MDS with nodsh"
23515 remote_ost_nodsh && skip "remote OST with nodsh"
23516 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
23517 skip_env "ldiskfs only test"
23527 # check lr_reader on OST0000
23529 dev=$(facet_device $tgt)
23530 out=$(do_facet $tgt $LR_READER $dev)
23531 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
23533 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
23534 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
23535 error "Invalid uuid returned by $LR_READER on target $tgt"
23536 echo -e "uuid returned by $LR_READER is '$uuid'\n"
23538 # check lr_reader -c on MDT0000
23540 dev=$(facet_device $tgt)
23541 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
23542 skip "$LR_READER does not support additional options"
23544 out=$(do_facet $tgt $LR_READER -c $dev)
23545 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
23547 num=$(echo "$out" | grep -c "mdtlov")
23548 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
23549 error "Invalid number of mdtlov clients returned by $LR_READER"
23550 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
23552 # check lr_reader -cr on MDT0000
23553 out=$(do_facet $tgt $LR_READER -cr $dev)
23554 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
23556 echo "$out" | grep -q "^reply_data:$" ||
23557 error "$LR_READER should have returned 'reply_data' section"
23558 num=$(echo "$out" | grep -c "client_generation")
23559 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
23561 run_test 252 "check lr_reader tool"
23564 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23565 remote_mds_nodsh && skip "remote MDS with nodsh"
23566 remote_mgs_nodsh && skip "remote MGS with nodsh"
23570 local ost_name=$(ostname_from_index $ostidx)
23573 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
23574 do_facet $SINGLEMDS $LCTL get_param -n \
23575 osp.$mdtosc_proc1.reserved_mb_high ||
23576 skip "remote MDS does not support reserved_mb_high"
23580 wait_delete_completed
23582 stack_trap "rm -rf $DIR/$tdir"
23584 pool_add $TESTNAME || error "Pool creation failed"
23585 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
23587 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
23588 error "Setstripe failed"
23590 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
23592 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
23594 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
23596 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
23597 osp.$mdtosc_proc1.prealloc_status)
23598 echo "prealloc_status $oa_status"
23600 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
23601 error "File creation should fail"
23603 #object allocation was stopped, but we still able to append files
23604 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
23605 oflag=append || error "Append failed"
23607 rm -f $DIR/$tdir/$tfile.0
23609 # For this test, we want to delete the files we created to go out of
23610 # space but leave the watermark, so we remain nearly out of space
23611 ost_watermarks_enospc_delete_files $tfile $ostidx
23613 wait_delete_completed
23617 for i in $(seq 10 12); do
23618 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
23619 2>/dev/null || error "File creation failed after rm"
23622 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
23623 osp.$mdtosc_proc1.prealloc_status)
23624 echo "prealloc_status $oa_status"
23626 if (( oa_status != 0 )); then
23627 error "Object allocation still disable after rm"
23630 run_test 253 "Check object allocation limit"
23633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23634 remote_mds_nodsh && skip "remote MDS with nodsh"
23636 local mdt=$(facet_svc $SINGLEMDS)
23638 do_facet $SINGLEMDS $LCTL get_param -n mdd.$mdt.changelog_size ||
23639 skip "MDS does not support changelog_size"
23643 changelog_register || error "changelog_register failed"
23645 changelog_clear 0 || error "changelog_clear failed"
23647 local size1=$(do_facet $SINGLEMDS \
23648 $LCTL get_param -n mdd.$mdt.changelog_size)
23649 echo "Changelog size $size1"
23652 $LFS mkdir -i 0 $DIR/$tdir
23654 mkdir -p $DIR/$tdir/pics/2008/zachy
23655 touch $DIR/$tdir/pics/2008/zachy/timestamp
23656 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
23657 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
23658 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
23659 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
23660 rm $DIR/$tdir/pics/desktop.jpg
23662 local size2=$(do_facet $SINGLEMDS \
23663 $LCTL get_param -n mdd.$mdt.changelog_size)
23664 echo "Changelog size after work $size2"
23666 (( $size2 > $size1 )) ||
23667 error "new Changelog size=$size2 less than old size=$size1"
23669 run_test 254 "Check changelog size"
23676 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
23677 awk -F: '{print $2}' | grep $type > /dev/null
23678 if [ $? -ne 0 ]; then
23688 lfs ladvise -a willread $file > /dev/null 2>&1
23689 if [ $? -eq 0 ]; then
23693 lfs ladvise -a willread $file 2>&1 |
23694 grep "Inappropriate ioctl for device" > /dev/null
23695 if [ $? -eq 0 ]; then
23702 bc <<<"scale=2; ($1 - $2) * 100 / $2"
23705 # run a random read IO workload
23706 # usage: random_read_iops <filename> <filesize> <iosize>
23707 random_read_iops() {
23710 local iosize=${3:-4096}
23712 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
23713 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
23716 drop_file_oss_cache() {
23720 $LFS ladvise -a dontneed $file 2>/dev/null ||
23721 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
23724 ladvise_willread_performance()
23727 local average_origin=0
23728 local average_cache=0
23729 local average_ladvise=0
23731 for ((i = 1; i <= $repeat; i++)); do
23732 echo "Iter $i/$repeat: reading without willread hint"
23733 cancel_lru_locks osc
23734 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
23735 local speed_origin=$(random_read_iops $DIR/$tfile $size)
23736 echo "Iter $i/$repeat: uncached speed: $speed_origin"
23737 average_origin=$(bc <<<"$average_origin + $speed_origin")
23739 cancel_lru_locks osc
23740 local speed_cache=$(random_read_iops $DIR/$tfile $size)
23741 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
23742 average_cache=$(bc <<<"$average_cache + $speed_cache")
23744 cancel_lru_locks osc
23745 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
23746 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
23747 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
23748 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
23749 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
23751 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
23752 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
23753 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
23755 speedup_cache=$(percent $average_cache $average_origin)
23756 speedup_ladvise=$(percent $average_ladvise $average_origin)
23758 echo "Average uncached read: $average_origin"
23759 echo "Average speedup with OSS cached read: " \
23760 "$average_cache = +$speedup_cache%"
23761 echo "Average speedup with ladvise willread: " \
23762 "$average_ladvise = +$speedup_ladvise%"
23764 local lowest_speedup=20
23765 if (( ${average_cache%.*} < $lowest_speedup )); then
23766 echo "Speedup with OSS cached read less than $lowest_speedup%,"\
23767 " got $average_cache%. Skipping ladvise willread check."
23771 # the test won't work on ZFS until it supports 'ladvise dontneed', but
23772 # it is still good to run until then to exercise 'ladvise willread'
23773 ! $LFS ladvise -a dontneed $DIR/$tfile &&
23774 [ "$ost1_FSTYPE" = "zfs" ] &&
23775 echo "osd-zfs does not support dontneed or drop_caches" &&
23778 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
23779 (( ${average_ladvise%.*} > ${lowest_speedup%.*} )) ||
23780 error_not_in_vm "Speedup with willread is less than " \
23781 "$lowest_speedup%, got $average_ladvise%"
23785 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
23786 skip "lustre < 2.8.54 does not support ladvise "
23787 remote_ost_nodsh && skip "remote OST with nodsh"
23789 stack_trap "rm -f $DIR/$tfile"
23790 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
23792 ladvise_no_type willread $DIR/$tfile &&
23793 skip "willread ladvise is not supported"
23795 ladvise_no_ioctl $DIR/$tfile &&
23796 skip "ladvise ioctl is not supported"
23799 local size=$((size_mb * 1048576))
23800 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
23801 error "dd to $DIR/$tfile failed"
23803 lfs ladvise -a willread $DIR/$tfile ||
23804 error "Ladvise failed with no range argument"
23806 lfs ladvise -a willread -s 0 $DIR/$tfile ||
23807 error "Ladvise failed with no -l or -e argument"
23809 lfs ladvise -a willread -e 1 $DIR/$tfile ||
23810 error "Ladvise failed with only -e argument"
23812 lfs ladvise -a willread -l 1 $DIR/$tfile ||
23813 error "Ladvise failed with only -l argument"
23815 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
23816 error "End offset should not be smaller than start offset"
23818 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
23819 error "End offset should not be equal to start offset"
23821 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
23822 error "Ladvise failed with overflowing -s argument"
23824 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
23825 error "Ladvise failed with overflowing -e argument"
23827 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
23828 error "Ladvise failed with overflowing -l argument"
23830 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
23831 error "Ladvise succeeded with conflicting -l and -e arguments"
23833 echo "Synchronous ladvise should wait"
23835 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
23836 do_nodes $(comma_list $(osts_nodes)) \
23837 $LCTL set_param fail_val=$delay fail_loc=0x237
23838 stack_trap "do_nodes $(comma_list $(osts_nodes)) \
23839 $LCTL set_param fail_loc=0"
23841 local start_ts=$SECONDS
23842 lfs ladvise -a willread $DIR/$tfile ||
23843 error "Ladvise failed with no range argument"
23844 local end_ts=$SECONDS
23845 local inteval_ts=$((end_ts - start_ts))
23847 if [ $inteval_ts -lt $(($delay - 1)) ]; then
23848 error "Synchronous advice didn't wait reply"
23851 echo "Asynchronous ladvise shouldn't wait"
23852 local start_ts=$SECONDS
23853 lfs ladvise -a willread -b $DIR/$tfile ||
23854 error "Ladvise failed with no range argument"
23855 local end_ts=$SECONDS
23856 local inteval_ts=$((end_ts - start_ts))
23858 if [ $inteval_ts -gt $(($delay / 2)) ]; then
23859 error "Asynchronous advice blocked"
23862 ladvise_willread_performance
23864 run_test 255a "check 'lfs ladvise -a willread'"
23870 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
23874 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
23875 skip "lustre < 2.8.54 does not support ladvise "
23876 remote_ost_nodsh && skip "remote OST with nodsh"
23878 stack_trap "rm -f $DIR/$tfile"
23879 lfs setstripe -c 1 -i 0 $DIR/$tfile
23881 ladvise_no_type dontneed $DIR/$tfile &&
23882 skip "dontneed ladvise is not supported"
23884 ladvise_no_ioctl $DIR/$tfile &&
23885 skip "ladvise ioctl is not supported"
23887 ! $LFS ladvise -a dontneed $DIR/$tfile &&
23888 [ "$ost1_FSTYPE" = "zfs" ] &&
23889 skip "zfs-osd does not support 'ladvise dontneed'"
23892 local size=$((size_mb * 1048576))
23893 # In order to prevent disturbance of other processes, only check 3/4
23894 # of the memory usage
23895 local kibibytes=$((size_mb * 1024 * 3 / 4))
23897 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
23898 error "dd to $DIR/$tfile failed"
23900 #force write to complete before dropping OST cache & checking memory
23903 local total=$(facet_meminfo ost1 MemTotal)
23904 echo "Total memory: $total KiB"
23906 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
23907 local before_read=$(facet_meminfo ost1 Cached)
23908 echo "Cache used before read: $before_read KiB"
23910 lfs ladvise -a willread $DIR/$tfile ||
23911 error "Ladvise willread failed"
23912 local after_read=$(facet_meminfo ost1 Cached)
23913 echo "Cache used after read: $after_read KiB"
23915 lfs ladvise -a dontneed $DIR/$tfile ||
23916 error "Ladvise dontneed again failed"
23917 local no_read=$(facet_meminfo ost1 Cached)
23918 echo "Cache used after dontneed ladvise: $no_read KiB"
23920 if [ $total -lt $((before_read + kibibytes)) ]; then
23921 echo "Memory is too small, abort checking"
23925 if [ $((before_read + kibibytes)) -gt $after_read ]; then
23926 error "Ladvise willread should use more memory" \
23927 "than $kibibytes KiB"
23930 if [ $((no_read + kibibytes)) -gt $after_read ]; then
23931 error "Ladvise dontneed should release more memory" \
23932 "than $kibibytes KiB"
23935 run_test 255b "check 'lfs ladvise -a dontneed'"
23938 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
23939 skip "lustre < 2.10.50 does not support lockahead"
23941 local ost1_imp=$(get_osc_import_name client ost1)
23942 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
23950 test_mkdir -p $DIR/$tdir
23951 $LFS setstripe -i 0 -c 1 $DIR/$tdir
23953 #test 10 returns only success/failure
23955 lockahead_test -d $DIR/$tdir -t $i -f $tfile
23957 if [ $rc -eq 255 ]; then
23958 error "Ladvise test${i} failed, ${rc}"
23961 #test 11 counts lock enqueue requests, all others count new locks
23963 count=$(do_facet ost1 \
23964 $LCTL get_param -n ost.OSS.ost.stats)
23965 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
23967 lockahead_test -d $DIR/$tdir -t $i -f $tfile
23969 if [ $rc -eq 255 ]; then
23970 error "Ladvise test${i} failed, ${rc}"
23973 new_count=$(do_facet ost1 \
23974 $LCTL get_param -n ost.OSS.ost.stats)
23975 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
23976 awk '{ print $2 }')
23978 difference="$((new_count - count))"
23979 if [ $difference -ne $rc ]; then
23980 error "Ladvise test${i}, bad enqueue count, returned " \
23981 "${rc}, actual ${difference}"
23984 for i in $(seq 12 21); do
23985 # If we do not do this, we run the risk of having too many
23986 # locks and starting lock cancellation while we are checking
23988 cancel_lru_locks osc
23990 count=$($LCTL get_param -n \
23991 ldlm.namespaces.$imp_name.lock_unused_count)
23993 lockahead_test -d $DIR/$tdir -t $i -f $tfile
23995 if [ $rc -eq 255 ]; then
23996 error "Ladvise test ${i} failed, ${rc}"
23999 new_count=$($LCTL get_param -n \
24000 ldlm.namespaces.$imp_name.lock_unused_count)
24001 difference="$((new_count - count))"
24003 # Test 15 output is divided by 100 to map down to valid return
24004 if [ $i -eq 15 ]; then
24008 if [ $difference -ne $rc ]; then
24009 error "Ladvise test ${i}, bad lock count, returned " \
24010 "${rc}, actual ${difference}"
24014 #test 22 returns only success/failure
24016 lockahead_test -d $DIR/$tdir -t $i -f $tfile
24018 if [ $rc -eq 255 ]; then
24019 error "Ladvise test${i} failed, ${rc}"
24022 run_test 255c "suite of ladvise lockahead tests"
24025 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24026 remote_mds_nodsh && skip "remote MDS with nodsh"
24027 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
24028 changelog_users $SINGLEMDS | grep "^cl" &&
24029 skip "active changelog user"
24035 mdt_dev=$(facet_device $SINGLEMDS)
24038 changelog_register || error "changelog_register failed"
24041 mkdir_on_mdt -i$(($(facet_number $SINGLEMDS) - 1)) $DIR/$tdir
24043 changelog_clear 0 || error "changelog_clear failed"
24046 touch $DIR/$tdir/{1..10}
24049 stop $SINGLEMDS || error "Fail to stop MDT"
24052 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
24053 error "Fail to start MDT"
24055 #after mount new plainllog is used
24056 touch $DIR/$tdir/{11..19}
24057 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
24058 stack_trap "rm -f $tmpfile"
24059 cat_sl=$(do_facet $SINGLEMDS "sync; \
24060 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
24061 llog_reader $tmpfile | grep -c type=1064553b")
24062 do_facet $SINGLEMDS llog_reader $tmpfile
24064 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
24066 changelog_clear 0 || error "changelog_clear failed"
24068 cat_sl=$(do_facet $SINGLEMDS "sync; \
24069 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
24070 llog_reader $tmpfile | grep -c type=1064553b")
24072 if (( cat_sl == 2 )); then
24073 error "Empty plain llog was not deleted from changelog catalog"
24074 elif (( cat_sl != 1 )); then
24075 error "Active plain llog shouldn't be deleted from catalog"
24078 run_test 256 "Check llog delete for empty and not full state"
24081 remote_mds_nodsh && skip "remote MDS with nodsh"
24082 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
24083 skip "Need MDS version at least 2.8.55"
24085 test_mkdir $DIR/$tdir
24087 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
24088 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
24091 #define OBD_FAIL_MDS_XATTR_REP 0x161
24092 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
24093 local facet=mds$((mdtidx + 1))
24094 set_nodes_failloc $(facet_active_host $facet) 0x80000161
24095 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
24097 stop $facet || error "stop MDS failed"
24098 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
24099 error "start MDS fail"
24100 wait_recovery_complete $facet
24102 run_test 257 "xattr locks are not lost"
24104 # Verify we take the i_mutex when security requires it
24106 #define OBD_FAIL_IMUTEX_SEC 0x141c
24107 $LCTL set_param fail_loc=0x141c
24109 chmod u+s $DIR/$tfile
24110 chmod a+rwx $DIR/$tfile
24111 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
24113 if [ $RC -ne 0 ]; then
24114 error "error, failed to take i_mutex, rc=$?"
24118 run_test 258a "verify i_mutex security behavior when suid attributes is set"
24120 # Verify we do NOT take the i_mutex in the normal case
24122 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
24123 $LCTL set_param fail_loc=0x141d
24126 chmod a+rw $DIR/$tfile
24127 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
24129 if [ $RC -ne 0 ]; then
24130 error "error, took i_mutex unnecessarily, rc=$?"
24135 run_test 258b "verify i_mutex security behavior"
24138 local file=$DIR/$tfile
24142 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
24144 stack_trap "rm -f $file" EXIT
24146 wait_delete_completed
24147 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
24148 echo "before: $before"
24150 $LFS setstripe -i 0 -c 1 $file
24151 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
24153 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
24154 echo "after write: $after"
24156 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
24157 do_facet ost1 $LCTL set_param fail_loc=0x2301
24159 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
24160 echo "after truncate: $after"
24163 do_facet ost1 $LCTL set_param fail_loc=0
24164 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
24166 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
24167 echo "after restart: $after"
24168 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
24169 error "missing truncate?"
24173 run_test 259 "crash at delayed truncate"
24176 #define OBD_FAIL_MDC_CLOSE 0x806
24177 $LCTL set_param fail_loc=0x80000806
24181 run_test 260 "Check mdc_close fail"
24183 ### Data-on-MDT sanity tests ###
24185 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24186 skip "Need MDS version at least 2.10.55 for DoM"
24189 local dom=$DIR/$tdir/dom_file
24190 local tmp=$DIR/$tdir/tmp_file
24192 mkdir_on_mdt0 $DIR/$tdir
24194 # basic checks for DoM component creation
24195 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
24196 error "Can set MDT layout to non-first entry"
24198 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
24199 error "Can define multiple entries as MDT layout"
24201 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
24203 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
24204 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
24205 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
24207 local mdtidx=$($LFS getstripe -m $dom)
24208 local mdtname=MDT$(printf %04x $mdtidx)
24209 local facet=mds$((mdtidx + 1))
24210 local space_check=1
24212 # Skip free space checks with ZFS
24213 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
24217 local size_tmp=$((65536 * 3))
24218 local mdtfree1=$(do_facet $facet \
24219 lctl get_param -n osd*.*$mdtname.kbytesfree)
24221 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
24222 # check also direct IO along write
24223 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
24224 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
24226 cmp $tmp $dom || error "file data is different"
24227 [ $(stat -c%s $dom) == $size_tmp ] ||
24228 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
24229 if [ $space_check == 1 ]; then
24230 local mdtfree2=$(do_facet $facet \
24231 lctl get_param -n osd*.*$mdtname.kbytesfree)
24233 # increase in usage from by $size_tmp
24234 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
24235 error "MDT free space wrong after write: " \
24236 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
24240 local size_dom=10000
24242 $TRUNCATE $dom $size_dom
24243 [ $(stat -c%s $dom) == $size_dom ] ||
24244 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
24245 if [ $space_check == 1 ]; then
24246 mdtfree1=$(do_facet $facet \
24247 lctl get_param -n osd*.*$mdtname.kbytesfree)
24248 # decrease in usage from $size_tmp to new $size_dom
24249 [ $(($mdtfree1 - $mdtfree2)) -ge \
24250 $(((size_tmp - size_dom) / 1024)) ] ||
24251 error "MDT free space is wrong after truncate: " \
24252 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
24258 size_dom=$((size_dom + size_tmp))
24259 [ $(stat -c%s $dom) == $size_dom ] ||
24260 error "bad size after append: $(stat -c%s $dom) != $size_dom"
24261 if [ $space_check == 1 ]; then
24262 mdtfree2=$(do_facet $facet \
24263 lctl get_param -n osd*.*$mdtname.kbytesfree)
24264 # increase in usage by $size_tmp from previous
24265 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
24266 error "MDT free space is wrong after append: " \
24267 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
24272 if [ $space_check == 1 ]; then
24273 mdtfree1=$(do_facet $facet \
24274 lctl get_param -n osd*.*$mdtname.kbytesfree)
24275 # decrease in usage by $size_dom from previous
24276 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
24277 error "MDT free space is wrong after removal: " \
24278 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
24281 # combined striping
24282 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
24283 error "Can't create DoM + OST striping"
24285 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
24286 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
24287 # check also direct IO along write
24288 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
24290 cmp $tmp $dom || error "file data is different"
24291 [ $(stat -c%s $dom) == $size_tmp ] ||
24292 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
24297 run_test 270a "DoM: basic functionality tests"
24300 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24301 skip "Need MDS version at least 2.10.55"
24303 local dom=$DIR/$tdir/dom_file
24304 local max_size=1048576
24306 mkdir -p $DIR/$tdir
24307 $LFS setstripe -E $max_size -L mdt $dom
24309 # truncate over the limit
24310 $TRUNCATE $dom $(($max_size + 1)) &&
24311 error "successful truncate over the maximum size"
24312 # write over the limit
24313 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
24314 error "successful write over the maximum size"
24315 # append over the limit
24316 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
24317 echo "12345" >> $dom && error "successful append over the maximum size"
24322 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
24325 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24326 skip "Need MDS version at least 2.10.55"
24328 mkdir -p $DIR/$tdir
24329 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24331 # check files inherit DoM EA
24332 touch $DIR/$tdir/first
24333 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
24334 error "bad pattern"
24335 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
24336 error "bad stripe count"
24337 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
24338 error "bad stripe size"
24340 # check directory inherits DoM EA and uses it as default
24341 mkdir $DIR/$tdir/subdir
24342 touch $DIR/$tdir/subdir/second
24343 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
24344 error "bad pattern in sub-directory"
24345 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
24346 error "bad stripe count in sub-directory"
24347 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
24348 error "bad stripe size in sub-directory"
24351 run_test 270c "DoM: DoM EA inheritance tests"
24354 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24355 skip "Need MDS version at least 2.10.55"
24357 mkdir -p $DIR/$tdir
24358 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24360 # inherit default DoM striping
24361 mkdir $DIR/$tdir/subdir
24362 touch $DIR/$tdir/subdir/f1
24364 # change default directory striping
24365 $LFS setstripe -c 1 $DIR/$tdir/subdir
24366 touch $DIR/$tdir/subdir/f2
24367 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
24368 error "wrong default striping in file 2"
24369 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
24370 error "bad pattern in file 2"
24373 run_test 270d "DoM: change striping from DoM to RAID0"
24376 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24377 skip "Need MDS version at least 2.10.55"
24379 mkdir -p $DIR/$tdir/dom
24380 mkdir -p $DIR/$tdir/norm
24383 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
24384 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
24386 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
24387 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
24389 # find DoM files by layout
24390 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
24391 [ $NUM -eq $DOMFILES ] ||
24392 error "lfs find -L: found $NUM, expected $DOMFILES"
24393 echo "Test 1: lfs find 20 DOM files by layout: OK"
24395 # there should be 1 dir with default DOM striping
24396 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
24398 error "lfs find -L: found $NUM, expected 1 dir"
24399 echo "Test 2: lfs find 1 DOM dir by layout: OK"
24401 # find DoM files by stripe size
24402 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
24403 [ $NUM -eq $DOMFILES ] ||
24404 error "lfs find -S: found $NUM, expected $DOMFILES"
24405 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
24407 # find files by stripe offset except DoM files
24408 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
24409 [ $NUM -eq $NORMFILES ] ||
24410 error "lfs find -i: found $NUM, expected $NORMFILES"
24411 echo "Test 5: lfs find no DOM files by stripe index: OK"
24414 run_test 270e "DoM: lfs find with DoM files test"
24417 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24418 skip "Need MDS version at least 2.10.55"
24420 local mdtname=${FSNAME}-MDT0000-mdtlov
24421 local dom=$DIR/$tdir/dom_file
24422 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
24423 lod.$mdtname.dom_stripesize)
24424 local dom_limit=131072
24426 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
24427 local dom_current=$(do_facet mds1 $LCTL get_param -n \
24428 lod.$mdtname.dom_stripesize)
24429 [ ${dom_limit} -eq ${dom_current} ] ||
24430 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
24432 $LFS mkdir -i 0 -c 1 $DIR/$tdir
24433 $LFS setstripe -d $DIR/$tdir
24434 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
24435 error "Can't set directory default striping"
24437 # exceed maximum stripe size
24438 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
24439 error "Can't create file with $((dom_limit * 2)) DoM stripe"
24440 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
24441 error "Able to create DoM component size more than LOD limit"
24443 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
24444 dom_current=$(do_facet mds1 $LCTL get_param -n \
24445 lod.$mdtname.dom_stripesize)
24446 [ 0 -eq ${dom_current} ] ||
24447 error "Can't set zero DoM stripe limit"
24450 # attempt to create DoM file on server with disabled DoM should
24451 # remove DoM entry from layout and be succeed
24452 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
24453 error "Can't create DoM file (DoM is disabled)"
24454 [ $($LFS getstripe -L $dom) == "mdt" ] &&
24455 error "File has DoM component while DoM is disabled"
24458 # attempt to create DoM file with only DoM stripe should return error
24459 $LFS setstripe -E $dom_limit -L mdt $dom &&
24460 error "Able to create DoM-only file while DoM is disabled"
24462 # too low values to be aligned with smallest stripe size 64K
24463 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
24464 dom_current=$(do_facet mds1 $LCTL get_param -n \
24465 lod.$mdtname.dom_stripesize)
24466 [ 30000 -eq ${dom_current} ] &&
24467 error "Can set too small DoM stripe limit"
24469 # 64K is a minimal stripe size in Lustre, expect limit of that size
24470 [ 65536 -eq ${dom_current} ] ||
24471 error "Limit is not set to 64K but ${dom_current}"
24473 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
24474 dom_current=$(do_facet mds1 $LCTL get_param -n \
24475 lod.$mdtname.dom_stripesize)
24477 [ 2147483648 -eq ${dom_current} ] &&
24478 error "Can set too large DoM stripe limit"
24480 do_facet mds1 $LCTL set_param -n \
24481 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
24482 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
24483 error "Can't create DoM component size after limit change"
24484 do_facet mds1 $LCTL set_param -n \
24485 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
24486 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
24487 error "Can't create DoM file after limit decrease"
24488 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
24489 error "Can create big DoM component after limit decrease"
24490 touch ${dom}_def ||
24491 error "Can't create file with old default layout"
24493 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
24496 run_test 270f "DoM: maximum DoM stripe size checks"
24499 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
24500 skip "Need MDS version at least 2.13.52"
24501 local dom=$DIR/$tdir/$tfile
24503 $LFS mkdir -i 0 -c 1 $DIR/$tdir
24504 local lodname=${FSNAME}-MDT0000-mdtlov
24506 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
24507 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
24508 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
24509 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
24511 local dom_limit=1024
24512 local dom_threshold="50%"
24514 $LFS setstripe -d $DIR/$tdir
24515 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
24516 error "Can't set directory default striping"
24518 do_facet mds1 $LCTL set_param -n \
24519 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
24520 # set 0 threshold and create DOM file to change tunable stripesize
24521 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
24522 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
24523 error "Failed to create $dom file"
24524 # now tunable dom_cur_stripesize should reach maximum
24525 local dom_current=$(do_facet mds1 $LCTL get_param -n \
24526 lod.${lodname}.dom_stripesize_cur_kb)
24527 [[ $dom_current == $dom_limit ]] ||
24528 error "Current DOM stripesize is not maximum"
24531 # set threshold for further tests
24532 do_facet mds1 $LCTL set_param -n \
24533 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
24534 echo "DOM threshold is $dom_threshold free space"
24537 # Spoof bfree to exceed threshold
24538 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
24539 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
24540 for spfree in 40 20 0 15 30 55; do
24541 do_facet mds1 $LCTL set_param -n fail_val=$spfree
24542 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
24543 error "Failed to create $dom file"
24544 dom_def=$(do_facet mds1 $LCTL get_param -n \
24545 lod.${lodname}.dom_stripesize_cur_kb)
24546 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
24547 [[ $dom_def != $dom_current ]] ||
24548 error "Default stripe size was not changed"
24549 if (( spfree > 0 )) ; then
24550 dom_set=$($LFS getstripe -S $dom)
24551 (( dom_set == dom_def * 1024 )) ||
24552 error "DOM component size is still old"
24554 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
24555 error "DoM component is set with no free space"
24558 dom_current=$dom_def
24561 run_test 270g "DoM: default DoM stripe size depends on free space"
24564 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
24565 skip "Need MDS version at least 2.13.53"
24567 local mdtname=${FSNAME}-MDT0000-mdtlov
24568 local dom=$DIR/$tdir/$tfile
24569 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
24571 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
24572 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
24574 $LFS mkdir -i 0 -c 1 $DIR/$tdir
24575 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
24576 error "can't create OST file"
24577 # mirrored file with DOM entry in the second mirror
24578 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
24579 error "can't create mirror with DoM component"
24581 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
24583 # DOM component in the middle and has other enries in the same mirror,
24584 # should succeed but lost DoM component
24585 $LFS setstripe --copy=${dom}_1 $dom ||
24586 error "Can't create file from OST|DOM mirror layout"
24587 # check new file has no DoM layout after all
24588 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
24589 error "File has DoM component while DoM is disabled"
24591 run_test 270h "DoM: DoM stripe removal when disabled on server"
24594 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
24595 skip "Need MDS version at least 2.14.54"
24598 # DoM with plain layout
24599 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir &&
24600 error "default plain layout with DoM must fail"
24601 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir/$tfile &&
24602 error "setstripe plain file layout with DoM must fail"
24603 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir &&
24604 error "default DoM layout with bad striping must fail"
24605 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir/$tfile &&
24606 error "setstripe to DoM layout with bad striping must fail"
24609 run_test 270i "DoM: setting invalid DoM striping should fail"
24612 (( $MDS1_VERSION >= $(version_code 2.15.55.203) )) ||
24613 skip "Need MDS version at least 2.15.55.203"
24615 local dom=$DIR/$tdir/$tfile
24619 mkdir -p $DIR/$tdir
24621 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
24623 odv=$($LFS data_version $dom)
24625 mv $dom ${dom}_moved
24626 link ${dom}_moved $dom
24627 setfattr -n user.attrx -v "some_attr" $dom
24628 ndv=$($LFS data_version $dom)
24629 (( $ndv == $odv )) ||
24630 error "data version was changed by metadata operations"
24632 dd if=/dev/urandom of=$dom bs=1M count=1 ||
24633 error "failed to write data into $dom"
24634 cancel_lru_locks mdc
24635 ndv=$($LFS data_version $dom)
24636 (( $ndv != $odv )) ||
24637 error "data version wasn't changed on write"
24640 $TRUNCATE $dom 1000 || error "failed to truncate $dom"
24641 ndv=$($LFS data_version $dom)
24642 (( $ndv != $odv )) ||
24643 error "data version wasn't changed on truncate down"
24646 $TRUNCATE $dom 25000
24647 ndv=$($LFS data_version $dom)
24648 (( $ndv != $odv )) ||
24649 error "data version wasn't changed on truncate up"
24651 # check also fallocate for ldiskfs
24652 if [[ "$mds1_FSTYPE" == ldiskfs ]]; then
24654 fallocate -l 1048576 $dom
24655 ndv=$($LFS data_version $dom)
24656 (( $ndv != $odv )) ||
24657 error "data version wasn't changed on fallocate"
24660 fallocate -p --offset 4096 -l 4096 $dom
24661 ndv=$($LFS data_version $dom)
24662 (( $ndv != $odv )) ||
24663 error "data version wasn't changed on fallocate punch"
24666 run_test 270j "DoM migration: DOM file to the OST-striped file (plain)"
24669 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24670 skip "Need MDS version at least 2.10.55"
24672 local dom=$DIR/$tdir/dom
24674 mkdir -p $DIR/$tdir
24676 $LFS setstripe -E 1024K -L mdt $dom
24678 lctl set_param -n mdc.*.stats=clear
24679 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
24680 cat $dom > /dev/null
24681 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
24682 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
24686 run_test 271a "DoM: data is cached for read after write"
24689 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24690 skip "Need MDS version at least 2.10.55"
24692 local dom=$DIR/$tdir/dom
24694 mkdir -p $DIR/$tdir
24696 $LFS setstripe -E 1024K -L mdt -E EOF $dom
24698 lctl set_param -n mdc.*.stats=clear
24699 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
24700 cancel_lru_locks mdc
24701 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
24702 # second stat to check size is cached on client
24703 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
24704 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
24705 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
24708 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
24711 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24712 skip "Need MDS version at least 2.10.55"
24714 local dom=$DIR/$tdir/dom
24716 mkdir -p $DIR/$tdir
24718 $LFS setstripe -E 1024K -L mdt -E EOF $dom
24720 lctl set_param -n mdc.*.stats=clear
24721 lctl set_param -n osc.*.stats=clear
24722 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
24723 cancel_lru_locks mdc
24724 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
24725 # second stat to check size is cached on client
24726 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
24727 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
24728 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
24729 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
24730 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
24733 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
24739 local mdt=MDT$(printf %04x $mdtidx)
24741 if [ -z $param ]; then
24742 lctl get_param -n mdc.*$mdt*.stats
24744 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
24749 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24750 skip "Need MDS version at least 2.10.55"
24752 local dom=$DIR/$tdir/dom
24754 mkdir -p $DIR/$tdir
24756 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24758 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
24759 local facet=mds$((mdtidx + 1))
24761 cancel_lru_locks mdc
24762 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
24763 createmany -o $dom 1000
24764 lctl set_param -n mdc.*.stats=clear
24765 smalliomany -w $dom 1000 200
24766 get_mdc_stats $mdtidx
24767 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
24768 # Each file has 1 open, 1 IO enqueues, total 2000
24769 # but now we have also +1 getxattr for security.capability, total 3000
24770 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
24771 unlinkmany $dom 1000
24773 cancel_lru_locks mdc
24774 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
24775 createmany -o $dom 1000
24776 lctl set_param -n mdc.*.stats=clear
24777 smalliomany -w $dom 1000 200
24778 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
24779 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
24780 # for OPEN and IO lock.
24781 [ $((enq - enq_2)) -ge 1000 ] ||
24782 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
24783 unlinkmany $dom 1000
24786 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
24788 cleanup_271def_tests() {
24794 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
24795 skip "Need MDS version at least 2.10.57"
24797 local dom=$DIR/$tdir/dom
24798 local tmp=$TMP/$tfile
24799 trap "cleanup_271def_tests $tmp" EXIT
24801 mkdir -p $DIR/$tdir
24803 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24805 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
24807 cancel_lru_locks mdc
24808 dd if=/dev/urandom of=$tmp bs=1000 count=1
24809 dd if=$tmp of=$dom bs=1000 count=1
24810 cancel_lru_locks mdc
24812 cat /etc/hosts >> $tmp
24813 lctl set_param -n mdc.*.stats=clear
24815 # append data to the same file it should update local page
24816 echo "Append to the same page"
24817 cat /etc/hosts >> $dom
24818 local num=$(get_mdc_stats $mdtidx ost_read)
24819 local ra=$(get_mdc_stats $mdtidx req_active)
24820 local rw=$(get_mdc_stats $mdtidx req_waittime)
24822 [ -z $num ] || error "$num READ RPC occured"
24823 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24827 cmp $tmp $dom || error "file miscompare"
24829 cancel_lru_locks mdc
24830 lctl set_param -n mdc.*.stats=clear
24832 echo "Open and read file"
24833 cat $dom > /dev/null
24834 local num=$(get_mdc_stats $mdtidx ost_read)
24835 local ra=$(get_mdc_stats $mdtidx req_active)
24836 local rw=$(get_mdc_stats $mdtidx req_waittime)
24838 [ -z $num ] || error "$num READ RPC occured"
24839 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24843 cmp $tmp $dom || error "file miscompare"
24847 run_test 271d "DoM: read on open (1K file in reply buffer)"
24850 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
24851 skip "Need MDS version at least 2.10.57"
24853 local dom=$DIR/$tdir/dom
24854 local tmp=$TMP/$tfile
24855 trap "cleanup_271def_tests $tmp" EXIT
24857 mkdir -p $DIR/$tdir
24859 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24861 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
24863 cancel_lru_locks mdc
24864 dd if=/dev/urandom of=$tmp bs=265000 count=1
24865 dd if=$tmp of=$dom bs=265000 count=1
24866 cancel_lru_locks mdc
24867 cat /etc/hosts >> $tmp
24868 lctl set_param -n mdc.*.stats=clear
24870 echo "Append to the same page"
24871 cat /etc/hosts >> $dom
24872 local num=$(get_mdc_stats $mdtidx ost_read)
24873 local ra=$(get_mdc_stats $mdtidx req_active)
24874 local rw=$(get_mdc_stats $mdtidx req_waittime)
24876 [ -z $num ] || error "$num READ RPC occured"
24877 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24881 cmp $tmp $dom || error "file miscompare"
24883 cancel_lru_locks mdc
24884 lctl set_param -n mdc.*.stats=clear
24886 echo "Open and read file"
24887 cat $dom > /dev/null
24888 local num=$(get_mdc_stats $mdtidx ost_read)
24889 local ra=$(get_mdc_stats $mdtidx req_active)
24890 local rw=$(get_mdc_stats $mdtidx req_waittime)
24892 [ -z $num ] && num=0
24893 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
24894 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24898 cmp $tmp $dom || error "file miscompare"
24902 run_test 271f "DoM: read on open (200K file and read tail)"
24905 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
24906 skip "Skipping due to old client or server version"
24908 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
24910 $CHECKSTAT -t file $DIR1/$tfile
24912 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
24915 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
24916 $LCTL set_param fail_loc=0x80000314
24917 rm $DIR1/$tfile || error "Unlink fails"
24919 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
24920 [ $RC -eq 0 ] || error "Failed write to stale object"
24922 run_test 271g "Discard DoM data vs client flush race"
24925 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
24926 skip "Need MDS version at least 2.11.50"
24928 local dom=$DIR/$tdir/dom
24929 mkdir -p $DIR/$tdir
24931 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
24932 dd if=/dev/urandom of=$dom bs=512K count=1 ||
24933 error "failed to write data into $dom"
24934 local old_md5=$(md5sum $dom)
24936 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
24937 error "failed to migrate to the same DoM component"
24939 local new_md5=$(md5sum $dom)
24941 [ "$old_md5" == "$new_md5" ] ||
24942 error "md5sum differ: $old_md5, $new_md5"
24944 [ $($LFS getstripe -c $dom) -eq 2 ] ||
24945 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
24947 run_test 272a "DoM migration: new layout with the same DOM component"
24950 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
24951 skip "Need MDS version at least 2.11.50"
24953 local dom=$DIR/$tdir/dom
24954 mkdir -p $DIR/$tdir
24955 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
24956 stack_trap "rm -rf $DIR/$tdir"
24958 local mdtidx=$($LFS getstripe -m $dom)
24959 local mdtname=MDT$(printf %04x $mdtidx)
24960 local facet=mds$((mdtidx + 1))
24962 local mdtfree1=$(do_facet $facet \
24963 lctl get_param -n osd*.*$mdtname.kbytesfree)
24964 dd if=/dev/urandom of=$dom bs=2M count=1 ||
24965 error "failed to write data into $dom"
24966 local old_md5=$(md5sum $dom)
24967 cancel_lru_locks mdc
24968 local mdtfree1=$(do_facet $facet \
24969 lctl get_param -n osd*.*$mdtname.kbytesfree)
24971 $LFS migrate -c2 $dom ||
24972 error "failed to migrate to the new composite layout"
24973 [[ $($LFS getstripe --component-start=0 -L $dom) != 'mdt' ]] ||
24974 error "MDT stripe was not removed"
24975 ! getfattr -n trusted.dataver $dom &> /dev/null ||
24976 error "$dir1 shouldn't have DATAVER EA"
24978 cancel_lru_locks mdc
24979 local new_md5=$(md5sum $dom)
24980 [ "$old_md5" == "$new_md5" ] ||
24981 error "$old_md5 != $new_md5"
24983 # Skip free space checks with ZFS
24984 if [ "$(facet_fstype $facet)" != "zfs" ]; then
24985 local mdtfree2=$(do_facet $facet \
24986 lctl get_param -n osd*.*$mdtname.kbytesfree)
24987 [ $mdtfree2 -gt $mdtfree1 ] ||
24988 error "MDT space is not freed after migration"
24992 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
24995 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
24996 skip "Need MDS version at least 2.11.50"
24998 local dom=$DIR/$tdir/$tfile
24999 mkdir -p $DIR/$tdir
25000 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
25001 stack_trap "rm -rf $DIR/$tdir"
25003 local mdtidx=$($LFS getstripe -m $dom)
25004 local mdtname=MDT$(printf %04x $mdtidx)
25005 local facet=mds$((mdtidx + 1))
25007 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
25008 error "failed to write data into $dom"
25009 local old_md5=$(md5sum $dom)
25010 cancel_lru_locks mdc
25011 local mdtfree1=$(do_facet $facet \
25012 lctl get_param -n osd*.*$mdtname.kbytesfree)
25014 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
25015 error "failed to migrate to the new composite layout"
25016 [[ $($LFS getstripe --component-start=0 -L $dom) != 'mdt' ]] ||
25017 error "MDT stripe was not removed"
25019 cancel_lru_locks mdc
25020 local new_md5=$(md5sum $dom)
25021 [ "$old_md5" == "$new_md5" ] ||
25022 error "$old_md5 != $new_md5"
25024 # Skip free space checks with ZFS
25025 if [ "$(facet_fstype $facet)" != "zfs" ]; then
25026 local mdtfree2=$(do_facet $facet \
25027 lctl get_param -n osd*.*$mdtname.kbytesfree)
25028 [ $mdtfree2 -gt $mdtfree1 ] ||
25029 error "MDS space is not freed after migration"
25033 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
25036 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
25037 skip "Need MDS version at least 2.12.55"
25039 local dom=$DIR/$tdir/$tfile
25040 mkdir -p $DIR/$tdir
25041 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
25043 local mdtidx=$($LFS getstripe -m $dom)
25044 local mdtname=MDT$(printf %04x $mdtidx)
25045 local facet=mds$((mdtidx + 1))
25047 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
25048 error "failed to write data into $dom"
25049 local old_md5=$(md5sum $dom)
25050 cancel_lru_locks mdc
25051 local mdtfree1=$(do_facet $facet \
25052 lctl get_param -n osd*.*$mdtname.kbytesfree)
25054 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
25055 error "failed mirroring to the new composite layout"
25056 $LFS mirror resync $dom ||
25057 error "failed mirror resync"
25058 $LFS mirror split --mirror-id 1 -d $dom ||
25059 error "failed mirror split"
25061 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
25062 error "MDT stripe was not removed"
25064 cancel_lru_locks mdc
25065 local new_md5=$(md5sum $dom)
25066 [ "$old_md5" == "$new_md5" ] ||
25067 error "$old_md5 != $new_md5"
25069 # Skip free space checks with ZFS
25070 if [ "$(facet_fstype $facet)" != "zfs" ]; then
25071 local mdtfree2=$(do_facet $facet \
25072 lctl get_param -n osd*.*$mdtname.kbytesfree)
25073 [ $mdtfree2 -gt $mdtfree1 ] ||
25074 error "MDS space is not freed after DOM mirror deletion"
25078 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
25081 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
25082 skip "Need MDS version at least 2.12.55"
25084 local dom=$DIR/$tdir/$tfile
25085 mkdir -p $DIR/$tdir
25086 $LFS setstripe -c 2 $dom
25088 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
25089 error "failed to write data into $dom"
25090 local old_md5=$(md5sum $dom)
25093 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
25094 error "failed mirroring to the DOM layout"
25095 $LFS mirror resync $dom ||
25096 error "failed mirror resync"
25097 $LFS mirror split --mirror-id 1 -d $dom ||
25098 error "failed mirror split"
25100 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
25101 error "MDT stripe wasn't set"
25104 local new_md5=$(md5sum $dom)
25105 [ "$old_md5" == "$new_md5" ] ||
25106 error "$old_md5 != $new_md5"
25110 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
25113 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
25114 skip "Need MDS version at least 2.12.55"
25116 local dom=$DIR/$tdir/$tfile
25117 mkdir -p $DIR/$tdir
25118 $LFS setstripe -c 2 $dom
25120 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
25121 error "failed to write data into $dom"
25122 local old_md5=$(md5sum $dom)
25125 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
25126 error "failed migrating to the DOM file"
25128 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
25129 error "MDT stripe wasn't set"
25132 local new_md5=$(md5sum $dom)
25133 [ "$old_md5" != "$new_md5" ] &&
25134 error "$old_md5 != $new_md5"
25138 run_test 272f "DoM migration: OST-striped file to DOM file"
25141 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
25142 skip "Need MDS version at least 2.11.50"
25144 # Layout swap cannot be done if either file has DOM component,
25145 # this will never be supported, migration should be used instead
25147 local dom=$DIR/$tdir/$tfile
25148 mkdir -p $DIR/$tdir
25150 $LFS setstripe -c2 ${dom}_plain
25151 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
25152 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
25153 error "can swap layout with DoM component"
25154 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
25155 error "can swap layout with DoM component"
25157 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
25158 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
25159 error "can swap layout with DoM component"
25160 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
25161 error "can swap layout with DoM component"
25164 run_test 273a "DoM: layout swapping should fail with DOM"
25167 mkdir -p $DIR/$tdir
25168 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
25170 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
25171 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
25173 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
25175 run_test 273b "DoM: race writeback and object destroy"
25178 mkdir -p $DIR/$tdir
25179 $LFS setstripe -E 1M -E-1 -c-1 $DIR/$tdir
25181 #define OBD_FAIL_OFD_COMMITRW_DELAY 0x1e1
25182 do_facet ost1 $LCTL set_param fail_loc=0x800001e1 fail_val=2
25184 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
25186 run_test 273c "race writeback and object destroy"
25189 remote_ost_nodsh && skip "remote OST with nodsh"
25190 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
25191 skip "Need OST version >= 2.10.57"
25193 local file=$DIR/$tfile
25196 oss=$(comma_list $(osts_nodes))
25198 dd if=/dev/urandom of=$file bs=1M count=2 ||
25199 error "failed to create a file"
25200 stack_trap "rm -f $file"
25201 cancel_lru_locks osc
25204 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
25205 error "failed to read a file"
25207 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
25208 $LCTL set_param fail_loc=0x8000031f
25210 cancel_lru_locks osc &
25213 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
25214 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
25215 #IO takes another lock, but matches the PENDING one
25216 #and places it to the IO RPC
25217 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
25218 error "failed to read a file with PENDING lock"
25220 run_test 275 "Read on a canceled duplicate lock"
25223 remote_ost_nodsh && skip "remote OST with nodsh"
25226 do_facet ost1 "(while true; do \
25227 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
25228 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
25231 for LOOP in $(seq 20); do
25233 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
25236 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
25237 rm $TMP/sanity_276_pid"
25239 run_test 276 "Race between mount and obd_statfs"
25242 $LCTL set_param ldlm.namespaces.*.lru_size=0
25243 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
25244 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
25245 awk '/^used_mb/ { print $2 }')
25246 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
25247 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
25248 oflag=direct conv=notrunc
25249 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
25250 awk '/^used_mb/ { print $2 }')
25251 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
25253 run_test 277 "Direct IO shall drop page cache"
25256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
25257 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
25258 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
25259 skip "needs the same host for mdt1 mdt2" && return
25264 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
25265 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
25271 echo "Starting MDTs"
25272 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
25274 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
25276 do_facet mds2 $LCTL set_param fail_loc=0
25278 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
25279 wait_recovery_complete mds2
25281 run_test 278 "Race starting MDS between MDTs stop/start"
25284 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
25285 skip "Need MGS version at least 2.13.52"
25286 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25287 combined_mgs_mds || skip "needs combined MGS/MDT"
25289 umount_client $MOUNT
25290 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
25291 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
25293 mount_client $MOUNT &
25295 stop mgs || error "stop mgs failed"
25296 #for a race mgs would crash
25297 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
25298 # make sure we unmount client before remounting
25300 umount_client $MOUNT
25301 mount_client $MOUNT || error "mount client failed"
25303 run_test 280 "Race between MGS umount and client llog processing"
25305 cleanup_test_300() {
25309 test_striped_dir() {
25314 mkdir -p $DIR/$tdir
25316 SAVE_UMASK=$(umask)
25317 trap cleanup_test_300 RETURN EXIT
25319 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
25320 $DIR/$tdir/striped_dir ||
25321 error "set striped dir error"
25323 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
25324 [ "$mode" = "755" ] || error "expect 755 got $mode"
25326 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
25327 error "getdirstripe failed"
25328 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
25329 if [ "$stripe_count" != "2" ]; then
25330 error "1:stripe_count is $stripe_count, expect 2"
25332 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
25333 if [ "$stripe_count" != "2" ]; then
25334 error "2:stripe_count is $stripe_count, expect 2"
25337 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
25338 if [ "$stripe_index" != "$mdt_index" ]; then
25339 error "stripe_index is $stripe_index, expect $mdt_index"
25342 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
25343 error "nlink error after create striped dir"
25345 mkdir $DIR/$tdir/striped_dir/a
25346 mkdir $DIR/$tdir/striped_dir/b
25348 stat $DIR/$tdir/striped_dir/a ||
25349 error "create dir under striped dir failed"
25350 stat $DIR/$tdir/striped_dir/b ||
25351 error "create dir under striped dir failed"
25353 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
25354 error "nlink error after mkdir"
25356 rmdir $DIR/$tdir/striped_dir/a
25357 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
25358 error "nlink error after rmdir"
25360 rmdir $DIR/$tdir/striped_dir/b
25361 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
25362 error "nlink error after rmdir"
25364 chattr +i $DIR/$tdir/striped_dir
25365 createmany -o $DIR/$tdir/striped_dir/f 10 &&
25366 error "immutable flags not working under striped dir!"
25367 chattr -i $DIR/$tdir/striped_dir
25369 rmdir $DIR/$tdir/striped_dir ||
25370 error "rmdir striped dir error"
25378 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25379 skip "skipped for lustre < 2.7.0"
25380 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25381 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25383 test_striped_dir 0 || error "failed on striped dir on MDT0"
25384 test_striped_dir 1 || error "failed on striped dir on MDT0"
25386 run_test 300a "basic striped dir sanity test"
25389 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25390 skip "skipped for lustre < 2.7.0"
25391 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25392 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25399 test_mkdir $DIR/$tdir || error "mkdir fail"
25400 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25401 error "set striped dir error"
25402 for i in {0..9}; do
25403 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
25405 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
25406 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
25407 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
25409 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
25410 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
25411 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
25415 run_test 300b "check ctime/mtime for striped dir"
25418 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25419 skip "skipped for lustre < 2.7.0"
25420 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25421 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25425 mkdir_on_mdt0 $DIR/$tdir
25426 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
25427 error "set striped dir error"
25429 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
25430 error "chown striped dir failed"
25432 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
25433 error "create 5k files failed"
25435 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
25437 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
25441 run_test 300c "chown && check ls under striped directory"
25444 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25445 skip "skipped for lustre < 2.7.0"
25446 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25447 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25452 mkdir -p $DIR/$tdir
25453 $LFS setstripe -c 2 $DIR/$tdir
25455 #local striped directory
25456 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25457 error "set striped dir error"
25458 #look at the directories for debug purposes
25460 $LFS getdirstripe $DIR/$tdir
25461 ls -l $DIR/$tdir/striped_dir
25462 $LFS getdirstripe $DIR/$tdir/striped_dir
25463 createmany -o $DIR/$tdir/striped_dir/f 10 ||
25464 error "create 10 files failed"
25466 #remote striped directory
25467 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
25468 error "set striped dir error"
25469 #look at the directories for debug purposes
25471 $LFS getdirstripe $DIR/$tdir
25472 ls -l $DIR/$tdir/remote_striped_dir
25473 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
25474 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
25475 error "create 10 files failed"
25477 for file in $(find $DIR/$tdir); do
25478 stripe_count=$($LFS getstripe -c $file)
25479 [ $stripe_count -eq 2 ] ||
25480 error "wrong stripe $stripe_count for $file"
25485 run_test 300d "check default stripe under striped directory"
25488 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25489 skip "Need MDS version at least 2.7.55"
25490 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25491 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25496 mkdir -p $DIR/$tdir
25498 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25499 error "set striped dir error"
25501 touch $DIR/$tdir/striped_dir/a
25502 touch $DIR/$tdir/striped_dir/b
25503 touch $DIR/$tdir/striped_dir/c
25505 mkdir $DIR/$tdir/striped_dir/dir_a
25506 mkdir $DIR/$tdir/striped_dir/dir_b
25507 mkdir $DIR/$tdir/striped_dir/dir_c
25509 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
25510 error "set striped adir under striped dir error"
25512 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
25513 error "set striped bdir under striped dir error"
25515 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
25516 error "set striped cdir under striped dir error"
25518 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
25519 error "rename dir under striped dir fails"
25521 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
25522 error "rename dir under different stripes fails"
25524 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
25525 error "rename file under striped dir should succeed"
25527 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
25528 error "rename dir under striped dir should succeed"
25532 run_test 300e "check rename under striped directory"
25535 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25536 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25537 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25538 skip "Need MDS version at least 2.7.55"
25544 mkdir -p $DIR/$tdir
25546 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25547 error "set striped dir error"
25549 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
25550 error "set striped dir error"
25552 touch $DIR/$tdir/striped_dir/a
25553 mkdir $DIR/$tdir/striped_dir/dir_a
25554 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
25555 error "create striped dir under striped dir fails"
25557 touch $DIR/$tdir/striped_dir1/b
25558 mkdir $DIR/$tdir/striped_dir1/dir_b
25559 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
25560 error "create striped dir under striped dir fails"
25562 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
25563 error "rename dir under different striped dir should fail"
25565 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
25566 error "rename striped dir under diff striped dir should fail"
25568 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
25569 error "rename file under diff striped dirs fails"
25573 run_test 300f "check rename cross striped directory"
25575 test_300_check_default_striped_dir()
25578 local default_count=$2
25579 local default_index=$3
25582 local dir_stripe_index
25585 echo "checking $dirname $default_count $default_index"
25586 $LFS setdirstripe -D -c $default_count -i $default_index \
25587 -H all_char $DIR/$tdir/$dirname ||
25588 error "set default stripe on striped dir error"
25589 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
25590 [ $stripe_count -eq $default_count ] ||
25591 error "expect $default_count get $stripe_count for $dirname"
25593 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
25594 [ $stripe_index -eq $default_index ] ||
25595 error "expect $default_index get $stripe_index for $dirname"
25597 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
25598 error "create dirs failed"
25600 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
25601 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
25602 for dir in $(find $DIR/$tdir/$dirname/*); do
25603 stripe_count=$($LFS getdirstripe -c $dir)
25604 (( $stripe_count == $default_count )) ||
25605 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
25606 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
25607 error "stripe count $default_count != $stripe_count for $dir"
25609 stripe_index=$($LFS getdirstripe -i $dir)
25610 [ $default_index -eq -1 ] ||
25611 [ $stripe_index -eq $default_index ] ||
25612 error "$stripe_index != $default_index for $dir"
25614 #check default stripe
25615 stripe_count=$($LFS getdirstripe -D -c $dir)
25616 [ $stripe_count -eq $default_count ] ||
25617 error "default count $default_count != $stripe_count for $dir"
25619 stripe_index=$($LFS getdirstripe -D -i $dir)
25620 [ $stripe_index -eq $default_index ] ||
25621 error "default index $default_index != $stripe_index for $dir"
25623 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
25627 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25628 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25629 skip "Need MDS version at least 2.7.55"
25635 mkdir_on_mdt0 $DIR/$tdir
25636 mkdir $DIR/$tdir/normal_dir
25638 #Checking when client cache stripe index
25639 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
25640 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
25641 error "create striped_dir failed"
25643 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
25644 error "create dir0 fails"
25645 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
25646 [ $stripe_index -eq 0 ] ||
25647 error "dir0 expect index 0 got $stripe_index"
25649 mkdir $DIR/$tdir/striped_dir/dir1 ||
25650 error "create dir1 fails"
25651 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
25652 [ $stripe_index -eq 1 ] ||
25653 error "dir1 expect index 1 got $stripe_index"
25655 #check default stripe count/stripe index
25656 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
25657 test_300_check_default_striped_dir normal_dir 1 0
25658 test_300_check_default_striped_dir normal_dir -1 1
25659 test_300_check_default_striped_dir normal_dir 2 -1
25661 #delete default stripe information
25662 echo "delete default stripeEA"
25663 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
25664 error "set default stripe on striped dir error"
25666 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
25667 for dir in $(find $DIR/$tdir/normal_dir/*); do
25668 stripe_count=$($LFS getdirstripe -c $dir)
25669 [ $stripe_count -eq 0 ] ||
25670 error "expect 1 get $stripe_count for $dir"
25673 run_test 300g "check default striped directory for normal directory"
25676 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25677 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25678 skip "Need MDS version at least 2.7.55"
25684 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
25685 error "set striped dir error"
25687 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
25688 test_300_check_default_striped_dir striped_dir 1 0
25689 test_300_check_default_striped_dir striped_dir -1 1
25690 test_300_check_default_striped_dir striped_dir 2 -1
25692 #delete default stripe information
25693 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
25694 error "set default stripe on striped dir error"
25696 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
25697 for dir in $(find $DIR/$tdir/striped_dir/*); do
25698 stripe_count=$($LFS getdirstripe -c $dir)
25699 [ $stripe_count -eq 0 ] ||
25700 error "expect 1 get $stripe_count for $dir"
25703 run_test 300h "check default striped directory for striped directory"
25706 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
25707 (( $MDSCOUNT >= 2 )) || skip_env "needs >= 2 MDTs"
25708 (( $MDS1_VERSION >= $(version_code 2.7.55) )) ||
25709 skip "Need MDS version at least 2.7.55"
25716 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
25717 error "set striped dir error"
25719 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
25720 error "create files under striped dir failed"
25722 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
25723 error "set striped hashdir error"
25725 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
25726 error "create dir0 under hash dir failed"
25727 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
25728 error "create dir1 under hash dir failed"
25729 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
25730 error "create dir2 under hash dir failed"
25732 # unfortunately, we need to umount to clear dir layout cache for now
25733 # once we fully implement dir layout, we can drop this
25734 umount_client $MOUNT || error "umount failed"
25735 mount_client $MOUNT || error "mount failed"
25737 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
25738 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
25739 (( $dircnt == 2 )) || error "lfs find striped dir got $dircnt != 2"
25741 if (( $MDS1_VERSION > $(version_code 2.15.0) )); then
25742 $LFS mkdir -i0 -c$MDSCOUNT -H crush2 $DIR/$tdir/hashdir/d3 ||
25743 error "create crush2 dir $tdir/hashdir/d3 failed"
25744 $LFS find -H crush2 $DIR/$tdir/hashdir
25745 dircnt=$($LFS find -H crush2 $DIR/$tdir/hashdir | wc -l)
25746 (( $dircnt == 1 )) || error "find crush2 dir got $dircnt != 1"
25748 # mkdir with an invalid hash type (hash=fail_val) from client
25749 # should be replaced on MDS with a valid (default) hash type
25750 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
25751 $LCTL set_param fail_loc=0x1901 fail_val=99
25752 $LFS mkdir -c2 $DIR/$tdir/hashdir/d99
25754 local hash=$($LFS getdirstripe -H $DIR/$tdir/hashdir/d99)
25755 local expect=$(do_facet mds1 \
25756 $LCTL get_param -n lod.$FSNAME-MDT0000-mdtlov.mdt_hash)
25757 [[ $hash == $expect ]] ||
25758 error "d99 hash '$hash' != expected hash '$expect'"
25761 #set the stripe to be unknown hash type on read
25762 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
25763 $LCTL set_param fail_loc=0x1901 fail_val=99
25764 for ((i = 0; i < 10; i++)); do
25765 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
25766 error "stat f-$i failed"
25767 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
25770 touch $DIR/$tdir/striped_dir/f0 &&
25771 error "create under striped dir with unknown hash should fail"
25773 $LCTL set_param fail_loc=0
25775 umount_client $MOUNT || error "umount failed"
25776 mount_client $MOUNT || error "mount failed"
25780 run_test 300i "client handle unknown hash type striped directory"
25783 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25784 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25785 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25786 skip "Need MDS version at least 2.7.55"
25793 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
25794 $LCTL set_param fail_loc=0x1702
25795 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
25796 error "set striped dir error"
25798 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
25799 error "create files under striped dir failed"
25801 $LCTL set_param fail_loc=0
25803 rm -rf $DIR/$tdir || error "unlink striped dir fails"
25807 run_test 300j "test large update record"
25810 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25811 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25812 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25813 skip "Need MDS version at least 2.7.55"
25815 # this test needs a huge transaction
25817 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
25818 osd*.$FSNAME-MDT0000.kbytestotal")
25819 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
25826 #define OBD_FAIL_LARGE_STRIPE 0x1703
25827 $LCTL set_param fail_loc=0x1703
25828 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
25829 error "set striped dir error"
25830 $LCTL set_param fail_loc=0
25832 $LFS getdirstripe $DIR/$tdir/striped_dir ||
25833 error "getstripeddir fails"
25834 rm -rf $DIR/$tdir/striped_dir ||
25835 error "unlink striped dir fails"
25839 run_test 300k "test large striped directory"
25842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25843 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25844 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25845 skip "Need MDS version at least 2.7.55"
25849 test_mkdir -p $DIR/$tdir/striped_dir
25850 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
25851 error "chown $RUNAS_ID failed"
25852 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
25853 error "set default striped dir failed"
25855 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
25856 $LCTL set_param fail_loc=0x80000158
25857 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
25859 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
25860 [ $stripe_index -eq 1 ] ||
25861 error "expect 1 get $stripe_index for $dir"
25863 run_test 300l "non-root user to create dir under striped dir with stale layout"
25866 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25867 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
25868 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25869 skip "Need MDS version at least 2.7.55"
25871 mkdir -p $DIR/$tdir/striped_dir
25872 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
25873 error "set default stripes dir error"
25875 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
25877 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
25878 [ $stripe_count -eq 0 ] ||
25879 error "expect 0 get $stripe_count for a"
25881 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
25882 error "set default stripes dir error"
25884 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
25886 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
25887 [ $stripe_count -eq 0 ] ||
25888 error "expect 0 get $stripe_count for b"
25890 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
25891 error "set default stripes dir error"
25893 mkdir $DIR/$tdir/striped_dir/c &&
25894 error "default stripe_index is invalid, mkdir c should fails"
25896 rm -rf $DIR/$tdir || error "rmdir fails"
25898 run_test 300m "setstriped directory on single MDT FS"
25901 local list=$(comma_list $(mdts_nodes))
25904 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
25908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25909 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25910 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25911 skip "Need MDS version at least 2.7.55"
25912 remote_mds_nodsh && skip "remote MDS with nodsh"
25915 local list=$(comma_list $(mdts_nodes))
25917 trap cleanup_300n RETURN EXIT
25918 mkdir -p $DIR/$tdir
25919 chmod 777 $DIR/$tdir
25920 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
25921 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
25922 error "create striped dir succeeds with gid=0"
25924 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
25925 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
25926 error "create striped dir fails with gid=-1"
25928 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
25929 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
25930 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
25931 error "set default striped dir succeeds with gid=0"
25934 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
25935 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
25936 error "set default striped dir fails with gid=-1"
25939 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
25940 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
25941 error "create test_dir fails"
25942 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
25943 error "create test_dir1 fails"
25944 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
25945 error "create test_dir2 fails"
25948 run_test 300n "non-root user to create dir under striped dir with default EA"
25951 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25952 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25953 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25954 skip "Need MDS version at least 2.7.55"
25959 mkdir -p $DIR/$tdir
25961 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
25962 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
25963 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
25964 skip "not enough free inodes $numfree1 $numfree2"
25967 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
25968 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
25969 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
25970 skip "not enough free space $numfree1 $numfree2"
25973 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
25974 error "setdirstripe fails"
25976 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
25977 error "create dirs fails"
25979 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
25980 ls $DIR/$tdir/striped_dir > /dev/null ||
25981 error "ls striped dir fails"
25982 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
25983 error "unlink big striped dir fails"
25985 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
25988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25989 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25990 remote_mds_nodsh && skip "remote MDS with nodsh"
25992 mkdir_on_mdt0 $DIR/$tdir
25994 #define OBD_FAIL_OUT_ENOSPC 0x1704
25995 do_facet mds2 lctl set_param fail_loc=0x80001704
25996 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
25997 && error "create striped directory should fail"
25999 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
26001 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
26004 run_test 300p "create striped directory without space"
26007 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26008 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
26010 local fd=$(free_fd)
26011 local cmd="exec $fd<$tdir"
26013 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
26016 trap "eval $cmd" EXIT
26017 cd $tdir || error "cd $tdir fails"
26018 rmdir ../$tdir || error "rmdir $tdir fails"
26019 mkdir local_dir && error "create dir succeeds"
26020 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
26024 run_test 300q "create remote directory under orphan directory"
26027 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
26028 skip "Need MDS version at least 2.7.55" && return
26029 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
26033 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
26034 error "set striped dir error"
26036 $LFS getdirstripe $DIR/$tdir/striped_dir ||
26037 error "getstripeddir fails"
26040 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
26041 awk '/lmv_stripe_count:/ { print $2 }')
26043 [ $MDSCOUNT -ne $stripe_count ] &&
26044 error "wrong stripe count $stripe_count expected $MDSCOUNT"
26046 rm -rf $DIR/$tdir/striped_dir ||
26047 error "unlink striped dir fails"
26049 run_test 300r "test -1 striped directory"
26051 test_300s_helper() {
26054 local stripe_dir=$DIR/$tdir/striped_dir.$count
26056 $LFS mkdir -c $count $stripe_dir ||
26057 error "lfs mkdir -c error"
26059 $LFS getdirstripe $stripe_dir ||
26060 error "lfs getdirstripe fails"
26063 stripe_count=$($LFS getdirstripe $stripe_dir |
26064 awk '/lmv_stripe_count:/ { print $2 }')
26066 [ $count -ne $stripe_count ] &&
26067 error_noexit "bad stripe count $stripe_count expected $count"
26070 dupe_stripes=$($LFS getdirstripe $stripe_dir |
26071 awk '/0x/ {count[$1] += 1}; END {
26072 for (idx in count) {
26073 if (count[idx]>1) {
26074 print "index " idx " count " count[idx]
26079 if [[ -n "$dupe_stripes" ]] ; then
26080 lfs getdirstripe $stripe_dir
26081 error_noexit "Dupe MDT above: $dupe_stripes "
26084 rm -rf $stripe_dir ||
26085 error_noexit "unlink $stripe_dir fails"
26089 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
26090 skip "Need MDS version at least 2.7.55" && return
26091 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
26094 for count in $(seq 2 $MDSCOUNT); do
26095 test_300s_helper $count
26098 run_test 300s "test lfs mkdir -c without -i"
26101 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
26102 skip "need MDS 2.14.55 or later"
26103 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
26105 local testdir="$DIR/$tdir/striped_dir"
26106 local dir1=$testdir/dir1
26107 local dir2=$testdir/dir2
26111 $LFS setdirstripe -D -c -1 --max-inherit=3 $testdir ||
26112 error "failed to set default stripe count for $testdir"
26115 local stripe_count=$($LFS getdirstripe -c $dir1)
26117 (( $stripe_count == $MDSCOUNT )) || error "wrong stripe count"
26119 local max_count=$((MDSCOUNT - 1))
26120 local mdts=$(comma_list $(mdts_nodes))
26122 do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=$max_count
26123 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=0"
26126 stripe_count=$($LFS getdirstripe -c $dir2)
26128 (( $stripe_count == $max_count )) || error "wrong stripe count"
26130 run_test 300t "test max_mdt_stripecount"
26132 prepare_remote_file() {
26133 mkdir $DIR/$tdir/src_dir ||
26134 error "create remote source failed"
26136 cp /etc/hosts $DIR/$tdir/src_dir/a ||
26137 error "cp to remote source failed"
26138 touch $DIR/$tdir/src_dir/a
26140 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
26141 error "create remote target dir failed"
26143 touch $DIR/$tdir/tgt_dir/b
26145 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
26146 error "rename dir cross MDT failed!"
26148 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
26149 error "src_child still exists after rename"
26151 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
26152 error "missing file(a) after rename"
26154 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
26155 error "diff after rename"
26159 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
26160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26162 local remote_file=$DIR/$tdir/tgt_dir/b
26164 mkdir -p $DIR/$tdir
26166 prepare_remote_file || error "prepare remote file failed"
26169 $OPENUNLINK $remote_file $remote_file ||
26170 error "openunlink $remote_file failed"
26171 $CHECKSTAT -a $remote_file || error "$remote_file exists"
26173 run_test 310a "open unlink remote file"
26176 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
26177 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26179 local remote_file=$DIR/$tdir/tgt_dir/b
26181 mkdir -p $DIR/$tdir
26183 prepare_remote_file || error "prepare remote file failed"
26185 ln $remote_file $DIR/$tfile || error "link failed for remote file"
26186 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
26187 $CHECKSTAT -t file $remote_file || error "check file failed"
26189 run_test 310b "unlink remote file with multiple links while open"
26192 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26193 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
26195 local remote_file=$DIR/$tdir/tgt_dir/b
26197 mkdir -p $DIR/$tdir
26199 prepare_remote_file || error "prepare remote file failed"
26201 ln $remote_file $DIR/$tfile || error "link failed for remote file"
26202 multiop_bg_pause $remote_file O_uc ||
26203 error "mulitop failed for remote file"
26205 $MULTIOP $DIR/$tfile Ouc
26206 kill -USR1 $MULTIPID
26209 run_test 310c "open-unlink remote file with multiple links"
26213 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26214 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
26215 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
26216 skip "lustre < 2.8.54 does not contain LU-4825 fix"
26217 remote_mds_nodsh && skip "remote MDS with nodsh"
26219 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
26220 local mdts=$(comma_list $(mdts_nodes))
26222 mkdir -p $DIR/$tdir
26223 $LFS setstripe -i 0 -c 1 $DIR/$tdir
26224 createmany -o $DIR/$tdir/$tfile. 1000
26226 # statfs data is not real time, let's just calculate it
26227 old_iused=$((old_iused + 1000))
26229 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
26230 osp.*OST0000*MDT0000.create_count")
26231 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
26232 osp.*OST0000*MDT0000.max_create_count")
26233 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
26235 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
26236 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
26237 [ $index -ne 0 ] || error "$tfile stripe index is 0"
26239 unlinkmany $DIR/$tdir/$tfile. 1000
26241 do_nodes $mdts "$LCTL set_param -n \
26242 osp.*OST0000*.max_create_count=$max_count"
26243 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
26244 do_nodes $mdts "$LCTL set_param -n \
26245 osp.*OST0000*.create_count=$count"
26246 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
26247 grep "=0" && error "create_count is zero"
26250 for i in $(seq 120); do
26251 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
26252 # system may be too busy to destroy all objs in time, use
26253 # a somewhat small value to not fail autotest
26254 [ $((old_iused - new_iused)) -gt 400 ] && break
26258 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
26259 [ $((old_iused - new_iused)) -gt 400 ] ||
26260 error "objs not destroyed after unlink"
26262 run_test 311 "disable OSP precreate, and unlink should destroy objs"
26268 local fid=($($LFS getstripe $tf | grep 0x))
26269 local seq=${fid[3]#0x}
26270 local objid=${fid[1]}
26272 local vdevdir=$(dirname $(facet_vdevice $ost))
26273 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
26274 local zfs_zapid=$(do_facet $ost $cmd |
26275 grep -w "/O/$seq/d$((objid%32))" -C 5 |
26276 awk '/Object/{getline; print $1}')
26277 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
26278 awk "/$objid = /"'{printf $3}')
26283 zfs_object_blksz() {
26287 local vdevdir=$(dirname $(facet_vdevice $ost))
26288 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
26289 local blksz=$(do_facet $ost $cmd $objid |
26290 awk '/dblk/{getline; printf $4}')
26292 case "${blksz: -1}" in
26293 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
26294 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
26301 test_312() { # LU-4856
26302 remote_ost_nodsh && skip "remote OST with nodsh"
26303 [[ "$ost1_FSTYPE" == "zfs" ]] || skip "the test only applies to zfs"
26305 local max_blksz=$(do_facet ost1 \
26306 $ZFS get -p recordsize $(facet_device ost1) |
26307 awk '!/VALUE/{print $3}')
26308 local tf=$DIR/$tfile
26310 $LFS setstripe -c1 $tf
26311 local facet="ost$(($($LFS getstripe -i $tf) + 1))"
26313 # Get ZFS object id
26314 local zfs_objid=$(zfs_get_objid $facet $tf)
26315 # block size change by sequential overwrite
26318 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
26319 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
26321 local blksz=$(zfs_object_blksz $facet $zfs_objid)
26322 [[ $blksz -eq $bs ]] || error "blksz error: $blksz, expected: $bs"
26326 $LFS setstripe -c1 $tf
26327 facet="ost$(($($LFS getstripe -i $tf) + 1))"
26329 # block size change by sequential append write
26330 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
26331 zfs_objid=$(zfs_get_objid $facet $tf)
26334 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
26335 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
26336 oflag=sync conv=notrunc
26338 blksz=$(zfs_object_blksz $facet $zfs_objid)
26339 (( $blksz == 2 * count * PAGE_SIZE )) ||
26340 error "blksz error, actual $blksz, " \
26341 "expected: 2 * $count * $PAGE_SIZE"
26346 $LFS setstripe -c1 $tf
26347 facet="ost$(($($LFS getstripe -i $tf) + 1))"
26348 zfs_objid=$(zfs_get_objid $facet $tf)
26350 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
26351 blksz=$(zfs_object_blksz $facet $zfs_objid)
26352 (( blksz == PAGE_SIZE )) ||
26353 error "blksz error: $blksz, expected: $PAGE_SIZE"
26355 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
26356 blksz=$(zfs_object_blksz $facet $zfs_objid)
26357 (( blksz == 65536 )) || error "blksz error: $blksz, expected: 64k"
26359 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
26360 blksz=$(zfs_object_blksz $facet $zfs_objid)
26361 (( blksz == 65536 )) || error "rewrite error: $blksz, expected: 64k"
26363 run_test 312 "make sure ZFS adjusts its block size by write pattern"
26366 remote_ost_nodsh && skip "remote OST with nodsh"
26368 local file=$DIR/$tfile
26371 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
26373 # define OBD_FAIL_TGT_RCVD_EIO 0x720
26374 do_facet ost1 "$LCTL set_param fail_loc=0x720"
26375 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
26376 error "write should failed"
26377 do_facet ost1 "$LCTL set_param fail_loc=0"
26380 run_test 313 "io should fail after last_rcvd update fail"
26383 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
26385 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
26386 do_facet ost1 "$LCTL set_param fail_loc=0x720"
26388 wait_delete_completed
26389 do_facet ost1 "$LCTL set_param fail_loc=0"
26391 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
26393 test_315() { # LU-618
26394 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
26396 local file=$DIR/$tfile
26399 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
26400 error "multiop file write failed"
26401 $MULTIOP $file oO_RDONLY:r4063232_c &
26406 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
26409 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
26412 run_test 315 "read should be accounted"
26415 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
26416 large_xattr_enabled || skip "ea_inode feature disabled"
26418 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
26419 mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
26420 chown nobody $DIR/$tdir/d || error "chown $tdir/d failed"
26421 touch $DIR/$tdir/d/$tfile || error "touch $tdir/d/$tfile failed"
26423 $LFS migrate -m1 $DIR/$tdir/d || error "lfs migrate -m1 failed"
26425 run_test 316 "lfs migrate of file with large_xattr enabled"
26428 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
26429 skip "Need MDS version at least 2.11.53"
26430 if [ "$ost1_FSTYPE" == "zfs" ]; then
26431 skip "LU-10370: no implementation for ZFS"
26435 local grant_blk_size
26437 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
26438 awk '/grant_block_size:/ { print $2; exit; }')
26440 # Create File of size 5M. Truncate it to below size's and verify
26443 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
26444 error "Create file $DIR/$tfile failed"
26445 stack_trap "rm -f $DIR/$tfile" EXIT
26447 for trunc_sz in 2097152 4097 4000 509 0; do
26448 $TRUNCATE $DIR/$tfile $trunc_sz ||
26449 error "truncate $tfile to $trunc_sz failed"
26450 local sz=$(stat --format=%s $DIR/$tfile)
26451 local blk=$(stat --format=%b $DIR/$tfile)
26452 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
26453 grant_blk_size) * 8))
26455 if [[ $blk -ne $trunc_blk ]]; then
26456 $(which stat) $DIR/$tfile
26457 error "Expected Block $trunc_blk got $blk for $tfile"
26460 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
26461 error "Expected Size $trunc_sz got $sz for $tfile"
26466 # Create file with a hole and write actual 65536 bytes which aligned
26467 # with 4K and 64K PAGE_SIZE. Block count must be 128.
26470 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 seek=5 conv=fsync ||
26471 error "Create file : $DIR/$tfile"
26474 # Truncate to size $trunc_sz bytes. Strip tail blocks and leave only 8
26475 # blocks. The block count must drop to 8.
26477 trunc_sz=$(($(stat --format=%s $DIR/$tfile) -
26478 ((bs - grant_blk_size) + 1)))
26479 $TRUNCATE $DIR/$tfile $trunc_sz ||
26480 error "truncate $tfile to $trunc_sz failed"
26482 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
26483 sz=$(stat --format=%s $DIR/$tfile)
26484 blk=$(stat --format=%b $DIR/$tfile)
26486 if [[ $blk -ne $trunc_bsz ]]; then
26487 $(which stat) $DIR/$tfile
26488 error "Expected Block $trunc_bsz got $blk for $tfile"
26491 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
26492 error "Expected Size $trunc_sz got $sz for $tfile"
26494 run_test 317 "Verify blocks get correctly update after truncate"
26497 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
26498 local old_max_active=$($LCTL get_param -n \
26499 ${llite_name}.max_read_ahead_async_active \
26502 $LCTL set_param llite.*.max_read_ahead_async_active=256
26503 local max_active=$($LCTL get_param -n \
26504 ${llite_name}.max_read_ahead_async_active \
26506 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
26508 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
26509 error "set max_read_ahead_async_active should succeed"
26511 $LCTL set_param llite.*.max_read_ahead_async_active=512
26512 max_active=$($LCTL get_param -n \
26513 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
26514 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
26516 # restore @max_active
26517 [ $old_max_active -ne 0 ] && $LCTL set_param \
26518 llite.*.max_read_ahead_async_active=$old_max_active
26520 local old_threshold=$($LCTL get_param -n \
26521 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
26522 local max_per_file_mb=$($LCTL get_param -n \
26523 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
26525 local invalid=$(($max_per_file_mb + 1))
26527 llite.*.read_ahead_async_file_threshold_mb=$invalid\
26528 && error "set $invalid should fail"
26530 local valid=$(($invalid - 1))
26532 llite.*.read_ahead_async_file_threshold_mb=$valid ||
26533 error "set $valid should succeed"
26534 local threshold=$($LCTL get_param -n \
26535 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
26536 [ $threshold -eq $valid ] || error \
26537 "expect threshold $valid got $threshold"
26539 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
26541 run_test 318 "Verify async readahead tunables"
26544 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
26546 local before=$(date +%s)
26548 local mdir=$DIR/$tdir
26549 local file=$mdir/xxx
26551 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
26554 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
26555 $LCTL set_param fail_val=5 fail_loc=0x8000032c
26556 $LFS migrate -m1 $mdir &
26559 dd if=$file of=/dev/null
26561 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
26562 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
26564 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
26566 run_test 319 "lost lease lock on migrate error"
26569 (( $OST1_VERSION >= $(version_code 2.15.58.96) )) ||
26570 skip "Need OST version at least 2.15.58.96"
26571 [[ "$ost1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
26573 check_set_fallocate_or_skip
26574 do_facet ost1 "$LCTL set_param osd-ldiskfs.delayed_unlink_mb=1MiB"
26577 do_facet ost1 $LCTL set_param debug=+inode
26578 do_facet ost1 $LCTL clear
26581 for ((i = 0; i < $files; i++)); do
26582 fallocate -l 1280k $DIR/$tdir/$tfile.$i ||
26583 error "fallocate 1280k $DIR/$tdir/$tfile.$i failed"
26585 local min=$(($($LFS find $DIR/$tdir --ost 0 | wc -l) / 2))
26587 for ((i = 0; i < $files; i++)); do
26588 unlink $DIR/$tdir/$tfile.$i ||
26589 error "unlink $DIR/$tdir/$tfile.$i failed"
26595 for (( loop = 0; loop < 30 && count < min; loop++)); do
26597 (( count += $(do_facet ost1 $LCTL dk | grep -c "delayed iput")))
26598 echo "Count[$loop]: $count"
26600 (( count >= min )) || error "$count < $min delayed iput after $loop s"
26602 run_test 360 "ldiskfs unlink in a separate thread"
26604 test_398a() { # LU-4198
26605 local ost1_imp=$(get_osc_import_name client ost1)
26606 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
26609 $LFS setstripe -c 1 -i 0 $DIR/$tfile
26610 stack_trap "rm -f $DIR/$tfile"
26611 $LCTL set_param ldlm.namespaces.*.lru_size=clear
26613 # request a new lock on client
26614 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
26616 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
26617 local lock_count=$($LCTL get_param -n \
26618 ldlm.namespaces.$imp_name.lru_size)
26619 [[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
26621 $LCTL set_param ldlm.namespaces.$imp_name.lru_size=clear
26623 # no lock cached, should use lockless DIO and not enqueue new lock
26624 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
26625 lock_count=$($LCTL get_param -n \
26626 ldlm.namespaces.$imp_name.lru_size)
26627 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
26629 $LCTL set_param ldlm.namespaces.$imp_name.lru_size=clear
26631 # no lock cached, should use locked DIO append
26632 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct oflag=append \
26633 conv=notrunc || error "DIO append failed"
26634 lock_count=$($LCTL get_param -n \
26635 ldlm.namespaces.$imp_name.lru_size)
26636 [[ $lock_count -ne 0 ]] || error "lock still must be held by DIO append"
26638 run_test 398a "direct IO should cancel lock otherwise lockless"
26640 test_398b() { # LU-4198
26641 local before=$(date +%s)
26645 which fio || skip_env "no fio installed"
26646 $LFS setstripe -c -1 -S 1M $DIR/$tfile
26647 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
26649 # Single page, multiple pages, stripe size, 4*stripe size
26650 for bsize in $(( $PAGE_SIZE )) $(( 4*$PAGE_SIZE )) 1048576 4194304; do
26651 echo "mix direct rw ${bsize} by fio with $njobs jobs..."
26652 fio --name=rand-rw --rw=randrw --bs=$bsize --direct=1 \
26653 --numjobs=$njobs --fallocate=none \
26654 --iodepth=16 --allow_file_create=0 \
26655 --size=$((size/njobs))M \
26656 --filename=$DIR/$tfile &
26659 echo "mix buffer rw ${bsize} by fio with $njobs jobs..."
26660 fio --name=rand-rw --rw=randrw --bs=$bsize \
26661 --numjobs=$njobs --fallocate=none \
26662 --iodepth=16 --allow_file_create=0 \
26663 --size=$((size/njobs))M \
26664 --filename=$DIR/$tfile || true
26668 evict=$(do_facet client $LCTL get_param \
26669 osc.$FSNAME-OST*-osc-*/state |
26670 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
26672 [ -z "$evict" ] || [[ $evict -le $before ]] ||
26673 (do_facet client $LCTL get_param \
26674 osc.$FSNAME-OST*-osc-*/state;
26675 error "eviction happened: $evict before:$before")
26679 run_test 398b "DIO and buffer IO race"
26681 test_398c() { # LU-4198
26682 local ost1_imp=$(get_osc_import_name client ost1)
26683 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
26686 which fio || skip_env "no fio installed"
26688 saved_debug=$($LCTL get_param -n debug)
26689 $LCTL set_param debug=0
26691 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
26692 ((size /= 1024)) # by megabytes
26693 ((size /= 2)) # write half of the OST at most
26694 [ $size -gt 40 ] && size=40 #reduce test time anyway
26696 $LFS setstripe -c 1 $DIR/$tfile
26698 # it seems like ldiskfs reserves more space than necessary if the
26699 # writing blocks are not mapped, so it extends the file firstly
26700 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
26701 cancel_lru_locks osc
26703 # clear and verify rpc_stats later
26704 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
26707 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
26708 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
26709 --numjobs=$njobs --fallocate=none --ioengine=libaio \
26710 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
26711 --filename=$DIR/$tfile
26712 [ $? -eq 0 ] || error "fio write error"
26714 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
26715 error "Locks were requested while doing AIO"
26717 # get the percentage of 1-page I/O
26718 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
26719 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
26721 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
26723 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
26724 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
26725 --numjobs=$njobs --fallocate=none --ioengine=libaio \
26726 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
26727 --filename=$DIR/$tfile
26728 [ $? -eq 0 ] || error "fio mixed read write error"
26730 echo "AIO with large block size ${size}M"
26731 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
26732 --numjobs=1 --fallocate=none --ioengine=libaio \
26733 --iodepth=16 --allow_file_create=0 --size=${size}M \
26734 --filename=$DIR/$tfile
26735 [ $? -eq 0 ] || error "fio large block size failed"
26738 $LCTL set_param debug="$saved_debug"
26740 run_test 398c "run fio to test AIO"
26742 test_398d() { # LU-13846
26743 which aiocp || skip_env "no aiocp installed"
26744 local aio_file=$DIR/$tfile.aio
26746 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
26748 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
26749 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
26750 stack_trap "rm -f $DIR/$tfile $aio_file"
26752 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
26754 # test memory unaligned aio
26755 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file ||
26756 error "unaligned aio failed"
26757 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
26759 rm -f $DIR/$tfile $aio_file
26761 run_test 398d "run aiocp to verify block size > stripe size"
26764 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
26765 touch $DIR/$tfile.new
26766 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
26768 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
26770 test_398f() { # LU-14687
26771 which aiocp || skip_env "no aiocp installed"
26772 local aio_file=$DIR/$tfile.aio
26774 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
26776 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
26777 stack_trap "rm -f $DIR/$tfile $aio_file"
26779 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
26780 $LCTL set_param fail_loc=0x1418
26781 # make sure we don't crash and fail properly
26782 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
26783 error "aio with page allocation failure succeeded"
26784 $LCTL set_param fail_loc=0
26785 diff $DIR/$tfile $aio_file
26786 [[ $? != 0 ]] || error "no diff after failed aiocp"
26788 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
26790 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
26791 # stripe and i/o size must be > stripe size
26792 # Old style synchronous DIO waits after submitting each chunk, resulting in a
26793 # single RPC in flight. This test shows async DIO submission is working by
26794 # showing multiple RPCs in flight.
26795 test_398g() { # LU-13798
26796 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
26798 # We need to do some i/o first to acquire enough grant to put our RPCs
26799 # in flight; otherwise a new connection may not have enough grant
26801 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
26802 error "parallel dio failed"
26803 stack_trap "rm -f $DIR/$tfile"
26805 # Reduce RPC size to 1M to avoid combination in to larger RPCs
26806 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
26807 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
26808 stack_trap "$LCTL set_param -n $pages_per_rpc"
26810 # Recreate file so it's empty
26812 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
26813 #Pause rpc completion to guarantee we see multiple rpcs in flight
26814 #define OBD_FAIL_OST_BRW_PAUSE_BULK
26815 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
26816 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
26819 $LCTL set_param osc.*.rpc_stats=c
26821 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
26822 error "parallel dio failed"
26823 stack_trap "rm -f $DIR/$tfile"
26825 $LCTL get_param osc.*-OST0000-*.rpc_stats
26826 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
26827 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
26828 grep "8:" | awk '{print $8}')
26829 # We look at the "8 rpcs in flight" field, and verify A) it is present
26830 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
26831 # as expected for an 8M DIO to a file with 1M stripes.
26832 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
26834 # Verify turning off parallel dio works as expected
26836 $LCTL set_param osc.*.rpc_stats=c
26837 $LCTL set_param llite.*.parallel_dio=0
26838 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
26840 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
26841 error "dio with parallel dio disabled failed"
26843 # Ideally, we would see only one RPC in flight here, but there is an
26844 # unavoidable race between i/o completion and RPC in flight counting,
26845 # so while only 1 i/o is in flight at a time, the RPC in flight counter
26846 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
26847 # So instead we just verify it's always < 8.
26848 $LCTL get_param osc.*-OST0000-*.rpc_stats
26849 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
26850 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
26851 grep '^$' -B1 | grep . | awk '{print $1}')
26852 [ $ret != "8:" ] ||
26853 error "we should see fewer than 8 RPCs in flight (saw $ret)"
26855 run_test 398g "verify parallel dio async RPC submission"
26857 test_398h() { # LU-13798
26858 local dio_file=$DIR/$tfile.dio
26860 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
26862 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
26863 stack_trap "rm -f $DIR/$tfile $dio_file"
26865 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
26866 error "parallel dio failed"
26867 diff $DIR/$tfile $dio_file
26868 [[ $? == 0 ]] || error "file diff after aiocp"
26870 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
26872 test_398i() { # LU-13798
26873 local dio_file=$DIR/$tfile.dio
26875 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
26877 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
26878 stack_trap "rm -f $DIR/$tfile $dio_file"
26880 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
26881 $LCTL set_param fail_loc=0x1418
26882 # make sure we don't crash and fail properly
26883 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
26884 error "parallel dio page allocation failure succeeded"
26885 diff $DIR/$tfile $dio_file
26886 [[ $? != 0 ]] || error "no diff after failed aiocp"
26888 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
26890 test_398j() { # LU-13798
26891 # Stripe size > RPC size but less than i/o size tests split across
26892 # stripes and RPCs for individual i/o op
26893 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
26895 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
26896 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
26897 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
26898 stack_trap "$LCTL set_param -n $pages_per_rpc"
26900 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
26901 error "parallel dio write failed"
26902 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
26904 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
26905 error "parallel dio read failed"
26906 diff $DIR/$tfile $DIR/$tfile.2
26907 [[ $? == 0 ]] || error "file diff after parallel dio read"
26909 run_test 398j "test parallel dio where stripe size > rpc_size"
26911 test_398k() { # LU-13798
26912 wait_delete_completed
26915 # 4 stripe file; we will cause out of space on OST0
26916 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
26918 # Fill OST0 (if it's not too large)
26919 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
26921 if [[ $ORIGFREE -gt $MAXFREE ]]; then
26922 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
26924 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
26925 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
26926 error "dd should fill OST0"
26927 stack_trap "rm -f $DIR/$tfile.1"
26929 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
26933 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
26934 error "file is not 0 bytes in size"
26936 # dd above should not succeed, but don't error until here so we can
26937 # get debug info above
26939 error "parallel dio write with enospc succeeded"
26940 stack_trap "rm -f $DIR/$tfile"
26942 run_test 398k "test enospc on first stripe"
26944 test_398l() { # LU-13798
26945 wait_delete_completed
26948 # 4 stripe file; we will cause out of space on OST0
26949 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
26950 # happens on the second i/o chunk we issue
26951 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
26953 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
26954 stack_trap "rm -f $DIR/$tfile"
26956 # Fill OST0 (if it's not too large)
26957 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
26959 if [[ $ORIGFREE -gt $MAXFREE ]]; then
26960 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
26962 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
26963 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
26964 error "dd should fill OST0"
26965 stack_trap "rm -f $DIR/$tfile.1"
26967 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
26969 stack_trap "rm -f $DIR/$tfile.2"
26971 # Check that short write completed as expected
26972 ls -la $DIR/$tfile.2
26973 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
26974 error "file is not 1M in size"
26976 # dd above should not succeed, but don't error until here so we can
26977 # get debug info above
26979 error "parallel dio write with enospc succeeded"
26981 # Truncate source file to same length as output file and diff them
26982 $TRUNCATE $DIR/$tfile 1048576
26983 diff $DIR/$tfile $DIR/$tfile.2
26984 [[ $? == 0 ]] || error "data incorrect after short write"
26986 run_test 398l "test enospc on intermediate stripe/RPC"
26988 test_398m() { # LU-13798
26989 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
26991 # Set up failure on OST0, the first stripe:
26992 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
26993 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
26994 # OST0 is on ost1, OST1 is on ost2.
26995 # So this fail_val specifies OST0
26996 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
26997 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
26999 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
27000 error "parallel dio write with failure on first stripe succeeded"
27001 stack_trap "rm -f $DIR/$tfile"
27002 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
27004 # Place data in file for read
27005 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
27006 error "parallel dio write failed"
27008 # Fail read on OST0, first stripe
27009 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
27010 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
27011 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
27012 error "parallel dio read with error on first stripe succeeded"
27013 rm -f $DIR/$tfile.2
27014 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
27016 # Switch to testing on OST1, second stripe
27017 # Clear file contents, maintain striping
27019 # Set up failure on OST1, second stripe:
27020 do_facet ost2 $LCTL set_param fail_loc=0x20e fail_val=2
27021 stack_trap "do_facet ost2 $LCTL set_param fail_loc=0"
27023 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
27024 error "parallel dio write with failure on second stripe succeeded"
27025 stack_trap "rm -f $DIR/$tfile"
27026 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
27028 # Place data in file for read
27029 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
27030 error "parallel dio write failed"
27032 # Fail read on OST1, second stripe
27033 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
27034 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
27035 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
27036 error "parallel dio read with error on second stripe succeeded"
27037 rm -f $DIR/$tfile.2
27038 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
27040 run_test 398m "test RPC failures with parallel dio"
27042 # Parallel submission of DIO should not cause problems for append, but it's
27043 # important to verify.
27044 test_398n() { # LU-13798
27045 $LFS setstripe -C 2 -S 1M $DIR/$tfile
27047 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
27048 error "dd to create source file failed"
27049 stack_trap "rm -f $DIR/$tfile"
27051 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
27052 error "parallel dio write with failure on second stripe succeeded"
27053 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
27054 diff $DIR/$tfile $DIR/$tfile.1
27055 [[ $? == 0 ]] || error "data incorrect after append"
27058 run_test 398n "test append with parallel DIO"
27061 directio rdwr $DIR/$tfile 0 1 1 || error "bad KMS"
27063 run_test 398o "right kms with DIO"
27067 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
27068 which aiocp || skip_env "no aiocp installed"
27070 local stripe_size=$((1024 * 1024)) #1 MiB
27071 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
27072 local file_size=$((25 * stripe_size))
27074 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
27075 stack_trap "rm -f $DIR/$tfile*"
27076 # Just a bit bigger than the largest size in the test set below
27077 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
27078 error "buffered i/o to create file failed"
27080 for bs in $PAGE_SIZE $((PAGE_SIZE * 4)) $stripe_size \
27081 $((stripe_size * 4)); do
27083 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
27085 echo "bs: $bs, file_size $file_size"
27086 aiocp -a $PAGE_SIZE -b $bs -s $file_size -f O_DIRECT \
27087 $DIR/$tfile.1 $DIR/$tfile.2 &
27089 # Buffered I/O with similar but not the same block size
27090 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 \
27097 if (( rc1 != 0 )); then
27098 error "aio copy 1 w/bsize $bs failed: $rc1"
27100 if (( rc2 != 0 )); then
27101 error "buffered copy 2 w/bsize $bs failed: $rc2"
27104 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
27105 error "size incorrect"
27106 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
27107 error "files differ, bsize $bs"
27108 rm -f $DIR/$tfile.2
27111 run_test 398p "race aio with buffered i/o"
27115 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
27117 local stripe_size=$((1024 * 1024)) #1 MiB
27118 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
27119 local file_size=$((25 * stripe_size))
27121 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
27122 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
27124 # Just a bit bigger than the largest size in the test set below
27125 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
27126 error "buffered i/o to create file failed"
27128 for bs in $PAGE_SIZE $((PAGE_SIZE * 4)) $stripe_size \
27129 $((stripe_size * 4)); do
27131 echo "bs: $bs, file_size $file_size"
27132 dd if=$DIR/$tfile.1 bs=$((bs *2 )) of=$DIR/tfile.2 \
27133 conv=notrunc oflag=direct iflag=direct &
27135 # Buffered I/O with similar but not the same block size
27136 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 \
27143 if (( rc1 != 0 )); then
27144 error "dio copy 1 w/bsize $bs failed: $rc1"
27146 if (( rc2 != 0 )); then
27147 error "buffered copy 2 w/bsize $bs failed: $rc2"
27150 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
27151 error "size incorrect"
27152 diff $DIR/$tfile.1 $DIR/$tfile.2 ||
27153 error "files differ, bsize $bs"
27158 run_test 398q "race dio with buffered i/o"
27161 local read_write=$1
27162 if [ "$read_write" = "write" ]; then
27163 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
27164 elif [ "$read_write" = "read" ]; then
27165 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
27167 error "argument error"
27170 # turn off debug for performance testing
27171 local saved_debug=$($LCTL get_param -n debug)
27172 $LCTL set_param debug=0
27174 $LFS setstripe -c 1 -i 0 $DIR/$tfile
27176 # get ost1 size - $FSNAME-OST0000
27177 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
27178 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
27179 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
27181 if [ "$read_write" = "read" ]; then
27182 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
27185 local start_time=$(date +%s.%N)
27186 $dd_cmd bs=1M count=$blocks oflag=sync ||
27187 error "real dd $read_write error"
27188 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
27190 if [ "$read_write" = "write" ]; then
27194 # define OBD_FAIL_OST_FAKE_RW 0x238
27195 do_facet ost1 $LCTL set_param fail_loc=0x238
27197 local start_time=$(date +%s.%N)
27198 $dd_cmd bs=1M count=$blocks oflag=sync ||
27199 error "fake dd $read_write error"
27200 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
27202 if [ "$read_write" = "write" ]; then
27204 cancel_lru_locks osc
27205 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
27206 error "$tfile size not $blocks MB"
27208 do_facet ost1 $LCTL set_param fail_loc=0
27210 echo "fake $read_write $duration_fake vs. normal $read_write" \
27211 "$duration in seconds"
27212 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
27213 error_not_in_vm "fake write is slower"
27215 $LCTL set_param -n debug="$saved_debug"
27218 test_399a() { # LU-7655 for OST fake write
27219 remote_ost_nodsh && skip "remote OST with nodsh"
27223 run_test 399a "fake write should not be slower than normal write"
27225 test_399b() { # LU-8726 for OST fake read
27226 remote_ost_nodsh && skip "remote OST with nodsh"
27227 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
27228 skip_env "ldiskfs only test"
27233 run_test 399b "fake read should not be slower than normal read"
27235 test_400a() { # LU-1606, was conf-sanity test_74
27236 if ! which $CC > /dev/null 2>&1; then
27237 skip_env "$CC is not installed"
27240 local extra_flags=''
27241 local out=$TMP/$tfile
27242 local prefix=/usr/include/lustre
27245 # Oleg removes .c files in his test rig so test if any c files exist
27246 [[ -n "$(ls -A $LUSTRE_TESTS_API_DIR)" ]] ||
27247 skip_env "Needed .c test files are missing"
27249 if ! [[ -d $prefix ]]; then
27250 # Assume we're running in tree and fixup the include path.
27251 extra_flags+=" -I$LUSTRE/../lnet/include/uapi"
27252 extra_flags+=" -I$LUSTRE/include/uapi -I$LUSTRE/include"
27253 extra_flags+=" -L$LUSTRE/utils/.libs"
27256 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
27257 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
27258 error "client api broken"
27262 run_test 400a "Lustre client api program can compile and link"
27264 test_400b() { # LU-1606, LU-5011
27266 local out=$TMP/$tfile
27267 local prefix=/usr/include/linux/lustre
27269 # We use a hard coded prefix so that this test will not fail
27270 # when run in tree. There are headers in lustre/include/lustre/
27271 # that are not packaged (like lustre_idl.h) and have more
27272 # complicated include dependencies (like config.h and lnet/types.h).
27273 # Since this test about correct packaging we just skip them when
27274 # they don't exist (see below) rather than try to fixup cppflags.
27276 if ! which $CC > /dev/null 2>&1; then
27277 skip_env "$CC is not installed"
27280 for header in $prefix/*.h; do
27281 if ! [[ -f "$header" ]]; then
27285 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
27286 continue # lustre_ioctl.h is internal header
27289 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
27290 error "cannot compile '$header'"
27294 run_test 400b "packaged headers can be compiled"
27296 test_401a() { #LU-7437
27297 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
27298 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
27300 #count the number of parameters by "list_param -R"
27301 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
27302 #count the number of parameters by listing proc files
27303 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
27304 echo "proc_dirs='$proc_dirs'"
27305 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
27306 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
27309 [ $params -eq $procs ] ||
27310 error "found $params parameters vs. $procs proc files"
27312 # test the list_param -D option only returns directories
27313 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
27314 #count the number of parameters by listing proc directories
27315 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
27318 [ $params -eq $procs ] ||
27319 error "found $params parameters vs. $procs proc files"
27321 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
27324 # jobid_var may not allow arbitrary values, so use jobid_name
27326 if $LCTL list_param jobid_name > /dev/null 2>&1; then
27327 local testname=jobid_name tmp='testing%p'
27329 local testname=jobid_var tmp=testing
27332 local save=$($LCTL get_param -n $testname)
27334 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
27335 error "no error returned when setting bad parameters"
27337 local jobid_new=$($LCTL get_param -n foe $testname baz)
27338 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
27340 $LCTL set_param -n fog=bam $testname=$save bat=fog
27341 local jobid_old=$($LCTL get_param -n foe $testname bag)
27342 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
27344 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
27347 # jobid_var may not allow arbitrary values, so use jobid_name
27349 if $LCTL list_param jobid_name > /dev/null 2>&1; then
27350 local testname=jobid_name
27352 local testname=jobid_var
27355 local jobid_var_old=$($LCTL get_param -n $testname)
27356 local jobid_var_new
27358 $LCTL set_param $testname= &&
27359 error "no error returned for 'set_param a='"
27361 jobid_var_new=$($LCTL get_param -n $testname)
27362 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
27363 error "$testname was changed by setting without value"
27365 $LCTL set_param $testname &&
27366 error "no error returned for 'set_param a'"
27368 jobid_var_new=$($LCTL get_param -n $testname)
27369 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
27370 error "$testname was changed by setting without value"
27372 run_test 401c "Verify 'lctl set_param' without value fails in either format."
27375 # jobid_var may not allow arbitrary values, so use jobid_name
27377 if $LCTL list_param jobid_name > /dev/null 2>&1; then
27378 local testname=jobid_name new_value='foo=bar%p'
27380 local testname=jobid_var new_valuie=foo=bar
27383 local jobid_var_old=$($LCTL get_param -n $testname)
27384 local jobid_var_new
27386 $LCTL set_param $testname=$new_value ||
27387 error "'set_param a=b' did not accept a value containing '='"
27389 jobid_var_new=$($LCTL get_param -n $testname)
27390 [[ "$jobid_var_new" == "$new_value" ]] ||
27391 error "'set_param a=b' failed on a value containing '='"
27393 # Reset the $testname to test the other format
27394 $LCTL set_param $testname=$jobid_var_old
27395 jobid_var_new=$($LCTL get_param -n $testname)
27396 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
27397 error "failed to reset $testname"
27399 $LCTL set_param $testname $new_value ||
27400 error "'set_param a b' did not accept a value containing '='"
27402 jobid_var_new=$($LCTL get_param -n $testname)
27403 [[ "$jobid_var_new" == "$new_value" ]] ||
27404 error "'set_param a b' failed on a value containing '='"
27406 $LCTL set_param $testname $jobid_var_old
27407 jobid_var_new=$($LCTL get_param -n $testname)
27408 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
27409 error "failed to reset $testname"
27411 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
27413 test_401e() { # LU-14779
27414 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
27415 error "lctl list_param MGC* failed"
27416 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
27417 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
27418 error "lctl get_param lru_size failed"
27420 run_test 401e "verify 'lctl get_param' works with NID in parameter"
27423 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
27424 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
27425 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
27426 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
27427 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
27428 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
27429 remote_mds_nodsh && skip "remote MDS with nodsh"
27431 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
27432 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
27433 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
27434 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
27435 echo "Touch failed - OK"
27437 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
27440 local file1=$DIR/$tfile.1
27441 local file2=$DIR/$tfile.2
27442 local tfile=$TMP/$tfile
27444 rm -f $file1 $file2 $tfile
27449 # 30 sec OBD_TIMEOUT in ll_getattr()
27450 # right before populating st_nlink
27451 $LCTL set_param fail_loc=0x80001409
27452 stat -c %h $file1 > $tfile &
27454 # create an alias, drop all locks and reclaim the dentry
27456 cancel_lru_locks mdc
27457 cancel_lru_locks osc
27458 sysctl -w vm.drop_caches=2
27462 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
27464 rm -f $tfile $file1 $file2
27466 run_test 403 "i_nlink should not drop to zero due to aliasing"
27468 test_404() { # LU-6601
27469 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
27470 skip "Need server version newer than 2.8.52"
27471 remote_mds_nodsh && skip "remote MDS with nodsh"
27473 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
27474 awk '/osp .*-osc-MDT/ { print $4}')
27477 for osp in $mosps; do
27478 echo "Deactivate: " $osp
27479 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
27480 local stat=$(do_facet $SINGLEMDS $LCTL dl |
27481 awk -vp=$osp '$4 == p { print $2 }')
27482 [ $stat = IN ] || {
27483 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
27484 error "deactivate error"
27486 echo "Activate: " $osp
27487 do_facet $SINGLEMDS $LCTL --device %$osp activate
27488 local stat=$(do_facet $SINGLEMDS $LCTL dl |
27489 awk -vp=$osp '$4 == p { print $2 }')
27490 [ $stat = UP ] || {
27491 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
27492 error "activate error"
27496 run_test 404 "validate manual {de}activated works properly for OSPs"
27499 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
27500 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
27501 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
27502 skip "Layout swap lock is not supported"
27504 check_swap_layouts_support
27505 check_swap_layout_no_dom $DIR
27507 test_mkdir $DIR/$tdir
27508 swap_lock_test -d $DIR/$tdir ||
27509 error "One layout swap locked test failed"
27511 run_test 405 "Various layout swap lock tests"
27514 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
27515 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
27516 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
27517 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27518 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
27519 skip "Need MDS version at least 2.8.50"
27521 local def_stripe_size=$($LFS getstripe -S $MOUNT)
27522 local test_pool=$TESTNAME
27524 pool_add $test_pool || error "pool_add failed"
27525 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
27526 error "pool_add_targets failed"
27528 save_layout_restore_at_exit $MOUNT
27530 # parent set default stripe count only, child will stripe from both
27531 # parent and fs default
27532 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
27533 error "setstripe $MOUNT failed"
27534 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
27535 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
27536 for i in $(seq 10); do
27537 local f=$DIR/$tdir/$tfile.$i
27538 touch $f || error "touch failed"
27539 local count=$($LFS getstripe -c $f)
27540 [ $count -eq $OSTCOUNT ] ||
27541 error "$f stripe count $count != $OSTCOUNT"
27542 local offset=$($LFS getstripe -i $f)
27543 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
27544 local size=$($LFS getstripe -S $f)
27545 [ $size -eq $((def_stripe_size * 2)) ] ||
27546 error "$f stripe size $size != $((def_stripe_size * 2))"
27547 local pool=$($LFS getstripe -p $f)
27548 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
27551 # change fs default striping, delete parent default striping, now child
27552 # will stripe from new fs default striping only
27553 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
27554 error "change $MOUNT default stripe failed"
27555 $LFS setstripe -c 0 $DIR/$tdir ||
27556 error "delete $tdir default stripe failed"
27557 for i in $(seq 11 20); do
27558 local f=$DIR/$tdir/$tfile.$i
27559 touch $f || error "touch $f failed"
27560 local count=$($LFS getstripe -c $f)
27561 [ $count -eq 1 ] || error "$f stripe count $count != 1"
27562 local offset=$($LFS getstripe -i $f)
27563 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
27564 local size=$($LFS getstripe -S $f)
27565 [ $size -eq $def_stripe_size ] ||
27566 error "$f stripe size $size != $def_stripe_size"
27567 local pool=$($LFS getstripe -p $f)
27568 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
27571 unlinkmany $DIR/$tdir/$tfile. 1 20
27573 local f=$DIR/$tdir/$tfile
27574 pool_remove_all_targets $test_pool $f
27575 pool_remove $test_pool $f
27577 run_test 406 "DNE support fs default striping"
27580 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
27581 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
27582 skip "Need MDS version at least 2.8.55"
27583 remote_mds_nodsh && skip "remote MDS with nodsh"
27585 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
27586 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
27587 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
27588 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
27589 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
27591 #define OBD_FAIL_DT_TXN_STOP 0x2019
27592 for idx in $(seq $MDSCOUNT); do
27593 do_facet mds$idx "lctl set_param fail_loc=0x2019"
27595 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
27596 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
27597 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
27600 run_test 407 "transaction fail should cause operation fail"
27603 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
27605 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
27606 lctl set_param fail_loc=0x8000040a
27607 # let ll_prepare_partial_page() fail
27608 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
27612 # create at least 100 unused inodes so that
27613 # shrink_icache_memory(0) should not return 0
27614 touch $DIR/$tfile-{0..100}
27615 rm -f $DIR/$tfile-{0..100}
27618 echo 2 > /proc/sys/vm/drop_caches
27620 run_test 408 "drop_caches should not hang due to page leaks"
27624 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
27626 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
27627 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
27628 touch $DIR/$tdir/guard || error "(2) Fail to create"
27630 local PREFIX=$(str_repeat 'A' 128)
27631 echo "Create 1K hard links start at $(date)"
27632 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
27633 error "(3) Fail to hard link"
27635 echo "Links count should be right although linkEA overflow"
27636 stat $DIR/$tdir/guard || error "(4) Fail to stat"
27637 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
27638 [ $linkcount -eq 1001 ] ||
27639 error "(5) Unexpected hard links count: $linkcount"
27641 echo "List all links start at $(date)"
27642 ls -l $DIR/$tdir/foo > /dev/null ||
27643 error "(6) Fail to list $DIR/$tdir/foo"
27645 echo "Unlink hard links start at $(date)"
27646 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
27647 error "(7) Fail to unlink"
27648 echo "Unlink hard links finished at $(date)"
27650 run_test 409 "Large amount of cross-MDTs hard links on the same file"
27654 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
27655 skip "Need client version at least 2.9.59"
27656 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
27657 skip "Need MODULES build"
27659 # Create a file, and stat it from the kernel
27660 local testfile=$DIR/$tfile
27663 local run_id=$RANDOM
27664 local my_ino=$(stat --format "%i" $testfile)
27666 # Try to insert the module. This will always fail as the
27667 # module is designed to not be inserted.
27668 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
27671 # Anything but success is a test failure
27673 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
27674 error "no inode match"
27676 run_test 410 "Test inode number returned from kernel thread"
27678 cleanup_test411_cgroup() {
27685 local cg_basedir=/sys/fs/cgroup/memory
27687 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
27688 skip "no setup for cgroup"
27690 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
27691 error "test file creation failed"
27692 cancel_lru_locks osc
27694 # Create a very small memory cgroup to force a slab allocation error
27695 local cgdir=$cg_basedir/osc_slab_alloc
27696 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
27697 trap "cleanup_test411_cgroup $cgdir" EXIT
27698 echo 2M > $cgdir/memory.kmem.limit_in_bytes
27699 echo 1M > $cgdir/memory.limit_in_bytes
27701 # Should not LBUG, just be killed by oom-killer
27702 # dd will return 0 even allocation failure in some environment.
27703 # So don't check return value
27704 bash -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
27705 cleanup_test411_cgroup $cgdir
27709 run_test 411a "Slab allocation error with cgroup does not LBUG"
27712 local cg_basedir=/sys/fs/cgroup/memory
27714 [ -e "$cg_basedir/memory.kmem.limit_in_bytes" ] ||
27715 skip "no setup for cgroup"
27716 $LFS setstripe -c 2 $DIR/$tfile || error "unable to setstripe"
27717 # (x86) testing suggests we can't reliably avoid OOM with a 64M-256M
27718 # limit, so we have 384M in cgroup
27719 # (arm) this seems to hit OOM more often than x86, so 1024M
27720 if [[ $(uname -m) = aarch64 ]]; then
27721 local memlimit_mb=1024
27723 local memlimit_mb=384
27726 # Create a cgroup and set memory limit
27727 # (tfile is used as an easy way to get a recognizable cgroup name)
27728 local cgdir=$cg_basedir/$tfile
27729 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
27730 stack_trap "cleanup_test411_cgroup $cgdir" EXIT
27731 echo $((memlimit_mb * 1024 * 1024)) > $cgdir/memory.limit_in_bytes
27733 echo "writing first file"
27734 # Write a file 4x the memory limit in size
27735 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile bs=1M count=$((memlimit_mb * 4))" ||
27736 error "(1) failed to write successfully"
27739 cancel_lru_locks osc
27742 $LFS setstripe -c 2 $DIR/$tfile || error "unable to setstripe"
27744 # Try writing at a larger block size
27745 # NB: if block size is >= 1/2 cgroup size, we sometimes get OOM killed
27746 # so test with 1/4 cgroup size (this seems reasonable to me - we do
27747 # need *some* memory to do IO in)
27748 echo "writing at larger block size"
27749 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile bs=64M count=$((memlimit_mb * 4 / 128))" ||
27750 error "(3) failed to write successfully"
27753 cancel_lru_locks osc
27755 $LFS setstripe -c 2 $DIR/$tfile.{1..4} || error "unable to setstripe"
27757 # Try writing multiple files at once
27758 echo "writing multiple files"
27759 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile.1 bs=32M count=$((memlimit_mb * 4 / 64))" &
27761 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile.2 bs=32M count=$((memlimit_mb * 4 / 64))" &
27763 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile.3 bs=32M count=$((memlimit_mb * 4 / 64))" &
27765 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile.4 bs=32M count=$((memlimit_mb * 4 / 64))" &
27776 if (( rc1 != 0)); then
27777 error "error $rc1 writing to file from $pid1"
27779 if (( rc2 != 0)); then
27780 error "error $rc2 writing to file from $pid2"
27782 if (( rc3 != 0)); then
27783 error "error $rc3 writing to file from $pid3"
27785 if (( rc4 != 0)); then
27786 error "error $rc4 writing to file from $pid4"
27790 cancel_lru_locks osc
27792 # These files can be large-ish (~1 GiB total), so delete them rather
27793 # than leave for later cleanup
27794 rm -f $DIR/$tfile.*
27797 run_test 411b "confirm Lustre can avoid OOM with reasonable cgroups limits"
27800 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
27801 (( $MDS1_VERSION >= $(version_code 2.10.55) )) ||
27802 skip "Need server version at least 2.10.55"
27804 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
27805 error "mkdir failed"
27806 $LFS getdirstripe $DIR/$tdir
27807 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
27808 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
27809 error "expect $((MDSCOUT - 1)) get $stripe_index"
27810 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
27811 [ $stripe_count -eq 2 ] ||
27812 error "expect 2 get $stripe_count"
27814 (( $MDS1_VERSION >= $(version_code 2.14.55) )) || return 0
27819 # subdirs should be on the same MDT as parent
27820 for i in $(seq 0 $((MDSCOUNT - 1))); do
27821 $LFS mkdir -i $i $DIR/$tdir/mdt$i || error "mkdir mdt$i failed"
27822 mkdir $DIR/$tdir/mdt$i/sub || error "mkdir sub failed"
27823 index=$($LFS getstripe -m $DIR/$tdir/mdt$i/sub)
27824 (( index == i )) || error "mdt$i/sub on MDT$index"
27827 # stripe offset -1, ditto
27828 for i in {1..10}; do
27829 $LFS mkdir -i -1 $DIR/$tdir/qos$i || error "mkdir qos$i failed"
27830 index=$($LFS getstripe -m $DIR/$tdir/qos$i)
27831 mkdir $DIR/$tdir/qos$i/sub || error "mkdir sub failed"
27832 index2=$($LFS getstripe -m $DIR/$tdir/qos$i/sub)
27833 (( index == index2 )) ||
27834 error "qos$i on MDT$index, sub on MDT$index2"
27837 local testdir=$DIR/$tdir/inherit
27839 $LFS mkdir -i 1 --max-inherit=3 $testdir || error "mkdir inherit failed"
27842 testdir=$testdir/s$i
27843 mkdir $testdir || error "mkdir $testdir failed"
27844 index=$($LFS getstripe -m $testdir)
27845 (( index == 1 )) ||
27846 error "$testdir on MDT$index"
27849 # not inherit any more
27850 testdir=$testdir/s3
27851 mkdir $testdir || error "mkdir $testdir failed"
27852 getfattr -d -m dmv $testdir | grep dmv &&
27853 error "default LMV set on $testdir" || true
27855 run_test 412 "mkdir on specific MDTs"
27857 TEST413_COUNT=${TEST413_COUNT:-200}
27860 # set_maxage() is used by test_413 only.
27861 # This is a helper function to set maxage. Does not return any value.
27862 # Input: maxage to set
27865 local lmv_qos_maxage
27866 local lod_qos_maxage
27867 local new_maxage=$1
27869 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
27870 $LCTL set_param lmv.*.qos_maxage=$new_maxage
27871 stack_trap "$LCTL set_param \
27872 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
27873 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
27874 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
27875 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
27876 lod.*.mdt_qos_maxage=$new_maxage
27877 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
27878 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
27881 generate_uneven_mdts() {
27893 echo "Check for uneven MDTs: "
27895 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
27896 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
27897 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
27899 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
27900 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
27903 for ((i = 1; i < ${#ffree[@]}; i++)); do
27904 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
27905 if [ $tmp -gt $max ]; then
27909 if [ $tmp -lt $min ]; then
27915 (( min > 0 )) || skip "low space on MDT$min_index"
27916 (( ${ffree[min_index]} > 0 )) ||
27917 skip "no free files on MDT$min_index"
27918 (( ${ffree[min_index]} < 10000000 )) ||
27919 skip "too many free files on MDT$min_index"
27921 # Check if we need to generate uneven MDTs
27922 local diff=$(((max - min) * 100 / min))
27923 local testdirp=$DIR/$tdir-fillmdt # parent fill folder
27924 local testdir # individual folder within $testdirp
27928 # fallocate is faster to consume space on MDT, if available
27929 if check_fallocate_supported mds$((min_index + 1)); then
27930 cmd="fallocate -l 128K "
27932 cmd="dd if=/dev/zero bs=128K count=1 of="
27935 echo "using cmd $cmd"
27936 for (( i = 0; diff < threshold; i++ )); do
27937 testdir=${testdirp}/$i
27938 [ -d $testdir ] && continue
27940 (( i % 10 > 0 )) || { $LFS df; $LFS df -i; }
27943 # generate uneven MDTs, create till $threshold% diff
27944 echo -n "weight diff=$diff% must be > $threshold% ..."
27945 echo "Fill MDT$min_index with $TEST413_COUNT files: loop $i"
27946 $LFS mkdir -i $min_index $testdir ||
27947 error "mkdir $testdir failed"
27948 $LFS setstripe -E 1M -L mdt $testdir ||
27949 error "setstripe $testdir failed"
27951 for (( f = 0; f < TEST413_COUNT; f++ )); do
27952 $cmd$testdir/f.$f &> /dev/null || error "$cmd $f failed"
27954 sync; sleep 1; sync
27956 # wait for QOS to update
27957 (( SECONDS < start + 2 )) && sleep $((start + 2 - SECONDS))
27959 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
27960 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
27961 max=$(((${ffree[max_index]} >> 8) *
27962 (${bavail[max_index]} * bsize >> 16)))
27963 min=$(((${ffree[min_index]} >> 8) *
27964 (${bavail[min_index]} * bsize >> 16)))
27965 (( min > 0 )) || skip "low space on MDT$min_index"
27966 diff=$(((max - min) * 100 / min))
27969 echo "MDT filesfree available: ${ffree[*]}"
27970 echo "MDT blocks available: ${bavail[*]}"
27971 echo "weight diff=$diff%"
27976 local stripe_count=$2
27977 local mdts=$(comma_list $(mdts_nodes))
27980 local lmv_qos_prio_free
27981 local lmv_qos_threshold_rr
27982 local lod_qos_prio_free
27983 local lod_qos_threshold_rr
27988 # @total is total directories created if it's testing plain
27989 # directories, otherwise it's total stripe object count for
27990 # striped directories test.
27991 # remote/striped directory unlinking is slow on zfs and may
27992 # timeout, test with fewer directories
27993 [ "$mds1_FSTYPE" = "zfs" ] && total=120 || total=240
27995 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
27996 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
27997 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
27999 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
28000 stack_trap "$LCTL set_param \
28001 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
28002 stack_trap "$LCTL set_param \
28003 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
28005 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
28006 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
28007 lod_qos_prio_free=${lod_qos_prio_free%%%}
28008 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
28009 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
28010 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
28011 stack_trap "do_nodes $mdts $LCTL set_param \
28012 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
28013 stack_trap "do_nodes $mdts $LCTL set_param \
28014 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
28016 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
28017 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
28019 testdir=$DIR/$tdir-s$stripe_count/rr
28021 local stripe_index=$($LFS getstripe -m $testdir)
28022 local test_mkdir_rr=true
28024 getfattr -d -m dmv -e hex $testdir | grep dmv
28025 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
28026 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
28027 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
28028 test_mkdir_rr=false
28033 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
28034 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
28036 stack_trap "unlinkmany -d $testdir/subdir $((total / stripe_count))"
28037 for (( i = 0; i < total / stripe_count; i++ )); do
28038 eval $mkdir_cmd $testdir/subdir$i ||
28039 error "$mkdir_cmd subdir$i failed"
28042 for (( i = 0; i < $MDSCOUNT; i++ )); do
28043 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
28044 echo "$count directories created on MDT$i"
28045 if $test_mkdir_rr; then
28046 (( count == total / stripe_count / MDSCOUNT )) ||
28047 error "subdirs are not evenly distributed"
28048 elif (( i == stripe_index )); then
28049 (( count == total / stripe_count )) ||
28050 error "$count subdirs created on MDT$i"
28052 (( count == 0 )) ||
28053 error "$count subdirs created on MDT$i"
28056 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
28057 count=$($LFS getdirstripe $testdir/* |
28058 grep -c -P "^\s+$i\t")
28059 echo "$count stripes created on MDT$i"
28060 # deviation should < 5% of average
28061 delta=$((count - total / MDSCOUNT))
28062 (( ${delta#-} <= total / MDSCOUNT / 20 )) ||
28063 error "stripes are not evenly distributed"
28068 echo "Check for uneven MDTs: "
28078 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
28079 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
28080 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
28082 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
28083 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
28086 for ((i = 1; i < ${#ffree[@]}; i++)); do
28087 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
28088 if [ $tmp -gt $max ]; then
28092 if [ $tmp -lt $min ]; then
28097 echo "stripe_count=$stripe_count min_idx=$min_index max_idx=$max_index"
28099 (( min > 0 )) || skip "low space on MDT$min_index"
28100 (( ${ffree[min_index]} < 10000000 )) ||
28101 skip "too many free files on MDT$min_index"
28103 generate_uneven_mdts 120
28105 echo "MDT filesfree available: ${ffree[*]}"
28106 echo "MDT blocks available: ${bavail[*]}"
28107 echo "weight diff=$(((max - min) * 100 / min))%"
28109 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
28111 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
28112 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
28113 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
28114 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
28115 # decrease statfs age, so that it can be updated in time
28116 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
28117 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
28121 testdir=$DIR/$tdir-s$stripe_count/qos
28123 stack_trap "unlinkmany -d $testdir/subdir $((total / stripe_count))"
28124 for (( i = 0; i < total / stripe_count; i++ )); do
28125 eval $mkdir_cmd $testdir/subdir$i ||
28126 error "$mkdir_cmd subdir$i failed"
28130 for (( i = 0; i < $MDSCOUNT; i++ )); do
28131 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
28132 (( count > max )) && max=$count
28133 echo "$count directories created on MDT$i : curmax=$max"
28136 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
28138 # D-value should > 10% of average
28139 (( max - min > total / stripe_count / MDSCOUNT / 10 )) ||
28140 error "subdirs shouldn't be evenly distributed: $max - $min <= $((total / stripe_count / MDSCOUNT / 10))"
28142 # ditto for stripes
28143 if (( stripe_count > 1 )); then
28145 for (( i = 0; i < $MDSCOUNT; i++ )); do
28146 count=$($LFS getdirstripe $testdir/* |
28147 grep -c -P "^\s+$i\t")
28148 (( count > max )) && max=$count
28149 echo "$count stripes created on MDT$i"
28152 min=$($LFS getdirstripe $testdir/* |
28153 grep -c -P "^\s+$min_index\t")
28154 (( max - min > total / MDSCOUNT / 10 )) ||
28155 error "stripes shouldn't be evenly distributed: $max - $min <= $((total / MDSCOUNT / 10))"
28167 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
28168 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
28169 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
28171 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
28173 for ((i = 1; i < ${#ffree[@]}; i++)); do
28174 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
28175 (( tmp < min )) && min=$tmp && min_index=$i
28182 [ $MDSCOUNT -lt 2 ] &&
28183 skip "We need at least 2 MDTs for this test"
28185 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
28186 skip "Need server version at least 2.12.52"
28188 local stripe_max=$((MDSCOUNT - 1))
28191 # let caller set maxage for latest result
28194 # fill MDT unevenly
28195 generate_uneven_mdts 120
28197 # test 4-stripe directory at most, otherwise it's too slow
28198 # We are being very defensive. Although Autotest uses 4 MDTs.
28199 # We make sure stripe_max does not go over 4.
28200 (( stripe_max > 4 )) && stripe_max=4
28201 # unlinking striped directory is slow on zfs, and may timeout, only test
28203 [ "$mds1_FSTYPE" == "zfs" ] && stripe_max=1
28204 for stripe_count in $(seq 1 $stripe_max); do
28205 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
28206 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
28207 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
28208 error "mkdir failed"
28209 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
28212 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
28215 [ $MDSCOUNT -lt 2 ] &&
28216 skip "We need at least 2 MDTs for this test"
28218 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
28219 skip "Need server version at least 2.12.52"
28221 local stripe_max=$((MDSCOUNT - 1))
28225 # let caller set maxage for latest result
28228 # fill MDT unevenly
28229 generate_uneven_mdts 120
28231 # test 4-stripe directory at most, otherwise it's too slow
28232 # We are being very defensive. Although Autotest uses 4 MDTs.
28233 # We make sure stripe_max does not go over 4.
28234 (( stripe_max > 4 )) && stripe_max=4
28235 [ "$mds1_FSTYPE" == "zfs" ] && stripe_max=1
28236 for stripe_count in $(seq 1 $stripe_max); do
28237 testdir=$DIR/$tdir-s$stripe_count
28238 mkdir $testdir || error "mkdir $testdir failed"
28239 mkdir $testdir/rr || error "mkdir rr failed"
28240 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
28241 error "mkdir qos failed"
28242 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
28243 $testdir/rr || error "setdirstripe rr failed"
28244 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
28245 error "setdirstripe failed"
28246 test_qos_mkdir "mkdir" $stripe_count
28249 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
28252 (( $MDSCOUNT >= 2 )) ||
28253 skip "We need at least 2 MDTs for this test"
28255 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
28256 skip "Need server version at least 2.14.51"
28261 local lmv_qos_maxage
28262 local lod_qos_maxage
28264 # let caller set maxage for latest result
28265 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
28266 $LCTL set_param lmv.*.qos_maxage=1
28267 stack_trap "$LCTL set_param \
28268 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
28269 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
28270 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
28271 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
28272 lod.*.mdt_qos_maxage=1
28273 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
28274 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
28276 # fill MDT unevenly
28277 generate_uneven_mdts 120
28279 testdir=$DIR/${tdir}-s1
28280 mkdir $testdir || error "mkdir $testdir failed"
28281 mkdir $testdir/rr || error "mkdir rr failed"
28282 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
28283 # default max_inherit is -1, default max_inherit_rr is 0
28284 $LFS setdirstripe -D -c 1 $testdir/rr ||
28285 error "setdirstripe rr failed"
28286 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
28287 error "setdirstripe qos failed"
28288 test_qos_mkdir "mkdir" 1
28290 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
28291 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
28292 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
28293 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
28294 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
28296 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
28297 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
28298 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
28299 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
28300 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
28301 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
28302 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
28303 error "level2 shouldn't have default LMV" || true
28305 run_test 413c "mkdir with default LMV max inherit rr"
28308 (( MDSCOUNT >= 2 )) ||
28309 skip "We need at least 2 MDTs for this test"
28311 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
28312 skip "Need server version at least 2.14.51"
28314 local lmv_qos_threshold_rr
28316 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
28318 stack_trap "$LCTL set_param \
28319 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
28321 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
28322 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
28323 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
28324 error "$tdir shouldn't have default LMV"
28325 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
28326 error "mkdir sub failed"
28328 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
28330 (( count == 100 )) || error "$count subdirs on MDT0"
28332 run_test 413d "inherit ROOT default LMV"
28335 (( MDSCOUNT >= 2 )) ||
28336 skip "We need at least 2 MDTs for this test"
28337 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
28338 skip "Need server version at least 2.14.55"
28340 local testdir=$DIR/$tdir
28341 local tmpfile=$TMP/temp.setdirstripe.stderr.$$
28343 local sub_max_inherit
28345 mkdir -p $testdir || error "failed to create $testdir"
28347 # set default max-inherit to -1 if stripe count is 0 or 1
28348 $LFS setdirstripe -D -c 1 $testdir ||
28349 error "failed to set default LMV"
28350 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
28351 (( max_inherit == -1 )) ||
28352 error "wrong max_inherit value $max_inherit"
28354 # set default max_inherit to a fixed value if stripe count is not 0 or 1
28355 $LFS setdirstripe -D -c -1 $testdir ||
28356 error "failed to set default LMV"
28357 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
28358 (( max_inherit > 0 )) ||
28359 error "wrong max_inherit value $max_inherit"
28361 # and the subdir will decrease the max_inherit by 1
28362 mkdir -p $testdir/subdir-1 || error "failed to make subdir"
28363 sub_max_inherit=$($LFS getdirstripe -D --max-inherit $testdir/subdir-1)
28364 (( sub_max_inherit == max_inherit - 1)) ||
28365 error "wrong max-inherit of subdir $sub_max_inherit"
28367 # check specified --max-inherit and warning message
28368 stack_trap "rm -f $tmpfile"
28369 $LFS setdirstripe -D -c 2 --max-inherit=-1 $testdir 2> $tmpfile ||
28370 error "failed to set default LMV"
28371 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
28372 (( max_inherit == -1 )) ||
28373 error "wrong max_inherit value $max_inherit"
28375 # check the warning messages
28376 if ! [[ $(cat $tmpfile) =~ "max-inherit=" ]]; then
28377 error "failed to detect warning string"
28380 run_test 413e "check default max-inherit value"
28382 test_fs_dmv_inherit()
28384 local testdir=$DIR/$tdir
28391 mkdir $testdir || error "mkdir $testdir failed"
28392 count=$($LFS getdirstripe -D -c $testdir)
28393 (( count == 1 )) ||
28394 error "$testdir default LMV count mismatch $count != 1"
28395 inherit=$($LFS getdirstripe -D -X $testdir)
28396 (( inherit == 3 - i )) ||
28397 error "$testdir default LMV max-inherit $inherit != $((3 - i))"
28398 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir)
28399 (( inherit_rr == 3 - i )) ||
28400 error "$testdir default LMV max-inherit-rr $inherit_rr != $((3 - i))"
28401 testdir=$testdir/sub
28404 mkdir $testdir || error "mkdir $testdir failed"
28405 count=$($LFS getdirstripe -D -c $testdir)
28406 (( count == 0 )) ||
28407 error "$testdir default LMV count not zero: $count"
28411 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
28413 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
28414 skip "Need server version at least 2.14.55"
28416 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
28417 error "dump $DIR default LMV failed"
28418 stack_trap "setfattr --restore=$TMP/dmv.ea"
28420 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
28421 error "set $DIR default LMV failed"
28423 test_fs_dmv_inherit
28425 run_test 413f "lfs getdirstripe -D list ROOT default LMV if it's not set on dir"
28428 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
28430 mkdir -p $DIR/$tdir/l2/l3/l4 || error "mkdir $tdir/l1/l2/l3 failed"
28431 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
28432 error "dump $DIR default LMV failed"
28433 stack_trap "setfattr --restore=$TMP/dmv.ea"
28435 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
28436 error "set $DIR default LMV failed"
28438 FILESET="$FILESET/$tdir/l2/l3/l4" mount_client $MOUNT2 ||
28439 error "mount $MOUNT2 failed"
28440 stack_trap "umount_client $MOUNT2"
28442 local saved_DIR=$DIR
28446 stack_trap "export DIR=$saved_DIR"
28448 # first check filesystem-wide default LMV inheritance
28449 test_fs_dmv_inherit || error "incorrect fs default LMV inheritance"
28451 # then check subdirs are spread to all MDTs
28452 createmany -d $DIR/s $((MDSCOUNT * 100)) || error "createmany failed"
28454 local count=$($LFS getstripe -m $DIR/s* | sort -u | wc -l)
28456 (( $count == $MDSCOUNT )) || error "dirs are spread to $count MDTs"
28458 run_test 413g "enforce ROOT default LMV on subdir mount"
28461 (( MDSCOUNT >= 2 )) ||
28462 skip "We need at least 2 MDTs for this test"
28464 (( MDS1_VERSION >= $(version_code 2.15.50.6) )) ||
28465 skip "Need server version at least 2.15.50.6"
28467 local lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
28469 stack_trap "$LCTL set_param \
28470 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
28471 $LCTL set_param lmv.*.qos_maxage=1
28475 local dir=$DIR/$tdir/l1/l2/l3/l4/l5
28476 local count=$((MDSCOUNT * 20))
28478 generate_uneven_mdts 50
28480 mkdir -p $dir || error "mkdir $dir failed"
28481 stack_trap "rm -rf $dir"
28482 $LFS setdirstripe -D -c 1 -i -1 --max-inherit=$depth \
28483 --max-inherit-rr=$rr_depth $dir
28485 for ((d=0; d < depth + 2; d++)); do
28487 for ((sub=0; sub < count; sub++)); do
28490 $LFS getdirstripe -i $dir/d* | sort | uniq -c | sort -nr
28491 local num=($($LFS getdirstripe -i $dir/d* | sort | uniq -c))
28492 # subdirs within $rr_depth should be created round-robin
28493 if (( d < rr_depth )); then
28494 (( ${num[0]} != count )) ||
28495 error "all objects created on MDT ${num[1]}"
28501 run_test 413h "don't stick to parent for round-robin dirs"
28504 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
28506 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
28507 skip "Need server version at least 2.14.55"
28509 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
28510 error "dump $DIR default LMV failed"
28511 stack_trap "setfattr --restore=$TMP/dmv.ea"
28513 local testdir=$DIR/$tdir
28518 $LFS setdirstripe -D -i-1 -c1 --max-inherit=$def_max \
28519 --max-inherit-rr=$def_max_rr $DIR ||
28520 error "set $DIR default LMV failed"
28522 for i in $(seq 2 3); do
28523 def_max=$((def_max - 1))
28524 (( def_max_rr == 0 )) || def_max_rr=$((def_max_rr - 1))
28527 # RR is decremented and keeps zeroed once exhausted
28528 count=$($LFS getdirstripe -D --max-inherit-rr $testdir)
28529 (( count == def_max_rr )) ||
28530 error_noexit "$testdir: max-inherit-rr $count != $def_max_rr"
28532 # max-inherit is decremented
28533 count=$($LFS getdirstripe -D --max-inherit $testdir)
28534 (( count == def_max )) ||
28535 error_noexit "$testdir: max-inherit $count != $def_max"
28537 testdir=$testdir/d$i
28540 # d3 is the last inherited from ROOT, no inheritance anymore
28541 # i.e. no the default layout anymore
28542 mkdir -p $testdir/d4/d5
28543 count=$($LFS getdirstripe -D --max-inherit $testdir)
28544 (( count == -1 )) ||
28545 error_noexit "$testdir: max-inherit $count != -1"
28547 local p_count=$($LFS getdirstripe -i $testdir)
28549 for i in $(seq 4 5); do
28550 testdir=$testdir/d$i
28552 # the root default layout is not applied once exhausted
28553 count=$($LFS getdirstripe -i $testdir)
28554 (( count == p_count )) ||
28555 error_noexit "$testdir: stripe-offset $count != parent offset $p_count"
28558 $LFS setdirstripe -i 0 $DIR/d2
28559 count=$($LFS getdirstripe -D --max-inherit $DIR/d2)
28560 (( count == -1 )) ||
28561 error_noexit "$DIR/d2: max-inherit non-striped default $count != -1"
28563 run_test 413i "check default layout inheritance"
28570 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
28571 unlinkmany $subdir/f. $TEST413_COUNT &
28575 for pid in $pids; do
28581 run_test 413z "413 test cleanup"
28584 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
28585 $LCTL set_param fail_loc=0x80000521
28586 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
28589 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
28592 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
28593 (( $MDS1_VERSION >= $(version_code 2.11.52) )) ||
28594 skip "Need server version at least 2.11.52"
28600 # this test may be slow on ZFS
28601 [[ "$mds1_FSTYPE" == "zfs" ]] && total=50
28603 # though this test is designed for striped directory, let's test normal
28604 # directory too since lock is always saved as CoS lock.
28605 test_mkdir $DIR/$tdir || error "mkdir $tdir"
28606 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
28607 stack_trap "unlinkmany $DIR/$tdir/$tfile. $total || true"
28608 # if looping with ONLY_REPEAT, wait for previous deletions to finish
28609 wait_delete_completed_mds
28611 # run a loop without concurrent touch to measure rename duration.
28612 # only for test debug/robustness, NOT part of COS functional test.
28613 local start_time=$SECONDS
28614 for ((i = 0; i < total; i++)); do
28615 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
28618 local baseline=$((SECONDS - start_time))
28619 echo "rename $total files without 'touch' took $baseline sec"
28626 local setattr_pid=$!
28628 # rename files back to original name so unlinkmany works
28629 start_time=$SECONDS
28630 for ((i = 0; i < total; i++)); do
28631 mrename $DIR/$tdir/$tfile-new.$i $DIR/$tdir/$tfile.$i\
28634 local duration=$((SECONDS - start_time))
28636 kill -9 $setattr_pid
28638 echo "rename $total files with 'touch' took $duration sec"
28639 (( max > 2 * baseline )) || max=$((2 * baseline + 5))
28640 (( duration <= max )) ||
28641 error_not_in_vm "rename took $duration > $max sec"
28643 run_test 415 "lock revoke is not missing"
28646 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
28647 skip "Need server version at least 2.11.55"
28649 # define OBD_FAIL_OSD_TXN_START 0x19a
28650 do_facet mds1 lctl set_param fail_loc=0x19a
28652 lfs mkdir -c $MDSCOUNT $DIR/$tdir
28656 run_test 416 "transaction start failure won't cause system hung"
28660 do_nodes $(comma_list $(mdts_nodes)) \
28661 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
28662 do_nodes $(comma_list $(mdts_nodes)) \
28663 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
28664 do_nodes $(comma_list $(mdts_nodes)) \
28665 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
28669 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
28670 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
28671 skip "Need MDS version at least 2.11.56"
28673 trap cleanup_417 RETURN EXIT
28675 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
28676 do_nodes $(comma_list $(mdts_nodes)) \
28677 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
28678 $LFS migrate -m 0 $DIR/$tdir.1 &&
28679 error "migrate dir $tdir.1 should fail"
28681 do_nodes $(comma_list $(mdts_nodes)) \
28682 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
28683 $LFS mkdir -i 1 $DIR/$tdir.2 &&
28684 error "create remote dir $tdir.2 should fail"
28686 do_nodes $(comma_list $(mdts_nodes)) \
28687 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
28688 $LFS mkdir -c 2 $DIR/$tdir.3 &&
28689 error "create striped dir $tdir.3 should fail"
28692 run_test 417 "disable remote dir, striped dir and dir migration"
28694 # Checks that the outputs of df [-i] and lfs df [-i] match
28696 # usage: check_lfs_df <blocks | inodes> <mountpoint>
28706 [ "$1" == "blocks" ] && inodes= || inodes="-i"
28708 for count in {1..100}; do
28709 do_nodes "$CLIENTS" \
28710 $LCTL set_param ldlm.namespaces.*.lru_size=clear
28713 # read the lines of interest
28714 df_out=($(df -P $inodes $dir | tail -n +2)) ||
28715 error "df $inodes $dir | tail -n +2 failed"
28716 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
28717 error "lfs df $inodes $dir | grep summary: failed"
28719 # skip first substrings of each output as they are different
28720 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
28721 # compare the two outputs
28723 # skip "available" on MDT until LU-13997 is fixed.
28724 #for i in {1..5}; do
28725 for i in 1 2 4 5; do
28726 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
28734 lfs df $inodes $dir
28735 error "df and lfs df $1 output mismatch: " \
28736 "df ${inodes}: ${df_out[*]}, " \
28737 "lfs df ${inodes}: ${lfs_df_out[*]}"
28742 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28744 local dir=$DIR/$tdir
28745 local numfiles=$((RANDOM % 4096 + 2))
28746 local numblocks=$((RANDOM % 256 + 1))
28748 wait_delete_completed
28751 # check block output
28752 check_lfs_df blocks $dir
28753 # check inode output
28754 check_lfs_df inodes $dir
28756 # create a single file and retest
28757 echo "Creating a single file and testing"
28758 createmany -o $dir/$tfile- 1 &>/dev/null ||
28759 error "creating 1 file in $dir failed"
28760 check_lfs_df blocks $dir
28761 check_lfs_df inodes $dir
28763 # create a random number of files
28764 echo "Creating $((numfiles - 1)) files and testing"
28765 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
28766 error "creating $((numfiles - 1)) files in $dir failed"
28768 # write a random number of blocks to the first test file
28769 echo "Writing $numblocks 4K blocks and testing"
28770 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
28771 count=$numblocks &>/dev/null ||
28772 error "dd to $dir/${tfile}-0 failed"
28775 check_lfs_df blocks $dir
28776 check_lfs_df inodes $dir
28778 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
28779 error "unlinking $numfiles files in $dir failed"
28781 run_test 418 "df and lfs df outputs match"
28785 local dir=$DIR/$tdir
28790 cancel_lru_locks mdc
28792 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
28793 $LCTL set_param fail_loc=0x1410
28795 $LCTL set_param fail_loc=0
28798 run_test 419 "Verify open file by name doesn't crash kernel"
28802 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
28803 skip "Need MDS version at least 2.12.53"
28805 local SAVE_UMASK=$(umask)
28806 local dir=$DIR/$tdir
28807 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
28811 mkdir -m03777 $dir/testdir
28812 ls -dn $dir/testdir
28813 # Need to remove trailing '.' when SELinux is enabled
28814 local dirperms=$(ls -dn $dir/testdir |
28815 awk '{ sub(/\.$/, "", $1); print $1}')
28816 [ $dirperms == "drwxrwsrwt" ] ||
28817 error "incorrect perms on $dir/testdir"
28819 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
28820 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
28821 ls -n $dir/testdir/testfile
28822 local fileperms=$(ls -n $dir/testdir/testfile |
28823 awk '{ sub(/\.$/, "", $1); print $1}')
28824 [ $fileperms == "-rwxr-xr-x" ] ||
28825 error "incorrect perms on $dir/testdir/testfile"
28829 run_test 420 "clear SGID bit on non-directories for non-members"
28836 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28837 skip "Need MDS version at least 2.12.54"
28839 test_mkdir $DIR/$tdir
28840 createmany -o $DIR/$tdir/f 3
28841 cnt=$(ls -1 $DIR/$tdir | wc -l)
28842 [ $cnt != 3 ] && error "unexpected #files: $cnt"
28844 fid1=$(lfs path2fid $DIR/$tdir/f1)
28845 fid2=$(lfs path2fid $DIR/$tdir/f2)
28846 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
28848 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
28849 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
28851 cnt=$(ls -1 $DIR/$tdir | wc -l)
28852 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
28854 rm -f $DIR/$tdir/f3 || error "can't remove f3"
28855 createmany -o $DIR/$tdir/f 3
28856 cnt=$(ls -1 $DIR/$tdir | wc -l)
28857 [ $cnt != 3 ] && error "unexpected #files: $cnt"
28859 fid1=$(lfs path2fid $DIR/$tdir/f1)
28860 fid2=$(lfs path2fid $DIR/$tdir/f2)
28861 echo "remove using fsname $FSNAME"
28862 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
28864 cnt=$(ls -1 $DIR/$tdir | wc -l)
28865 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
28867 run_test 421a "simple rm by fid"
28874 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28875 skip "Need MDS version at least 2.12.54"
28877 test_mkdir $DIR/$tdir
28878 createmany -o $DIR/$tdir/f 3
28879 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
28882 FID1=$(lfs path2fid $DIR/$tdir/f1)
28883 FID2=$(lfs path2fid $DIR/$tdir/f2)
28884 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
28886 kill -USR1 $MULTIPID
28889 cnt=$(ls $DIR/$tdir | wc -l)
28890 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
28892 run_test 421b "rm by fid on open file"
28898 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28899 skip "Need MDS version at least 2.12.54"
28901 test_mkdir $DIR/$tdir
28902 createmany -o $DIR/$tdir/f 3
28903 touch $DIR/$tdir/$tfile
28904 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
28905 cnt=$(ls -1 $DIR/$tdir | wc -l)
28906 [ $cnt != 184 ] && error "unexpected #files: $cnt"
28908 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
28909 $LFS rmfid $DIR $FID1 || error "rmfid failed"
28911 cnt=$(ls $DIR/$tdir | wc -l)
28912 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
28914 run_test 421c "rm by fid against hardlinked files"
28920 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28921 skip "Need MDS version at least 2.12.54"
28923 test_mkdir $DIR/$tdir
28924 createmany -o $DIR/$tdir/f 4097
28925 cnt=$(ls -1 $DIR/$tdir | wc -l)
28926 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
28928 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
28929 $LFS rmfid $DIR $FIDS || error "rmfid failed"
28931 cnt=$(ls $DIR/$tdir | wc -l)
28933 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
28935 run_test 421d "rmfid en masse"
28941 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
28942 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28943 skip "Need MDS version at least 2.12.54"
28945 mkdir -p $DIR/$tdir
28946 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
28947 createmany -o $DIR/$tdir/striped_dir/f 512
28948 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
28949 [ $cnt != 512 ] && error "unexpected #files: $cnt"
28951 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
28952 sed "s/[/][^:]*://g")
28953 $LFS rmfid $DIR $FIDS || error "rmfid failed"
28955 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
28957 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
28959 run_test 421e "rmfid in DNE"
28965 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28966 skip "Need MDS version at least 2.12.54"
28968 test_mkdir $DIR/$tdir
28970 cnt=$(ls -1 $DIR/$tdir | wc -l)
28971 [ $cnt != 1 ] && error "unexpected #files: $cnt"
28973 FID=$(lfs path2fid $DIR/$tdir/f)
28974 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
28975 # rmfid should fail
28976 cnt=$(ls -1 $DIR/$tdir | wc -l)
28977 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
28979 chmod a+rw $DIR/$tdir
28981 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
28982 # rmfid should fail
28983 cnt=$(ls -1 $DIR/$tdir | wc -l)
28984 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
28987 $RUNAS touch $DIR/$tdir/f
28988 FID=$(lfs path2fid $DIR/$tdir/f)
28989 echo "rmfid as root"
28990 $LFS rmfid $DIR $FID || error "rmfid as root failed"
28991 cnt=$(ls -1 $DIR/$tdir | wc -l)
28992 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
28995 $RUNAS touch $DIR/$tdir/f
28996 cnt=$(ls -1 $DIR/$tdir | wc -l)
28997 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
28998 FID=$(lfs path2fid $DIR/$tdir/f)
28999 # rmfid w/o user_fid2path mount option should fail
29000 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
29001 cnt=$(ls -1 $DIR/$tdir | wc -l)
29002 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
29004 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
29005 stack_trap "rmdir $tmpdir"
29006 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
29007 error "failed to mount client'"
29008 stack_trap "umount_client $tmpdir"
29010 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
29011 # rmfid should succeed
29012 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
29013 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
29015 # rmfid shouldn't allow to remove files due to dir's permission
29016 chmod a+rwx $tmpdir/$tdir
29017 touch $tmpdir/$tdir/f
29018 ls -la $tmpdir/$tdir
29019 FID=$(lfs path2fid $tmpdir/$tdir/f)
29020 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
29023 run_test 421f "rmfid checks permissions"
29029 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
29030 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
29031 skip "Need MDS version at least 2.12.54"
29033 mkdir -p $DIR/$tdir
29034 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
29035 createmany -o $DIR/$tdir/striped_dir/f 512
29036 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
29037 [ $cnt != 512 ] && error "unexpected #files: $cnt"
29039 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
29040 sed "s/[/][^:]*://g")
29042 rm -f $DIR/$tdir/striped_dir/f1*
29043 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
29044 removed=$((512 - cnt))
29046 # few files have been just removed, so we expect
29047 # rmfid to fail on their fids
29048 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
29049 [ $removed != $errors ] && error "$errors != $removed"
29051 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
29053 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
29055 run_test 421g "rmfid to return errors properly"
29067 (( MDS1_VERSION >= $(version_code 2.15.53) )) ||
29068 skip "Need MDS version at least 2.15.53"
29070 test_mkdir $DIR/$tdir
29071 test_mkdir $DIR/$tdir/subdir
29072 touch $DIR/$tdir/subdir/file0
29073 old_fid=$(lfs path2fid $DIR/$tdir/subdir/file0 | sed "s/[/][^:]*://g")
29074 echo File $DIR/$tdir/subdir/file0 FID $old_fid
29075 rm -f $DIR/$tdir/subdir/file0
29076 touch $DIR/$tdir/subdir/fileA
29077 fidA=$(lfs path2fid $DIR/$tdir/subdir/fileA | sed "s/[/][^:]*://g")
29078 echo File $DIR/$tdir/subdir/fileA FID $fidA
29079 touch $DIR/$tdir/subdir/fileB
29080 fidB=$(lfs path2fid $DIR/$tdir/subdir/fileB | sed "s/[/][^:]*://g")
29081 echo File $DIR/$tdir/subdir/fileB FID $fidB
29082 ln $DIR/$tdir/subdir/fileB $DIR/$tdir/subdir/fileB_hl
29083 touch $DIR/$tdir/subdir/fileC
29084 fidC=$(lfs path2fid $DIR/$tdir/subdir/fileC | sed "s/[/][^:]*://g")
29085 echo File $DIR/$tdir/subdir/fileC FID $fidC
29086 ln $DIR/$tdir/subdir/fileC $DIR/$tdir/fileC
29087 touch $DIR/$tdir/fileD
29088 fidD=$(lfs path2fid $DIR/$tdir/fileD | sed "s/[/][^:]*://g")
29089 echo File $DIR/$tdir/fileD FID $fidD
29091 # mount another client mount point with subdirectory mount
29092 export FILESET=/$tdir/subdir
29093 mount_other=${MOUNT}_other
29094 mount_client $mount_other ${MOUNT_OPTS}
29097 (( mount_ret == 0 )) || error "mount $mount_other failed"
29099 echo Removing FIDs:
29100 echo $LFS rmfid $mount_other $old_fid $fidA $fidD $fidB $fidC
29101 $LFS rmfid $mount_other $old_fid $fidA $fidD $fidB $fidC
29104 umount_client $mount_other || error "umount $mount_other failed"
29106 (( rmfid_ret != 0 )) || error "rmfid should have failed"
29108 # fileA should have been deleted
29109 stat $DIR/$tdir/subdir/fileA && error "fileA not deleted"
29111 # fileB should have been deleted
29112 stat $DIR/$tdir/subdir/fileB && error "fileB not deleted"
29114 # fileC should not have been deleted, fid also exists outside of fileset
29115 stat $DIR/$tdir/subdir/fileC || error "fileC deleted"
29117 # fileD should not have been deleted, it exists outside of fileset
29118 stat $DIR/$tdir/fileD || error "fileD deleted"
29120 run_test 421h "rmfid with fileset mount"
29123 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
29124 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
29125 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
29126 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
29127 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
29129 local amc=$(at_max_get client)
29130 local amo=$(at_max_get mds1)
29131 local timeout=`lctl get_param -n timeout`
29133 at_max_set 0 client
29136 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
29137 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
29138 fail_val=$(((2*timeout + 10)*1000))
29139 touch $DIR/$tdir/d3/file &
29141 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
29142 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
29143 fail_val=$((2*timeout + 5))
29144 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
29148 sleep $((2 * timeout))
29152 touch $DIR/$tdir/d2/file3
29153 touch $DIR/$tdir/d2/file4
29154 touch $DIR/$tdir/d2/file5
29157 at_max_set $amc client
29158 at_max_set $amo mds1
29160 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
29161 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
29162 error "Watchdog is always throttled"
29164 run_test 422 "kill a process with RPC in progress"
29177 # ensure statfs cache is expired
29180 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
29181 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
29185 run_test 423 "statfs should return a right data"
29188 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | CFS_FAIL_ONCE
29189 $LCTL set_param fail_loc=0x80000522
29190 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
29193 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
29196 test_mkdir -c -1 $DIR/$tdir
29197 $LFS setstripe -c -1 $DIR/$tdir
29199 lru_resize_disable "" 100
29200 stack_trap "lru_resize_enable" EXIT
29204 for i in $(seq $((MDSCOUNT * 125))); do
29205 local t=$DIR/$tdir/$tfile_$i
29207 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
29208 error_noexit "Create file $t"
29210 stack_trap "rm -rf $DIR/$tdir" EXIT
29212 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
29213 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
29214 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
29216 [ $lock_count -le $lru_size ] ||
29217 error "osc lock count $lock_count > lru size $lru_size"
29220 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
29221 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
29222 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
29224 [ $lock_count -le $lru_size ] ||
29225 error "mdc lock count $lock_count > lru size $lru_size"
29228 run_test 425 "lock count should not exceed lru size"
29231 splice-test -r $DIR/$tfile
29232 splice-test -rd $DIR/$tfile
29233 splice-test $DIR/$tfile
29234 splice-test -d $DIR/$tfile
29236 run_test 426 "splice test on Lustre"
29239 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
29240 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
29241 skip "Need MDS version at least 2.12.4"
29247 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
29248 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
29250 $LFS getdirstripe $DIR/$tdir/1/dir
29252 #first setfattr for creating updatelog
29253 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
29255 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
29256 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
29257 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
29258 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
29262 wait_recovery_complete mds2 $((2*TIMEOUT))
29264 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
29265 echo $log | grep "get update log failed" &&
29266 error "update log corruption is detected" || true
29268 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
29271 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29272 local max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
29273 awk '/^max_cached_mb/ { print $2 }')
29274 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$max_cached_mb"
29276 $LCTL set_param -n llite.*.max_cached_mb=64
29279 $LFS setstripe -c 1 $DIR/$tdir
29280 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
29281 stack_trap "rm -f $DIR/$tdir/$tfile.*"
29283 for f in $(seq 4); do
29284 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
29288 cancel_lru_locks osc
29290 for f in $(seq 4); do
29291 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
29295 run_test 428 "large block size IO should not hang"
29297 test_429() { # LU-7915 / LU-10948
29298 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
29299 local testfile=$DIR/$tfile
29300 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
29306 $LCTL get_param $ll_opencache_threshold_count ||
29307 skip "client does not have opencache parameter"
29309 set_opencache $new_flag
29310 stack_trap "restore_opencache"
29311 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
29312 error "enable opencache failed"
29314 # drop MDC DLM locks
29315 cancel_lru_locks mdc
29316 # clear MDC RPC stats counters
29317 $LCTL set_param $mdc_rpcstats=clear
29319 # According to the current implementation, we need to run 3 times
29320 # open & close file to verify if opencache is enabled correctly.
29321 # 1st, RPCs are sent for lookup/open and open handle is released on
29323 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
29324 # so open handle won't be released thereafter.
29325 # 3rd, No RPC is sent out.
29326 $MULTIOP $testfile oc || error "multiop failed"
29327 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
29328 echo "1st: $first_rpc RPCs in flight"
29330 $MULTIOP $testfile oc || error "multiop failed"
29331 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
29332 echo "2nd: $second_rpc RPCs in flight"
29334 $MULTIOP $testfile oc || error "multiop failed"
29335 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
29336 echo "3rd: $third_rpc RPCs in flight"
29338 #verify no MDC RPC is sent
29339 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
29341 run_test 429 "verify if opencache flag on client side does work"
29347 # data at [200K, 400K)
29348 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
29349 error "256K->512K dd fails"
29351 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
29352 error "2M->3M dd fails"
29354 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
29355 error "4M->5M dd fails"
29356 echo "Data at 256K...512K, 2M...3M and 4M...5M"
29357 # start at first component hole #1
29358 printf "Seeking hole from 1000 ... "
29359 offset=$(lseek_test -l 1000 $file)
29361 [[ $offset == 1000 ]] || error "offset $offset != 1000"
29362 printf "Seeking data from 1000 ... "
29363 offset=$(lseek_test -d 1000 $file)
29365 [[ $offset == 262144 ]] || error "offset $offset != 262144"
29367 # start at first component data block
29368 printf "Seeking hole from 300000 ... "
29369 offset=$(lseek_test -l 300000 $file)
29371 [[ $offset == 524288 ]] || error "offset $offset != 524288"
29372 printf "Seeking data from 300000 ... "
29373 offset=$(lseek_test -d 300000 $file)
29375 [[ $offset == 300000 ]] || error "offset $offset != 300000"
29377 # start at the first component but beyond end of object size
29378 printf "Seeking hole from 1000000 ... "
29379 offset=$(lseek_test -l 1000000 $file)
29381 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
29382 printf "Seeking data from 1000000 ... "
29383 offset=$(lseek_test -d 1000000 $file)
29385 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
29387 # start at second component stripe 2 (empty file)
29388 printf "Seeking hole from 1500000 ... "
29389 offset=$(lseek_test -l 1500000 $file)
29391 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
29392 printf "Seeking data from 1500000 ... "
29393 offset=$(lseek_test -d 1500000 $file)
29395 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
29397 # start at second component stripe 1 (all data)
29398 printf "Seeking hole from 3000000 ... "
29399 offset=$(lseek_test -l 3000000 $file)
29401 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
29402 printf "Seeking data from 3000000 ... "
29403 offset=$(lseek_test -d 3000000 $file)
29405 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
29407 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
29408 error "2nd dd fails"
29409 echo "Add data block at 640K...1280K"
29411 # start at before new data block, in hole
29412 printf "Seeking hole from 600000 ... "
29413 offset=$(lseek_test -l 600000 $file)
29415 [[ $offset == 600000 ]] || error "offset $offset != 600000"
29416 printf "Seeking data from 600000 ... "
29417 offset=$(lseek_test -d 600000 $file)
29419 [[ $offset == 655360 ]] || error "offset $offset != 655360"
29421 # start at the first component new data block
29422 printf "Seeking hole from 1000000 ... "
29423 offset=$(lseek_test -l 1000000 $file)
29425 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
29426 printf "Seeking data from 1000000 ... "
29427 offset=$(lseek_test -d 1000000 $file)
29429 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
29431 # start at second component stripe 2, new data
29432 printf "Seeking hole from 1200000 ... "
29433 offset=$(lseek_test -l 1200000 $file)
29435 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
29436 printf "Seeking data from 1200000 ... "
29437 offset=$(lseek_test -d 1200000 $file)
29439 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
29441 # start beyond file end
29442 printf "Using offset > filesize ... "
29443 lseek_test -l 4000000 $file && error "lseek should fail"
29444 printf "Using offset > filesize ... "
29445 lseek_test -d 4000000 $file && error "lseek should fail"
29451 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
29452 skip "MDT does not support SEEK_HOLE"
29454 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
29455 skip "OST does not support SEEK_HOLE"
29457 local file=$DIR/$tdir/$tfile
29459 mkdir -p $DIR/$tdir
29461 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
29462 # OST stripe #1 will have continuous data at [1M, 3M)
29463 # OST stripe #2 is empty
29464 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
29465 lseek_test_430 $file
29467 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
29468 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
29469 lseek_test_430 $file
29471 $LFS setstripe -c2 -S 512K $file
29472 echo "Two stripes, stripe size 512K"
29473 lseek_test_430 $file
29475 # FLR with stale mirror
29476 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
29478 echo "Mirrored file:"
29479 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
29480 echo "Plain 2 stripes 1M"
29481 lseek_test_430 $file
29484 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
29487 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
29488 skip "OST does not support SEEK_HOLE"
29491 local file=$DIR/$tdir/$tfile
29493 mkdir -p $DIR/$tdir
29494 # Empty layout lseek should fail
29497 printf "Seeking hole from 0 ... "
29498 lseek_test -l 0 $file && error "lseek should fail"
29499 printf "Seeking data from 0 ... "
29500 lseek_test -d 0 $file && error "lseek should fail"
29504 $LFS setstripe -E 1M -c2 -E eof $file
29505 $TRUNCATE $file 1048576
29506 printf "Seeking hole from 1000000 ... "
29507 offset=$(lseek_test -l 1000000 $file)
29509 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
29510 printf "Seeking data from 1000000 ... "
29511 lseek_test -d 1000000 $file && error "lseek should fail"
29514 # full component followed by non-inited one
29515 $LFS setstripe -E 1M -c2 -E eof $file
29516 dd if=/dev/urandom of=$file bs=1M count=1
29517 printf "Seeking hole from 1000000 ... "
29518 offset=$(lseek_test -l 1000000 $file)
29520 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
29521 printf "Seeking hole from 1048576 ... "
29522 lseek_test -l 1048576 $file && error "lseek should fail"
29523 # init second component and truncate back
29524 echo "123" >> $file
29525 $TRUNCATE $file 1048576
29526 printf "Seeking hole from 1000000 ... "
29527 offset=$(lseek_test -l 1000000 $file)
29529 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
29530 printf "Seeking hole from 1048576 ... "
29531 lseek_test -l 1048576 $file && error "lseek should fail"
29532 # boundary checks for big values
29533 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
29534 offset=$(lseek_test -d 0 $file.10g)
29535 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
29536 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
29537 offset=$(lseek_test -d 0 $file.100g)
29538 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
29541 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
29544 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
29545 skip "OST does not support SEEK_HOLE"
29547 local file=$DIR/$tdir/$tfile
29550 mkdir -p $DIR/$tdir
29551 stack_trap "rm -f $file $file.tmp"
29552 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M || error "dd failed"
29554 # cp version 8.33+ prefers lseek over fiemap
29555 local ver=$(cp --version | awk '{ print $4; exit; }')
29557 echo "cp $ver installed"
29558 if (( $(version_code $ver) >= $(version_code 8.33) )); then
29560 time cp -v $file $file.tmp || error "cp $file failed"
29561 (( SECONDS - start < 5 )) || {
29562 strace cp $file $file.tmp |&
29563 grep -E "open|read|seek|FIEMAP" |
29565 error "cp: too long runtime $((SECONDS - start))"
29568 echo "cp test skipped due to $ver < 8.33"
29571 # tar version 1.29+ supports SEEK_HOLE/DATA
29572 ver=$(tar --version | awk '{ print $4; exit; }')
29573 echo "tar $ver installed"
29574 if (( $(version_code $ver) >= $(version_code 1.29) )); then
29576 time tar cvf $file.tmp --sparse $file || error "tar $file error"
29577 (( SECONDS - start < 5 )) || {
29578 strace tar cf $file.tmp --sparse $file |&
29579 grep -E "open|read|seek|FIEMAP" |
29581 error "tar: too long runtime $((SECONDS - start))"
29584 echo "tar test skipped due to $ver < 1.29"
29587 run_test 430c "lseek: external tools check"
29589 test_431() { # LU-14187
29590 local file=$DIR/$tdir/$tfile
29592 mkdir -p $DIR/$tdir
29593 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
29594 dd if=/dev/urandom of=$file bs=4k count=1
29595 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
29596 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
29597 #define OBD_FAIL_OST_RESTART_IO 0x251
29598 do_facet ost1 "$LCTL set_param fail_loc=0x251"
29599 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
29603 echo 3 > /proc/sys/vm/drop_caches
29604 diff $file $file.0 || error "data diff"
29606 run_test 431 "Restart transaction for IO"
29608 cleanup_test_432() {
29609 do_facet mgs $LCTL nodemap_activate 0
29610 wait_nm_sync active
29614 local tmpdir=$TMP/dir432
29616 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
29617 skip "Need MDS version at least 2.14.52"
29619 stack_trap cleanup_test_432 EXIT
29623 do_facet mgs $LCTL nodemap_activate 1
29624 wait_nm_sync active
29625 do_facet mgs $LCTL nodemap_modify --name default \
29626 --property admin --value 1
29627 do_facet mgs $LCTL nodemap_modify --name default \
29628 --property trusted --value 1
29629 cancel_lru_locks mdc
29630 wait_nm_sync default admin_nodemap
29631 wait_nm_sync default trusted_nodemap
29633 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
29634 grep -ci "Operation not permitted") -ne 0 ]; then
29635 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
29638 run_test 432 "mv dir from outside Lustre"
29641 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29643 [[ -n "$($LCTL list_param llite.*.inode_cache 2>/dev/null)" ]] ||
29644 skip "inode cache not supported"
29646 $LCTL set_param llite.*.inode_cache=0
29647 stack_trap "$LCTL set_param llite.*.inode_cache=1"
29653 cancel_lru_locks mdc
29654 test_mkdir $DIR/$tdir || error "mkdir $tdir"
29655 createmany -m $DIR/$tdir/f $count
29656 createmany -d $DIR/$tdir/d $count
29657 ls -l $DIR/$tdir > /dev/null
29658 stack_trap "rm -rf $DIR/$tdir"
29660 before=$(num_objects)
29661 cancel_lru_locks mdc
29662 after=$(num_objects)
29664 # sometimes even @before is less than 2 * count
29665 while (( before - after < count )); do
29667 after=$(num_objects)
29669 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
29670 if (( wait > 60 )); then
29671 error "inode slab grew from $before to $after"
29675 echo "lustre_inode_cache $before objs before lock cancel, $after after"
29677 run_test 433 "ldlm lock cancel releases dentries and inodes"
29681 local getxattr_count
29682 local mdc_stat_param="mdc.$FSNAME-MDT0000*.md_stats"
29683 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
29685 [[ $(getenforce) == "Disabled" ]] ||
29686 skip "lsm selinux module have to be disabled for this test"
29688 test_mkdir -i 0 -c1 $DIR/$tdir/ ||
29689 error "fail to create $DIR/$tdir/ on MDT0000"
29691 touch $DIR/$tdir/$tfile-{001..100}
29693 # disable the xattr cache
29694 save_lustre_params client "llite.*.xattr_cache" > $p
29695 lctl set_param llite.*.xattr_cache=0
29696 stack_trap "restore_lustre_params < $p; rm -f $p" EXIT
29698 # clear clients mdc stats
29699 clear_stats $mdc_stat_param ||
29700 error "fail to clear stats on mdc MDT0000"
29702 for file in $DIR/$tdir/$tfile-{001..100}; do
29703 getfattr -n security.selinux $file |&
29704 grep -q "Operation not supported" ||
29705 error "getxattr on security.selinux should return EOPNOTSUPP"
29708 getxattr_count=$(calc_stats $mdc_stat_param "getxattr")
29709 (( getxattr_count < 100 )) ||
29710 error "client sent $getxattr_count getxattr RPCs to the MDS"
29712 run_test 434 "Client should not send RPCs for security.selinux with SElinux disabled"
29715 if [[ -f $LUSTRE/scripts/bash-completion/lustre ]]; then
29716 source $LUSTRE/scripts/bash-completion/lustre
29717 elif [[ -f /usr/share/bash-completion/completions/lustre ]]; then
29718 source /usr/share/bash-completion/completions/lustre
29720 skip "bash completion scripts not found"
29723 local lctl_completions
29724 local lfs_completions
29726 lctl_completions=$(_lustre_cmds lctl)
29727 if [[ ! $lctl_completions =~ "get_param" ]]; then
29728 error "lctl bash completion failed"
29731 lfs_completions=$(_lustre_cmds lfs)
29732 if [[ ! $lfs_completions =~ "setstripe" ]]; then
29733 error "lfs bash completion failed"
29736 run_test 440 "bash completion for lfs, lctl"
29739 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
29740 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
29741 skip "Need server version at least 2.9.55"
29743 start_full_debug_logging
29747 stop_full_debug_logging
29751 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
29752 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
29753 awk '/The barrier for/ { print $7 }')
29756 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
29761 barrier_expired() {
29764 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
29765 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
29766 awk '/will be expired/ { print $7 }')
29768 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
29777 echo "Start barrier_freeze at: $(date)"
29778 #define OBD_FAIL_BARRIER_DELAY 0x2202
29779 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
29780 # Do not reduce barrier time - See LU-11873
29781 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
29784 local b_status=$(barrier_stat)
29785 echo "Got barrier status at: $(date)"
29786 [ "$b_status" = "'freezing_p1'" ] ||
29787 error "(1) unexpected barrier status $b_status"
29789 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
29791 b_status=$(barrier_stat)
29792 [ "$b_status" = "'frozen'" ] ||
29793 error "(2) unexpected barrier status $b_status"
29795 local expired=$(barrier_expired)
29796 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
29797 sleep $((expired + 3))
29799 b_status=$(barrier_stat)
29800 [ "$b_status" = "'expired'" ] ||
29801 error "(3) unexpected barrier status $b_status"
29803 # Do not reduce barrier time - See LU-11873
29804 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
29805 error "(4) fail to freeze barrier"
29807 b_status=$(barrier_stat)
29808 [ "$b_status" = "'frozen'" ] ||
29809 error "(5) unexpected barrier status $b_status"
29811 echo "Start barrier_thaw at: $(date)"
29812 #define OBD_FAIL_BARRIER_DELAY 0x2202
29813 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
29814 do_facet mgs $LCTL barrier_thaw $FSNAME &
29817 b_status=$(barrier_stat)
29818 echo "Got barrier status at: $(date)"
29819 [ "$b_status" = "'thawing'" ] ||
29820 error "(6) unexpected barrier status $b_status"
29822 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
29824 b_status=$(barrier_stat)
29825 [ "$b_status" = "'thawed'" ] ||
29826 error "(7) unexpected barrier status $b_status"
29828 #define OBD_FAIL_BARRIER_FAILURE 0x2203
29829 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
29830 do_facet mgs $LCTL barrier_freeze $FSNAME
29832 b_status=$(barrier_stat)
29833 [ "$b_status" = "'failed'" ] ||
29834 error "(8) unexpected barrier status $b_status"
29836 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
29837 do_facet mgs $LCTL barrier_thaw $FSNAME
29841 run_test 801a "write barrier user interfaces and stat machine"
29846 mkdir $DIR/$tdir || error "(1) fail to mkdir"
29847 createmany -d $DIR/$tdir/d 6 || error "(2) fail to mkdir"
29848 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
29849 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
29850 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
29852 cancel_lru_locks mdc
29854 # 180 seconds should be long enough
29855 do_facet mgs $LCTL barrier_freeze $FSNAME 180
29857 local b_status=$(barrier_stat)
29858 [ "$b_status" = "'frozen'" ] ||
29859 error "(6) unexpected barrier status $b_status"
29861 mkdir $DIR/$tdir/d0/d10 &
29864 touch $DIR/$tdir/d1/f13 &
29867 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
29870 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
29873 rm -f $DIR/$tdir/d4/f12 &
29876 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
29878 # To guarantee taht the 'stat' is not blocked
29879 b_status=$(barrier_stat)
29880 [ "$b_status" = "'frozen'" ] ||
29881 error "(8) unexpected barrier status $b_status"
29883 # let above commands to run at background
29886 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
29887 ps -p $touch_pid || error "(10) touch should be blocked"
29888 ps -p $ln_pid || error "(11) link should be blocked"
29889 ps -p $mv_pid || error "(12) rename should be blocked"
29890 ps -p $rm_pid || error "(13) unlink should be blocked"
29892 b_status=$(barrier_stat)
29893 [ "$b_status" = "'frozen'" ] ||
29894 error "(14) unexpected barrier status $b_status"
29896 do_facet mgs $LCTL barrier_thaw $FSNAME
29897 b_status=$(barrier_stat)
29898 [ "$b_status" = "'thawed'" ] ||
29899 error "(15) unexpected barrier status $b_status"
29901 wait $mkdir_pid || error "(16) mkdir should succeed"
29902 wait $touch_pid || error "(17) touch should succeed"
29903 wait $ln_pid || error "(18) link should succeed"
29904 wait $mv_pid || error "(19) rename should succeed"
29905 wait $rm_pid || error "(20) unlink should succeed"
29909 run_test 801b "modification will be blocked by write barrier"
29912 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
29916 stop mds2 || error "(1) Fail to stop mds2"
29918 do_facet mgs $LCTL barrier_freeze $FSNAME 30
29920 local b_status=$(barrier_stat)
29921 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
29922 do_facet mgs $LCTL barrier_thaw $FSNAME
29923 error "(2) unexpected barrier status $b_status"
29926 do_facet mgs $LCTL barrier_rescan $FSNAME ||
29927 error "(3) Fail to rescan barrier bitmap"
29929 # Do not reduce barrier time - See LU-11873
29930 do_facet mgs $LCTL barrier_freeze $FSNAME 20
29932 b_status=$(barrier_stat)
29933 [ "$b_status" = "'frozen'" ] ||
29934 error "(4) unexpected barrier status $b_status"
29936 do_facet mgs $LCTL barrier_thaw $FSNAME
29937 b_status=$(barrier_stat)
29938 [ "$b_status" = "'thawed'" ] ||
29939 error "(5) unexpected barrier status $b_status"
29941 local devname=$(mdsdevname 2)
29943 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
29945 do_facet mgs $LCTL barrier_rescan $FSNAME ||
29946 error "(7) Fail to rescan barrier bitmap"
29950 run_test 801c "rescan barrier bitmap"
29953 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29954 remote_mds_nodsh && skip "remote MDS with nodsh"
29956 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
29957 skip "readonly option not available"
29959 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
29961 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
29962 error "(2) Fail to copy"
29964 # write back all cached data before setting MDT to readonly
29968 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
29969 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
29971 echo "Modify should be refused"
29972 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
29974 echo "Read should be allowed"
29975 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
29976 error "(7) Read should succeed under ro mode"
29979 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
29981 run_test 802b "be able to set MDTs to readonly"
29984 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
29985 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
29986 skip "MDS needs to be newer than 2.10.54"
29988 mkdir_on_mdt0 $DIR/$tdir
29989 # Create some objects on all MDTs to trigger related logs objects
29990 for idx in $(seq $MDSCOUNT); do
29991 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
29992 $DIR/$tdir/dir${idx} ||
29993 error "Fail to create $DIR/$tdir/dir${idx}"
29996 wait_delete_completed # ensure old test cleanups are finished
29998 echo "before create:"
30000 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
30002 for i in {1..10}; do
30003 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
30004 error "Fail to create $DIR/$tdir/foo$i"
30007 # sync ZFS-on-MDS to refresh statfs data
30008 wait_zfs_commit mds1
30010 echo "after create:"
30012 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
30014 # allow for an llog to be cleaned up during the test
30015 [ $after_used -ge $((before_used + 10 - 1)) ] ||
30016 error "before ($before_used) + 10 > after ($after_used)"
30018 for i in {1..10}; do
30019 rm -rf $DIR/$tdir/foo$i ||
30020 error "Fail to remove $DIR/$tdir/foo$i"
30023 # sync ZFS-on-MDS to refresh statfs data
30024 wait_zfs_commit mds1
30025 wait_delete_completed
30026 sleep 3 # avoid MDT return cached statfs
30027 echo "after unlink:"
30029 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
30031 # allow for an llog to be created during the test
30032 [ $after_used -le $((before_used + 1)) ] ||
30033 error "after ($after_used) > before ($before_used) + 1"
30035 run_test 803a "verify agent object for remote object"
30038 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
30039 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
30040 skip "MDS needs to be newer than 2.13.56"
30041 [ $PARALLEL == "yes" ] && skip "skip parallel run"
30043 for i in $(seq 0 $((MDSCOUNT - 1))); do
30044 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
30052 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
30053 for i in $(seq 0 $((MDSCOUNT - 1))); do
30054 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
30055 awk '/getattr/ { print $2 }')
30056 before=$((before + tmp))
30058 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
30059 for i in $(seq 0 $((MDSCOUNT - 1))); do
30060 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
30061 awk '/getattr/ { print $2 }')
30062 after=$((after + tmp))
30065 [ $before -eq $after ] || error "getattr count $before != $after"
30067 run_test 803b "remote object can getattr from cache"
30070 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
30071 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
30072 skip "MDS needs to be newer than 2.10.54"
30073 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
30075 mkdir -p $DIR/$tdir
30076 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
30077 error "Fail to create $DIR/$tdir/dir0"
30079 local fid=$($LFS path2fid $DIR/$tdir/dir0)
30080 local dev=$(mdsdevname 2)
30082 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
30083 grep ${fid} || error "NOT found agent entry for dir0"
30085 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
30086 error "Fail to create $DIR/$tdir/dir1"
30088 touch $DIR/$tdir/dir1/foo0 ||
30089 error "Fail to create $DIR/$tdir/dir1/foo0"
30090 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
30093 for idx in $(seq $MDSCOUNT); do
30094 dev=$(mdsdevname $idx)
30095 do_facet mds${idx} \
30096 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
30097 grep ${fid} && rc=$idx
30100 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
30101 error "Fail to rename foo0 to foo1"
30102 if [ $rc -eq 0 ]; then
30103 for idx in $(seq $MDSCOUNT); do
30104 dev=$(mdsdevname $idx)
30105 do_facet mds${idx} \
30106 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
30107 grep ${fid} && rc=$idx
30111 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
30112 error "Fail to rename foo1 to foo2"
30113 if [ $rc -eq 0 ]; then
30114 for idx in $(seq $MDSCOUNT); do
30115 dev=$(mdsdevname $idx)
30116 do_facet mds${idx} \
30117 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
30118 grep ${fid} && rc=$idx
30122 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
30124 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
30125 error "Fail to link to $DIR/$tdir/dir1/foo2"
30126 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
30127 error "Fail to rename foo2 to foo0"
30128 unlink $DIR/$tdir/dir1/foo0 ||
30129 error "Fail to unlink $DIR/$tdir/dir1/foo0"
30130 rm -rf $DIR/$tdir/dir0 ||
30131 error "Fail to rm $DIR/$tdir/dir0"
30133 for idx in $(seq $MDSCOUNT); do
30137 dev=$(mdsdevname $idx)
30138 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
30140 start mds${idx} $dev $MDS_MOUNT_OPTS ||
30141 error "mount mds$idx failed"
30142 df $MOUNT > /dev/null 2>&1
30144 # e2fsck should not return error
30146 error "e2fsck detected error on MDT${idx}: rc=$rc"
30149 run_test 804 "verify agent entry for remote entry"
30152 do_facet $SINGLEMDS zfs set quota=$old $fsset
30153 unlinkmany $DIR/$tdir/f- 1000000
30158 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
30159 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
30160 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
30161 skip "netfree not implemented before 0.7"
30162 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
30163 skip "Need MDS version at least 2.10.57"
30170 local pref="osd-zfs.$FSNAME-MDT0000."
30172 # limit available space on MDS dataset to meet nospace issue
30173 # quickly. then ZFS 0.7.2 can use reserved space if asked
30174 # properly (using netfree flag in osd_declare_destroy()
30175 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
30176 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
30178 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
30179 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
30180 let "usedkb=usedkb-freekb"
30181 let "freekb=freekb/2"
30182 if let "freekb > 5000"; then
30185 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
30186 trap cleanup_805 EXIT
30187 mkdir_on_mdt0 $DIR/$tdir
30188 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
30189 error "Can't set PFL layout"
30190 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
30191 rm -rf $DIR/$tdir || error "not able to remove"
30192 do_facet $SINGLEMDS zfs set quota=$old $fsset
30195 run_test 805 "ZFS can remove from full fs"
30201 local expect=$(stat -c %s $file)
30203 check_lsom_size $1 $expect
30205 local blocks=$($LFS getsom -b $file)
30206 expect=$(stat -c %b $file)
30207 [[ $blocks == $expect ]] ||
30208 error "$file expected blocks: $expect, got: $blocks"
30216 cancel_lru_locks mdc
30218 size=$($LFS getsom -s $1)
30219 [[ $size == $expect ]] ||
30220 error "$file expected size: $expect, got: $size"
30224 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
30225 skip "Need MDS version at least 2.11.52"
30229 $LFS setstripe -c-1 $DIR/$tfile || error "setstripe $tfile failed"
30232 stack_trap "restore_opencache"
30234 # single-threaded write
30235 echo "Test SOM for single-threaded write"
30236 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
30237 error "write $tfile failed"
30238 check_lsom_size $DIR/$tfile $bs
30241 local size=$(($num * $bs))
30245 echo "Test SOM for single client multi-threaded($num) write"
30246 $TRUNCATE $DIR/$tfile 0
30247 for ((i = 0; i < $num; i++)); do
30248 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
30250 offset=$((offset + $bs))
30252 for (( i=0; i < $num; i++ )); do
30255 check_lsom_size $DIR/$tfile $size
30257 $TRUNCATE $DIR/$tfile 0
30258 for ((i = 0; i < $num; i++)); do
30259 offset=$((offset - $bs))
30260 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
30263 for (( i=0; i < $num; i++ )); do
30266 check_lsom_size $DIR/$tfile $size
30268 # multi-client writes
30269 num=$(get_node_count ${CLIENTS//,/ })
30270 size=$(($num * $bs))
30274 echo "Test SOM for multi-client ($num) writes"
30275 $TRUNCATE $DIR/$tfile 0
30276 for client in ${CLIENTS//,/ }; do
30277 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
30280 offset=$((offset + $bs))
30282 for (( i=0; i < $num; i++ )); do
30285 check_lsom_size $DIR/$tfile $offset
30288 $TRUNCATE $DIR/$tfile 0
30289 for client in ${CLIENTS//,/ }; do
30290 offset=$((offset - $bs))
30291 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
30295 for (( i=0; i < $num; i++ )); do
30298 check_lsom_size $DIR/$tfile $size
30300 # verify SOM blocks count
30301 echo "Verify SOM block count"
30302 $TRUNCATE $DIR/$tfile 0
30303 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w$((bs))YSc ||
30304 error "failed to write file $tfile with fdatasync and fstat"
30305 check_lsom_data $DIR/$tfile
30307 $TRUNCATE $DIR/$tfile 0
30308 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w$((bs * 2))Yc ||
30309 error "failed to write file $tfile with fdatasync"
30310 check_lsom_data $DIR/$tfile
30312 $TRUNCATE $DIR/$tfile 0
30313 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:O_SYNC:w$((bs * 3))c ||
30314 error "failed to write file $tfile with sync IO"
30315 check_lsom_data $DIR/$tfile
30318 echo "Test SOM for truncate"
30319 # use ftruncate to sync blocks on close request
30320 $MULTIOP $DIR/$tfile oO_WRONLY:T16384c
30321 check_lsom_size $DIR/$tfile 16384
30322 check_lsom_data $DIR/$tfile
30324 $TRUNCATE $DIR/$tfile 1234
30325 check_lsom_size $DIR/$tfile 1234
30326 # sync blocks on the MDT
30327 $MULTIOP $DIR/$tfile oc
30328 check_lsom_data $DIR/$tfile
30330 run_test 806 "Verify Lazy Size on MDS"
30333 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
30334 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
30335 skip "Need MDS version at least 2.11.52"
30337 # Registration step
30338 changelog_register || error "changelog_register failed"
30339 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
30340 changelog_users $SINGLEMDS | grep -q $cl_user ||
30341 error "User $cl_user not found in changelog_users"
30343 rm -rf $DIR/$tdir || error "rm $tdir failed"
30344 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
30345 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
30346 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
30347 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
30348 error "truncate $tdir/trunc failed"
30351 echo "Test SOM for single-threaded write with fsync"
30352 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
30353 error "write $tfile failed"
30356 # multi-client wirtes
30357 local num=$(get_node_count ${CLIENTS//,/ })
30361 echo "Test SOM for multi-client ($num) writes"
30362 touch $DIR/$tfile || error "touch $tfile failed"
30363 $TRUNCATE $DIR/$tfile 0
30364 for client in ${CLIENTS//,/ }; do
30365 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
30368 offset=$((offset + $bs))
30370 for (( i=0; i < $num; i++ )); do
30374 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
30375 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
30376 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
30377 check_lsom_data $DIR/$tdir/trunc
30378 check_lsom_data $DIR/$tdir/single_dd
30379 check_lsom_data $DIR/$tfile
30382 # Deregistration step
30383 changelog_deregister || error "changelog_deregister failed"
30385 run_test 807 "verify LSOM syncing tool"
30387 check_som_nologged()
30389 local lines=$($LFS changelog $FSNAME-MDT0000 |
30390 grep 'x=trusted.som' | wc -l)
30391 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
30395 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
30396 skip "Need MDS version at least 2.11.55"
30398 # Registration step
30399 changelog_register || error "changelog_register failed"
30401 touch $DIR/$tfile || error "touch $tfile failed"
30404 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
30405 error "write $tfile failed"
30408 $TRUNCATE $DIR/$tfile 1234
30411 $TRUNCATE $DIR/$tfile 1048576
30414 # Deregistration step
30415 changelog_deregister || error "changelog_deregister failed"
30417 run_test 808 "Check trusted.som xattr not logged in Changelogs"
30422 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
30426 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
30427 skip "Need MDS version at least 2.11.56"
30429 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
30430 error "failed to create DoM-only file $DIR/$tfile"
30431 touch $DIR/$tfile || error "touch $tfile failed"
30432 check_som_nodata $DIR/$tfile
30434 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
30435 error "write $tfile failed"
30436 check_som_nodata $DIR/$tfile
30438 $TRUNCATE $DIR/$tfile 1234
30439 check_som_nodata $DIR/$tfile
30441 $TRUNCATE $DIR/$tfile 4097
30442 check_som_nodata $DIR/$file
30444 run_test 809 "Verify no SOM xattr store for DoM-only files"
30447 [ $PARALLEL == "yes" ] && skip "skip parallel run"
30448 $GSS && skip_env "could not run with gss"
30449 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
30450 skip "OST < 2.12.58 doesn't align checksum"
30453 stack_trap "set_checksums $ORIG_CSUM" EXIT
30454 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
30459 for csum in $CKSUM_TYPES; do
30460 #define OBD_FAIL_OSC_NO_GRANT 0x411
30461 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
30462 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
30464 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
30465 before=$(md5sum $DIR/$tfile)
30466 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
30467 after=$(md5sum $DIR/$tfile)
30468 [ "$before" == "$after" ] ||
30469 error "$csum: $before != $after bs=$1 seek=$2"
30473 run_test 810 "partial page writes on ZFS (LU-11663)"
30476 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
30477 skip "OST < 2.12.51 doesn't support this fail_loc"
30479 $LFS setstripe -c 1 -i 0 $DIR/$tfile
30480 # ensure ost1 is connected
30481 stat $DIR/$tfile >/dev/null || error "can't stat"
30482 wait_osc_import_state client ost1 FULL
30483 # no locks, no reqs to let the connection idle
30484 cancel_lru_locks osc
30486 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
30487 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
30488 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
30489 wait_osc_import_state client ost1 CONNECTING
30490 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
30492 stat $DIR/$tfile >/dev/null || error "can't stat file"
30494 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
30496 test_812b() { # LU-12378
30497 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
30498 skip "OST < 2.12.51 doesn't support this fail_loc"
30500 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
30501 # ensure ost1 is connected
30502 stat $DIR/$tfile >/dev/null || error "can't stat"
30503 wait_osc_import_state client ost1 FULL
30504 # no locks, no reqs to let the connection idle
30505 cancel_lru_locks osc
30507 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
30508 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
30509 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
30510 wait_osc_import_state client ost1 CONNECTING
30511 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
30513 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
30514 wait_osc_import_state client ost1 IDLE
30516 run_test 812b "do not drop no resend request for idle connect"
30521 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
30523 $LFS setstripe -c 1 -o 0 $DIR/$tfile
30524 $LFS getstripe $DIR/$tfile
30525 $LCTL set_param osc.*.idle_timeout=10
30526 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
30527 # ensure ost1 is connected
30528 stat $DIR/$tfile >/dev/null || error "can't stat"
30529 wait_osc_import_state client ost1 FULL
30530 # no locks, no reqs to let the connection idle
30531 cancel_lru_locks osc
30533 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
30534 $LCTL set_param fail_loc=0x80000533
30536 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
30538 run_test 812c "idle import vs lock enqueue race"
30541 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
30542 [ -z "$file_heat_sav" ] && skip "no file heat support"
30553 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
30554 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
30556 $LCTL set_param -n llite.*.file_heat=1
30557 echo "Turn on file heat"
30558 echo "Period second: $period_second, Decay percentage: $decay_pct"
30560 echo "QQQQ" > $DIR/$tfile
30561 echo "QQQQ" > $DIR/$tfile
30562 echo "QQQQ" > $DIR/$tfile
30563 cat $DIR/$tfile > /dev/null
30564 cat $DIR/$tfile > /dev/null
30565 cat $DIR/$tfile > /dev/null
30566 cat $DIR/$tfile > /dev/null
30568 local out=$($LFS heat_get $DIR/$tfile)
30570 $LFS heat_get $DIR/$tfile
30571 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30572 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30573 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30574 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30576 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
30577 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
30578 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
30579 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
30581 sleep $((period_second + 3))
30582 echo "Sleep $((period_second + 3)) seconds..."
30583 # The recursion formula to calculate the heat of the file f is as
30585 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
30586 # Where Hi is the heat value in the period between time points i*I and
30587 # (i+1)*I; Ci is the access count in the period; the symbol P refers
30588 # to the weight of Ci.
30589 out=$($LFS heat_get $DIR/$tfile)
30590 $LFS heat_get $DIR/$tfile
30591 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30592 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30593 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30594 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30596 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
30597 error "read sample ($readsample) is wrong"
30598 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
30599 error "write sample ($writesample) is wrong"
30600 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
30601 error "read bytes ($readbyte) is wrong"
30602 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
30603 error "write bytes ($writebyte) is wrong"
30605 echo "QQQQ" > $DIR/$tfile
30606 echo "QQQQ" > $DIR/$tfile
30607 echo "QQQQ" > $DIR/$tfile
30608 cat $DIR/$tfile > /dev/null
30609 cat $DIR/$tfile > /dev/null
30610 cat $DIR/$tfile > /dev/null
30611 cat $DIR/$tfile > /dev/null
30613 sleep $((period_second + 3))
30614 echo "Sleep $((period_second + 3)) seconds..."
30616 out=$($LFS heat_get $DIR/$tfile)
30617 $LFS heat_get $DIR/$tfile
30618 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30619 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30620 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30621 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30623 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
30624 4 * $decay_pct) / 100") -eq 1 ] ||
30625 error "read sample ($readsample1) is wrong"
30626 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
30627 3 * $decay_pct) / 100") -eq 1 ] ||
30628 error "write sample ($writesample1) is wrong"
30629 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
30630 20 * $decay_pct) / 100") -eq 1 ] ||
30631 error "read bytes ($readbyte1) is wrong"
30632 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
30633 15 * $decay_pct) / 100") -eq 1 ] ||
30634 error "write bytes ($writebyte1) is wrong"
30636 echo "Turn off file heat for the file $DIR/$tfile"
30637 $LFS heat_set -o $DIR/$tfile
30639 echo "QQQQ" > $DIR/$tfile
30640 echo "QQQQ" > $DIR/$tfile
30641 echo "QQQQ" > $DIR/$tfile
30642 cat $DIR/$tfile > /dev/null
30643 cat $DIR/$tfile > /dev/null
30644 cat $DIR/$tfile > /dev/null
30645 cat $DIR/$tfile > /dev/null
30647 out=$($LFS heat_get $DIR/$tfile)
30648 $LFS heat_get $DIR/$tfile
30649 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30650 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30651 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30652 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30654 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
30655 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
30656 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
30657 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
30659 echo "Trun on file heat for the file $DIR/$tfile"
30660 $LFS heat_set -O $DIR/$tfile
30662 echo "QQQQ" > $DIR/$tfile
30663 echo "QQQQ" > $DIR/$tfile
30664 echo "QQQQ" > $DIR/$tfile
30665 cat $DIR/$tfile > /dev/null
30666 cat $DIR/$tfile > /dev/null
30667 cat $DIR/$tfile > /dev/null
30668 cat $DIR/$tfile > /dev/null
30670 out=$($LFS heat_get $DIR/$tfile)
30671 $LFS heat_get $DIR/$tfile
30672 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30673 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30674 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30675 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30677 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
30678 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
30679 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
30680 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
30682 $LFS heat_set -c $DIR/$tfile
30683 $LCTL set_param -n llite.*.file_heat=0
30684 echo "Turn off file heat support for the Lustre filesystem"
30686 echo "QQQQ" > $DIR/$tfile
30687 echo "QQQQ" > $DIR/$tfile
30688 echo "QQQQ" > $DIR/$tfile
30689 cat $DIR/$tfile > /dev/null
30690 cat $DIR/$tfile > /dev/null
30691 cat $DIR/$tfile > /dev/null
30692 cat $DIR/$tfile > /dev/null
30694 out=$($LFS heat_get $DIR/$tfile)
30695 $LFS heat_get $DIR/$tfile
30696 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30697 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30698 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30699 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30701 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
30702 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
30703 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
30704 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
30706 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
30709 run_test 813 "File heat verfication"
30713 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
30714 echo -n y >> $DIR/$tfile
30715 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
30716 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
30718 run_test 814 "sparse cp works as expected (LU-12361)"
30722 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
30723 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
30725 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
30728 local ost1_imp=$(get_osc_import_name client ost1)
30729 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
30732 $LFS setstripe -c 1 -i 0 $DIR/$tfile
30733 # ensure ost1 is connected
30735 stat $DIR/$tfile >/dev/null || error "can't stat"
30736 wait_osc_import_state client ost1 FULL
30737 # no locks, no reqs to let the connection idle
30738 cancel_lru_locks osc
30739 lru_resize_disable osc
30742 before=$($LCTL get_param -n \
30743 ldlm.namespaces.$imp_name.lru_size)
30745 wait_osc_import_state client ost1 IDLE
30746 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
30747 now=$($LCTL get_param -n \
30748 ldlm.namespaces.$imp_name.lru_size)
30749 [ $before == $now ] || error "lru_size changed $before != $now"
30751 run_test 816 "do not reset lru_resize on idle reconnect"
30755 exportfs -u localhost:$DIR/nfsexp
30760 systemctl restart nfs-server.service || skip "failed to restart nfsd"
30762 mkdir -p $DIR/nfsexp
30763 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
30764 error "failed to export nfs"
30766 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
30767 stack_trap cleanup_817 EXIT
30769 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
30770 error "failed to mount nfs to $tmpdir"
30772 cp /bin/true $tmpdir
30773 $DIR/nfsexp/true || error "failed to execute 'true' command"
30775 run_test 817 "nfsd won't cache write lock for exec file"
30778 test_mkdir -i0 -c1 $DIR/$tdir
30779 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
30780 $LFS setstripe -c1 -i1 $DIR/$tdir/$tfile
30783 # restore osp-syn threads
30784 stack_trap "fail $SINGLEMDS"
30786 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
30787 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
30788 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
30789 error "start $SINGLEMDS failed"
30792 local testid=$(echo $TESTNAME | tr '_' ' ')
30794 do_facet mds1 dmesg | tac | sed "/$testid/,$ d" |
30795 grep "run LFSCK" || error "run LFSCK is not suggested"
30797 run_test 818 "unlink with failed llog"
30800 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
30801 cancel_lru_locks osc
30802 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
30803 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
30804 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
30807 run_test 819a "too big niobuf in read"
30810 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
30811 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
30812 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
30813 cancel_lru_locks osc
30817 run_test 819b "too big niobuf in write"
30820 function test_820_start_ost() {
30823 for num in $(seq $OSTCOUNT); do
30824 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
30829 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
30832 umount_client $MOUNT || error "umount failed"
30833 for num in $(seq $OSTCOUNT); do
30837 # mount client with no active OSTs
30838 # so that the client can't initialize max LOV EA size
30839 # from OSC notifications
30840 mount_client $MOUNT || error "mount failed"
30841 # delay OST starting to keep this 0 max EA size for a while
30842 test_820_start_ost &
30844 # create a directory on MDS2
30845 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
30846 error "Failed to create directory"
30847 # open intent should update default EA size
30848 # see mdc_update_max_ea_from_body()
30849 # notice this is the very first RPC to MDS2
30850 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
30853 # With SSK, this situation can lead to -EPERM being returned.
30854 # In that case, simply retry.
30855 if [ $ret -ne 0 ] && $SHARED_KEY; then
30856 if echo "$out" | grep -q "not permitted"; then
30857 cp /etc/services $DIR/$tdir/mds2
30861 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
30863 run_test 820 "update max EA from open intent"
30866 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
30867 local OST_MAX_PRECREATE=20000
30869 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
30870 skip "Need MDS version at least 2.14.56"
30872 save_lustre_params mds1 \
30873 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
30874 do_facet $SINGLEMDS "$LCTL set_param -n \
30875 osp.$FSNAME-OST*MDT0000.max_create_count=0"
30876 do_facet $SINGLEMDS "$LCTL set_param -n \
30877 osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE"
30879 stack_trap "restore_lustre_params < $p; rm $p"
30881 do_facet $SINGLEMDS "$LCTL set_param -n \
30882 osp.$FSNAME-OST*-osc-MDT*.create_count=100200"
30884 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
30885 osp.$FSNAME-OST0000*MDT0000.create_count")
30886 local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \
30887 osp.$FSNAME-OST0000*MDT0000.max_create_count")
30888 local expect_count=$(((($max/2)/256) * 256))
30890 log "setting create_count to 100200:"
30891 log " -result- count: $count with max: $max, expecting: $expect_count"
30893 [[ $count -eq expect_count ]] ||
30894 error "Create count not set to max precreate."
30896 run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum"
30899 [[ $MDS1_VERSION -lt $(version_code 2.14.56) ]] &&
30900 skip "Need MDS version 2.14.56"
30902 local sync_changes=$(do_facet $SINGLEMDS \
30903 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
30905 [ "$sync_changes" -gt 100 ] &&
30906 skip "Sync changes $sync_changes > 100 already"
30908 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
30910 $LFS mkdir -i 0 $DIR/$tdir
30911 $LFS setstripe -c 1 -i 0 $DIR/$tdir
30913 save_lustre_params mds1 \
30914 "osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes" > $p
30915 save_lustre_params mds1 \
30916 "osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress" >> $p
30918 do_facet mds1 "$LCTL set_param -n \
30919 osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes=100 \
30920 osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress=128"
30921 stack_trap "restore_lustre_params < $p" EXIT
30923 createmany -o $DIR/$tdir/f- 1000
30924 unlinkmany $DIR/$tdir/f- 1000 &
30925 local UNLINK_PID=$!
30928 sync_changes=$(do_facet mds1 \
30929 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
30930 # the check in the code is racy, fail the test
30931 # if the value above the limit by 10.
30932 [ $sync_changes -gt 110 ] && {
30933 kill -2 $UNLINK_PID
30935 error "osp changes throttling failed, $sync_changes>110"
30937 kill -0 $UNLINK_PID 2> /dev/null || break
30941 run_test 831 "throttling unlink/setattr queuing on OSP"
30944 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
30945 (( $MDS1_VERSION >= $(version_code 2.15.52) )) ||
30946 skip "Need MDS version 2.15.52+"
30947 is_rmentry_supported || skip "rm_entry not supported"
30949 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
30950 mkdir $DIR/$tdir/local_dir || error "mkdir local_dir failed"
30951 mkdir_on_mdt -i 1 $DIR/$tdir/remote_dir ||
30952 error "mkdir remote_dir failed"
30953 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/striped_dir ||
30954 error "mkdir striped_dir failed"
30955 touch $DIR/$tdir/file || error "touch file failed"
30956 $LFS rm_entry $DIR/$tdir/* || error "lfs rm_entry $tdir/* failed"
30957 [ -z "$(ls -A $DIR/$tdir)" ] || error "$tdir not empty"
30959 run_test 832 "lfs rm_entry"
30962 local file=$DIR/$tfile
30964 stack_trap "rm -f $file" EXIT
30965 dd if=/dev/zero of=$file bs=1M count=50 || error "Write $file failed"
30971 # Buffered I/O write
30973 while [ ! -e $DIR/sanity.833.lck ]; do
30974 dd if=/dev/zero of=$file bs=1M count=50 conv=notrunc ||
30975 error "failed to write $file"
30976 sleep 0.$((RANDOM % 4 + 1))
30981 # Buffered I/O read
30983 while [ ! -e $DIR/sanity.833.lck ]; do
30984 dd if=$file of=/dev/null bs=1M count=50 ||
30985 error "failed to read $file"
30986 sleep 0.$((RANDOM % 4 + 1))
30993 while [ ! -e $DIR/sanity.833.lck ]; do
30994 dd if=$file of=/dev/null bs=1M count=50 iflag=direct ||
30995 error "failed to read $file in direct I/O mode"
30996 sleep 0.$((RANDOM % 4 + 1))
31002 touch $DIR/sanity.833.lck
31003 wait $wpid || error "$?: buffered write failed"
31004 wait $rpid || error "$?: buffered read failed"
31005 wait $rpid2 || error "$?: direct read failed"
31007 run_test 833 "Mixed buffered/direct read and write should not return -EIO"
31010 # tests that do cleanup/setup should be run at the end
31014 [ $PARALLEL == "yes" ] && skip "skip parallel run"
31017 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
31018 $LCTL set_param fail_loc=0x903
31020 cancel_lru_locks MGC
31022 FAIL_ON_ERROR=true cleanup
31023 FAIL_ON_ERROR=true setup
31025 run_test 900 "umount should not race with any mgc requeue thread"
31027 # LUS-6253/LU-11185
31035 [ $PARALLEL == "yes" ] && skip "skip parallel run"
31037 # some get_param have a bug to handle dot in param name
31038 cancel_lru_locks MGC
31039 old=$(mount -t lustre | wc -l)
31047 while [ $old -ne $oldc ]; do
31048 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
31051 if [ $count -ge $TIMEOUT ]; then
31052 error "too large timeout"
31055 umount_client $MOUNT || error "umount failed"
31056 mount_client $MOUNT || error "mount failed"
31057 cancel_lru_locks MGC
31058 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
31060 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
31064 run_test 901 "don't leak a mgc lock on client umount"
31068 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
31069 skip "client does not have LU-13377 fix"
31070 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
31071 $LCTL set_param fail_loc=0x1415
31072 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
31073 cancel_lru_locks osc
31076 run_test 902 "test short write doesn't hang lustre"
31080 $LFS setstripe -i 0 -c 1 $DIR/$tfile $DIR/${tfile}-2
31081 echo "blah" > $DIR/${tfile}-2
31082 dd if=/dev/zero of=$DIR/$tfile bs=1M count=6 conv=fsync
31083 #define OBD_FAIL_OSC_SLOW_PAGE_EVICT 0x417
31084 $LCTL set_param fail_loc=0x417 fail_val=20
31086 mv $DIR/${tfile}-2 $DIR/$tfile # Destroys the big object
31087 sleep 1 # To start the destroy
31088 wait_destroy_complete 150 || error "Destroy taking too long"
31089 cat $DIR/$tfile > /dev/null || error "Evicted"
31091 run_test 903 "Test long page discard does not cause evictions"
31094 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
31095 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
31096 grep -q project || skip "skip project quota not supported"
31098 local testfile="$DIR/$tdir/$tfile"
31099 local xattr="trusted.projid"
31101 local mdts=$(comma_list $(mdts_nodes))
31102 local saved=$(do_facet mds1 $LCTL get_param -n \
31103 osd-ldiskfs.*MDT0000.enable_projid_xattr)
31105 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=0
31106 stack_trap "do_nodes $mdts $LCTL set_param \
31107 osd-ldiskfs.*MDT*.enable_projid_xattr=$saved"
31109 mkdir -p $DIR/$tdir
31111 #hide projid xattr on server
31112 $LFS project -p 1 $testfile ||
31113 error "set $testfile project id failed"
31114 getfattr -m - $testfile | grep $xattr &&
31115 error "do not show trusted.projid when disabled on server"
31116 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=1
31117 #should be hidden when projid is 0
31118 $LFS project -p 0 $testfile ||
31119 error "set $testfile project id failed"
31120 getfattr -m - $testfile | grep $xattr &&
31121 error "do not show trusted.projid with project ID 0"
31123 #still can getxattr explicitly
31124 projid=$(getfattr -n $xattr $testfile |
31125 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
31126 [ $projid == "0" ] ||
31127 error "projid expected 0 not $projid"
31129 #set the projid via setxattr
31130 setfattr -n $xattr -v "1000" $testfile ||
31131 error "setattr failed with $?"
31132 projid=($($LFS project $testfile))
31133 [ ${projid[0]} == "1000" ] ||
31134 error "projid expected 1000 not $projid"
31136 #check the new projid via getxattr
31137 $LFS project -p 1001 $testfile ||
31138 error "set $testfile project id failed"
31139 getfattr -m - $testfile | grep $xattr ||
31140 error "should show trusted.projid when project ID != 0"
31141 projid=$(getfattr -n $xattr $testfile |
31142 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
31143 [ $projid == "1001" ] ||
31144 error "projid expected 1001 not $projid"
31146 #try to set invalid projid
31147 setfattr -n $xattr -v "4294967295" $testfile &&
31148 error "set invalid projid should fail"
31150 #remove the xattr means setting projid to 0
31151 setfattr -x $xattr $testfile ||
31152 error "setfattr failed with $?"
31153 projid=($($LFS project $testfile))
31154 [ ${projid[0]} == "0" ] ||
31155 error "projid expected 0 not $projid"
31157 #should be hidden when parent has inherit flag and same projid
31158 $LFS project -srp 1002 $DIR/$tdir ||
31159 error "set $tdir project id failed"
31160 getfattr -m - $testfile | grep $xattr &&
31161 error "do not show trusted.projid with inherit flag"
31163 #still can getxattr explicitly
31164 projid=$(getfattr -n $xattr $testfile |
31165 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
31166 [ $projid == "1002" ] ||
31167 error "projid expected 1002 not $projid"
31169 run_test 904 "virtual project ID xattr"
31173 (( $OST1_VERSION >= $(version_code 2.15.50.220) )) ||
31174 skip "need OST version >= 2.15.50.220 for fail_loc"
31176 remote_ost_nodsh && skip "remote OST with nodsh"
31177 $LFS setstripe -c -1 -i 0 $DIR/$tfile || error "setstripe failed"
31179 $LFS ladvise -a willread $DIR/$tfile || error "ladvise does not work"
31181 #define OBD_FAIL_OST_OPCODE 0x253
31183 do_facet ost1 "$LCTL set_param fail_val=21 fail_loc=0x0253"
31184 $LFS ladvise -a willread $DIR/$tfile &&
31185 error "unexpected success of ladvise with fault injection"
31186 $LFS ladvise -a willread $DIR/$tfile |&
31187 grep -q "Operation not supported"
31188 (( $? == 0 )) || error "unexpected stderr of ladvise with fault injection"
31190 run_test 905 "bad or new opcode should not stuck client"
31193 grep -q io_uring_setup /proc/kallsyms ||
31194 skip "Client OS does not support io_uring I/O engine"
31195 io_uring_probe || skip "kernel does not support io_uring fully"
31196 which fio || skip_env "no fio installed"
31197 fio --enghelp | grep -q io_uring ||
31198 skip_env "fio does not support io_uring I/O engine"
31200 local file=$DIR/$tfile
31201 local ioengine="io_uring"
31205 fio --name=seqwrite --ioengine=$ioengine \
31206 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
31207 --iodepth=64 --size=$size --filename=$file --rw=write ||
31208 error "fio seqwrite $file failed"
31210 fio --name=seqread --ioengine=$ioengine \
31211 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
31212 --iodepth=64 --size=$size --filename=$file --rw=read ||
31213 error "fio seqread $file failed"
31215 rm -f $file || error "rm -f $file failed"
31217 run_test 906 "Simple test for io_uring I/O engine via fio"
31220 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
31222 # set stripe size to max rpc size
31223 $LFS setstripe -i 0 -c 2 -S $((max_pages * PAGE_SIZE)) $DIR/$tfile
31224 $LFS getstripe $DIR/$tfile
31225 #define OBD_FAIL_OST_EROFS 0x216
31226 do_facet ost1 "$LCTL set_param fail_val=3 fail_loc=0x80000216"
31228 local bs=$((max_pages * PAGE_SIZE / 16))
31230 # write full one stripe and one block
31231 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=17 || error "dd failed"
31233 rm $DIR/$tfile || error "rm failed"
31235 run_test 907 "write rpc error during unlink"
31237 complete_test $SECONDS
31238 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
31239 check_and_cleanup_lustre
31240 if [ "$I_MOUNTED" != "yes" ]; then
31241 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true