3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
17 CREATETEST=${CREATETEST:-createtest}
18 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
19 OPENFILE=${OPENFILE:-openfile}
20 OPENUNLINK=${OPENUNLINK:-openunlink}
21 READS=${READS:-"reads"}
22 MUNLINK=${MUNLINK:-munlink}
23 SOCKETSERVER=${SOCKETSERVER:-socketserver}
24 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
25 MEMHOG=${MEMHOG:-memhog}
26 DIRECTIO=${DIRECTIO:-directio}
27 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
31 export PARALLEL=${PARALLEL:-"no"}
34 LUSTRE=${LUSTRE:-$(dirname $0)/..}
35 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
36 . $LUSTRE/tests/test-framework.sh
41 ALWAYS_EXCEPT="$SANITY_EXCEPT "
42 # bug number for skipped test: LU-9693 LU-6493 LU-9693
43 ALWAYS_EXCEPT+=" 42a 42b 42c "
44 # bug number: LU-8411 LU-9054
45 ALWAYS_EXCEPT+=" 407 312"
48 # bug number: LU-14181 LU-14181
49 ALWAYS_EXCEPT+=" 64e 64f"
52 selinux_status=$(getenforce)
53 if [ "$selinux_status" != "Disabled" ]; then
58 # skip the grant tests for ARM until they are fixed
59 if [[ $(uname -m) = aarch64 ]]; then
60 # bug number: LU-11596
61 ALWAYS_EXCEPT+=" $GRANT_CHECK_LIST"
62 # bug number: LU-11671 LU-11667
63 ALWAYS_EXCEPT+=" 45 317"
64 # bug number: LU-14067 LU-14067
65 ALWAYS_EXCEPT+=" 400a 400b"
68 # skip nfs tests on kernels >= 4.12.0 until they are fixed
69 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
70 # bug number: LU-12661
73 # skip cgroup tests on RHEL8.1 kernels until they are fixed
74 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
75 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
76 # bug number: LU-13063
81 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 60i 64b 68 71 115 135 136 300o"
83 if [ "$mds1_FSTYPE" = "zfs" ]; then
84 # bug number for skipped test:
87 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
90 if [ "$ost1_FSTYPE" = "zfs" ]; then
91 # bug number for skipped test: LU-1941 LU-1941 LU-1941 LU-1941
92 ALWAYS_EXCEPT+=" 130a 130b 130c 130d 130e 130f 130g"
95 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
97 # Get the SLES distro version
99 # Returns a version string that should only be used in comparing
100 # strings returned by version_code()
103 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
105 # All SuSE Linux versions have one decimal. version_code expects two
106 local sles_version=$version.0
107 version_code $sles_version
110 # Check if we are running on Ubuntu or SLES so we can make decisions on
112 if [ -r /etc/SuSE-release ]; then
113 sles_version=$(sles_version_code)
114 [ $sles_version -lt $(version_code 11.4.0) ] &&
115 # bug number for skipped test: LU-4341
116 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
117 [ $sles_version -lt $(version_code 12.0.0) ] &&
118 # bug number for skipped test: LU-3703
119 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
120 elif [ -r /etc/os-release ]; then
121 if grep -qi ubuntu /etc/os-release; then
122 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
123 -e 's/^VERSION=//p' \
127 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
128 # bug number for skipped test:
130 ALWAYS_EXCEPT+=" 103a 410"
140 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
141 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
150 check_swap_layouts_support()
152 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
153 skip "Does not support layout lock."
156 check_swap_layout_no_dom()
159 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
160 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
163 check_and_setup_lustre
167 MAXFREE=${MAXFREE:-$((300000 * $OSTCOUNT))}
169 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
170 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
171 rm -rf $DIR/[Rdfs][0-9]*
173 # $RUNAS_ID may get set incorrectly somewhere else
174 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
175 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
177 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
179 if [ "${ONLY}" = "MOUNT" ] ; then
180 echo "Lustre is up, please go on"
184 echo "preparing for tests involving mounts"
185 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
187 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
188 echo # add a newline after mke2fs.
192 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
193 lctl set_param debug=-1 2> /dev/null || true
196 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
198 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
200 run_test 0a "touch; rm ====================="
203 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
204 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
206 run_test 0b "chmod 0755 $DIR ============================="
209 $LCTL get_param mdc.*.import | grep "state: FULL" ||
210 error "import not FULL"
211 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
214 run_test 0c "check import proc"
216 test_0d() { # LU-3397
217 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
218 skip "proc exports not supported before 2.10.57"
220 local mgs_exp="mgs.MGS.exports"
221 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
223 local exp_client_version
226 local temp_imp=$DIR/$tfile.import
227 local temp_exp=$DIR/$tfile.export
229 # save mgc import file to $temp_imp
230 $LCTL get_param mgc.*.import | tee $temp_imp
231 # Check if client uuid is found in MGS export
232 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
233 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
237 # save mgs export file to $temp_exp
238 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
240 # Compare the value of field "connect_flags"
241 imp_val=$(grep "connect_flags" $temp_imp)
242 exp_val=$(grep "connect_flags" $temp_exp)
243 [ "$exp_val" == "$imp_val" ] ||
244 error "export flags '$exp_val' != import flags '$imp_val'"
246 # Compare client versions. Only compare top-3 fields for compatibility
247 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
248 exp_val=$(version_code $(cut -d. -f1,2,3 <<<$exp_client_version))
249 imp_val=$(version_code $(lustre_build_version client | cut -d. -f1,2,3))
250 [ "$exp_val" == "$imp_val" ] ||
251 error "exp version '$exp_client_version'($exp_val) != " \
252 "'$(lustre_build_version client)'($imp_val)"
254 run_test 0d "check export proc ============================="
256 test_0e() { # LU-13417
257 (( $MDSCOUNT > 1 )) ||
258 skip "We need at least 2 MDTs for this test"
260 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
261 skip "Need server version at least 2.14.51"
263 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
264 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
266 [ $default_lmv_count -eq 1 ] ||
267 error "$MOUNT default stripe count $default_lmv_count"
269 [ $default_lmv_index -eq -1 ] ||
270 error "$MOUNT default stripe index $default_lmv_index"
272 mkdir $MOUNT/$tdir.1 || error "mkdir $MOUNT/$tdir.1 failed"
273 mkdir $MOUNT/$tdir.2 || error "mkdir $MOUNT/$tdir.2 failed"
275 local mdt_index1=$($LFS getdirstripe -i $MOUNT/$tdir.1)
276 local mdt_index2=$($LFS getdirstripe -i $MOUNT/$tdir.2)
278 [ $mdt_index1 -eq $mdt_index2 ] &&
279 error "directories are on the same MDT $mdt_index1=$mdt_index2"
281 rmdir $MOUNT/$tdir.1 $MOUNT/$tdir.2
283 run_test 0e "Enable DNE MDT balancing for mkdir in the ROOT"
286 test_mkdir $DIR/$tdir
287 test_mkdir $DIR/$tdir/d2
288 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
289 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
292 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
294 run_test 1 "mkdir; remkdir; rmdir"
297 test_mkdir $DIR/$tdir
298 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
299 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
301 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
303 run_test 2 "mkdir; touch; rmdir; check file"
306 test_mkdir $DIR/$tdir
307 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
308 touch $DIR/$tdir/$tfile
309 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
311 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
313 run_test 3 "mkdir; touch; rmdir; check dir"
315 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
317 test_mkdir -i 1 $DIR/$tdir
319 touch $DIR/$tdir/$tfile ||
320 error "Create file under remote directory failed"
323 error "Expect error removing in-use dir $DIR/$tdir"
325 test -d $DIR/$tdir || error "Remote directory disappeared"
327 rm -rf $DIR/$tdir || error "remove remote dir error"
329 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
332 test_mkdir $DIR/$tdir
333 test_mkdir $DIR/$tdir/d2
334 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
335 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
336 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
338 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
341 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
342 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
343 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
344 error "$tfile does not have perm 0666 or UID $UID"
345 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
346 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
347 error "$tfile should be 0666 and owned by UID $UID"
349 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
352 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
355 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
356 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
357 error "$tfile should be owned by UID $RUNAS_ID"
358 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
359 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
360 error "$tfile should be owned by UID $RUNAS_ID"
362 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
365 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
368 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
369 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
370 error "$tfile should be owned by GID $UID"
371 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
372 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
373 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
375 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
378 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
380 test_mkdir $DIR/$tdir
381 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
382 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
383 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
384 test_mkdir $DIR/$tdir/d/subdir
385 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
386 error "$tdir/d/subdir should be GID $RUNAS_GID"
387 if [[ $MDSCOUNT -gt 1 ]]; then
388 # check remote dir sgid inherite
389 $LFS mkdir -i 0 $DIR/$tdir.local ||
390 error "mkdir $tdir.local failed"
391 chmod g+s $DIR/$tdir.local ||
392 error "chmod $tdir.local failed"
393 chgrp $RUNAS_GID $DIR/$tdir.local ||
394 error "chgrp $tdir.local failed"
395 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
396 error "mkdir $tdir.remote failed"
397 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
398 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
399 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
400 error "$tdir.remote should be mode 02755"
403 run_test 6g "verify new dir in sgid dir inherits group"
405 test_6h() { # bug 7331
406 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
408 touch $DIR/$tfile || error "touch failed"
409 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
410 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
411 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
412 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
413 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
415 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
418 test_mkdir $DIR/$tdir
419 $MCREATE $DIR/$tdir/$tfile
420 chmod 0666 $DIR/$tdir/$tfile
421 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
422 error "$tdir/$tfile should be mode 0666"
424 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
427 if [ ! -d $DIR/$tdir ]; then
428 test_mkdir $DIR/$tdir
430 $MCREATE $DIR/$tdir/$tfile
431 echo -n foo > $DIR/$tdir/$tfile
432 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
433 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
435 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
438 test_mkdir $DIR/$tdir
439 touch $DIR/$tdir/$tfile
440 chmod 0666 $DIR/$tdir/$tfile
441 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
442 error "$tfile mode not 0666"
444 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
447 test_mkdir $DIR/$tdir
448 test_mkdir $DIR/$tdir/d2
449 test_mkdir $DIR/$tdir/d2/d3
450 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
452 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
455 test_mkdir $DIR/$tdir
456 test_mkdir $DIR/$tdir/d2
457 touch $DIR/$tdir/d2/$tfile
458 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
459 error "$tdir/d2/$tfile not a file"
461 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
464 test_mkdir $DIR/$tdir
465 test_mkdir $DIR/$tdir/d2
466 chmod 0666 $DIR/$tdir/d2
467 chmod 0705 $DIR/$tdir/d2
468 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
469 error "$tdir/d2 mode not 0705"
471 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
474 test_mkdir $DIR/$tdir
475 touch $DIR/$tdir/$tfile
476 chmod 0666 $DIR/$tdir/$tfile
477 chmod 0654 $DIR/$tdir/$tfile
478 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
479 error "$tdir/d2 mode not 0654"
481 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
484 test_mkdir $DIR/$tdir
485 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
487 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
488 error "$tdir/$tfile size not 0 after truncate"
490 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
493 test_mkdir $DIR/$tdir
494 touch $DIR/$tdir/$tfile
496 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
498 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
501 test_mkdir $DIR/$tdir
502 touch $DIR/$tdir/$tfile
503 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
504 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
505 error "$tdir/${tfile_2} not a file after rename"
506 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
508 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
511 test_mkdir $DIR/$tdir
512 touch $DIR/$tdir/$tfile
513 rm -rf $DIR/$tdir/$tfile
514 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
516 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
519 test_mkdir $DIR/$tdir
520 touch $DIR/$tdir/$tfile
521 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
523 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
524 error "$tdir/l-exist not a symlink"
525 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
526 error "$tdir/l-exist not referencing a file"
527 rm -f $DIR/$tdir/l-exist
528 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
530 run_test 17a "symlinks: create, remove (real)"
533 test_mkdir $DIR/$tdir
534 ln -s no-such-file $DIR/$tdir/l-dangle
536 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
537 error "$tdir/l-dangle not referencing no-such-file"
538 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
539 error "$tdir/l-dangle not referencing non-existent file"
540 rm -f $DIR/$tdir/l-dangle
541 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
543 run_test 17b "symlinks: create, remove (dangling)"
545 test_17c() { # bug 3440 - don't save failed open RPC for replay
546 test_mkdir $DIR/$tdir
547 ln -s foo $DIR/$tdir/$tfile
548 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
550 run_test 17c "symlinks: open dangling (should return error)"
553 test_mkdir $DIR/$tdir
554 ln -s foo $DIR/$tdir/$tfile
555 touch $DIR/$tdir/$tfile || error "creating to new symlink"
557 run_test 17d "symlinks: create dangling"
560 test_mkdir $DIR/$tdir
561 local foo=$DIR/$tdir/$tfile
562 ln -s $foo $foo || error "create symlink failed"
563 ls -l $foo || error "ls -l failed"
564 ls $foo && error "ls not failed" || true
566 run_test 17e "symlinks: create recursive symlink (should return error)"
569 test_mkdir $DIR/$tdir
570 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
571 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
572 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
573 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
574 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
575 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
578 run_test 17f "symlinks: long and very long symlink name"
580 # str_repeat(S, N) generate a string that is string S repeated N times
585 while [ $((n -= 1)) -ge 0 ]; do
591 # Long symlinks and LU-2241
593 test_mkdir $DIR/$tdir
594 local TESTS="59 60 61 4094 4095"
596 # Fix for inode size boundary in 2.1.4
597 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
600 # Patch not applied to 2.2 or 2.3 branches
601 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
602 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
606 local SYMNAME=$(str_repeat 'x' $i)
607 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
608 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
611 run_test 17g "symlinks: really long symlink name and inode boundaries"
613 test_17h() { #bug 17378
614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
615 remote_mds_nodsh && skip "remote MDS with nodsh"
619 test_mkdir $DIR/$tdir
620 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
621 $LFS setstripe -c -1 $DIR/$tdir
622 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
623 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
624 touch $DIR/$tdir/$tfile || true
626 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
628 test_17i() { #bug 20018
629 [ $PARALLEL == "yes" ] && skip "skip parallel run"
630 remote_mds_nodsh && skip "remote MDS with nodsh"
632 local foo=$DIR/$tdir/$tfile
635 test_mkdir -c1 $DIR/$tdir
636 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
637 ln -s $foo $foo || error "create symlink failed"
638 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
639 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
640 ls -l $foo && error "error not detected"
643 run_test 17i "don't panic on short symlink (should return error)"
645 test_17k() { #bug 22301
646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
647 [[ -z "$(which rsync 2>/dev/null)" ]] &&
648 skip "no rsync command"
649 rsync --help | grep -q xattr ||
650 skip_env "$(rsync --version | head -n1) does not support xattrs"
651 test_mkdir $DIR/$tdir
652 test_mkdir $DIR/$tdir.new
653 touch $DIR/$tdir/$tfile
654 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
655 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
656 error "rsync failed with xattrs enabled"
658 run_test 17k "symlinks: rsync with xattrs enabled"
660 test_17l() { # LU-279
661 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
662 skip "no getfattr command"
664 test_mkdir $DIR/$tdir
665 touch $DIR/$tdir/$tfile
666 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
667 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
668 # -h to not follow symlinks. -m '' to list all the xattrs.
669 # grep to remove first line: '# file: $path'.
670 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
672 lgetxattr_size_check $path $xattr ||
673 error "lgetxattr_size_check $path $xattr failed"
677 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
681 [ $PARALLEL == "yes" ] && skip "skip parallel run"
682 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
683 remote_mds_nodsh && skip "remote MDS with nodsh"
684 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
685 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
686 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
688 local short_sym="0123456789"
689 local wdir=$DIR/$tdir
694 # create a long symlink file
695 for ((i = 0; i < 4; ++i)); do
696 long_sym=${long_sym}${long_sym}
699 echo "create 512 short and long symlink files under $wdir"
700 for ((i = 0; i < 256; ++i)); do
701 ln -sf ${long_sym}"a5a5" $wdir/long-$i
702 ln -sf ${short_sym}"a5a5" $wdir/short-$i
708 wait_delete_completed
710 echo "recreate the 512 symlink files with a shorter string"
711 for ((i = 0; i < 512; ++i)); do
712 # rewrite the symlink file with a shorter string
713 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
714 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
717 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
718 local devname=$(mdsdevname $mds_index)
720 echo "stop and checking mds${mds_index}:"
721 # e2fsck should not return error
723 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
726 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
727 error "start mds${mds_index} failed"
728 df $MOUNT > /dev/null 2>&1
730 error "e2fsck detected error for short/long symlink: rc=$rc"
733 run_test 17m "run e2fsck against MDT which contains short/long symlink"
735 check_fs_consistency_17n() {
739 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
740 # so it only check MDT1/MDT2 instead of all of MDTs.
741 for mdt_index in 1 2; do
742 local devname=$(mdsdevname $mdt_index)
743 # e2fsck should not return error
745 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
748 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
749 error "mount mds$mdt_index failed"
750 df $MOUNT > /dev/null 2>&1
756 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
757 [ $PARALLEL == "yes" ] && skip "skip parallel run"
758 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
759 remote_mds_nodsh && skip "remote MDS with nodsh"
760 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
761 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
762 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
766 test_mkdir $DIR/$tdir
767 for ((i=0; i<10; i++)); do
768 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
769 error "create remote dir error $i"
770 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
771 error "create files under remote dir failed $i"
774 check_fs_consistency_17n ||
775 error "e2fsck report error after create files under remote dir"
777 for ((i = 0; i < 10; i++)); do
778 rm -rf $DIR/$tdir/remote_dir_${i} ||
779 error "destroy remote dir error $i"
782 check_fs_consistency_17n ||
783 error "e2fsck report error after unlink files under remote dir"
785 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
786 skip "lustre < 2.4.50 does not support migrate mv"
788 for ((i = 0; i < 10; i++)); do
789 mkdir -p $DIR/$tdir/remote_dir_${i}
790 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
791 error "create files under remote dir failed $i"
792 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
793 error "migrate remote dir error $i"
795 check_fs_consistency_17n || error "e2fsck report error after migration"
797 for ((i = 0; i < 10; i++)); do
798 rm -rf $DIR/$tdir/remote_dir_${i} ||
799 error "destroy remote dir error $i"
802 check_fs_consistency_17n || error "e2fsck report error after unlink"
804 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
807 remote_mds_nodsh && skip "remote MDS with nodsh"
808 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
809 skip "Need MDS version at least 2.3.64"
811 local wdir=$DIR/${tdir}o
817 mdt_index=$($LFS getstripe -m $wdir/$tfile)
818 mdt_index=$((mdt_index + 1))
821 #fail mds will wait the failover finish then set
822 #following fail_loc to avoid interfer the recovery process.
825 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
826 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
827 ls -l $wdir/$tfile && rc=1
828 do_facet mds${mdt_index} lctl set_param fail_loc=0
829 [[ $rc -eq 0 ]] || error "stat file should fail"
831 run_test 17o "stat file with incompat LMA feature"
834 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
835 ls $DIR || error "Failed to ls $DIR: $?"
837 run_test 18 "touch .../f ; ls ... =============================="
843 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
845 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
848 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
850 run_test 19b "ls -l .../f19 (should return error) =============="
853 [ $RUNAS_ID -eq $UID ] &&
854 skip_env "RUNAS_ID = UID = $UID -- skipping"
856 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
858 run_test 19c "$RUNAS touch .../f19 (should return error) =="
861 cat $DIR/f19 && error || true
863 run_test 19d "cat .../f19 (should return error) =============="
872 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
874 run_test 20 "touch .../f ; ls -l ..."
877 test_mkdir $DIR/$tdir
878 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
879 ln -s dangle $DIR/$tdir/link
880 echo foo >> $DIR/$tdir/link
881 cat $DIR/$tdir/dangle
882 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
883 $CHECKSTAT -f -t file $DIR/$tdir/link ||
884 error "$tdir/link not linked to a file"
886 run_test 21 "write to dangling link"
889 local wdir=$DIR/$tdir
891 chown $RUNAS_ID:$RUNAS_GID $wdir
892 (cd $wdir || error "cd $wdir failed";
893 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
895 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
896 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
897 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
898 error "checkstat -u failed"
900 run_test 22 "unpack tar archive as non-root user"
904 test_mkdir $DIR/$tdir
905 local file=$DIR/$tdir/$tfile
907 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
908 openfile -f O_CREAT:O_EXCL $file &&
909 error "$file recreate succeeded" || true
911 run_test 23a "O_CREAT|O_EXCL in subdir"
913 test_23b() { # bug 18988
914 test_mkdir $DIR/$tdir
915 local file=$DIR/$tdir/$tfile
918 echo foo > $file || error "write filed"
919 echo bar >> $file || error "append filed"
920 $CHECKSTAT -s 8 $file || error "wrong size"
923 run_test 23b "O_APPEND check"
925 # LU-9409, size with O_APPEND and tiny writes
927 local file=$DIR/$tfile
930 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
931 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
935 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
936 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
938 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
941 #racing tiny & normal writes
942 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
943 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
945 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
948 #racing tiny & normal writes 2, ugly numbers
949 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
950 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
952 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
955 run_test 23c "O_APPEND size checks for tiny writes"
957 # LU-11069 file offset is correct after appending writes
959 local file=$DIR/$tfile
962 echo CentaurHauls > $file
963 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
964 if ((offset != 26)); then
965 error "wrong offset, expected 26, got '$offset'"
968 run_test 23d "file offset is correct after appending writes"
972 echo '-- same directory rename'
973 test_mkdir $DIR/$tdir
974 touch $DIR/$tdir/$tfile.1
975 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
976 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
978 run_test 24a "rename file to non-existent target"
981 test_mkdir $DIR/$tdir
982 touch $DIR/$tdir/$tfile.{1,2}
983 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
984 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
985 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
987 run_test 24b "rename file to existing target"
990 test_mkdir $DIR/$tdir
991 test_mkdir $DIR/$tdir/d$testnum.1
992 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
993 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
994 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
996 run_test 24c "rename directory to non-existent target"
999 test_mkdir -c1 $DIR/$tdir
1000 test_mkdir -c1 $DIR/$tdir/d$testnum.1
1001 test_mkdir -c1 $DIR/$tdir/d$testnum.2
1002 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
1003 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
1004 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
1006 run_test 24d "rename directory to existing target"
1009 echo '-- cross directory renames --'
1013 mv $DIR/R5a/f $DIR/R5b/g
1014 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
1015 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
1017 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
1022 touch $DIR/R6a/f $DIR/R6b/g
1023 mv $DIR/R6a/f $DIR/R6b/g
1024 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
1025 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
1027 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
1032 test_mkdir $DIR/R7a/d
1033 mv $DIR/R7a/d $DIR/R7b/e
1034 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
1035 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
1037 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1040 test_mkdir -c1 $DIR/R8a
1041 test_mkdir -c1 $DIR/R8b
1042 test_mkdir -c1 $DIR/R8a/d
1043 test_mkdir -c1 $DIR/R8b/e
1044 mrename $DIR/R8a/d $DIR/R8b/e
1045 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1046 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1048 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1051 echo "-- rename error cases"
1053 test_mkdir $DIR/R9/a
1055 mrename $DIR/R9/f $DIR/R9/a
1056 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1057 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1058 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1060 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1064 mrename $DIR/R10/f $DIR/R10/g
1065 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1066 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1067 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1069 run_test 24j "source does not exist ============================"
1072 test_mkdir $DIR/R11a
1073 test_mkdir $DIR/R11a/d
1075 mv $DIR/R11a/f $DIR/R11a/d
1076 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1077 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1079 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1081 # bug 2429 - rename foo foo foo creates invalid file
1084 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1086 run_test 24l "Renaming a file to itself ========================"
1090 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1091 # on ext3 this does not remove either the source or target files
1092 # though the "expected" operation would be to remove the source
1093 $CHECKSTAT -t file ${f} || error "${f} missing"
1094 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1096 run_test 24m "Renaming a file to a hard link to itself ========="
1100 # this stats the old file after it was renamed, so it should fail
1102 $CHECKSTAT ${f} || error "${f} missing"
1104 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1105 $CHECKSTAT -a ${f} || error "${f} exists"
1107 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1110 test_mkdir $DIR/$tdir
1111 rename_many -s random -v -n 10 $DIR/$tdir
1113 run_test 24o "rename of files during htree split"
1116 test_mkdir $DIR/R12a
1117 test_mkdir $DIR/R12b
1118 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1119 mrename $DIR/R12a $DIR/R12b
1120 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1121 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1122 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1123 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1125 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1127 cleanup_multiop_pause() {
1129 kill -USR1 $MULTIPID
1133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1135 test_mkdir $DIR/R13a
1136 test_mkdir $DIR/R13b
1137 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1138 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1141 trap cleanup_multiop_pause EXIT
1142 mrename $DIR/R13a $DIR/R13b
1143 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1144 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1145 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1146 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1147 cleanup_multiop_pause
1148 wait $MULTIPID || error "multiop close failed"
1150 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1152 test_24r() { #bug 3789
1153 test_mkdir $DIR/R14a
1154 test_mkdir $DIR/R14a/b
1155 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1156 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1157 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1159 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1162 test_mkdir $DIR/R15a
1163 test_mkdir $DIR/R15a/b
1164 test_mkdir $DIR/R15a/b/c
1165 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1166 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1167 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1169 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1171 test_mkdir $DIR/R16a
1172 test_mkdir $DIR/R16a/b
1173 test_mkdir $DIR/R16a/b/c
1174 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1175 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1176 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1178 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1180 test_24u() { # bug12192
1181 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1182 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1184 run_test 24u "create stripe file"
1186 simple_cleanup_common() {
1189 [ -z "$DIR" ] || [ -z "$tdir" ] && return 0
1191 local start=$SECONDS
1194 wait_delete_completed
1195 echo "cleanup time $((SECONDS - start))"
1199 max_pages_per_rpc() {
1200 local mdtname="$(printf "MDT%04x" ${1:-0})"
1201 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1205 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1207 local nrfiles=${COUNT:-100000}
1208 local fname="$DIR/$tdir/$tfile"
1210 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1211 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1213 test_mkdir "$(dirname $fname)"
1214 # assume MDT0000 has the fewest inodes
1215 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1216 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1217 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1219 trap simple_cleanup_common EXIT
1221 createmany -m "$fname" $nrfiles
1223 cancel_lru_locks mdc
1224 lctl set_param mdc.*.stats clear
1226 # was previously test_24D: LU-6101
1227 # readdir() returns correct number of entries after cursor reload
1228 local num_ls=$(ls $DIR/$tdir | wc -l)
1229 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1230 local num_all=$(ls -a $DIR/$tdir | wc -l)
1231 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1232 [ $num_all -ne $((nrfiles + 2)) ]; then
1233 error "Expected $nrfiles files, got $num_ls " \
1234 "($num_uniq unique $num_all .&..)"
1236 # LU-5 large readdir
1237 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1238 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1239 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1240 # take into account of overhead in lu_dirpage header and end mark in
1241 # each page, plus one in rpc_num calculation.
1242 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1243 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1244 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1245 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1246 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1247 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1248 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1249 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1250 error "large readdir doesn't take effect: " \
1251 "$mds_readpage should be about $rpc_max"
1253 simple_cleanup_common
1255 run_test 24v "list large directory (test hash collision, b=17560)"
1257 test_24w() { # bug21506
1259 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1260 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1261 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1262 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1263 [[ "$SZ1" -eq "$SZ2" ]] ||
1264 error "Error reading at the end of the file $tfile"
1266 run_test 24w "Reading a file larger than 4Gb"
1269 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1270 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1271 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1272 skip "Need MDS version at least 2.7.56"
1275 local remote_dir=$DIR/$tdir/remote_dir
1277 test_mkdir $DIR/$tdir
1278 $LFS mkdir -i $MDTIDX $remote_dir ||
1279 error "create remote directory failed"
1281 test_mkdir $DIR/$tdir/src_dir
1282 touch $DIR/$tdir/src_file
1283 test_mkdir $remote_dir/tgt_dir
1284 touch $remote_dir/tgt_file
1286 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1287 error "rename dir cross MDT failed!"
1289 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1290 error "rename file cross MDT failed!"
1292 touch $DIR/$tdir/ln_file
1293 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1294 error "ln file cross MDT failed"
1296 rm -rf $DIR/$tdir || error "Can not delete directories"
1298 run_test 24x "cross MDT rename/link"
1301 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1302 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1304 local remote_dir=$DIR/$tdir/remote_dir
1307 test_mkdir $DIR/$tdir
1308 $LFS mkdir -i $mdtidx $remote_dir ||
1309 error "create remote directory failed"
1311 test_mkdir $remote_dir/src_dir
1312 touch $remote_dir/src_file
1313 test_mkdir $remote_dir/tgt_dir
1314 touch $remote_dir/tgt_file
1316 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1317 error "rename subdir in the same remote dir failed!"
1319 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1320 error "rename files in the same remote dir failed!"
1322 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1323 error "link files in the same remote dir failed!"
1325 rm -rf $DIR/$tdir || error "Can not delete directories"
1327 run_test 24y "rename/link on the same dir should succeed"
1330 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1331 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1332 skip "Need MDS version at least 2.12.51"
1336 for index in 0 1; do
1337 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1338 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1341 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1343 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1344 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1346 local mdts=$(comma_list $(mdts_nodes))
1348 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1349 stack_trap "do_nodes $mdts $LCTL \
1350 set_param mdt.*.enable_remote_rename=1" EXIT
1352 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1354 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1355 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1357 run_test 24z "cross-MDT rename is done as cp"
1359 test_24A() { # LU-3182
1363 test_mkdir $DIR/$tdir
1364 trap simple_cleanup_common EXIT
1365 createmany -m $DIR/$tdir/$tfile $NFILES
1366 local t=$(ls $DIR/$tdir | wc -l)
1367 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1368 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1369 if [ $t -ne $NFILES ] || [ $u -ne $NFILES ] ||
1370 [ $v -ne $((NFILES + 2)) ] ; then
1371 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1374 simple_cleanup_common || error "Can not delete directories"
1376 run_test 24A "readdir() returns correct number of entries."
1378 test_24B() { # LU-4805
1379 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1383 test_mkdir $DIR/$tdir
1384 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1385 error "create striped dir failed"
1387 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1388 [ $count -eq 2 ] || error "Expected 2, got $count"
1390 touch $DIR/$tdir/striped_dir/a
1392 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1393 [ $count -eq 3 ] || error "Expected 3, got $count"
1395 touch $DIR/$tdir/striped_dir/.f
1397 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1398 [ $count -eq 4 ] || error "Expected 4, got $count"
1400 rm -rf $DIR/$tdir || error "Can not delete directories"
1402 run_test 24B "readdir for striped dir return correct number of entries"
1405 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1411 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1412 error "create striped dir failed"
1414 cd $DIR/$tdir/d0/striped_dir
1416 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1417 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1418 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1420 [ "$d0_ino" = "$parent_ino" ] ||
1421 error ".. wrong, expect $d0_ino, get $parent_ino"
1423 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1424 error "mv striped dir failed"
1426 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1428 [ "$d1_ino" = "$parent_ino" ] ||
1429 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1431 run_test 24C "check .. in striped dir"
1434 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1438 mkdir $DIR/$tdir/src_dir
1439 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1440 error "create remote source failed"
1442 touch $DIR/$tdir/src_dir/src_child/a
1444 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1445 error "create remote target dir failed"
1447 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1448 error "create remote target child failed"
1450 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1451 error "rename dir cross MDT failed!"
1455 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1456 error "src_child still exists after rename"
1458 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1459 error "missing file(a) after rename"
1461 rm -rf $DIR/$tdir || error "Can not delete directories"
1463 run_test 24E "cross MDT rename/link"
1466 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1469 [ "$SLOW" = "no" ] && repeats=100
1473 echo "$repeats repeats"
1474 for ((i = 0; i < repeats; i++)); do
1475 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1476 touch $DIR/$tdir/test/a || error "touch fails"
1477 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1478 rm -rf $DIR/$tdir/test || error "rmdir fails"
1483 run_test 24F "hash order vs readdir (LU-11330)"
1486 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1491 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1492 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1493 touch $DIR/$tdir-0/f1 || error "touch f1"
1494 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1495 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1496 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1497 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1498 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1500 run_test 24G "migrate symlink in rename"
1503 echo '== symlink sanity ============================================='
1507 touch $DIR/s25/foo ||
1508 error "File creation in symlinked directory failed"
1510 run_test 25a "create file in symlinked directory ==============="
1513 [ ! -d $DIR/d25 ] && test_25a
1514 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1516 run_test 25b "lookup file in symlinked directory ==============="
1520 test_mkdir $DIR/d26/d26-2
1521 ln -s d26/d26-2 $DIR/s26
1522 touch $DIR/s26/foo || error "File creation failed"
1524 run_test 26a "multiple component symlink ======================="
1527 test_mkdir -p $DIR/$tdir/d26-2
1528 ln -s $tdir/d26-2/foo $DIR/s26-2
1529 touch $DIR/s26-2 || error "File creation failed"
1531 run_test 26b "multiple component symlink at end of lookup ======"
1534 test_mkdir $DIR/d26.2
1535 touch $DIR/d26.2/foo
1536 ln -s d26.2 $DIR/s26.2-1
1537 ln -s s26.2-1 $DIR/s26.2-2
1538 ln -s s26.2-2 $DIR/s26.2-3
1539 chmod 0666 $DIR/s26.2-3/foo
1541 run_test 26c "chain of symlinks"
1543 # recursive symlinks (bug 439)
1545 ln -s d26-3/foo $DIR/d26-3
1547 run_test 26d "create multiple component recursive symlink"
1550 [ ! -h $DIR/d26-3 ] && test_26d
1553 run_test 26e "unlink multiple component recursive symlink"
1555 # recursive symlinks (bug 7022)
1557 test_mkdir $DIR/$tdir
1558 test_mkdir $DIR/$tdir/$tfile
1559 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1560 test_mkdir -p lndir/bar1
1561 test_mkdir $DIR/$tdir/$tfile/$tfile
1562 cd $tfile || error "cd $tfile failed"
1563 ln -s .. dotdot || error "ln dotdot failed"
1564 ln -s dotdot/lndir lndir || error "ln lndir failed"
1565 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1566 output=`ls $tfile/$tfile/lndir/bar1`
1567 [ "$output" = bar1 ] && error "unexpected output"
1568 rm -r $tfile || error "rm $tfile failed"
1569 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1571 run_test 26f "rm -r of a directory which has recursive symlink"
1574 test_mkdir $DIR/$tdir
1575 $LFS getstripe $DIR/$tdir
1576 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1577 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1578 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1580 run_test 27a "one stripe file"
1583 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1585 test_mkdir $DIR/$tdir
1586 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1587 $LFS getstripe -c $DIR/$tdir/$tfile
1588 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1589 error "two-stripe file doesn't have two stripes"
1591 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1593 run_test 27b "create and write to two stripe file"
1595 # 27c family tests specific striping, setstripe -o
1597 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1598 test_mkdir -p $DIR/$tdir
1601 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1602 $LFS getstripe -i $DIR/$tdir/$tfile
1603 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1604 error "stripe not on specified OST"
1606 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1608 run_test 27ca "one stripe on specified OST"
1611 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1612 test_mkdir -p $DIR/$tdir
1614 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1615 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1618 # Strip getstripe output to a space separated list of OSTs
1619 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1620 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1621 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1622 error "stripes not on specified OSTs"
1624 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1626 run_test 27cb "two stripes on specified OSTs"
1629 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1630 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1631 skip "server does not support overstriping"
1633 test_mkdir -p $DIR/$tdir
1635 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1636 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1639 # Strip getstripe output to a space separated list of OSTs
1640 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1641 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1642 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1643 error "stripes not on specified OSTs"
1645 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1647 run_test 27cc "two stripes on the same OST"
1650 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1651 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1652 skip "server does not support overstriping"
1653 test_mkdir -p $DIR/$tdir
1654 local osts="0,1,1,0"
1655 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1656 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1659 # Strip getstripe output to a space separated list of OSTs
1660 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1661 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1662 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1663 error "stripes not on specified OSTs"
1665 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1667 run_test 27cd "four stripes on two OSTs"
1670 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1671 skip_env "too many osts, skipping"
1672 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1673 skip "server does not support overstriping"
1674 # We do one more stripe than we have OSTs
1675 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1676 skip_env "ea_inode feature disabled"
1678 test_mkdir -p $DIR/$tdir
1680 for i in $(seq 0 $OSTCOUNT);
1683 if [ $i -ne $OSTCOUNT ]; then
1687 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1688 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1691 # Strip getstripe output to a space separated list of OSTs
1692 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1693 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1694 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1695 error "stripes not on specified OSTs"
1697 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1699 run_test 27ce "more stripes than OSTs with -o"
1702 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1705 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1706 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1707 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1708 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1709 error "failed to set $osp_proc=0"
1711 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1714 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1715 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1716 error "failed to set $osp_proc=1"
1719 error "should return error due to $osp_proc=0"
1721 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1724 test_mkdir $DIR/$tdir
1725 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1726 error "setstripe failed"
1727 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1728 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1730 run_test 27d "create file with default settings"
1733 # LU-5839 adds check for existed layout before setting it
1734 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1735 skip "Need MDS version at least 2.7.56"
1737 test_mkdir $DIR/$tdir
1738 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1739 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1740 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1742 run_test 27e "setstripe existing file (should return error)"
1745 test_mkdir $DIR/$tdir
1746 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1747 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1748 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1749 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1750 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1751 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1753 run_test 27f "setstripe with bad stripe size (should return error)"
1756 test_mkdir $DIR/$tdir
1757 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1758 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1759 error "$DIR/$tdir/$tfile has object"
1761 run_test 27g "$LFS getstripe with no objects"
1764 test_mkdir $DIR/$tdir
1765 touch $DIR/$tdir/$tfile || error "touch failed"
1766 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1767 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1769 (( rc == 2 )) || error "getstripe did not return ENOENT"
1771 run_test 27ga "$LFS getstripe with missing file (should return error)"
1774 test_mkdir $DIR/$tdir
1775 touch $DIR/$tdir/$tfile || error "touch failed"
1776 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1777 error "missing objects"
1779 run_test 27i "$LFS getstripe with some objects"
1782 test_mkdir $DIR/$tdir
1783 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1784 error "setstripe failed" || true
1786 run_test 27j "setstripe with bad stripe offset (should return error)"
1788 test_27k() { # bug 2844
1789 test_mkdir $DIR/$tdir
1790 local file=$DIR/$tdir/$tfile
1791 local ll_max_blksize=$((4 * 1024 * 1024))
1792 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1793 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1794 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1795 dd if=/dev/zero of=$file bs=4k count=1
1796 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1797 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1799 run_test 27k "limit i_blksize for broken user apps"
1802 mcreate $DIR/$tfile || error "creating file"
1803 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1804 error "setstripe should have failed" || true
1806 run_test 27l "check setstripe permissions (should return error)"
1809 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1811 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1812 skip_env "multiple clients -- skipping"
1814 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1816 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1817 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1819 trap simple_cleanup_common EXIT
1820 test_mkdir $DIR/$tdir
1821 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1822 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1823 error "dd should fill OST0"
1825 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1827 [ $i -gt 256 ] && break
1830 touch $DIR/$tdir/$tfile.$i
1831 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1832 awk '{print $1}'| grep -w "0") ] &&
1833 error "OST0 was full but new created file still use it"
1835 touch $DIR/$tdir/$tfile.$i
1836 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1837 awk '{print $1}'| grep -w "0") ] &&
1838 error "OST0 was full but new created file still use it"
1839 simple_cleanup_common
1841 run_test 27m "create file while OST0 was full"
1843 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1844 # if the OST isn't full anymore.
1846 local ostidx=${1:-""}
1851 local list=$(comma_list $(osts_nodes))
1852 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1854 do_nodes $list lctl set_param fail_loc=0
1855 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1856 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1857 awk '{print $1 * 2;exit;}')
1858 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1860 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1863 __exhaust_precreations() {
1866 local FAILIDX=${3:-$OSTIDX}
1867 local ofacet=ost$((OSTIDX + 1))
1869 mkdir_on_mdt0 $DIR/$tdir
1870 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1871 local mfacet=mds$((mdtidx + 1))
1872 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1874 local OST=$(ostname_from_index $OSTIDX)
1877 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1878 local last_id=$(do_facet $mfacet lctl get_param -n \
1879 osp.$mdtosc_proc1.prealloc_last_id)
1880 local next_id=$(do_facet $mfacet lctl get_param -n \
1881 osp.$mdtosc_proc1.prealloc_next_id)
1883 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1884 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1886 test_mkdir -p $DIR/$tdir/${OST}
1887 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1888 #define OBD_FAIL_OST_ENOSPC 0x215
1889 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1890 echo "Creating to objid $last_id on ost $OST..."
1891 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1892 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1893 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1896 exhaust_precreations() {
1897 __exhaust_precreations $1 $2 $3
1901 exhaust_all_precreations() {
1903 for (( i=0; i < OSTCOUNT; i++ )) ; do
1904 __exhaust_precreations $i $1 -1
1910 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1911 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1912 remote_mds_nodsh && skip "remote MDS with nodsh"
1913 remote_ost_nodsh && skip "remote OST with nodsh"
1916 rm -f $DIR/$tdir/$tfile
1917 exhaust_precreations 0 0x80000215
1918 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1919 touch $DIR/$tdir/$tfile || error "touch failed"
1920 $LFS getstripe $DIR/$tdir/$tfile
1923 run_test 27n "create file with some full OSTs"
1926 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1928 remote_mds_nodsh && skip "remote MDS with nodsh"
1929 remote_ost_nodsh && skip "remote OST with nodsh"
1932 rm -f $DIR/$tdir/$tfile
1933 exhaust_all_precreations 0x215
1935 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1940 run_test 27o "create file with all full OSTs (should error)"
1942 function create_and_checktime() {
1947 for ((i=0; i < $loops; i++)); do
1948 local start=$SECONDS
1949 multiop $fname-$i Oc
1950 ((SECONDS-start < TIMEOUT)) ||
1951 error "creation took " $((SECONDS-$start)) && return 1
1956 local mdts=$(comma_list $(mdts_nodes))
1958 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1959 skip "Need MDS version at least 2.13.57"
1961 local f0=$DIR/${tfile}-0
1962 local f1=$DIR/${tfile}-1
1964 wait_delete_completed
1966 # refill precreated objects
1967 $LFS setstripe -i0 -c1 $f0
1969 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1970 # force QoS allocation policy
1971 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1972 stack_trap "do_nodes $mdts $LCTL set_param \
1973 lov.*.qos_threshold_rr=$saved" EXIT
1976 # one OST is unavailable, but still have few objects preallocated
1978 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1979 rm -rf $f1 $DIR/$tdir*" EXIT
1981 for ((i=0; i < 7; i++)); do
1982 mkdir $DIR/$tdir$i || error "can't create dir"
1983 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1984 error "can't set striping"
1986 for ((i=0; i < 7; i++)); do
1987 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1991 run_test 27oo "don't let few threads to reserve too many objects"
1994 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1995 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1996 remote_mds_nodsh && skip "remote MDS with nodsh"
1997 remote_ost_nodsh && skip "remote OST with nodsh"
2000 rm -f $DIR/$tdir/$tfile
2001 test_mkdir $DIR/$tdir
2003 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
2004 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
2005 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
2007 exhaust_precreations 0 0x80000215
2008 echo foo >> $DIR/$tdir/$tfile || error "append failed"
2009 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
2010 $LFS getstripe $DIR/$tdir/$tfile
2014 run_test 27p "append to a truncated file with some full OSTs"
2017 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2018 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2019 remote_mds_nodsh && skip "remote MDS with nodsh"
2020 remote_ost_nodsh && skip "remote OST with nodsh"
2023 rm -f $DIR/$tdir/$tfile
2025 mkdir_on_mdt0 $DIR/$tdir
2026 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
2027 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
2028 error "truncate $DIR/$tdir/$tfile failed"
2029 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
2031 exhaust_all_precreations 0x215
2033 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
2034 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
2038 run_test 27q "append to truncated file with all OSTs full (should error)"
2041 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2042 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2043 remote_mds_nodsh && skip "remote MDS with nodsh"
2044 remote_ost_nodsh && skip "remote OST with nodsh"
2047 rm -f $DIR/$tdir/$tfile
2048 exhaust_precreations 0 0x80000215
2050 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
2054 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
2056 test_27s() { # bug 10725
2057 test_mkdir $DIR/$tdir
2058 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2059 local stripe_count=0
2060 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2061 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2062 error "stripe width >= 2^32 succeeded" || true
2065 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2067 test_27t() { # bug 10864
2072 $WLFS getstripe $tfile
2075 run_test 27t "check that utils parse path correctly"
2077 test_27u() { # bug 4900
2078 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2079 remote_mds_nodsh && skip "remote MDS with nodsh"
2082 local list=$(comma_list $(mdts_nodes))
2084 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2085 do_nodes $list $LCTL set_param fail_loc=0x139
2086 test_mkdir -p $DIR/$tdir
2087 trap simple_cleanup_common EXIT
2088 createmany -o $DIR/$tdir/t- 1000
2089 do_nodes $list $LCTL set_param fail_loc=0
2091 TLOG=$TMP/$tfile.getstripe
2092 $LFS getstripe $DIR/$tdir > $TLOG
2093 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2094 unlinkmany $DIR/$tdir/t- 1000
2096 [[ $OBJS -gt 0 ]] &&
2097 error "$OBJS objects created on OST-0. See $TLOG" ||
2100 run_test 27u "skip object creation on OSC w/o objects"
2102 test_27v() { # bug 4900
2103 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2104 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2105 remote_mds_nodsh && skip "remote MDS with nodsh"
2106 remote_ost_nodsh && skip "remote OST with nodsh"
2108 exhaust_all_precreations 0x215
2111 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2113 touch $DIR/$tdir/$tfile
2114 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2116 for (( i=1; i < OSTCOUNT; i++ )); do
2117 do_facet ost$i lctl set_param fail_loc=0x705
2119 local START=`date +%s`
2120 createmany -o $DIR/$tdir/$tfile 32
2122 local FINISH=`date +%s`
2123 local TIMEOUT=`lctl get_param -n timeout`
2124 local PROCESS=$((FINISH - START))
2125 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2126 error "$FINISH - $START >= $TIMEOUT / 2"
2127 sleep $((TIMEOUT / 2 - PROCESS))
2130 run_test 27v "skip object creation on slow OST"
2132 test_27w() { # bug 10997
2133 test_mkdir $DIR/$tdir
2134 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2135 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2136 error "stripe size $size != 65536" || true
2137 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2138 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2140 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2143 [[ $OSTCOUNT -lt 2 ]] &&
2144 skip_env "skipping multiple stripe count/offset test"
2146 test_mkdir $DIR/$tdir
2147 for i in $(seq 1 $OSTCOUNT); do
2149 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2150 error "setstripe -c $i -i $offset failed"
2151 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2152 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2153 [ $count -ne $i ] && error "stripe count $count != $i" || true
2154 [ $index -ne $offset ] &&
2155 error "stripe offset $index != $offset" || true
2158 run_test 27wa "check $LFS setstripe -c -i options"
2161 remote_ost_nodsh && skip "remote OST with nodsh"
2162 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2163 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2165 OFFSET=$(($OSTCOUNT - 1))
2167 local OST=$(ostname_from_index $OSTIDX)
2169 test_mkdir $DIR/$tdir
2170 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2171 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2173 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2174 for i in $(seq 0 $OFFSET); do
2175 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2176 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2177 error "OST0 was degraded but new created file still use it"
2179 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2181 run_test 27x "create files while OST0 is degraded"
2184 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2185 remote_mds_nodsh && skip "remote MDS with nodsh"
2186 remote_ost_nodsh && skip "remote OST with nodsh"
2187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2189 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2190 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2191 osp.$mdtosc.prealloc_last_id)
2192 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2193 osp.$mdtosc.prealloc_next_id)
2194 local fcount=$((last_id - next_id))
2195 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2196 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2198 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2199 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2200 local OST_DEACTIVE_IDX=-1
2205 for OSC in $MDS_OSCS; do
2206 OST=$(osc_to_ost $OSC)
2207 OSTIDX=$(index_from_ostuuid $OST)
2208 if [ $OST_DEACTIVE_IDX == -1 ]; then
2209 OST_DEACTIVE_IDX=$OSTIDX
2211 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2212 echo $OSC "is Deactivated:"
2213 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2217 OSTIDX=$(index_from_ostuuid $OST)
2218 test_mkdir $DIR/$tdir
2219 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2221 for OSC in $MDS_OSCS; do
2222 OST=$(osc_to_ost $OSC)
2223 OSTIDX=$(index_from_ostuuid $OST)
2224 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2225 echo $OST "is degraded:"
2226 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2227 obdfilter.$OST.degraded=1
2232 createmany -o $DIR/$tdir/$tfile $fcount
2234 for OSC in $MDS_OSCS; do
2235 OST=$(osc_to_ost $OSC)
2236 OSTIDX=$(index_from_ostuuid $OST)
2237 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2238 echo $OST "is recovered from degraded:"
2239 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2240 obdfilter.$OST.degraded=0
2242 do_facet $SINGLEMDS lctl --device %$OSC activate
2246 # all osp devices get activated, hence -1 stripe count restored
2247 local stripe_count=0
2249 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2250 # devices get activated.
2252 $LFS setstripe -c -1 $DIR/$tfile
2253 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2255 [ $stripe_count -ne $OSTCOUNT ] &&
2256 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2259 run_test 27y "create files while OST0 is degraded and the rest inactive"
2265 lmm_count=$($LFS getstripe -c $1)
2266 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2267 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2269 local old_ifs="$IFS"
2271 fid=($($LFS path2fid $1))
2274 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2275 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2277 # compare lmm_seq and lu_fid->f_seq
2278 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2279 # compare lmm_object_id and lu_fid->oid
2280 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2282 # check the trusted.fid attribute of the OST objects of the file
2283 local have_obdidx=false
2285 $LFS getstripe $1 | while read obdidx oid hex seq; do
2286 # skip lines up to and including "obdidx"
2287 [ -z "$obdidx" ] && break
2288 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2289 $have_obdidx || continue
2291 local ost=$((obdidx + 1))
2292 local dev=$(ostdevname $ost)
2295 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2297 seq=$(echo $seq | sed -e "s/^0x//g")
2298 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2299 oid_hex=$(echo $oid)
2301 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2303 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2307 # Don't unmount/remount the OSTs if we don't need to do that.
2308 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2309 # update too, until that use mount/ll_decode_filter_fid/mount.
2310 # Re-enable when debugfs will understand new filter_fid.
2312 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2313 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2314 $dev 2>/dev/null" | grep "parent=")
2316 if [ -z "$ff" ]; then
2318 mount_fstype ost$ost
2319 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2320 $(facet_mntpt ost$ost)/$obj_file)
2321 unmount_fstype ost$ost
2322 start ost$ost $dev $OST_MOUNT_OPTS
2326 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2328 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2330 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2331 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2333 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2334 # stripe_size=1048576 component_id=1 component_start=0 \
2335 # component_end=33554432
2336 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2337 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2338 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2340 if grep -q 'stripe=' <<<$ff; then
2341 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2343 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2344 # into f_ver in this case. See comment on ff_parent.
2345 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2348 # compare lmm_seq and filter_fid->ff_parent.f_seq
2349 [ $ff_pseq = $lmm_seq ] ||
2350 error "FF parent SEQ $ff_pseq != $lmm_seq"
2351 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2352 [ $ff_poid = $lmm_oid ] ||
2353 error "FF parent OID $ff_poid != $lmm_oid"
2354 (($ff_pstripe == $stripe_nr)) ||
2355 error "FF stripe $ff_pstripe != $stripe_nr"
2357 stripe_nr=$((stripe_nr + 1))
2358 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2360 if grep -q 'stripe_count=' <<<$ff; then
2361 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2362 -e 's/ .*//' <<<$ff)
2363 [ $lmm_count = $ff_scnt ] ||
2364 error "FF stripe count $lmm_count != $ff_scnt"
2370 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2371 remote_ost_nodsh && skip "remote OST with nodsh"
2373 test_mkdir $DIR/$tdir
2374 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2375 { error "setstripe -c -1 failed"; return 1; }
2376 # We need to send a write to every object to get parent FID info set.
2377 # This _should_ also work for setattr, but does not currently.
2378 # touch $DIR/$tdir/$tfile-1 ||
2379 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2380 { error "dd $tfile-1 failed"; return 2; }
2381 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2382 { error "setstripe -c -1 failed"; return 3; }
2383 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2384 { error "dd $tfile-2 failed"; return 4; }
2386 # make sure write RPCs have been sent to OSTs
2389 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2390 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2392 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2394 test_27A() { # b=19102
2395 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2397 save_layout_restore_at_exit $MOUNT
2398 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2399 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2400 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2401 local default_size=$($LFS getstripe -S $MOUNT)
2402 local default_offset=$($LFS getstripe -i $MOUNT)
2403 local dsize=$(do_facet $SINGLEMDS \
2404 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2405 [ $default_size -eq $dsize ] ||
2406 error "stripe size $default_size != $dsize"
2407 [ $default_offset -eq -1 ] ||
2408 error "stripe offset $default_offset != -1"
2410 run_test 27A "check filesystem-wide default LOV EA values"
2412 test_27B() { # LU-2523
2413 test_mkdir $DIR/$tdir
2414 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2416 # open f1 with O_LOV_DELAY_CREATE
2418 # call setstripe ioctl on open file descriptor for f1
2420 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2424 # open f1 with O_LOV_DELAY_CREATE
2426 # call setstripe ioctl on open file descriptor for f1
2428 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2430 # Allow multiop to fail in imitation of NFS's busted semantics.
2433 run_test 27B "call setstripe on open unlinked file/rename victim"
2435 # 27C family tests full striping and overstriping
2436 test_27Ca() { #LU-2871
2437 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2445 test_mkdir $DIR/$tdir
2447 for i in $(seq 0 $((OSTCOUNT - 1))); do
2448 # set stripe across all OSTs starting from OST$i
2449 $LFS setstripe -i $i -c -1 $tfile$i
2450 # get striping information
2451 ost_idx=($($LFS getstripe $tfile$i |
2452 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2456 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2457 error "${#ost_idx[@]} != $OSTCOUNT"
2459 for index in $(seq 0 $((OSTCOUNT - 1))); do
2461 for j in $(echo ${ost_idx[@]}); do
2462 if [ $index -eq $j ]; then
2468 error "Can not find $index in ${ost_idx[@]}"
2472 run_test 27Ca "check full striping across all OSTs"
2475 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2476 skip "server does not support overstriping"
2477 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2478 skip_env "too many osts, skipping"
2480 test_mkdir -p $DIR/$tdir
2481 local setcount=$(($OSTCOUNT * 2))
2482 [ $setcount -lt 160 ] || large_xattr_enabled ||
2483 skip_env "ea_inode feature disabled"
2485 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2486 error "setstripe failed"
2488 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2489 [ $count -eq $setcount ] ||
2490 error "stripe count $count, should be $setcount"
2492 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2493 error "overstriped should be set in pattern"
2495 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2498 run_test 27Cb "more stripes than OSTs with -C"
2501 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2502 skip "server does not support overstriping"
2503 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2505 test_mkdir -p $DIR/$tdir
2506 local setcount=$(($OSTCOUNT - 1))
2508 [ $setcount -lt 160 ] || large_xattr_enabled ||
2509 skip_env "ea_inode feature disabled"
2511 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2512 error "setstripe failed"
2514 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2515 [ $count -eq $setcount ] ||
2516 error "stripe count $count, should be $setcount"
2518 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2519 error "overstriped should not be set in pattern"
2521 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2524 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2527 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2528 skip "server does not support overstriping"
2529 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2530 large_xattr_enabled || skip_env "ea_inode feature disabled"
2532 test_mkdir -p $DIR/$tdir
2533 local setcount=$LOV_MAX_STRIPE_COUNT
2535 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2536 error "setstripe failed"
2538 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2539 [ $count -eq $setcount ] ||
2540 error "stripe count $count, should be $setcount"
2542 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2543 error "overstriped should be set in pattern"
2545 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2548 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2550 run_test 27Cd "test maximum stripe count"
2553 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2554 skip "server does not support overstriping"
2555 test_mkdir -p $DIR/$tdir
2557 pool_add $TESTNAME || error "Pool creation failed"
2558 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2562 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2563 error "setstripe failed"
2565 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2566 [ $count -eq $setcount ] ||
2567 error "stripe count $count, should be $setcount"
2569 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2570 error "overstriped should be set in pattern"
2572 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2575 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2577 run_test 27Ce "test pool with overstriping"
2580 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2581 skip "server does not support overstriping"
2582 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2583 skip_env "too many osts, skipping"
2585 test_mkdir -p $DIR/$tdir
2587 local setcount=$(($OSTCOUNT * 2))
2588 [ $setcount -lt 160 ] || large_xattr_enabled ||
2589 skip_env "ea_inode feature disabled"
2591 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2592 error "setstripe failed"
2594 echo 1 > $DIR/$tdir/$tfile
2596 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2597 [ $count -eq $setcount ] ||
2598 error "stripe count $count, should be $setcount"
2600 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2601 error "overstriped should be set in pattern"
2603 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2606 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2608 run_test 27Cf "test default inheritance with overstriping"
2611 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2612 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2613 remote_mds_nodsh && skip "remote MDS with nodsh"
2615 local POOL=${POOL:-testpool}
2617 local last_ost=$(($OSTCOUNT - 1))
2619 local ost_list=$(seq $first_ost $ost_step $last_ost)
2620 local ost_range="$first_ost $last_ost $ost_step"
2622 test_mkdir $DIR/$tdir
2623 pool_add $POOL || error "pool_add failed"
2624 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2627 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2629 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2630 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2631 skip27D+=" -s 30,31"
2632 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2633 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2634 skip27D+=" -s 32,33"
2635 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2637 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2638 error "llapi_layout_test failed"
2640 destroy_test_pools || error "destroy test pools failed"
2642 run_test 27D "validate llapi_layout API"
2644 # Verify that default_easize is increased from its initial value after
2645 # accessing a widely striped file.
2647 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2648 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2649 skip "client does not have LU-3338 fix"
2651 # 72 bytes is the minimum space required to store striping
2652 # information for a file striped across one OST:
2653 # (sizeof(struct lov_user_md_v3) +
2654 # sizeof(struct lov_user_ost_data_v1))
2656 $LCTL set_param -n llite.*.default_easize $min_easize ||
2657 error "lctl set_param failed"
2658 local easize=$($LCTL get_param -n llite.*.default_easize)
2660 [ $easize -eq $min_easize ] ||
2661 error "failed to set default_easize"
2663 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2664 error "setstripe failed"
2665 # In order to ensure stat() call actually talks to MDS we need to
2666 # do something drastic to this file to shake off all lock, e.g.
2667 # rename it (kills lookup lock forcing cache cleaning)
2668 mv $DIR/$tfile $DIR/${tfile}-1
2669 ls -l $DIR/${tfile}-1
2672 easize=$($LCTL get_param -n llite.*.default_easize)
2674 [ $easize -gt $min_easize ] ||
2675 error "default_easize not updated"
2677 run_test 27E "check that default extended attribute size properly increases"
2679 test_27F() { # LU-5346/LU-7975
2680 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2681 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2682 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2683 skip "Need MDS version at least 2.8.51"
2684 remote_ost_nodsh && skip "remote OST with nodsh"
2686 test_mkdir $DIR/$tdir
2688 $LFS setstripe -c 2 $DIR/$tdir
2690 # stop all OSTs to reproduce situation for LU-7975 ticket
2691 for num in $(seq $OSTCOUNT); do
2695 # open/create f0 with O_LOV_DELAY_CREATE
2696 # truncate f0 to a non-0 size
2698 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2700 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2701 # open/write it again to force delayed layout creation
2702 cat /etc/hosts > $DIR/$tdir/f0 &
2706 for num in $(seq $OSTCOUNT); do
2707 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2708 error "ost$num failed to start"
2711 wait $catpid || error "cat failed"
2713 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2714 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2715 error "wrong stripecount"
2718 run_test 27F "Client resend delayed layout creation with non-zero size"
2720 test_27G() { #LU-10629
2721 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2722 skip "Need MDS version at least 2.11.51"
2723 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2724 remote_mds_nodsh && skip "remote MDS with nodsh"
2725 local POOL=${POOL:-testpool}
2726 local ostrange="0 0 1"
2728 test_mkdir $DIR/$tdir
2729 touch $DIR/$tdir/$tfile.nopool
2730 pool_add $POOL || error "pool_add failed"
2731 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2732 $LFS setstripe -p $POOL $DIR/$tdir
2734 local pool=$($LFS getstripe -p $DIR/$tdir)
2736 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2737 touch $DIR/$tdir/$tfile.default
2738 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2739 $LFS find $DIR/$tdir -type f --pool $POOL
2740 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2741 [[ "$found" == "2" ]] ||
2742 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2744 $LFS setstripe -d $DIR/$tdir
2746 pool=$($LFS getstripe -p -d $DIR/$tdir)
2748 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2750 run_test 27G "Clear OST pool from stripe"
2753 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2754 skip "Need MDS version newer than 2.11.54"
2755 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2756 test_mkdir $DIR/$tdir
2757 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2758 touch $DIR/$tdir/$tfile
2759 $LFS getstripe -c $DIR/$tdir/$tfile
2760 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2761 error "two-stripe file doesn't have two stripes"
2763 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2764 $LFS getstripe -y $DIR/$tdir/$tfile
2765 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2766 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2767 error "expected l_ost_idx: [02]$ not matched"
2769 # make sure ost list has been cleared
2770 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2771 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2772 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2774 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2776 run_test 27H "Set specific OSTs stripe"
2779 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2780 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2781 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2782 skip "Need MDS version newer than 2.12.52"
2783 local pool=$TESTNAME
2784 local ostrange="1 1 1"
2786 save_layout_restore_at_exit $MOUNT
2787 $LFS setstripe -c 2 -i 0 $MOUNT
2788 pool_add $pool || error "pool_add failed"
2789 pool_add_targets $pool $ostrange ||
2790 error "pool_add_targets failed"
2791 test_mkdir $DIR/$tdir
2792 $LFS setstripe -p $pool $DIR/$tdir
2793 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2794 $LFS getstripe $DIR/$tdir/$tfile
2796 run_test 27I "check that root dir striping does not break parent dir one"
2799 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2800 skip "Need MDS version newer than 2.12.51"
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 |
2951 grep "lfm_magic:.*0x0CD50CD0" ||
2952 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2953 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2954 # - sizeof(lfm_type) - sizeof(lfm_flags)
2955 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2956 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2957 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2958 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2959 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2960 grep "lfm_flags:.*0x0000DA05" ||
2961 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2962 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2963 grep "lfm_value.*${uuid1}@${uuid2}" ||
2964 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2966 # file create in dir should fail
2967 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2968 touch $DIR/$tdir/${tdir}2/$tfile &&
2969 "$DIR/${tdir}2: file create should fail"
2972 chmod 777 $DIR/$tdir/$tdir ||
2973 error "$DIR/$tdir: chmod failed"
2974 chmod 777 $DIR/$tdir/${tdir}2 ||
2975 error "$DIR/${tdir}2: chmod failed"
2978 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2979 error "$DIR/$tdir: chown failed"
2980 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2981 error "$DIR/${tdir}2: chown failed"
2983 # rename should work
2984 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2985 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2986 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2987 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2990 rmdir $DIR/$tdir/${tdir}.new ||
2991 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2992 rmdir $DIR/$tdir/${tdir}2.new ||
2993 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2995 run_test 27K "basic ops on dir with foreign LMV"
2998 remote_mds_nodsh && skip "remote MDS with nodsh"
3000 local POOL=${POOL:-$TESTNAME}
3002 pool_add $POOL || error "pool_add failed"
3004 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
3005 error "pool_list does not contain ${FSNAME}.${POOL}:" \
3006 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
3008 run_test 27L "lfs pool_list gives correct pool name"
3011 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
3012 skip "Need MDS version >= than 2.12.57"
3013 remote_mds_nodsh && skip "remote MDS with nodsh"
3014 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
3016 test_mkdir $DIR/$tdir
3018 # Set default striping on directory
3022 # if we run against a 2.12 server which lacks overstring support
3023 # then the connect_flag will not report overstriping, even if client
3025 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
3026 stripe_opt="-C $setcount"
3027 elif (( $OSTCOUNT >= $setcount )); then
3028 stripe_opt="-c $setcount"
3030 skip "server does not support overstriping"
3032 $LFS setstripe $stripe_opt $DIR/$tdir
3034 echo 1 > $DIR/$tdir/${tfile}.1
3035 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
3036 [ $count -eq $setcount ] ||
3037 error "(1) stripe count $count, should be $setcount"
3039 # Capture existing append_stripe_count setting for restore
3040 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3041 local mdts=$(comma_list $(mdts_nodes))
3042 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
3044 local appendcount=$orig_count
3045 echo 1 >> $DIR/$tdir/${tfile}.2_append
3046 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
3047 [ $count -eq $appendcount ] ||
3048 error "(2)stripe count $count, should be $appendcount for append"
3050 # Disable O_APPEND striping, verify it works
3051 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3053 # Should now get the default striping, which is 4
3055 echo 1 >> $DIR/$tdir/${tfile}.3_append
3056 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3057 [ $count -eq $setcount ] ||
3058 error "(3) stripe count $count, should be $setcount"
3060 # Try changing the stripe count for append files
3061 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3063 # Append striping is now 2 (directory default is still 4)
3065 echo 1 >> $DIR/$tdir/${tfile}.4_append
3066 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3067 [ $count -eq $appendcount ] ||
3068 error "(4) stripe count $count, should be $appendcount for append"
3070 # Test append stripe count of -1
3071 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3072 appendcount=$OSTCOUNT
3073 echo 1 >> $DIR/$tdir/${tfile}.5
3074 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3075 [ $count -eq $appendcount ] ||
3076 error "(5) stripe count $count, should be $appendcount for append"
3078 # Set append striping back to default of 1
3079 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3081 # Try a new default striping, PFL + DOM
3082 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3084 # Create normal DOM file, DOM returns stripe count == 0
3086 touch $DIR/$tdir/${tfile}.6
3087 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3088 [ $count -eq $setcount ] ||
3089 error "(6) stripe count $count, should be $setcount"
3093 echo 1 >> $DIR/$tdir/${tfile}.7_append
3094 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3095 [ $count -eq $appendcount ] ||
3096 error "(7) stripe count $count, should be $appendcount for append"
3098 # Clean up DOM layout
3099 $LFS setstripe -d $DIR/$tdir
3101 save_layout_restore_at_exit $MOUNT
3102 # Now test that append striping works when layout is from root
3103 $LFS setstripe -c 2 $MOUNT
3104 # Make a special directory for this
3105 mkdir $DIR/${tdir}/${tdir}.2
3107 # Verify for normal file
3109 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3110 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3111 [ $count -eq $setcount ] ||
3112 error "(8) stripe count $count, should be $setcount"
3115 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3116 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3117 [ $count -eq $appendcount ] ||
3118 error "(9) stripe count $count, should be $appendcount for append"
3120 # Now test O_APPEND striping with pools
3121 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3122 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
3125 pool_add $TESTNAME || error "pool creation failed"
3126 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3128 echo 1 >> $DIR/$tdir/${tfile}.10_append
3130 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3131 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3133 # Check that count is still correct
3135 echo 1 >> $DIR/$tdir/${tfile}.11_append
3136 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3137 [ $count -eq $appendcount ] ||
3138 error "(11) stripe count $count, should be $appendcount for append"
3140 # Disable O_APPEND stripe count, verify pool works separately
3141 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3143 echo 1 >> $DIR/$tdir/${tfile}.12_append
3145 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3146 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3148 # Remove pool setting, verify it's not applied
3149 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3151 echo 1 >> $DIR/$tdir/${tfile}.13_append
3153 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3154 [ "$pool" = "" ] || error "(13) pool found: $pool"
3156 run_test 27M "test O_APPEND striping"
3159 combined_mgs_mds && skip "needs separate MGS/MDT"
3161 pool_add $TESTNAME || error "pool_add failed"
3162 do_facet mgs "$LCTL pool_list $FSNAME" |
3163 grep -Fx "${FSNAME}.${TESTNAME}" ||
3164 error "lctl pool_list on MGS failed"
3166 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3168 clean_foreign_symlink() {
3170 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3171 for i in $DIR/$tdir/* ; do
3172 $LFS unlink_foreign $i || true
3177 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3178 skip "Need MDS version newer than 2.12.51"
3180 test_mkdir $DIR/$tdir
3181 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3182 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3184 trap clean_foreign_symlink EXIT
3186 # enable foreign_symlink behaviour
3187 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3189 # foreign symlink LOV format is a partial path by default
3191 # create foreign file (lfs + API)
3192 $LFS setstripe --foreign=symlink --flags 0xda05 \
3193 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3194 error "$DIR/$tdir/${tfile}: create failed"
3196 $LFS getstripe -v $DIR/$tdir/${tfile} |
3197 grep "lfm_magic:.*0x0BD70BD0" ||
3198 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3199 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3200 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3201 $LFS getstripe -v $DIR/$tdir/${tfile} |
3202 grep "lfm_flags:.*0x0000DA05" ||
3203 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3204 $LFS getstripe $DIR/$tdir/${tfile} |
3205 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3206 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3208 # modify striping should fail
3209 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3210 error "$DIR/$tdir/$tfile: setstripe should fail"
3212 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3213 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3214 cat /etc/passwd > $DIR/$tdir/$tfile &&
3215 error "$DIR/$tdir/$tfile: write should fail"
3217 # rename should succeed
3218 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3219 error "$DIR/$tdir/$tfile: rename has failed"
3221 #remove foreign_symlink file should fail
3222 rm $DIR/$tdir/${tfile}.new &&
3223 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3226 mkdir /tmp/${uuid1} ||
3227 error "/tmp/${uuid1}: mkdir has failed"
3228 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3229 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3230 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3231 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3232 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3233 #read should succeed now
3234 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3235 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3236 #write should succeed now
3237 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3238 error "$DIR/$tdir/${tfile}.new: write should succeed"
3239 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3240 error "$DIR/$tdir/${tfile}.new: diff has failed"
3241 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3242 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3244 #check that getstripe still works
3245 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3246 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3248 # chmod should still succeed
3249 chmod 644 $DIR/$tdir/${tfile}.new ||
3250 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3252 # chown should still succeed
3253 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3254 error "$DIR/$tdir/${tfile}.new: chown has failed"
3256 # rename should still succeed
3257 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3258 error "$DIR/$tdir/${tfile}.new: rename has failed"
3260 #remove foreign_symlink file should still fail
3261 rm $DIR/$tdir/${tfile} &&
3262 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3264 #use special ioctl() to unlink foreign_symlink file
3265 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3266 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3269 run_test 27O "basic ops on foreign file of symlink type"
3272 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3273 skip "Need MDS version newer than 2.12.49"
3275 test_mkdir $DIR/$tdir
3276 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3277 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3279 trap clean_foreign_symlink EXIT
3281 # enable foreign_symlink behaviour
3282 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3284 # foreign symlink LMV format is a partial path by default
3286 # create foreign dir (lfs + API)
3287 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3288 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3289 error "$DIR/$tdir/${tdir}: create failed"
3291 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3292 grep "lfm_magic:.*0x0CD50CD0" ||
3293 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3294 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3295 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3296 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3297 grep "lfm_flags:.*0x0000DA05" ||
3298 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3299 $LFS getdirstripe $DIR/$tdir/${tdir} |
3300 grep "lfm_value.*${uuid1}/${uuid2}" ||
3301 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3303 # file create in dir should fail
3304 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3305 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
3307 # rename should succeed
3308 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3309 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3311 #remove foreign_symlink dir should fail
3312 rmdir $DIR/$tdir/${tdir}.new &&
3313 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3316 mkdir -p /tmp/${uuid1}/${uuid2} ||
3317 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3318 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3319 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3320 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3321 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3322 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3323 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3324 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3326 #check that getstripe fails now that foreign_symlink enabled
3327 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3328 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3330 # file create in dir should work now
3331 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3332 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3333 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3334 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3335 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3336 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3338 # chmod should still succeed
3339 chmod 755 $DIR/$tdir/${tdir}.new ||
3340 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3342 # chown should still succeed
3343 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3344 error "$DIR/$tdir/${tdir}.new: chown has failed"
3346 # rename should still succeed
3347 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3348 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3350 #remove foreign_symlink dir should still fail
3351 rmdir $DIR/$tdir/${tdir} &&
3352 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3354 #use special ioctl() to unlink foreign_symlink file
3355 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3356 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3358 #created file should still exist
3359 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3360 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3361 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3362 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3364 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3367 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3368 stack_trap "rm -f $TMP/$tfile*"
3370 test_mkdir $DIR/$tdir-1
3371 test_mkdir $DIR/$tdir-2
3373 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3374 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3376 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3377 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3379 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3380 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3382 # Create some bad symlinks and ensure that we don't loop
3383 # forever or something. These should return ELOOP (40) and
3384 # ENOENT (2) but I don't want to test for that because there's
3385 # always some weirdo architecture that needs to ruin
3386 # everything by defining these error numbers differently.
3388 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3389 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3391 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3392 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3396 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3398 # createtest also checks that device nodes are created and
3399 # then visible correctly (#2091)
3400 test_28() { # bug 2091
3402 $CREATETEST $DIR/d28/ct || error "createtest failed"
3404 run_test 28 "create/mknod/mkdir with bad file types ============"
3407 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3409 sync; sleep 1; sync # flush out any dirty pages from previous tests
3416 declare -i LOCKCOUNTORIG=0
3417 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3418 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3420 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3422 declare -i LOCKUNUSEDCOUNTORIG=0
3423 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3424 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3431 declare -i LOCKCOUNTCURRENT=0
3432 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3433 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3436 declare -i LOCKUNUSEDCOUNTCURRENT=0
3437 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3438 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3441 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3442 $LCTL set_param -n ldlm.dump_namespaces ""
3443 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3444 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3445 log "dumped log to $TMP/test_29.dk (bug 5793)"
3448 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3449 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3450 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3451 log "dumped log to $TMP/test_29.dk (bug 5793)"
3455 run_test 29 "IT_GETATTR regression ============================"
3457 test_30a() { # was test_30
3458 cp $(which ls) $DIR || cp /bin/ls $DIR
3459 $DIR/ls / || error "Can't execute binary from lustre"
3462 run_test 30a "execute binary from Lustre (execve) =============="
3465 cp `which ls` $DIR || cp /bin/ls $DIR
3467 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3470 run_test 30b "execute binary from Lustre as non-root ==========="
3472 test_30c() { # b=22376
3473 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3475 cp $(which ls) $DIR || cp /bin/ls $DIR
3477 cancel_lru_locks mdc
3478 cancel_lru_locks osc
3479 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3482 run_test 30c "execute binary from Lustre without read perms ===="
3485 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3487 for i in {1..10}; do
3488 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3491 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3492 wait $PID || error "executing dd from Lustre failed"
3498 run_test 30d "execute binary from Lustre while clear locks"
3501 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3502 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3504 run_test 31a "open-unlink file =================================="
3507 touch $DIR/f31 || error "touch $DIR/f31 failed"
3508 ln $DIR/f31 $DIR/f31b || error "ln failed"
3509 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3510 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3512 run_test 31b "unlink file with multiple links while open ======="
3515 touch $DIR/f31 || error "touch $DIR/f31 failed"
3516 ln $DIR/f31 $DIR/f31c || error "ln failed"
3517 multiop_bg_pause $DIR/f31 O_uc ||
3518 error "multiop_bg_pause for $DIR/f31 failed"
3520 $MULTIOP $DIR/f31c Ouc
3521 kill -USR1 $MULTIPID
3524 run_test 31c "open-unlink file with multiple links ============="
3527 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3528 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3530 run_test 31d "remove of open directory ========================="
3532 test_31e() { # bug 2904
3533 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3535 run_test 31e "remove of open non-empty directory ==============="
3537 test_31f() { # bug 4554
3538 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3541 test_mkdir $DIR/d31f
3542 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3543 cp /etc/hosts $DIR/d31f
3545 $LFS getstripe $DIR/d31f/hosts
3546 multiop_bg_pause $DIR/d31f D_c || return 1
3549 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3550 test_mkdir $DIR/d31f
3551 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3552 cp /etc/hosts $DIR/d31f
3554 $LFS getstripe $DIR/d31f/hosts
3555 multiop_bg_pause $DIR/d31f D_c || return 1
3558 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3559 wait $MULTIPID || error "first opendir $MULTIPID failed"
3563 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3564 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3567 run_test 31f "remove of open directory with open-unlink file ==="
3570 echo "-- cross directory link --"
3571 test_mkdir -c1 $DIR/${tdir}ga
3572 test_mkdir -c1 $DIR/${tdir}gb
3573 touch $DIR/${tdir}ga/f
3574 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3575 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3576 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3577 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3578 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3580 run_test 31g "cross directory link==============="
3583 echo "-- cross directory link --"
3584 test_mkdir -c1 $DIR/${tdir}
3585 test_mkdir -c1 $DIR/${tdir}/dir
3586 touch $DIR/${tdir}/f
3587 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3588 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3589 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3590 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3591 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3593 run_test 31h "cross directory link under child==============="
3596 echo "-- cross directory link --"
3597 test_mkdir -c1 $DIR/$tdir
3598 test_mkdir -c1 $DIR/$tdir/dir
3599 touch $DIR/$tdir/dir/f
3600 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3601 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3602 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3603 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3604 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3606 run_test 31i "cross directory link under parent==============="
3609 test_mkdir -c1 -p $DIR/$tdir
3610 test_mkdir -c1 -p $DIR/$tdir/dir1
3611 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3612 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3613 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3614 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3617 run_test 31j "link for directory==============="
3620 test_mkdir -c1 -p $DIR/$tdir
3622 touch $DIR/$tdir/exist
3623 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3624 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3625 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3626 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3627 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3628 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3629 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3632 run_test 31k "link to file: the same, non-existing, dir==============="
3638 touch $DIR/d31m2/exist
3639 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3640 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3641 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3642 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3643 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3644 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3647 run_test 31m "link to file: the same, non-existing, dir==============="
3650 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3651 nlink=$(stat --format=%h $DIR/$tfile)
3652 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3654 local cmd="exec $fd<$DIR/$tfile"
3657 trap "eval $cmd" EXIT
3658 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3659 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3660 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3661 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3662 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3665 run_test 31n "check link count of unlinked file"
3668 local tempfile=$(mktemp $1_XXXXXX)
3669 mlink $tempfile $1 2> /dev/null &&
3670 echo "$BASHPID: link $tempfile to $1 succeeded"
3674 test_31o() { # LU-2901
3675 test_mkdir $DIR/$tdir
3676 for LOOP in $(seq 100); do
3677 rm -f $DIR/$tdir/$tfile*
3678 for THREAD in $(seq 8); do
3679 link_one $DIR/$tdir/$tfile.$LOOP &
3682 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3683 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3684 error "$LINKS duplicate links to $tfile.$LOOP" &&
3688 run_test 31o "duplicate hard links with same filename"
3691 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3693 test_mkdir $DIR/$tdir
3694 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3695 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3697 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3698 error "open unlink test1 failed"
3699 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3700 error "open unlink test2 failed"
3702 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3703 error "test1 still exists"
3704 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3705 error "test2 still exists"
3707 run_test 31p "remove of open striped directory"
3710 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3712 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3713 index=$($LFS getdirstripe -i $DIR/$tdir)
3714 [ $index -eq 3 ] || error "first stripe index $index != 3"
3715 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3716 [ $index -eq 1 ] || error "second stripe index $index != 1"
3718 # when "-c <stripe_count>" is set, the number of MDTs specified after
3719 # "-i" should equal to the stripe count
3720 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3722 run_test 31q "create striped directory on specific MDTs"
3724 cleanup_test32_mount() {
3727 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3728 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3729 losetup -d $loopdev || true
3735 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3737 echo "== more mountpoints and symlinks ================="
3738 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3739 trap cleanup_test32_mount EXIT
3740 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3741 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3742 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3743 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3744 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3745 cleanup_test32_mount
3747 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3750 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3752 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3753 trap cleanup_test32_mount EXIT
3754 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3755 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3756 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3757 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3758 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3759 cleanup_test32_mount
3761 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3764 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3766 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3767 trap cleanup_test32_mount EXIT
3768 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3769 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3770 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3771 test_mkdir -p $DIR/$tdir/d2/test_dir
3772 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3773 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3774 cleanup_test32_mount
3776 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3779 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3781 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3782 trap cleanup_test32_mount EXIT
3783 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3784 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3785 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3786 test_mkdir -p $DIR/$tdir/d2/test_dir
3787 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3788 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3789 cleanup_test32_mount
3791 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3795 test_mkdir -p $DIR/$tdir/tmp
3796 local tmp_dir=$DIR/$tdir/tmp
3797 ln -s $DIR/$tdir $tmp_dir/symlink11
3798 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3799 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3800 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3802 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3806 test_mkdir -p $DIR/$tdir/tmp
3807 local tmp_dir=$DIR/$tdir/tmp
3808 ln -s $DIR/$tdir $tmp_dir/symlink11
3809 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3810 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3811 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3813 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3816 local tmp_dir=$DIR/$tdir/tmp
3817 test_mkdir -p $tmp_dir
3818 test_mkdir $DIR/${tdir}2
3819 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3820 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3821 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3822 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3823 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3824 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3826 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3829 rm -fr $DIR/$tdir $DIR/${tdir}2
3830 tmp_dir=$DIR/$tdir/tmp
3831 test_mkdir -p $tmp_dir
3832 test_mkdir $DIR/${tdir}2
3833 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3834 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3835 ls $tmp_dir/symlink12 || error "listing symlink12"
3836 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3838 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3841 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3843 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3844 trap cleanup_test32_mount EXIT
3845 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3846 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3847 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3848 touch $DIR/$tdir/test_file
3849 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3850 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3851 cleanup_test32_mount
3853 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3856 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3858 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3859 trap cleanup_test32_mount EXIT
3860 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3861 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3862 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3863 touch $DIR/$tdir/test_file
3864 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3865 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3866 cleanup_test32_mount
3868 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3874 trap cleanup_test32_mount EXIT
3875 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3876 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3877 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3878 test_mkdir -p $DIR/$tdir/d2
3879 touch $DIR/$tdir/d2/test_file || error "touch failed"
3880 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3881 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3882 cleanup_test32_mount
3884 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3887 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3890 trap cleanup_test32_mount EXIT
3891 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3892 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3893 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3894 test_mkdir -p $DIR/$tdir/d2
3895 touch $DIR/$tdir/d2/test_file || error "touch failed"
3896 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3897 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3898 cleanup_test32_mount
3900 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3904 test_mkdir -p $DIR/d32m/tmp
3905 TMP_DIR=$DIR/d32m/tmp
3906 ln -s $DIR $TMP_DIR/symlink11
3907 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3908 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3909 error "symlink11 not a link"
3910 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3911 error "symlink01 not a link"
3913 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3917 test_mkdir -p $DIR/d32n/tmp
3918 TMP_DIR=$DIR/d32n/tmp
3919 ln -s $DIR $TMP_DIR/symlink11
3920 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3921 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3922 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3924 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3928 test_mkdir -p $DIR/d32o/tmp
3929 TMP_DIR=$DIR/d32o/tmp
3930 ln -s $DIR/$tfile $TMP_DIR/symlink12
3931 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3932 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3933 error "symlink12 not a link"
3934 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3935 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3936 error "$DIR/d32o/tmp/symlink12 not file type"
3937 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3938 error "$DIR/d32o/symlink02 not file type"
3940 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3950 test_mkdir -p $DIR/d32p/tmp
3952 TMP_DIR=$DIR/d32p/tmp
3954 ln -s $DIR/$tfile $TMP_DIR/symlink12
3956 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3958 cat $DIR/d32p/tmp/symlink12 ||
3959 error "Can't open $DIR/d32p/tmp/symlink12"
3961 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3964 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3967 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3969 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3970 trap cleanup_test32_mount EXIT
3971 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3972 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3973 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3974 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3975 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3976 cleanup_test32_mount
3978 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3981 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3983 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3984 trap cleanup_test32_mount EXIT
3985 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3986 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3987 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3988 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3989 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3990 cleanup_test32_mount
3992 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3997 chmod 444 $DIR/$tfile
3998 chown $RUNAS_ID $DIR/$tfile
4000 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4003 run_test 33aa "write file with mode 444 (should return error)"
4007 test_mkdir $DIR/$tdir
4008 chown $RUNAS_ID $DIR/$tdir
4009 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
4010 error "$RUNAS create $tdir/$tfile failed"
4011 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4012 error "open RDWR" || true
4014 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4018 test_mkdir $DIR/$tdir
4019 chown $RUNAS_ID $DIR/$tdir
4020 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4022 run_test 33b "test open file with malformed flags (No panic)"
4025 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4026 remote_ost_nodsh && skip "remote OST with nodsh"
4034 test_mkdir $DIR/$tdir
4035 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4038 for ostnum in $(seq $OSTCOUNT); do
4039 # test-framework's OST numbering is one-based, while Lustre's
4041 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4042 # check if at least some write_bytes stats are counted
4043 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4044 obdfilter.$ostname.stats |
4045 awk '/^write_bytes/ {print $7}' )
4046 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4047 if (( ${write_bytes:-0} > 0 )); then
4053 $all_zeros || return 0
4056 echo foo > $DIR/$tdir/bar
4060 # Total up write_bytes after writing. We'd better find non-zeros.
4061 for ostnum in $(seq $OSTCOUNT); do
4062 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4063 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4064 obdfilter/$ostname/stats |
4065 awk '/^write_bytes/ {print $7}' )
4066 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4067 if (( ${write_bytes:-0} > 0 )); then
4074 for ostnum in $(seq $OSTCOUNT); do
4075 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4076 echo "Check write_bytes is in obdfilter.*.stats:"
4077 do_facet ost$ostnum lctl get_param -n \
4078 obdfilter.$ostname.stats
4080 error "OST not keeping write_bytes stats (b=22312)"
4083 run_test 33c "test write_bytes stats"
4086 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4090 local remote_dir=$DIR/$tdir/remote_dir
4092 test_mkdir $DIR/$tdir
4093 $LFS mkdir -i $MDTIDX $remote_dir ||
4094 error "create remote directory failed"
4096 touch $remote_dir/$tfile
4097 chmod 444 $remote_dir/$tfile
4098 chown $RUNAS_ID $remote_dir/$tfile
4100 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4102 chown $RUNAS_ID $remote_dir
4103 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4104 error "create" || true
4105 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4106 error "open RDWR" || true
4107 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4109 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4112 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4116 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4117 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4118 mkdir $DIR/$tdir/local_dir
4120 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4121 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4122 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4124 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4125 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4127 rmdir $DIR/$tdir/* || error "rmdir failed"
4130 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4131 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4132 mkdir $DIR/$tdir/local_dir
4134 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4135 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4136 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4138 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4139 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4141 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4144 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4145 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4146 mkdir $DIR/$tdir/local_dir
4148 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4149 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4150 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4152 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4153 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4155 run_test 33e "mkdir and striped directory should have same mode"
4159 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4163 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4164 remote_mds_nodsh && skip "remote MDS with nodsh"
4167 chmod go+rwx $DIR/$tdir
4168 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4169 trap cleanup_33f EXIT
4171 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4172 error "cannot create striped directory"
4174 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4175 error "cannot create files in striped directory"
4177 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4178 error "cannot remove files in striped directory"
4180 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4181 error "cannot remove striped directory"
4185 run_test 33f "nonroot user can create, access, and remove a striped directory"
4188 mkdir -p $DIR/$tdir/dir2
4190 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4192 [[ $err =~ "exists" ]] || error "Not exists error"
4194 run_test 33g "nonroot user create already existing root created file"
4197 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4198 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
4199 skip "Need MDS version at least 2.13.50"
4201 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir ||
4202 error "mkdir $tdir failed"
4203 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4205 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4208 for fname in $DIR/$tdir/$tfile.bak \
4209 $DIR/$tdir/$tfile.SAV \
4210 $DIR/$tdir/$tfile.orig \
4211 $DIR/$tdir/$tfile~; do
4212 touch $fname || error "touch $fname failed"
4213 index2=$($LFS getstripe -m $fname)
4214 [ $index -eq $index2 ] ||
4215 error "$fname MDT index mismatch $index != $index2"
4219 for i in {1..250}; do
4220 for fname in $(mktemp -u $DIR/$tdir/.$tfile.XXXXXX) \
4221 $(mktemp $DIR/$tdir/$tfile.XXXXXXXX); do
4222 touch $fname || error "touch $fname failed"
4223 index2=$($LFS getstripe -m $fname)
4224 if [[ $index != $index2 ]]; then
4225 failed=$((failed + 1))
4226 echo "$fname MDT index mismatch $index != $index2"
4230 echo "$failed MDT index mismatches"
4231 (( failed < 20 )) || error "MDT index mismatch $failed times"
4234 run_test 33h "temp file is located on the same MDT as target"
4236 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4239 $MCREATE $DIR/f34 || error "mcreate failed"
4240 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4241 error "getstripe failed"
4242 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4243 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4244 error "getstripe failed"
4245 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4246 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4248 run_test 34a "truncate file that has not been opened ==========="
4251 [ ! -f $DIR/f34 ] && test_34a
4252 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4253 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4254 $OPENFILE -f O_RDONLY $DIR/f34
4255 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4256 error "getstripe failed"
4257 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4258 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4260 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4263 [ ! -f $DIR/f34 ] && test_34a
4264 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4265 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4266 $OPENFILE -f O_RDWR $DIR/f34
4267 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4268 error "$LFS getstripe failed"
4269 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4270 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4272 run_test 34c "O_RDWR opening file-with-size works =============="
4275 [ ! -f $DIR/f34 ] && test_34a
4276 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4278 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4279 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4282 run_test 34d "write to sparse file ============================="
4286 $MCREATE $DIR/f34e || error "mcreate failed"
4287 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4288 $CHECKSTAT -s 1000 $DIR/f34e ||
4289 error "Size of $DIR/f34e not equal to 1000 bytes"
4290 $OPENFILE -f O_RDWR $DIR/f34e
4291 $CHECKSTAT -s 1000 $DIR/f34e ||
4292 error "Size of $DIR/f34e not equal to 1000 bytes"
4294 run_test 34e "create objects, some with size and some without =="
4296 test_34f() { # bug 6242, 6243
4297 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4301 $MCREATE $DIR/f34f || error "mcreate failed"
4302 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4303 dd if=$DIR/f34f of=$TMP/f34f
4304 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4305 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4306 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4307 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4308 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4310 run_test 34f "read from a file with no objects until EOF ======="
4313 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4315 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4317 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4318 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4319 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4320 cancel_lru_locks osc
4321 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4322 error "wrong size after lock cancel"
4324 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4325 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4326 error "expanding truncate failed"
4327 cancel_lru_locks osc
4328 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4329 error "wrong expanded size after lock cancel"
4331 run_test 34g "truncate long file ==============================="
4334 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4339 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4340 sync # Flush the cache so that multiop below does not block on cache
4341 # flush when getting the group lock
4342 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4345 # Since just timed wait is not good enough, let's do a sync write
4346 # that way we are sure enough time for a roundtrip + processing
4347 # passed + 2 seconds of extra margin.
4348 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4352 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4353 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4357 local nsz=`stat -c %s $DIR/$tfile`
4358 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4360 run_test 34h "ftruncate file under grouplock should not block"
4363 cp /bin/sh $DIR/f35a
4365 chown $RUNAS_ID $DIR/f35a
4366 $RUNAS $DIR/f35a && error || true
4369 run_test 35a "exec file with mode 444 (should return and not leak)"
4373 utime $DIR/f36 || error "utime failed for MDS"
4375 run_test 36a "MDS utime check (mknod, utime)"
4379 utime $DIR/f36 || error "utime failed for OST"
4381 run_test 36b "OST utime check (open, utime)"
4386 chown $RUNAS_ID $DIR/d36
4387 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4389 run_test 36c "non-root MDS utime check (mknod, utime)"
4392 [ ! -d $DIR/d36 ] && test_36c
4393 echo "" > $DIR/d36/f36
4394 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4396 run_test 36d "non-root OST utime check (open, utime)"
4399 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4401 test_mkdir $DIR/$tdir
4402 touch $DIR/$tdir/$tfile
4403 $RUNAS utime $DIR/$tdir/$tfile &&
4404 error "utime worked, expected failure" || true
4406 run_test 36e "utime on non-owned file (should return error)"
4410 local LANG_SAVE=$LANG
4411 local LC_LANG_SAVE=$LC_LANG
4412 export LANG=C LC_LANG=C # for date language
4414 DATESTR="Dec 20 2000"
4415 test_mkdir $DIR/$tdir
4416 lctl set_param fail_loc=$fl
4418 cp /etc/hosts $DIR/$tdir/$tfile
4419 sync & # write RPC generated with "current" inode timestamp, but delayed
4421 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4422 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4423 cancel_lru_locks $OSC
4424 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4426 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4427 echo "BEFORE: $LS_BEFORE" && \
4428 echo "AFTER : $LS_AFTER" && \
4429 echo "WANT : $DATESTR" && \
4430 error "$DIR/$tdir/$tfile timestamps changed" || true
4432 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4436 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4438 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4439 subr_36fh "0x80000214"
4441 run_test 36f "utime on file racing with OST BRW write =========="
4444 remote_ost_nodsh && skip "remote OST with nodsh"
4445 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4446 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4447 skip "Need MDS version at least 2.12.51"
4452 local tgt="obdfilter"
4454 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4456 test_mkdir $DIR/$tdir
4457 fmd_max_age=$(do_facet $facet \
4458 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4461 echo "FMD max age: ${fmd_max_age}s"
4462 touch $DIR/$tdir/$tfile
4463 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4464 gawk '{cnt=cnt+$1} END{print cnt}')
4465 echo "FMD before: $fmd"
4467 error "FMD wasn't create by touch"
4468 sleep $((fmd_max_age + 12))
4469 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4470 gawk '{cnt=cnt+$1} END{print cnt}')
4471 echo "FMD after: $fmd"
4473 error "FMD wasn't expired by ping"
4475 run_test 36g "FMD cache expiry ====================="
4478 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4480 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4481 subr_36fh "0x80000227"
4483 run_test 36h "utime on file racing with OST BRW write =========="
4486 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4488 test_mkdir $DIR/$tdir
4489 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4491 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4492 local new_mtime=$((mtime + 200))
4494 #change Modify time of striped dir
4495 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4496 error "change mtime failed"
4498 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4500 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4502 run_test 36i "change mtime on striped directory"
4504 # test_37 - duplicate with tests 32q 32r
4507 local file=$DIR/$tfile
4509 openfile -f O_DIRECTORY $file
4512 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4513 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4515 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4517 test_39a() { # was test_39
4519 touch $DIR/${tfile}2
4520 # ls -l $DIR/$tfile $DIR/${tfile}2
4521 # ls -lu $DIR/$tfile $DIR/${tfile}2
4522 # ls -lc $DIR/$tfile $DIR/${tfile}2
4524 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4525 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4527 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4529 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4531 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4532 error "O_TRUNC didn't change timestamps"
4535 run_test 39a "mtime changed on create"
4538 test_mkdir -c1 $DIR/$tdir
4539 cp -p /etc/passwd $DIR/$tdir/fopen
4540 cp -p /etc/passwd $DIR/$tdir/flink
4541 cp -p /etc/passwd $DIR/$tdir/funlink
4542 cp -p /etc/passwd $DIR/$tdir/frename
4543 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4546 echo "aaaaaa" >> $DIR/$tdir/fopen
4547 echo "aaaaaa" >> $DIR/$tdir/flink
4548 echo "aaaaaa" >> $DIR/$tdir/funlink
4549 echo "aaaaaa" >> $DIR/$tdir/frename
4551 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4552 local link_new=`stat -c %Y $DIR/$tdir/flink`
4553 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4554 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4556 cat $DIR/$tdir/fopen > /dev/null
4557 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4558 rm -f $DIR/$tdir/funlink2
4559 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4561 for (( i=0; i < 2; i++ )) ; do
4562 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4563 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4564 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4565 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4567 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4568 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4569 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4570 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4572 cancel_lru_locks $OSC
4573 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4576 run_test 39b "mtime change on open, link, unlink, rename ======"
4578 # this should be set to past
4579 TEST_39_MTIME=`date -d "1 year ago" +%s`
4585 local mtime0=`stat -c %Y $DIR1/$tfile`
4587 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4588 local mtime1=`stat -c %Y $DIR1/$tfile`
4589 [ "$mtime1" = $TEST_39_MTIME ] || \
4590 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4593 echo hello >> $DIR1/$tfile
4595 local mtime2=`stat -c %Y $DIR1/$tfile`
4596 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4597 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4599 mv $DIR1/$tfile $DIR1/$tfile-1
4601 for (( i=0; i < 2; i++ )) ; do
4602 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4603 [ "$mtime2" = "$mtime3" ] || \
4604 error "mtime ($mtime2) changed (to $mtime3) on rename"
4606 cancel_lru_locks $OSC
4607 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4610 run_test 39c "mtime change on rename ==========================="
4614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4617 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4619 for (( i=0; i < 2; i++ )) ; do
4620 local mtime=`stat -c %Y $DIR1/$tfile`
4621 [ $mtime = $TEST_39_MTIME ] || \
4622 error "mtime($mtime) is not set to $TEST_39_MTIME"
4624 cancel_lru_locks $OSC
4625 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4628 run_test 39d "create, utime, stat =============================="
4632 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4635 local mtime1=`stat -c %Y $DIR1/$tfile`
4637 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4639 for (( i=0; i < 2; i++ )) ; do
4640 local mtime2=`stat -c %Y $DIR1/$tfile`
4641 [ $mtime2 = $TEST_39_MTIME ] || \
4642 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4644 cancel_lru_locks $OSC
4645 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4648 run_test 39e "create, stat, utime, stat ========================"
4652 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4655 mtime1=`stat -c %Y $DIR1/$tfile`
4658 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4660 for (( i=0; i < 2; i++ )) ; do
4661 local mtime2=`stat -c %Y $DIR1/$tfile`
4662 [ $mtime2 = $TEST_39_MTIME ] || \
4663 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4665 cancel_lru_locks $OSC
4666 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4669 run_test 39f "create, stat, sleep, utime, stat ================="
4673 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4675 echo hello >> $DIR1/$tfile
4676 local mtime1=`stat -c %Y $DIR1/$tfile`
4679 chmod o+r $DIR1/$tfile
4681 for (( i=0; i < 2; i++ )) ; do
4682 local mtime2=`stat -c %Y $DIR1/$tfile`
4683 [ "$mtime1" = "$mtime2" ] || \
4684 error "lost mtime: $mtime2, should be $mtime1"
4686 cancel_lru_locks $OSC
4687 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4690 run_test 39g "write, chmod, stat ==============================="
4694 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4700 echo hello >> $DIR1/$tfile
4701 local mtime1=`stat -c %Y $DIR1/$tfile`
4703 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4705 if [ "$d1" != "$d2" ]; then
4706 echo "write and touch not within one second"
4708 for (( i=0; i < 2; i++ )) ; do
4709 local mtime2=`stat -c %Y $DIR1/$tfile`
4710 [ "$mtime2" = $TEST_39_MTIME ] || \
4711 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4713 cancel_lru_locks $OSC
4714 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4718 run_test 39h "write, utime within one second, stat ============="
4721 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4726 echo hello >> $DIR1/$tfile
4727 local mtime1=`stat -c %Y $DIR1/$tfile`
4729 mv $DIR1/$tfile $DIR1/$tfile-1
4731 for (( i=0; i < 2; i++ )) ; do
4732 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4734 [ "$mtime1" = "$mtime2" ] || \
4735 error "lost mtime: $mtime2, should be $mtime1"
4737 cancel_lru_locks $OSC
4738 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4741 run_test 39i "write, rename, stat =============================="
4744 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4746 start_full_debug_logging
4750 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4751 lctl set_param fail_loc=0x80000412
4752 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4753 error "multiop failed"
4755 local mtime1=`stat -c %Y $DIR1/$tfile`
4757 mv $DIR1/$tfile $DIR1/$tfile-1
4759 kill -USR1 $multipid
4760 wait $multipid || error "multiop close failed"
4762 for (( i=0; i < 2; i++ )) ; do
4763 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4764 [ "$mtime1" = "$mtime2" ] ||
4765 error "mtime is lost on close: $mtime2, " \
4769 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4771 lctl set_param fail_loc=0
4772 stop_full_debug_logging
4774 run_test 39j "write, rename, close, stat ======================="
4777 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4782 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4784 local mtime1=`stat -c %Y $DIR1/$tfile`
4786 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4788 kill -USR1 $multipid
4789 wait $multipid || error "multiop close failed"
4791 for (( i=0; i < 2; i++ )) ; do
4792 local mtime2=`stat -c %Y $DIR1/$tfile`
4794 [ "$mtime2" = $TEST_39_MTIME ] || \
4795 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4798 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4801 run_test 39k "write, utime, close, stat ========================"
4803 # this should be set to future
4804 TEST_39_ATIME=`date -d "1 year" +%s`
4807 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4808 remote_mds_nodsh && skip "remote MDS with nodsh"
4810 local atime_diff=$(do_facet $SINGLEMDS \
4811 lctl get_param -n mdd.*MDT0000*.atime_diff)
4813 mkdir_on_mdt0 $DIR/$tdir
4815 # test setting directory atime to future
4816 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4817 local atime=$(stat -c %X $DIR/$tdir)
4818 [ "$atime" = $TEST_39_ATIME ] ||
4819 error "atime is not set to future: $atime, $TEST_39_ATIME"
4821 # test setting directory atime from future to now
4822 local now=$(date +%s)
4823 touch -a -d @$now $DIR/$tdir
4825 atime=$(stat -c %X $DIR/$tdir)
4826 [ "$atime" -eq "$now" ] ||
4827 error "atime is not updated from future: $atime, $now"
4829 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
4832 # test setting directory atime when now > dir atime + atime_diff
4833 local d1=$(date +%s)
4835 local d2=$(date +%s)
4836 cancel_lru_locks mdc
4837 atime=$(stat -c %X $DIR/$tdir)
4838 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4839 error "atime is not updated : $atime, should be $d2"
4841 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
4844 # test not setting directory atime when now < dir atime + atime_diff
4846 cancel_lru_locks mdc
4847 atime=$(stat -c %X $DIR/$tdir)
4848 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4849 error "atime is updated to $atime, should remain $d1<atime<$d2"
4851 do_facet $SINGLEMDS \
4852 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4854 run_test 39l "directory atime update ==========================="
4857 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4861 local far_past_mtime=$(date -d "May 29 1953" +%s)
4862 local far_past_atime=$(date -d "Dec 17 1903" +%s)
4864 touch -m -d @$far_past_mtime $DIR1/$tfile
4865 touch -a -d @$far_past_atime $DIR1/$tfile
4867 for (( i=0; i < 2; i++ )) ; do
4868 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
4869 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
4870 error "atime or mtime set incorrectly"
4872 cancel_lru_locks $OSC
4873 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4876 run_test 39m "test atime and mtime before 1970"
4878 test_39n() { # LU-3832
4879 remote_mds_nodsh && skip "remote MDS with nodsh"
4881 local atime_diff=$(do_facet $SINGLEMDS \
4882 lctl get_param -n mdd.*MDT0000*.atime_diff)
4887 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4890 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4891 atime0=$(stat -c %X $DIR/$tfile)
4894 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4895 atime1=$(stat -c %X $DIR/$tfile)
4898 cancel_lru_locks mdc
4899 cancel_lru_locks osc
4900 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4901 atime2=$(stat -c %X $DIR/$tfile)
4903 do_facet $SINGLEMDS \
4904 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4906 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4907 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4909 run_test 39n "check that O_NOATIME is honored"
4912 TESTDIR=$DIR/$tdir/$tfile
4913 [ -e $TESTDIR ] && rm -rf $TESTDIR
4920 links2=$(stat -c %h .)
4921 [ $(($links1 + 2)) != $links2 ] &&
4922 error "wrong links count $(($links1 + 2)) != $links2"
4924 links3=$(stat -c %h .)
4925 [ $(($links1 + 1)) != $links3 ] &&
4926 error "wrong links count $links1 != $links3"
4929 run_test 39o "directory cached attributes updated after create"
4932 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4935 TESTDIR=$DIR/$tdir/$tdir
4936 [ -e $TESTDIR ] && rm -rf $TESTDIR
4937 test_mkdir -p $TESTDIR
4941 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4942 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4944 links2=$(stat -c %h .)
4945 [ $(($links1 + 2)) != $links2 ] &&
4946 error "wrong links count $(($links1 + 2)) != $links2"
4948 links3=$(stat -c %h .)
4949 [ $(($links1 + 1)) != $links3 ] &&
4950 error "wrong links count $links1 != $links3"
4953 run_test 39p "remote directory cached attributes updated after create ========"
4956 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
4957 skip "no atime update on old OST"
4958 if [ "$ost1_FSTYPE" != ldiskfs ]; then
4959 skip_env "ldiskfs only test"
4963 saved_adiff=$(do_facet ost1 \
4964 lctl get_param -n obdfilter.*OST0000.atime_diff)
4965 stack_trap "do_facet ost1 \
4966 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
4968 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
4970 $LFS setstripe -i 0 $DIR/$tfile
4971 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
4972 error "can't write initial file"
4973 cancel_lru_locks osc
4975 # exceed atime_diff and access file
4977 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
4978 error "can't udpate atime"
4980 local atime_cli=$(stat -c %X $DIR/$tfile)
4981 echo "client atime: $atime_cli"
4982 # allow atime update to be written to device
4983 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
4986 local ostdev=$(ostdevname 1)
4987 local fid=($(lfs getstripe -y $DIR/$tfile |
4988 awk '/l_fid:/ { print $2 }' | tr ':' ' '))
4989 local objpath="O/0/d$((${fid[1]} % 32))/$((${fid[1]}))"
4990 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
4992 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
4993 local atime_ost=$(do_facet ost1 "$cmd" |&
4994 awk -F'[: ]' '/atime:/ { print $4 }')
4995 (( atime_cli == atime_ost )) ||
4996 error "atime on client $atime_cli != ost $atime_ost"
4998 run_test 39r "lazy atime update on OST"
5000 test_39q() { # LU-8041
5001 local testdir=$DIR/$tdir
5003 multiop_bg_pause $testdir D_c || error "multiop failed"
5005 cancel_lru_locks mdc
5006 kill -USR1 $multipid
5007 local atime=$(stat -c %X $testdir)
5008 [ "$atime" -ne 0 ] || error "atime is zero"
5010 run_test 39q "close won't zero out atime"
5013 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5014 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5015 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5016 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5017 error "$tfile is not 4096 bytes in size"
5019 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5023 small_write $DIR/f41 18
5025 run_test 41 "test small file write + fstat ====================="
5027 count_ost_writes() {
5028 lctl get_param -n ${OSC}.*.stats |
5029 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5030 END { printf("%0.0f", writes) }'
5037 BG_DIRTY_RATIO_SAVE=10
5038 MAX_BG_DIRTY_RATIO=25
5042 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5043 # dirty_ratio, dirty_background_ratio
5044 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5045 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5046 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5047 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5049 # if file not here, we are a 2.4 kernel
5050 kill -CONT `pidof kupdated`
5055 # setup the trap first, so someone cannot exit the test at the
5056 # exact wrong time and mess up a machine
5057 trap start_writeback EXIT
5058 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5059 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5060 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5061 sysctl -w vm.dirty_writeback_centisecs=0
5062 sysctl -w vm.dirty_writeback_centisecs=0
5063 # save and increase /proc/sys/vm/dirty_ratio
5064 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5065 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5066 # save and increase /proc/sys/vm/dirty_background_ratio
5067 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5068 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5070 # if file not here, we are a 2.4 kernel
5071 kill -STOP `pidof kupdated`
5075 # ensure that all stripes have some grant before we test client-side cache
5077 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5078 dd if=/dev/zero of=$i bs=4k count=1
5083 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5084 # file truncation, and file removal.
5086 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5089 cancel_lru_locks $OSC
5091 sync; sleep 1; sync # just to be safe
5092 BEFOREWRITES=`count_ost_writes`
5093 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5094 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5095 AFTERWRITES=`count_ost_writes`
5096 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5097 error "$BEFOREWRITES < $AFTERWRITES"
5100 run_test 42a "ensure that we don't flush on close"
5103 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5106 cancel_lru_locks $OSC
5109 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5110 BEFOREWRITES=$(count_ost_writes)
5111 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
5112 AFTERWRITES=$(count_ost_writes)
5113 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5114 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5116 BEFOREWRITES=$(count_ost_writes)
5117 sync || error "sync: $?"
5118 AFTERWRITES=$(count_ost_writes)
5119 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5120 error "$BEFOREWRITES < $AFTERWRITES on sync"
5122 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5126 run_test 42b "test destroy of file with cached dirty data ======"
5128 # if these tests just want to test the effect of truncation,
5129 # they have to be very careful. consider:
5130 # - the first open gets a {0,EOF}PR lock
5131 # - the first write conflicts and gets a {0, count-1}PW
5132 # - the rest of the writes are under {count,EOF}PW
5133 # - the open for truncate tries to match a {0,EOF}PR
5134 # for the filesize and cancels the PWs.
5135 # any number of fixes (don't get {0,EOF} on open, match
5136 # composite locks, do smarter file size management) fix
5137 # this, but for now we want these tests to verify that
5138 # the cancellation with truncate intent works, so we
5139 # start the file with a full-file pw lock to match against
5140 # until the truncate.
5145 cancel_lru_locks $OSC
5147 # prime the file with 0,EOF PW to match
5151 # now the real test..
5152 dd if=/dev/zero of=$file bs=1024 count=100
5153 BEFOREWRITES=`count_ost_writes`
5154 $TRUNCATE $file $offset
5155 cancel_lru_locks $OSC
5156 AFTERWRITES=`count_ost_writes`
5161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5164 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5165 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5168 run_test 42c "test partial truncate of file with cached dirty data"
5171 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5174 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5175 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5178 run_test 42d "test complete truncate of file with cached dirty data"
5180 test_42e() { # bug22074
5181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5183 local TDIR=$DIR/${tdir}e
5184 local pages=16 # hardcoded 16 pages, don't change it.
5185 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5186 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5190 test_mkdir $DIR/${tdir}e
5191 $LFS setstripe -c 1 $TDIR
5192 createmany -o $TDIR/f $files
5194 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5196 # we assume that with $OSTCOUNT files, at least one of them will
5197 # be allocated on OST0.
5198 warmup_files=$((OSTCOUNT * max_dirty_mb))
5199 createmany -o $TDIR/w $warmup_files
5201 # write a large amount of data into one file and sync, to get good
5202 # avail_grant number from OST.
5203 for ((i=0; i<$warmup_files; i++)); do
5204 idx=$($LFS getstripe -i $TDIR/w$i)
5205 [ $idx -ne 0 ] && continue
5206 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5209 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5211 $LCTL get_param $proc_osc0/cur_dirty_bytes
5212 $LCTL get_param $proc_osc0/cur_grant_bytes
5214 # create as much dirty pages as we can while not to trigger the actual
5215 # RPCs directly. but depends on the env, VFS may trigger flush during this
5216 # period, hopefully we are good.
5217 for ((i=0; i<$warmup_files; i++)); do
5218 idx=$($LFS getstripe -i $TDIR/w$i)
5219 [ $idx -ne 0 ] && continue
5220 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5222 $LCTL get_param $proc_osc0/cur_dirty_bytes
5223 $LCTL get_param $proc_osc0/cur_grant_bytes
5225 # perform the real test
5226 $LCTL set_param $proc_osc0/rpc_stats 0
5227 for ((;i<$files; i++)); do
5228 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5229 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5232 $LCTL get_param $proc_osc0/rpc_stats
5235 local have_ppr=false
5236 $LCTL get_param $proc_osc0/rpc_stats |
5237 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5238 # skip lines until we are at the RPC histogram data
5239 [ "$PPR" == "pages" ] && have_ppr=true && continue
5240 $have_ppr || continue
5242 # we only want the percent stat for < 16 pages
5243 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5245 percent=$((percent + WPCT))
5246 if [[ $percent -gt 15 ]]; then
5247 error "less than 16-pages write RPCs" \
5254 run_test 42e "verify sub-RPC writes are not done synchronously"
5256 test_43A() { # was test_43
5257 test_mkdir $DIR/$tdir
5258 cp -p /bin/ls $DIR/$tdir/$tfile
5259 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5261 # give multiop a chance to open
5264 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5266 # Wait for multiop to exit
5269 run_test 43A "execution of file opened for write should return -ETXTBSY"
5272 test_mkdir $DIR/$tdir
5273 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5274 $DIR/$tdir/sleep 60 &
5276 # Make sure exec of $tdir/sleep wins race with truncate
5278 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5281 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5284 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5286 test_mkdir $DIR/$tdir
5287 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5288 $DIR/$tdir/sleep 60 &
5290 # Make sure exec of $tdir/sleep wins race with truncate
5292 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5295 run_test 43b "truncate of file being executed should return -ETXTBSY"
5298 local testdir="$DIR/$tdir"
5301 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5302 ( cd $testdir && md5sum -c )
5304 run_test 43c "md5sum of copy into lustre"
5306 test_44A() { # was test_44
5307 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5309 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5310 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5312 run_test 44A "zero length read from a sparse stripe"
5315 local nstripe=$($LFS getstripe -c -d $DIR)
5316 [ -z "$nstripe" ] && skip "can't get stripe info"
5317 [[ $nstripe -gt $OSTCOUNT ]] &&
5318 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5320 local stride=$($LFS getstripe -S -d $DIR)
5321 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5322 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5325 OFFSETS="0 $((stride/2)) $((stride-1))"
5326 for offset in $OFFSETS; do
5327 for i in $(seq 0 $((nstripe-1))); do
5328 local GLOBALOFFSETS=""
5330 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5331 local myfn=$DIR/d44a-$size
5332 echo "--------writing $myfn at $size"
5333 ll_sparseness_write $myfn $size ||
5334 error "ll_sparseness_write"
5335 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5336 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5337 error "ll_sparseness_verify $GLOBALOFFSETS"
5339 for j in $(seq 0 $((nstripe-1))); do
5341 size=$((((j + $nstripe )*$stride + $offset)))
5342 ll_sparseness_write $myfn $size ||
5343 error "ll_sparseness_write"
5344 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5346 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5347 error "ll_sparseness_verify $GLOBALOFFSETS"
5352 run_test 44a "test sparse pwrite ==============================="
5356 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5362 before=`dirty_osc_total`
5363 echo executing "\"$*\""
5365 after=`dirty_osc_total`
5366 echo before $before, after $after
5369 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5372 # Obtain grants from OST if it supports it
5373 echo blah > ${f}_grant
5376 do_dirty_record "echo blah > $f"
5377 [[ $before -eq $after ]] && error "write wasn't cached"
5378 do_dirty_record "> $f"
5379 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5380 do_dirty_record "echo blah > $f"
5381 [[ $before -eq $after ]] && error "write wasn't cached"
5382 do_dirty_record "sync"
5383 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5384 do_dirty_record "echo blah > $f"
5385 [[ $before -eq $after ]] && error "write wasn't cached"
5386 do_dirty_record "cancel_lru_locks osc"
5387 [[ $before -gt $after ]] ||
5388 error "lock cancellation didn't lower dirty count"
5391 run_test 45 "osc io page accounting ============================"
5393 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5394 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5395 # objects offset and an assert hit when an rpc was built with 1023's mapped
5396 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5398 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5403 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5405 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5406 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5410 run_test 46 "dirtying a previously written page ================"
5412 # test_47 is removed "Device nodes check" is moved to test_28
5414 test_48a() { # bug 2399
5415 [ "$mds1_FSTYPE" = "zfs" ] &&
5416 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5417 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5419 test_mkdir $DIR/$tdir
5421 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5422 test_mkdir $DIR/$tdir
5423 touch foo || error "'touch foo' failed after recreating cwd"
5425 touch .foo || error "'touch .foo' failed after recreating cwd"
5427 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5428 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5429 cd . || error "'cd .' failed after recreating cwd"
5430 mkdir . && error "'mkdir .' worked after recreating cwd"
5431 rmdir . && error "'rmdir .' worked after recreating cwd"
5432 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5433 cd .. || error "'cd ..' failed after recreating cwd"
5435 run_test 48a "Access renamed working dir (should return errors)="
5437 test_48b() { # bug 2399
5439 test_mkdir $DIR/$tdir
5441 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5442 touch foo && error "'touch foo' worked after removing cwd"
5443 mkdir foo && error "'mkdir foo' worked after removing cwd"
5444 touch .foo && error "'touch .foo' worked after removing cwd"
5445 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5446 ls . > /dev/null && error "'ls .' worked after removing cwd"
5447 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5448 mkdir . && error "'mkdir .' worked after removing cwd"
5449 rmdir . && error "'rmdir .' worked after removing cwd"
5450 ln -s . foo && error "'ln -s .' worked after removing cwd"
5451 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5453 run_test 48b "Access removed working dir (should return errors)="
5455 test_48c() { # bug 2350
5456 #lctl set_param debug=-1
5459 test_mkdir -p $DIR/$tdir/dir
5461 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5462 $TRACE touch foo && error "touch foo worked after removing cwd"
5463 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5464 touch .foo && error "touch .foo worked after removing cwd"
5465 mkdir .foo && error "mkdir .foo worked after removing cwd"
5466 $TRACE ls . && error "'ls .' worked after removing cwd"
5467 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5468 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5469 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5470 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5471 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5473 run_test 48c "Access removed working subdir (should return errors)"
5475 test_48d() { # bug 2350
5476 #lctl set_param debug=-1
5479 test_mkdir -p $DIR/$tdir/dir
5481 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5482 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5483 $TRACE touch foo && error "'touch foo' worked after removing parent"
5484 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5485 touch .foo && error "'touch .foo' worked after removing parent"
5486 mkdir .foo && error "mkdir .foo worked after removing parent"
5487 $TRACE ls . && error "'ls .' worked after removing parent"
5488 $TRACE ls .. && error "'ls ..' worked after removing parent"
5489 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5490 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5491 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5494 run_test 48d "Access removed parent subdir (should return errors)"
5496 test_48e() { # bug 4134
5497 #lctl set_param debug=-1
5500 test_mkdir -p $DIR/$tdir/dir
5502 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5503 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5504 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5505 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5506 # On a buggy kernel addition of "touch foo" after cd .. will
5507 # produce kernel oops in lookup_hash_it
5508 touch ../foo && error "'cd ..' worked after recreate parent"
5510 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5512 run_test 48e "Access to recreated parent subdir (should return errors)"
5515 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5516 skip "need MDS >= 2.13.55"
5517 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5518 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5519 skip "needs different host for mdt1 mdt2"
5520 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5522 $LFS mkdir -i0 $DIR/$tdir
5523 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5525 for d in sub1 sub2 sub3; do
5526 #define OBD_FAIL_OSD_REF_DEL 0x19c
5527 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5528 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5531 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5533 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5535 test_49() { # LU-1030
5536 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5537 remote_ost_nodsh && skip "remote OST with nodsh"
5539 # get ost1 size - $FSNAME-OST0000
5540 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5542 # write 800M at maximum
5543 [[ $ost1_size -lt 2 ]] && ost1_size=2
5544 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5546 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5547 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5550 # change max_pages_per_rpc while writing the file
5551 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5552 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5553 # loop until dd process exits
5554 while ps ax -opid | grep -wq $dd_pid; do
5555 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5556 sleep $((RANDOM % 5 + 1))
5558 # restore original max_pages_per_rpc
5559 $LCTL set_param $osc1_mppc=$orig_mppc
5560 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5562 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5566 test_mkdir $DIR/$tdir
5568 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5570 run_test 50 "special situations: /proc symlinks ==============="
5572 test_51a() { # was test_51
5573 # bug 1516 - create an empty entry right after ".." then split dir
5574 test_mkdir -c1 $DIR/$tdir
5575 touch $DIR/$tdir/foo
5576 $MCREATE $DIR/$tdir/bar
5578 createmany -m $DIR/$tdir/longfile 201
5580 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5581 $MCREATE $DIR/$tdir/longfile$FNUM
5586 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5588 run_test 51a "special situations: split htree with empty entry =="
5590 cleanup_print_lfs_df () {
5597 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5599 local dir=$DIR/$tdir
5600 local nrdirs=$((65536 + 100))
5602 # cleanup the directory
5605 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5609 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5610 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5611 [[ $numfree -lt $nrdirs ]] &&
5612 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5614 # need to check free space for the directories as well
5615 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5616 numfree=$(( blkfree / $(fs_inode_ksize) ))
5617 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5619 trap cleanup_print_lfs_df EXIT
5622 createmany -d $dir/d $nrdirs || {
5623 unlinkmany $dir/d $nrdirs
5624 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5628 nrdirs=$(ls -U $dir | wc -l)
5630 # unlink all but 100 subdirectories, then check it still works
5632 local delete=$((nrdirs - left))
5637 # for ldiskfs the nlink count should be 1, but this is OSD specific
5638 # and so this is listed for informational purposes only
5639 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5640 unlinkmany -d $dir/d $delete ||
5641 error "unlink of first $delete subdirs failed"
5643 echo "nlink between: $(stat -c %h $dir)"
5644 local found=$(ls -U $dir | wc -l)
5645 [ $found -ne $left ] &&
5646 error "can't find subdirs: found only $found, expected $left"
5648 unlinkmany -d $dir/d $delete $left ||
5649 error "unlink of second $left subdirs failed"
5650 # regardless of whether the backing filesystem tracks nlink accurately
5651 # or not, the nlink count shouldn't be more than "." and ".." here
5652 local after=$(stat -c %h $dir)
5653 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5654 echo "nlink after: $after"
5656 cleanup_print_lfs_df
5658 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5662 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5664 test_mkdir $DIR/$tdir
5665 createmany -o $DIR/$tdir/t- 1000
5666 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5667 for N in $(seq 0 $((OSTCOUNT - 1))); do
5668 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
5669 END { printf("%0.0f", objs) }' $TMP/$tfile)
5670 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5671 '($1 == '$N') { objs += 1 } \
5672 END { printf("%0.0f", objs) }')
5673 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
5675 unlinkmany $DIR/$tdir/t- 1000
5678 for N in $(seq 1 $((OSTCOUNT - 1))); do
5679 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
5680 error "OST $N has less objects vs OST $NLAST" \
5681 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5682 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
5683 error "OST $N has less objects vs OST $NLAST" \
5684 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5686 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
5687 error "OST $N has less #0 objects vs OST $NLAST" \
5688 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5689 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
5690 error "OST $N has less #0 objects vs OST $NLAST" \
5691 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5696 run_test 51d "check object distribution"
5699 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5700 skip_env "ldiskfs only test"
5703 test_mkdir -c1 $DIR/$tdir
5704 test_mkdir -c1 $DIR/$tdir/d0
5706 touch $DIR/$tdir/d0/foo
5707 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5708 error "file exceed 65000 nlink limit!"
5709 unlinkmany $DIR/$tdir/d0/f- 65001
5712 run_test 51e "check file nlink limit"
5715 test_mkdir $DIR/$tdir
5718 local ulimit_old=$(ulimit -n)
5719 local spare=20 # number of spare fd's for scripts/libraries, etc.
5720 local mdt=$($LFS getstripe -m $DIR/$tdir)
5721 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5723 echo "MDT$mdt numfree=$numfree, max=$max"
5724 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5725 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5726 while ! ulimit -n $((numfree + spare)); do
5727 numfree=$((numfree * 3 / 4))
5729 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5731 echo "left ulimit at $ulimit_old"
5734 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5735 unlinkmany $DIR/$tdir/f $numfree
5736 error "create+open $numfree files in $DIR/$tdir failed"
5738 ulimit -n $ulimit_old
5740 # if createmany exits at 120s there will be fewer than $numfree files
5741 unlinkmany $DIR/$tdir/f $numfree || true
5743 run_test 51f "check many open files limit"
5746 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5747 test_mkdir $DIR/$tdir
5748 touch $DIR/$tdir/foo
5749 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5750 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5751 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5752 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5753 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5755 echo foo >> $DIR/$tdir/foo || error "append foo failed"
5756 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5757 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
5759 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
5760 cp -r $DIR/$tdir $TMP/
5761 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
5763 run_test 52a "append-only flag test (should return errors)"
5766 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
5767 test_mkdir $DIR/$tdir
5768 touch $DIR/$tdir/foo
5769 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
5770 cat test > $DIR/$tdir/foo && error "cat test worked"
5771 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5772 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5773 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5775 echo foo >> $DIR/$tdir/foo && error "echo worked"
5776 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5777 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
5778 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
5779 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
5781 chattr -i $DIR/$tdir/foo || error "chattr failed"
5783 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
5785 run_test 52b "immutable flag test (should return errors) ======="
5788 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5789 remote_mds_nodsh && skip "remote MDS with nodsh"
5790 remote_ost_nodsh && skip "remote OST with nodsh"
5803 local support_last_seq=true
5805 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
5806 support_last_seq=false
5809 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
5811 for value in $(do_facet $SINGLEMDS \
5812 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
5813 param=$(echo ${value[0]} | cut -d "=" -f1)
5814 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
5816 if $support_last_seq; then
5817 param_seq=$(echo $param |
5818 sed -e s/prealloc_last_id/prealloc_last_seq/g)
5819 mds_last_seq=$(do_facet $SINGLEMDS \
5820 $LCTL get_param -n $param_seq)
5822 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
5824 ostnum=$(index_from_ostuuid ${ostname}_UUID)
5825 node=$(facet_active_host ost$((ostnum+1)))
5826 param="obdfilter.$ostname.last_id"
5827 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
5828 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
5829 ost_last_id=$ost_last
5831 if $support_last_seq; then
5832 ost_last_id=$(echo $ost_last |
5833 awk -F':' '{print $2}' |
5835 ost_last_seq=$(echo $ost_last |
5836 awk -F':' '{print $1}')
5837 [[ $ost_last_seq = $mds_last_seq ]] || continue
5840 if [[ $ost_last_id != $mds_last ]]; then
5841 error "$ost_last_id != $mds_last"
5848 $found || error "can not match last_seq/last_id for $mdtosc"
5851 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
5854 perl -MSocket -e ';' || skip "no Socket perl module installed"
5856 $SOCKETSERVER $DIR/socket ||
5857 error "$SOCKETSERVER $DIR/socket failed: $?"
5858 $SOCKETCLIENT $DIR/socket ||
5859 error "$SOCKETCLIENT $DIR/socket failed: $?"
5860 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
5862 run_test 54a "unix domain socket test =========================="
5868 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
5870 run_test 54b "char device works in lustre ======================"
5873 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
5874 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
5875 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
5877 for i in $(seq 3 7); do
5878 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
5887 loopdev="$DIR/loop54c"
5890 $UMOUNT $DIR/$tdir || rc=$?
5891 losetup -d $loopdev || true
5892 losetup -d $LOOPDEV || true
5893 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
5898 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5900 loopdev="$DIR/loop54c"
5903 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
5904 trap cleanup_54c EXIT
5905 mknod $loopdev b 7 $LOOPNUM
5906 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
5907 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
5908 losetup $loopdev $DIR/$tfile ||
5909 error "can't set up $loopdev for $DIR/$tfile"
5910 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
5911 test_mkdir $DIR/$tdir
5912 mount -t ext2 $loopdev $DIR/$tdir ||
5913 error "error mounting $loopdev on $DIR/$tdir"
5914 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
5917 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
5921 run_test 54c "block device works in lustre ====================="
5927 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
5929 run_test 54d "fifo device works in lustre ======================"
5934 cp -aL /dev/console $f
5935 echo $string > $f || error "echo $string to $f failed"
5937 run_test 54e "console/tty device works in lustre ======================"
5942 local dir=$DIR/$tdir
5945 test_mkdir -p $dir/dir
5946 for i in $(seq $numfiles); do
5948 touch $dir/dir/file$i
5951 local numcomp=$($LFS getstripe --component-count $dir)
5953 [[ $numcomp == 0 ]] && numcomp=1
5955 # test lfs getstripe with --recursive
5956 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5958 [[ $filenum -eq $((numfiles * 2)) ]] ||
5959 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5960 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5961 [[ $filenum -eq $numfiles ]] ||
5962 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5963 echo "$LFS getstripe showed obdidx or l_ost_idx"
5965 # test lfs getstripe with file instead of dir
5966 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5967 [[ $filenum -eq 1 ]] ||
5968 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5969 echo "$LFS getstripe file1 passed"
5971 #test lfs getstripe with --verbose
5972 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5973 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5974 error "$LFS getstripe --verbose $dir: "\
5975 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5976 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5977 error "$LFS getstripe $dir: showed lmm_magic"
5979 #test lfs getstripe with -v prints lmm_fid
5980 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5981 local countfids=$((numdirs + numfiles * numcomp))
5982 [[ $filenum -eq $countfids ]] ||
5983 error "$LFS getstripe -v $dir: "\
5984 "got $filenum want $countfids lmm_fid"
5985 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5986 error "$LFS getstripe $dir: showed lmm_fid by default"
5987 echo "$LFS getstripe --verbose passed"
5989 #check for FID information
5990 local fid1=$($LFS getstripe --fid $dir/file1)
5991 local fid2=$($LFS getstripe --verbose $dir/file1 |
5992 awk '/lmm_fid: / { print $2; exit; }')
5993 local fid3=$($LFS path2fid $dir/file1)
5995 [ "$fid1" != "$fid2" ] &&
5996 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5997 [ "$fid1" != "$fid3" ] &&
5998 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5999 echo "$LFS getstripe --fid passed"
6001 #test lfs getstripe with --obd
6002 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6003 error "$LFS getstripe --obd wrong_uuid: should return error"
6005 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6008 local obduuid=$(ostuuid_from_index $ostidx)
6009 local found=$($LFS getstripe -r --obd $obduuid $dir |
6010 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6012 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6013 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6015 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6018 [[ $found -eq $filenum ]] ||
6019 error "$LFS getstripe --obd: found $found expect $filenum"
6020 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6021 sed '/^[ ]*'${ostidx}'[ ]/d' |
6022 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6023 error "$LFS getstripe --obd: should not show file on other obd"
6024 echo "$LFS getstripe --obd passed"
6026 run_test 56a "check $LFS getstripe"
6029 local dir=$DIR/$tdir
6033 for i in $(seq $numdirs); do
6034 test_mkdir $dir/dir$i
6037 # test lfs getdirstripe default mode is non-recursion, which is
6038 # different from lfs getstripe
6039 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6041 [[ $dircnt -eq 1 ]] ||
6042 error "$LFS getdirstripe: found $dircnt, not 1"
6043 dircnt=$($LFS getdirstripe --recursive $dir |
6044 grep -c lmv_stripe_count)
6045 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6046 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6048 run_test 56b "check $LFS getdirstripe"
6051 remote_ost_nodsh && skip "remote OST with nodsh"
6054 local ost_name=$(ostname_from_index $ost_idx)
6055 local old_status=$(ost_dev_status $ost_idx)
6056 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6058 [[ -z "$old_status" ]] ||
6059 skip_env "OST $ost_name is in $old_status status"
6061 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6062 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6063 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6064 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6065 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6066 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6069 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6070 error "$LFS df -v showing inactive devices"
6073 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6075 [[ "$new_status" =~ "D" ]] ||
6076 error "$ost_name status is '$new_status', missing 'D'"
6077 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6078 [[ "$new_status" =~ "N" ]] ||
6079 error "$ost_name status is '$new_status', missing 'N'"
6081 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6082 [[ "$new_status" =~ "f" ]] ||
6083 error "$ost_name status is '$new_status', missing 'f'"
6086 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6087 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6088 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6089 [[ -z "$p" ]] && restore_lustre_params < $p || true
6092 new_status=$(ost_dev_status $ost_idx)
6093 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6094 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6095 # can't check 'f' as devices may actually be on flash
6097 run_test 56c "check 'lfs df' showing device status"
6100 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6101 local osts=$($LFS df -v $MOUNT | grep -c OST)
6105 (( mdts == MDSCOUNT )) ||
6106 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6107 (( osts == OSTCOUNT )) ||
6108 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6110 run_test 56d "'lfs df -v' prints only configured devices"
6115 local local_tdir="$1"
6116 local local_numfiles="$2"
6117 local local_numdirs="$3"
6118 local dir_params="$4"
6119 local dir_stripe_params="$5"
6121 if [ ! -d "$local_tdir" ] ; then
6122 test_mkdir -p $dir_stripe_params $local_tdir
6123 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6124 for i in $(seq $local_numfiles) ; do
6125 touch $local_tdir/file$i
6127 for i in $(seq $local_numdirs) ; do
6128 test_mkdir $dir_stripe_params $local_tdir/dir$i
6129 for j in $(seq $local_numfiles) ; do
6130 touch $local_tdir/dir$i/file$j
6136 setup_56_special() {
6138 local local_numfiles=$2
6139 local local_numdirs=$3
6141 setup_56 $local_tdir $local_numfiles $local_numdirs
6143 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6144 for i in $(seq $local_numfiles) ; do
6145 mknod $local_tdir/loop${i}b b 7 $i
6146 mknod $local_tdir/null${i}c c 1 3
6147 ln -s $local_tdir/file1 $local_tdir/link${i}
6149 for i in $(seq $local_numdirs) ; do
6150 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6151 mknod $local_tdir/dir$i/null${i}c c 1 3
6152 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6158 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6159 local expected=$(($NUMDIRS + 2))
6161 setup_56 $dir $NUMFILES $NUMDIRS
6163 # test lfs find with -name
6164 for i in $(seq $NUMFILES) ; do
6165 local nums=$($LFS find -name "*$i" $dir | wc -l)
6167 [ $nums -eq $expected ] ||
6168 error "lfs find -name '*$i' $dir wrong: "\
6169 "found $nums, expected $expected"
6172 run_test 56g "check lfs find -name"
6175 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6176 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6178 setup_56 $dir $NUMFILES $NUMDIRS
6180 # test lfs find with ! -name
6181 for i in $(seq $NUMFILES) ; do
6182 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6184 [ $nums -eq $expected ] ||
6185 error "lfs find ! -name '*$i' $dir wrong: "\
6186 "found $nums, expected $expected"
6189 run_test 56h "check lfs find ! -name"
6192 local dir=$DIR/$tdir
6196 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6199 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6201 run_test 56i "check 'lfs find -ost UUID' skips directories"
6204 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6206 setup_56_special $dir $NUMFILES $NUMDIRS
6208 local expected=$((NUMDIRS + 1))
6209 local cmd="$LFS find -type d $dir"
6210 local nums=$($cmd | wc -l)
6212 [ $nums -eq $expected ] ||
6213 error "'$cmd' wrong: found $nums, expected $expected"
6215 run_test 56j "check lfs find -type d"
6218 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6220 setup_56_special $dir $NUMFILES $NUMDIRS
6222 local expected=$(((NUMDIRS + 1) * NUMFILES))
6223 local cmd="$LFS find -type f $dir"
6224 local nums=$($cmd | wc -l)
6226 [ $nums -eq $expected ] ||
6227 error "'$cmd' wrong: found $nums, expected $expected"
6229 run_test 56k "check lfs find -type f"
6232 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6234 setup_56_special $dir $NUMFILES $NUMDIRS
6236 local expected=$((NUMDIRS + NUMFILES))
6237 local cmd="$LFS find -type b $dir"
6238 local nums=$($cmd | wc -l)
6240 [ $nums -eq $expected ] ||
6241 error "'$cmd' wrong: found $nums, expected $expected"
6243 run_test 56l "check lfs find -type b"
6246 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6248 setup_56_special $dir $NUMFILES $NUMDIRS
6250 local expected=$((NUMDIRS + NUMFILES))
6251 local cmd="$LFS find -type c $dir"
6252 local nums=$($cmd | wc -l)
6253 [ $nums -eq $expected ] ||
6254 error "'$cmd' wrong: found $nums, expected $expected"
6256 run_test 56m "check lfs find -type c"
6259 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6260 setup_56_special $dir $NUMFILES $NUMDIRS
6262 local expected=$((NUMDIRS + NUMFILES))
6263 local cmd="$LFS find -type l $dir"
6264 local nums=$($cmd | wc -l)
6266 [ $nums -eq $expected ] ||
6267 error "'$cmd' wrong: found $nums, expected $expected"
6269 run_test 56n "check lfs find -type l"
6272 local dir=$DIR/$tdir
6274 setup_56 $dir $NUMFILES $NUMDIRS
6275 utime $dir/file1 > /dev/null || error "utime (1)"
6276 utime $dir/file2 > /dev/null || error "utime (2)"
6277 utime $dir/dir1 > /dev/null || error "utime (3)"
6278 utime $dir/dir2 > /dev/null || error "utime (4)"
6279 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6280 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6283 local nums=$($LFS find -mtime +0 $dir | wc -l)
6285 [ $nums -eq $expected ] ||
6286 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6289 cmd="$LFS find -mtime 0 $dir"
6290 nums=$($cmd | wc -l)
6291 [ $nums -eq $expected ] ||
6292 error "'$cmd' wrong: found $nums, expected $expected"
6294 run_test 56o "check lfs find -mtime for old files"
6297 local dir=$DIR/$tdir
6301 # just to make sure there is something that won't be found
6303 touch $dir/$tfile.now
6305 for age in year week day hour min; do
6306 count=$((count + 1))
6308 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6309 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6310 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6312 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6313 local nums=$($cmd | wc -l)
6314 [ $nums -eq $expected ] ||
6315 error "'$cmd' wrong: found $nums, expected $expected"
6317 cmd="$LFS find $dir -atime $count${age:0:1}"
6318 nums=$($cmd | wc -l)
6319 [ $nums -eq $expected ] ||
6320 error "'$cmd' wrong: found $nums, expected $expected"
6324 cmd="$LFS find $dir -ctime +1s -type f"
6325 nums=$($cmd | wc -l)
6326 (( $nums == $count * 2 + 1)) ||
6327 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6329 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6331 test_newerXY_base() {
6334 local dir=$DIR/$tdir
6338 if [ $y == "t" ]; then
6339 if [ $x == "b" ]; then
6340 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6342 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6345 ref=$DIR/$tfile.newer.$x$y
6346 touch $ref || error "touch $ref failed"
6349 echo "before = $ref"
6351 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6353 if [ $y == "t" ]; then
6354 if [ $x == "b" ]; then
6355 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6357 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6360 negref=$DIR/$tfile.negnewer.$x$y
6361 touch $negref || error "touch $negref failed"
6364 echo "after = $negref"
6365 local cmd="$LFS find $dir -newer$x$y $ref"
6366 local nums=$(eval $cmd | wc -l)
6367 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6369 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6370 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6372 cmd="$LFS find $dir ! -newer$x$y $negref"
6373 nums=$(eval $cmd | wc -l)
6374 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6375 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6377 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6378 nums=$(eval $cmd | wc -l)
6379 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6380 error "'$cmd' wrong: found $nums between, expected $expected"; }
6386 test_newerXY_base "a" "a"
6387 test_newerXY_base "a" "m"
6388 test_newerXY_base "a" "c"
6389 test_newerXY_base "m" "a"
6390 test_newerXY_base "m" "m"
6391 test_newerXY_base "m" "c"
6392 test_newerXY_base "c" "a"
6393 test_newerXY_base "c" "m"
6394 test_newerXY_base "c" "c"
6396 [[ -n "$sles_version" ]] &&
6397 echo "skip timestamp tests on SLES, LU-13665" && return 0
6399 test_newerXY_base "a" "t"
6400 test_newerXY_base "m" "t"
6401 test_newerXY_base "c" "t"
6403 [[ $MDS1_VERSION -lt $(version_code 2.13.54) ||
6404 $CLIENT_VERSION -lt $(version_code 2.13.54) ]] &&
6405 ! btime_supported && echo "btime unsupported" && return 0
6407 test_newerXY_base "b" "b"
6408 test_newerXY_base "b" "t"
6410 run_test 56oc "check lfs find -newerXY work"
6413 local dir=$DIR/$tdir
6418 $LFS find $dir -btime -1d -type f
6425 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
6426 ! btime_supported && skip "btime unsupported on MDS"
6428 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6429 ! btime_supported && skip "btime unsupported on clients"
6431 local dir=$DIR/$tdir
6432 local ref=$DIR/$tfile.ref
6433 local negref=$DIR/$tfile.negref
6435 mkdir $dir || error "mkdir $dir failed"
6436 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6437 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6438 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6439 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6440 touch $ref || error "touch $ref failed"
6441 # sleep 3 seconds at least
6444 local before=$(do_facet mds1 date +%s)
6445 local skew=$(($(date +%s) - before + 1))
6447 if (( skew < 0 && skew > -5 )); then
6448 sleep $((0 - skew + 1))
6452 # Set the dir stripe params to limit files all on MDT0,
6453 # otherwise we need to calc the max clock skew between
6454 # the client and MDTs.
6455 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6457 touch $negref || error "touch $negref failed"
6459 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6460 local nums=$($cmd | wc -l)
6461 local expected=$(((NUMFILES + 1) * NUMDIRS))
6463 [ $nums -eq $expected ] ||
6464 error "'$cmd' wrong: found $nums, expected $expected"
6466 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6467 nums=$($cmd | wc -l)
6468 expected=$((NUMFILES + 1))
6469 [ $nums -eq $expected ] ||
6470 error "'$cmd' wrong: found $nums, expected $expected"
6472 [ $skew -lt 0 ] && return
6474 local after=$(do_facet mds1 date +%s)
6475 local age=$((after - before + 1 + skew))
6477 cmd="$LFS find $dir -btime -${age}s -type f"
6478 nums=$($cmd | wc -l)
6479 expected=$(((NUMFILES + 1) * NUMDIRS))
6481 echo "Clock skew between client and server: $skew, age:$age"
6482 [ $nums -eq $expected ] ||
6483 error "'$cmd' wrong: found $nums, expected $expected"
6485 expected=$(($NUMDIRS + 1))
6486 cmd="$LFS find $dir -btime -${age}s -type d"
6487 nums=$($cmd | wc -l)
6488 [ $nums -eq $expected ] ||
6489 error "'$cmd' wrong: found $nums, expected $expected"
6490 rm -f $ref $negref || error "Failed to remove $ref $negref"
6492 run_test 56od "check lfs find -btime with units"
6495 [ $RUNAS_ID -eq $UID ] &&
6496 skip_env "RUNAS_ID = UID = $UID -- skipping"
6498 local dir=$DIR/$tdir
6500 setup_56 $dir $NUMFILES $NUMDIRS
6501 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6503 local expected=$NUMFILES
6504 local cmd="$LFS find -uid $RUNAS_ID $dir"
6505 local nums=$($cmd | wc -l)
6507 [ $nums -eq $expected ] ||
6508 error "'$cmd' wrong: found $nums, expected $expected"
6510 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6511 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6512 nums=$($cmd | wc -l)
6513 [ $nums -eq $expected ] ||
6514 error "'$cmd' wrong: found $nums, expected $expected"
6516 run_test 56p "check lfs find -uid and ! -uid"
6519 [ $RUNAS_ID -eq $UID ] &&
6520 skip_env "RUNAS_ID = UID = $UID -- skipping"
6522 local dir=$DIR/$tdir
6524 setup_56 $dir $NUMFILES $NUMDIRS
6525 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6527 local expected=$NUMFILES
6528 local cmd="$LFS find -gid $RUNAS_GID $dir"
6529 local nums=$($cmd | wc -l)
6531 [ $nums -eq $expected ] ||
6532 error "'$cmd' wrong: found $nums, expected $expected"
6534 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6535 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6536 nums=$($cmd | wc -l)
6537 [ $nums -eq $expected ] ||
6538 error "'$cmd' wrong: found $nums, expected $expected"
6540 run_test 56q "check lfs find -gid and ! -gid"
6543 local dir=$DIR/$tdir
6545 setup_56 $dir $NUMFILES $NUMDIRS
6548 local cmd="$LFS find -size 0 -type f -lazy $dir"
6549 local nums=$($cmd | wc -l)
6551 [ $nums -eq $expected ] ||
6552 error "'$cmd' wrong: found $nums, expected $expected"
6553 cmd="$LFS find -size 0 -type f $dir"
6554 nums=$($cmd | wc -l)
6555 [ $nums -eq $expected ] ||
6556 error "'$cmd' wrong: found $nums, expected $expected"
6559 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6560 nums=$($cmd | wc -l)
6561 [ $nums -eq $expected ] ||
6562 error "'$cmd' wrong: found $nums, expected $expected"
6563 cmd="$LFS find ! -size 0 -type f $dir"
6564 nums=$($cmd | wc -l)
6565 [ $nums -eq $expected ] ||
6566 error "'$cmd' wrong: found $nums, expected $expected"
6568 echo "test" > $dir/$tfile
6569 echo "test2" > $dir/$tfile.2 && sync
6571 cmd="$LFS find -size 5 -type f -lazy $dir"
6572 nums=$($cmd | wc -l)
6573 [ $nums -eq $expected ] ||
6574 error "'$cmd' wrong: found $nums, expected $expected"
6575 cmd="$LFS find -size 5 -type f $dir"
6576 nums=$($cmd | wc -l)
6577 [ $nums -eq $expected ] ||
6578 error "'$cmd' wrong: found $nums, expected $expected"
6581 cmd="$LFS find -size +5 -type f -lazy $dir"
6582 nums=$($cmd | wc -l)
6583 [ $nums -eq $expected ] ||
6584 error "'$cmd' wrong: found $nums, expected $expected"
6585 cmd="$LFS find -size +5 -type f $dir"
6586 nums=$($cmd | wc -l)
6587 [ $nums -eq $expected ] ||
6588 error "'$cmd' wrong: found $nums, expected $expected"
6591 cmd="$LFS find -size +0 -type f -lazy $dir"
6592 nums=$($cmd | wc -l)
6593 [ $nums -eq $expected ] ||
6594 error "'$cmd' wrong: found $nums, expected $expected"
6595 cmd="$LFS find -size +0 -type f $dir"
6596 nums=$($cmd | wc -l)
6597 [ $nums -eq $expected ] ||
6598 error "'$cmd' wrong: found $nums, expected $expected"
6601 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6602 nums=$($cmd | wc -l)
6603 [ $nums -eq $expected ] ||
6604 error "'$cmd' wrong: found $nums, expected $expected"
6605 cmd="$LFS find ! -size -5 -type f $dir"
6606 nums=$($cmd | wc -l)
6607 [ $nums -eq $expected ] ||
6608 error "'$cmd' wrong: found $nums, expected $expected"
6611 cmd="$LFS find -size -5 -type f -lazy $dir"
6612 nums=$($cmd | wc -l)
6613 [ $nums -eq $expected ] ||
6614 error "'$cmd' wrong: found $nums, expected $expected"
6615 cmd="$LFS find -size -5 -type f $dir"
6616 nums=$($cmd | wc -l)
6617 [ $nums -eq $expected ] ||
6618 error "'$cmd' wrong: found $nums, expected $expected"
6620 run_test 56r "check lfs find -size works"
6627 cancel_lru_locks $OSC
6629 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6630 local nums=$($cmd | wc -l)
6632 [ $nums -eq $expected ] ||
6633 error "'$cmd' wrong: found $nums, expected $expected"
6635 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6637 if (( rpcs_before + glimpses != rpcs_after )); then
6638 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6639 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
6641 if [[ $glimpses == 0 ]]; then
6642 error "'$cmd' should not send glimpse RPCs to OST"
6644 error "'$cmd' should send $glimpses glimpse RPCs to OST"
6650 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
6651 skip "MDS < 2.12.58 doesn't return LSOM data"
6652 local dir=$DIR/$tdir
6653 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
6655 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
6657 # statahead_agl may cause extra glimpse which confuses results. LU-13017
6658 $LCTL set_param -n llite.*.statahead_agl=0
6659 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
6661 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6662 # open and close all files to ensure LSOM is updated
6663 cancel_lru_locks $OSC
6664 find $dir -type f | xargs cat > /dev/null
6666 # expect_found glimpse_rpcs command_to_run
6667 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
6668 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
6669 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
6670 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
6672 echo "test" > $dir/$tfile
6673 echo "test2" > $dir/$tfile.2 && sync
6674 cancel_lru_locks $OSC
6675 cat $dir/$tfile $dir/$tfile.2 > /dev/null
6677 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
6678 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
6679 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
6680 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
6682 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
6683 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
6684 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
6685 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
6686 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
6687 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
6689 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6692 local dir=$DIR/$tdir
6693 local tmp=$TMP/$tfile.log
6696 test_mkdir -p $dir || error "failed to mkdir $dir"
6697 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
6698 error "failed to setstripe $dir/$tfile"
6699 mdt_idx=$($LFS getdirstripe -i $dir)
6700 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
6702 stack_trap "rm -f $tmp" EXIT
6703 $LFS find --size +100K --ost 0 $dir |& tee $tmp
6704 ! grep -q obd_uuid $tmp ||
6705 error "failed to find --size +100K --ost 0 $dir"
6706 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
6707 ! grep -q obd_uuid $tmp ||
6708 error "failed to find --size +100K --mdt $mdt_idx $dir"
6710 run_test 56rb "check lfs find --size --ost/--mdt works"
6713 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
6714 local dir=$DIR/$tdir
6717 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
6718 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
6719 (( $MDSCOUNT > 2 )) &&
6720 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
6721 mkdir $dir/$tdir-{1..10}
6722 touch $dir/$tfile-{1..10}
6724 found=$($LFS find $dir --mdt-count 2 | wc -l)
6726 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
6728 found=$($LFS find $dir -T +1 | wc -l)
6729 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
6730 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
6732 found=$($LFS find $dir --mdt-hash all_char | wc -l)
6734 (( $found == $expect )) || error "found $found all_char, expect $expect"
6736 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
6737 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
6738 (( $found == $expect )) || error "found $found all_char, expect $expect"
6740 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
6742 test_56s() { # LU-611 #LU-9369
6743 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
6745 local dir=$DIR/$tdir
6746 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
6748 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6749 for i in $(seq $NUMDIRS); do
6750 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
6753 local expected=$NUMDIRS
6754 local cmd="$LFS find -c $OSTCOUNT $dir"
6755 local nums=$($cmd | wc -l)
6757 [ $nums -eq $expected ] || {
6758 $LFS getstripe -R $dir
6759 error "'$cmd' wrong: found $nums, expected $expected"
6762 expected=$((NUMDIRS + onestripe))
6763 cmd="$LFS find -stripe-count +0 -type f $dir"
6764 nums=$($cmd | wc -l)
6765 [ $nums -eq $expected ] || {
6766 $LFS getstripe -R $dir
6767 error "'$cmd' wrong: found $nums, expected $expected"
6771 cmd="$LFS find -stripe-count 1 -type f $dir"
6772 nums=$($cmd | wc -l)
6773 [ $nums -eq $expected ] || {
6774 $LFS getstripe -R $dir
6775 error "'$cmd' wrong: found $nums, expected $expected"
6778 cmd="$LFS find -stripe-count -2 -type f $dir"
6779 nums=$($cmd | wc -l)
6780 [ $nums -eq $expected ] || {
6781 $LFS getstripe -R $dir
6782 error "'$cmd' wrong: found $nums, expected $expected"
6786 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
6787 nums=$($cmd | wc -l)
6788 [ $nums -eq $expected ] || {
6789 $LFS getstripe -R $dir
6790 error "'$cmd' wrong: found $nums, expected $expected"
6793 run_test 56s "check lfs find -stripe-count works"
6795 test_56t() { # LU-611 #LU-9369
6796 local dir=$DIR/$tdir
6798 setup_56 $dir 0 $NUMDIRS
6799 for i in $(seq $NUMDIRS); do
6800 $LFS setstripe -S 8M $dir/dir$i/$tfile
6803 local expected=$NUMDIRS
6804 local cmd="$LFS find -S 8M $dir"
6805 local nums=$($cmd | wc -l)
6807 [ $nums -eq $expected ] || {
6808 $LFS getstripe -R $dir
6809 error "'$cmd' wrong: found $nums, expected $expected"
6813 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
6815 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
6817 expected=$(((NUMDIRS + 1) * NUMFILES))
6818 cmd="$LFS find -stripe-size 512k -type f $dir"
6819 nums=$($cmd | wc -l)
6820 [ $nums -eq $expected ] ||
6821 error "'$cmd' wrong: found $nums, expected $expected"
6823 cmd="$LFS find -stripe-size +320k -type f $dir"
6824 nums=$($cmd | wc -l)
6825 [ $nums -eq $expected ] ||
6826 error "'$cmd' wrong: found $nums, expected $expected"
6828 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
6829 cmd="$LFS find -stripe-size +200k -type f $dir"
6830 nums=$($cmd | wc -l)
6831 [ $nums -eq $expected ] ||
6832 error "'$cmd' wrong: found $nums, expected $expected"
6834 cmd="$LFS find -stripe-size -640k -type f $dir"
6835 nums=$($cmd | wc -l)
6836 [ $nums -eq $expected ] ||
6837 error "'$cmd' wrong: found $nums, expected $expected"
6840 cmd="$LFS find -stripe-size 256k -type f $dir"
6841 nums=$($cmd | wc -l)
6842 [ $nums -eq $expected ] ||
6843 error "'$cmd' wrong: found $nums, expected $expected"
6845 cmd="$LFS find -stripe-size -320k -type f $dir"
6846 nums=$($cmd | wc -l)
6847 [ $nums -eq $expected ] ||
6848 error "'$cmd' wrong: found $nums, expected $expected"
6851 cmd="$LFS find -stripe-size 1024k -type f $dir"
6852 nums=$($cmd | wc -l)
6853 [ $nums -eq $expected ] ||
6854 error "'$cmd' wrong: found $nums, expected $expected"
6856 run_test 56t "check lfs find -stripe-size works"
6858 test_56u() { # LU-611
6859 local dir=$DIR/$tdir
6861 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
6863 if [[ $OSTCOUNT -gt 1 ]]; then
6864 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
6870 local expected=$(((NUMDIRS + 1) * NUMFILES))
6871 local cmd="$LFS find -stripe-index 0 -type f $dir"
6872 local nums=$($cmd | wc -l)
6874 [ $nums -eq $expected ] ||
6875 error "'$cmd' wrong: found $nums, expected $expected"
6878 cmd="$LFS find -stripe-index 1 -type f $dir"
6879 nums=$($cmd | wc -l)
6880 [ $nums -eq $expected ] ||
6881 error "'$cmd' wrong: found $nums, expected $expected"
6883 cmd="$LFS find ! -stripe-index 0 -type f $dir"
6884 nums=$($cmd | wc -l)
6885 [ $nums -eq $expected ] ||
6886 error "'$cmd' wrong: found $nums, expected $expected"
6889 # This should produce an error and not return any files
6890 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
6891 nums=$($cmd 2>/dev/null | wc -l)
6892 [ $nums -eq $expected ] ||
6893 error "'$cmd' wrong: found $nums, expected $expected"
6895 if [[ $OSTCOUNT -gt 1 ]]; then
6896 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
6897 cmd="$LFS find -stripe-index 0,1 -type f $dir"
6898 nums=$($cmd | wc -l)
6899 [ $nums -eq $expected ] ||
6900 error "'$cmd' wrong: found $nums, expected $expected"
6903 run_test 56u "check lfs find -stripe-index works"
6907 local dir=$DIR/$tdir
6909 setup_56 $dir $NUMFILES $NUMDIRS
6911 UUID=$(mdtuuid_from_index $mdt_idx $dir)
6912 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
6914 for file in $($LFS find -m $UUID $dir); do
6915 file_midx=$($LFS getstripe -m $file)
6916 [ $file_midx -eq $mdt_idx ] ||
6917 error "lfs find -m $UUID != getstripe -m $file_midx"
6920 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
6923 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6924 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6926 local dir=$DIR/$tdir
6928 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
6930 local stripe_size=$($LFS getstripe -S -d $dir) ||
6931 error "$LFS getstripe -S -d $dir failed"
6932 stripe_size=${stripe_size%% *}
6934 local file_size=$((stripe_size * OSTCOUNT))
6935 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
6936 local required_space=$((file_num * file_size))
6937 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
6939 [[ $free_space -le $((required_space / 1024)) ]] &&
6940 skip_env "need $required_space, have $free_space kbytes"
6943 local dd_count=$((file_size / dd_bs))
6945 # write data into the files
6950 for i in $(seq $NUMFILES); do
6952 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6953 error "write data into $file failed"
6955 for i in $(seq $NUMDIRS); do
6956 for j in $(seq $NUMFILES); do
6957 file=$dir/dir$i/file$j
6958 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6959 error "write data into $file failed"
6963 # $LFS_MIGRATE will fail if hard link migration is unsupported
6964 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
6965 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
6966 error "creating links to $dir/dir1/file1 failed"
6971 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
6974 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
6977 eval $cmd || error "$cmd failed"
6979 check_stripe_count $dir/file1 $expected
6981 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
6983 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
6984 # OST 1 if it is on OST 0. This file is small enough to
6985 # be on only one stripe.
6986 file=$dir/migr_1_ost
6987 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
6988 error "write data into $file failed"
6989 local obdidx=$($LFS getstripe -i $file)
6990 local oldmd5=$(md5sum $file)
6993 [[ $obdidx -eq 0 ]] && newobdidx=1
6994 cmd="$LFS migrate -i $newobdidx $file"
6996 eval $cmd || error "$cmd failed"
6998 local realobdix=$($LFS getstripe -i $file)
6999 local newmd5=$(md5sum $file)
7001 [[ $newobdidx -ne $realobdix ]] &&
7002 error "new OST is different (was=$obdidx, "\
7003 "wanted=$newobdidx, got=$realobdix)"
7004 [[ "$oldmd5" != "$newmd5" ]] &&
7005 error "md5sum differ: $oldmd5, $newmd5"
7009 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7011 eval $cmd || error "$cmd failed"
7013 for j in $(seq $NUMFILES); do
7014 check_stripe_count $dir/dir1/file$j $expected
7017 # lfs_migrate works with lfs find
7018 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7019 $LFS_MIGRATE -y -c $expected"
7021 eval $cmd || error "$cmd failed"
7023 for i in $(seq 2 $NUMFILES); do
7024 check_stripe_count $dir/file$i $expected
7026 for i in $(seq 2 $NUMDIRS); do
7027 for j in $(seq $NUMFILES); do
7028 check_stripe_count $dir/dir$i/file$j $expected
7032 run_test 56w "check lfs_migrate -c stripe_count works"
7035 local file1=$DIR/$tdir/file1
7036 local create_pool=false
7037 local initial_pool=$($LFS getstripe -p $DIR)
7041 echo -n "Creating test dir..."
7042 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7045 echo -n "Creating test file..."
7046 touch $file1 || error "cannot create file"
7049 echo -n "Detecting existing pools..."
7050 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7052 if [ ${#pool_list[@]} -gt 0 ]; then
7053 echo "${pool_list[@]}"
7054 for thispool in "${pool_list[@]}"; do
7055 if [[ -z "$initial_pool" ||
7056 "$initial_pool" != "$thispool" ]]; then
7058 echo "Using existing pool '$pool'"
7063 echo "none detected."
7065 if [ -z "$pool" ]; then
7066 pool=${POOL:-testpool}
7067 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7068 echo -n "Creating pool '$pool'..."
7070 pool_add $pool &> /dev/null ||
7071 error "pool_add failed"
7074 echo -n "Adding target to pool..."
7075 pool_add_targets $pool 0 0 1 &> /dev/null ||
7076 error "pool_add_targets failed"
7080 echo -n "Setting pool using -p option..."
7081 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7082 error "migrate failed rc = $?"
7085 echo -n "Verifying test file is in pool after migrating..."
7086 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7087 error "file was not migrated to pool $pool"
7090 echo -n "Removing test file from pool '$pool'..."
7091 # "lfs migrate $file" won't remove the file from the pool
7092 # until some striping information is changed.
7093 $LFS migrate -c 1 $file1 &> /dev/null ||
7094 error "cannot remove from pool"
7095 [ "$($LFS getstripe -p $file1)" ] &&
7096 error "pool still set"
7099 echo -n "Setting pool using --pool option..."
7100 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7101 error "migrate failed rc = $?"
7106 if $create_pool; then
7107 destroy_test_pools 2> /dev/null ||
7108 error "destroy test pools failed"
7111 run_test 56wb "check lfs_migrate pool support"
7114 local file1="$DIR/$tdir/file1"
7121 echo -n "Creating test dir..."
7122 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7123 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7124 error "cannot set stripe by '-S 1M -c 1'"
7127 echo -n "Setting initial stripe for test file..."
7128 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7129 error "cannot set stripe"
7130 cur_ssize=$($LFS getstripe -S "$file1")
7131 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
7134 # File currently set to -S 512K -c 1
7136 # Ensure -c and -S options are rejected when -R is set
7137 echo -n "Verifying incompatible options are detected..."
7138 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
7139 error "incompatible -c and -R options not detected"
7140 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
7141 error "incompatible -S and -R options not detected"
7144 # Ensure unrecognized options are passed through to 'lfs migrate'
7145 echo -n "Verifying -S option is passed through to lfs migrate..."
7146 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
7147 error "migration failed"
7148 cur_ssize=$($LFS getstripe -S "$file1")
7149 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
7152 # File currently set to -S 1M -c 1
7154 # Ensure long options are supported
7155 echo -n "Verifying long options supported..."
7156 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
7157 error "long option without argument not supported"
7158 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
7159 error "long option with argument not supported"
7160 cur_ssize=$($LFS getstripe -S "$file1")
7161 [ $cur_ssize -eq 524288 ] ||
7162 error "migrate --stripe-size $cur_ssize != 524288"
7165 # File currently set to -S 512K -c 1
7167 if [ "$OSTCOUNT" -gt 1 ]; then
7168 echo -n "Verifying explicit stripe count can be set..."
7169 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
7170 error "migrate failed"
7171 cur_scount=$($LFS getstripe -c "$file1")
7172 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
7176 # File currently set to -S 512K -c 1 or -S 512K -c 2
7178 # Ensure parent striping is used if -R is set, and no stripe
7179 # count or size is specified
7180 echo -n "Setting stripe for parent directory..."
7181 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7182 error "cannot set stripe '-S 2M -c 1'"
7185 echo -n "Verifying restripe option uses parent stripe settings..."
7186 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7187 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7188 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
7189 error "migrate failed"
7190 cur_ssize=$($LFS getstripe -S "$file1")
7191 [ $cur_ssize -eq $parent_ssize ] ||
7192 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7193 cur_scount=$($LFS getstripe -c "$file1")
7194 [ $cur_scount -eq $parent_scount ] ||
7195 error "migrate -R stripe_count $cur_scount != $parent_scount"
7198 # File currently set to -S 1M -c 1
7200 # Ensure striping is preserved if -R is not set, and no stripe
7201 # count or size is specified
7202 echo -n "Verifying striping size preserved when not specified..."
7203 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7204 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7205 error "cannot set stripe on parent directory"
7206 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7207 error "migrate failed"
7208 cur_ssize=$($LFS getstripe -S "$file1")
7209 [ $cur_ssize -eq $orig_ssize ] ||
7210 error "migrate by default $cur_ssize != $orig_ssize"
7213 # Ensure file name properly detected when final option has no argument
7214 echo -n "Verifying file name properly detected..."
7215 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7216 error "file name interpreted as option argument"
7222 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7225 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7227 local file1=$DIR/$tdir/file1
7229 echo -n "Creating test dir..."
7230 test_mkdir $DIR/$tdir || error "cannot create dir"
7233 echo -n "Creating test file..."
7237 # Ensure 'lfs migrate' will fail by using a non-existent option,
7238 # and make sure rsync is not called to recover
7239 echo -n "Make sure --no-rsync option works..."
7240 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7241 grep -q 'refusing to fall back to rsync' ||
7242 error "rsync was called with --no-rsync set"
7245 # Ensure rsync is called without trying 'lfs migrate' first
7246 echo -n "Make sure --rsync option works..."
7247 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7248 grep -q 'falling back to rsync' &&
7249 error "lfs migrate was called with --rsync set"
7252 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
7253 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
7254 grep -q 'at the same time' ||
7255 error "--rsync and --no-rsync accepted concurrently"
7261 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7267 test_mkdir $td || error "cannot create $td"
7268 touch $tf || error "cannot touch $tf"
7270 echo -n "Make sure --non-direct|-D works..."
7271 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7272 grep -q "lfs migrate --non-direct" ||
7273 error "--non-direct option cannot work correctly"
7274 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7275 grep -q "lfs migrate -D" ||
7276 error "-D option cannot work correctly"
7279 run_test 56we "check lfs_migrate --non-direct|-D support"
7282 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7283 check_swap_layouts_support
7285 local dir=$DIR/$tdir
7286 local ref1=/etc/passwd
7287 local file1=$dir/file1
7289 test_mkdir $dir || error "creating dir $dir"
7290 $LFS setstripe -c 2 $file1
7292 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7293 stripe=$($LFS getstripe -c $file1)
7294 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7295 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7300 run_test 56x "lfs migration support"
7303 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7304 check_swap_layouts_support
7306 local dir=$DIR/$tdir/$testnum
7310 local ref1=/etc/passwd
7311 local file1=$dir/file1
7313 $LFS setstripe -c 2 $file1
7315 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7317 local stripe=$($LFS getstripe -c $file1)
7319 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7320 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7325 run_test 56xa "lfs migration --block support"
7327 check_migrate_links() {
7329 local file1="$dir/file1"
7333 local total_count=$(($begin + $count - 1))
7334 local symlink_count=10
7337 if [ ! -f "$file1" ]; then
7338 echo -n "creating initial file..."
7339 $LFS setstripe -c 1 -S "512k" "$file1" ||
7340 error "cannot setstripe initial file"
7343 echo -n "creating symlinks..."
7344 for s in $(seq 1 $symlink_count); do
7345 ln -s "$file1" "$dir/slink$s" ||
7346 error "cannot create symlinks"
7350 echo -n "creating nonlinked files..."
7351 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7352 error "cannot create nonlinked files"
7357 if [ ! -f "$dir/file$total_count" ]; then
7358 echo -n "creating hard links $begin:$total_count..."
7359 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7360 /dev/null || error "cannot create hard links"
7364 echo -n "checking number of hard links listed in xattrs..."
7365 local fid=$($LFS getstripe -F "$file1")
7366 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7369 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7370 skip "hard link list has unexpected size, skipping test"
7372 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7373 error "link names should exceed xattrs size"
7376 echo -n "migrating files..."
7377 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
7379 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7382 # make sure all links have been properly migrated
7383 echo -n "verifying files..."
7384 fid=$($LFS getstripe -F "$file1") ||
7385 error "cannot get fid for file $file1"
7386 for i in $(seq 2 $total_count); do
7387 local fid2=$($LFS getstripe -F $dir/file$i)
7389 [ "$fid2" == "$fid" ] ||
7390 error "migrated hard link has mismatched FID"
7393 # make sure hard links were properly detected, and migration was
7394 # performed only once for the entire link set; nonlinked files should
7396 local actual=$(grep -c 'done' <<< "$migrate_out")
7397 local expected=$(($uniq_count + 1))
7399 [ "$actual" -eq "$expected" ] ||
7400 error "hard links individually migrated ($actual != $expected)"
7402 # make sure the correct number of hard links are present
7403 local hardlinks=$(stat -c '%h' "$file1")
7405 [ $hardlinks -eq $total_count ] ||
7406 error "num hard links $hardlinks != $total_count"
7413 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7414 skip "Need MDS version at least 2.10.55"
7416 local dir="$DIR/$tdir"
7418 test_mkdir "$dir" || error "cannot create dir $dir"
7420 echo "testing lfs migrate mode when all links fit within xattrs"
7421 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
7423 echo "testing rsync mode when all links fit within xattrs"
7424 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
7426 echo "testing lfs migrate mode when all links do not fit within xattrs"
7427 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
7429 echo "testing rsync mode when all links do not fit within xattrs"
7430 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
7432 chown -R $RUNAS_ID $dir
7433 echo "testing non-root lfs migrate mode when not all links are in xattr"
7434 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
7439 run_test 56xb "lfs migration hard link support"
7442 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7444 local dir="$DIR/$tdir"
7446 test_mkdir "$dir" || error "cannot create dir $dir"
7448 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7449 echo -n "Setting initial stripe for 20MB test file..."
7450 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7451 error "cannot setstripe 20MB file"
7453 echo -n "Sizing 20MB test file..."
7454 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
7456 echo -n "Verifying small file autostripe count is 1..."
7457 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
7458 error "cannot migrate 20MB file"
7459 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7460 error "cannot get stripe for $dir/20mb"
7461 [ $stripe_count -eq 1 ] ||
7462 error "unexpected stripe count $stripe_count for 20MB file"
7466 # Test 2: File is small enough to fit within the available space on
7467 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7468 # have at least an additional 1KB for each desired stripe for test 3
7469 echo -n "Setting stripe for 1GB test file..."
7470 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7472 echo -n "Sizing 1GB test file..."
7473 # File size is 1GB + 3KB
7474 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7477 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7478 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7479 if (( avail > 524288 * OSTCOUNT )); then
7480 echo -n "Migrating 1GB file..."
7481 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7482 error "cannot migrate 1GB file"
7484 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7485 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7486 error "cannot getstripe for 1GB file"
7487 [ $stripe_count -eq 2 ] ||
7488 error "unexpected stripe count $stripe_count != 2"
7492 # Test 3: File is too large to fit within the available space on
7493 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7494 if [ $OSTCOUNT -ge 3 ]; then
7495 # The required available space is calculated as
7496 # file size (1GB + 3KB) / OST count (3).
7497 local kb_per_ost=349526
7499 echo -n "Migrating 1GB file with limit..."
7500 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7501 error "cannot migrate 1GB file with limit"
7504 stripe_count=$($LFS getstripe -c "$dir/1gb")
7505 echo -n "Verifying 1GB autostripe count with limited space..."
7506 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7507 error "unexpected stripe count $stripe_count (min 3)"
7514 run_test 56xc "lfs migration autostripe"
7517 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7519 local dir=$DIR/$tdir
7520 local f_mgrt=$dir/$tfile.mgrt
7521 local f_yaml=$dir/$tfile.yaml
7522 local f_copy=$dir/$tfile.copy
7523 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7524 local layout_copy="-c 2 -S 2M -i 1"
7525 local yamlfile=$dir/yamlfile
7526 local layout_before;
7529 test_mkdir "$dir" || error "cannot create dir $dir"
7530 $LFS setstripe $layout_yaml $f_yaml ||
7531 error "cannot setstripe $f_yaml with layout $layout_yaml"
7532 $LFS getstripe --yaml $f_yaml > $yamlfile
7533 $LFS setstripe $layout_copy $f_copy ||
7534 error "cannot setstripe $f_copy with layout $layout_copy"
7536 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7538 # 1. test option --yaml
7539 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7540 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7541 layout_before=$(get_layout_param $f_yaml)
7542 layout_after=$(get_layout_param $f_mgrt)
7543 [ "$layout_after" == "$layout_before" ] ||
7544 error "lfs_migrate --yaml: $layout_after != $layout_before"
7546 # 2. test option --copy
7547 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7548 error "cannot migrate $f_mgrt with --copy $f_copy"
7549 layout_before=$(get_layout_param $f_copy)
7550 layout_after=$(get_layout_param $f_mgrt)
7551 [ "$layout_after" == "$layout_before" ] ||
7552 error "lfs_migrate --copy: $layout_after != $layout_before"
7554 run_test 56xd "check lfs_migrate --yaml and --copy support"
7557 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7559 local dir=$DIR/$tdir
7560 local f_comp=$dir/$tfile
7561 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7562 local layout_before=""
7563 local layout_after=""
7565 test_mkdir "$dir" || error "cannot create dir $dir"
7566 $LFS setstripe $layout $f_comp ||
7567 error "cannot setstripe $f_comp with layout $layout"
7568 layout_before=$(get_layout_param $f_comp)
7569 dd if=/dev/zero of=$f_comp bs=1M count=4
7571 # 1. migrate a comp layout file by lfs_migrate
7572 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7573 layout_after=$(get_layout_param $f_comp)
7574 [ "$layout_before" == "$layout_after" ] ||
7575 error "lfs_migrate: $layout_before != $layout_after"
7577 # 2. migrate a comp layout file by lfs migrate
7578 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7579 layout_after=$(get_layout_param $f_comp)
7580 [ "$layout_before" == "$layout_after" ] ||
7581 error "lfs migrate: $layout_before != $layout_after"
7583 run_test 56xe "migrate a composite layout file"
7586 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7588 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7589 skip "Need server version at least 2.13.53"
7591 local dir=$DIR/$tdir
7592 local f_comp=$dir/$tfile
7593 local layout="-E 1M -c1 -E -1 -c2"
7597 test_mkdir "$dir" || error "cannot create dir $dir"
7598 $LFS setstripe $layout $f_comp ||
7599 error "cannot setstripe $f_comp with layout $layout"
7600 fid_before=$($LFS getstripe --fid $f_comp)
7601 dd if=/dev/zero of=$f_comp bs=1M count=4
7603 # 1. migrate a comp layout file to a comp layout
7604 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7605 fid_after=$($LFS getstripe --fid $f_comp)
7606 [ "$fid_before" == "$fid_after" ] ||
7607 error "comp-to-comp migrate: $fid_before != $fid_after"
7609 # 2. migrate a comp layout file to a plain layout
7610 $LFS migrate -c2 $f_comp ||
7611 error "cannot migrate $f_comp by lfs migrate"
7612 fid_after=$($LFS getstripe --fid $f_comp)
7613 [ "$fid_before" == "$fid_after" ] ||
7614 error "comp-to-plain migrate: $fid_before != $fid_after"
7616 # 3. migrate a plain layout file to a comp layout
7617 $LFS migrate $layout $f_comp ||
7618 error "cannot migrate $f_comp by lfs migrate"
7619 fid_after=$($LFS getstripe --fid $f_comp)
7620 [ "$fid_before" == "$fid_after" ] ||
7621 error "plain-to-comp migrate: $fid_before != $fid_after"
7623 run_test 56xf "FID is not lost during migration of a composite layout file"
7626 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
7627 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
7630 local dir=$DIR/$tdir
7634 test_mkdir -p $dir || error "creating dir $dir"
7635 touch $f1 || error "creating std file $f1"
7636 $MULTIOP $f2 H2c || error "creating released file $f2"
7638 # a directory can be raid0, so ask only for files
7639 res=$($LFS find $dir -L raid0 -type f | wc -l)
7640 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
7642 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
7643 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
7645 # only files can be released, so no need to force file search
7646 res=$($LFS find $dir -L released)
7647 [[ $res == $f2 ]] || error "search released: found $res != $f2"
7649 res=$($LFS find $dir -type f \! -L released)
7650 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
7652 run_test 56y "lfs find -L raid0|released"
7654 test_56z() { # LU-4824
7655 # This checks to make sure 'lfs find' continues after errors
7656 # There are two classes of errors that should be caught:
7657 # - If multiple paths are provided, all should be searched even if one
7659 # - If errors are encountered during the search, it should not terminate
7661 local dir=$DIR/$tdir
7665 for i in d{0..9}; do
7667 touch $dir/$i/$tfile
7669 $LFS find $DIR/non_existent_dir $dir &&
7670 error "$LFS find did not return an error"
7671 # Make a directory unsearchable. This should NOT be the last entry in
7672 # directory order. Arbitrarily pick the 6th entry
7673 chmod 700 $($LFS find $dir -type d | sed '6!d')
7675 $RUNAS $LFS find $DIR/non_existent $dir
7676 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
7678 # The user should be able to see 10 directories and 9 files
7679 (( count == 19 )) ||
7680 error "$LFS find found $count != 19 entries after error"
7682 run_test 56z "lfs find should continue after an error"
7684 test_56aa() { # LU-5937
7685 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
7687 local dir=$DIR/$tdir
7690 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
7692 createmany -o $dir/striped_dir/${tfile}- 1024
7693 local dirs=$($LFS find --size +8k $dir/)
7695 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
7697 run_test 56aa "lfs find --size under striped dir"
7699 test_56ab() { # LU-10705
7700 test_mkdir $DIR/$tdir
7701 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
7702 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
7703 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
7704 # Flush writes to ensure valid blocks. Need to be more thorough for
7705 # ZFS, since blocks are not allocated/returned to client immediately.
7707 wait_zfs_commit ost1 2
7708 cancel_lru_locks osc
7711 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
7713 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
7715 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
7716 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
7718 rm -f $DIR/$tdir/$tfile.[123]
7720 run_test 56ab "lfs find --blocks"
7724 local dir="$DIR/$tdir"
7725 local perms=(001 002 003 004 005 006 007
7726 010 020 030 040 050 060 070
7727 100 200 300 400 500 600 700
7728 111 222 333 444 555 666 777)
7729 local perm_minus=(8 8 4 8 4 4 2
7733 local perm_slash=(8 8 12 8 12 12 14
7736 16 16 24 16 24 24 28)
7739 for perm in ${perms[*]}; do
7740 touch "$dir/$tfile.$perm"
7741 chmod $perm "$dir/$tfile.$perm"
7744 for ((i = 0; i < ${#perms[*]}; i++)); do
7745 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
7747 error "lfs find -perm ${perms[i]}:"\
7750 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
7751 (( $num == ${perm_minus[i]} )) ||
7752 error "lfs find -perm -${perms[i]}:"\
7753 "$num != ${perm_minus[i]}"
7755 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
7756 (( $num == ${perm_slash[i]} )) ||
7757 error "lfs find -perm /${perms[i]}:"\
7758 "$num != ${perm_slash[i]}"
7761 run_test 56aca "check lfs find -perm with octal representation"
7764 local dir=$DIR/$tdir
7765 # p is the permission of write and execute for user, group and other
7766 # without the umask. It is used to test +wx.
7767 local p=$(printf "%o" "$((0333 & ~$(umask)))")
7768 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
7769 local symbolic=(+t a+t u+t g+t o+t
7775 o=r,ug+o,u+w u=r,a+u,u+w
7776 g=r,ugo=g,u+w u+x,+X +X
7777 u+x,u+X u+X u+x,g+X o+r,+X
7781 for perm in ${perms[*]}; do
7782 touch "$dir/$tfile.$perm"
7783 chmod $perm "$dir/$tfile.$perm"
7786 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
7787 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
7790 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
7793 run_test 56acb "check lfs find -perm with symbolic representation"
7796 local dir=$DIR/$tdir
7797 local tests="17777 787 789 abcd
7798 ug=uu ug=a ug=gu uo=ou urw
7802 for err in $tests; do
7803 if $LFS find $dir -perm $err 2>/dev/null; then
7804 error "lfs find -perm $err: parsing should have failed"
7808 run_test 56acc "check parsing error for lfs find -perm"
7811 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
7812 skip "Need MDS version at least 2.10.50"
7814 # Create composite files with one component
7815 local dir=$DIR/$tdir
7817 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
7818 # Create composite files with three components
7819 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
7820 # Create non-composite files
7821 createmany -o $dir/${tfile}- 10
7823 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
7825 [[ $nfiles == 10 ]] ||
7826 error "lfs find -E 1M found $nfiles != 10 files"
7828 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
7829 [[ $nfiles == 25 ]] ||
7830 error "lfs find ! -E 1M found $nfiles != 25 files"
7832 # All files have a component that starts at 0
7833 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
7834 [[ $nfiles == 35 ]] ||
7835 error "lfs find --component-start 0 - $nfiles != 35 files"
7837 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
7838 [[ $nfiles == 15 ]] ||
7839 error "lfs find --component-start 2M - $nfiles != 15 files"
7841 # All files created here have a componenet that does not starts at 2M
7842 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
7843 [[ $nfiles == 35 ]] ||
7844 error "lfs find ! --component-start 2M - $nfiles != 35 files"
7846 # Find files with a specified number of components
7847 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
7848 [[ $nfiles == 15 ]] ||
7849 error "lfs find --component-count 3 - $nfiles != 15 files"
7851 # Remember non-composite files have a component count of zero
7852 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
7853 [[ $nfiles == 10 ]] ||
7854 error "lfs find --component-count 0 - $nfiles != 10 files"
7856 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
7857 [[ $nfiles == 20 ]] ||
7858 error "lfs find ! --component-count 3 - $nfiles != 20 files"
7860 # All files have a flag called "init"
7861 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
7862 [[ $nfiles == 35 ]] ||
7863 error "lfs find --component-flags init - $nfiles != 35 files"
7865 # Multi-component files will have a component not initialized
7866 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
7867 [[ $nfiles == 15 ]] ||
7868 error "lfs find !--component-flags init - $nfiles != 15 files"
7873 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
7876 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
7877 skip "Need MDS version at least 2.10.57"
7887 # create mirrored directories and mirrored files
7888 mkdir $td || error "mkdir $td failed"
7889 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
7890 createmany -o $tf- 10 || error "create $tf- failed"
7892 for i in $(seq 2); do
7894 mkdir $dir || error "mkdir $dir failed"
7895 $LFS mirror create -N$((3 + i)) $dir ||
7896 error "create mirrored dir $dir failed"
7897 createmany -o $dir/$tfile- 10 ||
7898 error "create $dir/$tfile- failed"
7901 # change the states of some mirrored files
7903 for i in $(seq 2); do
7905 for j in $(seq 4 9); do
7906 echo foo > $dir/$tfile-$j
7910 # find mirrored files with specific mirror count
7911 cmd="$LFS find --mirror-count 3 --type f $td"
7912 nfiles=$($cmd | wc -l)
7913 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
7915 cmd="$LFS find ! --mirror-count 3 --type f $td"
7916 nfiles=$($cmd | wc -l)
7917 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
7919 cmd="$LFS find --mirror-count +2 --type f $td"
7920 nfiles=$($cmd | wc -l)
7921 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7923 cmd="$LFS find --mirror-count -6 --type f $td"
7924 nfiles=$($cmd | wc -l)
7925 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7927 # find mirrored files with specific file state
7928 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
7929 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
7931 cmd="$LFS find --mirror-state=ro --type f $td"
7932 nfiles=$($cmd | wc -l)
7933 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
7935 cmd="$LFS find ! --mirror-state=ro --type f $td"
7936 nfiles=$($cmd | wc -l)
7937 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7939 cmd="$LFS find --mirror-state=wp --type f $td"
7940 nfiles=$($cmd | wc -l)
7941 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7943 cmd="$LFS find ! --mirror-state=sp --type f $td"
7944 nfiles=$($cmd | wc -l)
7945 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7947 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
7949 test_56da() { # LU-14179
7950 local path=$DIR/$tdir
7955 local longdir=$(str_repeat 'a' 255)
7957 for i in {1..15}; do
7964 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
7969 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
7972 touch $(str_repeat 'f' 255)
7974 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
7975 error "lfs find reported an error"
7979 run_test 56da "test lfs find with long paths"
7982 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7983 # note test will not do anything if MDS is not local
7984 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7985 skip_env "ldiskfs only test"
7987 remote_mds_nodsh && skip "remote MDS with nodsh"
7989 local MNTDEV="osd*.*MDT*.mntdev"
7990 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
7991 [ -z "$DEV" ] && error "can't access $MNTDEV"
7992 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
7993 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
7994 error "can't access $DEV"
7995 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
7996 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
8000 run_test 57a "verify MDS filesystem created with large inodes =="
8003 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8004 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8005 skip_env "ldiskfs only test"
8007 remote_mds_nodsh && skip "remote MDS with nodsh"
8009 local dir=$DIR/$tdir
8012 local fileN=$dir/f$filecount
8014 rm -rf $dir || error "removing $dir"
8016 local mdtidx=$($LFS getstripe -m $dir)
8017 local mdtname=MDT$(printf %04x $mdtidx)
8018 local facet=mds$((mdtidx + 1))
8020 echo "mcreating $filecount files"
8021 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
8023 # verify that files do not have EAs yet
8024 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
8025 error "$file1 has an EA"
8026 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
8027 error "$fileN has an EA"
8031 df $dir #make sure we get new statfs data
8032 local mdsfree=$(do_facet $facet \
8033 lctl get_param -n osd*.*$mdtname.kbytesfree)
8034 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8037 echo "opening files to create objects/EAs"
8038 for file in $(seq -f $dir/f%g 1 $filecount); do
8039 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
8040 error "opening $file"
8043 # verify that files have EAs now
8044 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
8045 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
8047 sleep 1 #make sure we get new statfs data
8049 local mdsfree2=$(do_facet $facet \
8050 lctl get_param -n osd*.*$mdtname.kbytesfree)
8051 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8053 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
8054 if [ "$mdsfree" != "$mdsfree2" ]; then
8055 error "MDC before $mdcfree != after $mdcfree2"
8057 echo "MDC before $mdcfree != after $mdcfree2"
8058 echo "unable to confirm if MDS has large inodes"
8063 run_test 57b "default LOV EAs are stored inside large inodes ==="
8066 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8067 [ -z "$(which wiretest 2>/dev/null)" ] &&
8068 skip_env "could not find wiretest"
8072 run_test 58 "verify cross-platform wire constants =============="
8075 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8077 echo "touch 130 files"
8078 createmany -o $DIR/f59- 130
8080 unlinkmany $DIR/f59- 130
8082 # wait for commitment of removal
8083 wait_delete_completed
8085 run_test 59 "verify cancellation of llog records async ========="
8087 TEST60_HEAD="test_60 run $RANDOM"
8089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8090 remote_mgs_nodsh && skip "remote MGS with nodsh"
8091 do_facet mgs "! which run-llog.sh &> /dev/null" &&
8092 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
8093 skip_env "missing subtest run-llog.sh"
8095 log "$TEST60_HEAD - from kernel mode"
8096 do_facet mgs "$LCTL dk > /dev/null"
8097 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
8098 do_facet mgs $LCTL dk > $TMP/$tfile
8100 # LU-6388: test llog_reader
8101 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
8102 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
8103 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
8104 skip_env "missing llog_reader"
8105 local fstype=$(facet_fstype mgs)
8106 [ $fstype != ldiskfs -a $fstype != zfs ] &&
8107 skip_env "Only for ldiskfs or zfs type mgs"
8109 local mntpt=$(facet_mntpt mgs)
8110 local mgsdev=$(mgsdevname 1)
8122 #get fid and record list
8123 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
8125 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
8127 #remount mgs as ldiskfs or zfs type
8128 stop mgs || error "stop mgs failed"
8129 mount_fstype mgs || error "remount mgs failed"
8130 for ((i = 0; i < ${#fid_list[@]}; i++)); do
8133 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
8134 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
8139 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
8141 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
8143 echo "obj_file is $obj_file"
8144 do_facet mgs $llog_reader $obj_file
8146 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
8147 awk '{ print $3 }' | sed -e "s/^type=//g")
8148 if [ $rec_type != $rec ]; then
8149 echo "FAILED test_60a wrong record type $rec_type," \
8155 #check obj path if record type is LLOG_LOGID_MAGIC
8156 if [ "$rec" == "1064553b" ]; then
8157 path=$(do_facet mgs $llog_reader $obj_file |
8158 grep "path=" | awk '{ print $NF }' |
8159 sed -e "s/^path=//g")
8160 if [ $obj_file != $mntpt/$path ]; then
8161 echo "FAILED test_60a wrong obj path" \
8162 "$montpt/$path, should be $obj_file"
8169 #restart mgs before "error", otherwise it will block the next test
8170 stop mgs || error "stop mgs failed"
8171 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
8172 $pass || error "test failed, see FAILED test_60a messages for specifics"
8174 run_test 60a "llog_test run from kernel module and test llog_reader"
8176 test_60b() { # bug 6411
8177 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8180 LLOG_COUNT=$(do_facet mgs dmesg |
8181 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
8182 /llog_[a-z]*.c:[0-9]/ {
8194 [[ $LLOG_COUNT -gt 120 ]] &&
8195 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
8197 run_test 60b "limit repeated messages from CERROR/CWARN"
8200 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8202 echo "create 5000 files"
8203 createmany -o $DIR/f60c- 5000
8204 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
8205 lctl set_param fail_loc=0x80000137
8206 unlinkmany $DIR/f60c- 5000
8207 lctl set_param fail_loc=0
8209 run_test 60c "unlink file when mds full"
8212 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8214 SAVEPRINTK=$(lctl get_param -n printk)
8215 # verify "lctl mark" is even working"
8216 MESSAGE="test message ID $RANDOM $$"
8217 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8218 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
8220 lctl set_param printk=0 || error "set lnet.printk failed"
8221 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
8222 MESSAGE="new test message ID $RANDOM $$"
8223 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
8224 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8225 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
8227 lctl set_param -n printk="$SAVEPRINTK"
8229 run_test 60d "test printk console message masking"
8232 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8233 remote_mds_nodsh && skip "remote MDS with nodsh"
8236 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
8237 do_facet mds1 lctl set_param fail_loc=0x15b
8240 run_test 60e "no space while new llog is being created"
8243 local old_path=$($LCTL get_param -n debug_path)
8245 stack_trap "$LCTL set_param debug_path=$old_path"
8246 stack_trap "rm -f $TMP/$tfile*"
8247 rm -f $TMP/$tfile* 2> /dev/null
8248 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8249 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
8250 test_mkdir $DIR/$tdir
8251 # retry in case the open is cached and not released
8252 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
8253 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
8257 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
8259 run_test 60f "change debug_path works"
8265 test_mkdir -c $MDSCOUNT $DIR/$tdir
8270 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
8271 -c $MDSCOUNT $DIR/$tdir/subdir$index \
8273 mkdir $DIR/$tdir/subdir$index 2>/dev/null
8274 rmdir $DIR/$tdir/subdir$index 2>/dev/null
8275 index=$((index + 1))
8281 for i in {0..100}; do
8282 # define OBD_FAIL_OSD_TXN_START 0x19a
8283 local index=$((i % MDSCOUNT + 1))
8285 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
8292 for i in $(seq $MDSCOUNT); do
8293 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
8296 mkdir $DIR/$tdir/new || error "mkdir failed"
8297 rmdir $DIR/$tdir/new || error "rmdir failed"
8299 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
8301 for i in $(seq $MDSCOUNT); do
8302 wait_update_facet mds$i "$LCTL get_param -n \
8303 mdd.$(facet_svc mds$i).lfsck_namespace |
8304 awk '/^status/ { print \\\$2 }'" "completed"
8307 ls -R $DIR/$tdir || error "ls failed"
8308 rm -rf $DIR/$tdir || error "rmdir failed"
8310 run_test 60g "transaction abort won't cause MDT hung"
8313 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
8314 skip "Need MDS version at least 2.12.52"
8315 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
8319 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
8320 #define OBD_FAIL_MDS_STRIPE_FID 0x189
8321 for fail_loc in 0x80000188 0x80000189; do
8322 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
8323 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
8324 error "mkdir $dir-$fail_loc failed"
8325 for i in {0..10}; do
8326 # create may fail on missing stripe
8327 echo $i > $DIR/$tdir-$fail_loc/$i
8329 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8330 error "getdirstripe $tdir-$fail_loc failed"
8331 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
8332 error "migrate $tdir-$fail_loc failed"
8333 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8334 error "getdirstripe $tdir-$fail_loc failed"
8335 pushd $DIR/$tdir-$fail_loc
8337 echo $f | cmp $f - || error "$f data mismatch"
8340 rm -rf $DIR/$tdir-$fail_loc
8343 run_test 60h "striped directory with missing stripes can be accessed"
8345 function t60i_load() {
8347 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
8348 $LCTL set_param fail_loc=0x131c fail_val=1
8349 for ((i=0; i<5000; i++)); do
8350 touch $DIR/$tdir/f$i
8355 changelog_register || error "changelog_register failed"
8356 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
8357 changelog_users $SINGLEMDS | grep -q $cl_user ||
8358 error "User $cl_user not found in changelog_users"
8359 changelog_chmask "ALL"
8362 for((i=0; i<100; i++)); do
8363 changelog_dump >/dev/null ||
8364 error "can't read changelog"
8368 changelog_deregister || error "changelog_deregister failed"
8369 $LCTL set_param fail_loc=0
8371 run_test 60i "llog: new record vs reader race"
8374 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8377 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
8378 cancel_lru_locks osc
8379 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
8382 run_test 61a "mmap() writes don't make sync hang ================"
8385 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
8387 run_test 61b "mmap() of unstriped file is successful"
8389 # bug 2330 - insufficient obd_match error checking causes LBUG
8391 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8395 cancel_lru_locks osc
8396 lctl set_param fail_loc=0x405
8397 cat $f && error "cat succeeded, expect -EIO"
8398 lctl set_param fail_loc=0
8400 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
8401 # match every page all of the time.
8402 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
8404 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
8405 # Though this test is irrelevant anymore, it helped to reveal some
8406 # other grant bugs (LU-4482), let's keep it.
8407 test_63a() { # was test_63
8408 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8410 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
8412 for i in `seq 10` ; do
8413 dd if=/dev/zero of=$DIR/f63 bs=8k &
8419 rm -f $DIR/f63 || true
8421 run_test 63a "Verify oig_wait interruption does not crash ======="
8423 # bug 2248 - async write errors didn't return to application on sync
8424 # bug 3677 - async write errors left page locked
8426 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8429 lctl set_param debug=-1
8431 # ensure we have a grant to do async writes
8432 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
8435 sync # sync lest earlier test intercept the fail_loc
8437 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8438 lctl set_param fail_loc=0x80000406
8439 $MULTIOP $DIR/$tfile Owy && \
8440 error "sync didn't return ENOMEM"
8441 sync; sleep 2; sync # do a real sync this time to flush page
8442 lctl get_param -n llite.*.dump_page_cache | grep locked && \
8443 error "locked page left in cache after async error" || true
8446 run_test 63b "async write errors should be returned to fsync ==="
8449 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8452 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
8454 run_test 64a "verify filter grant calculations (in kernel) ====="
8457 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8459 sh oos.sh $MOUNT || error "oos.sh failed: $?"
8461 run_test 64b "check out-of-space detection on client"
8464 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
8466 run_test 64c "verify grant shrink"
8472 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
8475 # this does exactly what osc_request.c:osc_announce_cached() does in
8476 # order to calculate max amount of grants to ask from server
8480 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
8481 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
8483 ((rpc_in_flight++));
8484 nrpages=$((nrpages * rpc_in_flight))
8486 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
8488 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
8490 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
8491 local undirty=$((nrpages * PAGE_SIZE))
8493 local max_extent_pages
8494 max_extent_pages=$(import_param $tgt grant_max_extent_size)
8495 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
8496 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
8497 local grant_extent_tax
8498 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8500 undirty=$((undirty + nrextents * grant_extent_tax))
8505 # this is size of unit for grant allocation. It should be equal to
8506 # what tgt_grant.c:tgt_grant_chunk() calculates
8510 local grant_extent_tax
8512 max_brw_size=$(import_param $tgt max_brw_size)
8514 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8516 echo $(((max_brw_size + grant_extent_tax) * 2))
8520 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
8521 skip "OST < 2.10.55 doesn't limit grants enough"
8523 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
8525 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
8526 skip "no grant_param connect flag"
8528 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
8530 $LCTL set_param -n -n debug="$OLDDEBUG" || true
8531 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
8534 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
8535 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
8537 $LFS setstripe $DIR/$tfile -i 0 -c 1
8538 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
8541 while kill -0 $ddpid; do
8542 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8544 if [[ $cur_grant -gt $max_cur_granted ]]; then
8546 error "cur_grant $cur_grant > $max_cur_granted"
8552 run_test 64d "check grant limit exceed"
8558 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8560 ((cur_grants == expected)) ||
8561 error "$msg: grants mismatch: $cur_grants, expected $expected"
8565 echo $((($1 + $2 - 1) & ~($2 - 1)))
8569 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8570 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
8571 skip "Need OSS version at least 2.11.56"
8573 # Remount client to reset grant
8574 remount_client $MOUNT || error "failed to remount client"
8575 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8577 local init_grants=$(import_param $osc_tgt initial_grant)
8579 check_grants $osc_tgt $init_grants "init grants"
8581 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
8582 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8583 local gbs=$(import_param $osc_tgt grant_block_size)
8585 # write random number of bytes from max_brw_size / 4 to max_brw_size
8586 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
8587 # align for direct io
8588 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
8589 # round to grant consumption unit
8590 local wb_round_up=$(round_up_p2 $write_bytes gbs)
8592 local grants=$((wb_round_up + extent_tax))
8594 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8596 # define OBD_FAIL_TGT_NO_GRANT 0x725
8597 # make the server not grant more back
8598 do_facet ost1 $LCTL set_param fail_loc=0x725
8599 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
8601 do_facet ost1 $LCTL set_param fail_loc=0
8603 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
8605 rm -f $DIR/$tfile || error "rm failed"
8607 # Remount client to reset grant
8608 remount_client $MOUNT || error "failed to remount client"
8609 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8611 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8613 # define OBD_FAIL_TGT_NO_GRANT 0x725
8614 # make the server not grant more back
8615 do_facet ost1 $LCTL set_param fail_loc=0x725
8616 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
8617 do_facet ost1 $LCTL set_param fail_loc=0
8619 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
8621 run_test 64e "check grant consumption (no grant allocation)"
8624 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8626 # Remount client to reset grant
8627 remount_client $MOUNT || error "failed to remount client"
8628 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8630 local init_grants=$(import_param $osc_tgt initial_grant)
8631 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
8632 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8633 local gbs=$(import_param $osc_tgt grant_block_size)
8634 local chunk=$(grant_chunk $osc_tgt)
8636 # write random number of bytes from max_brw_size / 4 to max_brw_size
8637 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
8638 # align for direct io
8639 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
8640 # round to grant consumption unit
8641 local wb_round_up=$(round_up_p2 $write_bytes gbs)
8643 local grants=$((wb_round_up + extent_tax))
8645 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8646 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
8647 error "error writing to $DIR/$tfile"
8649 check_grants $osc_tgt $((init_grants - grants + chunk)) \
8650 "direct io with grant allocation"
8652 rm -f $DIR/$tfile || error "rm failed"
8654 # Remount client to reset grant
8655 remount_client $MOUNT || error "failed to remount client"
8656 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8658 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8660 local cmd="oO_WRONLY:w${write_bytes}_yc"
8662 $MULTIOP $DIR/$tfile $cmd &
8666 check_grants $osc_tgt $((init_grants - grants)) \
8667 "buffered io, not write rpc"
8669 kill -USR1 $MULTIPID
8672 check_grants $osc_tgt $((init_grants - grants + chunk)) \
8673 "buffered io, one RPC"
8675 run_test 64f "check grant consumption (with grant allocation)"
8677 # bug 1414 - set/get directories' stripe info
8679 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8681 test_mkdir $DIR/$tdir
8683 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
8685 run_test 65a "directory with no stripe info"
8688 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8690 test_mkdir $DIR/$tdir
8691 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8693 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8696 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
8698 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
8701 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8702 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
8704 test_mkdir $DIR/$tdir
8705 local stripesize=$($LFS getstripe -S $DIR/$tdir)
8707 $LFS setstripe -S $((stripesize * 4)) -i 1 \
8708 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
8710 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
8712 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
8715 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8717 test_mkdir $DIR/$tdir
8718 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
8719 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8721 if [[ $STRIPECOUNT -le 0 ]]; then
8723 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
8724 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
8725 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
8727 sc=$(($STRIPECOUNT - 1))
8729 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
8730 touch $DIR/$tdir/f4 $DIR/$tdir/f5
8731 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
8732 error "lverify failed"
8734 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
8737 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8739 test_mkdir $DIR/$tdir
8741 $LFS setstripe $DIR/$tdir || error "setstripe"
8742 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
8743 error "no stripe info failed"
8745 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
8747 run_test 65e "directory setstripe defaults"
8750 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8752 test_mkdir $DIR/${tdir}f
8753 $RUNAS $LFS setstripe $DIR/${tdir}f &&
8754 error "setstripe succeeded" || true
8756 run_test 65f "dir setstripe permission (should return error) ==="
8759 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8761 test_mkdir $DIR/$tdir
8762 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8764 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8765 error "setstripe -S failed"
8766 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
8767 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
8768 error "delete default stripe failed"
8770 run_test 65g "directory setstripe -d"
8773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8775 test_mkdir $DIR/$tdir
8776 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8778 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8779 error "setstripe -S failed"
8780 test_mkdir $DIR/$tdir/dd1
8781 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
8782 error "stripe info inherit failed"
8784 run_test 65h "directory stripe info inherit ===================="
8787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8789 save_layout_restore_at_exit $MOUNT
8791 # bug6367: set non-default striping on root directory
8792 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
8794 # bug12836: getstripe on -1 default directory striping
8795 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
8797 # bug12836: getstripe -v on -1 default directory striping
8798 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
8800 # bug12836: new find on -1 default directory striping
8801 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
8803 run_test 65i "various tests to set root directory striping"
8805 test_65j() { # bug6367
8806 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8810 # if we aren't already remounting for each test, do so for this test
8811 if [ "$I_MOUNTED" = "yes" ]; then
8812 cleanup || error "failed to unmount"
8816 save_layout_restore_at_exit $MOUNT
8818 $LFS setstripe -d $MOUNT || error "setstripe failed"
8820 run_test 65j "set default striping on root directory (bug 6367)="
8824 wait_delete_completed
8825 do_facet $SINGLEMDS "lctl set_param -n \
8826 osp.$ost*MDT0000.max_create_count=$max_count"
8827 do_facet $SINGLEMDS "lctl set_param -n \
8828 osp.$ost*MDT0000.create_count=$count"
8829 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
8830 echo $INACTIVE_OSC "is Activate"
8832 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
8835 test_65k() { # bug11679
8836 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8837 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8838 remote_mds_nodsh && skip "remote MDS with nodsh"
8840 local disable_precreate=true
8841 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
8842 disable_precreate=false
8844 echo "Check OST status: "
8845 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
8846 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
8848 for OSC in $MDS_OSCS; do
8849 echo $OSC "is active"
8850 do_facet $SINGLEMDS lctl --device %$OSC activate
8853 for INACTIVE_OSC in $MDS_OSCS; do
8854 local ost=$(osc_to_ost $INACTIVE_OSC)
8855 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
8856 lov.*md*.target_obd |
8857 awk -F: /$ost/'{ print $1 }' | head -n 1)
8860 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
8861 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
8863 echo "Deactivate: " $INACTIVE_OSC
8864 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
8866 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
8867 osp.$ost*MDT0000.create_count")
8868 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
8869 osp.$ost*MDT0000.max_create_count")
8870 $disable_precreate &&
8871 do_facet $SINGLEMDS "lctl set_param -n \
8872 osp.$ost*MDT0000.max_create_count=0"
8874 for idx in $(seq 0 $((OSTCOUNT - 1))); do
8875 [ -f $DIR/$tdir/$idx ] && continue
8876 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
8877 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
8879 error "setstripe $idx should succeed"; }
8880 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
8882 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
8885 do_facet $SINGLEMDS "lctl set_param -n \
8886 osp.$ost*MDT0000.max_create_count=$max_count"
8887 do_facet $SINGLEMDS "lctl set_param -n \
8888 osp.$ost*MDT0000.create_count=$count"
8889 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
8890 echo $INACTIVE_OSC "is Activate"
8892 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
8895 run_test 65k "validate manual striping works properly with deactivated OSCs"
8897 test_65l() { # bug 12836
8898 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8900 test_mkdir -p $DIR/$tdir/test_dir
8901 $LFS setstripe -c -1 $DIR/$tdir/test_dir
8902 $LFS find -mtime -1 $DIR/$tdir >/dev/null
8904 run_test 65l "lfs find on -1 stripe dir ========================"
8907 local layout=$(save_layout $MOUNT)
8908 $RUNAS $LFS setstripe -c 2 $MOUNT && {
8909 restore_layout $MOUNT $layout
8910 error "setstripe should fail by non-root users"
8914 run_test 65m "normal user can't set filesystem default stripe"
8917 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
8918 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
8919 skip "Need MDS version at least 2.12.50"
8920 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
8922 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
8923 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
8924 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
8926 save_layout_restore_at_exit $MOUNT
8928 # new subdirectory under root directory should not inherit
8929 # the default layout from root
8930 local dir1=$MOUNT/$tdir-1
8931 mkdir $dir1 || error "mkdir $dir1 failed"
8932 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
8933 error "$dir1 shouldn't have LOV EA"
8935 # delete the default layout on root directory
8936 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
8938 local dir2=$MOUNT/$tdir-2
8939 mkdir $dir2 || error "mkdir $dir2 failed"
8940 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
8941 error "$dir2 shouldn't have LOV EA"
8943 # set a new striping pattern on root directory
8944 local def_stripe_size=$($LFS getstripe -S $MOUNT)
8945 local new_def_stripe_size=$((def_stripe_size * 2))
8946 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
8947 error "set stripe size on $MOUNT failed"
8949 # new file created in $dir2 should inherit the new stripe size from
8950 # the filesystem default
8951 local file2=$dir2/$tfile-2
8952 touch $file2 || error "touch $file2 failed"
8954 local file2_stripe_size=$($LFS getstripe -S $file2)
8955 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
8957 echo "file2_stripe_size: '$file2_stripe_size'"
8958 echo "new_def_stripe_size: '$new_def_stripe_size'"
8959 error "$file2 didn't inherit stripe size $new_def_stripe_size"
8962 local dir3=$MOUNT/$tdir-3
8963 mkdir $dir3 || error "mkdir $dir3 failed"
8964 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
8965 # the root layout, which is the actual default layout that will be used
8966 # when new files are created in $dir3.
8967 local dir3_layout=$(get_layout_param $dir3)
8968 local root_dir_layout=$(get_layout_param $MOUNT)
8969 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
8971 echo "dir3_layout: '$dir3_layout'"
8972 echo "root_dir_layout: '$root_dir_layout'"
8973 error "$dir3 should show the default layout from $MOUNT"
8976 # set OST pool on root directory
8977 local pool=$TESTNAME
8978 pool_add $pool || error "add $pool failed"
8979 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8980 error "add targets to $pool failed"
8982 $LFS setstripe -p $pool $MOUNT ||
8983 error "set OST pool on $MOUNT failed"
8985 # new file created in $dir3 should inherit the pool from
8986 # the filesystem default
8987 local file3=$dir3/$tfile-3
8988 touch $file3 || error "touch $file3 failed"
8990 local file3_pool=$($LFS getstripe -p $file3)
8991 [[ "$file3_pool" = "$pool" ]] ||
8992 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
8994 local dir4=$MOUNT/$tdir-4
8995 mkdir $dir4 || error "mkdir $dir4 failed"
8996 local dir4_layout=$(get_layout_param $dir4)
8997 root_dir_layout=$(get_layout_param $MOUNT)
8998 echo "$LFS getstripe -d $dir4"
8999 $LFS getstripe -d $dir4
9000 echo "$LFS getstripe -d $MOUNT"
9001 $LFS getstripe -d $MOUNT
9002 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
9004 echo "dir4_layout: '$dir4_layout'"
9005 echo "root_dir_layout: '$root_dir_layout'"
9006 error "$dir4 should show the default layout from $MOUNT"
9009 # new file created in $dir4 should inherit the pool from
9010 # the filesystem default
9011 local file4=$dir4/$tfile-4
9012 touch $file4 || error "touch $file4 failed"
9014 local file4_pool=$($LFS getstripe -p $file4)
9015 [[ "$file4_pool" = "$pool" ]] ||
9016 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
9018 # new subdirectory under non-root directory should inherit
9019 # the default layout from its parent directory
9020 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
9021 error "set directory layout on $dir4 failed"
9023 local dir5=$dir4/$tdir-5
9024 mkdir $dir5 || error "mkdir $dir5 failed"
9026 dir4_layout=$(get_layout_param $dir4)
9027 local dir5_layout=$(get_layout_param $dir5)
9028 [[ "$dir4_layout" = "$dir5_layout" ]] ||
9030 echo "dir4_layout: '$dir4_layout'"
9031 echo "dir5_layout: '$dir5_layout'"
9032 error "$dir5 should inherit the default layout from $dir4"
9035 # though subdir under ROOT doesn't inherit default layout, but
9036 # its sub dir/file should be created with default layout.
9037 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
9038 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
9039 skip "Need MDS version at least 2.12.59"
9041 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
9042 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
9043 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
9045 if [ $default_lmv_hash == "none" ]; then
9046 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
9048 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
9049 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
9052 $LFS setdirstripe -D -c 2 $MOUNT ||
9053 error "setdirstripe -D -c 2 failed"
9054 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
9055 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
9056 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
9058 run_test 65n "don't inherit default layout from root for new subdirectories"
9060 # bug 2543 - update blocks count on client
9062 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9065 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
9066 sync; sync_all_data; sync; sync_all_data
9067 cancel_lru_locks osc
9068 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
9069 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
9071 run_test 66 "update inode blocks count on client ==============="
9074 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
9078 swapon -s | awk '($1 == "'$1'") { print $4 }'
9081 # bug5265, obdfilter oa2dentry return -ENOENT
9082 # #define OBD_FAIL_SRV_ENOENT 0x217
9084 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9085 remote_ost_nodsh && skip "remote OST with nodsh"
9088 $LFS setstripe -c 1 -i 0 $f
9090 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
9092 do_facet ost1 lctl set_param fail_loc=0x217
9093 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
9094 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
9096 do_facet ost1 lctl set_param fail_loc=0
9097 $DIRECTIO write $f 0 2 || error "write error"
9099 cancel_lru_locks osc
9100 $DIRECTIO read $f 0 1 || error "read error"
9102 do_facet ost1 lctl set_param fail_loc=0x217
9103 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
9105 do_facet ost1 lctl set_param fail_loc=0
9108 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
9111 test_mkdir $DIR/$tdir
9112 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
9113 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
9115 run_test 71 "Running dbench on lustre (don't segment fault) ===="
9117 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
9118 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9119 [ "$RUNAS_ID" = "$UID" ] &&
9120 skip_env "RUNAS_ID = UID = $UID -- skipping"
9121 # Check that testing environment is properly set up. Skip if not
9122 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
9123 skip_env "User $RUNAS_ID does not exist - skipping"
9126 chmod 777 $DIR/$tfile
9127 chmod ug+s $DIR/$tfile
9128 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
9129 error "$RUNAS dd $DIR/$tfile failed"
9130 # See if we are still setuid/sgid
9131 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9132 error "S/gid is not dropped on write"
9133 # Now test that MDS is updated too
9134 cancel_lru_locks mdc
9135 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9136 error "S/gid is not dropped on MDS"
9139 run_test 72a "Test that remove suid works properly (bug5695) ===="
9141 test_72b() { # bug 24226 -- keep mode setting when size is not changing
9144 [ "$RUNAS_ID" = "$UID" ] &&
9145 skip_env "RUNAS_ID = UID = $UID -- skipping"
9146 [ "$RUNAS_ID" -eq 0 ] &&
9147 skip_env "RUNAS_ID = 0 -- skipping"
9148 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9149 # Check that testing environment is properly set up. Skip if not
9150 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
9151 skip_env "User $RUNAS_ID does not exist - skipping"
9153 touch $DIR/${tfile}-f{g,u}
9154 test_mkdir $DIR/${tfile}-dg
9155 test_mkdir $DIR/${tfile}-du
9156 chmod 770 $DIR/${tfile}-{f,d}{g,u}
9157 chmod g+s $DIR/${tfile}-{f,d}g
9158 chmod u+s $DIR/${tfile}-{f,d}u
9159 for perm in 777 2777 4777; do
9160 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
9161 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
9162 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
9163 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
9167 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
9169 # bug 3462 - multiple simultaneous MDC requests
9171 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9173 test_mkdir $DIR/d73-1
9174 test_mkdir $DIR/d73-2
9175 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
9178 lctl set_param fail_loc=0x80000129
9179 $MULTIOP $DIR/d73-1/f73-2 Oc &
9181 lctl set_param fail_loc=0
9183 $MULTIOP $DIR/d73-2/f73-3 Oc &
9187 wait $pid1 || return 1
9191 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
9192 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
9193 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
9197 run_test 73 "multiple MDC requests (should not deadlock)"
9199 test_74a() { # bug 6149, 6184
9200 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9203 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9205 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9206 # will spin in a tight reconnection loop
9207 $LCTL set_param fail_loc=0x8000030e
9208 # get any lock that won't be difficult - lookup works.
9210 $LCTL set_param fail_loc=0
9214 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
9216 test_74b() { # bug 13310
9217 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9219 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9221 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9222 # will spin in a tight reconnection loop
9223 $LCTL set_param fail_loc=0x8000030e
9224 # get a "difficult" lock
9226 $LCTL set_param fail_loc=0
9230 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
9233 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9235 #define OBD_FAIL_LDLM_NEW_LOCK
9236 $LCTL set_param fail_loc=0x319
9237 touch $DIR/$tfile && error "touch successful"
9238 $LCTL set_param fail_loc=0
9241 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
9243 slab_lic=/sys/kernel/slab/lustre_inode_cache
9245 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
9246 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
9247 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
9250 test_76a() { # Now for b=20433, added originally in b=1443
9251 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9253 cancel_lru_locks osc
9254 # there may be some slab objects cached per core
9255 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
9256 local before=$(num_objects)
9257 local count=$((512 * cpus))
9258 [ "$SLOW" = "no" ] && count=$((128 * cpus))
9259 local margin=$((count / 10))
9260 if [[ -f $slab_lic/aliases ]]; then
9261 local aliases=$(cat $slab_lic/aliases)
9262 (( aliases > 0 )) && margin=$((margin * aliases))
9265 echo "before slab objects: $before"
9266 for i in $(seq $count); do
9270 cancel_lru_locks osc
9271 local after=$(num_objects)
9272 echo "created: $count, after slab objects: $after"
9273 # shared slab counts are not very accurate, allow significant margin
9274 # the main goal is that the cache growth is not permanently > $count
9275 while (( after > before + margin )); do
9277 after=$(num_objects)
9279 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9280 if (( wait > 60 )); then
9281 error "inode slab grew from $before+$margin to $after"
9285 run_test 76a "confirm clients recycle inodes properly ===="
9288 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9289 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
9292 local before=$(num_objects)
9294 for i in $(seq $count); do
9299 local after=$(num_objects)
9302 while (( after > before )); do
9304 after=$(num_objects)
9306 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9307 if (( wait > 60 )); then
9308 error "inode slab grew from $before to $after"
9312 echo "slab objects before: $before, after: $after"
9314 run_test 76b "confirm clients recycle directory inodes properly ===="
9319 # Note: in sptlrpc modes which enable its own bulk checksum, the
9320 # original crc32_le bulk checksum will be automatically disabled,
9321 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
9322 # will be checked by sptlrpc code against sptlrpc bulk checksum.
9323 # In this case set_checksums() will not be no-op, because sptlrpc
9324 # bulk checksum will be enabled all through the test.
9326 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
9327 lctl set_param -n osc.*.checksums $1
9331 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9332 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
9333 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9334 tr -d [] | head -n1)}
9337 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
9339 log "set checksum type to $1, rc = $rc"
9343 get_osc_checksum_type()
9345 # arugment 1: OST name, like OST0000
9347 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
9348 sed 's/.*\[\(.*\)\].*/\1/g')
9350 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
9354 F77_TMP=$TMP/f77-temp
9357 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
9358 error "error writing to $F77_TMP"
9361 test_77a() { # bug 10889
9362 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9363 $GSS && skip_env "could not run with gss"
9365 [ ! -f $F77_TMP ] && setup_f77
9367 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
9371 run_test 77a "normal checksum read/write operation"
9373 test_77b() { # bug 10889
9374 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9375 $GSS && skip_env "could not run with gss"
9377 [ ! -f $F77_TMP ] && setup_f77
9378 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9379 $LCTL set_param fail_loc=0x80000409
9382 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9383 error "dd error: $?"
9384 $LCTL set_param fail_loc=0
9386 for algo in $CKSUM_TYPES; do
9387 cancel_lru_locks osc
9388 set_checksum_type $algo
9389 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9390 $LCTL set_param fail_loc=0x80000408
9391 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
9392 $LCTL set_param fail_loc=0
9395 set_checksum_type $ORIG_CSUM_TYPE
9398 run_test 77b "checksum error on client write, read"
9403 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
9405 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
9406 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
9407 $check_ost && [ -n "$ost_file_prefix" ] &&
9408 do_facet ost1 rm -f ${ost_file_prefix}\*
9412 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9413 $GSS && skip_env "could not run with gss"
9414 remote_ost_nodsh && skip "remote OST with nodsh"
9417 local osc_file_prefix
9419 local check_ost=false
9420 local ost_file_prefix
9426 # ensure corruption will occur on first OSS/OST
9427 $LFS setstripe -i 0 $DIR/$tfile
9429 [ ! -f $F77_TMP ] && setup_f77
9430 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9431 error "dd write error: $?"
9432 fid=$($LFS path2fid $DIR/$tfile)
9434 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
9437 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
9438 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
9440 echo "OSS do not support bulk pages dump upon error"
9443 osc_file_prefix=$($LCTL get_param -n debug_path)
9444 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
9446 trap cleanup_77c EXIT
9449 # enable bulk pages dump upon error on Client
9450 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
9451 # enable bulk pages dump upon error on OSS
9453 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
9455 # flush Client cache to allow next read to reach OSS
9456 cancel_lru_locks osc
9458 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9459 $LCTL set_param fail_loc=0x80000408
9460 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
9461 $LCTL set_param fail_loc=0
9465 # check cksum dump on Client
9466 osc_file=$(ls ${osc_file_prefix}*)
9467 [ -n "$osc_file" ] || error "no checksum dump file on Client"
9468 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
9469 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
9470 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
9471 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
9473 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
9474 [[ "$orig_cksum" == "$dump_cksum" ]] ||
9475 error "dump content does not match on Client"
9477 $check_ost || skip "No need to check cksum dump on OSS"
9479 # check cksum dump on OSS
9480 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
9481 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
9482 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
9483 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
9484 [[ "$orig_cksum" == "$dump_cksum" ]] ||
9485 error "dump content does not match on OSS"
9489 run_test 77c "checksum error on client read with debug"
9491 test_77d() { # bug 10889
9492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9493 $GSS && skip_env "could not run with gss"
9495 stack_trap "rm -f $DIR/$tfile"
9496 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9497 $LCTL set_param fail_loc=0x80000409
9499 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
9500 error "direct write: rc=$?"
9501 $LCTL set_param fail_loc=0
9504 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9505 $LCTL set_param fail_loc=0x80000408
9507 cancel_lru_locks osc
9508 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
9509 error "direct read: rc=$?"
9510 $LCTL set_param fail_loc=0
9513 run_test 77d "checksum error on OST direct write, read"
9515 test_77f() { # bug 10889
9516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9517 $GSS && skip_env "could not run with gss"
9520 stack_trap "rm -f $DIR/$tfile"
9521 for algo in $CKSUM_TYPES; do
9522 cancel_lru_locks osc
9523 set_checksum_type $algo
9524 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9525 $LCTL set_param fail_loc=0x409
9526 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
9527 error "direct write succeeded"
9528 $LCTL set_param fail_loc=0
9530 set_checksum_type $ORIG_CSUM_TYPE
9533 run_test 77f "repeat checksum error on write (expect error)"
9535 test_77g() { # bug 10889
9536 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9537 $GSS && skip_env "could not run with gss"
9538 remote_ost_nodsh && skip "remote OST with nodsh"
9540 [ ! -f $F77_TMP ] && setup_f77
9542 local file=$DIR/$tfile
9543 stack_trap "rm -f $file" EXIT
9545 $LFS setstripe -c 1 -i 0 $file
9546 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
9547 do_facet ost1 lctl set_param fail_loc=0x8000021a
9549 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
9550 error "write error: rc=$?"
9551 do_facet ost1 lctl set_param fail_loc=0
9554 cancel_lru_locks osc
9555 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
9556 do_facet ost1 lctl set_param fail_loc=0x8000021b
9558 cmp $F77_TMP $file || error "file compare failed"
9559 do_facet ost1 lctl set_param fail_loc=0
9562 run_test 77g "checksum error on OST write, read"
9564 test_77k() { # LU-10906
9565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9566 $GSS && skip_env "could not run with gss"
9568 local cksum_param="osc.$FSNAME*.checksums"
9569 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
9573 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
9574 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
9575 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
9578 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
9579 error "failed to set checksum=$i on MGS"
9580 wait_update $HOSTNAME "$get_checksum" $i
9582 echo "remount client, checksum should be $i"
9583 remount_client $MOUNT || error "failed to remount client"
9584 checksum=$(eval $get_checksum)
9585 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
9587 # remove persistent param to avoid races with checksum mountopt below
9588 do_facet mgs $LCTL set_param -P -d $cksum_param ||
9589 error "failed to delete checksum on MGS"
9591 for opt in "checksum" "nochecksum"; do
9592 #remount with mount option
9593 echo "remount client with option $opt, checksum should be $i"
9594 umount_client $MOUNT || error "failed to umount client"
9595 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
9596 error "failed to mount client with option '$opt'"
9597 checksum=$(eval $get_checksum)
9598 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
9602 remount_client $MOUNT || error "failed to remount client"
9604 run_test 77k "enable/disable checksum correctly"
9607 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9608 $GSS && skip_env "could not run with gss"
9611 stack_trap "set_checksums $ORIG_CSUM" EXIT
9612 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
9614 set_checksum_type invalid && error "unexpected success of invalid checksum type"
9616 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9617 for algo in $CKSUM_TYPES; do
9618 set_checksum_type $algo || error "fail to set checksum type $algo"
9619 osc_algo=$(get_osc_checksum_type OST0000)
9620 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
9622 # no locks, no reqs to let the connection idle
9623 cancel_lru_locks osc
9624 lru_resize_disable osc
9625 wait_osc_import_state client ost1 IDLE
9627 # ensure ost1 is connected
9628 stat $DIR/$tfile >/dev/null || error "can't stat"
9629 wait_osc_import_state client ost1 FULL
9631 osc_algo=$(get_osc_checksum_type OST0000)
9632 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
9636 run_test 77l "preferred checksum type is remembered after reconnected"
9638 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
9643 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
9644 skip "Need at least version 2.14.52"
9645 local param=checksum_speed
9647 $LCTL get_param $param || error "reading $param failed"
9649 csum_speeds=$($LCTL get_param -n $param)
9651 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
9652 error "known checksum types are missing"
9654 run_test 77m "Verify checksum_speed is correctly read"
9656 check_filefrag_77n() {
9661 while read extidx a b start end rest; do
9662 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
9663 nr_ext=$(( $nr_ext + 1 ))
9664 starts+=( ${start%..} )
9667 done < <( filefrag -sv $1 )
9669 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
9674 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
9677 $TRUNCATE $DIR/$tfile 0
9678 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
9679 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
9680 check_filefrag_77n $DIR/$tfile ||
9681 skip "$tfile blocks not contiguous around hole"
9684 stack_trap "set_checksums $ORIG_CSUM" EXIT
9685 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
9686 stack_trap "rm -f $DIR/$tfile"
9688 for algo in $CKSUM_TYPES; do
9689 if [[ "$algo" =~ ^t10 ]]; then
9690 set_checksum_type $algo ||
9691 error "fail to set checksum type $algo"
9692 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
9693 error "fail to read $tfile with $algo"
9699 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
9706 test_78() { # bug 10901
9707 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9708 remote_ost || skip_env "local OST"
9711 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
9712 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
9713 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
9714 echo "MemTotal: $MEMTOTAL"
9716 # reserve 256MB of memory for the kernel and other running processes,
9717 # and then take 1/2 of the remaining memory for the read/write buffers.
9718 if [ $MEMTOTAL -gt 512 ] ;then
9719 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
9721 # for those poor memory-starved high-end clusters...
9722 MEMTOTAL=$((MEMTOTAL / 2))
9724 echo "Mem to use for directio: $MEMTOTAL"
9726 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
9727 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
9728 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
9729 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
9731 echo "Smallest OST: $SMALLESTOST"
9732 [[ $SMALLESTOST -lt 10240 ]] &&
9733 skip "too small OSTSIZE, useless to run large O_DIRECT test"
9735 trap cleanup_test_78 EXIT
9737 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
9738 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
9740 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
9741 echo "File size: $F78SIZE"
9742 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
9743 for i in $(seq 1 $NSEQ); do
9744 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
9745 echo directIO rdwr round $i of $NSEQ
9746 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
9751 run_test 78 "handle large O_DIRECT writes correctly ============"
9753 test_79() { # bug 12743
9754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9756 wait_delete_completed
9758 BKTOTAL=$(calc_osc_kbytes kbytestotal)
9759 BKFREE=$(calc_osc_kbytes kbytesfree)
9760 BKAVAIL=$(calc_osc_kbytes kbytesavail)
9762 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
9763 DFTOTAL=`echo $STRING | cut -d, -f1`
9764 DFUSED=`echo $STRING | cut -d, -f2`
9765 DFAVAIL=`echo $STRING | cut -d, -f3`
9766 DFFREE=$(($DFTOTAL - $DFUSED))
9768 ALLOWANCE=$((64 * $OSTCOUNT))
9770 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
9771 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
9772 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
9774 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
9775 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
9776 error "df free($DFFREE) mismatch OST free($BKFREE)"
9778 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
9779 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
9780 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
9783 run_test 79 "df report consistency check ======================="
9785 test_80() { # bug 10718
9786 remote_ost_nodsh && skip "remote OST with nodsh"
9787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9789 # relax strong synchronous semantics for slow backends like ZFS
9790 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
9791 local soc="obdfilter.*.sync_lock_cancel"
9792 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
9794 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
9795 if [ -z "$save" ]; then
9796 soc="obdfilter.*.sync_on_lock_cancel"
9797 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
9800 if [ "$save" != "never" ]; then
9801 local hosts=$(comma_list $(osts_nodes))
9803 do_nodes $hosts $LCTL set_param $soc=never
9804 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
9808 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
9810 local before=$(date +%s)
9811 cancel_lru_locks osc
9812 local after=$(date +%s)
9813 local diff=$((after - before))
9814 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
9818 run_test 80 "Page eviction is equally fast at high offsets too"
9820 test_81a() { # LU-456
9821 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9822 remote_ost_nodsh && skip "remote OST with nodsh"
9824 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
9825 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
9826 do_facet ost1 lctl set_param fail_loc=0x80000228
9828 # write should trigger a retry and success
9829 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9830 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9832 if [ $RC -ne 0 ] ; then
9833 error "write should success, but failed for $RC"
9836 run_test 81a "OST should retry write when get -ENOSPC ==============="
9838 test_81b() { # LU-456
9839 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9840 remote_ost_nodsh && skip "remote OST with nodsh"
9842 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
9843 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
9844 do_facet ost1 lctl set_param fail_loc=0x228
9846 # write should retry several times and return -ENOSPC finally
9847 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9848 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9851 if [ $RC -ne $ENOSPC ] ; then
9852 error "dd should fail for -ENOSPC, but succeed."
9855 run_test 81b "OST should return -ENOSPC when retry still fails ======="
9858 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
9860 test_mkdir $DIR/$tdir.cvsroot
9861 chown $RUNAS_ID $DIR/$tdir.cvsroot
9864 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
9867 # some versions of cvs import exit(1) when asked to import links or
9868 # files they can't read. ignore those files.
9869 local toignore=$(find . -type l -printf '-I %f\n' -o \
9870 ! -perm /4 -printf '-I %f\n')
9871 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
9872 $tdir.reposname vtag rtag
9875 test_mkdir $DIR/$tdir.reposname
9876 chown $RUNAS_ID $DIR/$tdir.reposname
9877 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
9879 cd $DIR/$tdir.reposname
9881 $RUNAS cvs add -m 'addmsg' foo99
9883 $RUNAS cvs commit -m 'nomsg' foo99
9884 rm -fr $DIR/$tdir.cvsroot
9886 run_test 99 "cvs strange file/directory operations"
9889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9890 [[ "$NETTYPE" =~ tcp ]] ||
9891 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
9892 remote_ost_nodsh && skip "remote OST with nodsh"
9893 remote_mds_nodsh && skip "remote MDS with nodsh"
9895 skip "useless for local single node setup"
9897 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
9898 [ "$PROT" != "tcp" ] && continue
9899 RPORT=$(echo $REMOTE | cut -d: -f2)
9900 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
9903 LPORT=`echo $LOCAL | cut -d: -f2`
9904 if [ $LPORT -ge 1024 ]; then
9905 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
9907 error_exit "local: $LPORT > 1024, remote: $RPORT"
9910 [ "$rc" = 0 ] || error_exit "privileged port not found" )
9912 run_test 100 "check local port using privileged port ==========="
9914 function get_named_value()
9918 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
9921 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
9922 awk '/^max_cached_mb/ { print $2 }')
9925 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
9930 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9935 local cache_limit=32
9937 $LCTL set_param -n osc.*-osc*.rpc_stats=0
9938 trap cleanup_101a EXIT
9939 $LCTL set_param -n llite.*.read_ahead_stats=0
9940 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
9943 # randomly read 10000 of 64K chunks from file 3x 32MB in size
9945 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
9946 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
9949 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
9950 get_named_value 'read.but.discarded'); do
9951 discard=$(($discard + $s))
9955 $LCTL get_param osc.*-osc*.rpc_stats
9956 $LCTL get_param llite.*.read_ahead_stats
9958 # Discard is generally zero, but sometimes a few random reads line up
9959 # and trigger larger readahead, which is wasted & leads to discards.
9960 if [[ $(($discard)) -gt $nreads ]]; then
9961 error "too many ($discard) discarded pages"
9963 rm -f $DIR/$tfile || true
9965 run_test 101a "check read-ahead for random reads"
9968 test_mkdir $DIR/$tdir
9970 local FILE_LENGTH=$2
9973 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
9975 local list=$(comma_list $(osts_nodes))
9976 set_osd_param $list '' read_cache_enable 0
9977 set_osd_param $list '' writethrough_cache_enable 0
9979 trap cleanup_test101bc EXIT
9980 # prepare the read-ahead file
9981 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
9983 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
9984 count=$FILE_SIZE_MB 2> /dev/null
9988 cleanup_test101bc() {
9993 local list=$(comma_list $(osts_nodes))
9994 set_osd_param $list '' read_cache_enable 1
9995 set_osd_param $list '' writethrough_cache_enable 1
9999 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
10004 local STRIPE_SIZE=$2
10005 local FILE_LENGTH=$3
10006 local RA_INC=1048576
10007 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
10008 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
10009 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
10010 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
10011 get_named_value 'read.but.discarded' | calc_total)
10012 if [[ $DISCARD -gt $discard_limit ]]; then
10013 $LCTL get_param llite.*.read_ahead_stats
10014 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
10016 echo "Read-ahead success for size ${READ_SIZE}"
10021 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10022 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10024 local STRIPE_SIZE=1048576
10025 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
10027 if [ $SLOW == "yes" ]; then
10028 local FILE_LENGTH=$((STRIDE_SIZE * 64))
10030 local FILE_LENGTH=$((STRIDE_SIZE * 8))
10033 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
10035 # prepare the read-ahead file
10036 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10037 cancel_lru_locks osc
10038 for BIDX in 2 4 8 16 32 64 128 256
10040 local BSIZE=$((BIDX*4096))
10041 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
10042 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
10043 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
10044 $LCTL set_param -n llite.*.read_ahead_stats=0
10045 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
10046 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
10047 cancel_lru_locks osc
10048 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
10053 run_test 101b "check stride-io mode read-ahead ================="
10056 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10058 local STRIPE_SIZE=1048576
10059 local FILE_LENGTH=$((STRIPE_SIZE*100))
10062 local osc_rpc_stats
10064 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10066 cancel_lru_locks osc
10067 $LCTL set_param osc.*.rpc_stats=0
10068 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
10069 $LCTL get_param osc.*.rpc_stats
10070 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
10071 local stats=$($LCTL get_param -n $osc_rpc_stats)
10072 local lines=$(echo "$stats" | awk 'END {print NR;}')
10075 if [ $lines -le 20 ]; then
10076 echo "continue debug"
10079 for size in 1 2 4 8; do
10080 local rpc=$(echo "$stats" |
10081 awk '($1 == "'$size':") {print $2; exit; }')
10082 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
10083 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
10085 echo "$osc_rpc_stats check passed!"
10090 run_test 101c "check stripe_size aligned read-ahead"
10093 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10095 local file=$DIR/$tfile
10096 local sz_MB=${FILESIZE_101d:-80}
10097 local ra_MB=${READAHEAD_MB:-40}
10099 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
10100 [ $free_MB -lt $sz_MB ] &&
10101 skip "Need free space ${sz_MB}M, have ${free_MB}M"
10103 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
10104 $LFS setstripe -c -1 $file || error "setstripe failed"
10106 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
10107 echo Cancel LRU locks on lustre client to flush the client cache
10108 cancel_lru_locks osc
10110 echo Disable read-ahead
10111 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10112 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10113 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
10114 $LCTL get_param -n llite.*.max_read_ahead_mb
10116 echo "Reading the test file $file with read-ahead disabled"
10117 local sz_KB=$((sz_MB * 1024 / 4))
10118 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
10119 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
10120 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10121 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10123 echo "Cancel LRU locks on lustre client to flush the client cache"
10124 cancel_lru_locks osc
10125 echo Enable read-ahead with ${ra_MB}MB
10126 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
10128 echo "Reading the test file $file with read-ahead enabled"
10129 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10130 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10132 echo "read-ahead disabled time read $raOFF"
10133 echo "read-ahead enabled time read $raON"
10136 wait_delete_completed
10138 # use awk for this check instead of bash because it handles decimals
10139 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
10140 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
10142 run_test 101d "file read with and without read-ahead enabled"
10145 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10147 local file=$DIR/$tfile
10148 local size_KB=500 #KB
10152 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
10153 local need_KB=$((count * size_KB))
10154 [[ $free_KB -le $need_KB ]] &&
10155 skip_env "Need free space $need_KB, have $free_KB"
10157 echo "Creating $count ${size_KB}K test files"
10158 for ((i = 0; i < $count; i++)); do
10159 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
10162 echo "Cancel LRU locks on lustre client to flush the client cache"
10163 cancel_lru_locks $OSC
10165 echo "Reset readahead stats"
10166 $LCTL set_param -n llite.*.read_ahead_stats=0
10168 for ((i = 0; i < $count; i++)); do
10169 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
10172 $LCTL get_param llite.*.max_cached_mb
10173 $LCTL get_param llite.*.read_ahead_stats
10174 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10175 get_named_value 'misses' | calc_total)
10177 for ((i = 0; i < $count; i++)); do
10178 rm -rf $file.$i 2>/dev/null
10181 #10000 means 20% reads are missing in readahead
10182 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
10184 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
10187 which iozone || skip_env "no iozone installed"
10189 local old_debug=$($LCTL get_param debug)
10190 old_debug=${old_debug#*=}
10191 $LCTL set_param debug="reada mmap"
10193 # create a test file
10194 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
10196 echo Cancel LRU locks on lustre client to flush the client cache
10197 cancel_lru_locks osc
10199 echo Reset readahead stats
10200 $LCTL set_param -n llite.*.read_ahead_stats=0
10202 echo mmap read the file with small block size
10203 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
10206 echo checking missing pages
10207 $LCTL get_param llite.*.read_ahead_stats
10208 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10209 get_named_value 'misses' | calc_total)
10211 $LCTL set_param debug="$old_debug"
10212 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
10215 run_test 101f "check mmap read performance"
10217 test_101g_brw_size_test() {
10219 local pages=$((mb * 1048576 / PAGE_SIZE))
10220 local file=$DIR/$tfile
10222 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
10223 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
10224 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
10225 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
10229 stack_trap "rm -f $file" EXIT
10230 $LCTL set_param -n osc.*.rpc_stats=0
10232 # 10 RPCs should be enough for the test
10234 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
10235 { error "dd write ${mb} MB blocks failed"; return 3; }
10236 cancel_lru_locks osc
10237 dd of=/dev/null if=$file bs=${mb}M count=$count ||
10238 { error "dd write ${mb} MB blocks failed"; return 4; }
10240 # calculate number of full-sized read and write RPCs
10241 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
10242 sed -n '/pages per rpc/,/^$/p' |
10243 awk '/'$pages':/ { reads += $2; writes += $6 }; \
10244 END { print reads,writes }'))
10245 # allow one extra full-sized read RPC for async readahead
10246 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
10247 { error "${rpcs[0]} != $count read RPCs"; return 5; }
10248 [[ ${rpcs[1]} == $count ]] ||
10249 { error "${rpcs[1]} != $count write RPCs"; return 6; }
10253 remote_ost_nodsh && skip "remote OST with nodsh"
10256 local osts=$(get_facets OST)
10257 local list=$(comma_list $(osts_nodes))
10258 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10259 local brw_size="obdfilter.*.brw_size"
10261 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10263 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
10265 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
10266 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
10267 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
10268 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
10269 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
10270 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
10272 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
10275 if [[ $orig_mb -lt 16 ]]; then
10276 save_lustre_params $osts "$brw_size" > $p
10277 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
10278 error "set 16MB RPC size failed"
10280 echo "remount client to enable new RPC size"
10281 remount_client $MOUNT || error "remount_client failed"
10284 test_101g_brw_size_test 16 || error "16MB RPC test failed"
10285 # should be able to set brw_size=12, but no rpc_stats for that
10286 test_101g_brw_size_test 8 || error "8MB RPC test failed"
10289 test_101g_brw_size_test 4 || error "4MB RPC test failed"
10291 if [[ $orig_mb -lt 16 ]]; then
10292 restore_lustre_params < $p
10293 remount_client $MOUNT || error "remount_client restore failed"
10296 rm -f $p $DIR/$tfile
10298 run_test 101g "Big bulk(4/16 MiB) readahead"
10301 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10303 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
10304 error "dd 70M file failed"
10305 echo Cancel LRU locks on lustre client to flush the client cache
10306 cancel_lru_locks osc
10308 echo "Reset readahead stats"
10309 $LCTL set_param -n llite.*.read_ahead_stats 0
10311 echo "Read 10M of data but cross 64M bundary"
10312 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
10313 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10314 get_named_value 'misses' | calc_total)
10315 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
10316 rm -f $p $DIR/$tfile
10318 run_test 101h "Readahead should cover current read window"
10321 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
10322 error "dd 10M file failed"
10324 local max_per_file_mb=$($LCTL get_param -n \
10325 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
10326 cancel_lru_locks osc
10327 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
10328 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
10329 error "set max_read_ahead_per_file_mb to 1 failed"
10331 echo "Reset readahead stats"
10332 $LCTL set_param llite.*.read_ahead_stats=0
10334 dd if=$DIR/$tfile of=/dev/null bs=2M
10336 $LCTL get_param llite.*.read_ahead_stats
10337 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10338 awk '/misses/ { print $2 }')
10339 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
10342 run_test 101i "allow current readahead to exceed reservation"
10345 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
10346 error "setstripe $DIR/$tfile failed"
10347 local file_size=$((1048576 * 16))
10348 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10349 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
10351 echo Disable read-ahead
10352 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10354 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
10355 for blk in $PAGE_SIZE 1048576 $file_size; do
10356 cancel_lru_locks osc
10357 echo "Reset readahead stats"
10358 $LCTL set_param -n llite.*.read_ahead_stats=0
10359 local count=$(($file_size / $blk))
10360 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
10361 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10362 get_named_value 'failed.to.fast.read' | calc_total)
10363 $LCTL get_param -n llite.*.read_ahead_stats
10364 [ $miss -eq $count ] || error "expected $count got $miss"
10367 rm -f $p $DIR/$tfile
10369 run_test 101j "A complete read block should be submitted when no RA"
10372 test_mkdir $DIR/$tdir
10373 chown $RUNAS_ID $DIR/$tdir
10376 STRIPE_COUNT=$OSTCOUNT
10377 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
10379 trap cleanup_test102 EXIT
10381 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
10383 for num in 1 2 3 4; do
10384 for count in $(seq 1 $STRIPE_COUNT); do
10385 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
10386 local size=`expr $STRIPE_SIZE \* $num`
10387 local file=file"$num-$idx-$count"
10388 $1 $LFS setstripe -S $size -i $idx -c $count $file
10394 $1 tar cf $TMP/f102.tar $tdir --xattrs
10397 cleanup_test102() {
10399 rm -f $TMP/f102.tar
10400 rm -rf $DIR/d0.sanity/d102
10404 [ "$UID" != 0 ] && skip "must run as root"
10405 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
10406 skip_env "must have user_xattr"
10408 [ -z "$(which setfattr 2>/dev/null)" ] &&
10409 skip_env "could not find setfattr"
10411 local testfile=$DIR/$tfile
10414 echo "set/get xattr..."
10415 setfattr -n trusted.name1 -v value1 $testfile ||
10416 error "setfattr -n trusted.name1=value1 $testfile failed"
10417 getfattr -n trusted.name1 $testfile 2> /dev/null |
10418 grep "trusted.name1=.value1" ||
10419 error "$testfile missing trusted.name1=value1"
10421 setfattr -n user.author1 -v author1 $testfile ||
10422 error "setfattr -n user.author1=author1 $testfile failed"
10423 getfattr -n user.author1 $testfile 2> /dev/null |
10424 grep "user.author1=.author1" ||
10425 error "$testfile missing trusted.author1=author1"
10427 echo "listxattr..."
10428 setfattr -n trusted.name2 -v value2 $testfile ||
10429 error "$testfile unable to set trusted.name2"
10430 setfattr -n trusted.name3 -v value3 $testfile ||
10431 error "$testfile unable to set trusted.name3"
10432 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
10433 grep "trusted.name" | wc -l) -eq 3 ] ||
10434 error "$testfile missing 3 trusted.name xattrs"
10436 setfattr -n user.author2 -v author2 $testfile ||
10437 error "$testfile unable to set user.author2"
10438 setfattr -n user.author3 -v author3 $testfile ||
10439 error "$testfile unable to set user.author3"
10440 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
10441 grep "user.author" | wc -l) -eq 3 ] ||
10442 error "$testfile missing 3 user.author xattrs"
10444 echo "remove xattr..."
10445 setfattr -x trusted.name1 $testfile ||
10446 error "$testfile error deleting trusted.name1"
10447 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
10448 error "$testfile did not delete trusted.name1 xattr"
10450 setfattr -x user.author1 $testfile ||
10451 error "$testfile error deleting user.author1"
10452 echo "set lustre special xattr ..."
10453 $LFS setstripe -c1 $testfile
10454 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
10455 awk -F "=" '/trusted.lov/ { print $2 }' )
10456 setfattr -n "trusted.lov" -v $lovea $testfile ||
10457 error "$testfile doesn't ignore setting trusted.lov again"
10458 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
10459 error "$testfile allow setting invalid trusted.lov"
10462 run_test 102a "user xattr test =================================="
10464 check_102b_layout() {
10466 local testfile=$DIR/$tfile
10468 echo "test layout '$layout'"
10469 $LFS setstripe $layout $testfile || error "setstripe failed"
10470 $LFS getstripe -y $testfile
10472 echo "get/set/list trusted.lov xattr ..." # b=10930
10473 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
10474 [[ "$value" =~ "trusted.lov" ]] ||
10475 error "can't get trusted.lov from $testfile"
10476 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
10477 error "getstripe failed"
10479 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
10481 value=$(cut -d= -f2 <<<$value)
10482 # LU-13168: truncated xattr should fail if short lov_user_md header
10483 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
10484 lens="${#value}" || lens="$(seq 4 2 ${#value})"
10485 for len in $lens; do
10486 echo "setfattr $len $testfile.2"
10487 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
10488 [ $len -lt 66 ] && error "short xattr len=$len worked"
10490 local stripe_size=$($LFS getstripe -S $testfile.2)
10491 local stripe_count=$($LFS getstripe -c $testfile.2)
10492 [[ $stripe_size -eq 65536 ]] ||
10493 error "stripe size $stripe_size != 65536"
10494 [[ $stripe_count -eq $stripe_count_orig ]] ||
10495 error "stripe count $stripe_count != $stripe_count_orig"
10496 rm $testfile $testfile.2
10500 [ -z "$(which setfattr 2>/dev/null)" ] &&
10501 skip_env "could not find setfattr"
10502 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10504 # check plain layout
10505 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
10507 # and also check composite layout
10508 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
10511 run_test 102b "getfattr/setfattr for trusted.lov EAs"
10514 [ -z "$(which setfattr 2>/dev/null)" ] &&
10515 skip_env "could not find setfattr"
10516 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10518 # b10930: get/set/list lustre.lov xattr
10519 echo "get/set/list lustre.lov xattr ..."
10520 test_mkdir $DIR/$tdir
10521 chown $RUNAS_ID $DIR/$tdir
10522 local testfile=$DIR/$tdir/$tfile
10523 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
10524 error "setstripe failed"
10525 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
10526 error "getstripe failed"
10527 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
10528 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
10530 local testfile2=${testfile}2
10531 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
10532 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
10534 $RUNAS $MCREATE $testfile2
10535 $RUNAS setfattr -n lustre.lov -v $value $testfile2
10536 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
10537 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
10538 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
10539 [ $stripe_count -eq $STRIPECOUNT ] ||
10540 error "stripe count $stripe_count != $STRIPECOUNT"
10542 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
10544 compare_stripe_info1() {
10545 local stripe_index_all_zero=true
10547 for num in 1 2 3 4; do
10548 for count in $(seq 1 $STRIPE_COUNT); do
10549 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
10550 local size=$((STRIPE_SIZE * num))
10551 local file=file"$num-$offset-$count"
10552 stripe_size=$($LFS getstripe -S $PWD/$file)
10553 [[ $stripe_size -ne $size ]] &&
10554 error "$file: size $stripe_size != $size"
10555 stripe_count=$($LFS getstripe -c $PWD/$file)
10556 # allow fewer stripes to be created, ORI-601
10557 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
10558 error "$file: count $stripe_count != $count"
10559 stripe_index=$($LFS getstripe -i $PWD/$file)
10560 [[ $stripe_index -ne 0 ]] &&
10561 stripe_index_all_zero=false
10565 $stripe_index_all_zero &&
10566 error "all files are being extracted starting from OST index 0"
10570 have_xattrs_include() {
10571 tar --help | grep -q xattrs-include &&
10572 echo --xattrs-include="lustre.*"
10576 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10577 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10579 XINC=$(have_xattrs_include)
10581 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
10582 cd $DIR/$tdir/$tdir
10583 compare_stripe_info1
10585 run_test 102d "tar restore stripe info from tarfile,not keep osts"
10588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10589 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10591 XINC=$(have_xattrs_include)
10593 test_mkdir $DIR/$tdir.restore
10595 tar cf - --xattrs $tdir | tar xf - \
10596 -C $DIR/$tdir.restore --xattrs $XINC
10597 cd $DIR/$tdir.restore/$tdir
10598 compare_stripe_info1
10600 run_test 102f "tar copy files, not keep osts"
10603 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
10604 skip "must have user_xattr"
10605 [ -z "$(which setfattr 2>/dev/null)" ] &&
10606 skip_env "could not find setfattr"
10607 [ -z "$(which getfattr 2>/dev/null)" ] &&
10608 skip_env "could not find getfattr"
10610 local xsize=${1:-1024} # in bytes
10611 local file=$DIR/$tfile
10612 local value="$(generate_string $xsize)"
10613 local xbig=trusted.big
10617 log "save $xbig on $file"
10618 if [ -z "$toobig" ]
10620 setfattr -n $xbig -v $value $file ||
10621 error "saving $xbig on $file failed"
10623 setfattr -n $xbig -v $value $file &&
10624 error "saving $xbig on $file succeeded"
10628 local orig=$(get_xattr_value $xbig $file)
10629 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
10631 local xsml=trusted.sml
10632 log "save $xsml on $file"
10633 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
10635 local new=$(get_xattr_value $xbig $file)
10636 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
10638 log "grow $xsml on $file"
10639 setfattr -n $xsml -v "$value" $file ||
10640 error "growing $xsml on $file failed"
10642 new=$(get_xattr_value $xbig $file)
10643 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
10644 log "$xbig still valid after growing $xsml"
10649 test_102h() { # bug 15777
10652 run_test 102h "grow xattr from inside inode to external block"
10655 large_xattr_enabled || skip_env "ea_inode feature disabled"
10657 echo "setting xattr of max xattr size: $(max_xattr_size)"
10658 grow_xattr $(max_xattr_size)
10660 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
10661 echo "This should fail:"
10662 grow_xattr $(($(max_xattr_size) + 10)) 1
10664 run_test 102ha "grow xattr from inside inode to external inode"
10666 test_102i() { # bug 17038
10667 [ -z "$(which getfattr 2>/dev/null)" ] &&
10668 skip "could not find getfattr"
10671 ln -s $DIR/$tfile $DIR/${tfile}link
10672 getfattr -n trusted.lov $DIR/$tfile ||
10673 error "lgetxattr on $DIR/$tfile failed"
10674 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
10675 grep -i "no such attr" ||
10676 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
10677 rm -f $DIR/$tfile $DIR/${tfile}link
10679 run_test 102i "lgetxattr test on symbolic link ============"
10682 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10683 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10685 XINC=$(have_xattrs_include)
10686 setup_test102 "$RUNAS"
10687 chown $RUNAS_ID $DIR/$tdir
10688 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
10689 cd $DIR/$tdir/$tdir
10690 compare_stripe_info1 "$RUNAS"
10692 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
10695 [ -z "$(which setfattr 2>/dev/null)" ] &&
10696 skip "could not find setfattr"
10699 # b22187 just check that does not crash for regular file.
10700 setfattr -n trusted.lov $DIR/$tfile
10701 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
10702 local test_kdir=$DIR/$tdir
10703 test_mkdir $test_kdir
10704 local default_size=$($LFS getstripe -S $test_kdir)
10705 local default_count=$($LFS getstripe -c $test_kdir)
10706 local default_offset=$($LFS getstripe -i $test_kdir)
10707 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
10708 error 'dir setstripe failed'
10709 setfattr -n trusted.lov $test_kdir
10710 local stripe_size=$($LFS getstripe -S $test_kdir)
10711 local stripe_count=$($LFS getstripe -c $test_kdir)
10712 local stripe_offset=$($LFS getstripe -i $test_kdir)
10713 [ $stripe_size -eq $default_size ] ||
10714 error "stripe size $stripe_size != $default_size"
10715 [ $stripe_count -eq $default_count ] ||
10716 error "stripe count $stripe_count != $default_count"
10717 [ $stripe_offset -eq $default_offset ] ||
10718 error "stripe offset $stripe_offset != $default_offset"
10719 rm -rf $DIR/$tfile $test_kdir
10721 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
10724 [ -z "$(which getfattr 2>/dev/null)" ] &&
10725 skip "could not find getfattr"
10727 # LU-532 trusted. xattr is invisible to non-root
10728 local testfile=$DIR/$tfile
10732 echo "listxattr as user..."
10733 chown $RUNAS_ID $testfile
10734 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
10735 grep -q "trusted" &&
10736 error "$testfile trusted xattrs are user visible"
10740 run_test 102l "listxattr size test =================================="
10742 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
10743 local path=$DIR/$tfile
10746 listxattr_size_check $path || error "listattr_size_check $path failed"
10748 run_test 102m "Ensure listxattr fails on small bufffer ========"
10752 getxattr() { # getxattr path name
10753 # Return the base64 encoding of the value of xattr name on path.
10757 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
10759 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
10761 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
10763 getfattr --absolute-names --encoding=base64 --name=$name $path |
10764 awk -F= -v name=$name '$1 == name {
10765 print substr($0, index($0, "=") + 1);
10769 test_102n() { # LU-4101 mdt: protect internal xattrs
10770 [ -z "$(which setfattr 2>/dev/null)" ] &&
10771 skip "could not find setfattr"
10772 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
10774 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
10777 local file0=$DIR/$tfile.0
10778 local file1=$DIR/$tfile.1
10779 local xattr0=$TMP/$tfile.0
10780 local xattr1=$TMP/$tfile.1
10781 local namelist="lov lma lmv link fid version som hsm"
10785 rm -rf $file0 $file1 $xattr0 $xattr1
10786 touch $file0 $file1
10788 # Get 'before' xattrs of $file1.
10789 getfattr --absolute-names --dump --match=- $file1 > $xattr0
10791 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
10792 namelist+=" lfsck_namespace"
10793 for name in $namelist; do
10794 # Try to copy xattr from $file0 to $file1.
10795 value=$(getxattr $file0 trusted.$name 2> /dev/null)
10797 setfattr --name=trusted.$name --value="$value" $file1 ||
10798 error "setxattr 'trusted.$name' failed"
10800 # Try to set a garbage xattr.
10801 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
10803 if [[ x$name == "xlov" ]]; then
10804 setfattr --name=trusted.lov --value="$value" $file1 &&
10805 error "setxattr invalid 'trusted.lov' success"
10807 setfattr --name=trusted.$name --value="$value" $file1 ||
10808 error "setxattr invalid 'trusted.$name' failed"
10811 # Try to remove the xattr from $file1. We don't care if this
10812 # appears to succeed or fail, we just don't want there to be
10813 # any changes or crashes.
10814 setfattr --remove=$trusted.$name $file1 2> /dev/null
10817 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
10820 # Try to copy xattr from $file0 to $file1.
10821 value=$(getxattr $file0 trusted.$name 2> /dev/null)
10823 setfattr --name=trusted.$name --value="$value" $file1 ||
10824 error "setxattr 'trusted.$name' failed"
10826 # Try to set a garbage xattr.
10827 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
10829 setfattr --name=trusted.$name --value="$value" $file1 ||
10830 error "setxattr 'trusted.$name' failed"
10832 # Try to remove the xattr from $file1. We don't care if this
10833 # appears to succeed or fail, we just don't want there to be
10834 # any changes or crashes.
10835 setfattr --remove=$trusted.$name $file1 2> /dev/null
10838 # Get 'after' xattrs of file1.
10839 getfattr --absolute-names --dump --match=- $file1 > $xattr1
10841 if ! diff $xattr0 $xattr1; then
10842 error "before and after xattrs of '$file1' differ"
10845 rm -rf $file0 $file1 $xattr0 $xattr1
10849 run_test 102n "silently ignore setxattr on internal trusted xattrs"
10851 test_102p() { # LU-4703 setxattr did not check ownership
10852 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
10853 skip "MDS needs to be at least 2.5.56"
10855 local testfile=$DIR/$tfile
10859 echo "setfacl as user..."
10860 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
10861 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
10863 echo "setfattr as user..."
10864 setfacl -m "u:$RUNAS_ID:---" $testfile
10865 $RUNAS setfattr -x system.posix_acl_access $testfile
10866 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
10868 run_test 102p "check setxattr(2) correctly fails without permission"
10871 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
10872 skip "MDS needs to be at least 2.6.92"
10874 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
10876 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
10879 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
10880 skip "MDS needs to be at least 2.6.93"
10882 touch $DIR/$tfile || error "touch"
10883 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
10884 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
10885 rm $DIR/$tfile || error "rm"
10888 mkdir -p $DIR/$tdir || error "mkdir"
10889 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
10890 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
10891 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
10892 error "$testfile error deleting user.author1"
10893 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
10894 grep "user.$(basename $tdir)" &&
10895 error "$tdir did not delete user.$(basename $tdir)"
10896 rmdir $DIR/$tdir || error "rmdir"
10899 test_mkdir $DIR/$tdir
10900 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
10901 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
10902 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
10903 error "$testfile error deleting user.author1"
10904 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
10905 grep "user.$(basename $tdir)" &&
10906 error "$tdir did not delete user.$(basename $tdir)"
10907 rmdir $DIR/$tdir || error "rm striped dir"
10909 run_test 102r "set EAs with empty values"
10912 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
10913 skip "MDS needs to be at least 2.11.52"
10915 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10917 save_lustre_params client "llite.*.xattr_cache" > $save
10919 for cache in 0 1; do
10920 lctl set_param llite.*.xattr_cache=$cache
10923 touch $DIR/$tfile || error "touch"
10924 for prefix in lustre security system trusted user; do
10925 # Note getxattr() may fail with 'Operation not
10926 # supported' or 'No such attribute' depending
10927 # on prefix and cache.
10928 getfattr -n $prefix.n102s $DIR/$tfile &&
10929 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
10933 restore_lustre_params < $save
10935 run_test 102s "getting nonexistent xattrs should fail"
10938 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
10939 skip "MDS needs to be at least 2.11.52"
10941 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10943 save_lustre_params client "llite.*.xattr_cache" > $save
10945 for cache in 0 1; do
10946 lctl set_param llite.*.xattr_cache=$cache
10948 for buf_size in 0 256; do
10950 touch $DIR/$tfile || error "touch"
10951 setfattr -n user.multiop $DIR/$tfile
10952 $MULTIOP $DIR/$tfile oa$buf_size ||
10953 error "cannot get zero length xattr value (buf_size = $buf_size)"
10957 restore_lustre_params < $save
10959 run_test 102t "zero length xattr values handled correctly"
10963 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
10968 [ "$UID" != 0 ] && skip "must run as root"
10969 $GSS && skip_env "could not run under gss"
10970 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
10971 skip_env "must have acl enabled"
10972 [ -z "$(which setfacl 2>/dev/null)" ] &&
10973 skip_env "could not find setfacl"
10974 remote_mds_nodsh && skip "remote MDS with nodsh"
10976 gpasswd -a daemon bin # LU-5641
10977 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
10979 declare -a identity_old
10981 for num in $(seq $MDSCOUNT); do
10982 switch_identity $num true || identity_old[$num]=$?
10985 SAVE_UMASK=$(umask)
10987 mkdir -p $DIR/$tdir
10990 echo "performing cp ..."
10991 run_acl_subtest cp || error "run_acl_subtest cp failed"
10992 echo "performing getfacl-noacl..."
10993 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
10994 echo "performing misc..."
10995 run_acl_subtest misc || error "misc test failed"
10996 echo "performing permissions..."
10997 run_acl_subtest permissions || error "permissions failed"
10998 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
10999 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
11000 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
11001 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
11003 echo "performing permissions xattr..."
11004 run_acl_subtest permissions_xattr ||
11005 error "permissions_xattr failed"
11007 echo "performing setfacl..."
11008 run_acl_subtest setfacl || error "setfacl test failed"
11010 # inheritance test got from HP
11011 echo "performing inheritance..."
11012 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
11013 chmod +x make-tree || error "chmod +x failed"
11014 run_acl_subtest inheritance || error "inheritance test failed"
11017 echo "LU-974 ignore umask when acl is enabled..."
11018 run_acl_subtest 974 || error "LU-974 umask test failed"
11019 if [ $MDSCOUNT -ge 2 ]; then
11020 run_acl_subtest 974_remote ||
11021 error "LU-974 umask test failed under remote dir"
11024 echo "LU-2561 newly created file is same size as directory..."
11025 if [ "$mds1_FSTYPE" != "zfs" ]; then
11026 run_acl_subtest 2561 || error "LU-2561 test failed"
11028 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
11031 run_acl_subtest 4924 || error "LU-4924 test failed"
11036 for num in $(seq $MDSCOUNT); do
11037 if [ "${identity_old[$num]}" = 1 ]; then
11038 switch_identity $num false || identity_old[$num]=$?
11042 run_test 103a "acl test"
11048 for U in {0..511}; do
11050 local O=$(printf "%04o" $U)
11052 umask $(printf "%04o" $((511 ^ $O)))
11053 $LFS setstripe -c 1 $DIR/$tfile.s$O
11054 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
11056 (( $S == ($O & 0666) )) ||
11057 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
11059 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
11060 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
11061 (( $S == ($O & 0666) )) ||
11062 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
11064 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
11065 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
11066 (( $S == ($O & 0666) )) ||
11067 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
11068 rm -f $DIR/$tfile.[smp]$0
11072 # limit the concurrently running threads to 64. LU-11878
11073 local idx=$((U % 64))
11074 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
11079 run_test 103b "umask lfs setstripe"
11082 mkdir -p $DIR/$tdir
11083 cp -rp $DIR/$tdir $DIR/$tdir.bak
11085 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
11086 error "$DIR/$tdir shouldn't contain default ACL"
11087 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
11088 error "$DIR/$tdir.bak shouldn't contain default ACL"
11091 run_test 103c "'cp -rp' won't set empty acl"
11096 local saved_debug=$($LCTL get_param -n debug)
11098 (( $MDS1_VERSION >= $(version_code 2.14.0) )) ||
11099 skip "MDS needs to be at least 2.14.0"
11101 large_xattr_enabled || skip_env "ea_inode feature disabled"
11103 mkdir -p $DIR/$tdir
11104 # add big LOV EA to cause reply buffer overflow earlier
11105 $LFS setstripe -C 1000 $DIR/$tdir
11106 lctl set_param mdc.*-mdc*.stats=clear
11108 $LCTL set_param debug=0
11109 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
11110 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
11112 # add a large number of default ACLs (expect 8000+ for 2.13+)
11113 for U in {2..7000}; do
11114 setfacl -d -m user:$U:rwx $DIR/$tdir ||
11115 error "Able to add just $U default ACLs"
11117 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
11118 echo "$numacl default ACLs created"
11120 stat $DIR/$tdir || error "Cannot stat directory"
11121 # check file creation
11122 touch $DIR/$tdir/$tfile ||
11123 error "failed to create $tfile with $numacl default ACLs"
11124 stat $DIR/$tdir/$tfile || error "Cannot stat file"
11125 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11126 echo "$fileacl ACLs were inherited"
11127 (( $fileacl == $numacl )) ||
11128 error "Not all default ACLs were inherited: $numacl != $fileacl"
11129 # check that new ACLs creation adds new ACLs to inherited ACLs
11130 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
11131 error "Cannot set new ACL"
11132 numacl=$((numacl + 1))
11133 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11134 (( $fileacl == $numacl )) ||
11135 error "failed to add new ACL: $fileacl != $numacl as expected"
11136 # adds more ACLs to a file to reach their maximum at 8000+
11138 for U in {20000..25000}; do
11139 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
11140 numacl=$((numacl + 1))
11142 echo "Added $numacl more ACLs to the file"
11143 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11144 echo "Total $fileacl ACLs in file"
11145 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
11146 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
11147 rmdir $DIR/$tdir || error "Cannot remove directory"
11149 run_test 103e "inheritance of big amount of default ACLs"
11152 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
11153 skip "MDS needs to be at least 2.14.51"
11155 large_xattr_enabled || skip_env "ea_inode feature disabled"
11157 # enable changelog to consume more internal MDD buffers
11160 mkdir -p $DIR/$tdir
11162 $LFS setstripe -C 1000 $DIR/$tdir
11163 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
11164 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
11165 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
11166 rmdir $DIR/$tdir || error "Cannot remove directory"
11168 run_test 103f "changelog doesn't interfere with default ACLs buffers"
11171 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11174 lfs df || error "lfs df failed"
11175 lfs df -ih || error "lfs df -ih failed"
11176 lfs df -h $DIR || error "lfs df -h $DIR failed"
11177 lfs df -i $DIR || error "lfs df -i $DIR failed"
11178 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
11179 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
11181 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
11182 lctl --device %$OSC deactivate
11183 lfs df || error "lfs df with deactivated OSC failed"
11184 lctl --device %$OSC activate
11185 # wait the osc back to normal
11186 wait_osc_import_ready client ost
11188 lfs df || error "lfs df with reactivated OSC failed"
11191 run_test 104a "lfs df [-ih] [path] test ========================="
11194 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11195 [ $RUNAS_ID -eq $UID ] &&
11196 skip_env "RUNAS_ID = UID = $UID -- skipping"
11198 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
11199 grep "Permission denied" | wc -l)))
11200 if [ $denied_cnt -ne 0 ]; then
11201 error "lfs check servers test failed"
11204 run_test 104b "$RUNAS lfs check servers test ===================="
11207 # Verify $1 is within range of $2.
11208 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
11209 # $1 is <= 2% of $2. Else Fail.
11212 # Strip all units (M, G, T)
11213 actual=$(echo $1 | tr -d A-Z)
11214 expect=$(echo $2 | tr -d A-Z)
11216 expect_lo=$(($expect * 98 / 100)) # 2% below
11217 expect_hi=$(($expect * 102 / 100)) # 2% above
11219 # permit 2% drift above and below
11220 (( $actual >= $expect_lo && $actual <= $expect_hi ))
11224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11225 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
11227 local ost_param="osd-zfs.$FSNAME-OST0000."
11228 local mdt_param="osd-zfs.$FSNAME-MDT0000."
11229 local ofacets=$(get_facets OST)
11230 local mfacets=$(get_facets MDS)
11231 local saved_ost_blocks=
11232 local saved_mdt_blocks=
11234 echo "Before recordsize change"
11235 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
11236 df=($(df -h | grep "/mnt/lustre"$))
11239 echo "lfs output : ${lfs_df[*]}"
11240 echo "df output : ${df[*]}"
11242 for facet in ${ofacets//,/ }; do
11243 if [ -z $saved_ost_blocks ]; then
11244 saved_ost_blocks=$(do_facet $facet \
11245 lctl get_param -n $ost_param.blocksize)
11246 echo "OST Blocksize: $saved_ost_blocks"
11248 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11249 do_facet $facet zfs set recordsize=32768 $ost
11252 # BS too small. Sufficient for functional testing.
11253 for facet in ${mfacets//,/ }; do
11254 if [ -z $saved_mdt_blocks ]; then
11255 saved_mdt_blocks=$(do_facet $facet \
11256 lctl get_param -n $mdt_param.blocksize)
11257 echo "MDT Blocksize: $saved_mdt_blocks"
11259 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11260 do_facet $facet zfs set recordsize=32768 $mdt
11263 # Give new values chance to reflect change
11266 echo "After recordsize change"
11267 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
11268 df_after=($(df -h | grep "/mnt/lustre"$))
11271 echo "lfs output : ${lfs_df_after[*]}"
11272 echo "df output : ${df_after[*]}"
11275 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
11276 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
11277 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
11278 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
11279 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
11280 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
11283 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
11284 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
11285 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
11286 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
11287 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
11288 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
11290 # Restore MDT recordize back to original
11291 for facet in ${mfacets//,/ }; do
11292 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11293 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
11296 # Restore OST recordize back to original
11297 for facet in ${ofacets//,/ }; do
11298 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11299 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
11304 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
11307 # doesn't work on 2.4 kernels
11309 if $(flock_is_enabled); then
11310 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
11312 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
11316 run_test 105a "flock when mounted without -o flock test ========"
11320 if $(flock_is_enabled); then
11321 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
11323 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
11327 run_test 105b "fcntl when mounted without -o flock test ========"
11331 if $(flock_is_enabled); then
11332 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
11334 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
11338 run_test 105c "lockf when mounted without -o flock test"
11340 test_105d() { # bug 15924
11341 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11343 test_mkdir $DIR/$tdir
11344 flock_is_enabled || skip_env "mount w/o flock enabled"
11345 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
11346 $LCTL set_param fail_loc=0x80000315
11347 flocks_test 2 $DIR/$tdir
11349 run_test 105d "flock race (should not freeze) ========"
11351 test_105e() { # bug 22660 && 22040
11352 flock_is_enabled || skip_env "mount w/o flock enabled"
11355 flocks_test 3 $DIR/$tfile
11357 run_test 105e "Two conflicting flocks from same process"
11359 test_106() { #bug 10921
11360 test_mkdir $DIR/$tdir
11361 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
11362 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
11364 run_test 106 "attempt exec of dir followed by chown of that dir"
11367 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11375 local save_pattern=$(sysctl -n kernel.core_pattern)
11376 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
11377 sysctl -w kernel.core_pattern=$file
11378 sysctl -w kernel.core_uses_pid=0
11380 ulimit -c unlimited
11386 kill -s 11 $SLEEPPID
11388 if [ -e $file ]; then
11389 size=`stat -c%s $file`
11390 [ $size -eq 0 ] && error "Fail to create core file $file"
11392 error "Fail to create core file $file"
11395 sysctl -w kernel.core_pattern=$save_pattern
11396 sysctl -w kernel.core_uses_pid=$save_uses_pid
11399 run_test 107 "Coredump on SIG"
11402 test_mkdir $DIR/$tdir
11403 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
11404 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
11405 error "mkdir with 256 char should fail, but did not"
11406 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
11407 error "create with 255 char failed"
11408 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
11409 error "create with 256 char should fail, but did not"
11414 run_test 110 "filename length checking"
11417 # Purpose: To verify dynamic thread (OSS) creation.
11420 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11421 remote_ost_nodsh && skip "remote OST with nodsh"
11423 # Lustre does not stop service threads once they are started.
11424 # Reset number of running threads to default.
11429 local save_params="$TMP/sanity-$TESTNAME.parameters"
11431 # Get ll_ost_io count before I/O
11432 OSTIO_pre=$(do_facet ost1 \
11433 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
11434 # Exit if lustre is not running (ll_ost_io not running).
11435 [ -z "$OSTIO_pre" ] && error "no OSS threads"
11437 echo "Starting with $OSTIO_pre threads"
11438 local thread_max=$((OSTIO_pre * 2))
11439 local rpc_in_flight=$((thread_max * 2))
11440 # Number of I/O Process proposed to be started.
11442 local facets=$(get_facets OST)
11444 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
11445 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
11447 # Set in_flight to $rpc_in_flight
11448 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
11449 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
11450 nfiles=${rpc_in_flight}
11451 # Set ost thread_max to $thread_max
11452 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
11454 # 5 Minutes should be sufficient for max number of OSS
11455 # threads(thread_max) to be created.
11459 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
11460 test_mkdir $DIR/$tdir
11461 for i in $(seq $nfiles); do
11462 local file=$DIR/$tdir/${tfile}-$i
11463 $LFS setstripe -c -1 -i 0 $file
11464 ($WTL $file $timeout)&
11467 # I/O Started - Wait for thread_started to reach thread_max or report
11468 # error if thread_started is more than thread_max.
11469 echo "Waiting for thread_started to reach thread_max"
11470 local thread_started=0
11471 local end_time=$((SECONDS + timeout))
11473 while [ $SECONDS -le $end_time ] ; do
11475 # Get ost i/o thread_started count.
11476 thread_started=$(do_facet ost1 \
11478 ost.OSS.ost_io.threads_started | cut -d= -f2")
11479 # Break out if thread_started is equal/greater than thread_max
11480 if [[ $thread_started -ge $thread_max ]]; then
11481 echo ll_ost_io thread_started $thread_started, \
11482 equal/greater than thread_max $thread_max
11488 # Cleanup - We have the numbers, Kill i/o jobs if running.
11489 jobcount=($(jobs -p))
11490 for i in $(seq 0 $((${#jobcount[@]}-1)))
11492 kill -9 ${jobcount[$i]}
11493 if [ $? -ne 0 ] ; then
11495 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
11499 # Cleanup files left by WTL binary.
11500 for i in $(seq $nfiles); do
11501 local file=$DIR/$tdir/${tfile}-$i
11503 if [ $? -ne 0 ] ; then
11504 echo "Warning: Failed to delete file $file"
11508 restore_lustre_params <$save_params
11509 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
11511 # Error out if no new thread has started or Thread started is greater
11513 if [[ $thread_started -le $OSTIO_pre ||
11514 $thread_started -gt $thread_max ]]; then
11515 error "ll_ost_io: thread_started $thread_started" \
11516 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
11517 "No new thread started or thread started greater " \
11521 run_test 115 "verify dynamic thread creation===================="
11524 wait_delete_completed
11525 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
11526 echo "OST kbytes available: ${AVAIL[@]}"
11531 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
11532 #echo OST $i: ${AVAIL[i]}kb
11533 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
11537 if [[ ${AVAIL[i]} -lt $MINV ]]; then
11542 echo "Min free space: OST $MINI: $MINV"
11543 echo "Max free space: OST $MAXI: $MAXV"
11546 test_116a() { # was previously test_116()
11547 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11548 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11549 remote_mds_nodsh && skip "remote MDS with nodsh"
11551 echo -n "Free space priority "
11552 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
11557 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
11558 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
11559 trap simple_cleanup_common EXIT
11561 # Check if we need to generate uneven OSTs
11562 test_mkdir -p $DIR/$tdir/OST${MINI}
11563 local FILL=$((MINV / 4))
11564 local DIFF=$((MAXV - MINV))
11565 local DIFF2=$((DIFF * 100 / MINV))
11567 local threshold=$(do_facet $SINGLEMDS \
11568 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
11569 threshold=${threshold%%%}
11570 echo -n "Check for uneven OSTs: "
11571 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
11573 if [[ $DIFF2 -gt $threshold ]]; then
11575 echo "Don't need to fill OST$MINI"
11577 # generate uneven OSTs. Write 2% over the QOS threshold value
11579 DIFF=$((threshold - DIFF2 + 2))
11580 DIFF2=$((MINV * DIFF / 100))
11581 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
11582 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
11583 error "setstripe failed"
11584 DIFF=$((DIFF2 / 2048))
11586 while [ $i -lt $DIFF ]; do
11588 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
11589 bs=2M count=1 2>/dev/null
11598 DIFF=$((MAXV - MINV))
11599 DIFF2=$((DIFF * 100 / MINV))
11600 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
11601 if [ $DIFF2 -gt $threshold ]; then
11604 echo "failed - QOS mode won't be used"
11605 simple_cleanup_common
11606 skip "QOS imbalance criteria not met"
11614 # now fill using QOS
11615 $LFS setstripe -c 1 $DIR/$tdir
11616 FILL=$((FILL / 200))
11617 if [ $FILL -gt 600 ]; then
11620 echo "writing $FILL files to QOS-assigned OSTs"
11622 while [ $i -lt $FILL ]; do
11624 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
11625 count=1 2>/dev/null
11628 echo "wrote $i 200k files"
11632 echo "Note: free space may not be updated, so measurements might be off"
11634 DIFF2=$((MAXV - MINV))
11635 echo "free space delta: orig $DIFF final $DIFF2"
11636 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
11637 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
11638 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
11639 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
11640 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
11641 if [[ $DIFF -gt 0 ]]; then
11642 FILL=$((DIFF2 * 100 / DIFF - 100))
11643 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
11646 # Figure out which files were written where
11647 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
11648 awk '/'$MINI1': / {print $2; exit}')
11650 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
11651 echo "$MINC files created on smaller OST $MINI1"
11652 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
11653 awk '/'$MAXI1': / {print $2; exit}')
11655 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
11656 echo "$MAXC files created on larger OST $MAXI1"
11657 if [[ $MINC -gt 0 ]]; then
11658 FILL=$((MAXC * 100 / MINC - 100))
11659 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
11661 [[ $MAXC -gt $MINC ]] ||
11662 error_ignore LU-9 "stripe QOS didn't balance free space"
11663 simple_cleanup_common
11665 run_test 116a "stripe QOS: free space balance ==================="
11667 test_116b() { # LU-2093
11668 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11669 remote_mds_nodsh && skip "remote MDS with nodsh"
11671 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
11672 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
11673 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
11674 [ -z "$old_rr" ] && skip "no QOS"
11675 do_facet $SINGLEMDS lctl set_param \
11676 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
11677 mkdir -p $DIR/$tdir
11678 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
11679 createmany -o $DIR/$tdir/f- 20 || error "can't create"
11680 do_facet $SINGLEMDS lctl set_param fail_loc=0
11682 do_facet $SINGLEMDS lctl set_param \
11683 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
11685 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
11687 test_117() # bug 10891
11689 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11691 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
11692 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
11693 lctl set_param fail_loc=0x21e
11694 > $DIR/$tfile || error "truncate failed"
11695 lctl set_param fail_loc=0
11696 echo "Truncate succeeded."
11699 run_test 117 "verify osd extend =========="
11701 NO_SLOW_RESENDCOUNT=4
11702 export OLD_RESENDCOUNT=""
11703 set_resend_count () {
11704 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
11705 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
11706 lctl set_param -n $PROC_RESENDCOUNT $1
11707 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
11710 # for reduce test_118* time (b=14842)
11711 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
11713 # Reset async IO behavior after error case
11715 FILE=$DIR/reset_async
11717 # Ensure all OSCs are cleared
11718 $LFS setstripe -c -1 $FILE
11719 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
11724 test_118a() #bug 11710
11726 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11730 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11731 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11732 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
11734 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11735 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11740 run_test 118a "verify O_SYNC works =========="
11744 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11745 remote_ost_nodsh && skip "remote OST with nodsh"
11749 #define OBD_FAIL_SRV_ENOENT 0x217
11750 set_nodes_failloc "$(osts_nodes)" 0x217
11751 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11753 set_nodes_failloc "$(osts_nodes)" 0
11754 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11755 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11758 if [[ $RC -eq 0 ]]; then
11759 error "Must return error due to dropped pages, rc=$RC"
11763 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11764 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11768 echo "Dirty pages not leaked on ENOENT"
11770 # Due to the above error the OSC will issue all RPCs syncronously
11771 # until a subsequent RPC completes successfully without error.
11772 $MULTIOP $DIR/$tfile Ow4096yc
11777 run_test 118b "Reclaim dirty pages on fatal error =========="
11781 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11783 # for 118c, restore the original resend count, LU-1940
11784 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
11785 set_resend_count $OLD_RESENDCOUNT
11786 remote_ost_nodsh && skip "remote OST with nodsh"
11790 #define OBD_FAIL_OST_EROFS 0x216
11791 set_nodes_failloc "$(osts_nodes)" 0x216
11793 # multiop should block due to fsync until pages are written
11794 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
11798 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
11799 error "Multiop failed to block on fsync, pid=$MULTIPID"
11802 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11804 if [[ $WRITEBACK -eq 0 ]]; then
11805 error "No page in writeback, writeback=$WRITEBACK"
11808 set_nodes_failloc "$(osts_nodes)" 0
11811 if [[ $RC -ne 0 ]]; then
11812 error "Multiop fsync failed, rc=$RC"
11815 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11816 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11818 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11819 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11823 echo "Dirty pages flushed via fsync on EROFS"
11826 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
11828 # continue to use small resend count to reduce test_118* time (b=14842)
11829 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
11833 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11834 remote_ost_nodsh && skip "remote OST with nodsh"
11838 #define OBD_FAIL_OST_BRW_PAUSE_BULK
11839 set_nodes_failloc "$(osts_nodes)" 0x214
11840 # multiop should block due to fsync until pages are written
11841 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
11845 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
11846 error "Multiop failed to block on fsync, pid=$MULTIPID"
11849 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11851 if [[ $WRITEBACK -eq 0 ]]; then
11852 error "No page in writeback, writeback=$WRITEBACK"
11855 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
11856 set_nodes_failloc "$(osts_nodes)" 0
11858 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11859 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11861 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11862 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11866 echo "Dirty pages gaurenteed flushed via fsync"
11869 run_test 118d "Fsync validation inject a delay of the bulk =========="
11872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11876 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
11877 lctl set_param fail_loc=0x8000040a
11879 # Should simulate EINVAL error which is fatal
11880 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11882 if [[ $RC -eq 0 ]]; then
11883 error "Must return error due to dropped pages, rc=$RC"
11886 lctl set_param fail_loc=0x0
11888 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11889 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11890 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11892 if [[ $LOCKED -ne 0 ]]; then
11893 error "Locked pages remain in cache, locked=$LOCKED"
11896 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11897 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11901 echo "No pages locked after fsync"
11906 run_test 118f "Simulate unrecoverable OSC side error =========="
11909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11913 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
11914 lctl set_param fail_loc=0x406
11916 # simulate local -ENOMEM
11917 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11920 lctl set_param fail_loc=0
11921 if [[ $RC -eq 0 ]]; then
11922 error "Must return error due to dropped pages, rc=$RC"
11925 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11926 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11927 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11929 if [[ $LOCKED -ne 0 ]]; then
11930 error "Locked pages remain in cache, locked=$LOCKED"
11933 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11934 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11938 echo "No pages locked after fsync"
11943 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
11946 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11947 remote_ost_nodsh && skip "remote OST with nodsh"
11951 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
11952 set_nodes_failloc "$(osts_nodes)" 0x20e
11953 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
11954 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11957 set_nodes_failloc "$(osts_nodes)" 0
11958 if [[ $RC -eq 0 ]]; then
11959 error "Must return error due to dropped pages, rc=$RC"
11962 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11963 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11964 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11966 if [[ $LOCKED -ne 0 ]]; then
11967 error "Locked pages remain in cache, locked=$LOCKED"
11970 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11971 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11975 echo "No pages locked after fsync"
11979 run_test 118h "Verify timeout in handling recoverables errors =========="
11981 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
11984 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11985 remote_ost_nodsh && skip "remote OST with nodsh"
11989 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
11990 set_nodes_failloc "$(osts_nodes)" 0x20e
11992 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
11993 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
11996 set_nodes_failloc "$(osts_nodes)" 0
12000 if [[ $RC -ne 0 ]]; then
12001 error "got error, but should be not, rc=$RC"
12004 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12005 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12006 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12007 if [[ $LOCKED -ne 0 ]]; then
12008 error "Locked pages remain in cache, locked=$LOCKED"
12011 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12012 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12016 echo "No pages locked after fsync"
12020 run_test 118i "Fix error before timeout in recoverable error =========="
12022 [ "$SLOW" = "no" ] && set_resend_count 4
12025 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12026 remote_ost_nodsh && skip "remote OST with nodsh"
12030 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
12031 set_nodes_failloc "$(osts_nodes)" 0x220
12033 # return -EIO from OST
12034 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12036 set_nodes_failloc "$(osts_nodes)" 0x0
12037 if [[ $RC -eq 0 ]]; then
12038 error "Must return error due to dropped pages, rc=$RC"
12041 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12042 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12043 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12044 if [[ $LOCKED -ne 0 ]]; then
12045 error "Locked pages remain in cache, locked=$LOCKED"
12048 # in recoverable error on OST we want resend and stay until it finished
12049 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12050 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12054 echo "No pages locked after fsync"
12058 run_test 118j "Simulate unrecoverable OST side error =========="
12062 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12063 remote_ost_nodsh && skip "remote OSTs with nodsh"
12065 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12066 set_nodes_failloc "$(osts_nodes)" 0x20e
12067 test_mkdir $DIR/$tdir
12069 for ((i=0;i<10;i++)); do
12070 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
12071 error "dd to $DIR/$tdir/$tfile-$i failed" )&
12078 set_nodes_failloc "$(osts_nodes)" 0
12081 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
12083 test_118l() # LU-646
12085 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12087 test_mkdir $DIR/$tdir
12088 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
12091 run_test 118l "fsync dir"
12093 test_118m() # LU-3066
12095 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12097 test_mkdir $DIR/$tdir
12098 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
12101 run_test 118m "fdatasync dir ========="
12103 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12111 remote_ost_nodsh && skip "remote OSTs with nodsh"
12113 # Sleep to avoid a cached response.
12114 #define OBD_STATFS_CACHE_SECONDS 1
12117 # Inject a 10 second delay in the OST_STATFS handler.
12118 #define OBD_FAIL_OST_STATFS_DELAY 0x242
12119 set_nodes_failloc "$(osts_nodes)" 0x242
12122 stat --file-system $MOUNT > /dev/null
12125 set_nodes_failloc "$(osts_nodes)" 0
12127 if ((end - begin > 20)); then
12128 error "statfs took $((end - begin)) seconds, expected 10"
12131 run_test 118n "statfs() sends OST_STATFS requests in parallel"
12133 test_119a() # bug 11737
12135 BSIZE=$((512 * 1024))
12136 directio write $DIR/$tfile 0 1 $BSIZE
12137 # We ask to read two blocks, which is more than a file size.
12138 # directio will indicate an error when requested and actual
12139 # sizes aren't equeal (a normal situation in this case) and
12140 # print actual read amount.
12141 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
12142 if [ "$NOB" != "$BSIZE" ]; then
12143 error "read $NOB bytes instead of $BSIZE"
12147 run_test 119a "Short directIO read must return actual read amount"
12149 test_119b() # bug 11737
12151 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12153 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
12154 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
12156 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
12157 error "direct read failed"
12160 run_test 119b "Sparse directIO read must return actual read amount"
12162 test_119c() # bug 13099
12165 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
12166 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
12169 run_test 119c "Testing for direct read hitting hole"
12171 test_119d() # bug 15950
12173 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12175 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
12176 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
12178 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
12179 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
12180 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
12181 lctl set_param fail_loc=0x40d
12182 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
12185 cat $DIR/$tfile > /dev/null &
12186 lctl set_param fail_loc=0
12189 log "the DIO writes have completed, now wait for the reads (should not block very long)"
12191 [ -n "`ps h -p $pid_reads -o comm`" ] && \
12192 error "the read rpcs have not completed in 2s"
12194 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
12196 run_test 119d "The DIO path should try to send a new rpc once one is completed"
12199 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12200 remote_mds_nodsh && skip "remote MDS with nodsh"
12201 test_mkdir -i0 -c1 $DIR/$tdir
12202 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12203 skip_env "no early lock cancel on server"
12205 lru_resize_disable mdc
12206 lru_resize_disable osc
12207 cancel_lru_locks mdc
12208 # asynchronous object destroy at MDT could cause bl ast to client
12209 cancel_lru_locks osc
12211 stat $DIR/$tdir > /dev/null
12212 can1=$(do_facet mds1 \
12213 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12214 awk '/ldlm_cancel/ {print $2}')
12215 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12216 awk '/ldlm_bl_callback/ {print $2}')
12217 test_mkdir -i0 -c1 $DIR/$tdir/d1
12218 can2=$(do_facet mds1 \
12219 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12220 awk '/ldlm_cancel/ {print $2}')
12221 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12222 awk '/ldlm_bl_callback/ {print $2}')
12223 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12224 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12225 lru_resize_enable mdc
12226 lru_resize_enable osc
12228 run_test 120a "Early Lock Cancel: mkdir test"
12231 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12232 remote_mds_nodsh && skip "remote MDS with nodsh"
12233 test_mkdir $DIR/$tdir
12234 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12235 skip_env "no early lock cancel on server"
12237 lru_resize_disable mdc
12238 lru_resize_disable osc
12239 cancel_lru_locks mdc
12240 stat $DIR/$tdir > /dev/null
12241 can1=$(do_facet $SINGLEMDS \
12242 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12243 awk '/ldlm_cancel/ {print $2}')
12244 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12245 awk '/ldlm_bl_callback/ {print $2}')
12246 touch $DIR/$tdir/f1
12247 can2=$(do_facet $SINGLEMDS \
12248 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12249 awk '/ldlm_cancel/ {print $2}')
12250 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12251 awk '/ldlm_bl_callback/ {print $2}')
12252 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12253 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12254 lru_resize_enable mdc
12255 lru_resize_enable osc
12257 run_test 120b "Early Lock Cancel: create test"
12260 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12261 remote_mds_nodsh && skip "remote MDS with nodsh"
12262 test_mkdir -i0 -c1 $DIR/$tdir
12263 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12264 skip "no early lock cancel on server"
12266 lru_resize_disable mdc
12267 lru_resize_disable osc
12268 test_mkdir -i0 -c1 $DIR/$tdir/d1
12269 test_mkdir -i0 -c1 $DIR/$tdir/d2
12270 touch $DIR/$tdir/d1/f1
12271 cancel_lru_locks mdc
12272 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
12273 can1=$(do_facet mds1 \
12274 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12275 awk '/ldlm_cancel/ {print $2}')
12276 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12277 awk '/ldlm_bl_callback/ {print $2}')
12278 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
12279 can2=$(do_facet mds1 \
12280 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12281 awk '/ldlm_cancel/ {print $2}')
12282 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12283 awk '/ldlm_bl_callback/ {print $2}')
12284 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12285 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12286 lru_resize_enable mdc
12287 lru_resize_enable osc
12289 run_test 120c "Early Lock Cancel: link test"
12292 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12293 remote_mds_nodsh && skip "remote MDS with nodsh"
12294 test_mkdir -i0 -c1 $DIR/$tdir
12295 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12296 skip_env "no early lock cancel on server"
12298 lru_resize_disable mdc
12299 lru_resize_disable osc
12301 cancel_lru_locks mdc
12302 stat $DIR/$tdir > /dev/null
12303 can1=$(do_facet mds1 \
12304 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12305 awk '/ldlm_cancel/ {print $2}')
12306 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12307 awk '/ldlm_bl_callback/ {print $2}')
12308 chmod a+x $DIR/$tdir
12309 can2=$(do_facet mds1 \
12310 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12311 awk '/ldlm_cancel/ {print $2}')
12312 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12313 awk '/ldlm_bl_callback/ {print $2}')
12314 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12315 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12316 lru_resize_enable mdc
12317 lru_resize_enable osc
12319 run_test 120d "Early Lock Cancel: setattr test"
12322 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12323 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12324 skip_env "no early lock cancel on server"
12325 remote_mds_nodsh && skip "remote MDS with nodsh"
12327 local dlmtrace_set=false
12329 test_mkdir -i0 -c1 $DIR/$tdir
12330 lru_resize_disable mdc
12331 lru_resize_disable osc
12332 ! $LCTL get_param debug | grep -q dlmtrace &&
12333 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
12334 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
12335 cancel_lru_locks mdc
12336 cancel_lru_locks osc
12337 dd if=$DIR/$tdir/f1 of=/dev/null
12338 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
12339 # XXX client can not do early lock cancel of OST lock
12340 # during unlink (LU-4206), so cancel osc lock now.
12342 cancel_lru_locks osc
12343 can1=$(do_facet mds1 \
12344 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12345 awk '/ldlm_cancel/ {print $2}')
12346 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12347 awk '/ldlm_bl_callback/ {print $2}')
12348 unlink $DIR/$tdir/f1
12350 can2=$(do_facet mds1 \
12351 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12352 awk '/ldlm_cancel/ {print $2}')
12353 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12354 awk '/ldlm_bl_callback/ {print $2}')
12355 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
12356 $LCTL dk $TMP/cancel.debug.txt
12357 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
12358 $LCTL dk $TMP/blocking.debug.txt
12359 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
12360 lru_resize_enable mdc
12361 lru_resize_enable osc
12363 run_test 120e "Early Lock Cancel: unlink test"
12366 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12367 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12368 skip_env "no early lock cancel on server"
12369 remote_mds_nodsh && skip "remote MDS with nodsh"
12371 test_mkdir -i0 -c1 $DIR/$tdir
12372 lru_resize_disable mdc
12373 lru_resize_disable osc
12374 test_mkdir -i0 -c1 $DIR/$tdir/d1
12375 test_mkdir -i0 -c1 $DIR/$tdir/d2
12376 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
12377 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
12378 cancel_lru_locks mdc
12379 cancel_lru_locks osc
12380 dd if=$DIR/$tdir/d1/f1 of=/dev/null
12381 dd if=$DIR/$tdir/d2/f2 of=/dev/null
12382 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
12383 # XXX client can not do early lock cancel of OST lock
12384 # during rename (LU-4206), so cancel osc lock now.
12386 cancel_lru_locks osc
12387 can1=$(do_facet mds1 \
12388 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12389 awk '/ldlm_cancel/ {print $2}')
12390 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12391 awk '/ldlm_bl_callback/ {print $2}')
12392 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
12394 can2=$(do_facet mds1 \
12395 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12396 awk '/ldlm_cancel/ {print $2}')
12397 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12398 awk '/ldlm_bl_callback/ {print $2}')
12399 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12400 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12401 lru_resize_enable mdc
12402 lru_resize_enable osc
12404 run_test 120f "Early Lock Cancel: rename test"
12407 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12408 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12409 skip_env "no early lock cancel on server"
12410 remote_mds_nodsh && skip "remote MDS with nodsh"
12412 lru_resize_disable mdc
12413 lru_resize_disable osc
12415 echo create $count files
12416 test_mkdir $DIR/$tdir
12417 cancel_lru_locks mdc
12418 cancel_lru_locks osc
12421 can0=$(do_facet $SINGLEMDS \
12422 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12423 awk '/ldlm_cancel/ {print $2}')
12424 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12425 awk '/ldlm_bl_callback/ {print $2}')
12426 createmany -o $DIR/$tdir/f $count
12428 can1=$(do_facet $SINGLEMDS \
12429 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12430 awk '/ldlm_cancel/ {print $2}')
12431 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12432 awk '/ldlm_bl_callback/ {print $2}')
12434 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
12435 echo rm $count files
12438 can2=$(do_facet $SINGLEMDS \
12439 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12440 awk '/ldlm_cancel/ {print $2}')
12441 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12442 awk '/ldlm_bl_callback/ {print $2}')
12444 echo total: $count removes in $((t2-t1))
12445 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
12447 # wait for commitment of removal
12448 lru_resize_enable mdc
12449 lru_resize_enable osc
12451 run_test 120g "Early Lock Cancel: performance test"
12453 test_121() { #bug #10589
12454 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12457 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
12458 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
12459 lctl set_param fail_loc=0x310
12460 cancel_lru_locks osc > /dev/null
12461 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
12462 lctl set_param fail_loc=0
12463 [[ $reads -eq $writes ]] ||
12464 error "read $reads blocks, must be $writes blocks"
12466 run_test 121 "read cancel race ========="
12468 test_123a_base() { # was test 123, statahead(bug 11401)
12472 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
12473 log "testing UP system. Performance may be lower than expected."
12478 test_mkdir $DIR/$tdir
12479 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
12480 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
12482 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
12483 createmany -o $DIR/$tdir/$tfile $j $((i - j))
12485 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
12486 lctl set_param -n llite.*.statahead_max 0
12487 lctl get_param llite.*.statahead_max
12488 cancel_lru_locks mdc
12489 cancel_lru_locks osc
12491 time $lsx $DIR/$tdir | wc -l
12493 delta=$((etime - stime))
12494 log "$lsx $i files without statahead: $delta sec"
12495 lctl set_param llite.*.statahead_max=$max
12497 swrong=$(lctl get_param -n llite.*.statahead_stats |
12498 grep "statahead wrong:" | awk '{print $3}')
12499 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
12500 cancel_lru_locks mdc
12501 cancel_lru_locks osc
12503 time $lsx $DIR/$tdir | wc -l
12505 delta_sa=$((etime - stime))
12506 log "$lsx $i files with statahead: $delta_sa sec"
12507 lctl get_param -n llite.*.statahead_stats
12508 ewrong=$(lctl get_param -n llite.*.statahead_stats |
12509 grep "statahead wrong:" | awk '{print $3}')
12511 [[ $swrong -lt $ewrong ]] &&
12512 log "statahead was stopped, maybe too many locks held!"
12513 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
12515 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
12516 max=$(lctl get_param -n llite.*.statahead_max |
12518 lctl set_param -n llite.*.statahead_max 0
12519 lctl get_param llite.*.statahead_max
12520 cancel_lru_locks mdc
12521 cancel_lru_locks osc
12523 time $lsx $DIR/$tdir | wc -l
12525 delta=$((etime - stime))
12526 log "$lsx $i files again without statahead: $delta sec"
12527 lctl set_param llite.*.statahead_max=$max
12528 if [ $((delta_sa * 100 > delta * 105 && delta_sa > delta + 2)) ]; then
12529 if [ $SLOWOK -eq 0 ]; then
12530 error "$lsx $i files is slower with statahead!"
12532 log "$lsx $i files is slower with statahead!"
12538 [ $delta -gt 20 ] && break
12539 [ $delta -gt 8 ] && MULT=$((50 / delta))
12540 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
12548 delta=$((etime - stime))
12549 log "rm -r $DIR/$tdir/: $delta seconds"
12551 lctl get_param -n llite.*.statahead_stats
12555 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12557 test_123a_base "ls -l"
12559 run_test 123aa "verify statahead work"
12562 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12564 statx_supported || skip_env "Test must be statx() syscall supported"
12566 test_123a_base "$STATX -l"
12568 run_test 123ab "verify statahead work by using statx"
12571 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12573 statx_supported || skip_env "Test must be statx() syscall supported"
12580 cancel_lru_locks $OSC
12581 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
12582 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
12583 awk '/agl.total:/ {print $3}')
12584 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
12585 test_123a_base "$STATX --cached=always -D"
12586 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
12587 awk '/agl.total:/ {print $3}')
12588 [ $agl_before -eq $agl_after ] ||
12589 error "Should not trigger AGL thread - $agl_before:$agl_after"
12590 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
12591 [ $rpcs_after -eq $rpcs_before ] ||
12592 error "$STATX should not send glimpse RPCs to $OSC"
12594 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
12596 test_123b () { # statahead(bug 15027)
12597 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12599 test_mkdir $DIR/$tdir
12600 createmany -o $DIR/$tdir/$tfile-%d 1000
12602 cancel_lru_locks mdc
12603 cancel_lru_locks osc
12605 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
12606 lctl set_param fail_loc=0x80000803
12607 ls -lR $DIR/$tdir > /dev/null
12609 lctl set_param fail_loc=0x0
12610 lctl get_param -n llite.*.statahead_stats
12615 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
12618 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
12620 test_mkdir -i 0 -c 1 $DIR/$tdir.0
12621 test_mkdir -i 1 -c 1 $DIR/$tdir.1
12622 touch $DIR/$tdir.1/{1..3}
12623 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
12625 remount_client $MOUNT
12627 $MULTIOP $DIR/$tdir.0 Q
12629 # let statahead to complete
12630 ls -l $DIR/$tdir.0 > /dev/null
12632 testid=$(echo $TESTNAME | tr '_' ' ')
12633 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
12634 error "statahead warning" || true
12636 run_test 123c "Can not initialize inode warning on DNE statahead"
12639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12640 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
12641 skip_env "no lru resize on server"
12645 test_mkdir $DIR/$tdir
12647 log "create $NR files at $DIR/$tdir"
12648 createmany -o $DIR/$tdir/f $NR ||
12649 error "failed to create $NR files in $DIR/$tdir"
12651 cancel_lru_locks mdc
12652 ls -l $DIR/$tdir > /dev/null
12656 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
12657 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
12658 LRU_SIZE=$($LCTL get_param -n $PARAM)
12659 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
12660 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
12662 log "NS=$(basename $NSDIR)"
12667 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
12668 skip "Not enough cached locks created!"
12670 log "LRU=$LRU_SIZE"
12674 # We know that lru resize allows one client to hold $LIMIT locks
12675 # for 10h. After that locks begin to be killed by client.
12677 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
12679 if [ $LIMIT -lt $LRU_SIZE ]; then
12680 skip "Limit is too small $LIMIT"
12683 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
12684 # killing locks. Some time was spent for creating locks. This means
12685 # that up to the moment of sleep finish we must have killed some of
12686 # them (10-100 locks). This depends on how fast ther were created.
12687 # Many of them were touched in almost the same moment and thus will
12688 # be killed in groups.
12689 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
12691 # Use $LRU_SIZE_B here to take into account real number of locks
12692 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
12693 local LRU_SIZE_B=$LRU_SIZE
12695 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
12696 log "OLD_LVF=$OLD_LVF"
12697 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
12699 # Let's make sure that we really have some margin. Client checks
12700 # cached locks every 10 sec.
12701 SLEEP=$((SLEEP+20))
12702 log "Sleep ${SLEEP} sec"
12704 while ((SEC<$SLEEP)); do
12708 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
12709 echo -n "$LRU_SIZE"
12712 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
12713 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
12715 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
12716 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
12717 unlinkmany $DIR/$tdir/f $NR
12721 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
12722 log "unlink $NR files at $DIR/$tdir"
12723 unlinkmany $DIR/$tdir/f $NR
12725 run_test 124a "lru resize ======================================="
12727 get_max_pool_limit()
12729 local limit=$($LCTL get_param \
12730 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
12732 for l in $limit; do
12733 if [[ $l -gt $max ]]; then
12741 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12742 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
12743 skip_env "no lru resize on server"
12745 LIMIT=$(get_max_pool_limit)
12747 NR=$(($(default_lru_size)*20))
12748 if [[ $NR -gt $LIMIT ]]; then
12749 log "Limit lock number by $LIMIT locks"
12753 IFree=$(mdsrate_inodes_available)
12754 if [ $IFree -lt $NR ]; then
12755 log "Limit lock number by $IFree inodes"
12759 lru_resize_disable mdc
12760 test_mkdir -p $DIR/$tdir/disable_lru_resize
12762 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
12763 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
12764 cancel_lru_locks mdc
12767 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
12770 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
12773 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
12777 nolruresize_delta=$((etime-stime))
12778 log "ls -la time: $nolruresize_delta seconds"
12779 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
12780 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
12782 lru_resize_enable mdc
12783 test_mkdir -p $DIR/$tdir/enable_lru_resize
12785 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
12786 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
12787 cancel_lru_locks mdc
12790 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
12793 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
12796 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
12800 lruresize_delta=$((etime-stime))
12801 log "ls -la time: $lruresize_delta seconds"
12802 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
12804 if [ $lruresize_delta -gt $nolruresize_delta ]; then
12805 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
12806 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
12807 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
12809 log "lru resize performs the same with no lru resize"
12811 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
12813 run_test 124b "lru resize (performance test) ======================="
12816 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12817 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
12818 skip_env "no lru resize on server"
12820 # cache ununsed locks on client
12822 cancel_lru_locks mdc
12823 test_mkdir $DIR/$tdir
12824 createmany -o $DIR/$tdir/f $nr ||
12825 error "failed to create $nr files in $DIR/$tdir"
12826 ls -l $DIR/$tdir > /dev/null
12828 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12829 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12830 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
12831 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
12832 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
12834 # set lru_max_age to 1 sec
12835 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
12836 echo "sleep $((recalc_p * 2)) seconds..."
12837 sleep $((recalc_p * 2))
12839 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
12840 # restore lru_max_age
12841 $LCTL set_param -n $nsdir.lru_max_age $max_age
12842 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
12843 unlinkmany $DIR/$tdir/f $nr
12845 run_test 124c "LRUR cancel very aged locks"
12848 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12849 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
12850 skip_env "no lru resize on server"
12852 # cache ununsed locks on client
12855 lru_resize_disable mdc
12856 stack_trap "lru_resize_enable mdc" EXIT
12858 cancel_lru_locks mdc
12860 # asynchronous object destroy at MDT could cause bl ast to client
12861 test_mkdir $DIR/$tdir
12862 createmany -o $DIR/$tdir/f $nr ||
12863 error "failed to create $nr files in $DIR/$tdir"
12864 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
12866 ls -l $DIR/$tdir > /dev/null
12868 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12869 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12870 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
12871 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
12873 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
12875 # set lru_max_age to 1 sec
12876 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
12877 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
12879 echo "sleep $((recalc_p * 2)) seconds..."
12880 sleep $((recalc_p * 2))
12882 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
12884 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
12886 run_test 124d "cancel very aged locks if lru-resize diasbaled"
12888 test_125() { # 13358
12889 $LCTL get_param -n llite.*.client_type | grep -q local ||
12890 skip "must run as local client"
12891 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
12892 skip_env "must have acl enabled"
12893 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
12895 test_mkdir $DIR/$tdir
12896 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
12897 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
12898 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
12900 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
12902 test_126() { # bug 12829/13455
12903 $GSS && skip_env "must run as gss disabled"
12904 $LCTL get_param -n llite.*.client_type | grep -q local ||
12905 skip "must run as local client"
12906 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
12908 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
12909 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
12911 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
12913 run_test 126 "check that the fsgid provided by the client is taken into account"
12915 test_127a() { # bug 15521
12916 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12917 local name count samp unit min max sum sumsq
12919 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
12920 echo "stats before reset"
12921 $LCTL get_param osc.*.stats
12922 $LCTL set_param osc.*.stats=0
12923 local fsize=$((2048 * 1024))
12925 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
12926 cancel_lru_locks osc
12927 dd if=$DIR/$tfile of=/dev/null bs=$fsize
12929 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
12930 stack_trap "rm -f $TMP/$tfile.tmp"
12931 while read name count samp unit min max sum sumsq; do
12932 echo "got name=$name count=$count unit=$unit min=$min max=$max"
12933 [ ! $min ] && error "Missing min value for $name proc entry"
12934 eval $name=$count || error "Wrong proc format"
12937 read_bytes|write_bytes)
12938 [[ "$unit" =~ "bytes" ]] ||
12939 error "unit is not 'bytes': $unit"
12940 (( $min >= 4096 )) || error "min is too small: $min"
12941 (( $min <= $fsize )) || error "min is too big: $min"
12942 (( $max >= 4096 )) || error "max is too small: $max"
12943 (( $max <= $fsize )) || error "max is too big: $max"
12944 (( $sum == $fsize )) || error "sum is wrong: $sum"
12945 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
12946 error "sumsquare is too small: $sumsq"
12947 (( $sumsq <= $fsize * $fsize )) ||
12948 error "sumsquare is too big: $sumsq"
12950 ost_read|ost_write)
12951 [[ "$unit" =~ "usec" ]] ||
12952 error "unit is not 'usec': $unit"
12956 done < $DIR/$tfile.tmp
12958 #check that we actually got some stats
12959 [ "$read_bytes" ] || error "Missing read_bytes stats"
12960 [ "$write_bytes" ] || error "Missing write_bytes stats"
12961 [ "$read_bytes" != 0 ] || error "no read done"
12962 [ "$write_bytes" != 0 ] || error "no write done"
12964 run_test 127a "verify the client stats are sane"
12966 test_127b() { # bug LU-333
12967 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12968 local name count samp unit min max sum sumsq
12970 echo "stats before reset"
12971 $LCTL get_param llite.*.stats
12972 $LCTL set_param llite.*.stats=0
12974 # perform 2 reads and writes so MAX is different from SUM.
12975 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
12976 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
12977 cancel_lru_locks osc
12978 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
12979 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
12981 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
12982 stack_trap "rm -f $TMP/$tfile.tmp"
12983 while read name count samp unit min max sum sumsq; do
12984 echo "got name=$name count=$count unit=$unit min=$min max=$max"
12985 eval $name=$count || error "Wrong proc format"
12988 read_bytes|write_bytes)
12989 [[ "$unit" =~ "bytes" ]] ||
12990 error "unit is not 'bytes': $unit"
12991 (( $count == 2 )) || error "count is not 2: $count"
12992 (( $min == $PAGE_SIZE )) ||
12993 error "min is not $PAGE_SIZE: $min"
12994 (( $max == $PAGE_SIZE )) ||
12995 error "max is not $PAGE_SIZE: $max"
12996 (( $sum == $PAGE_SIZE * 2 )) ||
12997 error "sum is not $((PAGE_SIZE * 2)): $sum"
13000 [[ "$unit" =~ "usec" ]] ||
13001 error "unit is not 'usec': $unit"
13005 done < $TMP/$tfile.tmp
13007 #check that we actually got some stats
13008 [ "$read_bytes" ] || error "Missing read_bytes stats"
13009 [ "$write_bytes" ] || error "Missing write_bytes stats"
13010 [ "$read_bytes" != 0 ] || error "no read done"
13011 [ "$write_bytes" != 0 ] || error "no write done"
13013 run_test 127b "verify the llite client stats are sane"
13015 test_127c() { # LU-12394
13016 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13023 $LCTL set_param llite.*.extents_stats=1
13024 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
13026 # Use two stripes so there is enough space in default config
13027 $LFS setstripe -c 2 $DIR/$tfile
13029 # Extent stats start at 0-4K and go in power of two buckets
13030 # LL_HIST_START = 12 --> 2^12 = 4K
13031 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
13032 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
13034 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
13036 # Write and read, 2x each, second time at a non-zero offset
13037 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
13038 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
13039 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
13040 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
13044 $LCTL get_param llite.*.extents_stats
13047 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
13049 local bucket=$($LCTL get_param -n llite.*.extents_stats |
13051 reads=$(echo $bucket | awk '{print $5}')
13052 writes=$(echo $bucket | awk '{print $9}')
13053 [ "$reads" -eq $count ] ||
13054 error "$reads reads in < $bsize bucket, expect $count"
13055 [ "$writes" -eq $count ] ||
13056 error "$writes writes in < $bsize bucket, expect $count"
13059 # Test mmap write and read
13060 $LCTL set_param llite.*.extents_stats=c
13062 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
13063 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
13064 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
13066 $LCTL get_param llite.*.extents_stats
13068 count=$(((size*1024) / PAGE_SIZE))
13070 bsize=$((2 * PAGE_SIZE / 1024))K
13072 bucket=$($LCTL get_param -n llite.*.extents_stats |
13074 reads=$(echo $bucket | awk '{print $5}')
13075 writes=$(echo $bucket | awk '{print $9}')
13076 # mmap writes fault in the page first, creating an additonal read
13077 [ "$reads" -eq $((2 * count)) ] ||
13078 error "$reads reads in < $bsize bucket, expect $count"
13079 [ "$writes" -eq $count ] ||
13080 error "$writes writes in < $bsize bucket, expect $count"
13082 run_test 127c "test llite extent stats with regular & mmap i/o"
13084 test_128() { # bug 15212
13086 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
13091 result=$(grep error $TMP/$tfile.log)
13092 rm -f $DIR/$tfile $TMP/$tfile.log
13093 [ -z "$result" ] ||
13094 error "consecutive find's under interactive lfs failed"
13096 run_test 128 "interactive lfs for 2 consecutive find's"
13098 set_dir_limits () {
13103 local ldproc=/proc/fs/ldiskfs
13104 local facets=$(get_facets MDS)
13106 for facet in ${facets//,/ }; do
13107 canondev=$(ldiskfs_canon \
13108 *.$(convert_facet2label $facet).mntdev $facet)
13109 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
13110 ldproc=/sys/fs/ldiskfs
13111 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
13112 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
13116 check_mds_dmesg() {
13117 local facets=$(get_facets MDS)
13118 for facet in ${facets//,/ }; do
13119 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
13125 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13126 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
13127 skip "Need MDS version with at least 2.5.56"
13128 if [ "$mds1_FSTYPE" != ldiskfs ]; then
13129 skip_env "ldiskfs only test"
13131 remote_mds_nodsh && skip "remote MDS with nodsh"
13134 local has_warning=false
13137 mkdir -p $DIR/$tdir
13139 # block size of mds1
13140 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
13141 set_dir_limits $maxsize $((maxsize * 6 / 8))
13142 stack_trap "set_dir_limits 0 0"
13143 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
13144 local dirsize=$(stat -c%s "$DIR/$tdir")
13146 while (( $dirsize <= $maxsize )); do
13147 $MCREATE $DIR/$tdir/file_base_$nfiles
13149 # check two errors:
13150 # ENOSPC for ext4 max_dir_size, which has been used since
13151 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
13152 if (( rc == ENOSPC )); then
13154 echo "rc=$rc returned as expected after $nfiles files"
13156 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
13157 error "create failed w/o dir size limit"
13159 # messages may be rate limited if test is run repeatedly
13160 check_mds_dmesg '"is approaching max"' ||
13161 echo "warning message should be output"
13162 check_mds_dmesg '"has reached max"' ||
13163 echo "reached message should be output"
13165 dirsize=$(stat -c%s "$DIR/$tdir")
13167 [[ $dirsize -ge $maxsize ]] && return 0
13168 error "dirsize $dirsize < $maxsize after $nfiles files"
13169 elif (( rc != 0 )); then
13172 nfiles=$((nfiles + 1))
13173 dirsize=$(stat -c%s "$DIR/$tdir")
13176 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
13178 run_test 129 "test directory size limit ========================"
13187 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13188 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13190 trap cleanup_130 EXIT RETURN
13192 local fm_file=$DIR/$tfile
13193 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
13194 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
13195 error "dd failed for $fm_file"
13197 # LU-1795: test filefrag/FIEMAP once, even if unsupported
13198 filefrag -ves $fm_file
13200 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13201 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13202 [ $RC != 0 ] && error "filefrag $fm_file failed"
13204 filefrag_op=$(filefrag -ve -k $fm_file |
13205 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13206 lun=$($LFS getstripe -i $fm_file)
13208 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
13211 for line in $filefrag_op
13213 frag_lun=`echo $line | cut -d: -f5`
13214 ext_len=`echo $line | cut -d: -f4`
13215 if (( $frag_lun != $lun )); then
13217 error "FIEMAP on 1-stripe file($fm_file) failed"
13220 (( tot_len += ext_len ))
13223 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
13225 error "FIEMAP on 1-stripe file($fm_file) failed;"
13231 echo "FIEMAP on single striped file succeeded"
13233 run_test 130a "FIEMAP (1-stripe file)"
13236 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13238 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13239 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13241 trap cleanup_130 EXIT RETURN
13243 local fm_file=$DIR/$tfile
13244 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13245 error "setstripe on $fm_file"
13246 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13247 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13249 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
13250 error "dd failed on $fm_file"
13252 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13253 filefrag_op=$(filefrag -ve -k $fm_file |
13254 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13256 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13257 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13262 for line in $filefrag_op
13264 frag_lun=$(echo $line | cut -d: -f5 |
13265 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13266 ext_len=$(echo $line | cut -d: -f4)
13267 if (( $frag_lun != $last_lun )); then
13268 if (( tot_len != 1024 )); then
13270 error "FIEMAP on $fm_file failed; returned " \
13271 "len $tot_len for OST $last_lun instead of 1024"
13274 (( num_luns += 1 ))
13278 (( tot_len += ext_len ))
13281 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
13283 error "FIEMAP on $fm_file failed; returned wrong number of " \
13284 "luns or wrong len for OST $last_lun"
13290 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
13292 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
13295 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13297 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13298 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13300 trap cleanup_130 EXIT RETURN
13302 local fm_file=$DIR/$tfile
13303 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
13304 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13305 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13307 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
13308 error "dd failed on $fm_file"
13310 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13311 filefrag_op=$(filefrag -ve -k $fm_file |
13312 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13314 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13315 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13320 for line in $filefrag_op
13322 frag_lun=$(echo $line | cut -d: -f5 |
13323 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13324 ext_len=$(echo $line | cut -d: -f4)
13325 if (( $frag_lun != $last_lun )); then
13326 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
13327 if (( logical != 512 )); then
13329 error "FIEMAP on $fm_file failed; returned " \
13330 "logical start for lun $logical instead of 512"
13333 if (( tot_len != 512 )); then
13335 error "FIEMAP on $fm_file failed; returned " \
13336 "len $tot_len for OST $last_lun instead of 1024"
13339 (( num_luns += 1 ))
13343 (( tot_len += ext_len ))
13346 if (( num_luns != 2 || tot_len != 512 )); then
13348 error "FIEMAP on $fm_file failed; returned wrong number of " \
13349 "luns or wrong len for OST $last_lun"
13355 echo "FIEMAP on 2-stripe file with hole succeeded"
13357 run_test 130c "FIEMAP (2-stripe file with hole)"
13360 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
13362 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13363 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13365 trap cleanup_130 EXIT RETURN
13367 local fm_file=$DIR/$tfile
13368 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13369 error "setstripe on $fm_file"
13370 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13371 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13373 local actual_stripe_count=$($LFS getstripe -c $fm_file)
13374 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
13375 error "dd failed on $fm_file"
13377 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13378 filefrag_op=$(filefrag -ve -k $fm_file |
13379 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13381 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13382 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13387 for line in $filefrag_op
13389 frag_lun=$(echo $line | cut -d: -f5 |
13390 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13391 ext_len=$(echo $line | cut -d: -f4)
13392 if (( $frag_lun != $last_lun )); then
13393 if (( tot_len != 1024 )); then
13395 error "FIEMAP on $fm_file failed; returned " \
13396 "len $tot_len for OST $last_lun instead of 1024"
13399 (( num_luns += 1 ))
13403 (( tot_len += ext_len ))
13406 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
13408 error "FIEMAP on $fm_file failed; returned wrong number of " \
13409 "luns or wrong len for OST $last_lun"
13415 echo "FIEMAP on N-stripe file succeeded"
13417 run_test 130d "FIEMAP (N-stripe file)"
13420 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13422 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13423 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13425 trap cleanup_130 EXIT RETURN
13427 local fm_file=$DIR/$tfile
13428 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
13431 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
13432 for ((i = 0; i < $NUM_BLKS; i++)); do
13433 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
13434 conv=notrunc > /dev/null 2>&1
13437 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13438 filefrag_op=$(filefrag -ve -k $fm_file |
13439 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13441 last_lun=$(echo $filefrag_op | cut -d: -f5)
13446 for line in $filefrag_op; do
13447 frag_lun=$(echo $line | cut -d: -f5)
13448 ext_len=$(echo $line | cut -d: -f4)
13449 if [[ "$frag_lun" != "$last_lun" ]]; then
13450 if (( tot_len != $EXPECTED_LEN )); then
13452 error "OST$last_lun $tot_len != $EXPECTED_LEN"
13454 (( num_luns += 1 ))
13458 (( tot_len += ext_len ))
13461 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
13463 error "OST$last_lun $num_luns != 2, $tot_len != $EXPECTED_LEN"
13466 echo "FIEMAP with continuation calls succeeded"
13468 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
13471 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13472 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13474 local fm_file=$DIR/$tfile
13475 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
13476 error "multiop create with lov_delay_create on $fm_file"
13478 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13479 filefrag_extents=$(filefrag -vek $fm_file |
13480 awk '/extents? found/ { print $2 }')
13481 if [[ "$filefrag_extents" != "0" ]]; then
13482 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
13487 run_test 130f "FIEMAP (unstriped file)"
13490 local file=$DIR/$tfile
13491 local nr=$((OSTCOUNT * 100))
13493 $LFS setstripe -C $nr $file ||
13494 error "failed to setstripe -C $nr $file"
13496 dd if=/dev/zero of=$file count=$nr bs=1M
13498 nr=$($LFS getstripe -c $file)
13500 local extents=$(filefrag -v $file |
13501 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
13503 echo "filefrag list $extents extents in file with stripecount $nr"
13504 if (( extents < nr )); then
13505 $LFS getstripe $file
13507 error "filefrag printed $extents < $nr extents"
13512 run_test 130g "FIEMAP (overstripe file)"
13514 # Test for writev/readv
13516 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
13517 error "writev test failed"
13518 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
13519 error "readv failed"
13522 run_test 131a "test iov's crossing stripe boundary for writev/readv"
13525 local fsize=$((524288 + 1048576 + 1572864))
13526 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
13527 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
13528 error "append writev test failed"
13530 ((fsize += 1572864 + 1048576))
13531 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
13532 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
13533 error "append writev test failed"
13536 run_test 131b "test append writev"
13539 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
13542 run_test 131c "test read/write on file w/o objects"
13545 rwv -f $DIR/$tfile -w -n 1 1572864
13546 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
13547 if [ "$NOB" != 1572864 ]; then
13548 error "Short read filed: read $NOB bytes instead of 1572864"
13552 run_test 131d "test short read"
13555 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
13556 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
13557 error "read hitting hole failed"
13560 run_test 131e "test read hitting hole"
13569 mds*) res=$(do_facet $facet \
13570 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
13572 ost*) res=$(do_facet $facet \
13573 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
13575 *) error "Wrong facet '$facet'" ;;
13577 [ "$res" ] || error "The counter for $op on $facet was not incremented"
13578 # if the argument $3 is zero, it means any stat increment is ok.
13579 if [[ $want -gt 0 ]]; then
13580 local count=$(echo $res | awk '{ print $2 }')
13581 [[ $count -ne $want ]] &&
13582 error "The $op counter on $facet is $count, not $want"
13587 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13588 remote_ost_nodsh && skip "remote OST with nodsh"
13589 remote_mds_nodsh && skip "remote MDS with nodsh"
13590 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
13591 skip_env "MDS doesn't support rename stats"
13593 local testdir=$DIR/${tdir}/stats_testdir
13595 mkdir -p $DIR/${tdir}
13598 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13599 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
13601 # verify mdt stats first.
13602 mkdir ${testdir} || error "mkdir failed"
13603 check_stats $SINGLEMDS "mkdir" 1
13604 touch ${testdir}/${tfile} || error "touch failed"
13605 check_stats $SINGLEMDS "open" 1
13606 check_stats $SINGLEMDS "close" 1
13607 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
13608 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
13609 check_stats $SINGLEMDS "mknod" 2
13611 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
13612 check_stats $SINGLEMDS "unlink" 1
13613 rm -f ${testdir}/${tfile} || error "file remove failed"
13614 check_stats $SINGLEMDS "unlink" 2
13616 # remove working dir and check mdt stats again.
13617 rmdir ${testdir} || error "rmdir failed"
13618 check_stats $SINGLEMDS "rmdir" 1
13620 local testdir1=$DIR/${tdir}/stats_testdir1
13621 mkdir -p ${testdir}
13622 mkdir -p ${testdir1}
13623 touch ${testdir1}/test1
13624 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
13625 check_stats $SINGLEMDS "crossdir_rename" 1
13627 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
13628 check_stats $SINGLEMDS "samedir_rename" 1
13630 rm -rf $DIR/${tdir}
13632 run_test 133a "Verifying MDT stats ========================================"
13637 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13638 remote_ost_nodsh && skip "remote OST with nodsh"
13639 remote_mds_nodsh && skip "remote MDS with nodsh"
13641 local testdir=$DIR/${tdir}/stats_testdir
13643 mkdir -p ${testdir} || error "mkdir failed"
13644 touch ${testdir}/${tfile} || error "touch failed"
13645 cancel_lru_locks mdc
13648 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13649 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
13651 # extra mdt stats verification.
13652 chmod 444 ${testdir}/${tfile} || error "chmod failed"
13653 check_stats $SINGLEMDS "setattr" 1
13654 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13655 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
13657 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
13658 check_stats $SINGLEMDS "getattr" 1
13660 rm -rf $DIR/${tdir}
13662 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
13663 # so the check below is not reliable
13664 [ $MDSCOUNT -eq 1 ] || return 0
13666 # Sleep to avoid a cached response.
13667 #define OBD_STATFS_CACHE_SECONDS 1
13669 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13670 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
13671 $LFS df || error "lfs failed"
13672 check_stats $SINGLEMDS "statfs" 1
13674 # check aggregated statfs (LU-10018)
13675 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
13677 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
13680 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13681 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
13683 check_stats $SINGLEMDS "statfs" 1
13685 # We want to check that the client didn't send OST_STATFS to
13686 # ost1 but the MDT also uses OST_STATFS for precreate. So some
13687 # extra care is needed here.
13688 if remote_mds; then
13689 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
13690 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
13692 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
13693 [ "$res" ] && error "OST got STATFS"
13698 run_test 133b "Verifying extra MDT stats =================================="
13701 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13702 remote_ost_nodsh && skip "remote OST with nodsh"
13703 remote_mds_nodsh && skip "remote MDS with nodsh"
13705 local testdir=$DIR/$tdir/stats_testdir
13707 test_mkdir -p $testdir
13709 # verify obdfilter stats.
13710 $LFS setstripe -c 1 -i 0 $testdir/$tfile
13712 cancel_lru_locks osc
13713 wait_delete_completed
13716 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13717 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
13719 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
13722 cancel_lru_locks osc
13723 check_stats ost1 "write" 1
13725 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
13726 check_stats ost1 "read" 1
13728 > $testdir/$tfile || error "truncate failed"
13729 check_stats ost1 "punch" 1
13731 rm -f $testdir/$tfile || error "file remove failed"
13732 wait_delete_completed
13733 check_stats ost1 "destroy" 1
13737 run_test 133c "Verifying OST stats ========================================"
13744 while [ $value -ge 2 ]; do
13749 if [ $orig -gt $order ]; then
13757 local size=('K' 'M' 'G' 'T');
13759 local size_string=$value
13761 while [ $value -ge 1024 ]; do
13762 if [ $i -gt 3 ]; then
13763 #T is the biggest unit we get here, if that is bigger,
13765 size_string=${value}T
13768 value=$((value >> 10))
13769 if [ $value -lt 1024 ]; then
13770 size_string=${value}${size[$i]}
13779 get_rename_size() {
13781 local context=${2:-.}
13782 local sample=$(do_facet $SINGLEMDS $LCTL \
13783 get_param mdt.$FSNAME-MDT0000.rename_stats |
13784 grep -A1 $context |
13785 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
13790 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13791 remote_ost_nodsh && skip "remote OST with nodsh"
13792 remote_mds_nodsh && skip "remote MDS with nodsh"
13793 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
13794 skip_env "MDS doesn't support rename stats"
13796 local testdir1=$DIR/${tdir}/stats_testdir1
13797 local testdir2=$DIR/${tdir}/stats_testdir2
13798 mkdir -p $DIR/${tdir}
13800 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
13802 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
13803 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
13805 createmany -o $testdir1/test 512 || error "createmany failed"
13807 # check samedir rename size
13808 mv ${testdir1}/test0 ${testdir1}/test_0
13810 local testdir1_size=$(ls -l $DIR/${tdir} |
13811 awk '/stats_testdir1/ {print $5}')
13812 local testdir2_size=$(ls -l $DIR/${tdir} |
13813 awk '/stats_testdir2/ {print $5}')
13815 testdir1_size=$(order_2 $testdir1_size)
13816 testdir2_size=$(order_2 $testdir2_size)
13818 testdir1_size=$(size_in_KMGT $testdir1_size)
13819 testdir2_size=$(size_in_KMGT $testdir2_size)
13821 echo "source rename dir size: ${testdir1_size}"
13822 echo "target rename dir size: ${testdir2_size}"
13824 local cmd="do_facet $SINGLEMDS $LCTL "
13825 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
13827 eval $cmd || error "$cmd failed"
13828 local samedir=$($cmd | grep 'same_dir')
13829 local same_sample=$(get_rename_size $testdir1_size)
13830 [ -z "$samedir" ] && error "samedir_rename_size count error"
13831 [[ $same_sample -eq 1 ]] ||
13832 error "samedir_rename_size error $same_sample"
13833 echo "Check same dir rename stats success"
13835 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
13837 # check crossdir rename size
13838 mv ${testdir1}/test_0 ${testdir2}/test_0
13840 testdir1_size=$(ls -l $DIR/${tdir} |
13841 awk '/stats_testdir1/ {print $5}')
13842 testdir2_size=$(ls -l $DIR/${tdir} |
13843 awk '/stats_testdir2/ {print $5}')
13845 testdir1_size=$(order_2 $testdir1_size)
13846 testdir2_size=$(order_2 $testdir2_size)
13848 testdir1_size=$(size_in_KMGT $testdir1_size)
13849 testdir2_size=$(size_in_KMGT $testdir2_size)
13851 echo "source rename dir size: ${testdir1_size}"
13852 echo "target rename dir size: ${testdir2_size}"
13854 eval $cmd || error "$cmd failed"
13855 local crossdir=$($cmd | grep 'crossdir')
13856 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
13857 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
13858 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
13859 [[ $src_sample -eq 1 ]] ||
13860 error "crossdir_rename_size error $src_sample"
13861 [[ $tgt_sample -eq 1 ]] ||
13862 error "crossdir_rename_size error $tgt_sample"
13863 echo "Check cross dir rename stats success"
13864 rm -rf $DIR/${tdir}
13866 run_test 133d "Verifying rename_stats ========================================"
13869 remote_mds_nodsh && skip "remote MDS with nodsh"
13870 remote_ost_nodsh && skip "remote OST with nodsh"
13871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13873 local testdir=$DIR/${tdir}/stats_testdir
13874 local ctr f0 f1 bs=32768 count=42 sum
13876 mkdir -p ${testdir} || error "mkdir failed"
13878 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
13880 for ctr in {write,read}_bytes; do
13882 cancel_lru_locks osc
13884 do_facet ost1 $LCTL set_param -n \
13885 "obdfilter.*.exports.clear=clear"
13887 if [ $ctr = write_bytes ]; then
13889 f1=${testdir}/${tfile}
13891 f0=${testdir}/${tfile}
13895 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
13898 cancel_lru_locks osc
13900 sum=$(do_facet ost1 $LCTL get_param \
13901 "obdfilter.*.exports.*.stats" |
13902 awk -v ctr=$ctr 'BEGIN { sum = 0 }
13903 $1 == ctr { sum += $7 }
13904 END { printf("%0.0f", sum) }')
13906 if ((sum != bs * count)); then
13907 error "Bad $ctr sum, expected $((bs * count)), got $sum"
13911 rm -rf $DIR/${tdir}
13913 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
13916 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
13917 skip "too old lustre for get_param -R ($facet_ver)"
13919 # verifying readability.
13920 $LCTL get_param -R '*' &> /dev/null
13922 # Verifing writability with badarea_io.
13923 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
13924 local skipped_params='force_lbug|changelog_mask|daemon_file'
13925 $LCTL list_param -FR '*' | grep '=' | tr -d = |
13926 egrep -v "$skipped_params" |
13927 xargs -n 1 find $proc_dirs -name |
13928 xargs -n 1 badarea_io ||
13929 error "client badarea_io failed"
13931 # remount the FS in case writes/reads /proc break the FS
13932 cleanup || error "failed to unmount"
13933 setup || error "failed to setup"
13935 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
13938 remote_mds_nodsh && skip "remote MDS with nodsh"
13939 remote_ost_nodsh && skip "remote OST with nodsh"
13941 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
13942 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
13944 for facet in mds1 ost1; do
13945 local facet_ver=$(lustre_version_code $facet)
13946 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
13947 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
13949 log "$facet: too old lustre for get_param -R"
13951 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
13952 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
13953 tr -d = | egrep -v $skipped_params |
13954 xargs -n 1 find $proc_dirs -name |
13955 xargs -n 1 badarea_io" ||
13956 error "$facet badarea_io failed"
13958 skip_noexit "$facet: too old lustre for get_param -R"
13962 # remount the FS in case writes/reads /proc break the FS
13963 cleanup || error "failed to unmount"
13964 setup || error "failed to setup"
13966 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
13969 remote_mds_nodsh && skip "remote MDS with nodsh"
13970 remote_ost_nodsh && skip "remote OST with nodsh"
13971 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
13972 skip "Need MDS version at least 2.9.54"
13975 for facet in client mds1 ost1; do
13976 # Get the list of files that are missing the terminating newline
13977 local plist=$(do_facet $facet
13978 $LCTL list_param -FR '*' | grep '=' | tr -d =)
13980 for ent in $plist; do
13981 local missing=$(do_facet $facet $LCTL get_param $ent \|\
13982 awk -v FS='\v' -v RS='\v\v' \
13983 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
13984 print FILENAME}'" 2>/dev/null)
13985 [ -z $missing ] || {
13986 do_facet $facet $LCTL get_param $ent | od -An -tx1
13987 error "file does not end with newline: $facet-$ent"
13992 run_test 133h "Proc files should end with newlines"
13995 remote_mds_nodsh && skip "remote MDS with nodsh"
13996 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
13997 skip "Need MDS version at least 2.7.54"
13999 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14000 cancel_lru_locks mdc
14002 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14003 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14004 [ $unused -eq 0 ] || error "$unused locks are not cleared"
14007 createmany -o $DIR/$tdir/f $nr ||
14008 error "failed to create $nr files in $DIR/$tdir"
14009 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14011 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
14012 do_facet mds1 $LCTL set_param fail_loc=0x327
14013 do_facet mds1 $LCTL set_param fail_val=500
14016 echo "sleep 10 seconds ..."
14018 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
14020 do_facet mds1 $LCTL set_param fail_loc=0
14021 do_facet mds1 $LCTL set_param fail_val=0
14022 [ $lck_cnt -lt $unused ] ||
14023 error "No locks reclaimed, before:$unused, after:$lck_cnt"
14026 unlinkmany $DIR/$tdir/f $nr
14028 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
14031 remote_mds_nodsh && skip "remote MDS with nodsh"
14032 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14033 skip "Need MDS version at least 2.7.54"
14035 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14036 cancel_lru_locks mdc
14038 local low_wm=$(do_facet mds1 $LCTL get_param -n \
14039 ldlm.lock_reclaim_threshold_mb)
14040 # disable reclaim temporarily
14041 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
14043 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
14044 do_facet mds1 $LCTL set_param fail_loc=0x328
14045 do_facet mds1 $LCTL set_param fail_val=500
14047 $LCTL set_param debug=+trace
14050 createmany -o $DIR/$tdir/f $nr &
14051 local create_pid=$!
14053 echo "Sleep $TIMEOUT seconds ..."
14055 if ! ps -p $create_pid > /dev/null 2>&1; then
14056 do_facet mds1 $LCTL set_param fail_loc=0
14057 do_facet mds1 $LCTL set_param fail_val=0
14058 do_facet mds1 $LCTL set_param \
14059 ldlm.lock_reclaim_threshold_mb=${low_wm}m
14060 error "createmany finished incorrectly!"
14062 do_facet mds1 $LCTL set_param fail_loc=0
14063 do_facet mds1 $LCTL set_param fail_val=0
14064 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
14065 wait $create_pid || return 1
14067 unlinkmany $DIR/$tdir/f $nr
14069 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
14072 remote_mds_nodsh && skip "remote MDS with nodsh"
14073 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14074 skip "Need MDS version at least 2.13.50"
14077 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14079 #define OBD_FAIL_PLAIN_RECORDS 0x1319
14080 #set only one record at plain llog
14081 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
14083 #fill already existed plain llog each 64767
14084 #wrapping whole catalog
14085 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14087 createmany -o $DIR/$tdir/$tfile_ 64700
14088 for (( i = 0; i < 64700; i = i + 2 ))
14090 rm $DIR/$tdir/$tfile_$i &
14091 rm $DIR/$tdir/$tfile_$((i + 1)) &
14096 #waiting osp synchronization
14097 wait_delete_completed
14099 run_test 135 "Race catalog processing"
14102 remote_mds_nodsh && skip "remote MDS with nodsh"
14103 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14104 skip "Need MDS version at least 2.13.50"
14107 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14108 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
14109 #set only one record at plain llog
14110 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
14111 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
14113 #fill already existed 2 plain llogs each 64767
14114 #wrapping whole catalog
14115 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14116 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
14117 wait_delete_completed
14119 createmany -o $DIR/$tdir/$tfile_ 10
14122 do_facet $SINGLEMDS $LCTL set_param fail_val=3
14123 for (( i = 0; i < 10; i = i + 3 ))
14125 rm $DIR/$tdir/$tfile_$i &
14126 rm $DIR/$tdir/$tfile_$((i + 1)) &
14130 rm $DIR/$tdir/$tfile_$((i + 2)) &
14133 #waiting osp synchronization
14134 wait_delete_completed
14136 run_test 136 "Race catalog processing 2"
14138 test_140() { #bug-17379
14139 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14141 test_mkdir $DIR/$tdir
14142 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
14143 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
14145 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
14146 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
14148 while i=$((i + 1)); do
14150 cd $i || error "Changing to $i"
14151 ln -s ../stat stat || error "Creating stat symlink"
14152 # Read the symlink until ELOOP present,
14153 # not LBUGing the system is considered success,
14154 # we didn't overrun the stack.
14155 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
14156 if [ $ret -ne 0 ]; then
14157 if [ $ret -eq 40 ]; then
14160 error "Open stat symlink"
14166 echo "The symlink depth = $i"
14167 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
14168 error "Invalid symlink depth"
14170 # Test recursive symlink
14171 ln -s symlink_self symlink_self
14172 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
14173 echo "open symlink_self returns $ret"
14174 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
14176 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
14179 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14181 local TF="$TMP/$tfile"
14183 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14184 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
14186 cancel_lru_locks $OSC
14187 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
14188 remount_client $MOUNT
14190 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
14193 $TRUNCATE $DIR/$tfile 6000
14194 cancel_lru_locks $OSC
14195 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
14198 echo "12345" >>$DIR/$tfile
14199 cancel_lru_locks $OSC
14200 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
14203 echo "12345" >>$DIR/$tfile
14204 cancel_lru_locks $OSC
14205 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
14207 run_test 150a "truncate/append tests"
14210 check_set_fallocate_or_skip
14213 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14214 check_fallocate $DIR/$tfile || error "fallocate failed"
14216 run_test 150b "Verify fallocate (prealloc) functionality"
14219 check_set_fallocate_or_skip
14222 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14223 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
14225 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14226 # precomputed md5sum for 20MB of zeroes
14227 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
14228 local sum=($(md5sum $DIR/$tfile))
14230 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
14232 check_set_fallocate 1
14235 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14236 sum=($(md5sum $DIR/$tfile))
14238 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
14240 run_test 150bb "Verify fallocate modes both zero space"
14243 check_set_fallocate_or_skip
14244 local striping="-c2"
14246 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14247 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
14248 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
14249 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14250 local want=$((OSTCOUNT * 1048576))
14252 # Must allocate all requested space, not more than 5% extra
14253 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14254 error "bytes $bytes is not $want"
14258 echo "verify fallocate on PFL file"
14260 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14262 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
14263 error "Create $DIR/$tfile failed"
14264 fallocate -l $((1048576 * 512)) $DIR/$tfile ||
14265 error "fallocate failed"
14266 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14267 want=$((512 * 1048576))
14269 # Must allocate all requested space, not more than 5% extra
14270 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14271 error "bytes $bytes is not $want"
14273 run_test 150c "Verify fallocate Size and Blocks"
14276 check_set_fallocate_or_skip
14277 local striping="-c2"
14279 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14281 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14282 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
14283 error "setstripe failed"
14284 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
14285 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
14286 local want=$((OSTCOUNT * 1048576))
14288 # Must allocate all requested space, not more than 5% extra
14289 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14290 error "bytes $bytes is not $want"
14292 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
14295 check_set_fallocate_or_skip
14299 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14300 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
14301 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
14303 # Find OST with Minimum Size
14304 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
14305 sort -un | head -1)
14307 # Get 100MB per OST of the available space to reduce run time
14308 # else 60% of the available space if we are running SLOW tests
14309 if [ $SLOW == "no" ]; then
14310 local space=$((1024 * 100 * OSTCOUNT))
14312 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
14315 fallocate -l${space}k $DIR/$tfile ||
14316 error "fallocate ${space}k $DIR/$tfile failed"
14317 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
14319 # get size immediately after fallocate. This should be correctly
14321 local size=$(stat -c '%s' $DIR/$tfile)
14322 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
14324 # Sleep for a while for statfs to get updated. And not pull from cache.
14327 echo "df after fallocate:"
14330 (( size / 1024 == space )) || error "size $size != requested $space"
14331 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
14332 error "used $used < space $space"
14334 rm $DIR/$tfile || error "rm failed"
14336 wait_delete_completed
14338 echo "df after unlink:"
14341 run_test 150e "Verify 60% of available OST space consumed by fallocate"
14346 local want_size_before=20480 # in bytes
14347 local want_blocks_before=40 # 512 sized blocks
14348 local want_blocks_after=24 # 512 sized blocks
14349 local length=$(((want_blocks_before - want_blocks_after) * 512))
14351 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
14352 skip "need at least 2.14.0 for fallocate punch"
14354 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
14355 skip "LU-14160: punch mode is not implemented on OSD ZFS"
14358 check_set_fallocate_or_skip
14359 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14361 [[ "x$DOM" == "xyes" ]] &&
14362 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
14364 echo "Verify fallocate punch: Range within the file range"
14365 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
14366 error "dd failed for bs 4096 and count 5"
14368 # Call fallocate with punch range which is within the file range
14369 fallocate -p --offset 4096 -l $length $DIR/$tfile ||
14370 error "fallocate failed: offset 4096 and length $length"
14371 # client must see changes immediately after fallocate
14372 size=$(stat -c '%s' $DIR/$tfile)
14373 blocks=$(stat -c '%b' $DIR/$tfile)
14375 # Verify punch worked.
14376 (( blocks == want_blocks_after )) ||
14377 error "punch failed: blocks $blocks != $want_blocks_after"
14379 (( size == want_size_before )) ||
14380 error "punch failed: size $size != $want_size_before"
14382 # Verify there is hole in file
14383 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
14384 # precomputed md5sum
14385 local expect="4a9a834a2db02452929c0a348273b4aa"
14387 cksum=($(md5sum $DIR/$tfile))
14388 [[ "${cksum[0]}" == "$expect" ]] ||
14389 error "unexpected MD5SUM after punch: ${cksum[0]}"
14391 # Start second sub-case for fallocate punch.
14392 echo "Verify fallocate punch: Range overlapping and less than blocksize"
14393 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
14394 error "dd failed for bs 4096 and count 5"
14396 # Punch range less than block size will have no change in block count
14397 want_blocks_after=40 # 512 sized blocks
14399 # Punch overlaps two blocks and less than blocksize
14400 fallocate -p --offset 4000 -l 3000 $DIR/$tfile ||
14401 error "fallocate failed: offset 4000 length 3000"
14402 size=$(stat -c '%s' $DIR/$tfile)
14403 blocks=$(stat -c '%b' $DIR/$tfile)
14405 # Verify punch worked.
14406 (( blocks == want_blocks_after )) ||
14407 error "punch failed: blocks $blocks != $want_blocks_after"
14409 (( size == want_size_before )) ||
14410 error "punch failed: size $size != $want_size_before"
14412 # Verify if range is really zero'ed out. We expect Zeros.
14413 # precomputed md5sum
14414 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
14415 cksum=($(md5sum $DIR/$tfile))
14416 [[ "${cksum[0]}" == "$expect" ]] ||
14417 error "unexpected MD5SUM after punch: ${cksum[0]}"
14419 run_test 150f "Verify fallocate punch functionality"
14427 local BS=4096 # Block size in bytes
14429 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
14430 skip "need at least 2.14.0 for fallocate punch"
14432 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
14433 skip "LU-14160: punch mode is not implemented on OSD ZFS"
14436 check_set_fallocate_or_skip
14437 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14439 if [[ "x$DOM" == "xyes" ]]; then
14440 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
14441 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
14443 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
14444 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
14447 # Get 100MB per OST of the available space to reduce run time
14448 # else 60% of the available space if we are running SLOW tests
14449 if [ $SLOW == "no" ]; then
14450 space=$((1024 * 100 * OSTCOUNT))
14452 # Find OST with Minimum Size
14453 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
14454 sort -un | head -1)
14455 echo "min size OST: $space"
14456 space=$(((space * 60)/100 * OSTCOUNT))
14458 # space in 1k units, round to 4k blocks
14459 local blkcount=$((space * 1024 / $BS))
14461 echo "Verify fallocate punch: Very large Range"
14462 fallocate -l${space}k $DIR/$tfile ||
14463 error "fallocate ${space}k $DIR/$tfile failed"
14464 # write 1M at the end, start and in the middle
14465 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
14466 error "dd failed: bs $BS count 256"
14467 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
14468 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
14469 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
14470 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
14473 size=$(stat -c '%s' $DIR/$tfile)
14475 # gather punch length.
14476 local punch_size=$((size - (BS * 2)))
14478 echo "punch_size = $punch_size"
14479 echo "size - punch_size: $((size - punch_size))"
14480 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
14482 # Call fallocate to punch all except 2 blocks. We leave the
14483 # first and the last block
14484 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
14485 fallocate -p --offset $BS -l $punch_size $DIR/$tfile ||
14486 error "fallocate failed: offset $BS length $punch_size"
14488 size_after=$(stat -c '%s' $DIR/$tfile)
14489 blocks_after=$(stat -c '%b' $DIR/$tfile)
14491 # Verify punch worked.
14492 # Size should be kept
14493 (( size == size_after )) ||
14494 error "punch failed: size $size != $size_after"
14496 # two 4k data blocks to remain plus possible 1 extra extent block
14497 (( blocks_after <= ((BS / 512) * 3) )) ||
14498 error "too many blocks remains: $blocks_after"
14500 # Verify that file has hole between the first and the last blocks
14501 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
14502 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
14504 echo "Hole at [$hole_start, $hole_end)"
14505 (( hole_start == BS )) ||
14506 error "no hole at offset $BS after punch"
14508 (( hole_end == BS + punch_size )) ||
14509 error "data at offset $hole_end < $((BS + punch_size))"
14511 run_test 150g "Verify fallocate punch on large range"
14513 #LU-2902 roc_hit was not able to read all values from lproc
14514 function roc_hit_init() {
14515 local list=$(comma_list $(osts_nodes))
14516 local dir=$DIR/$tdir-check
14517 local file=$dir/$tfile
14523 #use setstripe to do a write to every ost
14524 for i in $(seq 0 $((OSTCOUNT-1))); do
14525 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
14526 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
14527 idx=$(printf %04x $i)
14528 BEFORE=$(get_osd_param $list *OST*$idx stats |
14529 awk '$1 == "cache_access" {sum += $7}
14530 END { printf("%0.0f", sum) }')
14532 cancel_lru_locks osc
14533 cat $file >/dev/null
14535 AFTER=$(get_osd_param $list *OST*$idx stats |
14536 awk '$1 == "cache_access" {sum += $7}
14537 END { printf("%0.0f", sum) }')
14539 echo BEFORE:$BEFORE AFTER:$AFTER
14540 if ! let "AFTER - BEFORE == 4"; then
14542 error "roc_hit is not safe to use"
14550 function roc_hit() {
14551 local list=$(comma_list $(osts_nodes))
14552 echo $(get_osd_param $list '' stats |
14553 awk '$1 == "cache_hit" {sum += $7}
14554 END { printf("%0.0f", sum) }')
14557 function set_cache() {
14560 if [ "$2" == "off" ]; then
14563 local list=$(comma_list $(osts_nodes))
14564 set_osd_param $list '' $1_cache_enable $on
14566 cancel_lru_locks osc
14570 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14571 remote_ost_nodsh && skip "remote OST with nodsh"
14574 local list=$(comma_list $(osts_nodes))
14576 # check whether obdfilter is cache capable at all
14577 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
14578 skip "not cache-capable obdfilter"
14581 # check cache is enabled on all obdfilters
14582 if get_osd_param $list '' read_cache_enable | grep 0; then
14583 skip "oss cache is disabled"
14586 set_osd_param $list '' writethrough_cache_enable 1
14588 # check write cache is enabled on all obdfilters
14589 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
14590 skip "oss write cache is NOT enabled"
14595 #define OBD_FAIL_OBD_NO_LRU 0x609
14596 do_nodes $list $LCTL set_param fail_loc=0x609
14598 # pages should be in the case right after write
14599 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
14602 local BEFORE=$(roc_hit)
14603 cancel_lru_locks osc
14604 cat $DIR/$tfile >/dev/null
14605 local AFTER=$(roc_hit)
14607 do_nodes $list $LCTL set_param fail_loc=0
14609 if ! let "AFTER - BEFORE == CPAGES"; then
14610 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
14613 cancel_lru_locks osc
14614 # invalidates OST cache
14615 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
14616 set_osd_param $list '' read_cache_enable 0
14617 cat $DIR/$tfile >/dev/null
14619 # now data shouldn't be found in the cache
14621 cancel_lru_locks osc
14622 cat $DIR/$tfile >/dev/null
14624 if let "AFTER - BEFORE != 0"; then
14625 error "IN CACHE: before: $BEFORE, after: $AFTER"
14628 set_osd_param $list '' read_cache_enable 1
14631 run_test 151 "test cache on oss and controls ==============================="
14634 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14636 local TF="$TMP/$tfile"
14638 # simulate ENOMEM during write
14639 #define OBD_FAIL_OST_NOMEM 0x226
14640 lctl set_param fail_loc=0x80000226
14641 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
14643 sync || error "sync failed"
14644 lctl set_param fail_loc=0
14646 # discard client's cache
14647 cancel_lru_locks osc
14649 # simulate ENOMEM during read
14650 lctl set_param fail_loc=0x80000226
14651 cmp $TF $DIR/$tfile || error "cmp failed"
14652 lctl set_param fail_loc=0
14656 run_test 152 "test read/write with enomem ============================"
14659 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
14661 run_test 153 "test if fdatasync does not crash ======================="
14663 dot_lustre_fid_permission_check() {
14665 local ffid=$MOUNT/.lustre/fid/$fid
14668 echo "stat fid $fid"
14669 stat $ffid > /dev/null || error "stat $ffid failed."
14670 echo "touch fid $fid"
14671 touch $ffid || error "touch $ffid failed."
14672 echo "write to fid $fid"
14673 cat /etc/hosts > $ffid || error "write $ffid failed."
14674 echo "read fid $fid"
14675 diff /etc/hosts $ffid || error "read $ffid failed."
14676 echo "append write to fid $fid"
14677 cat /etc/hosts >> $ffid || error "append write $ffid failed."
14678 echo "rename fid $fid"
14679 mv $ffid $test_dir/$tfile.1 &&
14680 error "rename $ffid to $tfile.1 should fail."
14681 touch $test_dir/$tfile.1
14682 mv $test_dir/$tfile.1 $ffid &&
14683 error "rename $tfile.1 to $ffid should fail."
14684 rm -f $test_dir/$tfile.1
14685 echo "truncate fid $fid"
14686 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
14687 echo "link fid $fid"
14688 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
14689 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
14690 echo "setfacl fid $fid"
14691 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
14692 echo "getfacl fid $fid"
14693 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
14695 echo "unlink fid $fid"
14696 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
14697 echo "mknod fid $fid"
14698 mknod $ffid c 1 3 && error "mknod $ffid should fail."
14700 fid=[0xf00000400:0x1:0x0]
14701 ffid=$MOUNT/.lustre/fid/$fid
14703 echo "stat non-exist fid $fid"
14704 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
14705 echo "write to non-exist fid $fid"
14706 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
14707 echo "link new fid $fid"
14708 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
14710 mkdir -p $test_dir/$tdir
14711 touch $test_dir/$tdir/$tfile
14712 fid=$($LFS path2fid $test_dir/$tdir)
14715 error "error: could not get fid for $test_dir/$dir/$tfile."
14717 ffid=$MOUNT/.lustre/fid/$fid
14720 ls $ffid > /dev/null || error "ls $ffid failed."
14721 echo "touch $fid/$tfile.1"
14722 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
14724 echo "touch $MOUNT/.lustre/fid/$tfile"
14725 touch $MOUNT/.lustre/fid/$tfile && \
14726 error "touch $MOUNT/.lustre/fid/$tfile should fail."
14728 echo "setxattr to $MOUNT/.lustre/fid"
14729 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
14731 echo "listxattr for $MOUNT/.lustre/fid"
14732 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
14734 echo "delxattr from $MOUNT/.lustre/fid"
14735 setfattr -x trusted.name1 $MOUNT/.lustre/fid
14737 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
14738 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
14739 error "touch invalid fid should fail."
14741 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
14742 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
14743 error "touch non-normal fid should fail."
14745 echo "rename $tdir to $MOUNT/.lustre/fid"
14746 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
14747 error "rename to $MOUNT/.lustre/fid should fail."
14749 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
14751 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
14752 local new_obf_mode=777
14754 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
14755 chmod $new_obf_mode $DIR/.lustre/fid ||
14756 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
14758 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
14759 [ $obf_mode -eq $new_obf_mode ] ||
14760 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
14762 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
14763 chmod $old_obf_mode $DIR/.lustre/fid ||
14764 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
14767 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
14768 fid=$($LFS path2fid $test_dir/$tfile-2)
14770 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
14772 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
14773 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
14774 error "create lov data thru .lustre failed"
14776 echo "cp /etc/passwd $test_dir/$tfile-2"
14777 cp /etc/passwd $test_dir/$tfile-2 ||
14778 error "copy to $test_dir/$tfile-2 failed."
14779 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
14780 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
14781 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
14783 rm -rf $test_dir/tfile.lnk
14784 rm -rf $test_dir/$tfile-2
14788 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
14789 skip "Need MDS version at least 2.4.1"
14791 local tf=$DIR/$tfile
14794 local fid=$($LFS path2fid $tf)
14795 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
14797 # check that we get the same pathname back
14800 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
14801 echo "$rootpath $fid"
14802 found=$($LFS fid2path $rootpath "$fid")
14803 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
14804 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
14807 # check wrong root path format
14808 rootpath=$MOUNT"_wrong"
14809 found=$($LFS fid2path $rootpath "$fid")
14810 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
14812 run_test 154A "lfs path2fid and fid2path basic checks"
14815 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
14816 skip "Need MDS version at least 2.4.1"
14818 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
14819 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
14820 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
14821 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
14823 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
14824 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
14826 # check that we get the same pathname
14827 echo "PFID: $PFID, name: $name"
14828 local FOUND=$($LFS fid2path $MOUNT "$PFID")
14829 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
14830 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
14831 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
14833 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
14835 run_test 154B "verify the ll_decode_linkea tool"
14838 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14839 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14840 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
14841 skip "Need MDS version at least 2.2.51"
14842 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
14844 cp /etc/hosts $DIR/$tfile
14846 fid=$($LFS path2fid $DIR/$tfile)
14848 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
14850 dot_lustre_fid_permission_check "$fid" $DIR ||
14851 error "dot lustre permission check $fid failed"
14853 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
14855 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
14857 touch $MOUNT/.lustre/file &&
14858 error "creation is not allowed under .lustre"
14860 mkdir $MOUNT/.lustre/dir &&
14861 error "mkdir is not allowed under .lustre"
14865 run_test 154a "Open-by-FID"
14868 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14869 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14870 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14871 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
14872 skip "Need MDS version at least 2.2.51"
14874 local remote_dir=$DIR/$tdir/remote_dir
14878 mkdir -p $DIR/$tdir
14879 $LFS mkdir -i $MDTIDX $remote_dir ||
14880 error "create remote directory failed"
14882 cp /etc/hosts $remote_dir/$tfile
14884 fid=$($LFS path2fid $remote_dir/$tfile)
14886 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
14888 dot_lustre_fid_permission_check "$fid" $remote_dir ||
14889 error "dot lustre permission check $fid failed"
14892 run_test 154b "Open-by-FID for remote directory"
14895 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
14896 skip "Need MDS version at least 2.4.1"
14898 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
14899 local FID1=$($LFS path2fid $DIR/$tfile.1)
14900 local FID2=$($LFS path2fid $DIR/$tfile.2)
14901 local FID3=$($LFS path2fid $DIR/$tfile.3)
14904 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
14905 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
14906 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
14908 [ "$FID" = "${!want}" ] ||
14909 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
14913 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
14915 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
14916 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
14920 run_test 154c "lfs path2fid and fid2path multiple arguments"
14923 remote_mds_nodsh && skip "remote MDS with nodsh"
14924 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
14925 skip "Need MDS version at least 2.5.53"
14927 if remote_mds; then
14928 nid=$($LCTL list_nids | sed "s/\./\\\./g")
14932 local proc_ofile="mdt.*.exports.'$nid'.open_files"
14939 local fid=$($LFS path2fid $DIR/$tfile)
14942 cmd="exec $fd<$DIR/$tfile"
14944 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
14945 echo "$fid_list" | grep "$fid"
14948 cmd="exec $fd>/dev/null"
14950 if [ $rc -ne 0 ]; then
14951 error "FID $fid not found in open files list $fid_list"
14954 run_test 154d "Verify open file fid"
14958 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
14959 skip "Need MDS version at least 2.6.50"
14961 if ls -a $MOUNT | grep -q '^\.lustre$'; then
14962 error ".lustre returned by readdir"
14965 run_test 154e ".lustre is not returned by readdir"
14968 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14970 # create parent directory on a single MDT to avoid cross-MDT hardlinks
14971 mkdir_on_mdt0 $DIR/$tdir
14972 # test dirs inherit from its stripe
14973 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
14974 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
14975 cp /etc/hosts $DIR/$tdir/foo1/$tfile
14976 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
14979 # get fid of parents
14980 local FID0=$($LFS path2fid $DIR/$tdir)
14981 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
14982 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
14983 local FID3=$($LFS path2fid $DIR)
14985 # check that path2fid --parents returns expected <parent_fid>/name
14986 # 1) test for a directory (single parent)
14987 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
14988 [ "$parent" == "$FID0/foo1" ] ||
14989 error "expected parent: $FID0/foo1, got: $parent"
14991 # 2) test for a file with nlink > 1 (multiple parents)
14992 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
14993 echo "$parent" | grep -F "$FID1/$tfile" ||
14994 error "$FID1/$tfile not returned in parent list"
14995 echo "$parent" | grep -F "$FID2/link" ||
14996 error "$FID2/link not returned in parent list"
14998 # 3) get parent by fid
14999 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
15000 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15001 echo "$parent" | grep -F "$FID1/$tfile" ||
15002 error "$FID1/$tfile not returned in parent list (by fid)"
15003 echo "$parent" | grep -F "$FID2/link" ||
15004 error "$FID2/link not returned in parent list (by fid)"
15006 # 4) test for entry in root directory
15007 parent=$($LFS path2fid --parents $DIR/f)
15008 echo "$parent" | grep -F "$FID3/f" ||
15009 error "$FID3/f not returned in parent list"
15011 # 5) test it on root directory
15012 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
15013 error "$MOUNT should not have parents"
15015 # enable xattr caching and check that linkea is correctly updated
15016 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
15017 save_lustre_params client "llite.*.xattr_cache" > $save
15018 lctl set_param llite.*.xattr_cache 1
15020 # 6.1) linkea update on rename
15021 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
15023 # get parents by fid
15024 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15025 # foo1 should no longer be returned in parent list
15026 echo "$parent" | grep -F "$FID1" &&
15027 error "$FID1 should no longer be in parent list"
15028 # the new path should appear
15029 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
15030 error "$FID2/$tfile.moved is not in parent list"
15032 # 6.2) linkea update on unlink
15033 rm -f $DIR/$tdir/foo2/link
15034 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15035 # foo2/link should no longer be returned in parent list
15036 echo "$parent" | grep -F "$FID2/link" &&
15037 error "$FID2/link should no longer be in parent list"
15041 restore_lustre_params < $save
15044 run_test 154f "get parent fids by reading link ea"
15048 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15049 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
15050 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
15051 skip "Need MDS version at least 2.6.92"
15053 mkdir_on_mdt0 $DIR/$tdir
15054 llapi_fid_test -d $DIR/$tdir
15056 run_test 154g "various llapi FID tests"
15058 test_155_small_load() {
15059 local temp=$TMP/$tfile
15060 local file=$DIR/$tfile
15062 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
15063 error "dd of=$temp bs=6096 count=1 failed"
15065 cancel_lru_locks $OSC
15066 cmp $temp $file || error "$temp $file differ"
15068 $TRUNCATE $temp 6000
15069 $TRUNCATE $file 6000
15070 cmp $temp $file || error "$temp $file differ (truncate1)"
15072 echo "12345" >>$temp
15073 echo "12345" >>$file
15074 cmp $temp $file || error "$temp $file differ (append1)"
15076 echo "12345" >>$temp
15077 echo "12345" >>$file
15078 cmp $temp $file || error "$temp $file differ (append2)"
15084 test_155_big_load() {
15085 remote_ost_nodsh && skip "remote OST with nodsh"
15087 local temp=$TMP/$tfile
15088 local file=$DIR/$tfile
15091 local cache_size=$(do_facet ost$((MAXI+1)) \
15092 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
15093 local large_file_size=$((cache_size * 2))
15095 echo "OSS cache size: $cache_size KB"
15096 echo "Large file size: $large_file_size KB"
15098 [ $MAXV -le $large_file_size ] &&
15099 skip_env "max available OST size needs > $large_file_size KB"
15101 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
15103 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
15104 error "dd of=$temp bs=$large_file_size count=1k failed"
15107 cancel_lru_locks osc
15108 cmp $temp $file || error "$temp $file differ"
15114 save_writethrough() {
15115 local facets=$(get_facets OST)
15117 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
15121 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15123 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15125 save_writethrough $p
15128 set_cache writethrough on
15129 test_155_small_load
15130 restore_lustre_params < $p
15133 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
15136 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15138 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15140 save_writethrough $p
15143 set_cache writethrough off
15144 test_155_small_load
15145 restore_lustre_params < $p
15148 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
15151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15153 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15155 save_writethrough $p
15158 set_cache writethrough on
15159 test_155_small_load
15160 restore_lustre_params < $p
15163 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
15166 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15168 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15170 save_writethrough $p
15173 set_cache writethrough off
15174 test_155_small_load
15175 restore_lustre_params < $p
15178 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
15181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15183 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15185 save_writethrough $p
15188 set_cache writethrough on
15190 restore_lustre_params < $p
15193 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
15196 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15198 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15200 save_writethrough $p
15203 set_cache writethrough off
15205 restore_lustre_params < $p
15208 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
15211 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15213 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15215 save_writethrough $p
15218 set_cache writethrough on
15220 restore_lustre_params < $p
15223 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
15226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15228 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15230 save_writethrough $p
15233 set_cache writethrough off
15235 restore_lustre_params < $p
15238 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
15241 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15242 remote_ost_nodsh && skip "remote OST with nodsh"
15243 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
15244 skip "stats not implemented on old servers"
15245 [ "$ost1_FSTYPE" = "zfs" ] &&
15246 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
15251 local file="$DIR/$tfile"
15252 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15254 save_writethrough $p
15257 log "Turn on read and write cache"
15259 set_cache writethrough on
15261 log "Write data and read it back."
15262 log "Read should be satisfied from the cache."
15263 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15265 cancel_lru_locks osc
15266 cat $file >/dev/null
15268 if ! let "AFTER - BEFORE == CPAGES"; then
15269 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
15271 log "cache hits: before: $BEFORE, after: $AFTER"
15274 log "Read again; it should be satisfied from the cache."
15276 cancel_lru_locks osc
15277 cat $file >/dev/null
15279 if ! let "AFTER - BEFORE == CPAGES"; then
15280 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
15282 log "cache hits:: before: $BEFORE, after: $AFTER"
15285 log "Turn off the read cache and turn on the write cache"
15287 set_cache writethrough on
15289 log "Read again; it should be satisfied from the cache."
15291 cancel_lru_locks osc
15292 cat $file >/dev/null
15294 if ! let "AFTER - BEFORE == CPAGES"; then
15295 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
15297 log "cache hits:: before: $BEFORE, after: $AFTER"
15300 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
15301 # > 2.12.56 uses pagecache if cached
15302 log "Read again; it should not be satisfied from the cache."
15304 cancel_lru_locks osc
15305 cat $file >/dev/null
15307 if ! let "AFTER - BEFORE == 0"; then
15308 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
15310 log "cache hits:: before: $BEFORE, after: $AFTER"
15314 log "Write data and read it back."
15315 log "Read should be satisfied from the cache."
15316 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15318 cancel_lru_locks osc
15319 cat $file >/dev/null
15321 if ! let "AFTER - BEFORE == CPAGES"; then
15322 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
15324 log "cache hits:: before: $BEFORE, after: $AFTER"
15327 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
15328 # > 2.12.56 uses pagecache if cached
15329 log "Read again; it should not be satisfied from the cache."
15331 cancel_lru_locks osc
15332 cat $file >/dev/null
15334 if ! let "AFTER - BEFORE == 0"; then
15335 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
15337 log "cache hits:: before: $BEFORE, after: $AFTER"
15341 log "Turn off read and write cache"
15343 set_cache writethrough off
15345 log "Write data and read it back"
15346 log "It should not be satisfied from the cache."
15348 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15349 cancel_lru_locks osc
15351 cat $file >/dev/null
15353 if ! let "AFTER - BEFORE == 0"; then
15354 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
15356 log "cache hits:: before: $BEFORE, after: $AFTER"
15359 log "Turn on the read cache and turn off the write cache"
15361 set_cache writethrough off
15363 log "Write data and read it back"
15364 log "It should not be satisfied from the cache."
15366 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15368 cancel_lru_locks osc
15369 cat $file >/dev/null
15371 if ! let "AFTER - BEFORE == 0"; then
15372 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
15374 log "cache hits:: before: $BEFORE, after: $AFTER"
15377 log "Read again; it should be satisfied from the cache."
15379 cancel_lru_locks osc
15380 cat $file >/dev/null
15382 if ! let "AFTER - BEFORE == CPAGES"; then
15383 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
15385 log "cache hits:: before: $BEFORE, after: $AFTER"
15388 restore_lustre_params < $p
15391 run_test 156 "Verification of tunables"
15394 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15395 remote_mds_nodsh && skip "remote MDS with nodsh"
15396 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
15397 skip "Need MDS version at least 2.2.0"
15399 changelog_register || error "changelog_register failed"
15400 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
15401 changelog_users $SINGLEMDS | grep -q $cl_user ||
15402 error "User $cl_user not found in changelog_users"
15404 mkdir_on_mdt0 $DIR/$tdir
15407 test_mkdir -p $DIR/$tdir/pics/2008/zachy
15408 changelog_clear 0 || error "changelog_clear failed"
15409 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
15410 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
15411 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
15412 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
15413 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
15414 rm $DIR/$tdir/pics/desktop.jpg
15416 echo "verifying changelog mask"
15417 changelog_chmask "-MKDIR"
15418 changelog_chmask "-CLOSE"
15420 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
15421 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
15423 changelog_chmask "+MKDIR"
15424 changelog_chmask "+CLOSE"
15426 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
15427 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
15429 MKDIRS=$(changelog_dump | grep -c "MKDIR")
15430 CLOSES=$(changelog_dump | grep -c "CLOSE")
15431 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
15432 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
15435 echo "verifying target fid"
15436 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
15437 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
15438 [ "$fidc" == "$fidf" ] ||
15439 error "changelog '$tfile' fid $fidc != file fid $fidf"
15440 echo "verifying parent fid"
15441 # The FID returned from the Changelog may be the directory shard on
15442 # a different MDT, and not the FID returned by path2fid on the parent.
15443 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
15444 # since this is what will matter when recreating this file in the tree.
15445 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
15446 local pathp=$($LFS fid2path $MOUNT "$fidp")
15447 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
15448 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
15450 echo "getting records for $cl_user"
15451 changelog_users $SINGLEMDS
15452 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
15454 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
15455 error "changelog_clear failed"
15456 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
15457 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
15458 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
15459 error "user index expect $user_rec1 + $nclr != $user_rec2"
15461 local min0_rec=$(changelog_users $SINGLEMDS |
15462 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
15463 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
15464 awk '{ print $1; exit; }')
15466 changelog_dump | tail -n 5
15467 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
15468 [ $first_rec == $((min0_rec + 1)) ] ||
15469 error "first index should be $min0_rec + 1 not $first_rec"
15471 # LU-3446 changelog index reset on MDT restart
15472 local cur_rec1=$(changelog_users $SINGLEMDS |
15473 awk '/^current.index:/ { print $NF }')
15474 changelog_clear 0 ||
15475 error "clear all changelog records for $cl_user failed"
15476 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
15477 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
15478 error "Fail to start $SINGLEMDS"
15479 local cur_rec2=$(changelog_users $SINGLEMDS |
15480 awk '/^current.index:/ { print $NF }')
15481 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
15482 [ $cur_rec1 == $cur_rec2 ] ||
15483 error "current index should be $cur_rec1 not $cur_rec2"
15485 echo "verifying users from this test are deregistered"
15486 changelog_deregister || error "changelog_deregister failed"
15487 changelog_users $SINGLEMDS | grep -q $cl_user &&
15488 error "User '$cl_user' still in changelog_users"
15490 # lctl get_param -n mdd.*.changelog_users
15491 # current_index: 144
15492 # ID index (idle seconds)
15493 # cl3 144 (2) mask=<list>
15494 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
15495 # this is the normal case where all users were deregistered
15496 # make sure no new records are added when no users are present
15497 local last_rec1=$(changelog_users $SINGLEMDS |
15498 awk '/^current.index:/ { print $NF }')
15499 touch $DIR/$tdir/chloe
15500 local last_rec2=$(changelog_users $SINGLEMDS |
15501 awk '/^current.index:/ { print $NF }')
15502 echo "verify changelogs are off: $last_rec1 == $last_rec2"
15503 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
15505 # any changelog users must be leftovers from a previous test
15506 changelog_users $SINGLEMDS
15507 echo "other changelog users; can't verify off"
15510 run_test 160a "changelog sanity"
15512 test_160b() { # LU-3587
15513 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15514 remote_mds_nodsh && skip "remote MDS with nodsh"
15515 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
15516 skip "Need MDS version at least 2.2.0"
15518 changelog_register || error "changelog_register failed"
15519 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
15520 changelog_users $SINGLEMDS | grep -q $cl_user ||
15521 error "User '$cl_user' not found in changelog_users"
15523 local longname1=$(str_repeat a 255)
15524 local longname2=$(str_repeat b 255)
15527 echo "creating very long named file"
15528 touch $longname1 || error "create of '$longname1' failed"
15529 echo "renaming very long named file"
15530 mv $longname1 $longname2
15532 changelog_dump | grep RENME | tail -n 5
15535 run_test 160b "Verify that very long rename doesn't crash in changelog"
15538 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15539 remote_mds_nodsh && skip "remote MDS with nodsh"
15541 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
15542 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
15543 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
15544 skip "Need MDS version at least 2.5.58 or 2.5.2+"
15548 # Registration step
15549 changelog_register || error "changelog_register failed"
15552 mkdir -p $DIR/$tdir
15553 $MCREATE $DIR/$tdir/foo_160c
15554 changelog_chmask "-TRUNC"
15555 $TRUNCATE $DIR/$tdir/foo_160c 200
15556 changelog_chmask "+TRUNC"
15557 $TRUNCATE $DIR/$tdir/foo_160c 199
15558 changelog_dump | tail -n 5
15559 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
15560 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
15562 run_test 160c "verify that changelog log catch the truncate event"
15565 remote_mds_nodsh && skip "remote MDS with nodsh"
15566 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15567 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15568 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
15569 skip "Need MDS version at least 2.7.60"
15571 # Registration step
15572 changelog_register || error "changelog_register failed"
15574 mkdir -p $DIR/$tdir/migrate_dir
15575 changelog_clear 0 || error "changelog_clear failed"
15577 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
15578 changelog_dump | tail -n 5
15579 local migrates=$(changelog_dump | grep -c "MIGRT")
15580 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
15582 run_test 160d "verify that changelog log catch the migrate event"
15585 remote_mds_nodsh && skip "remote MDS with nodsh"
15588 changelog_register || error "changelog_register failed"
15590 local MDT0=$(facet_svc $SINGLEMDS)
15593 # No user (expect fail)
15594 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
15596 if [ $rc -eq 0 ]; then
15597 error "Should fail without user"
15598 elif [ $rc -ne 4 ]; then
15599 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
15602 # Delete a future user (expect fail)
15603 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
15605 if [ $rc -eq 0 ]; then
15606 error "Deleted non-existant user cl77"
15607 elif [ $rc -ne 2 ]; then
15608 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
15611 # Clear to a bad index (1 billion should be safe)
15612 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
15615 if [ $rc -eq 0 ]; then
15616 error "Successfully cleared to invalid CL index"
15617 elif [ $rc -ne 22 ]; then
15618 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
15621 run_test 160e "changelog negative testing (should return errors)"
15624 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15625 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
15626 skip "Need MDS version at least 2.10.56"
15628 local mdts=$(comma_list $(mdts_nodes))
15631 changelog_register || error "first changelog_register failed"
15632 changelog_register || error "second changelog_register failed"
15634 declare -A cl_user1
15635 declare -A cl_user2
15640 # generate some changelog records to accumulate on each MDT
15641 # use all_char because created files should be evenly distributed
15642 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
15643 error "test_mkdir $tdir failed"
15644 log "$(date +%s): creating first files"
15645 for ((i = 0; i < MDSCOUNT * 2; i++)); do
15646 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
15647 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
15650 # check changelogs have been generated
15651 local start=$SECONDS
15652 local idle_time=$((MDSCOUNT * 5 + 5))
15653 local nbcl=$(changelog_dump | wc -l)
15654 [[ $nbcl -eq 0 ]] && error "no changelogs found"
15656 for param in "changelog_max_idle_time=$idle_time" \
15658 "changelog_min_gc_interval=2" \
15659 "changelog_min_free_cat_entries=3"; do
15660 local MDT0=$(facet_svc $SINGLEMDS)
15661 local var="${param%=*}"
15662 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
15664 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
15665 do_nodes $mdts $LCTL set_param mdd.*.$param
15668 # force cl_user2 to be idle (1st part), but also cancel the
15669 # cl_user1 records so that it is not evicted later in the test.
15670 local sleep1=$((idle_time / 2))
15671 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
15674 # simulate changelog catalog almost full
15675 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
15676 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
15678 for i in $(seq $MDSCOUNT); do
15679 cl_users=(${CL_USERS[mds$i]})
15680 cl_user1[mds$i]="${cl_users[0]}"
15681 cl_user2[mds$i]="${cl_users[1]}"
15683 [ -n "${cl_user1[mds$i]}" ] ||
15684 error "mds$i: no user registered"
15685 [ -n "${cl_user2[mds$i]}" ] ||
15686 error "mds$i: only ${cl_user2[mds$i]} is registered"
15688 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15689 [ -n "$user_rec1" ] ||
15690 error "mds$i: User ${cl_user1[mds$i]} not registered"
15691 __changelog_clear mds$i ${cl_user1[mds$i]} +2
15692 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15693 [ -n "$user_rec2" ] ||
15694 error "mds$i: User ${cl_user1[mds$i]} not registered"
15695 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
15696 "$user_rec1 + 2 == $user_rec2"
15697 [ $((user_rec1 + 2)) == $user_rec2 ] ||
15698 error "mds$i: user ${cl_user1[mds$i]} index expected " \
15699 "$user_rec1 + 2, but is $user_rec2"
15700 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
15701 [ -n "$user_rec2" ] ||
15702 error "mds$i: User ${cl_user2[mds$i]} not registered"
15703 [ $user_rec1 == $user_rec2 ] ||
15704 error "mds$i: user ${cl_user2[mds$i]} index expected " \
15705 "$user_rec1, but is $user_rec2"
15708 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
15709 local sleep2=$((idle_time - (SECONDS - start) + 1))
15710 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
15713 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
15714 # cl_user1 should be OK because it recently processed records.
15715 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
15716 for ((i = 0; i < MDSCOUNT * 2; i++)); do
15717 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
15718 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
15721 # ensure gc thread is done
15722 for i in $(mdts_nodes); do
15723 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
15724 error "$i: GC-thread not done"
15728 for (( i = 1; i <= MDSCOUNT; i++ )); do
15729 # check cl_user1 still registered
15730 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
15731 error "mds$i: User ${cl_user1[mds$i]} not registered"
15732 # check cl_user2 unregistered
15733 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
15734 error "mds$i: User ${cl_user2[mds$i]} still registered"
15736 # check changelogs are present and starting at $user_rec1 + 1
15737 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15738 [ -n "$user_rec1" ] ||
15739 error "mds$i: User ${cl_user1[mds$i]} not registered"
15740 first_rec=$($LFS changelog $(facet_svc mds$i) |
15741 awk '{ print $1; exit; }')
15743 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
15744 [ $((user_rec1 + 1)) == $first_rec ] ||
15745 error "mds$i: rec $first_rec != $user_rec1 + 1"
15748 run_test 160f "changelog garbage collect (timestamped users)"
15751 remote_mds_nodsh && skip "remote MDS with nodsh"
15752 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
15753 skip "Need MDS version at least 2.10.56"
15755 local mdts=$(comma_list $(mdts_nodes))
15757 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
15758 do_nodes $mdts $LCTL set_param fail_loc=0x1314
15761 changelog_register || error "first changelog_register failed"
15762 changelog_register || error "second changelog_register failed"
15764 declare -A cl_user1
15765 declare -A cl_user2
15770 # generate some changelog records to accumulate on each MDT
15771 # use all_char because created files should be evenly distributed
15772 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
15773 error "test_mkdir $tdir failed"
15774 for ((i = 0; i < MDSCOUNT; i++)); do
15775 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
15776 error "create $DIR/$tdir/d$i.1 failed"
15779 # check changelogs have been generated
15780 local nbcl=$(changelog_dump | wc -l)
15781 (( $nbcl > 0 )) || error "no changelogs found"
15783 # reduce the max_idle_indexes value to make sure we exceed it
15784 for param in "changelog_max_idle_indexes=1" \
15786 "changelog_min_gc_interval=2" \
15787 "changelog_min_free_cat_entries=3"; do
15788 local MDT0=$(facet_svc $SINGLEMDS)
15789 local var="${param%=*}"
15790 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
15792 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
15793 do_nodes $mdts $LCTL set_param mdd.*.$param ||
15794 error "unable to set mdd.*.$param"
15797 # simulate changelog catalog almost full
15798 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
15799 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
15801 local start=$SECONDS
15802 for i in $(seq $MDSCOUNT); do
15803 cl_users=(${CL_USERS[mds$i]})
15804 cl_user1[mds$i]="${cl_users[0]}"
15805 cl_user2[mds$i]="${cl_users[1]}"
15807 [ -n "${cl_user1[mds$i]}" ] ||
15808 error "mds$i: no user registered"
15809 [ -n "${cl_user2[mds$i]}" ] ||
15810 error "mds$i: only ${cl_user1[mds$i]} is registered"
15812 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15813 [ -n "$user_rec1" ] ||
15814 error "mds$i: User ${cl_user1[mds$i]} not registered"
15815 __changelog_clear mds$i ${cl_user1[mds$i]} +2
15816 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15817 [ -n "$user_rec2" ] ||
15818 error "mds$i: User ${cl_user1[mds$i]} not registered"
15819 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
15820 "$user_rec1 + 2 == $user_rec2"
15821 [ $((user_rec1 + 2)) == $user_rec2 ] ||
15822 error "mds$i: user ${cl_user1[mds$i]} index expected " \
15823 "$user_rec1 + 2, but is $user_rec2"
15824 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
15825 [ -n "$user_rec2" ] ||
15826 error "mds$i: User ${cl_user2[mds$i]} not registered"
15827 [ $user_rec1 == $user_rec2 ] ||
15828 error "mds$i: user ${cl_user2[mds$i]} index expected " \
15829 "$user_rec1, but is $user_rec2"
15832 # ensure we are past the previous changelog_min_gc_interval set above
15833 local sleep2=$((start + 2 - SECONDS))
15834 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
15836 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
15837 # cl_user1 should be OK because it recently processed records.
15838 for ((i = 0; i < MDSCOUNT; i++)); do
15839 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
15840 error "create $DIR/$tdir/d$i.3 failed"
15843 # ensure gc thread is done
15844 for i in $(mdts_nodes); do
15845 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
15846 error "$i: GC-thread not done"
15850 for (( i = 1; i <= MDSCOUNT; i++ )); do
15851 # check cl_user1 still registered
15852 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
15853 error "mds$i: User ${cl_user1[mds$i]} not registered"
15854 # check cl_user2 unregistered
15855 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
15856 error "mds$i: User ${cl_user2[mds$i]} still registered"
15858 # check changelogs are present and starting at $user_rec1 + 1
15859 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15860 [ -n "$user_rec1" ] ||
15861 error "mds$i: User ${cl_user1[mds$i]} not registered"
15862 first_rec=$($LFS changelog $(facet_svc mds$i) |
15863 awk '{ print $1; exit; }')
15865 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
15866 [ $((user_rec1 + 1)) == $first_rec ] ||
15867 error "mds$i: rec $first_rec != $user_rec1 + 1"
15870 run_test 160g "changelog garbage collect (old users)"
15873 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15874 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
15875 skip "Need MDS version at least 2.10.56"
15877 local mdts=$(comma_list $(mdts_nodes))
15880 changelog_register || error "first changelog_register failed"
15881 changelog_register || error "second changelog_register failed"
15883 declare -A cl_user1
15884 declare -A cl_user2
15889 # generate some changelog records to accumulate on each MDT
15890 # use all_char because created files should be evenly distributed
15891 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
15892 error "test_mkdir $tdir failed"
15893 for ((i = 0; i < MDSCOUNT; i++)); do
15894 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
15895 error "create $DIR/$tdir/d$i.1 failed"
15898 # check changelogs have been generated
15899 local nbcl=$(changelog_dump | wc -l)
15900 [[ $nbcl -eq 0 ]] && error "no changelogs found"
15902 for param in "changelog_max_idle_time=10" \
15904 "changelog_min_gc_interval=2"; do
15905 local MDT0=$(facet_svc $SINGLEMDS)
15906 local var="${param%=*}"
15907 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
15909 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
15910 do_nodes $mdts $LCTL set_param mdd.*.$param
15913 # force cl_user2 to be idle (1st part)
15916 for i in $(seq $MDSCOUNT); do
15917 cl_users=(${CL_USERS[mds$i]})
15918 cl_user1[mds$i]="${cl_users[0]}"
15919 cl_user2[mds$i]="${cl_users[1]}"
15921 [ -n "${cl_user1[mds$i]}" ] ||
15922 error "mds$i: no user registered"
15923 [ -n "${cl_user2[mds$i]}" ] ||
15924 error "mds$i: only ${cl_user2[mds$i]} is registered"
15926 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15927 [ -n "$user_rec1" ] ||
15928 error "mds$i: User ${cl_user1[mds$i]} not registered"
15929 __changelog_clear mds$i ${cl_user1[mds$i]} +2
15930 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15931 [ -n "$user_rec2" ] ||
15932 error "mds$i: User ${cl_user1[mds$i]} not registered"
15933 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
15934 "$user_rec1 + 2 == $user_rec2"
15935 [ $((user_rec1 + 2)) == $user_rec2 ] ||
15936 error "mds$i: user ${cl_user1[mds$i]} index expected " \
15937 "$user_rec1 + 2, but is $user_rec2"
15938 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
15939 [ -n "$user_rec2" ] ||
15940 error "mds$i: User ${cl_user2[mds$i]} not registered"
15941 [ $user_rec1 == $user_rec2 ] ||
15942 error "mds$i: user ${cl_user2[mds$i]} index expected " \
15943 "$user_rec1, but is $user_rec2"
15946 # force cl_user2 to be idle (2nd part) and to reach
15947 # changelog_max_idle_time
15950 # force each GC-thread start and block then
15951 # one per MDT/MDD, set fail_val accordingly
15952 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
15953 do_nodes $mdts $LCTL set_param fail_loc=0x1316
15955 # generate more changelogs to trigger fail_loc
15956 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
15957 error "create $DIR/$tdir/${tfile}bis failed"
15959 # stop MDT to stop GC-thread, should be done in back-ground as it will
15960 # block waiting for the thread to be released and exit
15961 declare -A stop_pids
15962 for i in $(seq $MDSCOUNT); do
15964 stop_pids[mds$i]=$!
15967 for i in $(mdts_nodes); do
15970 local facets=$(facets_up_on_host $i)
15972 for facet in ${facets//,/ }; do
15973 if [[ $facet == mds* ]]; then
15977 # ensure each MDS's gc threads are still present and all in "R"
15978 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
15979 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
15980 error "$i: expected $nb GC-thread"
15982 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
15984 error "$i: GC-thread not found in R-state"
15985 # check umounts of each MDT on MDS have reached kthread_stop()
15986 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
15987 error "$i: expected $nb umount"
15989 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
15990 error "$i: umount not found in D-state"
15993 # release all GC-threads
15994 do_nodes $mdts $LCTL set_param fail_loc=0
15996 # wait for MDT stop to complete
15997 for i in $(seq $MDSCOUNT); do
15998 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
16002 # may try to check if any orphan changelog records are present
16003 # via ldiskfs/zfs and llog_reader...
16005 # re-start/mount MDTs
16006 for i in $(seq $MDSCOUNT); do
16007 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
16008 error "Fail to start mds$i"
16012 for i in $(seq $MDSCOUNT); do
16013 # check cl_user1 still registered
16014 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16015 error "mds$i: User ${cl_user1[mds$i]} not registered"
16016 # check cl_user2 unregistered
16017 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16018 error "mds$i: User ${cl_user2[mds$i]} still registered"
16020 # check changelogs are present and starting at $user_rec1 + 1
16021 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16022 [ -n "$user_rec1" ] ||
16023 error "mds$i: User ${cl_user1[mds$i]} not registered"
16024 first_rec=$($LFS changelog $(facet_svc mds$i) |
16025 awk '{ print $1; exit; }')
16027 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
16028 [ $((user_rec1 + 1)) == $first_rec ] ||
16029 error "mds$i: first index should be $user_rec1 + 1, " \
16030 "but is $first_rec"
16033 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
16038 local mdts=$(comma_list $(mdts_nodes))
16040 changelog_register || error "first changelog_register failed"
16042 # generate some changelog records to accumulate on each MDT
16043 # use all_char because created files should be evenly distributed
16044 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16045 error "test_mkdir $tdir failed"
16046 for ((i = 0; i < MDSCOUNT; i++)); do
16047 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16048 error "create $DIR/$tdir/d$i.1 failed"
16051 # check changelogs have been generated
16052 local nbcl=$(changelog_dump | wc -l)
16053 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16055 # simulate race between register and unregister
16056 # XXX as fail_loc is set per-MDS, with DNE configs the race
16057 # simulation will only occur for one MDT per MDS and for the
16058 # others the normal race scenario will take place
16059 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
16060 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
16061 do_nodes $mdts $LCTL set_param fail_val=1
16063 # unregister 1st user
16064 changelog_deregister &
16066 # wait some time for deregister work to reach race rdv
16068 # register 2nd user
16069 changelog_register || error "2nd user register failed"
16071 wait $pid1 || error "1st user deregister failed"
16075 declare -A LAST_REC
16076 for i in $(seq $MDSCOUNT); do
16077 if changelog_users mds$i | grep "^cl"; then
16078 # make sure new records are added with one user present
16079 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
16080 awk '/^current.index:/ { print $NF }')
16082 error "mds$i has no user registered"
16086 # generate more changelog records to accumulate on each MDT
16087 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16088 error "create $DIR/$tdir/${tfile}bis failed"
16090 for i in $(seq $MDSCOUNT); do
16091 last_rec=$(changelog_users $SINGLEMDS |
16092 awk '/^current.index:/ { print $NF }')
16093 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
16094 [ $last_rec != ${LAST_REC[mds$i]} ] ||
16095 error "changelogs are off on mds$i"
16098 run_test 160i "changelog user register/unregister race"
16101 remote_mds_nodsh && skip "remote MDS with nodsh"
16102 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
16103 skip "Need MDS version at least 2.12.56"
16105 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
16106 stack_trap "umount $MOUNT2" EXIT
16108 changelog_register || error "first changelog_register failed"
16109 stack_trap "changelog_deregister" EXIT
16111 # generate some changelog
16112 # use all_char because created files should be evenly distributed
16113 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16114 error "mkdir $tdir failed"
16115 for ((i = 0; i < MDSCOUNT; i++)); do
16116 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16117 error "create $DIR/$tdir/d$i.1 failed"
16120 # open the changelog device
16121 exec 3>/dev/changelog-$FSNAME-MDT0000
16122 stack_trap "exec 3>&-" EXIT
16123 exec 4</dev/changelog-$FSNAME-MDT0000
16124 stack_trap "exec 4<&-" EXIT
16126 # umount the first lustre mount
16128 stack_trap "mount_client $MOUNT" EXIT
16130 # read changelog, which may or may not fail, but should not crash
16134 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16135 changelog_users $SINGLEMDS | grep -q $cl_user ||
16136 error "User $cl_user not found in changelog_users"
16138 printf 'clear:'$cl_user':0' >&3
16140 run_test 160j "client can be umounted while its chanangelog is being used"
16143 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16144 remote_mds_nodsh && skip "remote MDS with nodsh"
16146 mkdir -p $DIR/$tdir/1/1
16148 changelog_register || error "changelog_register failed"
16149 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16151 changelog_users $SINGLEMDS | grep -q $cl_user ||
16152 error "User '$cl_user' not found in changelog_users"
16153 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
16154 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
16155 rmdir $DIR/$tdir/1/1 & sleep 1
16157 touch $DIR/$tdir/2/2
16158 rm -rf $DIR/$tdir/2
16163 changelog_dump | grep rmdir || error "rmdir not recorded"
16165 run_test 160k "Verify that changelog records are not lost"
16167 # Verifies that a file passed as a parameter has recently had an operation
16168 # performed on it that has generated an MTIME changelog which contains the
16169 # correct parent FID. As files might reside on a different MDT from the
16170 # parent directory in DNE configurations, the FIDs are translated to paths
16171 # before being compared, which should be identical
16172 compare_mtime_changelog() {
16180 mdtidx=$($LFS getstripe --mdt-index $file)
16181 mdtidx=$(printf "%04x" $mdtidx)
16183 # Obtain the parent FID from the MTIME changelog
16184 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
16185 [ -z "$mtime" ] && error "MTIME changelog not recorded"
16187 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
16188 [ -z "$cl_fid" ] && error "parent FID not present"
16190 # Verify that the path for the parent FID is the same as the path for
16191 # the test directory
16192 pdir=$($LFS fid2path $MOUNT "$cl_fid")
16196 [[ "${pdir%/}" == "$dir" ]] ||
16197 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
16201 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16203 remote_mds_nodsh && skip "remote MDS with nodsh"
16204 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
16205 skip "Need MDS version at least 2.13.55"
16209 changelog_register || error "changelog_register failed"
16210 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16212 changelog_users $SINGLEMDS | grep -q $cl_user ||
16213 error "User '$cl_user' not found in changelog_users"
16215 # Clear some types so that MTIME changelogs are generated
16216 changelog_chmask "-CREAT"
16217 changelog_chmask "-CLOSE"
16219 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
16221 # Test CL_MTIME during setattr
16222 touch $DIR/$tdir/$tfile
16223 compare_mtime_changelog $DIR/$tdir/$tfile
16225 # Test CL_MTIME during close
16226 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
16227 compare_mtime_changelog $DIR/$tdir/${tfile}_2
16229 run_test 160l "Verify that MTIME changelog records contain the parent FID"
16232 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16233 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16234 skip "Need MDS version at least 2.14.51"
16241 changelog_register || error "first changelog_register failed"
16242 changelog_register || error "second changelog_register failed"
16244 cl_users=(${CL_USERS[mds1]})
16245 cl_user1="${cl_users[0]}"
16246 cl_user2="${cl_users[1]}"
16247 # generate some changelog records to accumulate on MDT0
16248 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16249 createmany -m $DIR/$tdir/$tfile 50 ||
16250 error "create $DIR/$tdir/$tfile failed"
16251 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16254 # check changelogs have been generated
16255 local nbcl=$(changelog_dump | wc -l)
16256 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16258 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
16259 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
16261 __changelog_clear mds1 $cl_user1 +10
16262 __changelog_clear mds1 $cl_user2 0 &
16265 __changelog_clear mds1 $cl_user1 0 ||
16266 error "fail to cancel record for $cl_user1"
16268 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
16270 run_test 160m "Changelog clear race"
16273 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16274 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16275 skip "Need MDS version at least 2.14.51"
16284 changelog_register || error "first changelog_register failed"
16286 cl_users=(${CL_USERS[mds1]})
16287 cl_user1="${cl_users[0]}"
16289 # generate some changelog records to accumulate on MDT0
16290 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16291 first_rec=$(changelog_users $SINGLEMDS |
16292 awk '/^current.index:/ { print $NF }')
16293 while (( last_rec < (( first_rec + 65000)) )); do
16294 createmany -m $DIR/$tdir/$tfile 10000 ||
16295 error "create $DIR/$tdir/$tfile failed"
16297 for i in $(seq 0 10000); do
16298 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
16302 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
16303 error "unlinkmany failed unlink"
16304 last_rec=$(changelog_users $SINGLEMDS |
16305 awk '/^current.index:/ { print $NF }')
16306 echo last record $last_rec
16307 (( last_rec == 0 )) && error "no changelog found"
16310 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
16311 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
16313 __changelog_clear mds1 $cl_user1 0 &
16316 __changelog_clear mds1 $cl_user1 0 ||
16317 error "fail to cancel record for $cl_user1"
16319 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
16321 run_test 160n "Changelog destroy race"
16324 local mdt="$(facet_svc $SINGLEMDS)"
16326 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
16327 remote_mds_nodsh && skip "remote MDS with nodsh"
16328 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
16329 skip "Need MDS version at least 2.14.52"
16331 changelog_register --user test_160o -m unlnk+close+open ||
16332 error "changelog_register failed"
16333 # drop server mask so it doesn't interfere
16334 do_facet $SINGLEMDS $LCTL --device $mdt \
16335 changelog_register -u "Tt3_-#" &&
16336 error "bad symbols in name should fail"
16338 do_facet $SINGLEMDS $LCTL --device $mdt \
16339 changelog_register -u test_160o &&
16340 error "the same name registration should fail"
16342 do_facet $SINGLEMDS $LCTL --device $mdt \
16343 changelog_register -u test_160toolongname &&
16344 error "too long name registration should fail"
16346 changelog_chmask "MARK+HSM"
16347 lctl get_param mdd.*.changelog*mask
16348 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16349 changelog_users $SINGLEMDS | grep -q $cl_user ||
16350 error "User $cl_user not found in changelog_users"
16352 echo $cl_user | grep -q test_160o ||
16353 error "User $cl_user has no specific name 'test160o'"
16356 changelog_clear 0 || error "changelog_clear failed"
16357 # generate some changelog records to accumulate on MDT0
16358 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16359 touch $DIR/$tdir/$tfile # open 1
16361 OPENS=$(changelog_dump | grep -c "OPEN")
16362 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
16364 # must be no MKDIR it wasn't set as user mask
16365 MKDIR=$(changelog_dump | grep -c "MKDIR")
16366 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
16368 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
16369 mdd.$mdt.changelog_current_mask -n)
16370 # register maskless user
16371 changelog_register || error "changelog_register failed"
16372 # effective mask should be not changed because it is not minimal
16373 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16374 mdd.$mdt.changelog_current_mask -n)
16375 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
16376 # set server mask to minimal value
16377 changelog_chmask "MARK"
16378 # check effective mask again, should be treated as DEFMASK now
16379 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16380 mdd.$mdt.changelog_current_mask -n)
16381 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
16383 do_facet $SINGLEMDS $LCTL --device $mdt \
16384 changelog_deregister -u test_160o ||
16385 error "cannot deregister by name"
16387 run_test 160o "changelog user name and mask"
16390 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16391 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16392 skip "Need MDS version at least 2.14.51"
16393 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
16399 changelog_register || error "first changelog_register failed"
16401 cl_users=(${CL_USERS[mds1]})
16402 cl_user1="${cl_users[0]}"
16404 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16405 createmany -m $DIR/$tdir/$tfile 50 ||
16406 error "create $DIR/$tdir/$tfile failed"
16407 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16410 # check changelogs have been generated
16411 entry_count=$(changelog_dump | wc -l)
16412 ((entry_count != 0)) || error "no changelog entries found"
16414 # remove changelog_users and check that orphan entries are removed
16416 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $(mdsdevname 1)"
16417 start mds1 || error "cannot start mdt"
16418 entry_count=$(changelog_dump | wc -l)
16419 ((entry_count == 0)) ||
16420 error "found $entry_count changelog entries, expected none"
16422 run_test 160p "Changelog orphan cleanup with no users"
16425 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16427 test_mkdir -c1 $DIR/$tdir
16428 cp /etc/hosts $DIR/$tdir/$tfile
16429 test_mkdir -c1 $DIR/$tdir/foo1
16430 test_mkdir -c1 $DIR/$tdir/foo2
16431 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
16432 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
16433 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
16434 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
16435 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
16436 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
16437 $LFS fid2path $DIR $FID
16438 error "bad link ea"
16441 rm $DIR/$tdir/foo2/zachary
16443 rm $DIR/$tdir/foo2/thor
16445 rm $DIR/$tdir/$tfile
16447 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
16448 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
16449 { $LFS fid2path $DIR $FID; error "bad link rename"; }
16450 rm $DIR/$tdir/foo2/maggie
16453 local longname=$tfile.avg_len_is_thirty_two_
16454 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
16455 error_noexit 'failed to unlink many hardlinks'" EXIT
16456 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
16457 error "failed to hardlink many files"
16458 links=$($LFS fid2path $DIR $FID | wc -l)
16459 echo -n "${links}/1000 links in link EA"
16460 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
16462 run_test 161a "link ea sanity"
16465 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16466 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
16469 local remote_dir=$DIR/$tdir/remote_dir
16471 mkdir -p $DIR/$tdir
16472 $LFS mkdir -i $MDTIDX $remote_dir ||
16473 error "create remote directory failed"
16475 cp /etc/hosts $remote_dir/$tfile
16476 mkdir -p $remote_dir/foo1
16477 mkdir -p $remote_dir/foo2
16478 ln $remote_dir/$tfile $remote_dir/foo1/sofia
16479 ln $remote_dir/$tfile $remote_dir/foo2/zachary
16480 ln $remote_dir/$tfile $remote_dir/foo1/luna
16481 ln $remote_dir/$tfile $remote_dir/foo2/thor
16483 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
16485 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
16486 $LFS fid2path $DIR $FID
16487 error "bad link ea"
16490 rm $remote_dir/foo2/zachary
16492 rm $remote_dir/foo2/thor
16494 rm $remote_dir/$tfile
16496 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
16497 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
16498 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
16499 $LFS fid2path $DIR $FID
16500 error "bad link rename"
16502 rm $remote_dir/foo2/maggie
16505 local longname=filename_avg_len_is_thirty_two_
16506 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
16507 error "failed to hardlink many files"
16508 links=$($LFS fid2path $DIR $FID | wc -l)
16509 echo -n "${links}/1000 links in link EA"
16510 [[ ${links} -gt 60 ]] ||
16511 error "expected at least 60 links in link EA"
16512 unlinkmany $remote_dir/foo2/$longname 1000 ||
16513 error "failed to unlink many hardlinks"
16515 run_test 161b "link ea sanity under remote directory"
16518 remote_mds_nodsh && skip "remote MDS with nodsh"
16519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16520 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
16521 skip "Need MDS version at least 2.1.5"
16523 # define CLF_RENAME_LAST 0x0001
16524 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
16525 changelog_register || error "changelog_register failed"
16528 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
16529 touch $DIR/$tdir/foo_161c
16530 touch $DIR/$tdir/bar_161c
16531 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
16532 changelog_dump | grep RENME | tail -n 5
16533 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
16534 changelog_clear 0 || error "changelog_clear failed"
16535 if [ x$flags != "x0x1" ]; then
16536 error "flag $flags is not 0x1"
16539 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
16540 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
16541 touch $DIR/$tdir/foo_161c
16542 touch $DIR/$tdir/bar_161c
16543 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
16544 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
16545 changelog_dump | grep RENME | tail -n 5
16546 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
16547 changelog_clear 0 || error "changelog_clear failed"
16548 if [ x$flags != "x0x0" ]; then
16549 error "flag $flags is not 0x0"
16551 echo "rename overwrite a target having nlink > 1," \
16552 "changelog record has flags of $flags"
16554 # rename doesn't overwrite a target (changelog flag 0x0)
16555 touch $DIR/$tdir/foo_161c
16556 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
16557 changelog_dump | grep RENME | tail -n 5
16558 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
16559 changelog_clear 0 || error "changelog_clear failed"
16560 if [ x$flags != "x0x0" ]; then
16561 error "flag $flags is not 0x0"
16563 echo "rename doesn't overwrite a target," \
16564 "changelog record has flags of $flags"
16566 # define CLF_UNLINK_LAST 0x0001
16567 # unlink a file having nlink = 1 (changelog flag 0x1)
16568 rm -f $DIR/$tdir/foo2_161c
16569 changelog_dump | grep UNLNK | tail -n 5
16570 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
16571 changelog_clear 0 || error "changelog_clear failed"
16572 if [ x$flags != "x0x1" ]; then
16573 error "flag $flags is not 0x1"
16575 echo "unlink a file having nlink = 1," \
16576 "changelog record has flags of $flags"
16578 # unlink a file having nlink > 1 (changelog flag 0x0)
16579 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
16580 rm -f $DIR/$tdir/foobar_161c
16581 changelog_dump | grep UNLNK | tail -n 5
16582 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
16583 changelog_clear 0 || error "changelog_clear failed"
16584 if [ x$flags != "x0x0" ]; then
16585 error "flag $flags is not 0x0"
16587 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
16589 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
16592 remote_mds_nodsh && skip "remote MDS with nodsh"
16593 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
16598 changelog_register || error "changelog_register failed"
16600 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
16601 # interfer with $MOUNT/.lustre/fid/ access
16603 [[ $? -eq 0 ]] || error "mkdir failed"
16605 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
16606 $LCTL set_param fail_loc=0x8000140c
16608 $LCTL set_param fail_val=5
16611 echo foofoo > $DIR/$tdir/$tfile &
16614 # wait for create to be delayed
16618 [[ $? -eq 0 ]] || error "create should be blocked"
16620 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
16621 stack_trap "rm -f $tempfile"
16622 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
16623 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
16624 # some delay may occur during ChangeLog publishing and file read just
16625 # above, that could allow file write to happen finally
16626 [[ -s $tempfile ]] && echo "file should be empty"
16628 $LCTL set_param fail_loc=0
16631 [[ $? -eq 0 ]] || error "create failed"
16633 run_test 161d "create with concurrent .lustre/fid access"
16636 local expected="$1"
16641 path=$($LFS fid2path "$@")
16644 if [ $rc -ne 0 ]; then
16645 error "path looked up of '$expected' failed: rc=$rc"
16646 elif [ "$path" != "$expected" ]; then
16647 error "path looked up '$path' instead of '$expected'"
16649 echo "FID '$fid' resolves to path '$path' as expected"
16653 test_162a() { # was test_162
16654 test_mkdir -p -c1 $DIR/$tdir/d2
16655 touch $DIR/$tdir/d2/$tfile
16656 touch $DIR/$tdir/d2/x1
16657 touch $DIR/$tdir/d2/x2
16658 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
16659 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
16661 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
16662 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
16665 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
16666 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
16667 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
16669 # softlink to wrong file
16670 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
16671 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
16672 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
16675 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
16676 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
16677 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
16678 # fid2path dir/fsname should both work
16679 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
16680 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
16682 # hardlink count: check that there are 2 links
16683 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
16684 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
16686 # hardlink indexing: remove the first link
16687 rm $DIR/$tdir/d2/p/q/r/hlink
16688 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
16690 run_test 162a "path lookup sanity"
16693 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16694 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16697 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
16698 error "create striped dir failed"
16700 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
16701 tail -n 1 | awk '{print $2}')
16702 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
16704 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
16705 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
16708 for ((i=0;i<5;i++)); do
16709 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
16710 error "get fid for f$i failed"
16711 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
16713 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
16714 error "get fid for d$i failed"
16715 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
16720 run_test 162b "striped directory path lookup sanity"
16722 # LU-4239: Verify fid2path works with paths 100 or more directories deep
16724 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
16725 skip "Need MDS version at least 2.7.51"
16727 local lpath=$tdir.local
16728 local rpath=$tdir.remote
16730 test_mkdir $DIR/$lpath
16731 test_mkdir $DIR/$rpath
16733 for ((i = 0; i <= 101; i++)); do
16736 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
16737 error "get fid for local directory $DIR/$lpath failed"
16738 check_path "$DIR/$lpath" $MOUNT $FID --link 0
16741 test_mkdir $DIR/$rpath
16742 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
16743 error "get fid for remote directory $DIR/$rpath failed"
16744 check_path "$DIR/$rpath" $MOUNT $FID --link 0
16749 run_test 162c "fid2path works with paths 100 or more directories deep"
16751 oalr_event_count() {
16755 awk -v name="${FSNAME}-OST0000" \
16756 -v event="${event}" \
16757 '$1 == "TRACE" && $2 == event && $3 == name' \
16762 oalr_expect_event_count() {
16765 local expect="${3}"
16768 count=$(oalr_event_count "${event}" "${trace}")
16769 if ((count == expect)); then
16773 error_noexit "${event} event count was '${count}', expected ${expect}"
16779 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
16781 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
16785 sync # Flush previous IOs so we can count log entries.
16786 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
16787 stack_trap cleanup_165 EXIT
16791 local trace="/tmp/${tfile}.trace"
16795 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
16796 skip "OFD access log unsupported"
16799 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
16802 do_facet ost1 ofd_access_log_reader --list
16805 do_facet ost1 killall -TERM ofd_access_log_reader
16809 if ((rc != 0)); then
16810 error "ofd_access_log_reader exited with rc = '${rc}'"
16813 # Parse trace file for discovery events:
16814 oalr_expect_event_count alr_log_add "${trace}" 1
16815 oalr_expect_event_count alr_log_eof "${trace}" 1
16816 oalr_expect_event_count alr_log_free "${trace}" 1
16818 run_test 165a "ofd access log discovery"
16821 local trace="/tmp/${tfile}.trace"
16822 local file="${DIR}/${tfile}"
16831 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
16832 skip "OFD access log unsupported"
16835 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
16838 do_facet ost1 ofd_access_log_reader --list
16840 lfs setstripe -c 1 -i 0 "${file}"
16841 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
16842 error "cannot create '${file}'"
16845 do_facet ost1 killall -TERM ofd_access_log_reader
16849 if ((rc != 0)); then
16850 error "ofd_access_log_reader exited with rc = '${rc}'"
16853 oalr_expect_event_count alr_log_entry "${trace}" 1
16855 pfid1=$($LFS path2fid "${file}")
16857 # 1 2 3 4 5 6 7 8 9 10
16858 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
16859 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
16861 echo "entry = '${entry[*]}'" >&2
16864 if [[ "${pfid1}" != "${pfid2}" ]]; then
16865 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
16869 if ((size != 1048576)); then
16870 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
16874 if [[ "${flags}" != "w" ]]; then
16875 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
16878 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
16881 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
16882 error "cannot read '${file}'"
16885 do_facet ost1 killall -TERM ofd_access_log_reader
16889 if ((rc != 0)); then
16890 error "ofd_access_log_reader exited with rc = '${rc}'"
16893 oalr_expect_event_count alr_log_entry "${trace}" 1
16895 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
16896 echo "entry = '${entry[*]}'" >&2
16899 if [[ "${pfid1}" != "${pfid2}" ]]; then
16900 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
16904 if ((size != 524288)); then
16905 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
16909 if [[ "${flags}" != "r" ]]; then
16910 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
16913 run_test 165b "ofd access log entries are produced and consumed"
16916 local trace="/tmp/${tfile}.trace"
16917 local file="${DIR}/${tdir}/${tfile}"
16919 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
16920 skip "OFD access log unsupported"
16922 test_mkdir "${DIR}/${tdir}"
16925 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
16928 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
16930 # 4096 / 64 = 64. Create twice as many entries.
16931 for ((i = 0; i < 128; i++)); do
16932 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
16933 error "cannot create file"
16938 do_facet ost1 killall -TERM ofd_access_log_reader
16941 if ((rc != 0)); then
16942 error "ofd_access_log_reader exited with rc = '${rc}'"
16945 unlinkmany "${file}-%d" 128
16947 run_test 165c "full ofd access logs do not block IOs"
16949 oal_get_read_count() {
16952 # STATS lustre-OST0001 alr_read_count 1
16954 do_facet ost1 cat "${stats}" |
16955 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
16956 END { print count; }'
16959 oal_expect_read_count() {
16964 # Ask ofd_access_log_reader to write stats.
16965 do_facet ost1 killall -USR1 ofd_access_log_reader
16967 # Allow some time for things to happen.
16970 count=$(oal_get_read_count "${stats}")
16971 if ((count == expect)); then
16975 error_noexit "bad read count, got ${count}, expected ${expect}"
16976 do_facet ost1 cat "${stats}" >&2
16981 local stats="/tmp/${tfile}.stats"
16982 local file="${DIR}/${tdir}/${tfile}"
16983 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
16985 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
16986 skip "OFD access log unsupported"
16988 test_mkdir "${DIR}/${tdir}"
16991 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
16994 lfs setstripe -c 1 -i 0 "${file}"
16996 do_facet ost1 lctl set_param "${param}=rw"
16997 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
16998 error "cannot create '${file}'"
16999 oal_expect_read_count "${stats}" 1
17001 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17002 error "cannot read '${file}'"
17003 oal_expect_read_count "${stats}" 2
17005 do_facet ost1 lctl set_param "${param}=r"
17006 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17007 error "cannot create '${file}'"
17008 oal_expect_read_count "${stats}" 2
17010 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17011 error "cannot read '${file}'"
17012 oal_expect_read_count "${stats}" 3
17014 do_facet ost1 lctl set_param "${param}=w"
17015 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17016 error "cannot create '${file}'"
17017 oal_expect_read_count "${stats}" 4
17019 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17020 error "cannot read '${file}'"
17021 oal_expect_read_count "${stats}" 4
17023 do_facet ost1 lctl set_param "${param}=0"
17024 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17025 error "cannot create '${file}'"
17026 oal_expect_read_count "${stats}" 4
17028 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17029 error "cannot read '${file}'"
17030 oal_expect_read_count "${stats}" 4
17032 do_facet ost1 killall -TERM ofd_access_log_reader
17035 if ((rc != 0)); then
17036 error "ofd_access_log_reader exited with rc = '${rc}'"
17039 run_test 165d "ofd_access_log mask works"
17042 local stats="/tmp/${tfile}.stats"
17043 local file0="${DIR}/${tdir}-0/${tfile}"
17044 local file1="${DIR}/${tdir}-1/${tfile}"
17046 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17047 skip "OFD access log unsupported"
17049 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
17051 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
17052 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
17054 lfs setstripe -c 1 -i 0 "${file0}"
17055 lfs setstripe -c 1 -i 0 "${file1}"
17058 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
17061 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
17062 error "cannot create '${file0}'"
17064 oal_expect_read_count "${stats}" 0
17066 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
17067 error "cannot create '${file1}'"
17069 oal_expect_read_count "${stats}" 1
17071 do_facet ost1 killall -TERM ofd_access_log_reader
17074 if ((rc != 0)); then
17075 error "ofd_access_log_reader exited with rc = '${rc}'"
17078 run_test 165e "ofd_access_log MDT index filter works"
17081 local trace="/tmp/${tfile}.trace"
17086 do_facet ost1 timeout 60 ofd_access_log_reader \
17087 --exit-on-close --debug=- --trace=- > "${trace}" &
17094 if ((rc != 0)); then
17095 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
17100 run_test 165f "ofd_access_log_reader --exit-on-close works"
17103 # do directio so as not to populate the page cache
17104 log "creating a 10 Mb file"
17105 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
17106 error "multiop failed while creating a file"
17107 log "starting reads"
17108 dd if=$DIR/$tfile of=/dev/null bs=4096 &
17109 log "truncating the file"
17110 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
17111 error "multiop failed while truncating the file"
17113 kill %+ || true # reads might have finished
17114 echo "wait until dd is finished"
17116 log "removing the temporary file"
17117 rm -rf $DIR/$tfile || error "tmp file removal failed"
17119 run_test 169 "parallel read and truncate should not deadlock"
17122 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17124 $LCTL clear # bug 18514
17125 $LCTL debug_daemon start $TMP/${tfile}_log_good
17127 $LCTL debug_daemon stop
17128 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
17129 error "sed failed to read log_good"
17131 $LCTL debug_daemon start $TMP/${tfile}_log_good
17133 $LCTL debug_daemon stop
17135 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
17136 error "lctl df log_bad failed"
17138 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
17139 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
17141 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
17142 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
17144 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
17145 error "bad_line good_line1 good_line2 are empty"
17147 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
17148 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
17149 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
17151 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
17152 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
17153 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
17155 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
17156 error "bad_line_new good_line_new are empty"
17158 local expected_good=$((good_line1 + good_line2*2))
17160 rm -f $TMP/${tfile}*
17161 # LU-231, short malformed line may not be counted into bad lines
17162 if [ $bad_line -ne $bad_line_new ] &&
17163 [ $bad_line -ne $((bad_line_new - 1)) ]; then
17164 error "expected $bad_line bad lines, but got $bad_line_new"
17168 if [ $expected_good -ne $good_line_new ]; then
17169 error "expected $expected_good good lines, but got $good_line_new"
17174 run_test 170 "test lctl df to handle corrupted log ====================="
17176 test_171() { # bug20592
17177 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17179 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
17180 $LCTL set_param fail_loc=0x50e
17181 $LCTL set_param fail_val=3000
17182 multiop_bg_pause $DIR/$tfile O_s || true
17184 kill -USR1 $MULTIPID
17188 if dmesg | grep "recursive fault"; then
17189 error "caught a recursive fault"
17191 $LCTL set_param fail_loc=0
17194 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
17196 # it would be good to share it with obdfilter-survey/iokit-libecho code
17197 setup_obdecho_osc () {
17200 local obdfilter_name=$2
17201 echo "Creating new osc for $obdfilter_name on $ost_nid"
17202 # make sure we can find loopback nid
17203 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
17205 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
17206 ${obdfilter_name}_osc_UUID || rc=2; }
17207 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
17208 ${obdfilter_name}_UUID $ost_nid || rc=3; }
17212 cleanup_obdecho_osc () {
17213 local obdfilter_name=$1
17214 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
17215 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
17222 local pages=${3:-64}
17227 local obd_size=$(get_obd_size $node $OBD)
17228 local page_size=$(get_page_size $node)
17229 if [[ -n "$obd_size" ]]; then
17230 local new_count=$((obd_size / (pages * page_size / 1024)))
17231 [[ $new_count -ge $count ]] || count=$new_count
17234 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
17235 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
17237 if [ $rc -eq 0 ]; then
17238 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
17239 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
17241 echo "New object id is $id"
17242 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
17244 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
17245 "test_brw $count w v $pages $id" || rc=4; }
17246 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
17248 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
17249 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
17250 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
17251 { do_facet $node "$LCTL --device ec detach" || rc=6; }
17252 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
17257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17259 if ! [ -d /sys/fs/lustre/echo_client ] &&
17260 ! module_loaded obdecho; then
17261 load_module obdecho/obdecho &&
17262 stack_trap "rmmod obdecho" EXIT ||
17263 error "unable to load obdecho on client"
17266 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
17267 local host=$($LCTL get_param -n osc.$osc.import |
17268 awk '/current_connection:/ { print $2 }' )
17269 local target=$($LCTL get_param -n osc.$osc.import |
17270 awk '/target:/ { print $2 }' )
17271 target=${target%_UUID}
17273 if [ -n "$target" ]; then
17274 setup_obdecho_osc $host $target &&
17275 stack_trap "cleanup_obdecho_osc $target" EXIT ||
17276 { error "obdecho setup failed with $?"; return; }
17278 obdecho_test ${target}_osc client ||
17279 error "obdecho_test failed on ${target}_osc"
17281 $LCTL get_param osc.$osc.import
17282 error "there is no osc.$osc.import target"
17285 run_test 180a "test obdecho on osc"
17288 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17289 remote_ost_nodsh && skip "remote OST with nodsh"
17291 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
17292 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
17293 error "failed to load module obdecho"
17295 local target=$(do_facet ost1 $LCTL dl |
17296 awk '/obdfilter/ { print $4; exit; }')
17298 if [ -n "$target" ]; then
17299 obdecho_test $target ost1 || error "obdecho_test failed with $?"
17301 do_facet ost1 $LCTL dl
17302 error "there is no obdfilter target on ost1"
17305 run_test 180b "test obdecho directly on obdfilter"
17307 test_180c() { # LU-2598
17308 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17309 remote_ost_nodsh && skip "remote OST with nodsh"
17310 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
17311 skip "Need MDS version at least 2.4.0"
17313 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
17314 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
17315 error "failed to load module obdecho"
17317 local target=$(do_facet ost1 $LCTL dl |
17318 awk '/obdfilter/ { print $4; exit; }')
17320 if [ -n "$target" ]; then
17321 local pages=16384 # 64MB bulk I/O RPC size
17323 obdecho_test "$target" ost1 "$pages" ||
17324 error "obdecho_test with pages=$pages failed with $?"
17326 do_facet ost1 $LCTL dl
17327 error "there is no obdfilter target on ost1"
17330 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
17332 test_181() { # bug 22177
17333 test_mkdir $DIR/$tdir
17334 # create enough files to index the directory
17335 createmany -o $DIR/$tdir/foobar 4000
17336 # print attributes for debug purpose
17339 multiop_bg_pause $DIR/$tdir D_Sc || return 1
17341 # remove the files & current working dir
17342 unlinkmany $DIR/$tdir/foobar 4000
17344 kill -USR1 $MULTIPID
17346 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
17349 run_test 181 "Test open-unlinked dir ========================"
17355 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
17357 $LCTL set_param mdc.*.rpc_stats=clear
17359 for (( i = 0; i < $tcount; i++ )) ; do
17360 mkdir $DIR/$tdir/$i
17363 for (( i = 0; i < $tcount; i++ )) ; do
17364 createmany -o $DIR/$tdir/$i/f- $fcount &
17368 for (( i = 0; i < $tcount; i++ )) ; do
17369 unlinkmany $DIR/$tdir/$i/f- $fcount &
17373 $LCTL get_param mdc.*.rpc_stats
17377 run_test 182 "Test parallel modify metadata operations ================"
17379 test_183() { # LU-2275
17380 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17381 remote_mds_nodsh && skip "remote MDS with nodsh"
17382 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
17383 skip "Need MDS version at least 2.3.56"
17385 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
17386 echo aaa > $DIR/$tdir/$tfile
17388 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
17389 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
17391 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
17392 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
17394 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17396 # Flush negative dentry cache
17397 touch $DIR/$tdir/$tfile
17399 # We are not checking for any leaked references here, they'll
17400 # become evident next time we do cleanup with module unload.
17403 run_test 183 "No crash or request leak in case of strange dispositions ========"
17405 # test suite 184 is for LU-2016, LU-2017
17407 check_swap_layouts_support
17409 dir0=$DIR/$tdir/$testnum
17410 test_mkdir -p -c1 $dir0
17415 $LFS setstripe -c1 $file1
17417 $LFS setstripe -c2 $file2
17419 gen1=$($LFS getstripe -g $file1)
17420 gen2=$($LFS getstripe -g $file2)
17422 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
17423 gen=$($LFS getstripe -g $file1)
17424 [[ $gen1 != $gen ]] ||
17425 "Layout generation on $file1 does not change"
17426 gen=$($LFS getstripe -g $file2)
17427 [[ $gen2 != $gen ]] ||
17428 "Layout generation on $file2 does not change"
17430 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
17431 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
17433 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
17435 run_test 184a "Basic layout swap"
17438 check_swap_layouts_support
17440 dir0=$DIR/$tdir/$testnum
17441 mkdir -p $dir0 || error "creating dir $dir0"
17448 $LFS setstripe -c1 $file1
17449 $LFS setstripe -c2 $file2
17450 $LFS setstripe -c1 $file3
17451 chown $RUNAS_ID $file3
17452 gen1=$($LFS getstripe -g $file1)
17453 gen2=$($LFS getstripe -g $file2)
17455 $LFS swap_layouts $dir1 $dir2 &&
17456 error "swap of directories layouts should fail"
17457 $LFS swap_layouts $dir1 $file1 &&
17458 error "swap of directory and file layouts should fail"
17459 $RUNAS $LFS swap_layouts $file1 $file2 &&
17460 error "swap of file we cannot write should fail"
17461 $LFS swap_layouts $file1 $file3 &&
17462 error "swap of file with different owner should fail"
17463 /bin/true # to clear error code
17465 run_test 184b "Forbidden layout swap (will generate errors)"
17468 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
17469 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
17470 check_swap_layouts_support
17471 check_swap_layout_no_dom $DIR
17473 local dir0=$DIR/$tdir/$testnum
17474 mkdir -p $dir0 || error "creating dir $dir0"
17476 local ref1=$dir0/ref1
17477 local ref2=$dir0/ref2
17478 local file1=$dir0/file1
17479 local file2=$dir0/file2
17480 # create a file large enough for the concurrent test
17481 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
17482 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
17483 echo "ref file size: ref1($(stat -c %s $ref1))," \
17484 "ref2($(stat -c %s $ref2))"
17487 dd if=$ref1 of=$file1 bs=16k &
17490 # Make sure dd starts to copy file, but wait at most 5 seconds
17492 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
17494 $LFS swap_layouts $file1 $file2
17497 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
17498 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
17500 # how many bytes copied before swapping layout
17501 local copied=$(stat -c %s $file2)
17502 local remaining=$(stat -c %s $ref1)
17503 remaining=$((remaining - copied))
17504 echo "Copied $copied bytes before swapping layout..."
17506 cmp -n $copied $file1 $ref2 | grep differ &&
17507 error "Content mismatch [0, $copied) of ref2 and file1"
17508 cmp -n $copied $file2 $ref1 ||
17509 error "Content mismatch [0, $copied) of ref1 and file2"
17510 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
17511 error "Content mismatch [$copied, EOF) of ref1 and file1"
17514 rm -f $ref1 $ref2 $file1 $file2
17516 run_test 184c "Concurrent write and layout swap"
17519 check_swap_layouts_support
17520 check_swap_layout_no_dom $DIR
17521 [ -z "$(which getfattr 2>/dev/null)" ] &&
17522 skip_env "no getfattr command"
17524 local file1=$DIR/$tdir/$tfile-1
17525 local file2=$DIR/$tdir/$tfile-2
17526 local file3=$DIR/$tdir/$tfile-3
17530 mkdir -p $DIR/$tdir
17531 touch $file1 || error "create $file1 failed"
17532 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
17533 error "create $file2 failed"
17534 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
17535 error "create $file3 failed"
17536 lovea1=$(get_layout_param $file1)
17538 $LFS swap_layouts $file2 $file3 ||
17539 error "swap $file2 $file3 layouts failed"
17540 $LFS swap_layouts $file1 $file2 ||
17541 error "swap $file1 $file2 layouts failed"
17543 lovea2=$(get_layout_param $file2)
17546 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
17548 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
17549 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
17551 run_test 184d "allow stripeless layouts swap"
17554 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
17555 skip "Need MDS version at least 2.6.94"
17556 check_swap_layouts_support
17557 check_swap_layout_no_dom $DIR
17558 [ -z "$(which getfattr 2>/dev/null)" ] &&
17559 skip_env "no getfattr command"
17561 local file1=$DIR/$tdir/$tfile-1
17562 local file2=$DIR/$tdir/$tfile-2
17563 local file3=$DIR/$tdir/$tfile-3
17566 mkdir -p $DIR/$tdir
17567 touch $file1 || error "create $file1 failed"
17568 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
17569 error "create $file2 failed"
17570 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
17571 error "create $file3 failed"
17573 $LFS swap_layouts $file1 $file2 ||
17574 error "swap $file1 $file2 layouts failed"
17576 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
17577 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
17579 echo 123 > $file1 || error "Should be able to write into $file1"
17581 $LFS swap_layouts $file1 $file3 ||
17582 error "swap $file1 $file3 layouts failed"
17584 echo 123 > $file1 || error "Should be able to write into $file1"
17586 rm -rf $file1 $file2 $file3
17588 run_test 184e "Recreate layout after stripeless layout swaps"
17591 # Create a file with name longer than sizeof(struct stat) ==
17592 # 144 to see if we can get chars from the file name to appear
17593 # in the returned striping. Note that 'f' == 0x66.
17594 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
17596 mkdir -p $DIR/$tdir
17597 mcreate $DIR/$tdir/$file
17598 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
17599 error "IOC_MDC_GETFILEINFO returned garbage striping"
17602 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
17604 test_185() { # LU-2441
17605 # LU-3553 - no volatile file support in old servers
17606 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
17607 skip "Need MDS version at least 2.3.60"
17609 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
17610 touch $DIR/$tdir/spoo
17611 local mtime1=$(stat -c "%Y" $DIR/$tdir)
17612 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
17613 error "cannot create/write a volatile file"
17614 [ "$FILESET" == "" ] &&
17615 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
17616 error "FID is still valid after close"
17618 multiop_bg_pause $DIR/$tdir vVw4096_c
17625 # assume that the next FID for this client is sequential, since stdout
17626 # is unfortunately eaten by multiop_bg_pause
17627 local n=$((${fidv[1]} + 1))
17628 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
17629 if [ "$FILESET" == "" ]; then
17630 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
17631 error "FID is missing before close"
17633 kill -USR1 $multi_pid
17634 # 1 second delay, so if mtime change we will see it
17636 local mtime2=$(stat -c "%Y" $DIR/$tdir)
17637 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
17639 run_test 185 "Volatile file support"
17641 function create_check_volatile() {
17645 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
17648 local FID=$(cat /tmp/${tfile}.fid)
17649 [ "$FID" == "" ] && error "can't get FID for volatile"
17650 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
17651 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
17652 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
17656 cancel_lru_locks mdc # flush opencache
17657 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
17662 # LU-12516 - volatile creation via .lustre
17663 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
17664 skip "Need MDS version at least 2.3.55"
17666 create_check_volatile 0
17667 [ $MDSCOUNT -lt 2 ] && return 0
17670 create_check_volatile 1
17674 run_test 185a "Volatile file creation in .lustre/fid/"
17677 remote_mds_nodsh && skip "remote MDS with nodsh"
17678 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
17679 skip "Need MDS version at least 2.3.0"
17681 local dir0=$DIR/$tdir/$testnum
17682 mkdir -p $dir0 || error "creating dir $dir0"
17684 local file=$dir0/file1
17685 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
17686 local dv1=$($LFS data_version $file)
17687 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
17688 local dv2=$($LFS data_version $file)
17689 [[ $dv1 != $dv2 ]] ||
17690 error "data version did not change on write $dv1 == $dv2"
17695 run_test 187a "Test data version change"
17698 remote_mds_nodsh && skip "remote MDS with nodsh"
17699 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
17700 skip "Need MDS version at least 2.3.0"
17702 local dir0=$DIR/$tdir/$testnum
17703 mkdir -p $dir0 || error "creating dir $dir0"
17705 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
17706 [[ ${DV[0]} != ${DV[1]} ]] ||
17707 error "data version did not change on write"\
17708 " ${DV[0]} == ${DV[1]}"
17713 run_test 187b "Test data version change on volatile file"
17716 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17717 remote_mgs_nodsh && skip "remote MGS with nodsh"
17718 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
17720 local POOL=${POOL:-cea1}
17721 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
17722 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
17725 local last_ost=$(($OSTCOUNT - 1))
17727 local ost_list=$(seq $first_ost $ost_step $last_ost)
17728 local ost_range="$first_ost $last_ost $ost_step"
17729 local test_path=$POOL_ROOT/$POOL_DIR_NAME
17730 local file_dir=$POOL_ROOT/file_tst
17731 local subdir=$test_path/subdir
17735 # former test_200a test_200b
17736 pool_add $POOL || { rc=$? ; break; }
17737 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
17738 # former test_200c test_200d
17739 mkdir -p $test_path
17740 pool_set_dir $POOL $test_path || { rc=$? ; break; }
17741 pool_check_dir $POOL $test_path || { rc=$? ; break; }
17743 pool_check_dir $POOL $subdir || { rc=$? ; break; }
17744 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
17745 || { rc=$? ; break; }
17746 # former test_200e test_200f
17747 local files=$((OSTCOUNT*3))
17748 pool_alloc_files $POOL $test_path $files "$ost_list" \
17749 || { rc=$? ; break; }
17750 pool_create_files $POOL $file_dir $files "$ost_list" \
17751 || { rc=$? ; break; }
17752 # former test_200g test_200h
17753 pool_lfs_df $POOL || { rc=$? ; break; }
17754 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
17756 # former test_201a test_201b test_201c
17757 pool_remove_first_target $POOL || { rc=$? ; break; }
17759 local f=$test_path/$tfile
17760 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
17761 pool_remove $POOL $f || { rc=$? ; break; }
17769 run_test 200 "OST pools"
17771 # usage: default_attr <count | size | offset>
17773 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
17776 # usage: check_default_stripe_attr
17777 check_default_stripe_attr() {
17778 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
17781 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
17783 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
17787 error "unknown getstripe attr '$1'"
17790 [ $ACTUAL == $EXPECTED ] ||
17791 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
17795 test_mkdir $DIR/$tdir
17796 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
17798 check_default_stripe_attr --stripe-count
17799 check_default_stripe_attr --stripe-size
17800 check_default_stripe_attr --stripe-index
17802 run_test 204a "Print default stripe attributes"
17805 test_mkdir $DIR/$tdir
17806 $LFS setstripe --stripe-count 1 $DIR/$tdir
17808 check_default_stripe_attr --stripe-size
17809 check_default_stripe_attr --stripe-index
17811 run_test 204b "Print default stripe size and offset"
17814 test_mkdir $DIR/$tdir
17815 $LFS setstripe --stripe-size 65536 $DIR/$tdir
17817 check_default_stripe_attr --stripe-count
17818 check_default_stripe_attr --stripe-index
17820 run_test 204c "Print default stripe count and offset"
17823 test_mkdir $DIR/$tdir
17824 $LFS setstripe --stripe-index 0 $DIR/$tdir
17826 check_default_stripe_attr --stripe-count
17827 check_default_stripe_attr --stripe-size
17829 run_test 204d "Print default stripe count and size"
17832 test_mkdir $DIR/$tdir
17833 $LFS setstripe -d $DIR/$tdir
17835 check_default_stripe_attr --stripe-count --raw
17836 check_default_stripe_attr --stripe-size --raw
17837 check_default_stripe_attr --stripe-index --raw
17839 run_test 204e "Print raw stripe attributes"
17842 test_mkdir $DIR/$tdir
17843 $LFS setstripe --stripe-count 1 $DIR/$tdir
17845 check_default_stripe_attr --stripe-size --raw
17846 check_default_stripe_attr --stripe-index --raw
17848 run_test 204f "Print raw stripe size and offset"
17851 test_mkdir $DIR/$tdir
17852 $LFS setstripe --stripe-size 65536 $DIR/$tdir
17854 check_default_stripe_attr --stripe-count --raw
17855 check_default_stripe_attr --stripe-index --raw
17857 run_test 204g "Print raw stripe count and offset"
17860 test_mkdir $DIR/$tdir
17861 $LFS setstripe --stripe-index 0 $DIR/$tdir
17863 check_default_stripe_attr --stripe-count --raw
17864 check_default_stripe_attr --stripe-size --raw
17866 run_test 204h "Print raw stripe count and size"
17868 # Figure out which job scheduler is being used, if any,
17869 # or use a fake one
17870 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
17871 JOBENV=SLURM_JOB_ID
17872 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
17874 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
17876 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
17877 JOBENV=LOADL_STEP_ID
17878 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
17881 $LCTL list_param jobid_name > /dev/null 2>&1
17882 if [ $? -eq 0 ]; then
17888 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
17890 verify_jobstats() {
17895 # we don't really need to clear the stats for this test to work, since each
17896 # command has a unique jobid, but it makes debugging easier if needed.
17897 # for facet in $facets; do
17898 # local dev=$(convert_facet2label $facet)
17899 # # clear old jobstats
17900 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
17903 # use a new JobID for each test, or we might see an old one
17904 [ "$JOBENV" = "FAKE_JOBID" ] &&
17905 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
17907 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
17909 [ "$JOBENV" = "nodelocal" ] && {
17910 FAKE_JOBID=id.$testnum.%e.$RANDOM
17911 $LCTL set_param jobid_name=$FAKE_JOBID
17912 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
17915 log "Test: ${cmd[*]}"
17916 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
17918 if [ $JOBENV = "FAKE_JOBID" ]; then
17919 FAKE_JOBID=$JOBVAL ${cmd[*]}
17924 # all files are created on OST0000
17925 for facet in $facets; do
17926 local stats="*.$(convert_facet2label $facet).job_stats"
17928 # strip out libtool wrappers for in-tree executables
17929 if [ $(do_facet $facet lctl get_param $stats |
17930 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
17931 do_facet $facet lctl get_param $stats
17932 error "No jobstats for $JOBVAL found on $facet::$stats"
17938 local new_jobenv=$1
17940 set_persistent_param_and_check client "jobid_var" \
17941 "$FSNAME.sys.jobid_var" $new_jobenv
17944 test_205a() { # Job stats
17945 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17946 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
17947 skip "Need MDS version with at least 2.7.1"
17948 remote_mgs_nodsh && skip "remote MGS with nodsh"
17949 remote_mds_nodsh && skip "remote MDS with nodsh"
17950 remote_ost_nodsh && skip "remote OST with nodsh"
17951 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
17952 skip "Server doesn't support jobstats"
17953 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
17955 local old_jobenv=$($LCTL get_param -n jobid_var)
17956 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
17958 if [[ $PERM_CMD == *"set_param -P"* ]]; then
17959 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
17961 stack_trap "do_facet mgs $PERM_CMD \
17962 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
17966 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
17967 mdt.*.job_cleanup_interval | head -n 1)
17968 local new_interval=5
17969 do_facet $SINGLEMDS \
17970 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
17971 stack_trap "do_facet $SINGLEMDS \
17972 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
17973 local start=$SECONDS
17977 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
17978 verify_jobstats "$cmd" "$SINGLEMDS"
17980 cmd="rmdir $DIR/$tdir"
17981 verify_jobstats "$cmd" "$SINGLEMDS"
17982 # mkdir on secondary MDT
17983 if [ $MDSCOUNT -gt 1 ]; then
17984 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
17985 verify_jobstats "$cmd" "mds2"
17988 cmd="mknod $DIR/$tfile c 1 3"
17989 verify_jobstats "$cmd" "$SINGLEMDS"
17991 cmd="rm -f $DIR/$tfile"
17992 verify_jobstats "$cmd" "$SINGLEMDS"
17993 # create all files on OST0000 so verify_jobstats can find OST stats
17995 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
17996 verify_jobstats "$cmd" "$SINGLEMDS"
17998 cmd="touch $DIR/$tfile"
17999 verify_jobstats "$cmd" "$SINGLEMDS ost1"
18001 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
18002 verify_jobstats "$cmd" "ost1"
18004 cancel_lru_locks osc
18005 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
18006 verify_jobstats "$cmd" "ost1"
18008 cmd="$TRUNCATE $DIR/$tfile 0"
18009 verify_jobstats "$cmd" "$SINGLEMDS ost1"
18011 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
18012 verify_jobstats "$cmd" "$SINGLEMDS"
18013 # jobstats expiry - sleep until old stats should be expired
18014 local left=$((new_interval + 5 - (SECONDS - start)))
18015 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
18016 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
18018 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
18019 verify_jobstats "$cmd" "$SINGLEMDS"
18020 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
18021 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
18023 # Ensure that jobid are present in changelog (if supported by MDS)
18024 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
18025 changelog_dump | tail -10
18026 jobids=$(changelog_dump | tail -9 | grep -c "j=")
18027 [ $jobids -eq 9 ] ||
18028 error "Wrong changelog jobid count $jobids != 9"
18032 jobstats_set $JOBENV
18034 changelog_dump | grep $tfile
18035 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
18036 [ $jobids -eq 0 ] ||
18037 error "Unexpected jobids when jobid_var=$JOBENV"
18040 # test '%j' access to environment variable - if supported
18041 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
18042 JOBENV="JOBCOMPLEX"
18043 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
18045 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18048 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
18049 JOBENV="JOBCOMPLEX"
18050 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
18052 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18055 # test '%j' access to per-session jobid - if supported
18056 if lctl list_param jobid_this_session > /dev/null 2>&1
18058 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
18059 lctl set_param jobid_this_session=$USER
18061 JOBENV="JOBCOMPLEX"
18062 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
18064 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18067 run_test 205a "Verify job stats"
18069 # LU-13117, LU-13597
18071 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
18072 skip "Need MDS version at least 2.13.54.91"
18074 job_stats="mdt.*.job_stats"
18075 $LCTL set_param $job_stats=clear
18076 # Setting jobid_var to USER might not be supported
18077 $LCTL set_param jobid_var=USER || true
18078 $LCTL set_param jobid_name="%e.%u"
18079 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
18080 do_facet $SINGLEMDS $LCTL get_param $job_stats |
18081 grep "job_id:.*foolish" &&
18082 error "Unexpected jobid found"
18083 do_facet $SINGLEMDS $LCTL get_param $job_stats |
18084 grep "open:.*min.*max.*sum" ||
18085 error "wrong job_stats format found"
18087 run_test 205b "Verify job stats jobid and output format"
18091 $LCTL set_param llite.*.stats=0
18092 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
18093 $LCTL get_param llite.*.stats
18094 $LCTL get_param llite.*.stats | grep \
18095 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
18096 error "wrong client stats format found"
18098 run_test 205c "Verify client stats format"
18100 # LU-1480, LU-1773 and LU-1657
18102 mkdir -p $DIR/$tdir
18103 $LFS setstripe -c -1 $DIR/$tdir
18104 #define OBD_FAIL_LOV_INIT 0x1403
18105 $LCTL set_param fail_loc=0xa0001403
18106 $LCTL set_param fail_val=1
18107 touch $DIR/$tdir/$tfile || true
18109 run_test 206 "fail lov_init_raid0() doesn't lbug"
18112 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
18113 local fsz=`stat -c %s $DIR/$tfile`
18114 cancel_lru_locks mdc
18116 # do not return layout in getattr intent
18117 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
18118 $LCTL set_param fail_loc=0x170
18119 local sz=`stat -c %s $DIR/$tfile`
18121 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
18125 run_test 207a "can refresh layout at glimpse"
18128 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
18129 local cksum=`md5sum $DIR/$tfile`
18130 local fsz=`stat -c %s $DIR/$tfile`
18131 cancel_lru_locks mdc
18132 cancel_lru_locks osc
18134 # do not return layout in getattr intent
18135 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
18136 $LCTL set_param fail_loc=0x171
18138 # it will refresh layout after the file is opened but before read issues
18139 echo checksum is "$cksum"
18140 echo "$cksum" |md5sum -c --quiet || error "file differs"
18144 run_test 207b "can refresh layout at open"
18147 # FIXME: in this test suite, only RD lease is used. This is okay
18148 # for now as only exclusive open is supported. After generic lease
18149 # is done, this test suite should be revised. - Jinshan
18151 remote_mds_nodsh && skip "remote MDS with nodsh"
18152 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
18153 skip "Need MDS version at least 2.4.52"
18155 echo "==== test 1: verify get lease work"
18156 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
18158 echo "==== test 2: verify lease can be broken by upcoming open"
18159 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
18163 $MULTIOP $DIR/$tfile oO_RDONLY:c
18164 kill -USR1 $PID && wait $PID || error "break lease error"
18166 echo "==== test 3: verify lease can't be granted if an open already exists"
18167 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
18171 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
18172 kill -USR1 $PID && wait $PID || error "open file error"
18174 echo "==== test 4: lease can sustain over recovery"
18175 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
18181 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
18183 echo "==== test 5: lease broken can't be regained by replay"
18184 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
18188 # open file to break lease and then recovery
18189 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
18192 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
18196 run_test 208 "Exclusive open"
18199 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
18200 skip_env "must have disp_stripe"
18203 sync; sleep 5; sync;
18205 echo 3 > /proc/sys/vm/drop_caches
18206 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
18207 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
18208 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
18210 # open/close 500 times
18211 for i in $(seq 500); do
18215 echo 3 > /proc/sys/vm/drop_caches
18216 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
18217 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
18218 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
18220 echo "before: $req_before, after: $req_after"
18221 [ $((req_after - req_before)) -ge 300 ] &&
18222 error "open/close requests are not freed"
18225 run_test 209 "read-only open/close requests should be freed promptly"
18230 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
18234 $LFS getstripe $DIR/$tfile
18236 wait $pid || error "multiop failed"
18238 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
18242 $LFS getstripe $DIR/$tfile
18244 wait $pid || error "multiop failed"
18246 run_test 210 "lfs getstripe does not break leases"
18250 size=$((size % 8192 + 1))
18251 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
18252 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
18253 rm -f $DIR/f212 $DIR/f212.xyz
18255 run_test 212 "Sendfile test ============================================"
18258 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
18259 cancel_lru_locks osc
18260 lctl set_param fail_loc=0x8000040f
18261 # generate a read lock
18262 cat $DIR/$tfile > /dev/null
18263 # write to the file, it will try to cancel the above read lock.
18264 cat /etc/hosts >> $DIR/$tfile
18266 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
18268 test_214() { # for bug 20133
18269 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
18270 for (( i=0; i < 340; i++ )) ; do
18271 touch $DIR/$tdir/d214c/a$i
18274 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
18275 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
18276 ls $DIR/d214c || error "ls $DIR/d214c failed"
18277 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
18278 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
18280 run_test 214 "hash-indexed directory test - bug 20133"
18282 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
18283 create_lnet_proc_files() {
18284 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
18287 # counterpart of create_lnet_proc_files
18288 remove_lnet_proc_files() {
18289 rm -f $TMP/lnet_$1.sys
18292 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
18293 # 3rd arg as regexp for body
18294 check_lnet_proc_stats() {
18295 local l=$(cat "$TMP/lnet_$1" |wc -l)
18296 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
18298 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
18301 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
18302 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
18303 # optional and can be regexp for 2nd line (lnet.routes case)
18304 check_lnet_proc_entry() {
18305 local blp=2 # blp stands for 'position of 1st line of body'
18306 [ -z "$5" ] || blp=3 # lnet.routes case
18308 local l=$(cat "$TMP/lnet_$1" |wc -l)
18309 # subtracting one from $blp because the body can be empty
18310 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
18312 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
18313 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
18315 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
18316 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
18318 # bail out if any unexpected line happened
18319 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
18320 [ "$?" != 0 ] || error "$2 misformatted"
18323 test_215() { # for bugs 18102, 21079, 21517
18324 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18326 local N='(0|[1-9][0-9]*)' # non-negative numeric
18327 local P='[1-9][0-9]*' # positive numeric
18328 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
18329 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
18330 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
18331 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
18333 local L1 # regexp for 1st line
18334 local L2 # regexp for 2nd line (optional)
18335 local BR # regexp for the rest (body)
18337 # lnet.stats should look as 11 space-separated non-negative numerics
18338 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
18339 create_lnet_proc_files "stats"
18340 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
18341 remove_lnet_proc_files "stats"
18343 # lnet.routes should look like this:
18344 # Routing disabled/enabled
18345 # net hops priority state router
18346 # where net is a string like tcp0, hops > 0, priority >= 0,
18347 # state is up/down,
18348 # router is a string like 192.168.1.1@tcp2
18349 L1="^Routing (disabled|enabled)$"
18350 L2="^net +hops +priority +state +router$"
18351 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
18352 create_lnet_proc_files "routes"
18353 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
18354 remove_lnet_proc_files "routes"
18356 # lnet.routers should look like this:
18357 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
18358 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
18359 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
18360 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
18361 L1="^ref +rtr_ref +alive +router$"
18362 BR="^$P +$P +(up|down) +$NID$"
18363 create_lnet_proc_files "routers"
18364 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
18365 remove_lnet_proc_files "routers"
18367 # lnet.peers should look like this:
18368 # nid refs state last max rtr min tx min queue
18369 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
18370 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
18371 # numeric (0 or >0 or <0), queue >= 0.
18372 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
18373 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
18374 create_lnet_proc_files "peers"
18375 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
18376 remove_lnet_proc_files "peers"
18378 # lnet.buffers should look like this:
18379 # pages count credits min
18380 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
18381 L1="^pages +count +credits +min$"
18382 BR="^ +$N +$N +$I +$I$"
18383 create_lnet_proc_files "buffers"
18384 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
18385 remove_lnet_proc_files "buffers"
18387 # lnet.nis should look like this:
18388 # nid status alive refs peer rtr max tx min
18389 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
18390 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
18391 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
18392 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
18393 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
18394 create_lnet_proc_files "nis"
18395 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
18396 remove_lnet_proc_files "nis"
18398 # can we successfully write to lnet.stats?
18399 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
18401 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
18403 test_216() { # bug 20317
18404 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18405 remote_ost_nodsh && skip "remote OST with nodsh"
18408 local facets=$(get_facets OST)
18409 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
18411 save_lustre_params client "osc.*.contention_seconds" > $p
18412 save_lustre_params $facets \
18413 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
18414 save_lustre_params $facets \
18415 "ldlm.namespaces.filter-*.contended_locks" >> $p
18416 save_lustre_params $facets \
18417 "ldlm.namespaces.filter-*.contention_seconds" >> $p
18418 clear_stats osc.*.osc_stats
18420 # agressive lockless i/o settings
18421 do_nodes $(comma_list $(osts_nodes)) \
18422 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
18423 ldlm.namespaces.filter-*.contended_locks=0 \
18424 ldlm.namespaces.filter-*.contention_seconds=60"
18425 lctl set_param -n osc.*.contention_seconds=60
18427 $DIRECTIO write $DIR/$tfile 0 10 4096
18428 $CHECKSTAT -s 40960 $DIR/$tfile
18430 # disable lockless i/o
18431 do_nodes $(comma_list $(osts_nodes)) \
18432 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
18433 ldlm.namespaces.filter-*.contended_locks=32 \
18434 ldlm.namespaces.filter-*.contention_seconds=0"
18435 lctl set_param -n osc.*.contention_seconds=0
18436 clear_stats osc.*.osc_stats
18438 dd if=/dev/zero of=$DIR/$tfile count=0
18439 $CHECKSTAT -s 0 $DIR/$tfile
18441 restore_lustre_params <$p
18445 run_test 216 "check lockless direct write updates file size and kms correctly"
18447 test_217() { # bug 22430
18448 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18453 for node in $(nodes_list); do
18454 nid=$(host_nids_address $node $NETTYPE)
18455 if [[ $nid = *-* ]] ; then
18456 echo "lctl ping $(h2nettype $nid)"
18457 lctl ping $(h2nettype $nid)
18459 echo "skipping $node (no hyphen detected)"
18463 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
18466 # do directio so as not to populate the page cache
18467 log "creating a 10 Mb file"
18468 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
18469 log "starting reads"
18470 dd if=$DIR/$tfile of=/dev/null bs=4096 &
18471 log "truncating the file"
18472 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
18474 kill %+ || true # reads might have finished
18475 echo "wait until dd is finished"
18477 log "removing the temporary file"
18478 rm -rf $DIR/$tfile || error "tmp file removal failed"
18480 run_test 218 "parallel read and truncate should not deadlock"
18483 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18485 # write one partial page
18486 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
18487 # set no grant so vvp_io_commit_write will do sync write
18488 $LCTL set_param fail_loc=0x411
18489 # write a full page at the end of file
18490 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
18492 $LCTL set_param fail_loc=0
18493 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
18494 $LCTL set_param fail_loc=0x411
18495 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
18498 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
18499 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
18501 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
18503 test_220() { #LU-325
18504 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18505 remote_ost_nodsh && skip "remote OST with nodsh"
18506 remote_mds_nodsh && skip "remote MDS with nodsh"
18507 remote_mgs_nodsh && skip "remote MGS with nodsh"
18511 # create on MDT0000 so the last_id and next_id are correct
18512 mkdir_on_mdt0 $DIR/$tdir
18513 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
18517 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
18518 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
18519 osp.$mdtosc_proc1.prealloc_last_id)
18520 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
18521 osp.$mdtosc_proc1.prealloc_next_id)
18525 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
18526 #define OBD_FAIL_OST_ENOINO 0x229
18527 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
18528 create_pool $FSNAME.$TESTNAME || return 1
18529 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
18531 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
18533 MDSOBJS=$((last_id - next_id))
18534 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
18536 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
18537 echo "OST still has $count kbytes free"
18539 echo "create $MDSOBJS files @next_id..."
18540 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
18542 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
18543 osp.$mdtosc_proc1.prealloc_last_id)
18544 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
18545 osp.$mdtosc_proc1.prealloc_next_id)
18547 echo "after creation, last_id=$last_id2, next_id=$next_id2"
18552 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
18553 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
18555 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
18556 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
18557 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
18558 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
18559 echo "unlink $MDSOBJS files @$next_id..."
18560 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
18562 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
18565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18567 dd if=`which date` of=$MOUNT/date oflag=sync
18568 chmod +x $MOUNT/date
18570 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
18571 $LCTL set_param fail_loc=0x80001401
18573 $MOUNT/date > /dev/null
18576 run_test 221 "make sure fault and truncate race to not cause OOM"
18579 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18582 test_mkdir $DIR/$tdir
18583 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18584 createmany -o $DIR/$tdir/$tfile 10
18585 cancel_lru_locks mdc
18586 cancel_lru_locks osc
18587 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
18588 $LCTL set_param fail_loc=0x31a
18589 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
18590 $LCTL set_param fail_loc=0
18593 run_test 222a "AGL for ls should not trigger CLIO lock failure"
18596 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18599 test_mkdir $DIR/$tdir
18600 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18601 createmany -o $DIR/$tdir/$tfile 10
18602 cancel_lru_locks mdc
18603 cancel_lru_locks osc
18604 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
18605 $LCTL set_param fail_loc=0x31a
18606 rm -r $DIR/$tdir || error "AGL for rmdir failed"
18607 $LCTL set_param fail_loc=0
18609 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
18612 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18615 test_mkdir $DIR/$tdir
18616 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18617 createmany -o $DIR/$tdir/$tfile 10
18618 cancel_lru_locks mdc
18619 cancel_lru_locks osc
18620 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
18621 $LCTL set_param fail_loc=0x31b
18622 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
18623 $LCTL set_param fail_loc=0
18626 run_test 223 "osc reenqueue if without AGL lock granted ======================="
18628 test_224a() { # LU-1039, MRP-303
18629 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18631 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
18632 $LCTL set_param fail_loc=0x508
18633 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
18634 $LCTL set_param fail_loc=0
18637 run_test 224a "Don't panic on bulk IO failure"
18639 test_224b() { # LU-1039, MRP-303
18640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18642 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
18643 cancel_lru_locks osc
18644 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
18645 $LCTL set_param fail_loc=0x515
18646 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
18647 $LCTL set_param fail_loc=0
18650 run_test 224b "Don't panic on bulk IO failure"
18652 test_224c() { # LU-6441
18653 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18654 remote_mds_nodsh && skip "remote MDS with nodsh"
18656 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
18657 save_writethrough $p
18658 set_cache writethrough on
18660 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
18661 local at_max=$($LCTL get_param -n at_max)
18662 local timeout=$($LCTL get_param -n timeout)
18663 local test_at="at_max"
18664 local param_at="$FSNAME.sys.at_max"
18665 local test_timeout="timeout"
18666 local param_timeout="$FSNAME.sys.timeout"
18668 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
18670 set_persistent_param_and_check client "$test_at" "$param_at" 0
18671 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
18673 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
18674 do_facet ost1 "$LCTL set_param fail_loc=0x520"
18675 $LFS setstripe -c 1 -i 0 $DIR/$tfile
18676 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
18678 do_facet ost1 "$LCTL set_param fail_loc=0"
18680 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
18681 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
18684 $LCTL set_param -n $pages_per_rpc
18685 restore_lustre_params < $p
18688 run_test 224c "Don't hang if one of md lost during large bulk RPC"
18690 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
18692 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18693 if [ -z ${MDSSURVEY} ]; then
18694 skip_env "mds-survey not found"
18696 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
18697 skip "Need MDS version at least 2.2.51"
18699 local mds=$(facet_host $SINGLEMDS)
18700 local target=$(do_nodes $mds 'lctl dl' |
18701 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
18703 local cmd1="file_count=1000 thrhi=4"
18704 local cmd2="dir_count=2 layer=mdd stripe_count=0"
18705 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
18706 local cmd="$cmd1 $cmd2 $cmd3"
18708 rm -f ${TMP}/mds_survey*
18710 eval $cmd || error "mds-survey with zero-stripe failed"
18711 cat ${TMP}/mds_survey*
18712 rm -f ${TMP}/mds_survey*
18714 run_test 225a "Metadata survey sanity with zero-stripe"
18717 if [ -z ${MDSSURVEY} ]; then
18718 skip_env "mds-survey not found"
18720 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
18721 skip "Need MDS version at least 2.2.51"
18722 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18723 remote_mds_nodsh && skip "remote MDS with nodsh"
18724 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
18725 skip_env "Need to mount OST to test"
18728 local mds=$(facet_host $SINGLEMDS)
18729 local target=$(do_nodes $mds 'lctl dl' |
18730 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
18732 local cmd1="file_count=1000 thrhi=4"
18733 local cmd2="dir_count=2 layer=mdd stripe_count=1"
18734 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
18735 local cmd="$cmd1 $cmd2 $cmd3"
18737 rm -f ${TMP}/mds_survey*
18739 eval $cmd || error "mds-survey with stripe_count failed"
18740 cat ${TMP}/mds_survey*
18741 rm -f ${TMP}/mds_survey*
18743 run_test 225b "Metadata survey sanity with stripe_count = 1"
18745 mcreate_path2fid () {
18751 local path=$DIR/$tdir/$name
18756 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
18757 error "cannot create $desc"
18759 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
18761 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
18763 fid_path=$($LFS fid2path $MOUNT $fid)
18765 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
18767 [ "$path" == "$fid_path" ] ||
18768 error "fid2path returned $fid_path, expected $path"
18770 echo "pass with $path and $fid"
18775 mkdir -p $DIR/$tdir
18777 mcreate_path2fid 0010666 0 0 fifo "FIFO"
18778 mcreate_path2fid 0020666 1 3 null "character special file (null)"
18779 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
18780 mcreate_path2fid 0040666 0 0 dir "directory"
18781 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
18782 mcreate_path2fid 0100666 0 0 file "regular file"
18783 mcreate_path2fid 0120666 0 0 link "symbolic link"
18784 mcreate_path2fid 0140666 0 0 sock "socket"
18786 run_test 226a "call path2fid and fid2path on files of all type"
18789 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18794 mkdir -p $DIR/$tdir
18795 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
18796 error "create remote directory failed"
18797 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
18798 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
18799 "character special file (null)"
18800 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
18801 "character special file (no device)"
18802 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
18803 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
18804 "block special file (loop)"
18805 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
18806 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
18807 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
18809 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
18812 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18813 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
18814 skip "Need MDS version at least 2.13.55"
18816 local submnt=/mnt/submnt
18817 local srcfile=/etc/passwd
18818 local dstfile=$submnt/passwd
18824 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
18825 error "create remote directory failed"
18826 mkdir -p $submnt || error "create $submnt failed"
18827 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
18828 error "mount $submnt failed"
18829 stack_trap "umount $submnt" EXIT
18831 cp $srcfile $dstfile
18832 fid=$($LFS path2fid $dstfile)
18833 path=$($LFS fid2path $submnt "$fid")
18834 [ "$path" = "$dstfile" ] ||
18835 error "fid2path $submnt $fid failed ($path != $dstfile)"
18837 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
18839 # LU-1299 Executing or running ldd on a truncated executable does not
18840 # cause an out-of-memory condition.
18842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18843 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
18845 dd if=$(which date) of=$MOUNT/date bs=1k count=1
18846 chmod +x $MOUNT/date
18848 $MOUNT/date > /dev/null
18849 ldd $MOUNT/date > /dev/null
18852 run_test 227 "running truncated executable does not cause OOM"
18854 # LU-1512 try to reuse idle OI blocks
18856 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18857 remote_mds_nodsh && skip "remote MDS with nodsh"
18858 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
18860 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
18861 local myDIR=$DIR/$tdir
18864 #define OBD_FAIL_SEQ_EXHAUST 0x1002
18865 $LCTL set_param fail_loc=0x80001002
18866 createmany -o $myDIR/t- 10000
18867 $LCTL set_param fail_loc=0
18868 # The guard is current the largest FID holder
18870 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
18872 local IDX=$(($SEQ % 64))
18874 do_facet $SINGLEMDS sync
18875 # Make sure journal flushed.
18877 local blk1=$(do_facet $SINGLEMDS \
18878 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18879 grep Blockcount | awk '{print $4}')
18881 # Remove old files, some OI blocks will become idle.
18882 unlinkmany $myDIR/t- 10000
18883 # Create new files, idle OI blocks should be reused.
18884 createmany -o $myDIR/t- 2000
18885 do_facet $SINGLEMDS sync
18886 # Make sure journal flushed.
18888 local blk2=$(do_facet $SINGLEMDS \
18889 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18890 grep Blockcount | awk '{print $4}')
18892 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
18894 run_test 228a "try to reuse idle OI blocks"
18897 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18898 remote_mds_nodsh && skip "remote MDS with nodsh"
18899 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
18901 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
18902 local myDIR=$DIR/$tdir
18905 #define OBD_FAIL_SEQ_EXHAUST 0x1002
18906 $LCTL set_param fail_loc=0x80001002
18907 createmany -o $myDIR/t- 10000
18908 $LCTL set_param fail_loc=0
18909 # The guard is current the largest FID holder
18911 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
18913 local IDX=$(($SEQ % 64))
18915 do_facet $SINGLEMDS sync
18916 # Make sure journal flushed.
18918 local blk1=$(do_facet $SINGLEMDS \
18919 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18920 grep Blockcount | awk '{print $4}')
18922 # Remove old files, some OI blocks will become idle.
18923 unlinkmany $myDIR/t- 10000
18926 stop $SINGLEMDS || error "Fail to stop MDT."
18928 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
18930 df $MOUNT || error "Fail to df."
18931 # Create new files, idle OI blocks should be reused.
18932 createmany -o $myDIR/t- 2000
18933 do_facet $SINGLEMDS sync
18934 # Make sure journal flushed.
18936 local blk2=$(do_facet $SINGLEMDS \
18937 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18938 grep Blockcount | awk '{print $4}')
18940 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
18942 run_test 228b "idle OI blocks can be reused after MDT restart"
18946 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18947 remote_mds_nodsh && skip "remote MDS with nodsh"
18948 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
18950 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
18951 local myDIR=$DIR/$tdir
18954 #define OBD_FAIL_SEQ_EXHAUST 0x1002
18955 $LCTL set_param fail_loc=0x80001002
18956 # 20000 files can guarantee there are index nodes in the OI file
18957 createmany -o $myDIR/t- 20000
18958 $LCTL set_param fail_loc=0
18959 # The guard is current the largest FID holder
18961 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
18963 local IDX=$(($SEQ % 64))
18965 do_facet $SINGLEMDS sync
18966 # Make sure journal flushed.
18968 local blk1=$(do_facet $SINGLEMDS \
18969 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18970 grep Blockcount | awk '{print $4}')
18972 # Remove old files, some OI blocks will become idle.
18973 unlinkmany $myDIR/t- 20000
18975 # The OI file should become empty now
18977 # Create new files, idle OI blocks should be reused.
18978 createmany -o $myDIR/t- 2000
18979 do_facet $SINGLEMDS sync
18980 # Make sure journal flushed.
18982 local blk2=$(do_facet $SINGLEMDS \
18983 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18984 grep Blockcount | awk '{print $4}')
18986 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
18988 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
18990 test_229() { # LU-2482, LU-3448
18991 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18992 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
18993 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
18994 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
18998 # Create a file with a released layout and stripe count 2.
18999 $MULTIOP $DIR/$tfile H2c ||
19000 error "failed to create file with released layout"
19002 $LFS getstripe -v $DIR/$tfile
19004 local pattern=$($LFS getstripe -L $DIR/$tfile)
19005 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
19007 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
19009 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
19010 stat $DIR/$tfile || error "failed to stat released file"
19012 chown $RUNAS_ID $DIR/$tfile ||
19013 error "chown $RUNAS_ID $DIR/$tfile failed"
19015 chgrp $RUNAS_ID $DIR/$tfile ||
19016 error "chgrp $RUNAS_ID $DIR/$tfile failed"
19018 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
19019 rm $DIR/$tfile || error "failed to remove released file"
19021 run_test 229 "getstripe/stat/rm/attr changes work on released files"
19024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19025 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19026 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19027 skip "Need MDS version at least 2.11.52"
19031 test_mkdir $DIR/$tdir
19032 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
19033 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
19034 [ $mdt_idx -ne 0 ] &&
19035 error "create local directory on wrong MDT $mdt_idx"
19037 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
19038 error "create remote directory failed"
19039 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
19040 [ $mdt_idx -ne $MDTIDX ] &&
19041 error "create remote directory on wrong MDT $mdt_idx"
19043 createmany -o $DIR/$tdir/test_230/t- 10 ||
19044 error "create files on remote directory failed"
19045 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
19046 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
19047 rm -r $DIR/$tdir || error "unlink remote directory failed"
19049 run_test 230a "Create remote directory and files under the remote directory"
19052 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19053 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19054 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19055 skip "Need MDS version at least 2.11.52"
19063 local migrate_dir=$DIR/$tdir/migrate_dir
19064 local other_dir=$DIR/$tdir/other_dir
19066 test_mkdir $DIR/$tdir
19067 test_mkdir -i0 -c1 $migrate_dir
19068 test_mkdir -i0 -c1 $other_dir
19069 for ((i=0; i<10; i++)); do
19070 mkdir -p $migrate_dir/dir_${i}
19071 createmany -o $migrate_dir/dir_${i}/f 10 ||
19072 error "create files under remote dir failed $i"
19075 cp /etc/passwd $migrate_dir/$tfile
19076 cp /etc/passwd $other_dir/$tfile
19077 chattr +SAD $migrate_dir
19078 chattr +SAD $migrate_dir/$tfile
19080 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19081 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19082 local old_dir_mode=$(stat -c%f $migrate_dir)
19083 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
19085 mkdir -p $migrate_dir/dir_default_stripe2
19086 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
19087 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
19089 mkdir -p $other_dir
19090 ln $migrate_dir/$tfile $other_dir/luna
19091 ln $migrate_dir/$tfile $migrate_dir/sofia
19092 ln $other_dir/$tfile $migrate_dir/david
19093 ln -s $migrate_dir/$tfile $other_dir/zachary
19094 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
19095 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
19101 for len in 58 59 60; do
19102 lnktgt=$(str_repeat 'l' $len)
19103 touch $migrate_dir/$lnktgt
19104 ln -s $lnktgt $migrate_dir/${len}char_ln
19108 for len in 4094 4095; do
19109 lnktgt=$(str_repeat 'l' $len)
19110 ln -s $lnktgt $migrate_dir/${len}char_ln
19114 for len in 254 255; do
19115 touch $migrate_dir/$(str_repeat 'l' $len)
19118 $LFS migrate -m $MDTIDX $migrate_dir ||
19119 error "fails on migrating remote dir to MDT1"
19121 echo "migratate to MDT1, then checking.."
19122 for ((i = 0; i < 10; i++)); do
19123 for file in $(find $migrate_dir/dir_${i}); do
19124 mdt_index=$($LFS getstripe -m $file)
19125 # broken symlink getstripe will fail
19126 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
19127 error "$file is not on MDT${MDTIDX}"
19131 # the multiple link file should still in MDT0
19132 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
19133 [ $mdt_index == 0 ] ||
19134 error "$file is not on MDT${MDTIDX}"
19136 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19137 [ "$old_dir_flag" = "$new_dir_flag" ] ||
19138 error " expect $old_dir_flag get $new_dir_flag"
19140 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19141 [ "$old_file_flag" = "$new_file_flag" ] ||
19142 error " expect $old_file_flag get $new_file_flag"
19144 local new_dir_mode=$(stat -c%f $migrate_dir)
19145 [ "$old_dir_mode" = "$new_dir_mode" ] ||
19146 error "expect mode $old_dir_mode get $new_dir_mode"
19148 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
19149 [ "$old_file_mode" = "$new_file_mode" ] ||
19150 error "expect mode $old_file_mode get $new_file_mode"
19152 diff /etc/passwd $migrate_dir/$tfile ||
19153 error "$tfile different after migration"
19155 diff /etc/passwd $other_dir/luna ||
19156 error "luna different after migration"
19158 diff /etc/passwd $migrate_dir/sofia ||
19159 error "sofia different after migration"
19161 diff /etc/passwd $migrate_dir/david ||
19162 error "david different after migration"
19164 diff /etc/passwd $other_dir/zachary ||
19165 error "zachary different after migration"
19167 diff /etc/passwd $migrate_dir/${tfile}_ln ||
19168 error "${tfile}_ln different after migration"
19170 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
19171 error "${tfile}_ln_other different after migration"
19173 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
19174 [ $stripe_count = 2 ] ||
19175 error "dir strpe_count $d != 2 after migration."
19177 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
19178 [ $stripe_count = 2 ] ||
19179 error "file strpe_count $d != 2 after migration."
19181 #migrate back to MDT0
19184 $LFS migrate -m $MDTIDX $migrate_dir ||
19185 error "fails on migrating remote dir to MDT0"
19187 echo "migrate back to MDT0, checking.."
19188 for file in $(find $migrate_dir); do
19189 mdt_index=$($LFS getstripe -m $file)
19190 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
19191 error "$file is not on MDT${MDTIDX}"
19194 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19195 [ "$old_dir_flag" = "$new_dir_flag" ] ||
19196 error " expect $old_dir_flag get $new_dir_flag"
19198 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19199 [ "$old_file_flag" = "$new_file_flag" ] ||
19200 error " expect $old_file_flag get $new_file_flag"
19202 local new_dir_mode=$(stat -c%f $migrate_dir)
19203 [ "$old_dir_mode" = "$new_dir_mode" ] ||
19204 error "expect mode $old_dir_mode get $new_dir_mode"
19206 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
19207 [ "$old_file_mode" = "$new_file_mode" ] ||
19208 error "expect mode $old_file_mode get $new_file_mode"
19210 diff /etc/passwd ${migrate_dir}/$tfile ||
19211 error "$tfile different after migration"
19213 diff /etc/passwd ${other_dir}/luna ||
19214 error "luna different after migration"
19216 diff /etc/passwd ${migrate_dir}/sofia ||
19217 error "sofia different after migration"
19219 diff /etc/passwd ${other_dir}/zachary ||
19220 error "zachary different after migration"
19222 diff /etc/passwd $migrate_dir/${tfile}_ln ||
19223 error "${tfile}_ln different after migration"
19225 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
19226 error "${tfile}_ln_other different after migration"
19228 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
19229 [ $stripe_count = 2 ] ||
19230 error "dir strpe_count $d != 2 after migration."
19232 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
19233 [ $stripe_count = 2 ] ||
19234 error "file strpe_count $d != 2 after migration."
19236 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19238 run_test 230b "migrate directory"
19241 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19242 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19243 remote_mds_nodsh && skip "remote MDS with nodsh"
19244 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19245 skip "Need MDS version at least 2.11.52"
19251 local migrate_dir=$DIR/$tdir/migrate_dir
19253 #If migrating directory fails in the middle, all entries of
19254 #the directory is still accessiable.
19255 test_mkdir $DIR/$tdir
19256 test_mkdir -i0 -c1 $migrate_dir
19257 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
19259 createmany -o $migrate_dir/f $total ||
19260 error "create files under ${migrate_dir} failed"
19262 # fail after migrating top dir, and this will fail only once, so the
19263 # first sub file migration will fail (currently f3), others succeed.
19264 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
19265 do_facet mds1 lctl set_param fail_loc=0x1801
19266 local t=$(ls $migrate_dir | wc -l)
19267 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
19268 error "migrate should fail"
19269 local u=$(ls $migrate_dir | wc -l)
19270 [ "$u" == "$t" ] || error "$u != $t during migration"
19272 # add new dir/file should succeed
19273 mkdir $migrate_dir/dir ||
19274 error "mkdir failed under migrating directory"
19275 touch $migrate_dir/file ||
19276 error "create file failed under migrating directory"
19278 # add file with existing name should fail
19279 for file in $migrate_dir/f*; do
19280 stat $file > /dev/null || error "stat $file failed"
19281 $OPENFILE -f O_CREAT:O_EXCL $file &&
19282 error "open(O_CREAT|O_EXCL) $file should fail"
19283 $MULTIOP $file m && error "create $file should fail"
19284 touch $DIR/$tdir/remote_dir/$tfile ||
19285 error "touch $tfile failed"
19286 ln $DIR/$tdir/remote_dir/$tfile $file &&
19287 error "link $file should fail"
19288 mdt_index=$($LFS getstripe -m $file)
19289 if [ $mdt_index == 0 ]; then
19290 # file failed to migrate is not allowed to rename to
19291 mv $DIR/$tdir/remote_dir/$tfile $file &&
19292 error "rename to $file should fail"
19294 mv $DIR/$tdir/remote_dir/$tfile $file ||
19295 error "rename to $file failed"
19297 echo hello >> $file || error "write $file failed"
19300 # resume migration with different options should fail
19301 $LFS migrate -m 0 $migrate_dir &&
19302 error "migrate -m 0 $migrate_dir should fail"
19304 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
19305 error "migrate -c 2 $migrate_dir should fail"
19307 # resume migration should succeed
19308 $LFS migrate -m $MDTIDX $migrate_dir ||
19309 error "migrate $migrate_dir failed"
19311 echo "Finish migration, then checking.."
19312 for file in $(find $migrate_dir); do
19313 mdt_index=$($LFS getstripe -m $file)
19314 [ $mdt_index == $MDTIDX ] ||
19315 error "$file is not on MDT${MDTIDX}"
19318 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19320 run_test 230c "check directory accessiblity if migration failed"
19323 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19324 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19325 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19326 skip "Need MDS version at least 2.11.52"
19328 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
19330 local migrate_dir=$DIR/$tdir/migrate_dir
19340 old_index=$((RANDOM % MDSCOUNT))
19341 old_count=$((MDSCOUNT - old_index))
19342 new_index=$((RANDOM % MDSCOUNT))
19343 new_count=$((MDSCOUNT - new_index))
19344 new_hash=1 # for all_char
19346 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
19347 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
19349 test_mkdir $DIR/$tdir
19350 test_mkdir -i $old_index -c $old_count $migrate_dir
19352 for ((i=0; i<100; i++)); do
19353 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
19354 createmany -o $migrate_dir/dir_${i}/f 100 ||
19355 error "create files under remote dir failed $i"
19358 echo -n "Migrate from MDT$old_index "
19359 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
19360 echo -n "to MDT$new_index"
19361 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
19364 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
19365 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
19366 error "migrate remote dir error"
19368 echo "Finish migration, then checking.."
19369 for file in $(find $migrate_dir); do
19370 mdt_index=$($LFS getstripe -m $file)
19371 if [ $mdt_index -lt $new_index ] ||
19372 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
19373 error "$file is on MDT$mdt_index"
19377 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19379 run_test 230d "check migrate big directory"
19382 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19383 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19384 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19385 skip "Need MDS version at least 2.11.52"
19392 mkdir_on_mdt0 $DIR/$tdir
19393 mkdir $DIR/$tdir/migrate_dir
19394 mkdir $DIR/$tdir/other_dir
19395 touch $DIR/$tdir/migrate_dir/a
19396 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
19397 ls $DIR/$tdir/other_dir
19399 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
19400 error "migrate dir fails"
19402 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
19403 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
19405 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19406 [ $mdt_index == 0 ] || error "a is not on MDT0"
19408 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
19409 error "migrate dir fails"
19411 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
19412 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
19414 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19415 [ $mdt_index == 1 ] || error "a is not on MDT1"
19417 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
19418 [ $mdt_index == 1 ] || error "b is not on MDT1"
19420 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
19421 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
19423 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
19425 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19427 run_test 230e "migrate mulitple local link files"
19430 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19431 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19432 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19433 skip "Need MDS version at least 2.11.52"
19438 mkdir -p $DIR/$tdir
19439 mkdir $DIR/$tdir/migrate_dir
19440 $LFS mkdir -i1 $DIR/$tdir/other_dir
19441 touch $DIR/$tdir/migrate_dir/a
19442 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
19443 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
19444 ls $DIR/$tdir/other_dir
19446 # a should be migrated to MDT1, since no other links on MDT0
19447 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
19448 error "#1 migrate dir fails"
19449 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
19450 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
19451 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19452 [ $mdt_index == 1 ] || error "a is not on MDT1"
19454 # a should stay on MDT1, because it is a mulitple link file
19455 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
19456 error "#2 migrate dir fails"
19457 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19458 [ $mdt_index == 1 ] || error "a is not on MDT1"
19460 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
19461 error "#3 migrate dir fails"
19463 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
19464 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
19465 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
19467 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
19468 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
19470 # a should be migrated to MDT0, since no other links on MDT1
19471 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
19472 error "#4 migrate dir fails"
19473 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19474 [ $mdt_index == 0 ] || error "a is not on MDT0"
19476 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19478 run_test 230f "migrate mulitple remote link files"
19481 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19482 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19483 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19484 skip "Need MDS version at least 2.11.52"
19486 mkdir -p $DIR/$tdir/migrate_dir
19488 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
19489 error "migrating dir to non-exist MDT succeeds"
19492 run_test 230g "migrate dir to non-exist MDT"
19495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19496 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19497 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19498 skip "Need MDS version at least 2.11.52"
19502 mkdir -p $DIR/$tdir/migrate_dir
19504 $LFS migrate -m1 $DIR &&
19505 error "migrating mountpoint1 should fail"
19507 $LFS migrate -m1 $DIR/$tdir/.. &&
19508 error "migrating mountpoint2 should fail"
19511 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
19512 error "migrating $tdir/migrate_dir/.. should fail"
19516 run_test 230h "migrate .. and root"
19519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19520 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19521 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19522 skip "Need MDS version at least 2.11.52"
19524 mkdir -p $DIR/$tdir/migrate_dir
19526 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
19527 error "migration fails with a tailing slash"
19529 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
19530 error "migration fails with two tailing slashes"
19532 run_test 230i "lfs migrate -m tolerates trailing slashes"
19535 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19536 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
19537 skip "Need MDS version at least 2.11.52"
19539 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
19540 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
19541 error "create $tfile failed"
19542 cat /etc/passwd > $DIR/$tdir/$tfile
19544 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
19546 cmp /etc/passwd $DIR/$tdir/$tfile ||
19547 error "DoM file mismatch after migration"
19549 run_test 230j "DoM file data not changed after dir migration"
19552 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
19553 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
19554 skip "Need MDS version at least 2.11.56"
19557 local files_on_starting_mdt=0
19559 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
19560 $LFS getdirstripe $DIR/$tdir
19561 for i in $(seq $total); do
19562 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
19563 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
19564 files_on_starting_mdt=$((files_on_starting_mdt + 1))
19567 echo "$files_on_starting_mdt files on MDT0"
19569 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
19570 $LFS getdirstripe $DIR/$tdir
19572 files_on_starting_mdt=0
19573 for i in $(seq $total); do
19574 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
19575 error "file $tfile.$i mismatch after migration"
19576 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
19577 files_on_starting_mdt=$((files_on_starting_mdt + 1))
19580 echo "$files_on_starting_mdt files on MDT1 after migration"
19581 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
19583 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
19584 $LFS getdirstripe $DIR/$tdir
19586 files_on_starting_mdt=0
19587 for i in $(seq $total); do
19588 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
19589 error "file $tfile.$i mismatch after 2nd migration"
19590 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
19591 files_on_starting_mdt=$((files_on_starting_mdt + 1))
19594 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
19595 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
19599 run_test 230k "file data not changed after dir migration"
19602 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19603 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
19604 skip "Need MDS version at least 2.11.56"
19606 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
19607 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
19608 error "create files under remote dir failed $i"
19609 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
19611 run_test 230l "readdir between MDTs won't crash"
19614 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19615 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
19616 skip "Need MDS version at least 2.11.56"
19619 local mig_dir=$DIR/$tdir/migrate_dir
19620 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
19624 echo "Creating files and dirs with xattrs"
19625 test_mkdir $DIR/$tdir
19626 test_mkdir -i0 -c1 $mig_dir
19628 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
19629 error "cannot set xattr attr1 on dir"
19630 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
19631 error "cannot set xattr attr2 on dir"
19632 touch $mig_dir/dir/f0
19633 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
19634 error "cannot set xattr attr1 on file"
19635 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
19636 error "cannot set xattr attr2 on file"
19637 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
19638 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
19639 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
19640 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
19641 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
19642 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
19643 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
19644 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
19645 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
19647 echo "Migrating to MDT1"
19648 $LFS migrate -m $MDTIDX $mig_dir ||
19649 error "fails on migrating dir to MDT1"
19651 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
19652 echo "Checking xattrs"
19653 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
19654 [ "$val" = $longstr ] ||
19655 error "expecting xattr1 $longstr on dir, found $val"
19656 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
19657 [ "$val" = $shortstr ] ||
19658 error "expecting xattr2 $shortstr on dir, found $val"
19659 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
19660 [ "$val" = $longstr ] ||
19661 error "expecting xattr1 $longstr on file, found $val"
19662 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
19663 [ "$val" = $shortstr ] ||
19664 error "expecting xattr2 $shortstr on file, found $val"
19666 run_test 230m "xattrs not changed after dir migration"
19669 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19670 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
19671 skip "Need MDS version at least 2.13.53"
19673 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
19674 cat /etc/hosts > $DIR/$tdir/$tfile
19675 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
19676 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
19678 cmp /etc/hosts $DIR/$tdir/$tfile ||
19679 error "File data mismatch after migration"
19681 run_test 230n "Dir migration with mirrored file"
19684 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
19685 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
19686 skip "Need MDS version at least 2.13.52"
19688 local mdts=$(comma_list $(mdts_nodes))
19690 local restripe_status
19694 [[ $mds1_FSTYPE == zfs ]] && timeout=300
19696 # in case "crush" hash type is not set
19697 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
19699 restripe_status=$(do_facet mds1 $LCTL get_param -n \
19700 mdt.*MDT0000.enable_dir_restripe)
19701 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
19702 stack_trap "do_nodes $mdts $LCTL set_param \
19703 mdt.*.enable_dir_restripe=$restripe_status"
19706 createmany -m $DIR/$tdir/f 100 ||
19707 error "create files under remote dir failed $i"
19708 createmany -d $DIR/$tdir/d 100 ||
19709 error "create dirs under remote dir failed $i"
19711 for i in $(seq 2 $MDSCOUNT); do
19712 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
19713 $LFS setdirstripe -c $i $DIR/$tdir ||
19714 error "split -c $i $tdir failed"
19715 wait_update $HOSTNAME \
19716 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
19717 error "dir split not finished"
19718 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
19719 awk '/migrate/ {sum += $2} END { print sum }')
19720 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
19721 # delta is around total_files/stripe_count
19722 (( $delta < 200 / (i - 1) + 4 )) ||
19723 error "$delta files migrated >= $((200 / (i - 1) + 4))"
19726 run_test 230o "dir split"
19729 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
19730 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
19731 skip "Need MDS version at least 2.13.52"
19733 local mdts=$(comma_list $(mdts_nodes))
19735 local restripe_status
19739 [[ $mds1_FSTYPE == zfs ]] && timeout=300
19741 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
19743 restripe_status=$(do_facet mds1 $LCTL get_param -n \
19744 mdt.*MDT0000.enable_dir_restripe)
19745 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
19746 stack_trap "do_nodes $mdts $LCTL set_param \
19747 mdt.*.enable_dir_restripe=$restripe_status"
19749 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
19750 createmany -m $DIR/$tdir/f 100 ||
19751 error "create files under remote dir failed"
19752 createmany -d $DIR/$tdir/d 100 ||
19753 error "create dirs under remote dir failed"
19755 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
19756 local mdt_hash="crush"
19758 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
19759 $LFS setdirstripe -c $c $DIR/$tdir ||
19760 error "split -c $c $tdir failed"
19761 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
19762 mdt_hash="$mdt_hash,fixed"
19763 elif [ $c -eq 1 ]; then
19766 wait_update $HOSTNAME \
19767 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
19768 error "dir merge not finished"
19769 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
19770 awk '/migrate/ {sum += $2} END { print sum }')
19771 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
19772 # delta is around total_files/stripe_count
19773 (( delta < 200 / c + 4 )) ||
19774 error "$delta files migrated >= $((200 / c + 4))"
19777 run_test 230p "dir merge"
19780 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
19781 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
19782 skip "Need MDS version at least 2.13.52"
19784 local mdts=$(comma_list $(mdts_nodes))
19785 local saved_threshold=$(do_facet mds1 \
19786 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
19787 local saved_delta=$(do_facet mds1 \
19788 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
19789 local threshold=100
19792 local stripe_count=0
19797 # test with fewer files on ZFS
19798 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
19800 stack_trap "do_nodes $mdts $LCTL set_param \
19801 mdt.*.dir_split_count=$saved_threshold"
19802 stack_trap "do_nodes $mdts $LCTL set_param \
19803 mdt.*.dir_split_delta=$saved_delta"
19804 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
19805 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
19806 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
19807 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
19808 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
19809 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
19811 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
19812 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
19814 create=$((threshold * 3 / 2))
19815 while [ $stripe_count -lt $MDSCOUNT ]; do
19816 createmany -m $DIR/$tdir/f $total $create ||
19817 error "create sub files failed"
19818 stat $DIR/$tdir > /dev/null
19819 total=$((total + create))
19820 stripe_count=$((stripe_count + delta))
19821 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
19823 wait_update $HOSTNAME \
19824 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
19825 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
19827 wait_update $HOSTNAME \
19828 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
19829 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
19831 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
19832 echo "$nr_files/$total files on MDT$stripe_index after split"
19833 # allow 10% margin of imbalance with crush hash
19834 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
19835 error "$nr_files files on MDT$stripe_index after split"
19837 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
19838 [ $nr_files -eq $total ] ||
19839 error "total sub files $nr_files != $total"
19842 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
19844 echo "fixed layout directory won't auto split"
19845 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
19846 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
19847 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
19848 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
19849 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
19851 run_test 230q "dir auto split"
19854 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
19855 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
19856 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
19857 skip "Need MDS version at least 2.13.54"
19859 # maximum amount of local locks:
19860 # parent striped dir - 2 locks
19861 # new stripe in parent to migrate to - 1 lock
19862 # source and target - 2 locks
19863 # Total 5 locks for regular file
19864 mkdir -p $DIR/$tdir
19865 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
19866 touch $DIR/$tdir/dir1/eee
19868 # create 4 hardlink for 4 more locks
19869 # Total: 9 locks > RS_MAX_LOCKS (8)
19870 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
19871 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
19872 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
19873 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
19874 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
19875 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
19876 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
19877 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
19879 cancel_lru_locks mdc
19881 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
19882 error "migrate dir fails"
19884 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19886 run_test 230r "migrate with too many local locks"
19889 [ $MDS1_VERSION -ge $(version_code 2.13.57) ] ||
19890 skip "Need MDS version at least 2.13.57"
19892 local mdts=$(comma_list $(mdts_nodes))
19893 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
19894 mdt.*MDT0000.enable_dir_restripe)
19896 stack_trap "do_nodes $mdts $LCTL set_param \
19897 mdt.*.enable_dir_restripe=$restripe_status"
19901 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
19902 test_mkdir $DIR/$tdir
19903 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
19904 error "$LFS mkdir doesn't return -EEXIST if target exists"
19908 run_test 230s "lfs mkdir should return -EEXIST if target exists"
19912 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
19913 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
19914 skip "Need MDS version at least 2.14.50"
19916 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
19917 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
19918 $LFS project -p 1 -s $DIR/$tdir ||
19919 error "set $tdir project id failed"
19920 $LFS project -p 2 -s $DIR/$tdir/subdir ||
19921 error "set subdir project id failed"
19922 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
19924 run_test 230t "migrate directory with project ID set"
19928 # For simplicity this test assumes that max_pages_per_rpc
19929 # is the same across all OSCs
19930 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
19931 local bulk_size=$((max_pages * PAGE_SIZE))
19932 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
19935 mkdir -p $DIR/$tdir
19936 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
19937 error "failed to set stripe with -S ${brw_size}M option"
19939 # clear the OSC stats
19940 $LCTL set_param osc.*.stats=0 &>/dev/null
19943 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
19944 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
19945 oflag=direct &>/dev/null || error "dd failed"
19947 sync; sleep 1; sync # just to be safe
19948 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
19949 if [ x$nrpcs != "x1" ]; then
19950 $LCTL get_param osc.*.stats
19951 error "found $nrpcs ost_write RPCs, not 1 as expected"
19955 # Drop the OSC cache, otherwise we will read from it
19956 cancel_lru_locks osc
19958 # clear the OSC stats
19959 $LCTL set_param osc.*.stats=0 &>/dev/null
19961 # Client reads $bulk_size.
19962 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
19963 iflag=direct &>/dev/null || error "dd failed"
19965 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
19966 if [ x$nrpcs != "x1" ]; then
19967 $LCTL get_param osc.*.stats
19968 error "found $nrpcs ost_read RPCs, not 1 as expected"
19971 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
19974 mkdir -p $DIR/$tdir
19976 for i in {0..1023}; do
19977 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
19978 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
19979 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
19983 run_test 231b "must not assert on fully utilized OST request buffer"
19986 mkdir -p $DIR/$tdir
19987 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
19989 #define OBD_FAIL_LDLM_OST_LVB 0x31c
19990 do_facet ost1 $LCTL set_param fail_loc=0x31c
19992 # ignore dd failure
19993 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
19995 do_facet ost1 $LCTL set_param fail_loc=0
19996 umount_client $MOUNT || error "umount failed"
19997 mount_client $MOUNT || error "mount failed"
19998 stop ost1 || error "cannot stop ost1"
19999 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
20001 run_test 232a "failed lock should not block umount"
20004 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
20005 skip "Need MDS version at least 2.10.58"
20007 mkdir -p $DIR/$tdir
20008 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
20009 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
20011 cancel_lru_locks osc
20013 #define OBD_FAIL_LDLM_OST_LVB 0x31c
20014 do_facet ost1 $LCTL set_param fail_loc=0x31c
20017 $LFS data_version $DIR/$tdir/$tfile || true
20019 do_facet ost1 $LCTL set_param fail_loc=0
20020 umount_client $MOUNT || error "umount failed"
20021 mount_client $MOUNT || error "mount failed"
20022 stop ost1 || error "cannot stop ost1"
20023 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
20025 run_test 232b "failed data version lock should not block umount"
20028 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
20029 skip "Need MDS version at least 2.3.64"
20030 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
20032 local fid=$($LFS path2fid $MOUNT)
20034 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20035 error "cannot access $MOUNT using its FID '$fid'"
20037 run_test 233a "checking that OBF of the FS root succeeds"
20040 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
20041 skip "Need MDS version at least 2.5.90"
20042 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
20044 local fid=$($LFS path2fid $MOUNT/.lustre)
20046 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20047 error "cannot access $MOUNT/.lustre using its FID '$fid'"
20049 fid=$($LFS path2fid $MOUNT/.lustre/fid)
20050 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20051 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
20053 run_test 233b "checking that OBF of the FS .lustre succeeds"
20056 local p="$TMP/sanityN-$TESTNAME.parameters"
20057 save_lustre_params client "llite.*.xattr_cache" > $p
20058 lctl set_param llite.*.xattr_cache 1 ||
20059 skip_env "xattr cache is not supported"
20061 mkdir -p $DIR/$tdir || error "mkdir failed"
20062 touch $DIR/$tdir/$tfile || error "touch failed"
20063 # OBD_FAIL_LLITE_XATTR_ENOMEM
20064 $LCTL set_param fail_loc=0x1405
20065 getfattr -n user.attr $DIR/$tdir/$tfile &&
20066 error "getfattr should have failed with ENOMEM"
20067 $LCTL set_param fail_loc=0x0
20070 restore_lustre_params < $p
20073 run_test 234 "xattr cache should not crash on ENOMEM"
20076 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
20077 skip "Need MDS version at least 2.4.52"
20079 flock_deadlock $DIR/$tfile
20084 124) error "process hangs on a deadlock"
20086 *) error "error executing flock_deadlock $DIR/$tfile"
20090 run_test 235 "LU-1715: flock deadlock detection does not work properly"
20094 check_swap_layouts_support
20096 local ref1=/etc/passwd
20097 local ref2=/etc/group
20098 local file1=$DIR/$tdir/f1
20099 local file2=$DIR/$tdir/f2
20101 test_mkdir -c1 $DIR/$tdir
20102 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
20103 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
20104 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
20105 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
20106 local fd=$(free_fd)
20107 local cmd="exec $fd<>$file2"
20110 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
20111 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
20114 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
20119 run_test 236 "Layout swap on open unlinked file"
20121 # LU-4659 linkea consistency
20123 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
20124 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
20125 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
20126 skip "Need MDS version at least 2.5.58 or 2.5.2+"
20129 ln $DIR/$tfile $DIR/$tfile.lnk
20130 touch $DIR/$tfile.new
20131 mv $DIR/$tfile.new $DIR/$tfile
20132 local fid1=$($LFS path2fid $DIR/$tfile)
20133 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
20134 local path1=$($LFS fid2path $FSNAME "$fid1")
20135 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
20136 local path2=$($LFS fid2path $FSNAME "$fid2")
20137 [ $tfile.lnk == $path2 ] ||
20138 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
20141 run_test 238 "Verify linkea consistency"
20143 test_239A() { # was test_239
20144 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
20145 skip "Need MDS version at least 2.5.60"
20147 local list=$(comma_list $(mdts_nodes))
20149 mkdir -p $DIR/$tdir
20150 createmany -o $DIR/$tdir/f- 5000
20151 unlinkmany $DIR/$tdir/f- 5000
20152 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
20153 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
20154 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
20155 osp.*MDT*.sync_in_flight" | calc_sum)
20156 [ "$changes" -eq 0 ] || error "$changes not synced"
20158 run_test 239A "osp_sync test"
20160 test_239a() { #LU-5297
20161 remote_mds_nodsh && skip "remote MDS with nodsh"
20164 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
20165 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
20166 chgrp $RUNAS_GID $DIR/$tfile
20167 wait_delete_completed
20169 run_test 239a "process invalid osp sync record correctly"
20171 test_239b() { #LU-5297
20172 remote_mds_nodsh && skip "remote MDS with nodsh"
20175 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
20176 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
20177 chgrp $RUNAS_GID $DIR/$tfile1
20178 wait_delete_completed
20179 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
20181 chgrp $RUNAS_GID $DIR/$tfile2
20182 wait_delete_completed
20184 run_test 239b "process osp sync record with ENOMEM error correctly"
20187 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20188 remote_mds_nodsh && skip "remote MDS with nodsh"
20190 mkdir -p $DIR/$tdir
20192 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
20193 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
20194 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
20195 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
20197 umount_client $MOUNT || error "umount failed"
20198 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
20199 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
20200 mount_client $MOUNT || error "failed to mount client"
20202 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
20203 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
20205 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
20211 for LOOP in $(seq $count); do
20212 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
20213 cancel_lru_locks $OSC || true
20221 for LOOP in $(seq $1); do
20222 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
20227 test_241a() { # was test_241
20228 local bsize=$PAGE_SIZE
20230 (( bsize < 40960 )) && bsize=40960
20231 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
20233 cancel_lru_locks $OSC
20234 test_241_bio 1000 $bsize &
20236 test_241_dio 1000 $bsize
20239 run_test 241a "bio vs dio"
20242 local bsize=$PAGE_SIZE
20244 (( bsize < 40960 )) && bsize=40960
20245 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
20247 test_241_dio 1000 $bsize &
20249 test_241_dio 1000 $bsize
20252 run_test 241b "dio vs dio"
20255 remote_mds_nodsh && skip "remote MDS with nodsh"
20257 mkdir_on_mdt0 $DIR/$tdir
20258 touch $DIR/$tdir/$tfile
20260 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
20261 do_facet mds1 lctl set_param fail_loc=0x105
20262 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
20264 do_facet mds1 lctl set_param fail_loc=0
20265 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
20267 run_test 242 "mdt_readpage failure should not cause directory unreadable"
20271 test_mkdir $DIR/$tdir
20272 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
20274 run_test 243 "various group lock tests"
20278 test_mkdir $DIR/$tdir
20279 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
20280 sendfile_grouplock $DIR/$tdir/$tfile || \
20281 error "sendfile+grouplock failed"
20284 run_test 244a "sendfile with group lock tests"
20288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
20291 local size=$((1024*1024))
20293 test_mkdir $DIR/$tdir
20294 for i in $(seq 1 $threads); do
20295 local file=$DIR/$tdir/file_$((i / 10))
20296 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
20299 for i in $(seq 1 $threads); do
20303 run_test 244b "multi-threaded write with group lock"
20306 local flagname="multi_mod_rpcs"
20307 local connect_data_name="max_mod_rpcs"
20310 # check if multiple modify RPCs flag is set
20311 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
20312 grep "connect_flags:")
20315 echo "$out" | grep -qw $flagname
20316 if [ $? -ne 0 ]; then
20317 echo "connect flag $flagname is not set"
20321 # check if multiple modify RPCs data is set
20322 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
20325 echo "$out" | grep -qw $connect_data_name ||
20326 error "import should have connect data $connect_data_name"
20328 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
20334 umount_client $submount
20339 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
20341 skip_env "Fileset feature is not supported"
20343 local submount=${MOUNT}_$tdir
20346 mkdir -p $submount || error "mkdir $submount failed"
20347 FILESET="$FILESET/$tdir" mount_client $submount ||
20348 error "mount $submount failed"
20349 trap "cleanup_247 $submount" EXIT
20350 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
20351 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
20352 error "read $MOUNT/$tdir/$tfile failed"
20353 cleanup_247 $submount
20355 run_test 247a "mount subdir as fileset"
20358 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
20359 skip_env "Fileset feature is not supported"
20361 local submount=${MOUNT}_$tdir
20363 rm -rf $MOUNT/$tdir
20364 mkdir -p $submount || error "mkdir $submount failed"
20366 FILESET="$FILESET/$tdir" mount_client $submount &&
20367 error "mount $submount should fail"
20370 run_test 247b "mount subdir that dose not exist"
20373 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
20374 skip_env "Fileset feature is not supported"
20376 local submount=${MOUNT}_$tdir
20378 mkdir -p $MOUNT/$tdir/dir1
20379 mkdir -p $submount || error "mkdir $submount failed"
20380 trap "cleanup_247 $submount" EXIT
20381 FILESET="$FILESET/$tdir" mount_client $submount ||
20382 error "mount $submount failed"
20383 local fid=$($LFS path2fid $MOUNT/)
20384 $LFS fid2path $submount $fid && error "fid2path should fail"
20385 cleanup_247 $submount
20387 run_test 247c "running fid2path outside subdirectory root"
20390 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
20391 skip "Fileset feature is not supported"
20393 local submount=${MOUNT}_$tdir
20395 mkdir -p $MOUNT/$tdir/dir1
20396 mkdir -p $submount || error "mkdir $submount failed"
20397 FILESET="$FILESET/$tdir" mount_client $submount ||
20398 error "mount $submount failed"
20399 trap "cleanup_247 $submount" EXIT
20401 local td=$submount/dir1
20402 local fid=$($LFS path2fid $td)
20403 [ -z "$fid" ] && error "path2fid unable to get $td FID"
20405 # check that we get the same pathname back
20408 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
20409 echo "$rootpath $fid"
20410 found=$($LFS fid2path $rootpath "$fid")
20411 [ -n "found" ] || error "fid2path should succeed"
20412 [ "$found" == "$td" ] || error "fid2path $found != $td"
20414 # check wrong root path format
20415 rootpath=$submount"_wrong"
20416 found=$($LFS fid2path $rootpath "$fid")
20417 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
20419 cleanup_247 $submount
20421 run_test 247d "running fid2path inside subdirectory root"
20425 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
20427 skip "Fileset feature is not supported"
20429 local submount=${MOUNT}_$tdir
20432 mkdir -p $submount || error "mkdir $submount failed"
20433 FILESET="$FILESET/.." mount_client $submount &&
20434 error "mount $submount should fail"
20437 run_test 247e "mount .. as fileset"
20440 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20441 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
20442 skip "Need at least version 2.13.52"
20443 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
20444 skip "Need at least version 2.14.50"
20445 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
20447 skip "Fileset feature is not supported"
20449 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
20450 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
20451 error "mkdir remote failed"
20452 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
20453 error "mkdir remote/subdir failed"
20454 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
20455 error "mkdir striped failed"
20456 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
20458 local submount=${MOUNT}_$tdir
20460 mkdir -p $submount || error "mkdir $submount failed"
20461 stack_trap "rmdir $submount"
20465 local fileset=$FILESET
20466 local mdts=$(comma_list $(mdts_nodes))
20468 stat=$(do_facet mds1 $LCTL get_param -n \
20469 mdt.*MDT0000.enable_remote_subdir_mount)
20470 stack_trap "do_nodes $mdts $LCTL set_param \
20471 mdt.*.enable_remote_subdir_mount=$stat"
20473 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
20474 stack_trap "umount_client $submount"
20475 FILESET="$fileset/$tdir/remote" mount_client $submount &&
20476 error "mount remote dir $dir should fail"
20478 for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
20479 $tdir/striped/. ; do
20480 FILESET="$fileset/$dir" mount_client $submount ||
20481 error "mount $dir failed"
20482 umount_client $submount
20485 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
20486 FILESET="$fileset/$tdir/remote" mount_client $submount ||
20487 error "mount $tdir/remote failed"
20489 run_test 247f "mount striped or remote directory as fileset"
20492 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
20493 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
20494 skip "Need at least version 2.14.50"
20496 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
20497 error "mkdir $tdir failed"
20498 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
20500 local submount=${MOUNT}_$tdir
20502 mkdir -p $submount || error "mkdir $submount failed"
20503 stack_trap "rmdir $submount"
20505 FILESET="$fileset/$tdir" mount_client $submount ||
20506 error "mount $dir failed"
20507 stack_trap "umount $submount"
20509 local mdts=$(comma_list $(mdts_nodes))
20513 stat $submount > /dev/null
20514 cancel_lru_locks $MDC
20515 stat $submount > /dev/null
20516 stat $submount/$tfile > /dev/null
20517 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
20518 stat $submount/$tfile > /dev/null
20519 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
20520 awk '/getattr/ {sum += $2} END {print sum}')
20522 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
20524 run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
20527 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
20528 [ -z "$fast_read_sav" ] && skip "no fast read support"
20530 # create a large file for fast read verification
20531 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
20533 # make sure the file is created correctly
20534 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
20535 { rm -f $DIR/$tfile; skip "file creation error"; }
20537 echo "Test 1: verify that fast read is 4 times faster on cache read"
20539 # small read with fast read enabled
20540 $LCTL set_param -n llite.*.fast_read=1
20541 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
20542 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20543 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20544 # small read with fast read disabled
20545 $LCTL set_param -n llite.*.fast_read=0
20546 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
20547 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20548 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20550 # verify that fast read is 4 times faster for cache read
20551 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
20552 error_not_in_vm "fast read was not 4 times faster: " \
20553 "$t_fast vs $t_slow"
20555 echo "Test 2: verify the performance between big and small read"
20556 $LCTL set_param -n llite.*.fast_read=1
20558 # 1k non-cache read
20559 cancel_lru_locks osc
20560 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
20561 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20562 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20564 # 1M non-cache read
20565 cancel_lru_locks osc
20566 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
20567 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20568 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20570 # verify that big IO is not 4 times faster than small IO
20571 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
20572 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
20574 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
20577 run_test 248a "fast read verification"
20580 # Default short_io_bytes=16384, try both smaller and larger sizes.
20581 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
20582 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
20583 echo "bs=53248 count=113 normal buffered write"
20584 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
20585 error "dd of initial data file failed"
20586 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
20588 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
20589 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
20590 error "dd with sync normal writes failed"
20591 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
20593 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
20594 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
20595 error "dd with sync small writes failed"
20596 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
20598 cancel_lru_locks osc
20600 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
20601 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
20602 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
20603 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
20604 iflag=direct || error "dd with O_DIRECT small read failed"
20605 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
20606 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
20607 error "compare $TMP/$tfile.1 failed"
20609 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
20610 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
20612 # just to see what the maximum tunable value is, and test parsing
20613 echo "test invalid parameter 2MB"
20614 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
20615 error "too-large short_io_bytes allowed"
20616 echo "test maximum parameter 512KB"
20617 # if we can set a larger short_io_bytes, run test regardless of version
20618 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
20619 # older clients may not allow setting it this large, that's OK
20620 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
20621 skip "Need at least client version 2.13.50"
20622 error "medium short_io_bytes failed"
20624 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
20625 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
20627 echo "test large parameter 64KB"
20628 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
20629 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
20631 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
20632 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
20633 error "dd with sync large writes failed"
20634 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
20636 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
20637 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
20638 num=$((113 * 4096 / PAGE_SIZE))
20639 echo "bs=$size count=$num oflag=direct large write $tfile.3"
20640 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
20641 error "dd with O_DIRECT large writes failed"
20642 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
20643 error "compare $DIR/$tfile.3 failed"
20645 cancel_lru_locks osc
20647 echo "bs=$size count=$num iflag=direct large read $tfile.2"
20648 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
20649 error "dd with O_DIRECT large read failed"
20650 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
20651 error "compare $TMP/$tfile.2 failed"
20653 echo "bs=$size count=$num iflag=direct large read $tfile.3"
20654 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
20655 error "dd with O_DIRECT large read failed"
20656 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
20657 error "compare $TMP/$tfile.3 failed"
20659 run_test 248b "test short_io read and write for both small and large sizes"
20661 test_249() { # LU-7890
20662 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
20663 skip "Need at least version 2.8.54"
20666 $LFS setstripe -c 1 $DIR/$tfile
20667 # Offset 2T == 4k * 512M
20668 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
20669 error "dd to 2T offset failed"
20671 run_test 249 "Write above 2T file size"
20674 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
20675 && skip "no 16TB file size limit on ZFS"
20677 $LFS setstripe -c 1 $DIR/$tfile
20678 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
20679 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
20680 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
20681 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
20682 conv=notrunc,fsync && error "append succeeded"
20685 run_test 250 "Write above 16T limit"
20688 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
20690 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
20691 #Skip once - writing the first stripe will succeed
20692 $LCTL set_param fail_loc=0xa0001407 fail_val=1
20693 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
20694 error "short write happened"
20696 $LCTL set_param fail_loc=0xa0001407 fail_val=1
20697 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
20698 error "short read happened"
20702 run_test 251 "Handling short read and write correctly"
20705 remote_mds_nodsh && skip "remote MDS with nodsh"
20706 remote_ost_nodsh && skip "remote OST with nodsh"
20707 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
20708 skip_env "ldiskfs only test"
20718 # check lr_reader on OST0000
20720 dev=$(facet_device $tgt)
20721 out=$(do_facet $tgt $LR_READER $dev)
20722 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
20724 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
20725 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
20726 error "Invalid uuid returned by $LR_READER on target $tgt"
20727 echo -e "uuid returned by $LR_READER is '$uuid'\n"
20729 # check lr_reader -c on MDT0000
20731 dev=$(facet_device $tgt)
20732 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
20733 skip "$LR_READER does not support additional options"
20735 out=$(do_facet $tgt $LR_READER -c $dev)
20736 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
20738 num=$(echo "$out" | grep -c "mdtlov")
20739 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
20740 error "Invalid number of mdtlov clients returned by $LR_READER"
20741 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
20743 # check lr_reader -cr on MDT0000
20744 out=$(do_facet $tgt $LR_READER -cr $dev)
20745 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
20747 echo "$out" | grep -q "^reply_data:$" ||
20748 error "$LR_READER should have returned 'reply_data' section"
20749 num=$(echo "$out" | grep -c "client_generation")
20750 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
20752 run_test 252 "check lr_reader tool"
20755 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20756 remote_mds_nodsh && skip "remote MDS with nodsh"
20757 remote_mgs_nodsh && skip "remote MGS with nodsh"
20761 local ost_name=$(ostname_from_index $ostidx)
20764 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
20765 do_facet $SINGLEMDS $LCTL get_param -n \
20766 osp.$mdtosc_proc1.reserved_mb_high ||
20767 skip "remote MDS does not support reserved_mb_high"
20771 wait_delete_completed
20774 pool_add $TESTNAME || error "Pool creation failed"
20775 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
20777 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
20778 error "Setstripe failed"
20780 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
20782 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
20784 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
20786 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
20787 osp.$mdtosc_proc1.prealloc_status)
20788 echo "prealloc_status $oa_status"
20790 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
20791 error "File creation should fail"
20793 #object allocation was stopped, but we still able to append files
20794 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
20795 oflag=append || error "Append failed"
20797 rm -f $DIR/$tdir/$tfile.0
20799 # For this test, we want to delete the files we created to go out of
20800 # space but leave the watermark, so we remain nearly out of space
20801 ost_watermarks_enospc_delete_files $tfile $ostidx
20803 wait_delete_completed
20807 for i in $(seq 10 12); do
20808 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
20809 2>/dev/null || error "File creation failed after rm"
20812 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
20813 osp.$mdtosc_proc1.prealloc_status)
20814 echo "prealloc_status $oa_status"
20816 if (( oa_status != 0 )); then
20817 error "Object allocation still disable after rm"
20820 run_test 253 "Check object allocation limit"
20823 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20824 remote_mds_nodsh && skip "remote MDS with nodsh"
20825 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
20826 skip "MDS does not support changelog_size"
20829 local MDT0=$(facet_svc $SINGLEMDS)
20831 changelog_register || error "changelog_register failed"
20833 changelog_clear 0 || error "changelog_clear failed"
20835 local size1=$(do_facet $SINGLEMDS \
20836 $LCTL get_param -n mdd.$MDT0.changelog_size)
20837 echo "Changelog size $size1"
20840 $LFS mkdir -i 0 $DIR/$tdir
20842 mkdir -p $DIR/$tdir/pics/2008/zachy
20843 touch $DIR/$tdir/pics/2008/zachy/timestamp
20844 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
20845 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
20846 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
20847 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
20848 rm $DIR/$tdir/pics/desktop.jpg
20850 local size2=$(do_facet $SINGLEMDS \
20851 $LCTL get_param -n mdd.$MDT0.changelog_size)
20852 echo "Changelog size after work $size2"
20854 (( $size2 > $size1 )) ||
20855 error "new Changelog size=$size2 less than old size=$size1"
20857 run_test 254 "Check changelog size"
20864 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
20865 awk -F: '{print $2}' | grep $type > /dev/null
20866 if [ $? -ne 0 ]; then
20876 lfs ladvise -a willread $file > /dev/null 2>&1
20877 if [ $? -eq 0 ]; then
20881 lfs ladvise -a willread $file 2>&1 |
20882 grep "Inappropriate ioctl for device" > /dev/null
20883 if [ $? -eq 0 ]; then
20890 bc <<<"scale=2; ($1 - $2) * 100 / $2"
20893 # run a random read IO workload
20894 # usage: random_read_iops <filename> <filesize> <iosize>
20895 random_read_iops() {
20898 local iosize=${3:-4096}
20900 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
20901 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
20904 drop_file_oss_cache() {
20908 $LFS ladvise -a dontneed $file 2>/dev/null ||
20909 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
20912 ladvise_willread_performance()
20915 local average_origin=0
20916 local average_cache=0
20917 local average_ladvise=0
20919 for ((i = 1; i <= $repeat; i++)); do
20920 echo "Iter $i/$repeat: reading without willread hint"
20921 cancel_lru_locks osc
20922 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
20923 local speed_origin=$(random_read_iops $DIR/$tfile $size)
20924 echo "Iter $i/$repeat: uncached speed: $speed_origin"
20925 average_origin=$(bc <<<"$average_origin + $speed_origin")
20927 cancel_lru_locks osc
20928 local speed_cache=$(random_read_iops $DIR/$tfile $size)
20929 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
20930 average_cache=$(bc <<<"$average_cache + $speed_cache")
20932 cancel_lru_locks osc
20933 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
20934 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
20935 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
20936 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
20937 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
20939 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
20940 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
20941 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
20943 speedup_cache=$(percent $average_cache $average_origin)
20944 speedup_ladvise=$(percent $average_ladvise $average_origin)
20946 echo "Average uncached read: $average_origin"
20947 echo "Average speedup with OSS cached read: " \
20948 "$average_cache = +$speedup_cache%"
20949 echo "Average speedup with ladvise willread: " \
20950 "$average_ladvise = +$speedup_ladvise%"
20952 local lowest_speedup=20
20953 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
20954 echo "Speedup with OSS cached read less than $lowest_speedup%," \
20955 "got $average_cache%. Skipping ladvise willread check."
20959 # the test won't work on ZFS until it supports 'ladvise dontneed', but
20960 # it is still good to run until then to exercise 'ladvise willread'
20961 ! $LFS ladvise -a dontneed $DIR/$tfile &&
20962 [ "$ost1_FSTYPE" = "zfs" ] &&
20963 echo "osd-zfs does not support dontneed or drop_caches" &&
20966 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
20967 [[ ${average_ladvise%.*} > $lowest_speedup ]] ||
20968 error_not_in_vm "Speedup with willread is less than " \
20969 "$lowest_speedup%, got $average_ladvise%"
20973 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
20974 skip "lustre < 2.8.54 does not support ladvise "
20975 remote_ost_nodsh && skip "remote OST with nodsh"
20977 stack_trap "rm -f $DIR/$tfile"
20978 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
20980 ladvise_no_type willread $DIR/$tfile &&
20981 skip "willread ladvise is not supported"
20983 ladvise_no_ioctl $DIR/$tfile &&
20984 skip "ladvise ioctl is not supported"
20987 local size=$((size_mb * 1048576))
20988 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
20989 error "dd to $DIR/$tfile failed"
20991 lfs ladvise -a willread $DIR/$tfile ||
20992 error "Ladvise failed with no range argument"
20994 lfs ladvise -a willread -s 0 $DIR/$tfile ||
20995 error "Ladvise failed with no -l or -e argument"
20997 lfs ladvise -a willread -e 1 $DIR/$tfile ||
20998 error "Ladvise failed with only -e argument"
21000 lfs ladvise -a willread -l 1 $DIR/$tfile ||
21001 error "Ladvise failed with only -l argument"
21003 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
21004 error "End offset should not be smaller than start offset"
21006 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
21007 error "End offset should not be equal to start offset"
21009 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
21010 error "Ladvise failed with overflowing -s argument"
21012 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
21013 error "Ladvise failed with overflowing -e argument"
21015 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
21016 error "Ladvise failed with overflowing -l argument"
21018 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
21019 error "Ladvise succeeded with conflicting -l and -e arguments"
21021 echo "Synchronous ladvise should wait"
21023 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
21024 do_nodes $(comma_list $(osts_nodes)) \
21025 $LCTL set_param fail_val=$delay fail_loc=0x237
21027 local start_ts=$SECONDS
21028 lfs ladvise -a willread $DIR/$tfile ||
21029 error "Ladvise failed with no range argument"
21030 local end_ts=$SECONDS
21031 local inteval_ts=$((end_ts - start_ts))
21033 if [ $inteval_ts -lt $(($delay - 1)) ]; then
21034 error "Synchronous advice didn't wait reply"
21037 echo "Asynchronous ladvise shouldn't wait"
21038 local start_ts=$SECONDS
21039 lfs ladvise -a willread -b $DIR/$tfile ||
21040 error "Ladvise failed with no range argument"
21041 local end_ts=$SECONDS
21042 local inteval_ts=$((end_ts - start_ts))
21044 if [ $inteval_ts -gt $(($delay / 2)) ]; then
21045 error "Asynchronous advice blocked"
21048 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
21049 ladvise_willread_performance
21051 run_test 255a "check 'lfs ladvise -a willread'"
21057 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
21061 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
21062 skip "lustre < 2.8.54 does not support ladvise "
21063 remote_ost_nodsh && skip "remote OST with nodsh"
21065 stack_trap "rm -f $DIR/$tfile"
21066 lfs setstripe -c 1 -i 0 $DIR/$tfile
21068 ladvise_no_type dontneed $DIR/$tfile &&
21069 skip "dontneed ladvise is not supported"
21071 ladvise_no_ioctl $DIR/$tfile &&
21072 skip "ladvise ioctl is not supported"
21074 ! $LFS ladvise -a dontneed $DIR/$tfile &&
21075 [ "$ost1_FSTYPE" = "zfs" ] &&
21076 skip "zfs-osd does not support 'ladvise dontneed'"
21079 local size=$((size_mb * 1048576))
21080 # In order to prevent disturbance of other processes, only check 3/4
21081 # of the memory usage
21082 local kibibytes=$((size_mb * 1024 * 3 / 4))
21084 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
21085 error "dd to $DIR/$tfile failed"
21087 #force write to complete before dropping OST cache & checking memory
21090 local total=$(facet_meminfo ost1 MemTotal)
21091 echo "Total memory: $total KiB"
21093 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
21094 local before_read=$(facet_meminfo ost1 Cached)
21095 echo "Cache used before read: $before_read KiB"
21097 lfs ladvise -a willread $DIR/$tfile ||
21098 error "Ladvise willread failed"
21099 local after_read=$(facet_meminfo ost1 Cached)
21100 echo "Cache used after read: $after_read KiB"
21102 lfs ladvise -a dontneed $DIR/$tfile ||
21103 error "Ladvise dontneed again failed"
21104 local no_read=$(facet_meminfo ost1 Cached)
21105 echo "Cache used after dontneed ladvise: $no_read KiB"
21107 if [ $total -lt $((before_read + kibibytes)) ]; then
21108 echo "Memory is too small, abort checking"
21112 if [ $((before_read + kibibytes)) -gt $after_read ]; then
21113 error "Ladvise willread should use more memory" \
21114 "than $kibibytes KiB"
21117 if [ $((no_read + kibibytes)) -gt $after_read ]; then
21118 error "Ladvise dontneed should release more memory" \
21119 "than $kibibytes KiB"
21122 run_test 255b "check 'lfs ladvise -a dontneed'"
21125 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
21126 skip "lustre < 2.10.50 does not support lockahead"
21128 local ost1_imp=$(get_osc_import_name client ost1)
21129 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
21137 test_mkdir -p $DIR/$tdir
21138 $LFS setstripe -i 0 -c 1 $DIR/$tdir
21140 #test 10 returns only success/failure
21142 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21144 if [ $rc -eq 255 ]; then
21145 error "Ladvise test${i} failed, ${rc}"
21148 #test 11 counts lock enqueue requests, all others count new locks
21150 count=$(do_facet ost1 \
21151 $LCTL get_param -n ost.OSS.ost.stats)
21152 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
21154 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21156 if [ $rc -eq 255 ]; then
21157 error "Ladvise test${i} failed, ${rc}"
21160 new_count=$(do_facet ost1 \
21161 $LCTL get_param -n ost.OSS.ost.stats)
21162 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
21163 awk '{ print $2 }')
21165 difference="$((new_count - count))"
21166 if [ $difference -ne $rc ]; then
21167 error "Ladvise test${i}, bad enqueue count, returned " \
21168 "${rc}, actual ${difference}"
21171 for i in $(seq 12 21); do
21172 # If we do not do this, we run the risk of having too many
21173 # locks and starting lock cancellation while we are checking
21175 cancel_lru_locks osc
21177 count=$($LCTL get_param -n \
21178 ldlm.namespaces.$imp_name.lock_unused_count)
21180 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21182 if [ $rc -eq 255 ]; then
21183 error "Ladvise test ${i} failed, ${rc}"
21186 new_count=$($LCTL get_param -n \
21187 ldlm.namespaces.$imp_name.lock_unused_count)
21188 difference="$((new_count - count))"
21190 # Test 15 output is divided by 100 to map down to valid return
21191 if [ $i -eq 15 ]; then
21195 if [ $difference -ne $rc ]; then
21196 error "Ladvise test ${i}, bad lock count, returned " \
21197 "${rc}, actual ${difference}"
21201 #test 22 returns only success/failure
21203 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21205 if [ $rc -eq 255 ]; then
21206 error "Ladvise test${i} failed, ${rc}"
21209 run_test 255c "suite of ladvise lockahead tests"
21212 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21213 remote_mds_nodsh && skip "remote MDS with nodsh"
21214 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
21215 changelog_users $SINGLEMDS | grep "^cl" &&
21216 skip "active changelog user"
21222 mdt_dev=$(mdsdevname 1)
21225 changelog_register || error "changelog_register failed"
21228 mkdir_on_mdt0 $DIR/$tdir
21230 changelog_clear 0 || error "changelog_clear failed"
21233 touch $DIR/$tdir/{1..10}
21236 stop $SINGLEMDS || error "Fail to stop MDT"
21240 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
21242 #after mount new plainllog is used
21243 touch $DIR/$tdir/{11..19}
21244 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
21245 stack_trap "rm -f $tmpfile"
21246 cat_sl=$(do_facet $SINGLEMDS "sync; \
21247 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
21248 llog_reader $tmpfile | grep -c type=1064553b")
21249 do_facet $SINGLEMDS llog_reader $tmpfile
21251 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
21253 changelog_clear 0 || error "changelog_clear failed"
21255 cat_sl=$(do_facet $SINGLEMDS "sync; \
21256 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
21257 llog_reader $tmpfile | grep -c type=1064553b")
21259 if (( cat_sl == 2 )); then
21260 error "Empty plain llog was not deleted from changelog catalog"
21261 elif (( cat_sl != 1 )); then
21262 error "Active plain llog shouldn't be deleted from catalog"
21265 run_test 256 "Check llog delete for empty and not full state"
21268 remote_mds_nodsh && skip "remote MDS with nodsh"
21269 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
21270 skip "Need MDS version at least 2.8.55"
21272 test_mkdir $DIR/$tdir
21274 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
21275 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
21278 #define OBD_FAIL_MDS_XATTR_REP 0x161
21279 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
21280 local facet=mds$((mdtidx + 1))
21281 set_nodes_failloc $(facet_active_host $facet) 0x80000161
21282 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
21284 stop $facet || error "stop MDS failed"
21285 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
21286 error "start MDS fail"
21287 wait_recovery_complete $facet
21289 run_test 257 "xattr locks are not lost"
21291 # Verify we take the i_mutex when security requires it
21293 #define OBD_FAIL_IMUTEX_SEC 0x141c
21294 $LCTL set_param fail_loc=0x141c
21296 chmod u+s $DIR/$tfile
21297 chmod a+rwx $DIR/$tfile
21298 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
21300 if [ $RC -ne 0 ]; then
21301 error "error, failed to take i_mutex, rc=$?"
21305 run_test 258a "verify i_mutex security behavior when suid attributes is set"
21307 # Verify we do NOT take the i_mutex in the normal case
21309 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
21310 $LCTL set_param fail_loc=0x141d
21313 chmod a+rw $DIR/$tfile
21314 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
21316 if [ $RC -ne 0 ]; then
21317 error "error, took i_mutex unnecessarily, rc=$?"
21322 run_test 258b "verify i_mutex security behavior"
21325 local file=$DIR/$tfile
21329 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
21331 stack_trap "rm -f $file" EXIT
21333 wait_delete_completed
21334 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21335 echo "before: $before"
21337 $LFS setstripe -i 0 -c 1 $file
21338 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
21340 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21341 echo "after write: $after"
21343 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
21344 do_facet ost1 $LCTL set_param fail_loc=0x2301
21346 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21347 echo "after truncate: $after"
21350 do_facet ost1 $LCTL set_param fail_loc=0
21351 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21353 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21354 echo "after restart: $after"
21355 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
21356 error "missing truncate?"
21360 run_test 259 "crash at delayed truncate"
21363 #define OBD_FAIL_MDC_CLOSE 0x806
21364 $LCTL set_param fail_loc=0x80000806
21368 run_test 260 "Check mdc_close fail"
21370 ### Data-on-MDT sanity tests ###
21372 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21373 skip "Need MDS version at least 2.10.55 for DoM"
21376 local dom=$DIR/$tdir/dom_file
21377 local tmp=$DIR/$tdir/tmp_file
21379 mkdir_on_mdt0 $DIR/$tdir
21381 # basic checks for DoM component creation
21382 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
21383 error "Can set MDT layout to non-first entry"
21385 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
21386 error "Can define multiple entries as MDT layout"
21388 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
21390 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
21391 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
21392 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
21394 local mdtidx=$($LFS getstripe -m $dom)
21395 local mdtname=MDT$(printf %04x $mdtidx)
21396 local facet=mds$((mdtidx + 1))
21397 local space_check=1
21399 # Skip free space checks with ZFS
21400 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
21404 local size_tmp=$((65536 * 3))
21405 local mdtfree1=$(do_facet $facet \
21406 lctl get_param -n osd*.*$mdtname.kbytesfree)
21408 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
21409 # check also direct IO along write
21410 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
21411 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
21413 cmp $tmp $dom || error "file data is different"
21414 [ $(stat -c%s $dom) == $size_tmp ] ||
21415 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
21416 if [ $space_check == 1 ]; then
21417 local mdtfree2=$(do_facet $facet \
21418 lctl get_param -n osd*.*$mdtname.kbytesfree)
21420 # increase in usage from by $size_tmp
21421 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
21422 error "MDT free space wrong after write: " \
21423 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
21427 local size_dom=10000
21429 $TRUNCATE $dom $size_dom
21430 [ $(stat -c%s $dom) == $size_dom ] ||
21431 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
21432 if [ $space_check == 1 ]; then
21433 mdtfree1=$(do_facet $facet \
21434 lctl get_param -n osd*.*$mdtname.kbytesfree)
21435 # decrease in usage from $size_tmp to new $size_dom
21436 [ $(($mdtfree1 - $mdtfree2)) -ge \
21437 $(((size_tmp - size_dom) / 1024)) ] ||
21438 error "MDT free space is wrong after truncate: " \
21439 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
21445 size_dom=$((size_dom + size_tmp))
21446 [ $(stat -c%s $dom) == $size_dom ] ||
21447 error "bad size after append: $(stat -c%s $dom) != $size_dom"
21448 if [ $space_check == 1 ]; then
21449 mdtfree2=$(do_facet $facet \
21450 lctl get_param -n osd*.*$mdtname.kbytesfree)
21451 # increase in usage by $size_tmp from previous
21452 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
21453 error "MDT free space is wrong after append: " \
21454 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
21459 if [ $space_check == 1 ]; then
21460 mdtfree1=$(do_facet $facet \
21461 lctl get_param -n osd*.*$mdtname.kbytesfree)
21462 # decrease in usage by $size_dom from previous
21463 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
21464 error "MDT free space is wrong after removal: " \
21465 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
21468 # combined striping
21469 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
21470 error "Can't create DoM + OST striping"
21472 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
21473 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
21474 # check also direct IO along write
21475 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
21477 cmp $tmp $dom || error "file data is different"
21478 [ $(stat -c%s $dom) == $size_tmp ] ||
21479 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
21484 run_test 270a "DoM: basic functionality tests"
21487 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21488 skip "Need MDS version at least 2.10.55"
21490 local dom=$DIR/$tdir/dom_file
21491 local max_size=1048576
21493 mkdir -p $DIR/$tdir
21494 $LFS setstripe -E $max_size -L mdt $dom
21496 # truncate over the limit
21497 $TRUNCATE $dom $(($max_size + 1)) &&
21498 error "successful truncate over the maximum size"
21499 # write over the limit
21500 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
21501 error "successful write over the maximum size"
21502 # append over the limit
21503 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
21504 echo "12345" >> $dom && error "successful append over the maximum size"
21509 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
21512 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21513 skip "Need MDS version at least 2.10.55"
21515 mkdir -p $DIR/$tdir
21516 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21518 # check files inherit DoM EA
21519 touch $DIR/$tdir/first
21520 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
21521 error "bad pattern"
21522 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
21523 error "bad stripe count"
21524 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
21525 error "bad stripe size"
21527 # check directory inherits DoM EA and uses it as default
21528 mkdir $DIR/$tdir/subdir
21529 touch $DIR/$tdir/subdir/second
21530 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
21531 error "bad pattern in sub-directory"
21532 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
21533 error "bad stripe count in sub-directory"
21534 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
21535 error "bad stripe size in sub-directory"
21538 run_test 270c "DoM: DoM EA inheritance tests"
21541 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21542 skip "Need MDS version at least 2.10.55"
21544 mkdir -p $DIR/$tdir
21545 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21547 # inherit default DoM striping
21548 mkdir $DIR/$tdir/subdir
21549 touch $DIR/$tdir/subdir/f1
21551 # change default directory striping
21552 $LFS setstripe -c 1 $DIR/$tdir/subdir
21553 touch $DIR/$tdir/subdir/f2
21554 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
21555 error "wrong default striping in file 2"
21556 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
21557 error "bad pattern in file 2"
21560 run_test 270d "DoM: change striping from DoM to RAID0"
21563 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21564 skip "Need MDS version at least 2.10.55"
21566 mkdir -p $DIR/$tdir/dom
21567 mkdir -p $DIR/$tdir/norm
21570 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
21571 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
21573 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
21574 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
21576 # find DoM files by layout
21577 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
21578 [ $NUM -eq $DOMFILES ] ||
21579 error "lfs find -L: found $NUM, expected $DOMFILES"
21580 echo "Test 1: lfs find 20 DOM files by layout: OK"
21582 # there should be 1 dir with default DOM striping
21583 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
21585 error "lfs find -L: found $NUM, expected 1 dir"
21586 echo "Test 2: lfs find 1 DOM dir by layout: OK"
21588 # find DoM files by stripe size
21589 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
21590 [ $NUM -eq $DOMFILES ] ||
21591 error "lfs find -S: found $NUM, expected $DOMFILES"
21592 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
21594 # find files by stripe offset except DoM files
21595 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
21596 [ $NUM -eq $NORMFILES ] ||
21597 error "lfs find -i: found $NUM, expected $NORMFILES"
21598 echo "Test 5: lfs find no DOM files by stripe index: OK"
21601 run_test 270e "DoM: lfs find with DoM files test"
21604 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21605 skip "Need MDS version at least 2.10.55"
21607 local mdtname=${FSNAME}-MDT0000-mdtlov
21608 local dom=$DIR/$tdir/dom_file
21609 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
21610 lod.$mdtname.dom_stripesize)
21611 local dom_limit=131072
21613 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
21614 local dom_current=$(do_facet mds1 $LCTL get_param -n \
21615 lod.$mdtname.dom_stripesize)
21616 [ ${dom_limit} -eq ${dom_current} ] ||
21617 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
21619 $LFS mkdir -i 0 -c 1 $DIR/$tdir
21620 $LFS setstripe -d $DIR/$tdir
21621 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
21622 error "Can't set directory default striping"
21624 # exceed maximum stripe size
21625 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
21626 error "Can't create file with $((dom_limit * 2)) DoM stripe"
21627 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
21628 error "Able to create DoM component size more than LOD limit"
21630 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
21631 dom_current=$(do_facet mds1 $LCTL get_param -n \
21632 lod.$mdtname.dom_stripesize)
21633 [ 0 -eq ${dom_current} ] ||
21634 error "Can't set zero DoM stripe limit"
21637 # attempt to create DoM file on server with disabled DoM should
21638 # remove DoM entry from layout and be succeed
21639 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
21640 error "Can't create DoM file (DoM is disabled)"
21641 [ $($LFS getstripe -L $dom) == "mdt" ] &&
21642 error "File has DoM component while DoM is disabled"
21645 # attempt to create DoM file with only DoM stripe should return error
21646 $LFS setstripe -E $dom_limit -L mdt $dom &&
21647 error "Able to create DoM-only file while DoM is disabled"
21649 # too low values to be aligned with smallest stripe size 64K
21650 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
21651 dom_current=$(do_facet mds1 $LCTL get_param -n \
21652 lod.$mdtname.dom_stripesize)
21653 [ 30000 -eq ${dom_current} ] &&
21654 error "Can set too small DoM stripe limit"
21656 # 64K is a minimal stripe size in Lustre, expect limit of that size
21657 [ 65536 -eq ${dom_current} ] ||
21658 error "Limit is not set to 64K but ${dom_current}"
21660 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
21661 dom_current=$(do_facet mds1 $LCTL get_param -n \
21662 lod.$mdtname.dom_stripesize)
21664 [ 2147483648 -eq ${dom_current} ] &&
21665 error "Can set too large DoM stripe limit"
21667 do_facet mds1 $LCTL set_param -n \
21668 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
21669 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
21670 error "Can't create DoM component size after limit change"
21671 do_facet mds1 $LCTL set_param -n \
21672 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
21673 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
21674 error "Can't create DoM file after limit decrease"
21675 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
21676 error "Can create big DoM component after limit decrease"
21677 touch ${dom}_def ||
21678 error "Can't create file with old default layout"
21680 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
21683 run_test 270f "DoM: maximum DoM stripe size checks"
21686 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
21687 skip "Need MDS version at least 2.13.52"
21688 local dom=$DIR/$tdir/$tfile
21690 $LFS mkdir -i 0 -c 1 $DIR/$tdir
21691 local lodname=${FSNAME}-MDT0000-mdtlov
21693 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21694 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
21695 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
21696 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
21698 local dom_limit=1024
21699 local dom_threshold="50%"
21701 $LFS setstripe -d $DIR/$tdir
21702 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
21703 error "Can't set directory default striping"
21705 do_facet mds1 $LCTL set_param -n \
21706 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
21707 # set 0 threshold and create DOM file to change tunable stripesize
21708 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
21709 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
21710 error "Failed to create $dom file"
21711 # now tunable dom_cur_stripesize should reach maximum
21712 local dom_current=$(do_facet mds1 $LCTL get_param -n \
21713 lod.${lodname}.dom_stripesize_cur_kb)
21714 [[ $dom_current == $dom_limit ]] ||
21715 error "Current DOM stripesize is not maximum"
21718 # set threshold for further tests
21719 do_facet mds1 $LCTL set_param -n \
21720 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
21721 echo "DOM threshold is $dom_threshold free space"
21724 # Spoof bfree to exceed threshold
21725 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
21726 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
21727 for spfree in 40 20 0 15 30 55; do
21728 do_facet mds1 $LCTL set_param -n fail_val=$spfree
21729 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
21730 error "Failed to create $dom file"
21731 dom_def=$(do_facet mds1 $LCTL get_param -n \
21732 lod.${lodname}.dom_stripesize_cur_kb)
21733 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
21734 [[ $dom_def != $dom_current ]] ||
21735 error "Default stripe size was not changed"
21736 if [[ $spfree > 0 ]] ; then
21737 dom_set=$($LFS getstripe -S $dom)
21738 [[ $dom_set == $((dom_def * 1024)) ]] ||
21739 error "DOM component size is still old"
21741 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
21742 error "DoM component is set with no free space"
21745 dom_current=$dom_def
21748 run_test 270g "DoM: default DoM stripe size depends on free space"
21751 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
21752 skip "Need MDS version at least 2.13.53"
21754 local mdtname=${FSNAME}-MDT0000-mdtlov
21755 local dom=$DIR/$tdir/$tfile
21756 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21758 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
21759 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
21761 $LFS mkdir -i 0 -c 1 $DIR/$tdir
21762 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
21763 error "can't create OST file"
21764 # mirrored file with DOM entry in the second mirror
21765 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
21766 error "can't create mirror with DoM component"
21768 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
21770 # DOM component in the middle and has other enries in the same mirror,
21771 # should succeed but lost DoM component
21772 $LFS setstripe --copy=${dom}_1 $dom ||
21773 error "Can't create file from OST|DOM mirror layout"
21774 # check new file has no DoM layout after all
21775 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
21776 error "File has DoM component while DoM is disabled"
21778 run_test 270h "DoM: DoM stripe removal when disabled on server"
21781 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21782 skip "Need MDS version at least 2.10.55"
21784 local dom=$DIR/$tdir/dom
21786 mkdir -p $DIR/$tdir
21788 $LFS setstripe -E 1024K -L mdt $dom
21790 lctl set_param -n mdc.*.stats=clear
21791 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
21792 cat $dom > /dev/null
21793 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
21794 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
21798 run_test 271a "DoM: data is cached for read after write"
21801 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21802 skip "Need MDS version at least 2.10.55"
21804 local dom=$DIR/$tdir/dom
21806 mkdir -p $DIR/$tdir
21808 $LFS setstripe -E 1024K -L mdt -E EOF $dom
21810 lctl set_param -n mdc.*.stats=clear
21811 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
21812 cancel_lru_locks mdc
21813 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
21814 # second stat to check size is cached on client
21815 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
21816 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
21817 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
21820 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
21823 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21824 skip "Need MDS version at least 2.10.55"
21826 local dom=$DIR/$tdir/dom
21828 mkdir -p $DIR/$tdir
21830 $LFS setstripe -E 1024K -L mdt -E EOF $dom
21832 lctl set_param -n mdc.*.stats=clear
21833 lctl set_param -n osc.*.stats=clear
21834 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
21835 cancel_lru_locks mdc
21836 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
21837 # second stat to check size is cached on client
21838 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
21839 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
21840 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
21841 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
21842 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
21845 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
21851 local mdt=MDT$(printf %04x $mdtidx)
21853 if [ -z $param ]; then
21854 lctl get_param -n mdc.*$mdt*.stats
21856 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
21861 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21862 skip "Need MDS version at least 2.10.55"
21864 local dom=$DIR/$tdir/dom
21866 mkdir -p $DIR/$tdir
21868 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21870 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
21871 local facet=mds$((mdtidx + 1))
21873 cancel_lru_locks mdc
21874 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
21875 createmany -o $dom 1000
21876 lctl set_param -n mdc.*.stats=clear
21877 smalliomany -w $dom 1000 200
21878 get_mdc_stats $mdtidx
21879 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
21880 # Each file has 1 open, 1 IO enqueues, total 2000
21881 # but now we have also +1 getxattr for security.capability, total 3000
21882 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
21883 unlinkmany $dom 1000
21885 cancel_lru_locks mdc
21886 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
21887 createmany -o $dom 1000
21888 lctl set_param -n mdc.*.stats=clear
21889 smalliomany -w $dom 1000 200
21890 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
21891 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
21892 # for OPEN and IO lock.
21893 [ $((enq - enq_2)) -ge 1000 ] ||
21894 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
21895 unlinkmany $dom 1000
21898 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
21900 cleanup_271def_tests() {
21906 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
21907 skip "Need MDS version at least 2.10.57"
21909 local dom=$DIR/$tdir/dom
21910 local tmp=$TMP/$tfile
21911 trap "cleanup_271def_tests $tmp" EXIT
21913 mkdir -p $DIR/$tdir
21915 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21917 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
21919 cancel_lru_locks mdc
21920 dd if=/dev/urandom of=$tmp bs=1000 count=1
21921 dd if=$tmp of=$dom bs=1000 count=1
21922 cancel_lru_locks mdc
21924 cat /etc/hosts >> $tmp
21925 lctl set_param -n mdc.*.stats=clear
21927 # append data to the same file it should update local page
21928 echo "Append to the same page"
21929 cat /etc/hosts >> $dom
21930 local num=$(get_mdc_stats $mdtidx ost_read)
21931 local ra=$(get_mdc_stats $mdtidx req_active)
21932 local rw=$(get_mdc_stats $mdtidx req_waittime)
21934 [ -z $num ] || error "$num READ RPC occured"
21935 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
21939 cmp $tmp $dom || error "file miscompare"
21941 cancel_lru_locks mdc
21942 lctl set_param -n mdc.*.stats=clear
21944 echo "Open and read file"
21945 cat $dom > /dev/null
21946 local num=$(get_mdc_stats $mdtidx ost_read)
21947 local ra=$(get_mdc_stats $mdtidx req_active)
21948 local rw=$(get_mdc_stats $mdtidx req_waittime)
21950 [ -z $num ] || error "$num READ RPC occured"
21951 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
21955 cmp $tmp $dom || error "file miscompare"
21959 run_test 271d "DoM: read on open (1K file in reply buffer)"
21962 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
21963 skip "Need MDS version at least 2.10.57"
21965 local dom=$DIR/$tdir/dom
21966 local tmp=$TMP/$tfile
21967 trap "cleanup_271def_tests $tmp" EXIT
21969 mkdir -p $DIR/$tdir
21971 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21973 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
21975 cancel_lru_locks mdc
21976 dd if=/dev/urandom of=$tmp bs=265000 count=1
21977 dd if=$tmp of=$dom bs=265000 count=1
21978 cancel_lru_locks mdc
21979 cat /etc/hosts >> $tmp
21980 lctl set_param -n mdc.*.stats=clear
21982 echo "Append to the same page"
21983 cat /etc/hosts >> $dom
21984 local num=$(get_mdc_stats $mdtidx ost_read)
21985 local ra=$(get_mdc_stats $mdtidx req_active)
21986 local rw=$(get_mdc_stats $mdtidx req_waittime)
21988 [ -z $num ] || error "$num READ RPC occured"
21989 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
21993 cmp $tmp $dom || error "file miscompare"
21995 cancel_lru_locks mdc
21996 lctl set_param -n mdc.*.stats=clear
21998 echo "Open and read file"
21999 cat $dom > /dev/null
22000 local num=$(get_mdc_stats $mdtidx ost_read)
22001 local ra=$(get_mdc_stats $mdtidx req_active)
22002 local rw=$(get_mdc_stats $mdtidx req_waittime)
22004 [ -z $num ] && num=0
22005 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
22006 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22010 cmp $tmp $dom || error "file miscompare"
22014 run_test 271f "DoM: read on open (200K file and read tail)"
22017 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
22018 skip "Skipping due to old client or server version"
22020 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
22022 $CHECKSTAT -t file $DIR1/$tfile
22024 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
22027 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
22028 $LCTL set_param fail_loc=0x80000314
22029 rm $DIR1/$tfile || error "Unlink fails"
22031 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
22032 [ $RC -eq 0 ] || error "Failed write to stale object"
22034 run_test 271g "Discard DoM data vs client flush race"
22037 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22038 skip "Need MDS version at least 2.11.50"
22040 local dom=$DIR/$tdir/dom
22041 mkdir -p $DIR/$tdir
22043 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
22044 dd if=/dev/urandom of=$dom bs=512K count=1 ||
22045 error "failed to write data into $dom"
22046 local old_md5=$(md5sum $dom)
22048 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
22049 error "failed to migrate to the same DoM component"
22051 local new_md5=$(md5sum $dom)
22053 [ "$old_md5" == "$new_md5" ] ||
22054 error "md5sum differ: $old_md5, $new_md5"
22056 [ $($LFS getstripe -c $dom) -eq 2 ] ||
22057 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
22059 run_test 272a "DoM migration: new layout with the same DOM component"
22062 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22063 skip "Need MDS version at least 2.11.50"
22065 local dom=$DIR/$tdir/dom
22066 mkdir -p $DIR/$tdir
22067 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22069 local mdtidx=$($LFS getstripe -m $dom)
22070 local mdtname=MDT$(printf %04x $mdtidx)
22071 local facet=mds$((mdtidx + 1))
22073 local mdtfree1=$(do_facet $facet \
22074 lctl get_param -n osd*.*$mdtname.kbytesfree)
22075 dd if=/dev/urandom of=$dom bs=2M count=1 ||
22076 error "failed to write data into $dom"
22077 local old_md5=$(md5sum $dom)
22078 cancel_lru_locks mdc
22079 local mdtfree1=$(do_facet $facet \
22080 lctl get_param -n osd*.*$mdtname.kbytesfree)
22082 $LFS migrate -c2 $dom ||
22083 error "failed to migrate to the new composite layout"
22084 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22085 error "MDT stripe was not removed"
22087 cancel_lru_locks mdc
22088 local new_md5=$(md5sum $dom)
22089 [ "$old_md5" == "$new_md5" ] ||
22090 error "$old_md5 != $new_md5"
22092 # Skip free space checks with ZFS
22093 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22094 local mdtfree2=$(do_facet $facet \
22095 lctl get_param -n osd*.*$mdtname.kbytesfree)
22096 [ $mdtfree2 -gt $mdtfree1 ] ||
22097 error "MDT space is not freed after migration"
22101 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
22104 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22105 skip "Need MDS version at least 2.11.50"
22107 local dom=$DIR/$tdir/$tfile
22108 mkdir -p $DIR/$tdir
22109 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22111 local mdtidx=$($LFS getstripe -m $dom)
22112 local mdtname=MDT$(printf %04x $mdtidx)
22113 local facet=mds$((mdtidx + 1))
22115 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
22116 error "failed to write data into $dom"
22117 local old_md5=$(md5sum $dom)
22118 cancel_lru_locks mdc
22119 local mdtfree1=$(do_facet $facet \
22120 lctl get_param -n osd*.*$mdtname.kbytesfree)
22122 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
22123 error "failed to migrate to the new composite layout"
22124 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
22125 error "MDT stripe was not removed"
22127 cancel_lru_locks mdc
22128 local new_md5=$(md5sum $dom)
22129 [ "$old_md5" == "$new_md5" ] ||
22130 error "$old_md5 != $new_md5"
22132 # Skip free space checks with ZFS
22133 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22134 local mdtfree2=$(do_facet $facet \
22135 lctl get_param -n osd*.*$mdtname.kbytesfree)
22136 [ $mdtfree2 -gt $mdtfree1 ] ||
22137 error "MDS space is not freed after migration"
22141 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
22144 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22145 skip "Need MDS version at least 2.12.55"
22147 local dom=$DIR/$tdir/$tfile
22148 mkdir -p $DIR/$tdir
22149 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22151 local mdtidx=$($LFS getstripe -m $dom)
22152 local mdtname=MDT$(printf %04x $mdtidx)
22153 local facet=mds$((mdtidx + 1))
22155 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
22156 error "failed to write data into $dom"
22157 local old_md5=$(md5sum $dom)
22158 cancel_lru_locks mdc
22159 local mdtfree1=$(do_facet $facet \
22160 lctl get_param -n osd*.*$mdtname.kbytesfree)
22162 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
22163 error "failed mirroring to the new composite layout"
22164 $LFS mirror resync $dom ||
22165 error "failed mirror resync"
22166 $LFS mirror split --mirror-id 1 -d $dom ||
22167 error "failed mirror split"
22169 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22170 error "MDT stripe was not removed"
22172 cancel_lru_locks mdc
22173 local new_md5=$(md5sum $dom)
22174 [ "$old_md5" == "$new_md5" ] ||
22175 error "$old_md5 != $new_md5"
22177 # Skip free space checks with ZFS
22178 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22179 local mdtfree2=$(do_facet $facet \
22180 lctl get_param -n osd*.*$mdtname.kbytesfree)
22181 [ $mdtfree2 -gt $mdtfree1 ] ||
22182 error "MDS space is not freed after DOM mirror deletion"
22186 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
22189 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22190 skip "Need MDS version at least 2.12.55"
22192 local dom=$DIR/$tdir/$tfile
22193 mkdir -p $DIR/$tdir
22194 $LFS setstripe -c 2 $dom
22196 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
22197 error "failed to write data into $dom"
22198 local old_md5=$(md5sum $dom)
22199 cancel_lru_locks mdc
22201 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
22202 error "failed mirroring to the DOM layout"
22203 $LFS mirror resync $dom ||
22204 error "failed mirror resync"
22205 $LFS mirror split --mirror-id 1 -d $dom ||
22206 error "failed mirror split"
22208 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22209 error "MDT stripe was not removed"
22211 cancel_lru_locks mdc
22212 local new_md5=$(md5sum $dom)
22213 [ "$old_md5" == "$new_md5" ] ||
22214 error "$old_md5 != $new_md5"
22218 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
22221 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22222 skip "Need MDS version at least 2.12.55"
22224 local dom=$DIR/$tdir/$tfile
22225 mkdir -p $DIR/$tdir
22226 $LFS setstripe -c 2 $dom
22228 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
22229 error "failed to write data into $dom"
22230 local old_md5=$(md5sum $dom)
22231 cancel_lru_locks mdc
22233 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
22234 error "failed migrating to the DOM file"
22236 cancel_lru_locks mdc
22237 local new_md5=$(md5sum $dom)
22238 [ "$old_md5" != "$new_md5" ] &&
22239 error "$old_md5 != $new_md5"
22243 run_test 272f "DoM migration: OST-striped file to DOM file"
22246 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22247 skip "Need MDS version at least 2.11.50"
22249 # Layout swap cannot be done if either file has DOM component,
22250 # this will never be supported, migration should be used instead
22252 local dom=$DIR/$tdir/$tfile
22253 mkdir -p $DIR/$tdir
22255 $LFS setstripe -c2 ${dom}_plain
22256 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
22257 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
22258 error "can swap layout with DoM component"
22259 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
22260 error "can swap layout with DoM component"
22262 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
22263 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
22264 error "can swap layout with DoM component"
22265 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
22266 error "can swap layout with DoM component"
22269 run_test 273a "DoM: layout swapping should fail with DOM"
22272 mkdir -p $DIR/$tdir
22273 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
22275 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
22276 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
22278 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
22280 run_test 273b "DoM: race writeback and object destroy"
22283 remote_ost_nodsh && skip "remote OST with nodsh"
22284 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
22285 skip "Need OST version >= 2.10.57"
22287 local file=$DIR/$tfile
22290 oss=$(comma_list $(osts_nodes))
22292 dd if=/dev/urandom of=$file bs=1M count=2 ||
22293 error "failed to create a file"
22294 cancel_lru_locks osc
22297 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
22298 error "failed to read a file"
22300 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
22301 $LCTL set_param fail_loc=0x8000031f
22303 cancel_lru_locks osc &
22306 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
22307 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
22308 #IO takes another lock, but matches the PENDING one
22309 #and places it to the IO RPC
22310 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
22311 error "failed to read a file with PENDING lock"
22313 run_test 275 "Read on a canceled duplicate lock"
22316 remote_ost_nodsh && skip "remote OST with nodsh"
22319 do_facet ost1 "(while true; do \
22320 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
22321 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
22324 for LOOP in $(seq 20); do
22326 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
22329 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
22330 rm $TMP/sanity_276_pid"
22332 run_test 276 "Race between mount and obd_statfs"
22335 $LCTL set_param ldlm.namespaces.*.lru_size=0
22336 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
22337 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
22338 grep ^used_mb | awk '{print $2}')
22339 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
22340 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
22341 oflag=direct conv=notrunc
22342 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
22343 grep ^used_mb | awk '{print $2}')
22344 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
22346 run_test 277 "Direct IO shall drop page cache"
22349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
22350 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
22351 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
22352 skip "needs the same host for mdt1 mdt2" && return
22357 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
22358 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
22364 echo "Starting MDTs"
22365 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
22367 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
22369 do_facet mds2 $LCTL set_param fail_loc=0
22371 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
22372 wait_recovery_complete mds2
22374 run_test 278 "Race starting MDS between MDTs stop/start"
22377 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
22378 skip "Need MGS version at least 2.13.52"
22379 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22380 combined_mgs_mds || skip "needs combined MGS/MDT"
22382 umount_client $MOUNT
22383 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
22384 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
22386 mount_client $MOUNT &
22388 stop mgs || error "stop mgs failed"
22389 #for a race mgs would crash
22390 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
22391 # make sure we unmount client before remounting
22393 umount_client $MOUNT
22394 mount_client $MOUNT || error "mount client failed"
22396 run_test 280 "Race between MGS umount and client llog processing"
22398 cleanup_test_300() {
22402 test_striped_dir() {
22407 mkdir -p $DIR/$tdir
22409 SAVE_UMASK=$(umask)
22410 trap cleanup_test_300 RETURN EXIT
22412 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
22413 $DIR/$tdir/striped_dir ||
22414 error "set striped dir error"
22416 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
22417 [ "$mode" = "755" ] || error "expect 755 got $mode"
22419 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
22420 error "getdirstripe failed"
22421 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
22422 if [ "$stripe_count" != "2" ]; then
22423 error "1:stripe_count is $stripe_count, expect 2"
22425 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
22426 if [ "$stripe_count" != "2" ]; then
22427 error "2:stripe_count is $stripe_count, expect 2"
22430 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
22431 if [ "$stripe_index" != "$mdt_index" ]; then
22432 error "stripe_index is $stripe_index, expect $mdt_index"
22435 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
22436 error "nlink error after create striped dir"
22438 mkdir $DIR/$tdir/striped_dir/a
22439 mkdir $DIR/$tdir/striped_dir/b
22441 stat $DIR/$tdir/striped_dir/a ||
22442 error "create dir under striped dir failed"
22443 stat $DIR/$tdir/striped_dir/b ||
22444 error "create dir under striped dir failed"
22446 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
22447 error "nlink error after mkdir"
22449 rmdir $DIR/$tdir/striped_dir/a
22450 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
22451 error "nlink error after rmdir"
22453 rmdir $DIR/$tdir/striped_dir/b
22454 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
22455 error "nlink error after rmdir"
22457 chattr +i $DIR/$tdir/striped_dir
22458 createmany -o $DIR/$tdir/striped_dir/f 10 &&
22459 error "immutable flags not working under striped dir!"
22460 chattr -i $DIR/$tdir/striped_dir
22462 rmdir $DIR/$tdir/striped_dir ||
22463 error "rmdir striped dir error"
22471 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22472 skip "skipped for lustre < 2.7.0"
22473 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22474 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22476 test_striped_dir 0 || error "failed on striped dir on MDT0"
22477 test_striped_dir 1 || error "failed on striped dir on MDT0"
22479 run_test 300a "basic striped dir sanity test"
22482 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22483 skip "skipped for lustre < 2.7.0"
22484 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22485 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22492 test_mkdir $DIR/$tdir || error "mkdir fail"
22493 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
22494 error "set striped dir error"
22495 for i in {0..9}; do
22496 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
22498 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
22499 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
22500 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
22502 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
22503 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
22504 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
22508 run_test 300b "check ctime/mtime for striped dir"
22511 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22512 skip "skipped for lustre < 2.7.0"
22513 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22514 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22518 mkdir_on_mdt0 $DIR/$tdir
22519 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
22520 error "set striped dir error"
22522 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
22523 error "chown striped dir failed"
22525 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
22526 error "create 5k files failed"
22528 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
22530 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
22534 run_test 300c "chown && check ls under striped directory"
22537 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22538 skip "skipped for lustre < 2.7.0"
22539 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22540 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22545 mkdir -p $DIR/$tdir
22546 $LFS setstripe -c 2 $DIR/$tdir
22548 #local striped directory
22549 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
22550 error "set striped dir error"
22551 #look at the directories for debug purposes
22553 $LFS getdirstripe $DIR/$tdir
22554 ls -l $DIR/$tdir/striped_dir
22555 $LFS getdirstripe $DIR/$tdir/striped_dir
22556 createmany -o $DIR/$tdir/striped_dir/f 10 ||
22557 error "create 10 files failed"
22559 #remote striped directory
22560 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
22561 error "set striped dir error"
22562 #look at the directories for debug purposes
22564 $LFS getdirstripe $DIR/$tdir
22565 ls -l $DIR/$tdir/remote_striped_dir
22566 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
22567 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
22568 error "create 10 files failed"
22570 for file in $(find $DIR/$tdir); do
22571 stripe_count=$($LFS getstripe -c $file)
22572 [ $stripe_count -eq 2 ] ||
22573 error "wrong stripe $stripe_count for $file"
22578 run_test 300d "check default stripe under striped directory"
22581 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22582 skip "Need MDS version at least 2.7.55"
22583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22584 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22589 mkdir -p $DIR/$tdir
22591 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
22592 error "set striped dir error"
22594 touch $DIR/$tdir/striped_dir/a
22595 touch $DIR/$tdir/striped_dir/b
22596 touch $DIR/$tdir/striped_dir/c
22598 mkdir $DIR/$tdir/striped_dir/dir_a
22599 mkdir $DIR/$tdir/striped_dir/dir_b
22600 mkdir $DIR/$tdir/striped_dir/dir_c
22602 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
22603 error "set striped adir under striped dir error"
22605 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
22606 error "set striped bdir under striped dir error"
22608 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
22609 error "set striped cdir under striped dir error"
22611 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
22612 error "rename dir under striped dir fails"
22614 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
22615 error "rename dir under different stripes fails"
22617 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
22618 error "rename file under striped dir should succeed"
22620 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
22621 error "rename dir under striped dir should succeed"
22625 run_test 300e "check rename under striped directory"
22628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22629 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22630 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22631 skip "Need MDS version at least 2.7.55"
22637 mkdir -p $DIR/$tdir
22639 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
22640 error "set striped dir error"
22642 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
22643 error "set striped dir error"
22645 touch $DIR/$tdir/striped_dir/a
22646 mkdir $DIR/$tdir/striped_dir/dir_a
22647 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
22648 error "create striped dir under striped dir fails"
22650 touch $DIR/$tdir/striped_dir1/b
22651 mkdir $DIR/$tdir/striped_dir1/dir_b
22652 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
22653 error "create striped dir under striped dir fails"
22655 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
22656 error "rename dir under different striped dir should fail"
22658 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
22659 error "rename striped dir under diff striped dir should fail"
22661 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
22662 error "rename file under diff striped dirs fails"
22666 run_test 300f "check rename cross striped directory"
22668 test_300_check_default_striped_dir()
22671 local default_count=$2
22672 local default_index=$3
22675 local dir_stripe_index
22678 echo "checking $dirname $default_count $default_index"
22679 $LFS setdirstripe -D -c $default_count -i $default_index \
22680 -H all_char $DIR/$tdir/$dirname ||
22681 error "set default stripe on striped dir error"
22682 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
22683 [ $stripe_count -eq $default_count ] ||
22684 error "expect $default_count get $stripe_count for $dirname"
22686 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
22687 [ $stripe_index -eq $default_index ] ||
22688 error "expect $default_index get $stripe_index for $dirname"
22690 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
22691 error "create dirs failed"
22693 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
22694 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
22695 for dir in $(find $DIR/$tdir/$dirname/*); do
22696 stripe_count=$($LFS getdirstripe -c $dir)
22697 (( $stripe_count == $default_count )) ||
22698 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
22699 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
22700 error "stripe count $default_count != $stripe_count for $dir"
22702 stripe_index=$($LFS getdirstripe -i $dir)
22703 [ $default_index -eq -1 ] ||
22704 [ $stripe_index -eq $default_index ] ||
22705 error "$stripe_index != $default_index for $dir"
22707 #check default stripe
22708 stripe_count=$($LFS getdirstripe -D -c $dir)
22709 [ $stripe_count -eq $default_count ] ||
22710 error "default count $default_count != $stripe_count for $dir"
22712 stripe_index=$($LFS getdirstripe -D -i $dir)
22713 [ $stripe_index -eq $default_index ] ||
22714 error "default index $default_index != $stripe_index for $dir"
22716 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
22720 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22721 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22722 skip "Need MDS version at least 2.7.55"
22728 mkdir_on_mdt0 $DIR/$tdir
22729 mkdir $DIR/$tdir/normal_dir
22731 #Checking when client cache stripe index
22732 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
22733 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
22734 error "create striped_dir failed"
22736 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
22737 error "create dir0 fails"
22738 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
22739 [ $stripe_index -eq 0 ] ||
22740 error "dir0 expect index 0 got $stripe_index"
22742 mkdir $DIR/$tdir/striped_dir/dir1 ||
22743 error "create dir1 fails"
22744 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
22745 [ $stripe_index -eq 1 ] ||
22746 error "dir1 expect index 1 got $stripe_index"
22748 #check default stripe count/stripe index
22749 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
22750 test_300_check_default_striped_dir normal_dir 1 0
22751 test_300_check_default_striped_dir normal_dir -1 1
22752 test_300_check_default_striped_dir normal_dir 2 -1
22754 #delete default stripe information
22755 echo "delete default stripeEA"
22756 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
22757 error "set default stripe on striped dir error"
22759 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
22760 for dir in $(find $DIR/$tdir/normal_dir/*); do
22761 stripe_count=$($LFS getdirstripe -c $dir)
22762 [ $stripe_count -eq 0 ] ||
22763 error "expect 1 get $stripe_count for $dir"
22766 run_test 300g "check default striped directory for normal directory"
22769 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22770 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22771 skip "Need MDS version at least 2.7.55"
22777 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
22778 error "set striped dir error"
22780 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
22781 test_300_check_default_striped_dir striped_dir 1 0
22782 test_300_check_default_striped_dir striped_dir -1 1
22783 test_300_check_default_striped_dir striped_dir 2 -1
22785 #delete default stripe information
22786 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
22787 error "set default stripe on striped dir error"
22789 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
22790 for dir in $(find $DIR/$tdir/striped_dir/*); do
22791 stripe_count=$($LFS getdirstripe -c $dir)
22792 [ $stripe_count -eq 0 ] ||
22793 error "expect 1 get $stripe_count for $dir"
22796 run_test 300h "check default striped directory for striped directory"
22799 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22800 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22801 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22802 skip "Need MDS version at least 2.7.55"
22809 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
22810 error "set striped dir error"
22812 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
22813 error "create files under striped dir failed"
22815 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
22816 error "set striped hashdir error"
22818 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
22819 error "create dir0 under hash dir failed"
22820 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
22821 error "create dir1 under hash dir failed"
22822 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
22823 error "create dir2 under hash dir failed"
22825 # unfortunately, we need to umount to clear dir layout cache for now
22826 # once we fully implement dir layout, we can drop this
22827 umount_client $MOUNT || error "umount failed"
22828 mount_client $MOUNT || error "mount failed"
22830 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
22831 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
22832 [ $dircnt -eq 2 ] || error "lfs find striped dir got:$dircnt,except:1"
22834 #set the stripe to be unknown hash type
22835 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
22836 $LCTL set_param fail_loc=0x1901
22837 for ((i = 0; i < 10; i++)); do
22838 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
22839 error "stat f-$i failed"
22840 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
22843 touch $DIR/$tdir/striped_dir/f0 &&
22844 error "create under striped dir with unknown hash should fail"
22846 $LCTL set_param fail_loc=0
22848 umount_client $MOUNT || error "umount failed"
22849 mount_client $MOUNT || error "mount failed"
22853 run_test 300i "client handle unknown hash type striped directory"
22856 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22857 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22858 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22859 skip "Need MDS version at least 2.7.55"
22866 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
22867 $LCTL set_param fail_loc=0x1702
22868 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
22869 error "set striped dir error"
22871 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
22872 error "create files under striped dir failed"
22874 $LCTL set_param fail_loc=0
22876 rm -rf $DIR/$tdir || error "unlink striped dir fails"
22880 run_test 300j "test large update record"
22883 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22884 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22885 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22886 skip "Need MDS version at least 2.7.55"
22888 # this test needs a huge transaction
22890 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
22891 osd*.$FSNAME-MDT0000.kbytestotal")
22892 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
22899 #define OBD_FAIL_LARGE_STRIPE 0x1703
22900 $LCTL set_param fail_loc=0x1703
22901 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
22902 error "set striped dir error"
22903 $LCTL set_param fail_loc=0
22905 $LFS getdirstripe $DIR/$tdir/striped_dir ||
22906 error "getstripeddir fails"
22907 rm -rf $DIR/$tdir/striped_dir ||
22908 error "unlink striped dir fails"
22912 run_test 300k "test large striped directory"
22915 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22916 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22917 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22918 skip "Need MDS version at least 2.7.55"
22922 test_mkdir -p $DIR/$tdir/striped_dir
22923 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
22924 error "chown $RUNAS_ID failed"
22925 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
22926 error "set default striped dir failed"
22928 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
22929 $LCTL set_param fail_loc=0x80000158
22930 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
22932 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
22933 [ $stripe_index -eq 1 ] ||
22934 error "expect 1 get $stripe_index for $dir"
22936 run_test 300l "non-root user to create dir under striped dir with stale layout"
22939 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22940 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
22941 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22942 skip "Need MDS version at least 2.7.55"
22944 mkdir -p $DIR/$tdir/striped_dir
22945 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
22946 error "set default stripes dir error"
22948 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
22950 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
22951 [ $stripe_count -eq 0 ] ||
22952 error "expect 0 get $stripe_count for a"
22954 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
22955 error "set default stripes dir error"
22957 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
22959 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
22960 [ $stripe_count -eq 0 ] ||
22961 error "expect 0 get $stripe_count for b"
22963 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
22964 error "set default stripes dir error"
22966 mkdir $DIR/$tdir/striped_dir/c &&
22967 error "default stripe_index is invalid, mkdir c should fails"
22969 rm -rf $DIR/$tdir || error "rmdir fails"
22971 run_test 300m "setstriped directory on single MDT FS"
22974 local list=$(comma_list $(mdts_nodes))
22977 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
22981 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22982 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22983 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22984 skip "Need MDS version at least 2.7.55"
22985 remote_mds_nodsh && skip "remote MDS with nodsh"
22988 local list=$(comma_list $(mdts_nodes))
22990 trap cleanup_300n RETURN EXIT
22991 mkdir -p $DIR/$tdir
22992 chmod 777 $DIR/$tdir
22993 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
22994 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
22995 error "create striped dir succeeds with gid=0"
22997 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
22998 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
22999 error "create striped dir fails with gid=-1"
23001 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
23002 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
23003 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
23004 error "set default striped dir succeeds with gid=0"
23007 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
23008 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
23009 error "set default striped dir fails with gid=-1"
23012 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
23013 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
23014 error "create test_dir fails"
23015 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
23016 error "create test_dir1 fails"
23017 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
23018 error "create test_dir2 fails"
23021 run_test 300n "non-root user to create dir under striped dir with default EA"
23024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23025 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23026 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23027 skip "Need MDS version at least 2.7.55"
23032 mkdir -p $DIR/$tdir
23034 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
23035 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
23036 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
23037 skip "not enough free inodes $numfree1 $numfree2"
23040 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
23041 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
23042 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
23043 skip "not enough free space $numfree1 $numfree2"
23046 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
23047 error "setdirstripe fails"
23049 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
23050 error "create dirs fails"
23052 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
23053 ls $DIR/$tdir/striped_dir > /dev/null ||
23054 error "ls striped dir fails"
23055 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
23056 error "unlink big striped dir fails"
23058 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
23061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23062 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23063 remote_mds_nodsh && skip "remote MDS with nodsh"
23065 mkdir_on_mdt0 $DIR/$tdir
23067 #define OBD_FAIL_OUT_ENOSPC 0x1704
23068 do_facet mds2 lctl set_param fail_loc=0x80001704
23069 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
23070 && error "create striped directory should fail"
23072 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
23074 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
23077 run_test 300p "create striped directory without space"
23080 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23081 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23083 local fd=$(free_fd)
23084 local cmd="exec $fd<$tdir"
23086 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
23089 trap "eval $cmd" EXIT
23090 cd $tdir || error "cd $tdir fails"
23091 rmdir ../$tdir || error "rmdir $tdir fails"
23092 mkdir local_dir && error "create dir succeeds"
23093 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
23097 run_test 300q "create remote directory under orphan directory"
23100 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23101 skip "Need MDS version at least 2.7.55" && return
23102 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23106 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
23107 error "set striped dir error"
23109 $LFS getdirstripe $DIR/$tdir/striped_dir ||
23110 error "getstripeddir fails"
23113 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
23114 awk '/lmv_stripe_count:/ { print $2 }')
23116 [ $MDSCOUNT -ne $stripe_count ] &&
23117 error "wrong stripe count $stripe_count expected $MDSCOUNT"
23119 rm -rf $DIR/$tdir/striped_dir ||
23120 error "unlink striped dir fails"
23122 run_test 300r "test -1 striped directory"
23124 test_300s_helper() {
23127 local stripe_dir=$DIR/$tdir/striped_dir.$count
23129 $LFS mkdir -c $count $stripe_dir ||
23130 error "lfs mkdir -c error"
23132 $LFS getdirstripe $stripe_dir ||
23133 error "lfs getdirstripe fails"
23136 stripe_count=$($LFS getdirstripe $stripe_dir |
23137 awk '/lmv_stripe_count:/ { print $2 }')
23139 [ $count -ne $stripe_count ] &&
23140 error_noexit "bad stripe count $stripe_count expected $count"
23143 dupe_stripes=$($LFS getdirstripe $stripe_dir |
23144 awk '/0x/ {count[$1] += 1}; END {
23145 for (idx in count) {
23146 if (count[idx]>1) {
23147 print "index " idx " count " count[idx]
23152 if [[ -n "$dupe_stripes" ]] ; then
23153 lfs getdirstripe $stripe_dir
23154 error_noexit "Dupe MDT above: $dupe_stripes "
23157 rm -rf $stripe_dir ||
23158 error_noexit "unlink $stripe_dir fails"
23162 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23163 skip "Need MDS version at least 2.7.55" && return
23164 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23167 for count in $(seq 2 $MDSCOUNT); do
23168 test_300s_helper $count
23171 run_test 300s "test lfs mkdir -c without -i"
23174 prepare_remote_file() {
23175 mkdir $DIR/$tdir/src_dir ||
23176 error "create remote source failed"
23178 cp /etc/hosts $DIR/$tdir/src_dir/a ||
23179 error "cp to remote source failed"
23180 touch $DIR/$tdir/src_dir/a
23182 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
23183 error "create remote target dir failed"
23185 touch $DIR/$tdir/tgt_dir/b
23187 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
23188 error "rename dir cross MDT failed!"
23190 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
23191 error "src_child still exists after rename"
23193 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
23194 error "missing file(a) after rename"
23196 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
23197 error "diff after rename"
23201 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
23202 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23204 local remote_file=$DIR/$tdir/tgt_dir/b
23206 mkdir -p $DIR/$tdir
23208 prepare_remote_file || error "prepare remote file failed"
23211 $OPENUNLINK $remote_file $remote_file ||
23212 error "openunlink $remote_file failed"
23213 $CHECKSTAT -a $remote_file || error "$remote_file exists"
23215 run_test 310a "open unlink remote file"
23218 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
23219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23221 local remote_file=$DIR/$tdir/tgt_dir/b
23223 mkdir -p $DIR/$tdir
23225 prepare_remote_file || error "prepare remote file failed"
23227 ln $remote_file $DIR/$tfile || error "link failed for remote file"
23228 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
23229 $CHECKSTAT -t file $remote_file || error "check file failed"
23231 run_test 310b "unlink remote file with multiple links while open"
23234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23235 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
23237 local remote_file=$DIR/$tdir/tgt_dir/b
23239 mkdir -p $DIR/$tdir
23241 prepare_remote_file || error "prepare remote file failed"
23243 ln $remote_file $DIR/$tfile || error "link failed for remote file"
23244 multiop_bg_pause $remote_file O_uc ||
23245 error "mulitop failed for remote file"
23247 $MULTIOP $DIR/$tfile Ouc
23248 kill -USR1 $MULTIPID
23251 run_test 310c "open-unlink remote file with multiple links"
23255 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23256 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
23257 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
23258 skip "lustre < 2.8.54 does not contain LU-4825 fix"
23259 remote_mds_nodsh && skip "remote MDS with nodsh"
23261 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
23262 local mdts=$(comma_list $(mdts_nodes))
23264 mkdir -p $DIR/$tdir
23265 $LFS setstripe -i 0 -c 1 $DIR/$tdir
23266 createmany -o $DIR/$tdir/$tfile. 1000
23268 # statfs data is not real time, let's just calculate it
23269 old_iused=$((old_iused + 1000))
23271 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
23272 osp.*OST0000*MDT0000.create_count")
23273 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
23274 osp.*OST0000*MDT0000.max_create_count")
23275 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
23277 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
23278 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
23279 [ $index -ne 0 ] || error "$tfile stripe index is 0"
23281 unlinkmany $DIR/$tdir/$tfile. 1000
23283 do_nodes $mdts "$LCTL set_param -n \
23284 osp.*OST0000*.max_create_count=$max_count"
23285 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
23286 do_nodes $mdts "$LCTL set_param -n \
23287 osp.*OST0000*.create_count=$count"
23288 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
23289 grep "=0" && error "create_count is zero"
23292 for i in $(seq 120); do
23293 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
23294 # system may be too busy to destroy all objs in time, use
23295 # a somewhat small value to not fail autotest
23296 [ $((old_iused - new_iused)) -gt 400 ] && break
23300 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
23301 [ $((old_iused - new_iused)) -gt 400 ] ||
23302 error "objs not destroyed after unlink"
23304 run_test 311 "disable OSP precreate, and unlink should destroy objs"
23311 local vdevdir=$(dirname $(facet_vdevice $ost))
23312 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
23313 local zfs_zapid=$(do_facet $ost $cmd |
23314 grep -w "/O/0/d$((objid%32))" -C 5 |
23315 awk '/Object/{getline; print $1}')
23316 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
23317 awk "/$objid = /"'{printf $3}')
23322 zfs_object_blksz() {
23326 local vdevdir=$(dirname $(facet_vdevice $ost))
23327 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
23328 local blksz=$(do_facet $ost $cmd $objid |
23329 awk '/dblk/{getline; printf $4}')
23331 case "${blksz: -1}" in
23332 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
23333 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
23340 test_312() { # LU-4856
23341 remote_ost_nodsh && skip "remote OST with nodsh"
23342 [ "$ost1_FSTYPE" = "zfs" ] ||
23343 skip_env "the test only applies to zfs"
23345 local max_blksz=$(do_facet ost1 \
23346 $ZFS get -p recordsize $(facet_device ost1) |
23347 awk '!/VALUE/{print $3}')
23349 # to make life a little bit easier
23350 $LFS mkdir -c 1 -i 0 $DIR/$tdir
23351 $LFS setstripe -c 1 -i 0 $DIR/$tdir
23353 local tf=$DIR/$tdir/$tfile
23355 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
23357 # Get ZFS object id
23358 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
23359 # block size change by sequential overwrite
23362 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
23363 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
23365 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
23366 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
23370 # block size change by sequential append write
23371 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
23372 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
23373 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
23376 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
23377 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
23378 oflag=sync conv=notrunc
23380 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23381 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
23382 error "blksz error, actual $blksz, " \
23383 "expected: 2 * $count * $PAGE_SIZE"
23389 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
23390 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
23392 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
23393 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23394 [ $blksz -eq $PAGE_SIZE ] ||
23395 error "blksz error: $blksz, expected: $PAGE_SIZE"
23397 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
23398 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23399 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
23401 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
23402 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23403 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
23405 run_test 312 "make sure ZFS adjusts its block size by write pattern"
23408 remote_ost_nodsh && skip "remote OST with nodsh"
23410 local file=$DIR/$tfile
23413 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
23415 # define OBD_FAIL_TGT_RCVD_EIO 0x720
23416 do_facet ost1 "$LCTL set_param fail_loc=0x720"
23417 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
23418 error "write should failed"
23419 do_facet ost1 "$LCTL set_param fail_loc=0"
23422 run_test 313 "io should fail after last_rcvd update fail"
23425 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
23427 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
23428 do_facet ost1 "$LCTL set_param fail_loc=0x720"
23430 wait_delete_completed
23431 do_facet ost1 "$LCTL set_param fail_loc=0"
23433 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
23435 test_315() { # LU-618
23436 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
23438 local file=$DIR/$tfile
23441 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
23442 error "multiop file write failed"
23443 $MULTIOP $file oO_RDONLY:r4063232_c &
23448 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
23451 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
23454 run_test 315 "read should be accounted"
23457 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
23458 large_xattr_enabled || skip_env "ea_inode feature disabled"
23460 rm -rf $DIR/$tdir/d
23461 mkdir -p $DIR/$tdir/d
23462 chown nobody $DIR/$tdir/d
23463 touch $DIR/$tdir/d/file
23465 $LFS mv -m1 $DIR/$tdir/d || error "lfs mv failed"
23467 run_test 316 "lfs mv"
23470 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
23471 skip "Need MDS version at least 2.11.53"
23472 if [ "$ost1_FSTYPE" == "zfs" ]; then
23473 skip "LU-10370: no implementation for ZFS"
23477 local grant_blk_size
23479 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
23480 awk '/grant_block_size:/ { print $2; exit; }')
23482 # Create File of size 5M. Truncate it to below size's and verify
23485 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
23486 error "Create file $DIR/$tfile failed"
23487 stack_trap "rm -f $DIR/$tfile" EXIT
23489 for trunc_sz in 2097152 4097 4000 509 0; do
23490 $TRUNCATE $DIR/$tfile $trunc_sz ||
23491 error "truncate $tfile to $trunc_sz failed"
23492 local sz=$(stat --format=%s $DIR/$tfile)
23493 local blk=$(stat --format=%b $DIR/$tfile)
23494 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
23495 grant_blk_size) * 8))
23497 if [[ $blk -ne $trunc_blk ]]; then
23498 $(which stat) $DIR/$tfile
23499 error "Expected Block $trunc_blk got $blk for $tfile"
23502 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
23503 error "Expected Size $trunc_sz got $sz for $tfile"
23508 # Create file with a hole and write actual two blocks. Block count
23511 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
23512 conv=fsync || error "Create file : $DIR/$tfile"
23514 # Calculate the final truncate size.
23515 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
23518 # truncate to size $trunc_sz bytes. Strip the last block
23519 # The block count must drop to 8
23521 $TRUNCATE $DIR/$tfile $trunc_sz ||
23522 error "truncate $tfile to $trunc_sz failed"
23524 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
23525 sz=$(stat --format=%s $DIR/$tfile)
23526 blk=$(stat --format=%b $DIR/$tfile)
23528 if [[ $blk -ne $trunc_bsz ]]; then
23529 $(which stat) $DIR/$tfile
23530 error "Expected Block $trunc_bsz got $blk for $tfile"
23533 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
23534 error "Expected Size $trunc_sz got $sz for $tfile"
23536 run_test 317 "Verify blocks get correctly update after truncate"
23539 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
23540 local old_max_active=$($LCTL get_param -n \
23541 ${llite_name}.max_read_ahead_async_active \
23544 $LCTL set_param llite.*.max_read_ahead_async_active=256
23545 local max_active=$($LCTL get_param -n \
23546 ${llite_name}.max_read_ahead_async_active \
23548 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
23550 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
23551 error "set max_read_ahead_async_active should succeed"
23553 $LCTL set_param llite.*.max_read_ahead_async_active=512
23554 max_active=$($LCTL get_param -n \
23555 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
23556 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
23558 # restore @max_active
23559 [ $old_max_active -ne 0 ] && $LCTL set_param \
23560 llite.*.max_read_ahead_async_active=$old_max_active
23562 local old_threshold=$($LCTL get_param -n \
23563 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
23564 local max_per_file_mb=$($LCTL get_param -n \
23565 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
23567 local invalid=$(($max_per_file_mb + 1))
23569 llite.*.read_ahead_async_file_threshold_mb=$invalid\
23570 && error "set $invalid should fail"
23572 local valid=$(($invalid - 1))
23574 llite.*.read_ahead_async_file_threshold_mb=$valid ||
23575 error "set $valid should succeed"
23576 local threshold=$($LCTL get_param -n \
23577 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
23578 [ $threshold -eq $valid ] || error \
23579 "expect threshold $valid got $threshold"
23581 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
23583 run_test 318 "Verify async readahead tunables"
23586 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
23588 local before=$(date +%s)
23590 local mdir=$DIR/$tdir
23591 local file=$mdir/xxx
23593 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
23596 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
23597 $LCTL set_param fail_val=5 fail_loc=0x8000032c
23598 $LFS mv -m1 $file &
23601 dd if=$file of=/dev/null
23603 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
23604 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
23606 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
23608 run_test 319 "lost lease lock on migrate error"
23610 test_398a() { # LU-4198
23611 local ost1_imp=$(get_osc_import_name client ost1)
23612 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
23615 $LFS setstripe -c 1 -i 0 $DIR/$tfile
23616 $LCTL set_param ldlm.namespaces.*.lru_size=clear
23618 # request a new lock on client
23619 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23621 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
23622 local lock_count=$($LCTL get_param -n \
23623 ldlm.namespaces.$imp_name.lru_size)
23624 [[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
23626 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
23628 # no lock cached, should use lockless IO and not enqueue new lock
23629 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
23630 lock_count=$($LCTL get_param -n \
23631 ldlm.namespaces.$imp_name.lru_size)
23632 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
23634 run_test 398a "direct IO should cancel lock otherwise lockless"
23636 test_398b() { # LU-4198
23637 which fio || skip_env "no fio installed"
23638 $LFS setstripe -c -1 $DIR/$tfile
23641 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
23644 echo "mix direct rw ${size}M to OST0 by fio with $njobs jobs..."
23645 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
23646 --numjobs=$njobs --fallocate=none \
23647 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
23648 --filename=$DIR/$tfile &
23651 echo "mix buffer rw ${size}M to OST0 by fio with $njobs jobs..."
23652 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE \
23653 --numjobs=$njobs --fallocate=none \
23654 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
23655 --filename=$DIR/$tfile || true
23660 run_test 398b "DIO and buffer IO race"
23662 test_398c() { # LU-4198
23663 local ost1_imp=$(get_osc_import_name client ost1)
23664 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
23667 which fio || skip_env "no fio installed"
23669 saved_debug=$($LCTL get_param -n debug)
23670 $LCTL set_param debug=0
23672 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
23673 ((size /= 1024)) # by megabytes
23674 ((size /= 2)) # write half of the OST at most
23675 [ $size -gt 40 ] && size=40 #reduce test time anyway
23677 $LFS setstripe -c 1 $DIR/$tfile
23679 # it seems like ldiskfs reserves more space than necessary if the
23680 # writing blocks are not mapped, so it extends the file firstly
23681 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
23682 cancel_lru_locks osc
23684 # clear and verify rpc_stats later
23685 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
23688 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
23689 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
23690 --numjobs=$njobs --fallocate=none --ioengine=libaio \
23691 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
23692 --filename=$DIR/$tfile
23693 [ $? -eq 0 ] || error "fio write error"
23695 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
23696 error "Locks were requested while doing AIO"
23698 # get the percentage of 1-page I/O
23699 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
23700 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
23702 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
23704 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
23705 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
23706 --numjobs=$njobs --fallocate=none --ioengine=libaio \
23707 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
23708 --filename=$DIR/$tfile
23709 [ $? -eq 0 ] || error "fio mixed read write error"
23711 echo "AIO with large block size ${size}M"
23712 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
23713 --numjobs=1 --fallocate=none --ioengine=libaio \
23714 --iodepth=16 --allow_file_create=0 --size=${size}M \
23715 --filename=$DIR/$tfile
23716 [ $? -eq 0 ] || error "fio large block size failed"
23719 $LCTL set_param debug="$saved_debug"
23721 run_test 398c "run fio to test AIO"
23723 test_398d() { # LU-13846
23724 which aiocp || skip_env "no aiocp installed"
23725 local aio_file=$DIR/$tfile.aio
23727 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
23729 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
23730 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
23731 stack_trap "rm -f $DIR/$tfile $aio_file"
23733 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
23735 # make sure we don't crash and fail properly
23736 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
23737 error "aio not aligned with PAGE SIZE should fail"
23739 rm -f $DIR/$tfile $aio_file
23741 run_test 398d "run aiocp to verify block size > stripe size"
23744 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
23745 touch $DIR/$tfile.new
23746 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
23748 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
23750 test_398f() { # LU-14687
23751 which aiocp || skip_env "no aiocp installed"
23752 local aio_file=$DIR/$tfile.aio
23754 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
23756 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
23757 stack_trap "rm -f $DIR/$tfile $aio_file"
23759 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
23760 $LCTL set_param fail_loc=0x1418
23761 # make sure we don't crash and fail properly
23762 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
23763 error "aio with page allocation failure succeeded"
23764 $LCTL set_param fail_loc=0
23765 diff $DIR/$tfile $aio_file
23766 [[ $? != 0 ]] || error "no diff after failed aiocp"
23768 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
23770 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
23771 # stripe and i/o size must be > stripe size
23772 # Old style synchronous DIO waits after submitting each chunk, resulting in a
23773 # single RPC in flight. This test shows async DIO submission is working by
23774 # showing multiple RPCs in flight.
23775 test_398g() { # LU-13798
23776 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
23778 # We need to do some i/o first to acquire enough grant to put our RPCs
23779 # in flight; otherwise a new connection may not have enough grant
23781 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
23782 error "parallel dio failed"
23783 stack_trap "rm -f $DIR/$tfile"
23785 # Reduce RPC size to 1M to avoid combination in to larger RPCs
23786 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
23787 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
23788 stack_trap "$LCTL set_param -n $pages_per_rpc"
23790 # Recreate file so it's empty
23792 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
23793 #Pause rpc completion to guarantee we see multiple rpcs in flight
23794 #define OBD_FAIL_OST_BRW_PAUSE_BULK
23795 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
23796 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
23799 $LCTL set_param osc.*.rpc_stats=c
23801 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
23802 error "parallel dio failed"
23803 stack_trap "rm -f $DIR/$tfile"
23805 $LCTL get_param osc.*-OST0000-*.rpc_stats
23806 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
23807 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
23808 grep "8:" | awk '{print $8}')
23809 # We look at the "8 rpcs in flight" field, and verify A) it is present
23810 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
23811 # as expected for an 8M DIO to a file with 1M stripes.
23812 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
23814 # Verify turning off parallel dio works as expected
23816 $LCTL set_param osc.*.rpc_stats=c
23817 $LCTL set_param llite.*.parallel_dio=0
23818 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
23820 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
23821 error "dio with parallel dio disabled failed"
23823 # Ideally, we would see only one RPC in flight here, but there is an
23824 # unavoidable race between i/o completion and RPC in flight counting,
23825 # so while only 1 i/o is in flight at a time, the RPC in flight counter
23826 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
23827 # So instead we just verify it's always < 8.
23828 $LCTL get_param osc.*-OST0000-*.rpc_stats
23829 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
23830 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
23831 grep '^$' -B1 | grep . | awk '{print $1}')
23832 [ $ret != "8:" ] ||
23833 error "we should see fewer than 8 RPCs in flight (saw $ret)"
23835 run_test 398g "verify parallel dio async RPC submission"
23837 test_398h() { # LU-13798
23838 local dio_file=$DIR/$tfile.dio
23840 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
23842 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
23843 stack_trap "rm -f $DIR/$tfile $dio_file"
23845 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
23846 error "parallel dio failed"
23847 diff $DIR/$tfile $dio_file
23848 [[ $? == 0 ]] || error "file diff after aiocp"
23850 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
23852 test_398i() { # LU-13798
23853 local dio_file=$DIR/$tfile.dio
23855 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
23857 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
23858 stack_trap "rm -f $DIR/$tfile $dio_file"
23860 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
23861 $LCTL set_param fail_loc=0x1418
23862 # make sure we don't crash and fail properly
23863 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
23864 error "parallel dio page allocation failure succeeded"
23865 diff $DIR/$tfile $dio_file
23866 [[ $? != 0 ]] || error "no diff after failed aiocp"
23868 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
23870 test_398j() { # LU-13798
23871 # Stripe size > RPC size but less than i/o size tests split across
23872 # stripes and RPCs for individual i/o op
23873 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
23875 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
23876 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
23877 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
23878 stack_trap "$LCTL set_param -n $pages_per_rpc"
23880 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
23881 error "parallel dio write failed"
23882 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
23884 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
23885 error "parallel dio read failed"
23886 diff $DIR/$tfile $DIR/$tfile.2
23887 [[ $? == 0 ]] || error "file diff after parallel dio read"
23889 run_test 398j "test parallel dio where stripe size > rpc_size"
23891 test_398k() { # LU-13798
23892 wait_delete_completed
23895 # 4 stripe file; we will cause out of space on OST0
23896 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
23898 # Fill OST0 (if it's not too large)
23899 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
23901 if [[ $ORIGFREE -gt $MAXFREE ]]; then
23902 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
23904 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
23905 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
23906 error "dd should fill OST0"
23907 stack_trap "rm -f $DIR/$tfile.1"
23909 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
23913 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
23914 error "file is not 0 bytes in size"
23916 # dd above should not succeed, but don't error until here so we can
23917 # get debug info above
23919 error "parallel dio write with enospc succeeded"
23920 stack_trap "rm -f $DIR/$tfile"
23922 run_test 398k "test enospc on first stripe"
23924 test_398l() { # LU-13798
23925 wait_delete_completed
23928 # 4 stripe file; we will cause out of space on OST0
23929 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
23930 # happens on the second i/o chunk we issue
23931 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
23933 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
23934 stack_trap "rm -f $DIR/$tfile"
23936 # Fill OST0 (if it's not too large)
23937 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
23939 if [[ $ORIGFREE -gt $MAXFREE ]]; then
23940 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
23942 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
23943 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
23944 error "dd should fill OST0"
23945 stack_trap "rm -f $DIR/$tfile.1"
23947 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
23949 stack_trap "rm -f $DIR/$tfile.2"
23951 # Check that short write completed as expected
23952 ls -la $DIR/$tfile.2
23953 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
23954 error "file is not 1M in size"
23956 # dd above should not succeed, but don't error until here so we can
23957 # get debug info above
23959 error "parallel dio write with enospc succeeded"
23961 # Truncate source file to same length as output file and diff them
23962 $TRUNCATE $DIR/$tfile 1048576
23963 diff $DIR/$tfile $DIR/$tfile.2
23964 [[ $? == 0 ]] || error "data incorrect after short write"
23966 run_test 398l "test enospc on intermediate stripe/RPC"
23968 test_398m() { # LU-13798
23969 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
23971 # Set up failure on OST0, the first stripe:
23972 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
23973 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
23974 # So this fail_val specifies OST0
23975 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
23976 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
23978 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
23979 error "parallel dio write with failure on first stripe succeeded"
23980 stack_trap "rm -f $DIR/$tfile"
23981 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
23983 # Place data in file for read
23984 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
23985 error "parallel dio write failed"
23987 # Fail read on OST0, first stripe
23988 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
23989 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
23990 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
23991 error "parallel dio read with error on first stripe succeeded"
23992 rm -f $DIR/$tfile.2
23993 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
23995 # Switch to testing on OST1, second stripe
23996 # Clear file contents, maintain striping
23998 # Set up failure on OST1, second stripe:
23999 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=2
24000 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
24002 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
24003 error "parallel dio write with failure on first stripe succeeded"
24004 stack_trap "rm -f $DIR/$tfile"
24005 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
24007 # Place data in file for read
24008 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
24009 error "parallel dio write failed"
24011 # Fail read on OST1, second stripe
24012 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
24013 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
24014 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
24015 error "parallel dio read with error on first stripe succeeded"
24016 rm -f $DIR/$tfile.2
24017 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
24019 run_test 398m "test RPC failures with parallel dio"
24021 # Parallel submission of DIO should not cause problems for append, but it's
24022 # important to verify.
24023 test_398n() { # LU-13798
24024 $LFS setstripe -C 2 -S 1M $DIR/$tfile
24026 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
24027 error "dd to create source file failed"
24028 stack_trap "rm -f $DIR/$tfile"
24030 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
24031 error "parallel dio write with failure on second stripe succeeded"
24032 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
24033 diff $DIR/$tfile $DIR/$tfile.1
24034 [[ $? == 0 ]] || error "data incorrect after append"
24037 run_test 398n "test append with parallel DIO"
24040 local read_write=$1
24041 if [ "$read_write" = "write" ]; then
24042 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
24043 elif [ "$read_write" = "read" ]; then
24044 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
24046 error "argument error"
24049 # turn off debug for performance testing
24050 local saved_debug=$($LCTL get_param -n debug)
24051 $LCTL set_param debug=0
24053 $LFS setstripe -c 1 -i 0 $DIR/$tfile
24055 # get ost1 size - $FSNAME-OST0000
24056 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
24057 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
24058 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
24060 if [ "$read_write" = "read" ]; then
24061 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
24064 local start_time=$(date +%s.%N)
24065 $dd_cmd bs=1M count=$blocks oflag=sync ||
24066 error "real dd $read_write error"
24067 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
24069 if [ "$read_write" = "write" ]; then
24073 # define OBD_FAIL_OST_FAKE_RW 0x238
24074 do_facet ost1 $LCTL set_param fail_loc=0x238
24076 local start_time=$(date +%s.%N)
24077 $dd_cmd bs=1M count=$blocks oflag=sync ||
24078 error "fake dd $read_write error"
24079 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
24081 if [ "$read_write" = "write" ]; then
24083 cancel_lru_locks osc
24084 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
24085 error "$tfile size not $blocks MB"
24087 do_facet ost1 $LCTL set_param fail_loc=0
24089 echo "fake $read_write $duration_fake vs. normal $read_write" \
24090 "$duration in seconds"
24091 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
24092 error_not_in_vm "fake write is slower"
24094 $LCTL set_param -n debug="$saved_debug"
24097 test_399a() { # LU-7655 for OST fake write
24098 remote_ost_nodsh && skip "remote OST with nodsh"
24102 run_test 399a "fake write should not be slower than normal write"
24104 test_399b() { # LU-8726 for OST fake read
24105 remote_ost_nodsh && skip "remote OST with nodsh"
24106 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
24107 skip_env "ldiskfs only test"
24112 run_test 399b "fake read should not be slower than normal read"
24114 test_400a() { # LU-1606, was conf-sanity test_74
24115 if ! which $CC > /dev/null 2>&1; then
24116 skip_env "$CC is not installed"
24119 local extra_flags=''
24120 local out=$TMP/$tfile
24121 local prefix=/usr/include/lustre
24124 # Oleg removes c files in his test rig so test if any c files exist
24125 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
24126 skip_env "Needed c test files are missing"
24128 if ! [[ -d $prefix ]]; then
24129 # Assume we're running in tree and fixup the include path.
24130 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
24131 extra_flags+=" -L$LUSTRE/utils/.lib"
24134 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
24135 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
24136 error "client api broken"
24140 run_test 400a "Lustre client api program can compile and link"
24142 test_400b() { # LU-1606, LU-5011
24144 local out=$TMP/$tfile
24145 local prefix=/usr/include/linux/lustre
24147 # We use a hard coded prefix so that this test will not fail
24148 # when run in tree. There are headers in lustre/include/lustre/
24149 # that are not packaged (like lustre_idl.h) and have more
24150 # complicated include dependencies (like config.h and lnet/types.h).
24151 # Since this test about correct packaging we just skip them when
24152 # they don't exist (see below) rather than try to fixup cppflags.
24154 if ! which $CC > /dev/null 2>&1; then
24155 skip_env "$CC is not installed"
24158 for header in $prefix/*.h; do
24159 if ! [[ -f "$header" ]]; then
24163 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
24164 continue # lustre_ioctl.h is internal header
24167 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
24168 error "cannot compile '$header'"
24172 run_test 400b "packaged headers can be compiled"
24174 test_401a() { #LU-7437
24175 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
24176 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
24178 #count the number of parameters by "list_param -R"
24179 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
24180 #count the number of parameters by listing proc files
24181 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
24182 echo "proc_dirs='$proc_dirs'"
24183 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
24184 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
24187 [ $params -eq $procs ] ||
24188 error "found $params parameters vs. $procs proc files"
24190 # test the list_param -D option only returns directories
24191 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
24192 #count the number of parameters by listing proc directories
24193 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
24196 [ $params -eq $procs ] ||
24197 error "found $params parameters vs. $procs proc files"
24199 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
24202 # jobid_var may not allow arbitrary values, so use jobid_name
24204 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24205 local testname=jobid_name tmp='testing%p'
24207 local testname=jobid_var tmp=testing
24210 local save=$($LCTL get_param -n $testname)
24212 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
24213 error "no error returned when setting bad parameters"
24215 local jobid_new=$($LCTL get_param -n foe $testname baz)
24216 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
24218 $LCTL set_param -n fog=bam $testname=$save bat=fog
24219 local jobid_old=$($LCTL get_param -n foe $testname bag)
24220 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
24222 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
24225 # jobid_var may not allow arbitrary values, so use jobid_name
24227 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24228 local testname=jobid_name
24230 local testname=jobid_var
24233 local jobid_var_old=$($LCTL get_param -n $testname)
24234 local jobid_var_new
24236 $LCTL set_param $testname= &&
24237 error "no error returned for 'set_param a='"
24239 jobid_var_new=$($LCTL get_param -n $testname)
24240 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
24241 error "$testname was changed by setting without value"
24243 $LCTL set_param $testname &&
24244 error "no error returned for 'set_param a'"
24246 jobid_var_new=$($LCTL get_param -n $testname)
24247 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
24248 error "$testname was changed by setting without value"
24250 run_test 401c "Verify 'lctl set_param' without value fails in either format."
24253 # jobid_var may not allow arbitrary values, so use jobid_name
24255 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24256 local testname=jobid_name new_value='foo=bar%p'
24258 local testname=jobid_var new_valuie=foo=bar
24261 local jobid_var_old=$($LCTL get_param -n $testname)
24262 local jobid_var_new
24264 $LCTL set_param $testname=$new_value ||
24265 error "'set_param a=b' did not accept a value containing '='"
24267 jobid_var_new=$($LCTL get_param -n $testname)
24268 [[ "$jobid_var_new" == "$new_value" ]] ||
24269 error "'set_param a=b' failed on a value containing '='"
24271 # Reset the $testname to test the other format
24272 $LCTL set_param $testname=$jobid_var_old
24273 jobid_var_new=$($LCTL get_param -n $testname)
24274 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
24275 error "failed to reset $testname"
24277 $LCTL set_param $testname $new_value ||
24278 error "'set_param a b' did not accept a value containing '='"
24280 jobid_var_new=$($LCTL get_param -n $testname)
24281 [[ "$jobid_var_new" == "$new_value" ]] ||
24282 error "'set_param a b' failed on a value containing '='"
24284 $LCTL set_param $testname $jobid_var_old
24285 jobid_var_new=$($LCTL get_param -n $testname)
24286 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
24287 error "failed to reset $testname"
24289 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
24291 test_401e() { # LU-14779
24292 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
24293 error "lctl list_param MGC* failed"
24294 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
24295 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
24296 error "lctl get_param lru_size failed"
24298 run_test 401e "verify 'lctl get_param' works with NID in parameter"
24301 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
24302 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
24303 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
24304 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
24305 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
24306 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
24307 remote_mds_nodsh && skip "remote MDS with nodsh"
24309 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
24310 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
24311 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
24312 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
24313 echo "Touch failed - OK"
24315 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
24318 local file1=$DIR/$tfile.1
24319 local file2=$DIR/$tfile.2
24320 local tfile=$TMP/$tfile
24322 rm -f $file1 $file2 $tfile
24327 # 30 sec OBD_TIMEOUT in ll_getattr()
24328 # right before populating st_nlink
24329 $LCTL set_param fail_loc=0x80001409
24330 stat -c %h $file1 > $tfile &
24332 # create an alias, drop all locks and reclaim the dentry
24334 cancel_lru_locks mdc
24335 cancel_lru_locks osc
24336 sysctl -w vm.drop_caches=2
24340 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
24342 rm -f $tfile $file1 $file2
24344 run_test 403 "i_nlink should not drop to zero due to aliasing"
24346 test_404() { # LU-6601
24347 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
24348 skip "Need server version newer than 2.8.52"
24349 remote_mds_nodsh && skip "remote MDS with nodsh"
24351 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
24352 awk '/osp .*-osc-MDT/ { print $4}')
24355 for osp in $mosps; do
24356 echo "Deactivate: " $osp
24357 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
24358 local stat=$(do_facet $SINGLEMDS $LCTL dl |
24359 awk -vp=$osp '$4 == p { print $2 }')
24360 [ $stat = IN ] || {
24361 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
24362 error "deactivate error"
24364 echo "Activate: " $osp
24365 do_facet $SINGLEMDS $LCTL --device %$osp activate
24366 local stat=$(do_facet $SINGLEMDS $LCTL dl |
24367 awk -vp=$osp '$4 == p { print $2 }')
24368 [ $stat = UP ] || {
24369 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
24370 error "activate error"
24374 run_test 404 "validate manual {de}activated works properly for OSPs"
24377 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
24378 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
24379 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
24380 skip "Layout swap lock is not supported"
24382 check_swap_layouts_support
24383 check_swap_layout_no_dom $DIR
24385 test_mkdir $DIR/$tdir
24386 swap_lock_test -d $DIR/$tdir ||
24387 error "One layout swap locked test failed"
24389 run_test 405 "Various layout swap lock tests"
24392 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24393 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
24394 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
24395 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24396 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
24397 skip "Need MDS version at least 2.8.50"
24399 local def_stripe_size=$($LFS getstripe -S $MOUNT)
24400 local test_pool=$TESTNAME
24402 pool_add $test_pool || error "pool_add failed"
24403 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
24404 error "pool_add_targets failed"
24406 save_layout_restore_at_exit $MOUNT
24408 # parent set default stripe count only, child will stripe from both
24409 # parent and fs default
24410 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
24411 error "setstripe $MOUNT failed"
24412 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
24413 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
24414 for i in $(seq 10); do
24415 local f=$DIR/$tdir/$tfile.$i
24416 touch $f || error "touch failed"
24417 local count=$($LFS getstripe -c $f)
24418 [ $count -eq $OSTCOUNT ] ||
24419 error "$f stripe count $count != $OSTCOUNT"
24420 local offset=$($LFS getstripe -i $f)
24421 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
24422 local size=$($LFS getstripe -S $f)
24423 [ $size -eq $((def_stripe_size * 2)) ] ||
24424 error "$f stripe size $size != $((def_stripe_size * 2))"
24425 local pool=$($LFS getstripe -p $f)
24426 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
24429 # change fs default striping, delete parent default striping, now child
24430 # will stripe from new fs default striping only
24431 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
24432 error "change $MOUNT default stripe failed"
24433 $LFS setstripe -c 0 $DIR/$tdir ||
24434 error "delete $tdir default stripe failed"
24435 for i in $(seq 11 20); do
24436 local f=$DIR/$tdir/$tfile.$i
24437 touch $f || error "touch $f failed"
24438 local count=$($LFS getstripe -c $f)
24439 [ $count -eq 1 ] || error "$f stripe count $count != 1"
24440 local offset=$($LFS getstripe -i $f)
24441 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
24442 local size=$($LFS getstripe -S $f)
24443 [ $size -eq $def_stripe_size ] ||
24444 error "$f stripe size $size != $def_stripe_size"
24445 local pool=$($LFS getstripe -p $f)
24446 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
24449 unlinkmany $DIR/$tdir/$tfile. 1 20
24451 local f=$DIR/$tdir/$tfile
24452 pool_remove_all_targets $test_pool $f
24453 pool_remove $test_pool $f
24455 run_test 406 "DNE support fs default striping"
24458 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24459 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
24460 skip "Need MDS version at least 2.8.55"
24461 remote_mds_nodsh && skip "remote MDS with nodsh"
24463 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
24464 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
24465 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
24466 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
24467 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
24469 #define OBD_FAIL_DT_TXN_STOP 0x2019
24470 for idx in $(seq $MDSCOUNT); do
24471 do_facet mds$idx "lctl set_param fail_loc=0x2019"
24473 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
24474 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
24475 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
24478 run_test 407 "transaction fail should cause operation fail"
24481 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
24483 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
24484 lctl set_param fail_loc=0x8000040a
24485 # let ll_prepare_partial_page() fail
24486 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
24490 # create at least 100 unused inodes so that
24491 # shrink_icache_memory(0) should not return 0
24492 touch $DIR/$tfile-{0..100}
24493 rm -f $DIR/$tfile-{0..100}
24496 echo 2 > /proc/sys/vm/drop_caches
24498 run_test 408 "drop_caches should not hang due to page leaks"
24502 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
24504 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
24505 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
24506 touch $DIR/$tdir/guard || error "(2) Fail to create"
24508 local PREFIX=$(str_repeat 'A' 128)
24509 echo "Create 1K hard links start at $(date)"
24510 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
24511 error "(3) Fail to hard link"
24513 echo "Links count should be right although linkEA overflow"
24514 stat $DIR/$tdir/guard || error "(4) Fail to stat"
24515 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
24516 [ $linkcount -eq 1001 ] ||
24517 error "(5) Unexpected hard links count: $linkcount"
24519 echo "List all links start at $(date)"
24520 ls -l $DIR/$tdir/foo > /dev/null ||
24521 error "(6) Fail to list $DIR/$tdir/foo"
24523 echo "Unlink hard links start at $(date)"
24524 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
24525 error "(7) Fail to unlink"
24526 echo "Unlink hard links finished at $(date)"
24528 run_test 409 "Large amount of cross-MDTs hard links on the same file"
24532 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
24533 skip "Need client version at least 2.9.59"
24534 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
24535 skip "Need MODULES build"
24537 # Create a file, and stat it from the kernel
24538 local testfile=$DIR/$tfile
24541 local run_id=$RANDOM
24542 local my_ino=$(stat --format "%i" $testfile)
24544 # Try to insert the module. This will always fail as the
24545 # module is designed to not be inserted.
24546 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
24549 # Anything but success is a test failure
24551 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
24552 error "no inode match"
24554 run_test 410 "Test inode number returned from kernel thread"
24556 cleanup_test411_cgroup() {
24562 local cg_basedir=/sys/fs/cgroup/memory
24564 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
24565 skip "no setup for cgroup"
24567 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
24568 error "test file creation failed"
24569 cancel_lru_locks osc
24571 # Create a very small memory cgroup to force a slab allocation error
24572 local cgdir=$cg_basedir/osc_slab_alloc
24573 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
24574 trap "cleanup_test411_cgroup $cgdir" EXIT
24575 echo 2M > $cgdir/memory.kmem.limit_in_bytes
24576 echo 1M > $cgdir/memory.limit_in_bytes
24578 # Should not LBUG, just be killed by oom-killer
24579 # dd will return 0 even allocation failure in some environment.
24580 # So don't check return value
24581 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
24582 cleanup_test411_cgroup $cgdir
24586 run_test 411 "Slab allocation error with cgroup does not LBUG"
24589 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24590 if [ $MDS1_VERSION -lt $(version_code 2.10.55) ]; then
24591 skip "Need server version at least 2.10.55"
24594 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
24595 error "mkdir failed"
24596 $LFS getdirstripe $DIR/$tdir
24597 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
24598 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
24599 error "expect $((MDSCOUT - 1)) get $stripe_index"
24600 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
24601 [ $stripe_count -eq 2 ] ||
24602 error "expect 2 get $stripe_count"
24604 run_test 412 "mkdir on specific MDTs"
24606 generate_uneven_mdts() {
24618 echo "Check for uneven MDTs: "
24620 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
24621 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
24622 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
24624 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
24625 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
24628 for ((i = 1; i < ${#ffree[@]}; i++)); do
24629 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
24630 if [ $tmp -gt $max ]; then
24634 if [ $tmp -lt $min ]; then
24640 # Check if we need to generate uneven MDTs
24641 local diff=$(((max - min) * 100 / min))
24642 local testdir=$DIR/$tdir-fillmdt
24647 while (( diff < threshold )); do
24648 # generate uneven MDTs, create till $threshold% diff
24649 echo -n "weight diff=$diff% must be > $threshold% ..."
24650 echo "Fill MDT$min_index with 100 files: loop $i"
24651 testdir=$DIR/$tdir-fillmdt/$i
24652 [ -d $testdir ] || $LFS mkdir -i $min_index $testdir ||
24653 error "mkdir $testdir failed"
24654 $LFS setstripe -E 1M -L mdt $testdir ||
24655 error "setstripe $testdir failed"
24656 for F in f.{0..99}; do
24657 dd if=/dev/zero of=$testdir/$F bs=1M count=1 > \
24658 /dev/null 2>&1 || error "dd $F failed"
24661 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
24662 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
24663 max=$(((${ffree[max_index]} >> 8) * \
24664 (${bavail[max_index]} * bsize >> 16)))
24665 min=$(((${ffree[min_index]} >> 8) * \
24666 (${bavail[min_index]} * bsize >> 16)))
24667 diff=$(((max - min) * 100 / min))
24671 echo "MDT filesfree available: ${ffree[@]}"
24672 echo "MDT blocks available: ${bavail[@]}"
24673 echo "weight diff=$diff%"
24678 local stripe_count=$2
24679 local mdts=$(comma_list $(mdts_nodes))
24682 local lmv_qos_prio_free
24683 local lmv_qos_threshold_rr
24684 local lmv_qos_maxage
24685 local lod_qos_prio_free
24686 local lod_qos_threshold_rr
24687 local lod_qos_maxage
24691 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
24692 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
24693 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
24695 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
24696 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
24697 stack_trap "$LCTL set_param \
24698 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
24699 stack_trap "$LCTL set_param \
24700 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
24701 stack_trap "$LCTL set_param \
24702 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
24704 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
24705 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
24706 lod_qos_prio_free=${lod_qos_prio_free%%%}
24707 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
24708 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
24709 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
24710 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
24711 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
24712 stack_trap "do_nodes $mdts $LCTL set_param \
24713 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
24714 stack_trap "do_nodes $mdts $LCTL set_param \
24715 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
24716 stack_trap "do_nodes $mdts $LCTL set_param \
24717 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
24719 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
24720 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
24722 testdir=$DIR/$tdir-s$stripe_count/rr
24724 local stripe_index=$($LFS getstripe -m $testdir)
24725 local test_mkdir_rr=true
24727 echo "dirstripe: '$($LFS getdirstripe $testdir)'"
24728 getfattr -d -m dmv -e hex $testdir | grep dmv
24729 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
24730 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
24731 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
24732 test_mkdir_rr=false
24737 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
24738 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
24740 stack_trap "unlinkmany -d $testdir/subdir $((100 * MDSCOUNT))"
24741 for (( i = 0; i < 100 * MDSCOUNT; i++ )); do
24742 eval $mkdir_cmd $testdir/subdir$i ||
24743 error "$mkdir_cmd subdir$i failed"
24746 for (( i = 0; i < $MDSCOUNT; i++ )); do
24747 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
24748 echo "$count directories created on MDT$i"
24749 if $test_mkdir_rr; then
24750 (( $count == 100 )) ||
24751 error "subdirs are not evenly distributed"
24752 elif (( $i == $stripe_index )); then
24753 (( $count == 100 * MDSCOUNT )) ||
24754 error "$count subdirs created on MDT$i"
24756 (( $count == 0 )) ||
24757 error "$count subdirs created on MDT$i"
24760 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
24761 count=$($LFS getdirstripe $testdir/* |
24762 grep -c -P "^\s+$i\t")
24763 echo "$count stripes created on MDT$i"
24764 # deviation should < 5% of average
24765 (( $count >= 95 * stripe_count &&
24766 $count <= 105 * stripe_count)) ||
24767 error "stripes are not evenly distributed"
24772 echo "Check for uneven MDTs: "
24782 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
24783 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
24784 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
24786 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
24787 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
24790 for ((i = 1; i < ${#ffree[@]}; i++)); do
24791 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
24792 if [ $tmp -gt $max ]; then
24796 if [ $tmp -lt $min ]; then
24802 (( ${ffree[min_index]} > 0 )) ||
24803 skip "no free files in MDT$min_index"
24804 (( ${ffree[min_index]} < 100000000 )) ||
24805 skip "too many free files in MDT$min_index"
24807 echo "MDT filesfree available: ${ffree[@]}"
24808 echo "MDT blocks available: ${bavail[@]}"
24809 echo "weight diff=$(((max - min) * 100 / min))%"
24811 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
24813 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
24814 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
24815 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
24816 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
24817 # decrease statfs age, so that it can be updated in time
24818 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
24819 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
24823 testdir=$DIR/$tdir-s$stripe_count/qos
24826 stack_trap "unlinkmany -d $testdir/subdir $((num * MDSCOUNT))"
24827 for (( i = 0; i < num * MDSCOUNT; i++ )); do
24828 eval $mkdir_cmd $testdir/subdir$i ||
24829 error "$mkdir_cmd subdir$i failed"
24832 for (( i = 0; i < $MDSCOUNT; i++ )); do
24833 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
24834 echo "$count directories created on MDT$i"
24836 if [ $stripe_count -gt 1 ]; then
24837 count=$($LFS getdirstripe $testdir/* |
24838 grep -c -P "^\s+$i\t")
24839 echo "$count stripes created on MDT$i"
24843 max=$($LFS getdirstripe -i $testdir/* | grep -c "^$max_index$")
24844 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
24846 # D-value should > 10% of averge
24847 (( max - min >= num / 10 )) ||
24848 error "subdirs shouldn't be evenly distributed: $max - $min < $((num / 10))"
24851 if (( stripe_count > 1 )); then
24852 max=$($LFS getdirstripe $testdir/* |
24853 grep -c -P "^\s+$max_index\t")
24854 min=$($LFS getdirstripe $testdir/* |
24855 grep -c -P "^\s+$min_index\t")
24856 (( max - min >= num * stripe_count / 20 )) ||
24857 error "stripes shouldn't be evenly distributed: $max - $min < $((num / 20)) * $stripe_count"
24869 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
24870 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
24871 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
24873 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
24875 for ((i = 1; i < ${#ffree[@]}; i++)); do
24876 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
24877 (( tmp < min )) && min=$tmp && min_index=$i
24884 [ $MDSCOUNT -lt 2 ] &&
24885 skip "We need at least 2 MDTs for this test"
24887 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
24888 skip "Need server version at least 2.12.52"
24892 generate_uneven_mdts 100
24893 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
24894 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
24895 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
24896 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
24897 error "mkdir failed"
24898 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
24901 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
24904 [ $MDSCOUNT -lt 2 ] &&
24905 skip "We need at least 2 MDTs for this test"
24907 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
24908 skip "Need server version at least 2.12.52"
24913 generate_uneven_mdts 100
24914 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
24915 testdir=$DIR/$tdir-s$stripe_count
24916 mkdir $testdir || error "mkdir $testdir failed"
24917 mkdir $testdir/rr || error "mkdir rr failed"
24918 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
24919 error "mkdir qos failed"
24920 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
24921 $testdir/rr || error "setdirstripe rr failed"
24922 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
24923 error "setdirstripe failed"
24924 test_qos_mkdir "mkdir" $stripe_count
24927 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
24930 (( $MDSCOUNT >= 2 )) ||
24931 skip "We need at least 2 MDTs for this test"
24933 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
24934 skip "Need server version at least 2.14.51"
24940 testdir=$DIR/${tdir}-s1
24941 mkdir $testdir || error "mkdir $testdir failed"
24942 mkdir $testdir/rr || error "mkdir rr failed"
24943 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
24944 # default max_inherit is -1, default max_inherit_rr is 0
24945 $LFS setdirstripe -D -c 1 $testdir/rr ||
24946 error "setdirstripe rr failed"
24947 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
24948 error "setdirstripe qos failed"
24949 test_qos_mkdir "mkdir" 1
24951 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
24952 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
24953 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
24954 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
24955 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
24957 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
24958 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
24959 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
24960 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
24961 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
24962 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
24963 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
24964 error "level2 shouldn't have default LMV" || true
24966 run_test 413c "mkdir with default LMV max inherit rr"
24969 (( MDSCOUNT >= 2 )) ||
24970 skip "We need at least 2 MDTs for this test"
24972 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
24973 skip "Need server version at least 2.14.51"
24975 local lmv_qos_threshold_rr
24977 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
24979 stack_trap "$LCTL set_param \
24980 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
24982 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
24983 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
24984 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
24985 error "$tdir shouldn't have default LMV"
24986 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
24987 error "mkdir sub failed"
24989 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
24991 (( count == 100 )) || error "$count subdirs on MDT0"
24993 run_test 413d "inherit ROOT default LMV"
25000 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
25001 unlinkmany $subdir/f. 100 &
25005 for pid in $pids; do
25009 run_test 413z "413 test cleanup"
25012 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
25013 $LCTL set_param fail_loc=0x80000521
25014 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
25017 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
25020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25021 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
25022 skip "Need server version at least 2.11.52"
25032 # this test may be slow on ZFS
25033 [ "$mds1_FSTYPE" == "zfs" ] && total=100
25035 # though this test is designed for striped directory, let's test normal
25036 # directory too since lock is always saved as CoS lock.
25037 test_mkdir $DIR/$tdir || error "mkdir $tdir"
25038 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
25047 start_time=$(date +%s)
25048 for i in $(seq $total); do
25049 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
25052 end_time=$(date +%s)
25053 duration=$((end_time - start_time))
25055 kill -9 $setattr_pid
25057 echo "rename $total files took $duration sec"
25058 [ $duration -lt 100 ] || error "rename took $duration sec"
25060 run_test 415 "lock revoke is not missing"
25063 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
25064 skip "Need server version at least 2.11.55"
25066 # define OBD_FAIL_OSD_TXN_START 0x19a
25067 do_facet mds1 lctl set_param fail_loc=0x19a
25069 lfs mkdir -c $MDSCOUNT $DIR/$tdir
25073 run_test 416 "transaction start failure won't cause system hung"
25077 do_nodes $(comma_list $(mdts_nodes)) \
25078 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
25079 do_nodes $(comma_list $(mdts_nodes)) \
25080 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
25081 do_nodes $(comma_list $(mdts_nodes)) \
25082 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
25086 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25087 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
25088 skip "Need MDS version at least 2.11.56"
25090 trap cleanup_417 RETURN EXIT
25092 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
25093 do_nodes $(comma_list $(mdts_nodes)) \
25094 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
25095 $LFS migrate -m 0 $DIR/$tdir.1 &&
25096 error "migrate dir $tdir.1 should fail"
25098 do_nodes $(comma_list $(mdts_nodes)) \
25099 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
25100 $LFS mkdir -i 1 $DIR/$tdir.2 &&
25101 error "create remote dir $tdir.2 should fail"
25103 do_nodes $(comma_list $(mdts_nodes)) \
25104 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
25105 $LFS mkdir -c 2 $DIR/$tdir.3 &&
25106 error "create striped dir $tdir.3 should fail"
25109 run_test 417 "disable remote dir, striped dir and dir migration"
25111 # Checks that the outputs of df [-i] and lfs df [-i] match
25113 # usage: check_lfs_df <blocks | inodes> <mountpoint>
25123 [ "$1" == "blocks" ] && inodes= || inodes="-i"
25125 for count in {1..100}; do
25129 # read the lines of interest
25130 df_out=($(df -P $inodes $dir | tail -n +2)) ||
25131 error "df $inodes $dir | tail -n +2 failed"
25132 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
25133 error "lfs df $inodes $dir | grep summary: failed"
25135 # skip first substrings of each output as they are different
25136 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
25137 # compare the two outputs
25139 for i in {1..5}; do
25140 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
25148 lfs df $inodes $dir
25149 error "df and lfs df $1 output mismatch: " \
25150 "df ${inodes}: ${df_out[*]}, " \
25151 "lfs df ${inodes}: ${lfs_df_out[*]}"
25156 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25158 local dir=$DIR/$tdir
25159 local numfiles=$((RANDOM % 4096 + 2))
25160 local numblocks=$((RANDOM % 256 + 1))
25162 wait_delete_completed
25165 # check block output
25166 check_lfs_df blocks $dir
25167 # check inode output
25168 check_lfs_df inodes $dir
25170 # create a single file and retest
25171 echo "Creating a single file and testing"
25172 createmany -o $dir/$tfile- 1 &>/dev/null ||
25173 error "creating 1 file in $dir failed"
25174 check_lfs_df blocks $dir
25175 check_lfs_df inodes $dir
25177 # create a random number of files
25178 echo "Creating $((numfiles - 1)) files and testing"
25179 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
25180 error "creating $((numfiles - 1)) files in $dir failed"
25182 # write a random number of blocks to the first test file
25183 echo "Writing $numblocks 4K blocks and testing"
25184 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
25185 count=$numblocks &>/dev/null ||
25186 error "dd to $dir/${tfile}-0 failed"
25189 check_lfs_df blocks $dir
25190 check_lfs_df inodes $dir
25192 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
25193 error "unlinking $numfiles files in $dir failed"
25195 run_test 418 "df and lfs df outputs match"
25199 local dir=$DIR/$tdir
25204 cancel_lru_locks mdc
25206 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
25207 $LCTL set_param fail_loc=0x1410
25209 $LCTL set_param fail_loc=0
25212 run_test 419 "Verify open file by name doesn't crash kernel"
25216 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
25217 skip "Need MDS version at least 2.12.53"
25219 local SAVE_UMASK=$(umask)
25220 local dir=$DIR/$tdir
25221 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
25225 mkdir -m03777 $dir/testdir
25226 ls -dn $dir/testdir
25227 # Need to remove trailing '.' when SELinux is enabled
25228 local dirperms=$(ls -dn $dir/testdir |
25229 awk '{ sub(/\.$/, "", $1); print $1}')
25230 [ $dirperms == "drwxrwsrwt" ] ||
25231 error "incorrect perms on $dir/testdir"
25233 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
25234 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
25235 ls -n $dir/testdir/testfile
25236 local fileperms=$(ls -n $dir/testdir/testfile |
25237 awk '{ sub(/\.$/, "", $1); print $1}')
25238 [ $fileperms == "-rwxr-xr-x" ] ||
25239 error "incorrect perms on $dir/testdir/testfile"
25243 run_test 420 "clear SGID bit on non-directories for non-members"
25250 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25251 skip "Need MDS version at least 2.12.54"
25253 test_mkdir $DIR/$tdir
25254 createmany -o $DIR/$tdir/f 3
25255 cnt=$(ls -1 $DIR/$tdir | wc -l)
25256 [ $cnt != 3 ] && error "unexpected #files: $cnt"
25258 fid1=$(lfs path2fid $DIR/$tdir/f1)
25259 fid2=$(lfs path2fid $DIR/$tdir/f2)
25260 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
25262 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
25263 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
25265 cnt=$(ls -1 $DIR/$tdir | wc -l)
25266 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
25268 rm -f $DIR/$tdir/f3 || error "can't remove f3"
25269 createmany -o $DIR/$tdir/f 3
25270 cnt=$(ls -1 $DIR/$tdir | wc -l)
25271 [ $cnt != 3 ] && error "unexpected #files: $cnt"
25273 fid1=$(lfs path2fid $DIR/$tdir/f1)
25274 fid2=$(lfs path2fid $DIR/$tdir/f2)
25275 echo "remove using fsname $FSNAME"
25276 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
25278 cnt=$(ls -1 $DIR/$tdir | wc -l)
25279 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
25281 run_test 421a "simple rm by fid"
25288 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25289 skip "Need MDS version at least 2.12.54"
25291 test_mkdir $DIR/$tdir
25292 createmany -o $DIR/$tdir/f 3
25293 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
25296 FID1=$(lfs path2fid $DIR/$tdir/f1)
25297 FID2=$(lfs path2fid $DIR/$tdir/f2)
25298 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
25300 kill -USR1 $MULTIPID
25303 cnt=$(ls $DIR/$tdir | wc -l)
25304 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
25306 run_test 421b "rm by fid on open file"
25312 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25313 skip "Need MDS version at least 2.12.54"
25315 test_mkdir $DIR/$tdir
25316 createmany -o $DIR/$tdir/f 3
25317 touch $DIR/$tdir/$tfile
25318 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
25319 cnt=$(ls -1 $DIR/$tdir | wc -l)
25320 [ $cnt != 184 ] && error "unexpected #files: $cnt"
25322 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
25323 $LFS rmfid $DIR $FID1 || error "rmfid failed"
25325 cnt=$(ls $DIR/$tdir | wc -l)
25326 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
25328 run_test 421c "rm by fid against hardlinked files"
25334 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25335 skip "Need MDS version at least 2.12.54"
25337 test_mkdir $DIR/$tdir
25338 createmany -o $DIR/$tdir/f 4097
25339 cnt=$(ls -1 $DIR/$tdir | wc -l)
25340 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
25342 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
25343 $LFS rmfid $DIR $FIDS || error "rmfid failed"
25345 cnt=$(ls $DIR/$tdir | wc -l)
25347 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
25349 run_test 421d "rmfid en masse"
25355 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25356 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25357 skip "Need MDS version at least 2.12.54"
25359 mkdir -p $DIR/$tdir
25360 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
25361 createmany -o $DIR/$tdir/striped_dir/f 512
25362 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
25363 [ $cnt != 512 ] && error "unexpected #files: $cnt"
25365 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
25366 sed "s/[/][^:]*://g")
25367 $LFS rmfid $DIR $FIDS || error "rmfid failed"
25369 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
25371 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
25373 run_test 421e "rmfid in DNE"
25379 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25380 skip "Need MDS version at least 2.12.54"
25382 test_mkdir $DIR/$tdir
25384 cnt=$(ls -1 $DIR/$tdir | wc -l)
25385 [ $cnt != 1 ] && error "unexpected #files: $cnt"
25387 FID=$(lfs path2fid $DIR/$tdir/f)
25388 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
25389 # rmfid should fail
25390 cnt=$(ls -1 $DIR/$tdir | wc -l)
25391 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
25393 chmod a+rw $DIR/$tdir
25395 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
25396 # rmfid should fail
25397 cnt=$(ls -1 $DIR/$tdir | wc -l)
25398 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
25401 $RUNAS touch $DIR/$tdir/f
25402 FID=$(lfs path2fid $DIR/$tdir/f)
25403 echo "rmfid as root"
25404 $LFS rmfid $DIR $FID || error "rmfid as root failed"
25405 cnt=$(ls -1 $DIR/$tdir | wc -l)
25406 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
25409 $RUNAS touch $DIR/$tdir/f
25410 cnt=$(ls -1 $DIR/$tdir | wc -l)
25411 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
25412 FID=$(lfs path2fid $DIR/$tdir/f)
25413 # rmfid w/o user_fid2path mount option should fail
25414 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
25415 cnt=$(ls -1 $DIR/$tdir | wc -l)
25416 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
25418 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
25419 stack_trap "rmdir $tmpdir"
25420 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
25421 error "failed to mount client'"
25422 stack_trap "umount_client $tmpdir"
25424 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
25425 # rmfid should succeed
25426 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
25427 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
25429 # rmfid shouldn't allow to remove files due to dir's permission
25430 chmod a+rwx $tmpdir/$tdir
25431 touch $tmpdir/$tdir/f
25432 ls -la $tmpdir/$tdir
25433 FID=$(lfs path2fid $tmpdir/$tdir/f)
25434 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
25437 run_test 421f "rmfid checks permissions"
25443 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25444 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25445 skip "Need MDS version at least 2.12.54"
25447 mkdir -p $DIR/$tdir
25448 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
25449 createmany -o $DIR/$tdir/striped_dir/f 512
25450 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
25451 [ $cnt != 512 ] && error "unexpected #files: $cnt"
25453 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
25454 sed "s/[/][^:]*://g")
25456 rm -f $DIR/$tdir/striped_dir/f1*
25457 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
25458 removed=$((512 - cnt))
25460 # few files have been just removed, so we expect
25461 # rmfid to fail on their fids
25462 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
25463 [ $removed != $errors ] && error "$errors != $removed"
25465 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
25467 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
25469 run_test 421g "rmfid to return errors properly"
25472 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
25473 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
25474 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
25475 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
25476 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
25478 local amc=$(at_max_get client)
25479 local amo=$(at_max_get mds1)
25480 local timeout=`lctl get_param -n timeout`
25482 at_max_set 0 client
25485 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
25486 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
25487 fail_val=$(((2*timeout + 10)*1000))
25488 touch $DIR/$tdir/d3/file &
25490 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
25491 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
25492 fail_val=$((2*timeout + 5))
25493 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
25497 sleep $((2 * timeout))
25501 touch $DIR/$tdir/d2/file3
25502 touch $DIR/$tdir/d2/file4
25503 touch $DIR/$tdir/d2/file5
25506 at_max_set $amc client
25507 at_max_set $amo mds1
25509 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
25510 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
25511 error "Watchdog is always throttled"
25513 run_test 422 "kill a process with RPC in progress"
25526 # ensure statfs cache is expired
25529 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
25530 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
25534 run_test 423 "statfs should return a right data"
25537 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
25538 $LCTL set_param fail_loc=0x80000522
25539 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
25542 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
25545 test_mkdir -c -1 $DIR/$tdir
25546 $LFS setstripe -c -1 $DIR/$tdir
25548 lru_resize_disable "" 100
25549 stack_trap "lru_resize_enable" EXIT
25553 for i in $(seq $((MDSCOUNT * 125))); do
25554 local t=$DIR/$tdir/$tfile_$i
25556 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
25557 error_noexit "Create file $t"
25559 stack_trap "rm -rf $DIR/$tdir" EXIT
25561 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
25562 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
25563 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
25565 [ $lock_count -le $lru_size ] ||
25566 error "osc lock count $lock_count > lru size $lru_size"
25569 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
25570 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
25571 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
25573 [ $lock_count -le $lru_size ] ||
25574 error "mdc lock count $lock_count > lru size $lru_size"
25577 run_test 425 "lock count should not exceed lru size"
25580 splice-test -r $DIR/$tfile
25581 splice-test -rd $DIR/$tfile
25582 splice-test $DIR/$tfile
25583 splice-test -d $DIR/$tfile
25585 run_test 426 "splice test on Lustre"
25588 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
25589 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
25590 skip "Need MDS version at least 2.12.4"
25596 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
25597 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
25599 $LFS getdirstripe $DIR/$tdir/1/dir
25601 #first setfattr for creating updatelog
25602 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
25604 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
25605 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
25606 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
25607 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
25611 wait_recovery_complete mds2 $((2*TIMEOUT))
25613 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
25614 echo $log | grep "get update log failed" &&
25615 error "update log corruption is detected" || true
25617 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
25620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25621 local cache_limit=$CACHE_MAX
25623 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$cache_limit"
25624 $LCTL set_param -n llite.*.max_cached_mb=64
25627 $LFS setstripe -c 1 $DIR/$tdir
25628 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
25629 stack_trap "rm -f $DIR/$tdir/$tfile.*"
25631 for f in $(seq 4); do
25632 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
25636 cancel_lru_locks osc
25638 for f in $(seq 4); do
25639 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
25643 run_test 428 "large block size IO should not hang"
25645 test_429() { # LU-7915 / LU-10948
25646 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
25647 local testfile=$DIR/$tfile
25648 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
25654 $LCTL get_param $ll_opencache_threshold_count ||
25655 skip "client does not have opencache parameter"
25657 set_opencache $new_flag
25658 stack_trap "restore_opencache"
25659 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
25660 error "enable opencache failed"
25662 # drop MDC DLM locks
25663 cancel_lru_locks mdc
25664 # clear MDC RPC stats counters
25665 $LCTL set_param $mdc_rpcstats=clear
25667 # According to the current implementation, we need to run 3 times
25668 # open & close file to verify if opencache is enabled correctly.
25669 # 1st, RPCs are sent for lookup/open and open handle is released on
25671 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
25672 # so open handle won't be released thereafter.
25673 # 3rd, No RPC is sent out.
25674 $MULTIOP $testfile oc || error "multiop failed"
25675 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
25676 echo "1st: $first_rpc RPCs in flight"
25678 $MULTIOP $testfile oc || error "multiop failed"
25679 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
25680 echo "2nd: $second_rpc RPCs in flight"
25682 $MULTIOP $testfile oc || error "multiop failed"
25683 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
25684 echo "3rd: $third_rpc RPCs in flight"
25686 #verify no MDC RPC is sent
25687 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
25689 run_test 429 "verify if opencache flag on client side does work"
25695 # data at [200K, 400K)
25696 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
25697 error "256K->512K dd fails"
25699 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
25700 error "2M->3M dd fails"
25702 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
25703 error "4M->5M dd fails"
25704 echo "Data at 256K...512K, 2M...3M and 4M...5M"
25705 # start at first component hole #1
25706 printf "Seeking hole from 1000 ... "
25707 offset=$(lseek_test -l 1000 $file)
25709 [[ $offset == 1000 ]] || error "offset $offset != 1000"
25710 printf "Seeking data from 1000 ... "
25711 offset=$(lseek_test -d 1000 $file)
25713 [[ $offset == 262144 ]] || error "offset $offset != 262144"
25715 # start at first component data block
25716 printf "Seeking hole from 300000 ... "
25717 offset=$(lseek_test -l 300000 $file)
25719 [[ $offset == 524288 ]] || error "offset $offset != 524288"
25720 printf "Seeking data from 300000 ... "
25721 offset=$(lseek_test -d 300000 $file)
25723 [[ $offset == 300000 ]] || error "offset $offset != 300000"
25725 # start at the first component but beyond end of object size
25726 printf "Seeking hole from 1000000 ... "
25727 offset=$(lseek_test -l 1000000 $file)
25729 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
25730 printf "Seeking data from 1000000 ... "
25731 offset=$(lseek_test -d 1000000 $file)
25733 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
25735 # start at second component stripe 2 (empty file)
25736 printf "Seeking hole from 1500000 ... "
25737 offset=$(lseek_test -l 1500000 $file)
25739 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
25740 printf "Seeking data from 1500000 ... "
25741 offset=$(lseek_test -d 1500000 $file)
25743 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
25745 # start at second component stripe 1 (all data)
25746 printf "Seeking hole from 3000000 ... "
25747 offset=$(lseek_test -l 3000000 $file)
25749 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
25750 printf "Seeking data from 3000000 ... "
25751 offset=$(lseek_test -d 3000000 $file)
25753 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
25755 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
25756 error "2nd dd fails"
25757 echo "Add data block at 640K...1280K"
25759 # start at before new data block, in hole
25760 printf "Seeking hole from 600000 ... "
25761 offset=$(lseek_test -l 600000 $file)
25763 [[ $offset == 600000 ]] || error "offset $offset != 600000"
25764 printf "Seeking data from 600000 ... "
25765 offset=$(lseek_test -d 600000 $file)
25767 [[ $offset == 655360 ]] || error "offset $offset != 655360"
25769 # start at the first component new data block
25770 printf "Seeking hole from 1000000 ... "
25771 offset=$(lseek_test -l 1000000 $file)
25773 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
25774 printf "Seeking data from 1000000 ... "
25775 offset=$(lseek_test -d 1000000 $file)
25777 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
25779 # start at second component stripe 2, new data
25780 printf "Seeking hole from 1200000 ... "
25781 offset=$(lseek_test -l 1200000 $file)
25783 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
25784 printf "Seeking data from 1200000 ... "
25785 offset=$(lseek_test -d 1200000 $file)
25787 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
25789 # start beyond file end
25790 printf "Using offset > filesize ... "
25791 lseek_test -l 4000000 $file && error "lseek should fail"
25792 printf "Using offset > filesize ... "
25793 lseek_test -d 4000000 $file && error "lseek should fail"
25799 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
25800 skip "MDT does not support SEEK_HOLE"
25802 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
25803 skip "OST does not support SEEK_HOLE"
25805 local file=$DIR/$tdir/$tfile
25807 mkdir -p $DIR/$tdir
25809 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
25810 # OST stripe #1 will have continuous data at [1M, 3M)
25811 # OST stripe #2 is empty
25812 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
25813 lseek_test_430 $file
25815 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
25816 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
25817 lseek_test_430 $file
25819 $LFS setstripe -c2 -S 512K $file
25820 echo "Two stripes, stripe size 512K"
25821 lseek_test_430 $file
25823 # FLR with stale mirror
25824 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
25826 echo "Mirrored file:"
25827 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
25828 echo "Plain 2 stripes 1M"
25829 lseek_test_430 $file
25832 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
25835 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
25836 skip "OST does not support SEEK_HOLE"
25839 local file=$DIR/$tdir/$tfile
25841 mkdir -p $DIR/$tdir
25842 # Empty layout lseek should fail
25845 printf "Seeking hole from 0 ... "
25846 lseek_test -l 0 $file && error "lseek should fail"
25847 printf "Seeking data from 0 ... "
25848 lseek_test -d 0 $file && error "lseek should fail"
25852 $LFS setstripe -E 1M -c2 -E eof $file
25853 $TRUNCATE $file 1048576
25854 printf "Seeking hole from 1000000 ... "
25855 offset=$(lseek_test -l 1000000 $file)
25857 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
25858 printf "Seeking data from 1000000 ... "
25859 lseek_test -d 1000000 $file && error "lseek should fail"
25862 # full component followed by non-inited one
25863 $LFS setstripe -E 1M -c2 -E eof $file
25864 dd if=/dev/urandom of=$file bs=1M count=1
25865 printf "Seeking hole from 1000000 ... "
25866 offset=$(lseek_test -l 1000000 $file)
25868 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
25869 printf "Seeking hole from 1048576 ... "
25870 lseek_test -l 1048576 $file && error "lseek should fail"
25871 # init second component and truncate back
25872 echo "123" >> $file
25873 $TRUNCATE $file 1048576
25874 printf "Seeking hole from 1000000 ... "
25875 offset=$(lseek_test -l 1000000 $file)
25877 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
25878 printf "Seeking hole from 1048576 ... "
25879 lseek_test -l 1048576 $file && error "lseek should fail"
25880 # boundary checks for big values
25881 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
25882 offset=$(lseek_test -d 0 $file.10g)
25883 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
25884 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
25885 offset=$(lseek_test -d 0 $file.100g)
25886 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
25889 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
25892 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
25893 skip "OST does not support SEEK_HOLE"
25895 local file=$DIR/$tdir/$tfile
25898 mkdir -p $DIR/$tdir
25899 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M
25901 # cp version 8.33+ prefers lseek over fiemap
25902 if [[ $(cp --version | head -n1 | sed "s/[^0-9]//g") -ge 833 ]]; then
25904 time cp $file /dev/null
25905 (( SECONDS - start < 5 )) ||
25906 error "cp: too long runtime $((SECONDS - start))"
25909 # tar version 1.29+ supports SEEK_HOLE/DATA
25910 if [[ $(tar --version | head -n1 | sed "s/[^0-9]//g") -ge 129 ]]; then
25912 time tar cS $file - | cat > /dev/null
25913 (( SECONDS - start < 5 )) ||
25914 error "tar: too long runtime $((SECONDS - start))"
25917 run_test 430c "lseek: external tools check"
25919 test_431() { # LU-14187
25920 local file=$DIR/$tdir/$tfile
25922 mkdir -p $DIR/$tdir
25923 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
25924 dd if=/dev/urandom of=$file bs=4k count=1
25925 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
25926 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
25927 #define OBD_FAIL_OST_RESTART_IO 0x251
25928 do_facet ost1 "$LCTL set_param fail_loc=0x251"
25929 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
25933 echo 3 > /proc/sys/vm/drop_caches
25934 diff $file $file.0 || error "data diff"
25936 run_test 431 "Restart transaction for IO"
25938 cleanup_test_432() {
25939 do_facet mgs $LCTL nodemap_activate 0
25940 wait_nm_sync active
25944 local tmpdir=$TMP/dir432
25946 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
25947 skip "Need MDS version at least 2.14.52"
25949 stack_trap cleanup_test_432 EXIT
25953 do_facet mgs $LCTL nodemap_activate 1
25954 wait_nm_sync active
25955 do_facet mgs $LCTL nodemap_modify --name default \
25956 --property admin --value 1
25957 do_facet mgs $LCTL nodemap_modify --name default \
25958 --property trusted --value 1
25959 cancel_lru_locks mdc
25960 wait_nm_sync default admin_nodemap
25961 wait_nm_sync default trusted_nodemap
25963 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
25964 grep -ci "Operation not permitted") -ne 0 ]; then
25965 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
25968 run_test 432 "mv dir from outside Lustre"
25971 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
25972 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
25973 skip "Need server version at least 2.9.55"
25975 start_full_debug_logging
25979 stop_full_debug_logging
25983 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
25984 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
25985 awk '/The barrier for/ { print $7 }')
25988 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
25993 barrier_expired() {
25996 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
25997 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
25998 awk '/will be expired/ { print $7 }')
26000 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
26009 echo "Start barrier_freeze at: $(date)"
26010 #define OBD_FAIL_BARRIER_DELAY 0x2202
26011 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
26012 # Do not reduce barrier time - See LU-11873
26013 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
26016 local b_status=$(barrier_stat)
26017 echo "Got barrier status at: $(date)"
26018 [ "$b_status" = "'freezing_p1'" ] ||
26019 error "(1) unexpected barrier status $b_status"
26021 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
26023 b_status=$(barrier_stat)
26024 [ "$b_status" = "'frozen'" ] ||
26025 error "(2) unexpected barrier status $b_status"
26027 local expired=$(barrier_expired)
26028 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
26029 sleep $((expired + 3))
26031 b_status=$(barrier_stat)
26032 [ "$b_status" = "'expired'" ] ||
26033 error "(3) unexpected barrier status $b_status"
26035 # Do not reduce barrier time - See LU-11873
26036 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
26037 error "(4) fail to freeze barrier"
26039 b_status=$(barrier_stat)
26040 [ "$b_status" = "'frozen'" ] ||
26041 error "(5) unexpected barrier status $b_status"
26043 echo "Start barrier_thaw at: $(date)"
26044 #define OBD_FAIL_BARRIER_DELAY 0x2202
26045 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
26046 do_facet mgs $LCTL barrier_thaw $FSNAME &
26049 b_status=$(barrier_stat)
26050 echo "Got barrier status at: $(date)"
26051 [ "$b_status" = "'thawing'" ] ||
26052 error "(6) unexpected barrier status $b_status"
26054 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
26056 b_status=$(barrier_stat)
26057 [ "$b_status" = "'thawed'" ] ||
26058 error "(7) unexpected barrier status $b_status"
26060 #define OBD_FAIL_BARRIER_FAILURE 0x2203
26061 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
26062 do_facet mgs $LCTL barrier_freeze $FSNAME
26064 b_status=$(barrier_stat)
26065 [ "$b_status" = "'failed'" ] ||
26066 error "(8) unexpected barrier status $b_status"
26068 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
26069 do_facet mgs $LCTL barrier_thaw $FSNAME
26073 run_test 801a "write barrier user interfaces and stat machine"
26078 mkdir $DIR/$tdir || error "(1) fail to mkdir"
26079 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
26080 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
26081 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
26082 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
26084 cancel_lru_locks mdc
26086 # 180 seconds should be long enough
26087 do_facet mgs $LCTL barrier_freeze $FSNAME 180
26089 local b_status=$(barrier_stat)
26090 [ "$b_status" = "'frozen'" ] ||
26091 error "(6) unexpected barrier status $b_status"
26093 mkdir $DIR/$tdir/d0/d10 &
26096 touch $DIR/$tdir/d1/f13 &
26099 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
26102 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
26105 rm -f $DIR/$tdir/d4/f12 &
26108 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
26110 # To guarantee taht the 'stat' is not blocked
26111 b_status=$(barrier_stat)
26112 [ "$b_status" = "'frozen'" ] ||
26113 error "(8) unexpected barrier status $b_status"
26115 # let above commands to run at background
26118 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
26119 ps -p $touch_pid || error "(10) touch should be blocked"
26120 ps -p $ln_pid || error "(11) link should be blocked"
26121 ps -p $mv_pid || error "(12) rename should be blocked"
26122 ps -p $rm_pid || error "(13) unlink should be blocked"
26124 b_status=$(barrier_stat)
26125 [ "$b_status" = "'frozen'" ] ||
26126 error "(14) unexpected barrier status $b_status"
26128 do_facet mgs $LCTL barrier_thaw $FSNAME
26129 b_status=$(barrier_stat)
26130 [ "$b_status" = "'thawed'" ] ||
26131 error "(15) unexpected barrier status $b_status"
26133 wait $mkdir_pid || error "(16) mkdir should succeed"
26134 wait $touch_pid || error "(17) touch should succeed"
26135 wait $ln_pid || error "(18) link should succeed"
26136 wait $mv_pid || error "(19) rename should succeed"
26137 wait $rm_pid || error "(20) unlink should succeed"
26141 run_test 801b "modification will be blocked by write barrier"
26144 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26148 stop mds2 || error "(1) Fail to stop mds2"
26150 do_facet mgs $LCTL barrier_freeze $FSNAME 30
26152 local b_status=$(barrier_stat)
26153 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
26154 do_facet mgs $LCTL barrier_thaw $FSNAME
26155 error "(2) unexpected barrier status $b_status"
26158 do_facet mgs $LCTL barrier_rescan $FSNAME ||
26159 error "(3) Fail to rescan barrier bitmap"
26161 # Do not reduce barrier time - See LU-11873
26162 do_facet mgs $LCTL barrier_freeze $FSNAME 20
26164 b_status=$(barrier_stat)
26165 [ "$b_status" = "'frozen'" ] ||
26166 error "(4) unexpected barrier status $b_status"
26168 do_facet mgs $LCTL barrier_thaw $FSNAME
26169 b_status=$(barrier_stat)
26170 [ "$b_status" = "'thawed'" ] ||
26171 error "(5) unexpected barrier status $b_status"
26173 local devname=$(mdsdevname 2)
26175 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
26177 do_facet mgs $LCTL barrier_rescan $FSNAME ||
26178 error "(7) Fail to rescan barrier bitmap"
26182 run_test 801c "rescan barrier bitmap"
26184 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
26185 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
26186 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
26187 saved_MOUNT_OPTS=$MOUNT_OPTS
26193 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
26194 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
26195 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
26196 MOUNT_OPTS=$saved_MOUNT_OPTS
26201 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
26202 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
26203 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
26204 skip "Need server version at least 2.9.55"
26206 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
26208 mkdir $DIR/$tdir || error "(1) fail to mkdir"
26210 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
26211 error "(2) Fail to copy"
26213 trap cleanup_802a EXIT
26215 # sync by force before remount as readonly
26216 sync; sync_all_data; sleep 3; sync_all_data
26220 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
26221 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
26222 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
26224 echo "Mount the server as read only"
26225 setupall server_only || error "(3) Fail to start servers"
26227 echo "Mount client without ro should fail"
26228 mount_client $MOUNT &&
26229 error "(4) Mount client without 'ro' should fail"
26231 echo "Mount client with ro should succeed"
26232 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
26233 mount_client $MOUNT ||
26234 error "(5) Mount client with 'ro' should succeed"
26236 echo "Modify should be refused"
26237 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
26239 echo "Read should be allowed"
26240 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
26241 error "(7) Read should succeed under ro mode"
26245 run_test 802a "simulate readonly device"
26248 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26249 remote_mds_nodsh && skip "remote MDS with nodsh"
26251 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
26252 skip "readonly option not available"
26254 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
26256 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
26257 error "(2) Fail to copy"
26259 # write back all cached data before setting MDT to readonly
26263 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
26264 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
26266 echo "Modify should be refused"
26267 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
26269 echo "Read should be allowed"
26270 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
26271 error "(7) Read should succeed under ro mode"
26274 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
26276 run_test 802b "be able to set MDTs to readonly"
26279 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26280 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
26281 skip "MDS needs to be newer than 2.10.54"
26283 mkdir_on_mdt0 $DIR/$tdir
26284 # Create some objects on all MDTs to trigger related logs objects
26285 for idx in $(seq $MDSCOUNT); do
26286 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
26287 $DIR/$tdir/dir${idx} ||
26288 error "Fail to create $DIR/$tdir/dir${idx}"
26292 wait_delete_completed # ensure old test cleanups are finished
26293 echo "before create:"
26295 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
26297 for i in {1..10}; do
26298 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
26299 error "Fail to create $DIR/$tdir/foo$i"
26303 echo "after create:"
26305 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
26307 # allow for an llog to be cleaned up during the test
26308 [ $after_used -ge $((before_used + 10 - 1)) ] ||
26309 error "before ($before_used) + 10 > after ($after_used)"
26311 for i in {1..10}; do
26312 rm -rf $DIR/$tdir/foo$i ||
26313 error "Fail to remove $DIR/$tdir/foo$i"
26316 sleep 3 # avoid MDT return cached statfs
26317 wait_delete_completed
26318 echo "after unlink:"
26320 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
26322 # allow for an llog to be created during the test
26323 [ $after_used -le $((before_used + 1)) ] ||
26324 error "after ($after_used) > before ($before_used) + 1"
26326 run_test 803a "verify agent object for remote object"
26329 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26330 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
26331 skip "MDS needs to be newer than 2.13.56"
26332 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26334 for i in $(seq 0 $((MDSCOUNT - 1))); do
26335 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
26343 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
26344 for i in $(seq 0 $((MDSCOUNT - 1))); do
26345 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
26346 awk '/getattr/ { print $2 }')
26347 before=$((before + tmp))
26349 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
26350 for i in $(seq 0 $((MDSCOUNT - 1))); do
26351 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
26352 awk '/getattr/ { print $2 }')
26353 after=$((after + tmp))
26356 [ $before -eq $after ] || error "getattr count $before != $after"
26358 run_test 803b "remote object can getattr from cache"
26361 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26362 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
26363 skip "MDS needs to be newer than 2.10.54"
26364 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
26366 mkdir -p $DIR/$tdir
26367 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
26368 error "Fail to create $DIR/$tdir/dir0"
26370 local fid=$($LFS path2fid $DIR/$tdir/dir0)
26371 local dev=$(mdsdevname 2)
26373 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26374 grep ${fid} || error "NOT found agent entry for dir0"
26376 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
26377 error "Fail to create $DIR/$tdir/dir1"
26379 touch $DIR/$tdir/dir1/foo0 ||
26380 error "Fail to create $DIR/$tdir/dir1/foo0"
26381 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
26384 for idx in $(seq $MDSCOUNT); do
26385 dev=$(mdsdevname $idx)
26386 do_facet mds${idx} \
26387 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26388 grep ${fid} && rc=$idx
26391 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
26392 error "Fail to rename foo0 to foo1"
26393 if [ $rc -eq 0 ]; then
26394 for idx in $(seq $MDSCOUNT); do
26395 dev=$(mdsdevname $idx)
26396 do_facet mds${idx} \
26397 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26398 grep ${fid} && rc=$idx
26402 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
26403 error "Fail to rename foo1 to foo2"
26404 if [ $rc -eq 0 ]; then
26405 for idx in $(seq $MDSCOUNT); do
26406 dev=$(mdsdevname $idx)
26407 do_facet mds${idx} \
26408 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26409 grep ${fid} && rc=$idx
26413 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
26415 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
26416 error "Fail to link to $DIR/$tdir/dir1/foo2"
26417 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
26418 error "Fail to rename foo2 to foo0"
26419 unlink $DIR/$tdir/dir1/foo0 ||
26420 error "Fail to unlink $DIR/$tdir/dir1/foo0"
26421 rm -rf $DIR/$tdir/dir0 ||
26422 error "Fail to rm $DIR/$tdir/dir0"
26424 for idx in $(seq $MDSCOUNT); do
26425 dev=$(mdsdevname $idx)
26429 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
26431 start mds${idx} $dev $MDS_MOUNT_OPTS ||
26432 error "mount mds$idx failed"
26433 df $MOUNT > /dev/null 2>&1
26435 # e2fsck should not return error
26437 error "e2fsck detected error on MDT${idx}: rc=$rc"
26440 run_test 804 "verify agent entry for remote entry"
26443 do_facet $SINGLEMDS zfs set quota=$old $fsset
26444 unlinkmany $DIR/$tdir/f- 1000000
26449 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
26450 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
26451 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
26452 skip "netfree not implemented before 0.7"
26453 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
26454 skip "Need MDS version at least 2.10.57"
26461 local pref="osd-zfs.$FSNAME-MDT0000."
26463 # limit available space on MDS dataset to meet nospace issue
26464 # quickly. then ZFS 0.7.2 can use reserved space if asked
26465 # properly (using netfree flag in osd_declare_destroy()
26466 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
26467 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
26469 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
26470 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
26471 let "usedkb=usedkb-freekb"
26472 let "freekb=freekb/2"
26473 if let "freekb > 5000"; then
26476 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
26477 trap cleanup_805 EXIT
26478 mkdir_on_mdt0 $DIR/$tdir
26479 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
26480 error "Can't set PFL layout"
26481 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
26482 rm -rf $DIR/$tdir || error "not able to remove"
26483 do_facet $SINGLEMDS zfs set quota=$old $fsset
26486 run_test 805 "ZFS can remove from full fs"
26492 local expect=$(stat -c %s $file)
26494 check_lsom_size $1 $expect
26496 local blocks=$($LFS getsom -b $file)
26497 expect=$(stat -c %b $file)
26498 [[ $blocks == $expect ]] ||
26499 error "$file expected blocks: $expect, got: $blocks"
26507 cancel_lru_locks mdc
26509 size=$($LFS getsom -s $1)
26510 [[ $size == $expect ]] ||
26511 error "$file expected size: $expect, got: $size"
26515 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
26516 skip "Need MDS version at least 2.11.52"
26520 touch $DIR/$tfile || error "touch $tfile failed"
26522 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
26523 save_lustre_params client "llite.*.xattr_cache" > $save
26524 lctl set_param llite.*.xattr_cache=0
26525 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
26527 # single-threaded write
26528 echo "Test SOM for single-threaded write"
26529 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
26530 error "write $tfile failed"
26531 check_lsom_size $DIR/$tfile $bs
26534 local size=$(($num * $bs))
26538 echo "Test SOM for single client multi-threaded($num) write"
26539 $TRUNCATE $DIR/$tfile 0
26540 for ((i = 0; i < $num; i++)); do
26541 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
26543 offset=$((offset + $bs))
26545 for (( i=0; i < $num; i++ )); do
26548 check_lsom_size $DIR/$tfile $size
26550 $TRUNCATE $DIR/$tfile 0
26551 for ((i = 0; i < $num; i++)); do
26552 offset=$((offset - $bs))
26553 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
26556 for (( i=0; i < $num; i++ )); do
26559 check_lsom_size $DIR/$tfile $size
26561 # multi-client writes
26562 num=$(get_node_count ${CLIENTS//,/ })
26563 size=$(($num * $bs))
26567 echo "Test SOM for multi-client ($num) writes"
26568 $TRUNCATE $DIR/$tfile 0
26569 for client in ${CLIENTS//,/ }; do
26570 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
26573 offset=$((offset + $bs))
26575 for (( i=0; i < $num; i++ )); do
26578 check_lsom_size $DIR/$tfile $offset
26581 $TRUNCATE $DIR/$tfile 0
26582 for client in ${CLIENTS//,/ }; do
26583 offset=$((offset - $bs))
26584 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
26588 for (( i=0; i < $num; i++ )); do
26591 check_lsom_size $DIR/$tfile $size
26594 echo "Test SOM for truncate"
26595 $TRUNCATE $DIR/$tfile 1048576
26596 check_lsom_size $DIR/$tfile 1048576
26597 $TRUNCATE $DIR/$tfile 1234
26598 check_lsom_size $DIR/$tfile 1234
26600 # verify SOM blocks count
26601 echo "Verify SOM block count"
26602 $TRUNCATE $DIR/$tfile 0
26603 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
26604 error "failed to write file $tfile"
26605 check_lsom_data $DIR/$tfile
26607 run_test 806 "Verify Lazy Size on MDS"
26610 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
26611 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
26612 skip "Need MDS version at least 2.11.52"
26614 # Registration step
26615 changelog_register || error "changelog_register failed"
26616 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
26617 changelog_users $SINGLEMDS | grep -q $cl_user ||
26618 error "User $cl_user not found in changelog_users"
26620 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
26621 save_lustre_params client "llite.*.xattr_cache" > $save
26622 lctl set_param llite.*.xattr_cache=0
26623 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
26625 rm -rf $DIR/$tdir || error "rm $tdir failed"
26626 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
26627 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
26628 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
26629 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
26630 error "truncate $tdir/trunc failed"
26633 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
26634 error "write $tfile failed"
26636 # multi-client wirtes
26637 local num=$(get_node_count ${CLIENTS//,/ })
26641 echo "Test SOM for multi-client ($num) writes"
26642 touch $DIR/$tfile || error "touch $tfile failed"
26643 $TRUNCATE $DIR/$tfile 0
26644 for client in ${CLIENTS//,/ }; do
26645 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
26648 offset=$((offset + $bs))
26650 for (( i=0; i < $num; i++ )); do
26654 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
26655 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
26656 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
26657 check_lsom_data $DIR/$tdir/trunc
26658 check_lsom_data $DIR/$tdir/single_dd
26659 check_lsom_data $DIR/$tfile
26662 # Deregistration step
26663 changelog_deregister || error "changelog_deregister failed"
26665 run_test 807 "verify LSOM syncing tool"
26667 check_som_nologged()
26669 local lines=$($LFS changelog $FSNAME-MDT0000 |
26670 grep 'x=trusted.som' | wc -l)
26671 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
26675 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
26676 skip "Need MDS version at least 2.11.55"
26678 # Registration step
26679 changelog_register || error "changelog_register failed"
26681 touch $DIR/$tfile || error "touch $tfile failed"
26684 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
26685 error "write $tfile failed"
26688 $TRUNCATE $DIR/$tfile 1234
26691 $TRUNCATE $DIR/$tfile 1048576
26694 # Deregistration step
26695 changelog_deregister || error "changelog_deregister failed"
26697 run_test 808 "Check trusted.som xattr not logged in Changelogs"
26702 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
26706 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
26707 skip "Need MDS version at least 2.11.56"
26709 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
26710 error "failed to create DoM-only file $DIR/$tfile"
26711 touch $DIR/$tfile || error "touch $tfile failed"
26712 check_som_nodata $DIR/$tfile
26714 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
26715 error "write $tfile failed"
26716 check_som_nodata $DIR/$tfile
26718 $TRUNCATE $DIR/$tfile 1234
26719 check_som_nodata $DIR/$tfile
26721 $TRUNCATE $DIR/$tfile 4097
26722 check_som_nodata $DIR/$file
26724 run_test 809 "Verify no SOM xattr store for DoM-only files"
26727 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26728 $GSS && skip_env "could not run with gss"
26729 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
26730 skip "OST < 2.12.58 doesn't align checksum"
26733 stack_trap "set_checksums $ORIG_CSUM" EXIT
26734 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
26739 for csum in $CKSUM_TYPES; do
26740 #define OBD_FAIL_OSC_NO_GRANT 0x411
26741 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
26742 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
26744 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
26745 before=$(md5sum $DIR/$tfile)
26746 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
26747 after=$(md5sum $DIR/$tfile)
26748 [ "$before" == "$after" ] ||
26749 error "$csum: $before != $after bs=$1 seek=$2"
26753 run_test 810 "partial page writes on ZFS (LU-11663)"
26756 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
26757 skip "OST < 2.12.51 doesn't support this fail_loc"
26759 $LFS setstripe -c 1 -i 0 $DIR/$tfile
26760 # ensure ost1 is connected
26761 stat $DIR/$tfile >/dev/null || error "can't stat"
26762 wait_osc_import_state client ost1 FULL
26763 # no locks, no reqs to let the connection idle
26764 cancel_lru_locks osc
26766 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
26767 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
26768 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
26769 wait_osc_import_state client ost1 CONNECTING
26770 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
26772 stat $DIR/$tfile >/dev/null || error "can't stat file"
26774 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
26776 test_812b() { # LU-12378
26777 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
26778 skip "OST < 2.12.51 doesn't support this fail_loc"
26780 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
26781 # ensure ost1 is connected
26782 stat $DIR/$tfile >/dev/null || error "can't stat"
26783 wait_osc_import_state client ost1 FULL
26784 # no locks, no reqs to let the connection idle
26785 cancel_lru_locks osc
26787 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
26788 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
26789 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
26790 wait_osc_import_state client ost1 CONNECTING
26791 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
26793 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
26794 wait_osc_import_state client ost1 IDLE
26796 run_test 812b "do not drop no resend request for idle connect"
26801 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
26803 $LFS setstripe -c 1 -o 0 $DIR/$tfile
26804 $LFS getstripe $DIR/$tfile
26805 $LCTL set_param osc.*.idle_timeout=10
26806 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
26807 # ensure ost1 is connected
26808 stat $DIR/$tfile >/dev/null || error "can't stat"
26809 wait_osc_import_state client ost1 FULL
26810 # no locks, no reqs to let the connection idle
26811 cancel_lru_locks osc
26813 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
26814 $LCTL set_param fail_loc=0x80000533
26816 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
26818 run_test 812c "idle import vs lock enqueue race"
26821 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
26822 [ -z "$file_heat_sav" ] && skip "no file heat support"
26833 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
26834 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
26836 $LCTL set_param -n llite.*.file_heat=1
26837 echo "Turn on file heat"
26838 echo "Period second: $period_second, Decay percentage: $decay_pct"
26840 echo "QQQQ" > $DIR/$tfile
26841 echo "QQQQ" > $DIR/$tfile
26842 echo "QQQQ" > $DIR/$tfile
26843 cat $DIR/$tfile > /dev/null
26844 cat $DIR/$tfile > /dev/null
26845 cat $DIR/$tfile > /dev/null
26846 cat $DIR/$tfile > /dev/null
26848 local out=$($LFS heat_get $DIR/$tfile)
26850 $LFS heat_get $DIR/$tfile
26851 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26852 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26853 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26854 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26856 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
26857 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
26858 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
26859 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
26861 sleep $((period_second + 3))
26862 echo "Sleep $((period_second + 3)) seconds..."
26863 # The recursion formula to calculate the heat of the file f is as
26865 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
26866 # Where Hi is the heat value in the period between time points i*I and
26867 # (i+1)*I; Ci is the access count in the period; the symbol P refers
26868 # to the weight of Ci.
26869 out=$($LFS heat_get $DIR/$tfile)
26870 $LFS heat_get $DIR/$tfile
26871 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26872 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26873 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26874 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26876 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
26877 error "read sample ($readsample) is wrong"
26878 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
26879 error "write sample ($writesample) is wrong"
26880 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
26881 error "read bytes ($readbyte) is wrong"
26882 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
26883 error "write bytes ($writebyte) is wrong"
26885 echo "QQQQ" > $DIR/$tfile
26886 echo "QQQQ" > $DIR/$tfile
26887 echo "QQQQ" > $DIR/$tfile
26888 cat $DIR/$tfile > /dev/null
26889 cat $DIR/$tfile > /dev/null
26890 cat $DIR/$tfile > /dev/null
26891 cat $DIR/$tfile > /dev/null
26893 sleep $((period_second + 3))
26894 echo "Sleep $((period_second + 3)) seconds..."
26896 out=$($LFS heat_get $DIR/$tfile)
26897 $LFS heat_get $DIR/$tfile
26898 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26899 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26900 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26901 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26903 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
26904 4 * $decay_pct) / 100") -eq 1 ] ||
26905 error "read sample ($readsample1) is wrong"
26906 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
26907 3 * $decay_pct) / 100") -eq 1 ] ||
26908 error "write sample ($writesample1) is wrong"
26909 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
26910 20 * $decay_pct) / 100") -eq 1 ] ||
26911 error "read bytes ($readbyte1) is wrong"
26912 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
26913 15 * $decay_pct) / 100") -eq 1 ] ||
26914 error "write bytes ($writebyte1) is wrong"
26916 echo "Turn off file heat for the file $DIR/$tfile"
26917 $LFS heat_set -o $DIR/$tfile
26919 echo "QQQQ" > $DIR/$tfile
26920 echo "QQQQ" > $DIR/$tfile
26921 echo "QQQQ" > $DIR/$tfile
26922 cat $DIR/$tfile > /dev/null
26923 cat $DIR/$tfile > /dev/null
26924 cat $DIR/$tfile > /dev/null
26925 cat $DIR/$tfile > /dev/null
26927 out=$($LFS heat_get $DIR/$tfile)
26928 $LFS heat_get $DIR/$tfile
26929 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26930 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26931 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26932 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26934 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
26935 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
26936 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
26937 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
26939 echo "Trun on file heat for the file $DIR/$tfile"
26940 $LFS heat_set -O $DIR/$tfile
26942 echo "QQQQ" > $DIR/$tfile
26943 echo "QQQQ" > $DIR/$tfile
26944 echo "QQQQ" > $DIR/$tfile
26945 cat $DIR/$tfile > /dev/null
26946 cat $DIR/$tfile > /dev/null
26947 cat $DIR/$tfile > /dev/null
26948 cat $DIR/$tfile > /dev/null
26950 out=$($LFS heat_get $DIR/$tfile)
26951 $LFS heat_get $DIR/$tfile
26952 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26953 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26954 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26955 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26957 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
26958 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
26959 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
26960 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
26962 $LFS heat_set -c $DIR/$tfile
26963 $LCTL set_param -n llite.*.file_heat=0
26964 echo "Turn off file heat support for the Lustre filesystem"
26966 echo "QQQQ" > $DIR/$tfile
26967 echo "QQQQ" > $DIR/$tfile
26968 echo "QQQQ" > $DIR/$tfile
26969 cat $DIR/$tfile > /dev/null
26970 cat $DIR/$tfile > /dev/null
26971 cat $DIR/$tfile > /dev/null
26972 cat $DIR/$tfile > /dev/null
26974 out=$($LFS heat_get $DIR/$tfile)
26975 $LFS heat_get $DIR/$tfile
26976 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26977 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26978 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26979 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26981 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
26982 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
26983 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
26984 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
26986 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
26989 run_test 813 "File heat verfication"
26993 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
26994 echo -n y >> $DIR/$tfile
26995 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
26996 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
26998 run_test 814 "sparse cp works as expected (LU-12361)"
27002 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
27003 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
27005 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
27008 local ost1_imp=$(get_osc_import_name client ost1)
27009 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
27012 $LFS setstripe -c 1 -i 0 $DIR/$tfile
27013 # ensure ost1 is connected
27015 stat $DIR/$tfile >/dev/null || error "can't stat"
27016 wait_osc_import_state client ost1 FULL
27017 # no locks, no reqs to let the connection idle
27018 cancel_lru_locks osc
27019 lru_resize_disable osc
27022 before=$($LCTL get_param -n \
27023 ldlm.namespaces.$imp_name.lru_size)
27025 wait_osc_import_state client ost1 IDLE
27026 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
27027 now=$($LCTL get_param -n \
27028 ldlm.namespaces.$imp_name.lru_size)
27029 [ $before == $now ] || error "lru_size changed $before != $now"
27031 run_test 816 "do not reset lru_resize on idle reconnect"
27035 exportfs -u localhost:$DIR/nfsexp
27040 systemctl restart nfs-server.service || skip "failed to restart nfsd"
27042 mkdir -p $DIR/nfsexp
27043 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
27044 error "failed to export nfs"
27046 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
27047 stack_trap cleanup_817 EXIT
27049 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
27050 error "failed to mount nfs to $tmpdir"
27052 cp /bin/true $tmpdir
27053 $DIR/nfsexp/true || error "failed to execute 'true' command"
27055 run_test 817 "nfsd won't cache write lock for exec file"
27059 $LFS setstripe -c1 -i0 $DIR/$tfile
27060 $LFS setstripe -c1 -i1 $DIR/$tfile
27062 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
27063 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
27064 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
27065 error "start $SINGLEMDS failed"
27068 run_test 818 "unlink with failed llog"
27071 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
27072 cancel_lru_locks osc
27073 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
27074 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
27075 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
27078 run_test 819a "too big niobuf in read"
27081 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
27082 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
27083 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
27084 cancel_lru_locks osc
27088 run_test 819b "too big niobuf in write"
27091 function test_820_start_ost() {
27094 for num in $(seq $OSTCOUNT); do
27095 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
27100 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27103 umount_client $MOUNT || error "umount failed"
27104 for num in $(seq $OSTCOUNT); do
27108 # mount client with no active OSTs
27109 # so that the client can't initialize max LOV EA size
27110 # from OSC notifications
27111 mount_client $MOUNT || error "mount failed"
27112 # delay OST starting to keep this 0 max EA size for a while
27113 test_820_start_ost &
27115 # create a directory on MDS2
27116 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
27117 error "Failed to create directory"
27118 # open intent should update default EA size
27119 # see mdc_update_max_ea_from_body()
27120 # notice this is the very first RPC to MDS2
27121 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
27124 # With SSK, this situation can lead to -EPERM being returned.
27125 # In that case, simply retry.
27126 if [ $ret -ne 0 ] && $SHARED_KEY; then
27127 if echo "$out" | grep -q "not permitted"; then
27128 cp /etc/services $DIR/$tdir/mds2
27132 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
27134 run_test 820 "update max EA from open intent"
27137 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
27139 save_lustre_params mds1 \
27140 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
27141 do_facet $SINGLEMDS "$LCTL set_param -n \
27142 osp.$FSNAME-OST*MDT0000.max_create_count=0"
27143 do_facet $SINGLEMDS "$LCTL set_param -n \
27144 osp.$FSNAME-OST0000*MDT0000.max_create_count=20000"
27146 # wait for statfs update to clear OS_STATFS_NOPRECREATE
27147 local maxage=$(do_facet mds1 $LCTL get_param -n \
27148 osp.$FSNAME-OST0000*MDT0000.maxage)
27149 sleep $((maxage + 1))
27151 #define OBD_FAIL_NET_ERROR_RPC 0x532
27152 do_facet mds1 "$LCTL set_param fail_loc=0x80000532 fail_val=5"
27154 stack_trap "restore_lustre_params < $p; rm $p"
27156 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
27157 osp.$FSNAME-OST0000*MDT0000.create_count")
27158 for i in $(seq 1 $count); do
27159 touch $DIR/$tfile.${i} || error "touch failed"
27162 run_test 822 "test precreate failure"
27165 # tests that do cleanup/setup should be run at the end
27169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27172 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
27173 $LCTL set_param fail_loc=0x903
27175 cancel_lru_locks MGC
27177 FAIL_ON_ERROR=true cleanup
27178 FAIL_ON_ERROR=true setup
27180 run_test 900 "umount should not race with any mgc requeue thread"
27182 # LUS-6253/LU-11185
27188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27190 # some get_param have a bug to handle dot in param name
27191 cancel_lru_locks MGC
27192 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
27193 olds=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
27194 umount_client $MOUNT || error "umount failed"
27195 mount_client $MOUNT || error "mount failed"
27196 cancel_lru_locks MGC
27197 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
27198 news=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
27200 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
27201 [ $olds -lt $news ] && error "mgs lock leak ($olds != $news)"
27205 run_test 901 "don't leak a mgc lock on client umount"
27209 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
27210 skip "client does not have LU-13377 fix"
27211 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
27212 $LCTL set_param fail_loc=0x1415
27213 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
27214 cancel_lru_locks osc
27217 run_test 902 "test short write doesn't hang lustre"
27220 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
27221 check_and_cleanup_lustre
27222 if [ "$I_MOUNTED" != "yes" ]; then
27223 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true