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
3019 $LFS setstripe -C 4 $DIR/$tdir
3021 echo 1 > $DIR/$tdir/${tfile}.1
3022 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
3024 [ $count -eq $setcount ] ||
3025 error "(1) stripe count $count, should be $setcount"
3027 # Capture existing append_stripe_count setting for restore
3028 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3029 local mdts=$(comma_list $(mdts_nodes))
3030 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
3032 local appendcount=$orig_count
3033 echo 1 >> $DIR/$tdir/${tfile}.2_append
3034 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
3035 [ $count -eq $appendcount ] ||
3036 error "(2)stripe count $count, should be $appendcount for append"
3038 # Disable O_APPEND striping, verify it works
3039 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3041 # Should now get the default striping, which is 4
3043 echo 1 >> $DIR/$tdir/${tfile}.3_append
3044 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3045 [ $count -eq $setcount ] ||
3046 error "(3) stripe count $count, should be $setcount"
3048 # Try changing the stripe count for append files
3049 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3051 # Append striping is now 2 (directory default is still 4)
3053 echo 1 >> $DIR/$tdir/${tfile}.4_append
3054 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3055 [ $count -eq $appendcount ] ||
3056 error "(4) stripe count $count, should be $appendcount for append"
3058 # Test append stripe count of -1
3059 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3060 appendcount=$OSTCOUNT
3061 echo 1 >> $DIR/$tdir/${tfile}.5
3062 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3063 [ $count -eq $appendcount ] ||
3064 error "(5) stripe count $count, should be $appendcount for append"
3066 # Set append striping back to default of 1
3067 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3069 # Try a new default striping, PFL + DOM
3070 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3072 # Create normal DOM file, DOM returns stripe count == 0
3074 touch $DIR/$tdir/${tfile}.6
3075 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3076 [ $count -eq $setcount ] ||
3077 error "(6) stripe count $count, should be $setcount"
3081 echo 1 >> $DIR/$tdir/${tfile}.7_append
3082 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3083 [ $count -eq $appendcount ] ||
3084 error "(7) stripe count $count, should be $appendcount for append"
3086 # Clean up DOM layout
3087 $LFS setstripe -d $DIR/$tdir
3089 # Now test that append striping works when layout is from root
3090 $LFS setstripe -c 2 $MOUNT
3091 # Make a special directory for this
3092 mkdir $DIR/${tdir}/${tdir}.2
3093 stack_trap "$LFS setstripe -d $MOUNT" EXIT
3095 # Verify for normal file
3097 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3098 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3099 [ $count -eq $setcount ] ||
3100 error "(8) stripe count $count, should be $setcount"
3103 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3104 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3105 [ $count -eq $appendcount ] ||
3106 error "(9) stripe count $count, should be $appendcount for append"
3108 # Now test O_APPEND striping with pools
3109 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3110 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
3113 pool_add $TESTNAME || error "pool creation failed"
3114 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3116 echo 1 >> $DIR/$tdir/${tfile}.10_append
3118 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3119 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3121 # Check that count is still correct
3123 echo 1 >> $DIR/$tdir/${tfile}.11_append
3124 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3125 [ $count -eq $appendcount ] ||
3126 error "(11) stripe count $count, should be $appendcount for append"
3128 # Disable O_APPEND stripe count, verify pool works separately
3129 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3131 echo 1 >> $DIR/$tdir/${tfile}.12_append
3133 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3134 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3136 # Remove pool setting, verify it's not applied
3137 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3139 echo 1 >> $DIR/$tdir/${tfile}.13_append
3141 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3142 [ "$pool" = "" ] || error "(13) pool found: $pool"
3144 run_test 27M "test O_APPEND striping"
3147 combined_mgs_mds && skip "needs separate MGS/MDT"
3149 pool_add $TESTNAME || error "pool_add failed"
3150 do_facet mgs "$LCTL pool_list $FSNAME" |
3151 grep -Fx "${FSNAME}.${TESTNAME}" ||
3152 error "lctl pool_list on MGS failed"
3154 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3156 clean_foreign_symlink() {
3158 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3159 for i in $DIR/$tdir/* ; do
3160 $LFS unlink_foreign $i || true
3165 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3166 skip "Need MDS version newer than 2.12.51"
3168 test_mkdir $DIR/$tdir
3169 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3170 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3172 trap clean_foreign_symlink EXIT
3174 # enable foreign_symlink behaviour
3175 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3177 # foreign symlink LOV format is a partial path by default
3179 # create foreign file (lfs + API)
3180 $LFS setstripe --foreign=symlink --flags 0xda05 \
3181 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3182 error "$DIR/$tdir/${tfile}: create failed"
3184 $LFS getstripe -v $DIR/$tdir/${tfile} |
3185 grep "lfm_magic:.*0x0BD70BD0" ||
3186 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3187 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3188 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3189 $LFS getstripe -v $DIR/$tdir/${tfile} |
3190 grep "lfm_flags:.*0x0000DA05" ||
3191 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3192 $LFS getstripe $DIR/$tdir/${tfile} |
3193 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3194 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3196 # modify striping should fail
3197 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3198 error "$DIR/$tdir/$tfile: setstripe should fail"
3200 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3201 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3202 cat /etc/passwd > $DIR/$tdir/$tfile &&
3203 error "$DIR/$tdir/$tfile: write should fail"
3205 # rename should succeed
3206 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3207 error "$DIR/$tdir/$tfile: rename has failed"
3209 #remove foreign_symlink file should fail
3210 rm $DIR/$tdir/${tfile}.new &&
3211 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3214 mkdir /tmp/${uuid1} ||
3215 error "/tmp/${uuid1}: mkdir has failed"
3216 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3217 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3218 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3219 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3220 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3221 #read should succeed now
3222 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3223 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3224 #write should succeed now
3225 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3226 error "$DIR/$tdir/${tfile}.new: write should succeed"
3227 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3228 error "$DIR/$tdir/${tfile}.new: diff has failed"
3229 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3230 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3232 #check that getstripe still works
3233 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3234 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3236 # chmod should still succeed
3237 chmod 644 $DIR/$tdir/${tfile}.new ||
3238 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3240 # chown should still succeed
3241 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3242 error "$DIR/$tdir/${tfile}.new: chown has failed"
3244 # rename should still succeed
3245 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3246 error "$DIR/$tdir/${tfile}.new: rename has failed"
3248 #remove foreign_symlink file should still fail
3249 rm $DIR/$tdir/${tfile} &&
3250 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3252 #use special ioctl() to unlink foreign_symlink file
3253 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3254 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3257 run_test 27O "basic ops on foreign file of symlink type"
3260 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3261 skip "Need MDS version newer than 2.12.49"
3263 test_mkdir $DIR/$tdir
3264 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3265 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3267 trap clean_foreign_symlink EXIT
3269 # enable foreign_symlink behaviour
3270 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3272 # foreign symlink LMV format is a partial path by default
3274 # create foreign dir (lfs + API)
3275 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3276 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3277 error "$DIR/$tdir/${tdir}: create failed"
3279 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3280 grep "lfm_magic:.*0x0CD50CD0" ||
3281 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3282 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3283 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3284 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3285 grep "lfm_flags:.*0x0000DA05" ||
3286 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3287 $LFS getdirstripe $DIR/$tdir/${tdir} |
3288 grep "lfm_value.*${uuid1}/${uuid2}" ||
3289 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3291 # file create in dir should fail
3292 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3293 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
3295 # rename should succeed
3296 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3297 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3299 #remove foreign_symlink dir should fail
3300 rmdir $DIR/$tdir/${tdir}.new &&
3301 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3304 mkdir -p /tmp/${uuid1}/${uuid2} ||
3305 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3306 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3307 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3308 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3309 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3310 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3311 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3312 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3314 #check that getstripe fails now that foreign_symlink enabled
3315 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3316 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3318 # file create in dir should work now
3319 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3320 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3321 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3322 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3323 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3324 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3326 # chmod should still succeed
3327 chmod 755 $DIR/$tdir/${tdir}.new ||
3328 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3330 # chown should still succeed
3331 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3332 error "$DIR/$tdir/${tdir}.new: chown has failed"
3334 # rename should still succeed
3335 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3336 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3338 #remove foreign_symlink dir should still fail
3339 rmdir $DIR/$tdir/${tdir} &&
3340 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3342 #use special ioctl() to unlink foreign_symlink file
3343 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3344 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3346 #created file should still exist
3347 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3348 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3349 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3350 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3352 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3355 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3356 stack_trap "rm -f $TMP/$tfile*"
3358 test_mkdir $DIR/$tdir-1
3359 test_mkdir $DIR/$tdir-2
3361 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3362 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3364 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3365 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3367 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3368 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3370 # Create some bad symlinks and ensure that we don't loop
3371 # forever or something. These should return ELOOP (40) and
3372 # ENOENT (2) but I don't want to test for that because there's
3373 # always some weirdo architecture that needs to ruin
3374 # everything by defining these error numbers differently.
3376 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3377 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3379 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3380 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3384 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3386 # createtest also checks that device nodes are created and
3387 # then visible correctly (#2091)
3388 test_28() { # bug 2091
3390 $CREATETEST $DIR/d28/ct || error "createtest failed"
3392 run_test 28 "create/mknod/mkdir with bad file types ============"
3395 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3397 sync; sleep 1; sync # flush out any dirty pages from previous tests
3404 declare -i LOCKCOUNTORIG=0
3405 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3406 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3408 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3410 declare -i LOCKUNUSEDCOUNTORIG=0
3411 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3412 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3419 declare -i LOCKCOUNTCURRENT=0
3420 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3421 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3424 declare -i LOCKUNUSEDCOUNTCURRENT=0
3425 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3426 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3429 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3430 $LCTL set_param -n ldlm.dump_namespaces ""
3431 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3432 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3433 log "dumped log to $TMP/test_29.dk (bug 5793)"
3436 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3437 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3438 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3439 log "dumped log to $TMP/test_29.dk (bug 5793)"
3443 run_test 29 "IT_GETATTR regression ============================"
3445 test_30a() { # was test_30
3446 cp $(which ls) $DIR || cp /bin/ls $DIR
3447 $DIR/ls / || error "Can't execute binary from lustre"
3450 run_test 30a "execute binary from Lustre (execve) =============="
3453 cp `which ls` $DIR || cp /bin/ls $DIR
3455 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3458 run_test 30b "execute binary from Lustre as non-root ==========="
3460 test_30c() { # b=22376
3461 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3463 cp $(which ls) $DIR || cp /bin/ls $DIR
3465 cancel_lru_locks mdc
3466 cancel_lru_locks osc
3467 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3470 run_test 30c "execute binary from Lustre without read perms ===="
3473 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3475 for i in {1..10}; do
3476 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3479 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3480 wait $PID || error "executing dd from Lustre failed"
3486 run_test 30d "execute binary from Lustre while clear locks"
3489 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3490 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3492 run_test 31a "open-unlink file =================================="
3495 touch $DIR/f31 || error "touch $DIR/f31 failed"
3496 ln $DIR/f31 $DIR/f31b || error "ln failed"
3497 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3498 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3500 run_test 31b "unlink file with multiple links while open ======="
3503 touch $DIR/f31 || error "touch $DIR/f31 failed"
3504 ln $DIR/f31 $DIR/f31c || error "ln failed"
3505 multiop_bg_pause $DIR/f31 O_uc ||
3506 error "multiop_bg_pause for $DIR/f31 failed"
3508 $MULTIOP $DIR/f31c Ouc
3509 kill -USR1 $MULTIPID
3512 run_test 31c "open-unlink file with multiple links ============="
3515 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3516 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3518 run_test 31d "remove of open directory ========================="
3520 test_31e() { # bug 2904
3521 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3523 run_test 31e "remove of open non-empty directory ==============="
3525 test_31f() { # bug 4554
3526 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3529 test_mkdir $DIR/d31f
3530 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3531 cp /etc/hosts $DIR/d31f
3533 $LFS getstripe $DIR/d31f/hosts
3534 multiop_bg_pause $DIR/d31f D_c || return 1
3537 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3538 test_mkdir $DIR/d31f
3539 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3540 cp /etc/hosts $DIR/d31f
3542 $LFS getstripe $DIR/d31f/hosts
3543 multiop_bg_pause $DIR/d31f D_c || return 1
3546 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3547 wait $MULTIPID || error "first opendir $MULTIPID failed"
3551 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3552 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3555 run_test 31f "remove of open directory with open-unlink file ==="
3558 echo "-- cross directory link --"
3559 test_mkdir -c1 $DIR/${tdir}ga
3560 test_mkdir -c1 $DIR/${tdir}gb
3561 touch $DIR/${tdir}ga/f
3562 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3563 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3564 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3565 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3566 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3568 run_test 31g "cross directory link==============="
3571 echo "-- cross directory link --"
3572 test_mkdir -c1 $DIR/${tdir}
3573 test_mkdir -c1 $DIR/${tdir}/dir
3574 touch $DIR/${tdir}/f
3575 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3576 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3577 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3578 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3579 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3581 run_test 31h "cross directory link under child==============="
3584 echo "-- cross directory link --"
3585 test_mkdir -c1 $DIR/$tdir
3586 test_mkdir -c1 $DIR/$tdir/dir
3587 touch $DIR/$tdir/dir/f
3588 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3589 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3590 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3591 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3592 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3594 run_test 31i "cross directory link under parent==============="
3597 test_mkdir -c1 -p $DIR/$tdir
3598 test_mkdir -c1 -p $DIR/$tdir/dir1
3599 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3600 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3601 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3602 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3605 run_test 31j "link for directory==============="
3608 test_mkdir -c1 -p $DIR/$tdir
3610 touch $DIR/$tdir/exist
3611 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3612 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3613 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3614 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3615 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3616 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3617 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3620 run_test 31k "link to file: the same, non-existing, dir==============="
3626 touch $DIR/d31m2/exist
3627 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3628 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3629 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3630 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3631 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3632 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3635 run_test 31m "link to file: the same, non-existing, dir==============="
3638 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3639 nlink=$(stat --format=%h $DIR/$tfile)
3640 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3642 local cmd="exec $fd<$DIR/$tfile"
3645 trap "eval $cmd" EXIT
3646 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3647 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3648 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3649 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3650 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3653 run_test 31n "check link count of unlinked file"
3656 local tempfile=$(mktemp $1_XXXXXX)
3657 mlink $tempfile $1 2> /dev/null &&
3658 echo "$BASHPID: link $tempfile to $1 succeeded"
3662 test_31o() { # LU-2901
3663 test_mkdir $DIR/$tdir
3664 for LOOP in $(seq 100); do
3665 rm -f $DIR/$tdir/$tfile*
3666 for THREAD in $(seq 8); do
3667 link_one $DIR/$tdir/$tfile.$LOOP &
3670 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3671 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3672 error "$LINKS duplicate links to $tfile.$LOOP" &&
3676 run_test 31o "duplicate hard links with same filename"
3679 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3681 test_mkdir $DIR/$tdir
3682 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3683 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3685 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3686 error "open unlink test1 failed"
3687 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3688 error "open unlink test2 failed"
3690 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3691 error "test1 still exists"
3692 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3693 error "test2 still exists"
3695 run_test 31p "remove of open striped directory"
3698 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3700 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3701 index=$($LFS getdirstripe -i $DIR/$tdir)
3702 [ $index -eq 3 ] || error "first stripe index $index != 3"
3703 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3704 [ $index -eq 1 ] || error "second stripe index $index != 1"
3706 # when "-c <stripe_count>" is set, the number of MDTs specified after
3707 # "-i" should equal to the stripe count
3708 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3710 run_test 31q "create striped directory on specific MDTs"
3712 cleanup_test32_mount() {
3715 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3716 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3717 losetup -d $loopdev || true
3723 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3725 echo "== more mountpoints and symlinks ================="
3726 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3727 trap cleanup_test32_mount EXIT
3728 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3729 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3730 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3731 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3732 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3733 cleanup_test32_mount
3735 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3738 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3740 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3741 trap cleanup_test32_mount EXIT
3742 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3743 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3744 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3745 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3746 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3747 cleanup_test32_mount
3749 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3752 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3754 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3755 trap cleanup_test32_mount EXIT
3756 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3757 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3758 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3759 test_mkdir -p $DIR/$tdir/d2/test_dir
3760 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3761 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3762 cleanup_test32_mount
3764 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3767 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3769 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3770 trap cleanup_test32_mount EXIT
3771 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3772 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3773 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3774 test_mkdir -p $DIR/$tdir/d2/test_dir
3775 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3776 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3777 cleanup_test32_mount
3779 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3783 test_mkdir -p $DIR/$tdir/tmp
3784 local tmp_dir=$DIR/$tdir/tmp
3785 ln -s $DIR/$tdir $tmp_dir/symlink11
3786 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3787 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3788 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3790 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3794 test_mkdir -p $DIR/$tdir/tmp
3795 local tmp_dir=$DIR/$tdir/tmp
3796 ln -s $DIR/$tdir $tmp_dir/symlink11
3797 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3798 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3799 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3801 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3804 local tmp_dir=$DIR/$tdir/tmp
3805 test_mkdir -p $tmp_dir
3806 test_mkdir $DIR/${tdir}2
3807 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3808 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3809 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3810 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3811 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3812 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3814 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3817 rm -fr $DIR/$tdir $DIR/${tdir}2
3818 tmp_dir=$DIR/$tdir/tmp
3819 test_mkdir -p $tmp_dir
3820 test_mkdir $DIR/${tdir}2
3821 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3822 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3823 ls $tmp_dir/symlink12 || error "listing symlink12"
3824 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3826 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3831 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3832 trap cleanup_test32_mount EXIT
3833 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3834 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3835 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3836 touch $DIR/$tdir/test_file
3837 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3838 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3839 cleanup_test32_mount
3841 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3844 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3846 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3847 trap cleanup_test32_mount EXIT
3848 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3849 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3850 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3851 touch $DIR/$tdir/test_file
3852 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3853 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3854 cleanup_test32_mount
3856 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3859 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3862 trap cleanup_test32_mount EXIT
3863 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3864 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3865 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3866 test_mkdir -p $DIR/$tdir/d2
3867 touch $DIR/$tdir/d2/test_file || error "touch failed"
3868 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3869 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3870 cleanup_test32_mount
3872 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3875 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3878 trap cleanup_test32_mount EXIT
3879 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3880 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3881 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3882 test_mkdir -p $DIR/$tdir/d2
3883 touch $DIR/$tdir/d2/test_file || error "touch failed"
3884 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3885 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3886 cleanup_test32_mount
3888 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3892 test_mkdir -p $DIR/d32m/tmp
3893 TMP_DIR=$DIR/d32m/tmp
3894 ln -s $DIR $TMP_DIR/symlink11
3895 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3896 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3897 error "symlink11 not a link"
3898 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3899 error "symlink01 not a link"
3901 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3905 test_mkdir -p $DIR/d32n/tmp
3906 TMP_DIR=$DIR/d32n/tmp
3907 ln -s $DIR $TMP_DIR/symlink11
3908 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3909 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3910 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3912 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3916 test_mkdir -p $DIR/d32o/tmp
3917 TMP_DIR=$DIR/d32o/tmp
3918 ln -s $DIR/$tfile $TMP_DIR/symlink12
3919 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3920 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3921 error "symlink12 not a link"
3922 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3923 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3924 error "$DIR/d32o/tmp/symlink12 not file type"
3925 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3926 error "$DIR/d32o/symlink02 not file type"
3928 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3938 test_mkdir -p $DIR/d32p/tmp
3940 TMP_DIR=$DIR/d32p/tmp
3942 ln -s $DIR/$tfile $TMP_DIR/symlink12
3944 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3946 cat $DIR/d32p/tmp/symlink12 ||
3947 error "Can't open $DIR/d32p/tmp/symlink12"
3949 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3952 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3955 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3957 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3958 trap cleanup_test32_mount EXIT
3959 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3960 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3961 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3962 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3963 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3964 cleanup_test32_mount
3966 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3969 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3971 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3972 trap cleanup_test32_mount EXIT
3973 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3974 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3975 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3976 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3977 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3978 cleanup_test32_mount
3980 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3985 chmod 444 $DIR/$tfile
3986 chown $RUNAS_ID $DIR/$tfile
3988 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3991 run_test 33aa "write file with mode 444 (should return error)"
3995 test_mkdir $DIR/$tdir
3996 chown $RUNAS_ID $DIR/$tdir
3997 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3998 error "$RUNAS create $tdir/$tfile failed"
3999 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4000 error "open RDWR" || true
4002 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4006 test_mkdir $DIR/$tdir
4007 chown $RUNAS_ID $DIR/$tdir
4008 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4010 run_test 33b "test open file with malformed flags (No panic)"
4013 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4014 remote_ost_nodsh && skip "remote OST with nodsh"
4022 test_mkdir $DIR/$tdir
4023 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4026 for ostnum in $(seq $OSTCOUNT); do
4027 # test-framework's OST numbering is one-based, while Lustre's
4029 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4030 # check if at least some write_bytes stats are counted
4031 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4032 obdfilter.$ostname.stats |
4033 awk '/^write_bytes/ {print $7}' )
4034 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4035 if (( ${write_bytes:-0} > 0 )); then
4041 $all_zeros || return 0
4044 echo foo > $DIR/$tdir/bar
4048 # Total up write_bytes after writing. We'd better find non-zeros.
4049 for ostnum in $(seq $OSTCOUNT); do
4050 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4051 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4052 obdfilter/$ostname/stats |
4053 awk '/^write_bytes/ {print $7}' )
4054 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4055 if (( ${write_bytes:-0} > 0 )); then
4062 for ostnum in $(seq $OSTCOUNT); do
4063 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4064 echo "Check write_bytes is in obdfilter.*.stats:"
4065 do_facet ost$ostnum lctl get_param -n \
4066 obdfilter.$ostname.stats
4068 error "OST not keeping write_bytes stats (b=22312)"
4071 run_test 33c "test write_bytes stats"
4074 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4075 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4078 local remote_dir=$DIR/$tdir/remote_dir
4080 test_mkdir $DIR/$tdir
4081 $LFS mkdir -i $MDTIDX $remote_dir ||
4082 error "create remote directory failed"
4084 touch $remote_dir/$tfile
4085 chmod 444 $remote_dir/$tfile
4086 chown $RUNAS_ID $remote_dir/$tfile
4088 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4090 chown $RUNAS_ID $remote_dir
4091 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4092 error "create" || true
4093 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4094 error "open RDWR" || true
4095 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4097 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4100 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4104 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4105 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4106 mkdir $DIR/$tdir/local_dir
4108 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4109 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4110 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4112 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4113 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4115 rmdir $DIR/$tdir/* || error "rmdir failed"
4118 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4119 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4120 mkdir $DIR/$tdir/local_dir
4122 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4123 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4124 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4126 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4127 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4129 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4132 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4133 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4134 mkdir $DIR/$tdir/local_dir
4136 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4137 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4138 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4140 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4141 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4143 run_test 33e "mkdir and striped directory should have same mode"
4147 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4151 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4152 remote_mds_nodsh && skip "remote MDS with nodsh"
4155 chmod go+rwx $DIR/$tdir
4156 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4157 trap cleanup_33f EXIT
4159 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4160 error "cannot create striped directory"
4162 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4163 error "cannot create files in striped directory"
4165 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4166 error "cannot remove files in striped directory"
4168 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4169 error "cannot remove striped directory"
4173 run_test 33f "nonroot user can create, access, and remove a striped directory"
4176 mkdir -p $DIR/$tdir/dir2
4178 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4180 [[ $err =~ "exists" ]] || error "Not exists error"
4182 run_test 33g "nonroot user create already existing root created file"
4185 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4186 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
4187 skip "Need MDS version at least 2.13.50"
4189 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir ||
4190 error "mkdir $tdir failed"
4191 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4193 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4196 for fname in $DIR/$tdir/$tfile.bak \
4197 $DIR/$tdir/$tfile.SAV \
4198 $DIR/$tdir/$tfile.orig \
4199 $DIR/$tdir/$tfile~; do
4200 touch $fname || error "touch $fname failed"
4201 index2=$($LFS getstripe -m $fname)
4202 [ $index -eq $index2 ] ||
4203 error "$fname MDT index mismatch $index != $index2"
4207 for i in {1..250}; do
4208 for fname in $(mktemp -u $DIR/$tdir/.$tfile.XXXXXX) \
4209 $(mktemp $DIR/$tdir/$tfile.XXXXXXXX); do
4210 touch $fname || error "touch $fname failed"
4211 index2=$($LFS getstripe -m $fname)
4212 if [[ $index != $index2 ]]; then
4213 failed=$((failed + 1))
4214 echo "$fname MDT index mismatch $index != $index2"
4218 echo "$failed MDT index mismatches"
4219 (( failed < 20 )) || error "MDT index mismatch $failed times"
4222 run_test 33h "temp file is located on the same MDT as target"
4224 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4227 $MCREATE $DIR/f34 || error "mcreate failed"
4228 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4229 error "getstripe failed"
4230 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4231 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4232 error "getstripe failed"
4233 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4234 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4236 run_test 34a "truncate file that has not been opened ==========="
4239 [ ! -f $DIR/f34 ] && test_34a
4240 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4241 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4242 $OPENFILE -f O_RDONLY $DIR/f34
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 34b "O_RDONLY opening file doesn't create objects ====="
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_RDWR $DIR/f34
4255 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4256 error "$LFS 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 34c "O_RDWR opening file-with-size works =============="
4263 [ ! -f $DIR/f34 ] && test_34a
4264 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4266 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4267 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4270 run_test 34d "write to sparse file ============================="
4274 $MCREATE $DIR/f34e || error "mcreate failed"
4275 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4276 $CHECKSTAT -s 1000 $DIR/f34e ||
4277 error "Size of $DIR/f34e not equal to 1000 bytes"
4278 $OPENFILE -f O_RDWR $DIR/f34e
4279 $CHECKSTAT -s 1000 $DIR/f34e ||
4280 error "Size of $DIR/f34e not equal to 1000 bytes"
4282 run_test 34e "create objects, some with size and some without =="
4284 test_34f() { # bug 6242, 6243
4285 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4289 $MCREATE $DIR/f34f || error "mcreate failed"
4290 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4291 dd if=$DIR/f34f of=$TMP/f34f
4292 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4293 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4294 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4295 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4296 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4298 run_test 34f "read from a file with no objects until EOF ======="
4301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4303 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4305 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4306 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4307 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4308 cancel_lru_locks osc
4309 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4310 error "wrong size after lock cancel"
4312 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4313 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4314 error "expanding truncate failed"
4315 cancel_lru_locks osc
4316 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4317 error "wrong expanded size after lock cancel"
4319 run_test 34g "truncate long file ==============================="
4322 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4327 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4328 sync # Flush the cache so that multiop below does not block on cache
4329 # flush when getting the group lock
4330 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4333 # Since just timed wait is not good enough, let's do a sync write
4334 # that way we are sure enough time for a roundtrip + processing
4335 # passed + 2 seconds of extra margin.
4336 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4340 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4341 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4345 local nsz=`stat -c %s $DIR/$tfile`
4346 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4348 run_test 34h "ftruncate file under grouplock should not block"
4351 cp /bin/sh $DIR/f35a
4353 chown $RUNAS_ID $DIR/f35a
4354 $RUNAS $DIR/f35a && error || true
4357 run_test 35a "exec file with mode 444 (should return and not leak)"
4361 utime $DIR/f36 || error "utime failed for MDS"
4363 run_test 36a "MDS utime check (mknod, utime)"
4367 utime $DIR/f36 || error "utime failed for OST"
4369 run_test 36b "OST utime check (open, utime)"
4374 chown $RUNAS_ID $DIR/d36
4375 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4377 run_test 36c "non-root MDS utime check (mknod, utime)"
4380 [ ! -d $DIR/d36 ] && test_36c
4381 echo "" > $DIR/d36/f36
4382 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4384 run_test 36d "non-root OST utime check (open, utime)"
4387 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4389 test_mkdir $DIR/$tdir
4390 touch $DIR/$tdir/$tfile
4391 $RUNAS utime $DIR/$tdir/$tfile &&
4392 error "utime worked, expected failure" || true
4394 run_test 36e "utime on non-owned file (should return error)"
4398 local LANG_SAVE=$LANG
4399 local LC_LANG_SAVE=$LC_LANG
4400 export LANG=C LC_LANG=C # for date language
4402 DATESTR="Dec 20 2000"
4403 test_mkdir $DIR/$tdir
4404 lctl set_param fail_loc=$fl
4406 cp /etc/hosts $DIR/$tdir/$tfile
4407 sync & # write RPC generated with "current" inode timestamp, but delayed
4409 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4410 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4411 cancel_lru_locks $OSC
4412 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4414 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4415 echo "BEFORE: $LS_BEFORE" && \
4416 echo "AFTER : $LS_AFTER" && \
4417 echo "WANT : $DATESTR" && \
4418 error "$DIR/$tdir/$tfile timestamps changed" || true
4420 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4424 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4426 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4427 subr_36fh "0x80000214"
4429 run_test 36f "utime on file racing with OST BRW write =========="
4432 remote_ost_nodsh && skip "remote OST with nodsh"
4433 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4434 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4435 skip "Need MDS version at least 2.12.51"
4440 local tgt="obdfilter"
4442 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4444 test_mkdir $DIR/$tdir
4445 fmd_max_age=$(do_facet $facet \
4446 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4449 echo "FMD max age: ${fmd_max_age}s"
4450 touch $DIR/$tdir/$tfile
4451 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4452 gawk '{cnt=cnt+$1} END{print cnt}')
4453 echo "FMD before: $fmd"
4455 error "FMD wasn't create by touch"
4456 sleep $((fmd_max_age + 12))
4457 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4458 gawk '{cnt=cnt+$1} END{print cnt}')
4459 echo "FMD after: $fmd"
4461 error "FMD wasn't expired by ping"
4463 run_test 36g "FMD cache expiry ====================="
4466 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4468 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4469 subr_36fh "0x80000227"
4471 run_test 36h "utime on file racing with OST BRW write =========="
4474 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4476 test_mkdir $DIR/$tdir
4477 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4479 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4480 local new_mtime=$((mtime + 200))
4482 #change Modify time of striped dir
4483 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4484 error "change mtime failed"
4486 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4488 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4490 run_test 36i "change mtime on striped directory"
4492 # test_37 - duplicate with tests 32q 32r
4495 local file=$DIR/$tfile
4497 openfile -f O_DIRECTORY $file
4500 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4501 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4503 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4505 test_39a() { # was test_39
4507 touch $DIR/${tfile}2
4508 # ls -l $DIR/$tfile $DIR/${tfile}2
4509 # ls -lu $DIR/$tfile $DIR/${tfile}2
4510 # ls -lc $DIR/$tfile $DIR/${tfile}2
4512 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4513 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4515 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4517 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4519 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4520 error "O_TRUNC didn't change timestamps"
4523 run_test 39a "mtime changed on create"
4526 test_mkdir -c1 $DIR/$tdir
4527 cp -p /etc/passwd $DIR/$tdir/fopen
4528 cp -p /etc/passwd $DIR/$tdir/flink
4529 cp -p /etc/passwd $DIR/$tdir/funlink
4530 cp -p /etc/passwd $DIR/$tdir/frename
4531 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4534 echo "aaaaaa" >> $DIR/$tdir/fopen
4535 echo "aaaaaa" >> $DIR/$tdir/flink
4536 echo "aaaaaa" >> $DIR/$tdir/funlink
4537 echo "aaaaaa" >> $DIR/$tdir/frename
4539 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4540 local link_new=`stat -c %Y $DIR/$tdir/flink`
4541 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4542 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4544 cat $DIR/$tdir/fopen > /dev/null
4545 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4546 rm -f $DIR/$tdir/funlink2
4547 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4549 for (( i=0; i < 2; i++ )) ; do
4550 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4551 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4552 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4553 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4555 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4556 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4557 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4558 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4560 cancel_lru_locks $OSC
4561 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4564 run_test 39b "mtime change on open, link, unlink, rename ======"
4566 # this should be set to past
4567 TEST_39_MTIME=`date -d "1 year ago" +%s`
4573 local mtime0=`stat -c %Y $DIR1/$tfile`
4575 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4576 local mtime1=`stat -c %Y $DIR1/$tfile`
4577 [ "$mtime1" = $TEST_39_MTIME ] || \
4578 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4581 echo hello >> $DIR1/$tfile
4583 local mtime2=`stat -c %Y $DIR1/$tfile`
4584 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4585 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4587 mv $DIR1/$tfile $DIR1/$tfile-1
4589 for (( i=0; i < 2; i++ )) ; do
4590 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4591 [ "$mtime2" = "$mtime3" ] || \
4592 error "mtime ($mtime2) changed (to $mtime3) on rename"
4594 cancel_lru_locks $OSC
4595 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4598 run_test 39c "mtime change on rename ==========================="
4602 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4605 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4607 for (( i=0; i < 2; i++ )) ; do
4608 local mtime=`stat -c %Y $DIR1/$tfile`
4609 [ $mtime = $TEST_39_MTIME ] || \
4610 error "mtime($mtime) is not set to $TEST_39_MTIME"
4612 cancel_lru_locks $OSC
4613 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4616 run_test 39d "create, utime, stat =============================="
4620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4623 local mtime1=`stat -c %Y $DIR1/$tfile`
4625 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4627 for (( i=0; i < 2; i++ )) ; do
4628 local mtime2=`stat -c %Y $DIR1/$tfile`
4629 [ $mtime2 = $TEST_39_MTIME ] || \
4630 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4632 cancel_lru_locks $OSC
4633 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4636 run_test 39e "create, stat, utime, stat ========================"
4640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4643 mtime1=`stat -c %Y $DIR1/$tfile`
4646 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4648 for (( i=0; i < 2; i++ )) ; do
4649 local mtime2=`stat -c %Y $DIR1/$tfile`
4650 [ $mtime2 = $TEST_39_MTIME ] || \
4651 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4653 cancel_lru_locks $OSC
4654 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4657 run_test 39f "create, stat, sleep, utime, stat ================="
4661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4663 echo hello >> $DIR1/$tfile
4664 local mtime1=`stat -c %Y $DIR1/$tfile`
4667 chmod o+r $DIR1/$tfile
4669 for (( i=0; i < 2; i++ )) ; do
4670 local mtime2=`stat -c %Y $DIR1/$tfile`
4671 [ "$mtime1" = "$mtime2" ] || \
4672 error "lost mtime: $mtime2, should be $mtime1"
4674 cancel_lru_locks $OSC
4675 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4678 run_test 39g "write, chmod, stat ==============================="
4682 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4688 echo hello >> $DIR1/$tfile
4689 local mtime1=`stat -c %Y $DIR1/$tfile`
4691 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4693 if [ "$d1" != "$d2" ]; then
4694 echo "write and touch not within one second"
4696 for (( i=0; i < 2; i++ )) ; do
4697 local mtime2=`stat -c %Y $DIR1/$tfile`
4698 [ "$mtime2" = $TEST_39_MTIME ] || \
4699 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4701 cancel_lru_locks $OSC
4702 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4706 run_test 39h "write, utime within one second, stat ============="
4709 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4714 echo hello >> $DIR1/$tfile
4715 local mtime1=`stat -c %Y $DIR1/$tfile`
4717 mv $DIR1/$tfile $DIR1/$tfile-1
4719 for (( i=0; i < 2; i++ )) ; do
4720 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4722 [ "$mtime1" = "$mtime2" ] || \
4723 error "lost mtime: $mtime2, should be $mtime1"
4725 cancel_lru_locks $OSC
4726 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4729 run_test 39i "write, rename, stat =============================="
4732 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4734 start_full_debug_logging
4738 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4739 lctl set_param fail_loc=0x80000412
4740 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4741 error "multiop failed"
4743 local mtime1=`stat -c %Y $DIR1/$tfile`
4745 mv $DIR1/$tfile $DIR1/$tfile-1
4747 kill -USR1 $multipid
4748 wait $multipid || error "multiop close failed"
4750 for (( i=0; i < 2; i++ )) ; do
4751 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4752 [ "$mtime1" = "$mtime2" ] ||
4753 error "mtime is lost on close: $mtime2, " \
4757 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4759 lctl set_param fail_loc=0
4760 stop_full_debug_logging
4762 run_test 39j "write, rename, close, stat ======================="
4765 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4770 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4772 local mtime1=`stat -c %Y $DIR1/$tfile`
4774 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4776 kill -USR1 $multipid
4777 wait $multipid || error "multiop close failed"
4779 for (( i=0; i < 2; i++ )) ; do
4780 local mtime2=`stat -c %Y $DIR1/$tfile`
4782 [ "$mtime2" = $TEST_39_MTIME ] || \
4783 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4786 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4789 run_test 39k "write, utime, close, stat ========================"
4791 # this should be set to future
4792 TEST_39_ATIME=`date -d "1 year" +%s`
4795 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4796 remote_mds_nodsh && skip "remote MDS with nodsh"
4798 local atime_diff=$(do_facet $SINGLEMDS \
4799 lctl get_param -n mdd.*MDT0000*.atime_diff)
4801 mkdir_on_mdt0 $DIR/$tdir
4803 # test setting directory atime to future
4804 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4805 local atime=$(stat -c %X $DIR/$tdir)
4806 [ "$atime" = $TEST_39_ATIME ] ||
4807 error "atime is not set to future: $atime, $TEST_39_ATIME"
4809 # test setting directory atime from future to now
4810 local now=$(date +%s)
4811 touch -a -d @$now $DIR/$tdir
4813 atime=$(stat -c %X $DIR/$tdir)
4814 [ "$atime" -eq "$now" ] ||
4815 error "atime is not updated from future: $atime, $now"
4817 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
4820 # test setting directory atime when now > dir atime + atime_diff
4821 local d1=$(date +%s)
4823 local d2=$(date +%s)
4824 cancel_lru_locks mdc
4825 atime=$(stat -c %X $DIR/$tdir)
4826 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4827 error "atime is not updated : $atime, should be $d2"
4829 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
4832 # test not setting directory atime when now < dir atime + atime_diff
4834 cancel_lru_locks mdc
4835 atime=$(stat -c %X $DIR/$tdir)
4836 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4837 error "atime is updated to $atime, should remain $d1<atime<$d2"
4839 do_facet $SINGLEMDS \
4840 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4842 run_test 39l "directory atime update ==========================="
4845 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4849 local far_past_mtime=$(date -d "May 29 1953" +%s)
4850 local far_past_atime=$(date -d "Dec 17 1903" +%s)
4852 touch -m -d @$far_past_mtime $DIR1/$tfile
4853 touch -a -d @$far_past_atime $DIR1/$tfile
4855 for (( i=0; i < 2; i++ )) ; do
4856 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
4857 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
4858 error "atime or mtime set incorrectly"
4860 cancel_lru_locks $OSC
4861 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4864 run_test 39m "test atime and mtime before 1970"
4866 test_39n() { # LU-3832
4867 remote_mds_nodsh && skip "remote MDS with nodsh"
4869 local atime_diff=$(do_facet $SINGLEMDS \
4870 lctl get_param -n mdd.*MDT0000*.atime_diff)
4875 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4878 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4879 atime0=$(stat -c %X $DIR/$tfile)
4882 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4883 atime1=$(stat -c %X $DIR/$tfile)
4886 cancel_lru_locks mdc
4887 cancel_lru_locks osc
4888 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4889 atime2=$(stat -c %X $DIR/$tfile)
4891 do_facet $SINGLEMDS \
4892 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4894 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4895 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4897 run_test 39n "check that O_NOATIME is honored"
4900 TESTDIR=$DIR/$tdir/$tfile
4901 [ -e $TESTDIR ] && rm -rf $TESTDIR
4908 links2=$(stat -c %h .)
4909 [ $(($links1 + 2)) != $links2 ] &&
4910 error "wrong links count $(($links1 + 2)) != $links2"
4912 links3=$(stat -c %h .)
4913 [ $(($links1 + 1)) != $links3 ] &&
4914 error "wrong links count $links1 != $links3"
4917 run_test 39o "directory cached attributes updated after create"
4920 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4923 TESTDIR=$DIR/$tdir/$tdir
4924 [ -e $TESTDIR ] && rm -rf $TESTDIR
4925 test_mkdir -p $TESTDIR
4929 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4930 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4932 links2=$(stat -c %h .)
4933 [ $(($links1 + 2)) != $links2 ] &&
4934 error "wrong links count $(($links1 + 2)) != $links2"
4936 links3=$(stat -c %h .)
4937 [ $(($links1 + 1)) != $links3 ] &&
4938 error "wrong links count $links1 != $links3"
4941 run_test 39p "remote directory cached attributes updated after create ========"
4944 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
4945 skip "no atime update on old OST"
4946 if [ "$ost1_FSTYPE" != ldiskfs ]; then
4947 skip_env "ldiskfs only test"
4951 saved_adiff=$(do_facet ost1 \
4952 lctl get_param -n obdfilter.*OST0000.atime_diff)
4953 stack_trap "do_facet ost1 \
4954 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
4956 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
4958 $LFS setstripe -i 0 $DIR/$tfile
4959 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
4960 error "can't write initial file"
4961 cancel_lru_locks osc
4963 # exceed atime_diff and access file
4965 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
4966 error "can't udpate atime"
4968 local atime_cli=$(stat -c %X $DIR/$tfile)
4969 echo "client atime: $atime_cli"
4970 # allow atime update to be written to device
4971 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
4974 local ostdev=$(ostdevname 1)
4975 local fid=($(lfs getstripe -y $DIR/$tfile |
4976 awk '/l_fid:/ { print $2 }' | tr ':' ' '))
4977 local objpath="O/0/d$((${fid[1]} % 32))/$((${fid[1]}))"
4978 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
4980 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
4981 local atime_ost=$(do_facet ost1 "$cmd" |&
4982 awk -F'[: ]' '/atime:/ { print $4 }')
4983 (( atime_cli == atime_ost )) ||
4984 error "atime on client $atime_cli != ost $atime_ost"
4986 run_test 39r "lazy atime update on OST"
4988 test_39q() { # LU-8041
4989 local testdir=$DIR/$tdir
4991 multiop_bg_pause $testdir D_c || error "multiop failed"
4993 cancel_lru_locks mdc
4994 kill -USR1 $multipid
4995 local atime=$(stat -c %X $testdir)
4996 [ "$atime" -ne 0 ] || error "atime is zero"
4998 run_test 39q "close won't zero out atime"
5001 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5002 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5003 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5004 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5005 error "$tfile is not 4096 bytes in size"
5007 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5011 small_write $DIR/f41 18
5013 run_test 41 "test small file write + fstat ====================="
5015 count_ost_writes() {
5016 lctl get_param -n ${OSC}.*.stats |
5017 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5018 END { printf("%0.0f", writes) }'
5025 BG_DIRTY_RATIO_SAVE=10
5026 MAX_BG_DIRTY_RATIO=25
5030 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5031 # dirty_ratio, dirty_background_ratio
5032 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5033 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5034 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5035 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5037 # if file not here, we are a 2.4 kernel
5038 kill -CONT `pidof kupdated`
5043 # setup the trap first, so someone cannot exit the test at the
5044 # exact wrong time and mess up a machine
5045 trap start_writeback EXIT
5046 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5047 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5048 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5049 sysctl -w vm.dirty_writeback_centisecs=0
5050 sysctl -w vm.dirty_writeback_centisecs=0
5051 # save and increase /proc/sys/vm/dirty_ratio
5052 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5053 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5054 # save and increase /proc/sys/vm/dirty_background_ratio
5055 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5056 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5058 # if file not here, we are a 2.4 kernel
5059 kill -STOP `pidof kupdated`
5063 # ensure that all stripes have some grant before we test client-side cache
5065 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5066 dd if=/dev/zero of=$i bs=4k count=1
5071 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5072 # file truncation, and file removal.
5074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5077 cancel_lru_locks $OSC
5079 sync; sleep 1; sync # just to be safe
5080 BEFOREWRITES=`count_ost_writes`
5081 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5082 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5083 AFTERWRITES=`count_ost_writes`
5084 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5085 error "$BEFOREWRITES < $AFTERWRITES"
5088 run_test 42a "ensure that we don't flush on close"
5091 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5094 cancel_lru_locks $OSC
5097 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5098 BEFOREWRITES=$(count_ost_writes)
5099 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
5100 AFTERWRITES=$(count_ost_writes)
5101 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5102 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5104 BEFOREWRITES=$(count_ost_writes)
5105 sync || error "sync: $?"
5106 AFTERWRITES=$(count_ost_writes)
5107 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5108 error "$BEFOREWRITES < $AFTERWRITES on sync"
5110 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5114 run_test 42b "test destroy of file with cached dirty data ======"
5116 # if these tests just want to test the effect of truncation,
5117 # they have to be very careful. consider:
5118 # - the first open gets a {0,EOF}PR lock
5119 # - the first write conflicts and gets a {0, count-1}PW
5120 # - the rest of the writes are under {count,EOF}PW
5121 # - the open for truncate tries to match a {0,EOF}PR
5122 # for the filesize and cancels the PWs.
5123 # any number of fixes (don't get {0,EOF} on open, match
5124 # composite locks, do smarter file size management) fix
5125 # this, but for now we want these tests to verify that
5126 # the cancellation with truncate intent works, so we
5127 # start the file with a full-file pw lock to match against
5128 # until the truncate.
5133 cancel_lru_locks $OSC
5135 # prime the file with 0,EOF PW to match
5139 # now the real test..
5140 dd if=/dev/zero of=$file bs=1024 count=100
5141 BEFOREWRITES=`count_ost_writes`
5142 $TRUNCATE $file $offset
5143 cancel_lru_locks $OSC
5144 AFTERWRITES=`count_ost_writes`
5149 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5152 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5153 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5156 run_test 42c "test partial truncate of file with cached dirty data"
5159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5162 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5163 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5166 run_test 42d "test complete truncate of file with cached dirty data"
5168 test_42e() { # bug22074
5169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5171 local TDIR=$DIR/${tdir}e
5172 local pages=16 # hardcoded 16 pages, don't change it.
5173 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5174 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5178 test_mkdir $DIR/${tdir}e
5179 $LFS setstripe -c 1 $TDIR
5180 createmany -o $TDIR/f $files
5182 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5184 # we assume that with $OSTCOUNT files, at least one of them will
5185 # be allocated on OST0.
5186 warmup_files=$((OSTCOUNT * max_dirty_mb))
5187 createmany -o $TDIR/w $warmup_files
5189 # write a large amount of data into one file and sync, to get good
5190 # avail_grant number from OST.
5191 for ((i=0; i<$warmup_files; i++)); do
5192 idx=$($LFS getstripe -i $TDIR/w$i)
5193 [ $idx -ne 0 ] && continue
5194 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5197 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5199 $LCTL get_param $proc_osc0/cur_dirty_bytes
5200 $LCTL get_param $proc_osc0/cur_grant_bytes
5202 # create as much dirty pages as we can while not to trigger the actual
5203 # RPCs directly. but depends on the env, VFS may trigger flush during this
5204 # period, hopefully we are good.
5205 for ((i=0; i<$warmup_files; i++)); do
5206 idx=$($LFS getstripe -i $TDIR/w$i)
5207 [ $idx -ne 0 ] && continue
5208 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5210 $LCTL get_param $proc_osc0/cur_dirty_bytes
5211 $LCTL get_param $proc_osc0/cur_grant_bytes
5213 # perform the real test
5214 $LCTL set_param $proc_osc0/rpc_stats 0
5215 for ((;i<$files; i++)); do
5216 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5217 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5220 $LCTL get_param $proc_osc0/rpc_stats
5223 local have_ppr=false
5224 $LCTL get_param $proc_osc0/rpc_stats |
5225 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5226 # skip lines until we are at the RPC histogram data
5227 [ "$PPR" == "pages" ] && have_ppr=true && continue
5228 $have_ppr || continue
5230 # we only want the percent stat for < 16 pages
5231 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5233 percent=$((percent + WPCT))
5234 if [[ $percent -gt 15 ]]; then
5235 error "less than 16-pages write RPCs" \
5242 run_test 42e "verify sub-RPC writes are not done synchronously"
5244 test_43A() { # was test_43
5245 test_mkdir $DIR/$tdir
5246 cp -p /bin/ls $DIR/$tdir/$tfile
5247 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5249 # give multiop a chance to open
5252 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5254 # Wait for multiop to exit
5257 run_test 43A "execution of file opened for write should return -ETXTBSY"
5260 test_mkdir $DIR/$tdir
5261 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5262 $DIR/$tdir/sleep 60 &
5264 # Make sure exec of $tdir/sleep wins race with truncate
5266 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5269 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5274 test_mkdir $DIR/$tdir
5275 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5276 $DIR/$tdir/sleep 60 &
5278 # Make sure exec of $tdir/sleep wins race with truncate
5280 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5283 run_test 43b "truncate of file being executed should return -ETXTBSY"
5286 local testdir="$DIR/$tdir"
5289 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5290 ( cd $testdir && md5sum -c )
5292 run_test 43c "md5sum of copy into lustre"
5294 test_44A() { # was test_44
5295 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5297 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5298 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5300 run_test 44A "zero length read from a sparse stripe"
5303 local nstripe=$($LFS getstripe -c -d $DIR)
5304 [ -z "$nstripe" ] && skip "can't get stripe info"
5305 [[ $nstripe -gt $OSTCOUNT ]] &&
5306 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5308 local stride=$($LFS getstripe -S -d $DIR)
5309 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5310 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5313 OFFSETS="0 $((stride/2)) $((stride-1))"
5314 for offset in $OFFSETS; do
5315 for i in $(seq 0 $((nstripe-1))); do
5316 local GLOBALOFFSETS=""
5318 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5319 local myfn=$DIR/d44a-$size
5320 echo "--------writing $myfn at $size"
5321 ll_sparseness_write $myfn $size ||
5322 error "ll_sparseness_write"
5323 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5324 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5325 error "ll_sparseness_verify $GLOBALOFFSETS"
5327 for j in $(seq 0 $((nstripe-1))); do
5329 size=$((((j + $nstripe )*$stride + $offset)))
5330 ll_sparseness_write $myfn $size ||
5331 error "ll_sparseness_write"
5332 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5334 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5335 error "ll_sparseness_verify $GLOBALOFFSETS"
5340 run_test 44a "test sparse pwrite ==============================="
5344 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5350 before=`dirty_osc_total`
5351 echo executing "\"$*\""
5353 after=`dirty_osc_total`
5354 echo before $before, after $after
5357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5360 # Obtain grants from OST if it supports it
5361 echo blah > ${f}_grant
5364 do_dirty_record "echo blah > $f"
5365 [[ $before -eq $after ]] && error "write wasn't cached"
5366 do_dirty_record "> $f"
5367 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5368 do_dirty_record "echo blah > $f"
5369 [[ $before -eq $after ]] && error "write wasn't cached"
5370 do_dirty_record "sync"
5371 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5372 do_dirty_record "echo blah > $f"
5373 [[ $before -eq $after ]] && error "write wasn't cached"
5374 do_dirty_record "cancel_lru_locks osc"
5375 [[ $before -gt $after ]] ||
5376 error "lock cancellation didn't lower dirty count"
5379 run_test 45 "osc io page accounting ============================"
5381 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5382 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5383 # objects offset and an assert hit when an rpc was built with 1023's mapped
5384 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5386 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5391 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5393 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5394 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5398 run_test 46 "dirtying a previously written page ================"
5400 # test_47 is removed "Device nodes check" is moved to test_28
5402 test_48a() { # bug 2399
5403 [ "$mds1_FSTYPE" = "zfs" ] &&
5404 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5405 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5407 test_mkdir $DIR/$tdir
5409 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5410 test_mkdir $DIR/$tdir
5411 touch foo || error "'touch foo' failed after recreating cwd"
5413 touch .foo || error "'touch .foo' failed after recreating cwd"
5415 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5416 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5417 cd . || error "'cd .' failed after recreating cwd"
5418 mkdir . && error "'mkdir .' worked after recreating cwd"
5419 rmdir . && error "'rmdir .' worked after recreating cwd"
5420 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5421 cd .. || error "'cd ..' failed after recreating cwd"
5423 run_test 48a "Access renamed working dir (should return errors)="
5425 test_48b() { # bug 2399
5427 test_mkdir $DIR/$tdir
5429 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5430 touch foo && error "'touch foo' worked after removing cwd"
5431 mkdir foo && error "'mkdir foo' worked after removing cwd"
5432 touch .foo && error "'touch .foo' worked after removing cwd"
5433 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5434 ls . > /dev/null && error "'ls .' worked after removing cwd"
5435 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5436 mkdir . && error "'mkdir .' worked after removing cwd"
5437 rmdir . && error "'rmdir .' worked after removing cwd"
5438 ln -s . foo && error "'ln -s .' worked after removing cwd"
5439 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5441 run_test 48b "Access removed working dir (should return errors)="
5443 test_48c() { # bug 2350
5444 #lctl set_param debug=-1
5447 test_mkdir -p $DIR/$tdir/dir
5449 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5450 $TRACE touch foo && error "touch foo worked after removing cwd"
5451 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5452 touch .foo && error "touch .foo worked after removing cwd"
5453 mkdir .foo && error "mkdir .foo worked after removing cwd"
5454 $TRACE ls . && error "'ls .' worked after removing cwd"
5455 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5456 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5457 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5458 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5459 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5461 run_test 48c "Access removed working subdir (should return errors)"
5463 test_48d() { # bug 2350
5464 #lctl set_param debug=-1
5467 test_mkdir -p $DIR/$tdir/dir
5469 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5470 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5471 $TRACE touch foo && error "'touch foo' worked after removing parent"
5472 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5473 touch .foo && error "'touch .foo' worked after removing parent"
5474 mkdir .foo && error "mkdir .foo worked after removing parent"
5475 $TRACE ls . && error "'ls .' worked after removing parent"
5476 $TRACE ls .. && error "'ls ..' worked after removing parent"
5477 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5478 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5479 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5482 run_test 48d "Access removed parent subdir (should return errors)"
5484 test_48e() { # bug 4134
5485 #lctl set_param debug=-1
5488 test_mkdir -p $DIR/$tdir/dir
5490 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5491 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5492 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5493 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5494 # On a buggy kernel addition of "touch foo" after cd .. will
5495 # produce kernel oops in lookup_hash_it
5496 touch ../foo && error "'cd ..' worked after recreate parent"
5498 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5500 run_test 48e "Access to recreated parent subdir (should return errors)"
5503 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5504 skip "need MDS >= 2.13.55"
5505 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5506 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5507 skip "needs different host for mdt1 mdt2"
5508 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5510 $LFS mkdir -i0 $DIR/$tdir
5511 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5513 for d in sub1 sub2 sub3; do
5514 #define OBD_FAIL_OSD_REF_DEL 0x19c
5515 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5516 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5519 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5521 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5523 test_49() { # LU-1030
5524 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5525 remote_ost_nodsh && skip "remote OST with nodsh"
5527 # get ost1 size - $FSNAME-OST0000
5528 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5530 # write 800M at maximum
5531 [[ $ost1_size -lt 2 ]] && ost1_size=2
5532 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5534 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5535 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5538 # change max_pages_per_rpc while writing the file
5539 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5540 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5541 # loop until dd process exits
5542 while ps ax -opid | grep -wq $dd_pid; do
5543 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5544 sleep $((RANDOM % 5 + 1))
5546 # restore original max_pages_per_rpc
5547 $LCTL set_param $osc1_mppc=$orig_mppc
5548 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5550 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5554 test_mkdir $DIR/$tdir
5556 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5558 run_test 50 "special situations: /proc symlinks ==============="
5560 test_51a() { # was test_51
5561 # bug 1516 - create an empty entry right after ".." then split dir
5562 test_mkdir -c1 $DIR/$tdir
5563 touch $DIR/$tdir/foo
5564 $MCREATE $DIR/$tdir/bar
5566 createmany -m $DIR/$tdir/longfile 201
5568 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5569 $MCREATE $DIR/$tdir/longfile$FNUM
5574 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5576 run_test 51a "special situations: split htree with empty entry =="
5578 cleanup_print_lfs_df () {
5585 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5587 local dir=$DIR/$tdir
5588 local nrdirs=$((65536 + 100))
5590 # cleanup the directory
5593 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5597 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5598 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5599 [[ $numfree -lt $nrdirs ]] &&
5600 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5602 # need to check free space for the directories as well
5603 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5604 numfree=$(( blkfree / $(fs_inode_ksize) ))
5605 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5607 trap cleanup_print_lfs_df EXIT
5610 createmany -d $dir/d $nrdirs || {
5611 unlinkmany $dir/d $nrdirs
5612 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5616 nrdirs=$(ls -U $dir | wc -l)
5618 # unlink all but 100 subdirectories, then check it still works
5620 local delete=$((nrdirs - left))
5625 # for ldiskfs the nlink count should be 1, but this is OSD specific
5626 # and so this is listed for informational purposes only
5627 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5628 unlinkmany -d $dir/d $delete ||
5629 error "unlink of first $delete subdirs failed"
5631 echo "nlink between: $(stat -c %h $dir)"
5632 local found=$(ls -U $dir | wc -l)
5633 [ $found -ne $left ] &&
5634 error "can't find subdirs: found only $found, expected $left"
5636 unlinkmany -d $dir/d $delete $left ||
5637 error "unlink of second $left subdirs failed"
5638 # regardless of whether the backing filesystem tracks nlink accurately
5639 # or not, the nlink count shouldn't be more than "." and ".." here
5640 local after=$(stat -c %h $dir)
5641 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5642 echo "nlink after: $after"
5644 cleanup_print_lfs_df
5646 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5649 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5650 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5652 test_mkdir $DIR/$tdir
5653 createmany -o $DIR/$tdir/t- 1000
5654 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5655 for N in $(seq 0 $((OSTCOUNT - 1))); do
5656 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
5657 END { printf("%0.0f", objs) }' $TMP/$tfile)
5658 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5659 '($1 == '$N') { objs += 1 } \
5660 END { printf("%0.0f", objs) }')
5661 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
5663 unlinkmany $DIR/$tdir/t- 1000
5666 for N in $(seq 1 $((OSTCOUNT - 1))); do
5667 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
5668 error "OST $N has less objects vs OST $NLAST" \
5669 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5670 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
5671 error "OST $N has less objects vs OST $NLAST" \
5672 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5674 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
5675 error "OST $N has less #0 objects vs OST $NLAST" \
5676 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5677 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
5678 error "OST $N has less #0 objects vs OST $NLAST" \
5679 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5684 run_test 51d "check object distribution"
5687 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5688 skip_env "ldiskfs only test"
5691 test_mkdir -c1 $DIR/$tdir
5692 test_mkdir -c1 $DIR/$tdir/d0
5694 touch $DIR/$tdir/d0/foo
5695 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5696 error "file exceed 65000 nlink limit!"
5697 unlinkmany $DIR/$tdir/d0/f- 65001
5700 run_test 51e "check file nlink limit"
5703 test_mkdir $DIR/$tdir
5706 local ulimit_old=$(ulimit -n)
5707 local spare=20 # number of spare fd's for scripts/libraries, etc.
5708 local mdt=$($LFS getstripe -m $DIR/$tdir)
5709 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5711 echo "MDT$mdt numfree=$numfree, max=$max"
5712 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5713 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5714 while ! ulimit -n $((numfree + spare)); do
5715 numfree=$((numfree * 3 / 4))
5717 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5719 echo "left ulimit at $ulimit_old"
5722 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5723 unlinkmany $DIR/$tdir/f $numfree
5724 error "create+open $numfree files in $DIR/$tdir failed"
5726 ulimit -n $ulimit_old
5728 # if createmany exits at 120s there will be fewer than $numfree files
5729 unlinkmany $DIR/$tdir/f $numfree || true
5731 run_test 51f "check many open files limit"
5734 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5735 test_mkdir $DIR/$tdir
5736 touch $DIR/$tdir/foo
5737 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5738 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5739 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5740 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5741 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5743 echo foo >> $DIR/$tdir/foo || error "append foo failed"
5744 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5745 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
5747 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
5748 cp -r $DIR/$tdir $TMP/
5749 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
5751 run_test 52a "append-only flag test (should return errors)"
5754 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
5755 test_mkdir $DIR/$tdir
5756 touch $DIR/$tdir/foo
5757 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
5758 cat test > $DIR/$tdir/foo && error "cat test worked"
5759 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5760 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5761 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5763 echo foo >> $DIR/$tdir/foo && error "echo worked"
5764 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5765 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
5766 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
5767 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
5769 chattr -i $DIR/$tdir/foo || error "chattr failed"
5771 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
5773 run_test 52b "immutable flag test (should return errors) ======="
5776 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5777 remote_mds_nodsh && skip "remote MDS with nodsh"
5778 remote_ost_nodsh && skip "remote OST with nodsh"
5791 local support_last_seq=true
5793 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
5794 support_last_seq=false
5797 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
5799 for value in $(do_facet $SINGLEMDS \
5800 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
5801 param=$(echo ${value[0]} | cut -d "=" -f1)
5802 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
5804 if $support_last_seq; then
5805 param_seq=$(echo $param |
5806 sed -e s/prealloc_last_id/prealloc_last_seq/g)
5807 mds_last_seq=$(do_facet $SINGLEMDS \
5808 $LCTL get_param -n $param_seq)
5810 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
5812 ostnum=$(index_from_ostuuid ${ostname}_UUID)
5813 node=$(facet_active_host ost$((ostnum+1)))
5814 param="obdfilter.$ostname.last_id"
5815 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
5816 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
5817 ost_last_id=$ost_last
5819 if $support_last_seq; then
5820 ost_last_id=$(echo $ost_last |
5821 awk -F':' '{print $2}' |
5823 ost_last_seq=$(echo $ost_last |
5824 awk -F':' '{print $1}')
5825 [[ $ost_last_seq = $mds_last_seq ]] || continue
5828 if [[ $ost_last_id != $mds_last ]]; then
5829 error "$ost_last_id != $mds_last"
5836 $found || error "can not match last_seq/last_id for $mdtosc"
5839 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
5842 perl -MSocket -e ';' || skip "no Socket perl module installed"
5844 $SOCKETSERVER $DIR/socket ||
5845 error "$SOCKETSERVER $DIR/socket failed: $?"
5846 $SOCKETCLIENT $DIR/socket ||
5847 error "$SOCKETCLIENT $DIR/socket failed: $?"
5848 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
5850 run_test 54a "unix domain socket test =========================="
5856 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
5858 run_test 54b "char device works in lustre ======================"
5861 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
5862 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
5863 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
5865 for i in $(seq 3 7); do
5866 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
5875 loopdev="$DIR/loop54c"
5878 $UMOUNT $DIR/$tdir || rc=$?
5879 losetup -d $loopdev || true
5880 losetup -d $LOOPDEV || true
5881 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
5886 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5888 loopdev="$DIR/loop54c"
5891 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
5892 trap cleanup_54c EXIT
5893 mknod $loopdev b 7 $LOOPNUM
5894 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
5895 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
5896 losetup $loopdev $DIR/$tfile ||
5897 error "can't set up $loopdev for $DIR/$tfile"
5898 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
5899 test_mkdir $DIR/$tdir
5900 mount -t ext2 $loopdev $DIR/$tdir ||
5901 error "error mounting $loopdev on $DIR/$tdir"
5902 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
5905 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
5909 run_test 54c "block device works in lustre ====================="
5915 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
5917 run_test 54d "fifo device works in lustre ======================"
5922 cp -aL /dev/console $f
5923 echo $string > $f || error "echo $string to $f failed"
5925 run_test 54e "console/tty device works in lustre ======================"
5930 local dir=$DIR/$tdir
5933 test_mkdir -p $dir/dir
5934 for i in $(seq $numfiles); do
5936 touch $dir/dir/file$i
5939 local numcomp=$($LFS getstripe --component-count $dir)
5941 [[ $numcomp == 0 ]] && numcomp=1
5943 # test lfs getstripe with --recursive
5944 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5946 [[ $filenum -eq $((numfiles * 2)) ]] ||
5947 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5948 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5949 [[ $filenum -eq $numfiles ]] ||
5950 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5951 echo "$LFS getstripe showed obdidx or l_ost_idx"
5953 # test lfs getstripe with file instead of dir
5954 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5955 [[ $filenum -eq 1 ]] ||
5956 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5957 echo "$LFS getstripe file1 passed"
5959 #test lfs getstripe with --verbose
5960 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5961 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5962 error "$LFS getstripe --verbose $dir: "\
5963 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5964 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5965 error "$LFS getstripe $dir: showed lmm_magic"
5967 #test lfs getstripe with -v prints lmm_fid
5968 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5969 local countfids=$((numdirs + numfiles * numcomp))
5970 [[ $filenum -eq $countfids ]] ||
5971 error "$LFS getstripe -v $dir: "\
5972 "got $filenum want $countfids lmm_fid"
5973 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5974 error "$LFS getstripe $dir: showed lmm_fid by default"
5975 echo "$LFS getstripe --verbose passed"
5977 #check for FID information
5978 local fid1=$($LFS getstripe --fid $dir/file1)
5979 local fid2=$($LFS getstripe --verbose $dir/file1 |
5980 awk '/lmm_fid: / { print $2; exit; }')
5981 local fid3=$($LFS path2fid $dir/file1)
5983 [ "$fid1" != "$fid2" ] &&
5984 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5985 [ "$fid1" != "$fid3" ] &&
5986 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5987 echo "$LFS getstripe --fid passed"
5989 #test lfs getstripe with --obd
5990 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5991 error "$LFS getstripe --obd wrong_uuid: should return error"
5993 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5996 local obduuid=$(ostuuid_from_index $ostidx)
5997 local found=$($LFS getstripe -r --obd $obduuid $dir |
5998 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6000 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6001 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6003 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6006 [[ $found -eq $filenum ]] ||
6007 error "$LFS getstripe --obd: found $found expect $filenum"
6008 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6009 sed '/^[ ]*'${ostidx}'[ ]/d' |
6010 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6011 error "$LFS getstripe --obd: should not show file on other obd"
6012 echo "$LFS getstripe --obd passed"
6014 run_test 56a "check $LFS getstripe"
6017 local dir=$DIR/$tdir
6021 for i in $(seq $numdirs); do
6022 test_mkdir $dir/dir$i
6025 # test lfs getdirstripe default mode is non-recursion, which is
6026 # different from lfs getstripe
6027 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6029 [[ $dircnt -eq 1 ]] ||
6030 error "$LFS getdirstripe: found $dircnt, not 1"
6031 dircnt=$($LFS getdirstripe --recursive $dir |
6032 grep -c lmv_stripe_count)
6033 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6034 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6036 run_test 56b "check $LFS getdirstripe"
6039 remote_ost_nodsh && skip "remote OST with nodsh"
6042 local ost_name=$(ostname_from_index $ost_idx)
6043 local old_status=$(ost_dev_status $ost_idx)
6044 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6046 [[ -z "$old_status" ]] ||
6047 skip_env "OST $ost_name is in $old_status status"
6049 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6050 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6051 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6052 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6053 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6054 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6057 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6058 error "$LFS df -v showing inactive devices"
6061 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6063 [[ "$new_status" =~ "D" ]] ||
6064 error "$ost_name status is '$new_status', missing 'D'"
6065 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6066 [[ "$new_status" =~ "N" ]] ||
6067 error "$ost_name status is '$new_status', missing 'N'"
6069 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6070 [[ "$new_status" =~ "f" ]] ||
6071 error "$ost_name status is '$new_status', missing 'f'"
6074 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6075 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6076 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6077 [[ -z "$p" ]] && restore_lustre_params < $p || true
6080 new_status=$(ost_dev_status $ost_idx)
6081 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6082 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6083 # can't check 'f' as devices may actually be on flash
6085 run_test 56c "check 'lfs df' showing device status"
6088 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6089 local osts=$($LFS df -v $MOUNT | grep -c OST)
6093 (( mdts == MDSCOUNT )) ||
6094 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6095 (( osts == OSTCOUNT )) ||
6096 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6098 run_test 56d "'lfs df -v' prints only configured devices"
6103 local local_tdir="$1"
6104 local local_numfiles="$2"
6105 local local_numdirs="$3"
6106 local dir_params="$4"
6107 local dir_stripe_params="$5"
6109 if [ ! -d "$local_tdir" ] ; then
6110 test_mkdir -p $dir_stripe_params $local_tdir
6111 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6112 for i in $(seq $local_numfiles) ; do
6113 touch $local_tdir/file$i
6115 for i in $(seq $local_numdirs) ; do
6116 test_mkdir $dir_stripe_params $local_tdir/dir$i
6117 for j in $(seq $local_numfiles) ; do
6118 touch $local_tdir/dir$i/file$j
6124 setup_56_special() {
6126 local local_numfiles=$2
6127 local local_numdirs=$3
6129 setup_56 $local_tdir $local_numfiles $local_numdirs
6131 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6132 for i in $(seq $local_numfiles) ; do
6133 mknod $local_tdir/loop${i}b b 7 $i
6134 mknod $local_tdir/null${i}c c 1 3
6135 ln -s $local_tdir/file1 $local_tdir/link${i}
6137 for i in $(seq $local_numdirs) ; do
6138 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6139 mknod $local_tdir/dir$i/null${i}c c 1 3
6140 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6146 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6147 local expected=$(($NUMDIRS + 2))
6149 setup_56 $dir $NUMFILES $NUMDIRS
6151 # test lfs find with -name
6152 for i in $(seq $NUMFILES) ; do
6153 local nums=$($LFS find -name "*$i" $dir | wc -l)
6155 [ $nums -eq $expected ] ||
6156 error "lfs find -name '*$i' $dir wrong: "\
6157 "found $nums, expected $expected"
6160 run_test 56g "check lfs find -name"
6163 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6164 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6166 setup_56 $dir $NUMFILES $NUMDIRS
6168 # test lfs find with ! -name
6169 for i in $(seq $NUMFILES) ; do
6170 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6172 [ $nums -eq $expected ] ||
6173 error "lfs find ! -name '*$i' $dir wrong: "\
6174 "found $nums, expected $expected"
6177 run_test 56h "check lfs find ! -name"
6180 local dir=$DIR/$tdir
6184 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6187 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6189 run_test 56i "check 'lfs find -ost UUID' skips directories"
6192 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6194 setup_56_special $dir $NUMFILES $NUMDIRS
6196 local expected=$((NUMDIRS + 1))
6197 local cmd="$LFS find -type d $dir"
6198 local nums=$($cmd | wc -l)
6200 [ $nums -eq $expected ] ||
6201 error "'$cmd' wrong: found $nums, expected $expected"
6203 run_test 56j "check lfs find -type d"
6206 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6208 setup_56_special $dir $NUMFILES $NUMDIRS
6210 local expected=$(((NUMDIRS + 1) * NUMFILES))
6211 local cmd="$LFS find -type f $dir"
6212 local nums=$($cmd | wc -l)
6214 [ $nums -eq $expected ] ||
6215 error "'$cmd' wrong: found $nums, expected $expected"
6217 run_test 56k "check lfs find -type f"
6220 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6222 setup_56_special $dir $NUMFILES $NUMDIRS
6224 local expected=$((NUMDIRS + NUMFILES))
6225 local cmd="$LFS find -type b $dir"
6226 local nums=$($cmd | wc -l)
6228 [ $nums -eq $expected ] ||
6229 error "'$cmd' wrong: found $nums, expected $expected"
6231 run_test 56l "check lfs find -type b"
6234 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6236 setup_56_special $dir $NUMFILES $NUMDIRS
6238 local expected=$((NUMDIRS + NUMFILES))
6239 local cmd="$LFS find -type c $dir"
6240 local nums=$($cmd | wc -l)
6241 [ $nums -eq $expected ] ||
6242 error "'$cmd' wrong: found $nums, expected $expected"
6244 run_test 56m "check lfs find -type c"
6247 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 l $dir"
6252 local nums=$($cmd | wc -l)
6254 [ $nums -eq $expected ] ||
6255 error "'$cmd' wrong: found $nums, expected $expected"
6257 run_test 56n "check lfs find -type l"
6260 local dir=$DIR/$tdir
6262 setup_56 $dir $NUMFILES $NUMDIRS
6263 utime $dir/file1 > /dev/null || error "utime (1)"
6264 utime $dir/file2 > /dev/null || error "utime (2)"
6265 utime $dir/dir1 > /dev/null || error "utime (3)"
6266 utime $dir/dir2 > /dev/null || error "utime (4)"
6267 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6268 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6271 local nums=$($LFS find -mtime +0 $dir | wc -l)
6273 [ $nums -eq $expected ] ||
6274 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6277 cmd="$LFS find -mtime 0 $dir"
6278 nums=$($cmd | wc -l)
6279 [ $nums -eq $expected ] ||
6280 error "'$cmd' wrong: found $nums, expected $expected"
6282 run_test 56o "check lfs find -mtime for old files"
6285 local dir=$DIR/$tdir
6289 # just to make sure there is something that won't be found
6291 touch $dir/$tfile.now
6293 for age in year week day hour min; do
6294 count=$((count + 1))
6296 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6297 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6298 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6300 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6301 local nums=$($cmd | wc -l)
6302 [ $nums -eq $expected ] ||
6303 error "'$cmd' wrong: found $nums, expected $expected"
6305 cmd="$LFS find $dir -atime $count${age:0:1}"
6306 nums=$($cmd | wc -l)
6307 [ $nums -eq $expected ] ||
6308 error "'$cmd' wrong: found $nums, expected $expected"
6312 cmd="$LFS find $dir -ctime +1s -type f"
6313 nums=$($cmd | wc -l)
6314 (( $nums == $count * 2 + 1)) ||
6315 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6317 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6319 test_newerXY_base() {
6322 local dir=$DIR/$tdir
6326 if [ $y == "t" ]; then
6327 if [ $x == "b" ]; then
6328 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6330 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6333 ref=$DIR/$tfile.newer.$x$y
6334 touch $ref || error "touch $ref failed"
6337 echo "before = $ref"
6339 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6341 if [ $y == "t" ]; then
6342 if [ $x == "b" ]; then
6343 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6345 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6348 negref=$DIR/$tfile.negnewer.$x$y
6349 touch $negref || error "touch $negref failed"
6352 echo "after = $negref"
6353 local cmd="$LFS find $dir -newer$x$y $ref"
6354 local nums=$(eval $cmd | wc -l)
6355 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6357 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6358 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6360 cmd="$LFS find $dir ! -newer$x$y $negref"
6361 nums=$(eval $cmd | wc -l)
6362 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6363 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6365 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6366 nums=$(eval $cmd | wc -l)
6367 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6368 error "'$cmd' wrong: found $nums between, expected $expected"; }
6374 test_newerXY_base "a" "a"
6375 test_newerXY_base "a" "m"
6376 test_newerXY_base "a" "c"
6377 test_newerXY_base "m" "a"
6378 test_newerXY_base "m" "m"
6379 test_newerXY_base "m" "c"
6380 test_newerXY_base "c" "a"
6381 test_newerXY_base "c" "m"
6382 test_newerXY_base "c" "c"
6384 [[ -n "$sles_version" ]] &&
6385 echo "skip timestamp tests on SLES, LU-13665" && return 0
6387 test_newerXY_base "a" "t"
6388 test_newerXY_base "m" "t"
6389 test_newerXY_base "c" "t"
6391 [[ $MDS1_VERSION -lt $(version_code 2.13.54) ||
6392 $CLIENT_VERSION -lt $(version_code 2.13.54) ]] &&
6393 ! btime_supported && echo "btime unsupported" && return 0
6395 test_newerXY_base "b" "b"
6396 test_newerXY_base "b" "t"
6398 run_test 56oc "check lfs find -newerXY work"
6401 local dir=$DIR/$tdir
6406 $LFS find $dir -btime -1d -type f
6413 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
6414 ! btime_supported && skip "btime unsupported on MDS"
6416 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6417 ! btime_supported && skip "btime unsupported on clients"
6419 local dir=$DIR/$tdir
6420 local ref=$DIR/$tfile.ref
6421 local negref=$DIR/$tfile.negref
6423 mkdir $dir || error "mkdir $dir failed"
6424 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6425 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6426 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6427 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6428 touch $ref || error "touch $ref failed"
6429 # sleep 3 seconds at least
6432 local before=$(do_facet mds1 date +%s)
6433 local skew=$(($(date +%s) - before + 1))
6435 if (( skew < 0 && skew > -5 )); then
6436 sleep $((0 - skew + 1))
6440 # Set the dir stripe params to limit files all on MDT0,
6441 # otherwise we need to calc the max clock skew between
6442 # the client and MDTs.
6443 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6445 touch $negref || error "touch $negref failed"
6447 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6448 local nums=$($cmd | wc -l)
6449 local expected=$(((NUMFILES + 1) * NUMDIRS))
6451 [ $nums -eq $expected ] ||
6452 error "'$cmd' wrong: found $nums, expected $expected"
6454 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6455 nums=$($cmd | wc -l)
6456 expected=$((NUMFILES + 1))
6457 [ $nums -eq $expected ] ||
6458 error "'$cmd' wrong: found $nums, expected $expected"
6460 [ $skew -lt 0 ] && return
6462 local after=$(do_facet mds1 date +%s)
6463 local age=$((after - before + 1 + skew))
6465 cmd="$LFS find $dir -btime -${age}s -type f"
6466 nums=$($cmd | wc -l)
6467 expected=$(((NUMFILES + 1) * NUMDIRS))
6469 echo "Clock skew between client and server: $skew, age:$age"
6470 [ $nums -eq $expected ] ||
6471 error "'$cmd' wrong: found $nums, expected $expected"
6473 expected=$(($NUMDIRS + 1))
6474 cmd="$LFS find $dir -btime -${age}s -type d"
6475 nums=$($cmd | wc -l)
6476 [ $nums -eq $expected ] ||
6477 error "'$cmd' wrong: found $nums, expected $expected"
6478 rm -f $ref $negref || error "Failed to remove $ref $negref"
6480 run_test 56od "check lfs find -btime with units"
6483 [ $RUNAS_ID -eq $UID ] &&
6484 skip_env "RUNAS_ID = UID = $UID -- skipping"
6486 local dir=$DIR/$tdir
6488 setup_56 $dir $NUMFILES $NUMDIRS
6489 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6491 local expected=$NUMFILES
6492 local cmd="$LFS find -uid $RUNAS_ID $dir"
6493 local nums=$($cmd | wc -l)
6495 [ $nums -eq $expected ] ||
6496 error "'$cmd' wrong: found $nums, expected $expected"
6498 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6499 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6500 nums=$($cmd | wc -l)
6501 [ $nums -eq $expected ] ||
6502 error "'$cmd' wrong: found $nums, expected $expected"
6504 run_test 56p "check lfs find -uid and ! -uid"
6507 [ $RUNAS_ID -eq $UID ] &&
6508 skip_env "RUNAS_ID = UID = $UID -- skipping"
6510 local dir=$DIR/$tdir
6512 setup_56 $dir $NUMFILES $NUMDIRS
6513 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6515 local expected=$NUMFILES
6516 local cmd="$LFS find -gid $RUNAS_GID $dir"
6517 local nums=$($cmd | wc -l)
6519 [ $nums -eq $expected ] ||
6520 error "'$cmd' wrong: found $nums, expected $expected"
6522 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6523 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6524 nums=$($cmd | wc -l)
6525 [ $nums -eq $expected ] ||
6526 error "'$cmd' wrong: found $nums, expected $expected"
6528 run_test 56q "check lfs find -gid and ! -gid"
6531 local dir=$DIR/$tdir
6533 setup_56 $dir $NUMFILES $NUMDIRS
6536 local cmd="$LFS find -size 0 -type f -lazy $dir"
6537 local nums=$($cmd | wc -l)
6539 [ $nums -eq $expected ] ||
6540 error "'$cmd' wrong: found $nums, expected $expected"
6541 cmd="$LFS find -size 0 -type f $dir"
6542 nums=$($cmd | wc -l)
6543 [ $nums -eq $expected ] ||
6544 error "'$cmd' wrong: found $nums, expected $expected"
6547 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6548 nums=$($cmd | wc -l)
6549 [ $nums -eq $expected ] ||
6550 error "'$cmd' wrong: found $nums, expected $expected"
6551 cmd="$LFS find ! -size 0 -type f $dir"
6552 nums=$($cmd | wc -l)
6553 [ $nums -eq $expected ] ||
6554 error "'$cmd' wrong: found $nums, expected $expected"
6556 echo "test" > $dir/$tfile
6557 echo "test2" > $dir/$tfile.2 && sync
6559 cmd="$LFS find -size 5 -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 5 -type f $dir"
6564 nums=$($cmd | wc -l)
6565 [ $nums -eq $expected ] ||
6566 error "'$cmd' wrong: found $nums, expected $expected"
6569 cmd="$LFS find -size +5 -type f -lazy $dir"
6570 nums=$($cmd | wc -l)
6571 [ $nums -eq $expected ] ||
6572 error "'$cmd' wrong: found $nums, expected $expected"
6573 cmd="$LFS find -size +5 -type f $dir"
6574 nums=$($cmd | wc -l)
6575 [ $nums -eq $expected ] ||
6576 error "'$cmd' wrong: found $nums, expected $expected"
6579 cmd="$LFS find -size +0 -type f -lazy $dir"
6580 nums=$($cmd | wc -l)
6581 [ $nums -eq $expected ] ||
6582 error "'$cmd' wrong: found $nums, expected $expected"
6583 cmd="$LFS find -size +0 -type f $dir"
6584 nums=$($cmd | wc -l)
6585 [ $nums -eq $expected ] ||
6586 error "'$cmd' wrong: found $nums, expected $expected"
6589 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6590 nums=$($cmd | wc -l)
6591 [ $nums -eq $expected ] ||
6592 error "'$cmd' wrong: found $nums, expected $expected"
6593 cmd="$LFS find ! -size -5 -type f $dir"
6594 nums=$($cmd | wc -l)
6595 [ $nums -eq $expected ] ||
6596 error "'$cmd' wrong: found $nums, expected $expected"
6599 cmd="$LFS find -size -5 -type f -lazy $dir"
6600 nums=$($cmd | wc -l)
6601 [ $nums -eq $expected ] ||
6602 error "'$cmd' wrong: found $nums, expected $expected"
6603 cmd="$LFS find -size -5 -type f $dir"
6604 nums=$($cmd | wc -l)
6605 [ $nums -eq $expected ] ||
6606 error "'$cmd' wrong: found $nums, expected $expected"
6608 run_test 56r "check lfs find -size works"
6615 cancel_lru_locks $OSC
6617 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6618 local nums=$($cmd | wc -l)
6620 [ $nums -eq $expected ] ||
6621 error "'$cmd' wrong: found $nums, expected $expected"
6623 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6625 if (( rpcs_before + glimpses != rpcs_after )); then
6626 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6627 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
6629 if [[ $glimpses == 0 ]]; then
6630 error "'$cmd' should not send glimpse RPCs to OST"
6632 error "'$cmd' should send $glimpses glimpse RPCs to OST"
6638 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
6639 skip "MDS < 2.12.58 doesn't return LSOM data"
6640 local dir=$DIR/$tdir
6641 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
6643 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
6645 # statahead_agl may cause extra glimpse which confuses results. LU-13017
6646 $LCTL set_param -n llite.*.statahead_agl=0
6647 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
6649 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6650 # open and close all files to ensure LSOM is updated
6651 cancel_lru_locks $OSC
6652 find $dir -type f | xargs cat > /dev/null
6654 # expect_found glimpse_rpcs command_to_run
6655 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
6656 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
6657 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
6658 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
6660 echo "test" > $dir/$tfile
6661 echo "test2" > $dir/$tfile.2 && sync
6662 cancel_lru_locks $OSC
6663 cat $dir/$tfile $dir/$tfile.2 > /dev/null
6665 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
6666 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
6667 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
6668 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
6670 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
6671 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
6672 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
6673 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
6674 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
6675 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
6677 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6680 local dir=$DIR/$tdir
6681 local tmp=$TMP/$tfile.log
6684 test_mkdir -p $dir || error "failed to mkdir $dir"
6685 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
6686 error "failed to setstripe $dir/$tfile"
6687 mdt_idx=$($LFS getdirstripe -i $dir)
6688 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
6690 stack_trap "rm -f $tmp" EXIT
6691 $LFS find --size +100K --ost 0 $dir |& tee $tmp
6692 ! grep -q obd_uuid $tmp ||
6693 error "failed to find --size +100K --ost 0 $dir"
6694 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
6695 ! grep -q obd_uuid $tmp ||
6696 error "failed to find --size +100K --mdt $mdt_idx $dir"
6698 run_test 56rb "check lfs find --size --ost/--mdt works"
6701 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
6702 local dir=$DIR/$tdir
6705 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
6706 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
6707 (( $MDSCOUNT > 2 )) &&
6708 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
6709 mkdir $dir/$tdir-{1..10}
6710 touch $dir/$tfile-{1..10}
6712 found=$($LFS find $dir --mdt-count 2 | wc -l)
6714 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
6716 found=$($LFS find $dir -T +1 | wc -l)
6717 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
6718 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
6720 found=$($LFS find $dir --mdt-hash all_char | wc -l)
6722 (( $found == $expect )) || error "found $found all_char, expect $expect"
6724 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
6725 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
6726 (( $found == $expect )) || error "found $found all_char, expect $expect"
6728 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
6730 test_56s() { # LU-611 #LU-9369
6731 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
6733 local dir=$DIR/$tdir
6734 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
6736 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6737 for i in $(seq $NUMDIRS); do
6738 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
6741 local expected=$NUMDIRS
6742 local cmd="$LFS find -c $OSTCOUNT $dir"
6743 local nums=$($cmd | wc -l)
6745 [ $nums -eq $expected ] || {
6746 $LFS getstripe -R $dir
6747 error "'$cmd' wrong: found $nums, expected $expected"
6750 expected=$((NUMDIRS + onestripe))
6751 cmd="$LFS find -stripe-count +0 -type f $dir"
6752 nums=$($cmd | wc -l)
6753 [ $nums -eq $expected ] || {
6754 $LFS getstripe -R $dir
6755 error "'$cmd' wrong: found $nums, expected $expected"
6759 cmd="$LFS find -stripe-count 1 -type f $dir"
6760 nums=$($cmd | wc -l)
6761 [ $nums -eq $expected ] || {
6762 $LFS getstripe -R $dir
6763 error "'$cmd' wrong: found $nums, expected $expected"
6766 cmd="$LFS find -stripe-count -2 -type f $dir"
6767 nums=$($cmd | wc -l)
6768 [ $nums -eq $expected ] || {
6769 $LFS getstripe -R $dir
6770 error "'$cmd' wrong: found $nums, expected $expected"
6774 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
6775 nums=$($cmd | wc -l)
6776 [ $nums -eq $expected ] || {
6777 $LFS getstripe -R $dir
6778 error "'$cmd' wrong: found $nums, expected $expected"
6781 run_test 56s "check lfs find -stripe-count works"
6783 test_56t() { # LU-611 #LU-9369
6784 local dir=$DIR/$tdir
6786 setup_56 $dir 0 $NUMDIRS
6787 for i in $(seq $NUMDIRS); do
6788 $LFS setstripe -S 8M $dir/dir$i/$tfile
6791 local expected=$NUMDIRS
6792 local cmd="$LFS find -S 8M $dir"
6793 local nums=$($cmd | wc -l)
6795 [ $nums -eq $expected ] || {
6796 $LFS getstripe -R $dir
6797 error "'$cmd' wrong: found $nums, expected $expected"
6801 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
6803 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
6805 expected=$(((NUMDIRS + 1) * NUMFILES))
6806 cmd="$LFS find -stripe-size 512k -type f $dir"
6807 nums=$($cmd | wc -l)
6808 [ $nums -eq $expected ] ||
6809 error "'$cmd' wrong: found $nums, expected $expected"
6811 cmd="$LFS find -stripe-size +320k -type f $dir"
6812 nums=$($cmd | wc -l)
6813 [ $nums -eq $expected ] ||
6814 error "'$cmd' wrong: found $nums, expected $expected"
6816 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
6817 cmd="$LFS find -stripe-size +200k -type f $dir"
6818 nums=$($cmd | wc -l)
6819 [ $nums -eq $expected ] ||
6820 error "'$cmd' wrong: found $nums, expected $expected"
6822 cmd="$LFS find -stripe-size -640k -type f $dir"
6823 nums=$($cmd | wc -l)
6824 [ $nums -eq $expected ] ||
6825 error "'$cmd' wrong: found $nums, expected $expected"
6828 cmd="$LFS find -stripe-size 256k -type f $dir"
6829 nums=$($cmd | wc -l)
6830 [ $nums -eq $expected ] ||
6831 error "'$cmd' wrong: found $nums, expected $expected"
6833 cmd="$LFS find -stripe-size -320k -type f $dir"
6834 nums=$($cmd | wc -l)
6835 [ $nums -eq $expected ] ||
6836 error "'$cmd' wrong: found $nums, expected $expected"
6839 cmd="$LFS find -stripe-size 1024k -type f $dir"
6840 nums=$($cmd | wc -l)
6841 [ $nums -eq $expected ] ||
6842 error "'$cmd' wrong: found $nums, expected $expected"
6844 run_test 56t "check lfs find -stripe-size works"
6846 test_56u() { # LU-611
6847 local dir=$DIR/$tdir
6849 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
6851 if [[ $OSTCOUNT -gt 1 ]]; then
6852 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
6858 local expected=$(((NUMDIRS + 1) * NUMFILES))
6859 local cmd="$LFS find -stripe-index 0 -type f $dir"
6860 local nums=$($cmd | wc -l)
6862 [ $nums -eq $expected ] ||
6863 error "'$cmd' wrong: found $nums, expected $expected"
6866 cmd="$LFS find -stripe-index 1 -type f $dir"
6867 nums=$($cmd | wc -l)
6868 [ $nums -eq $expected ] ||
6869 error "'$cmd' wrong: found $nums, expected $expected"
6871 cmd="$LFS find ! -stripe-index 0 -type f $dir"
6872 nums=$($cmd | wc -l)
6873 [ $nums -eq $expected ] ||
6874 error "'$cmd' wrong: found $nums, expected $expected"
6877 # This should produce an error and not return any files
6878 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
6879 nums=$($cmd 2>/dev/null | wc -l)
6880 [ $nums -eq $expected ] ||
6881 error "'$cmd' wrong: found $nums, expected $expected"
6883 if [[ $OSTCOUNT -gt 1 ]]; then
6884 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
6885 cmd="$LFS find -stripe-index 0,1 -type f $dir"
6886 nums=$($cmd | wc -l)
6887 [ $nums -eq $expected ] ||
6888 error "'$cmd' wrong: found $nums, expected $expected"
6891 run_test 56u "check lfs find -stripe-index works"
6895 local dir=$DIR/$tdir
6897 setup_56 $dir $NUMFILES $NUMDIRS
6899 UUID=$(mdtuuid_from_index $mdt_idx $dir)
6900 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
6902 for file in $($LFS find -m $UUID $dir); do
6903 file_midx=$($LFS getstripe -m $file)
6904 [ $file_midx -eq $mdt_idx ] ||
6905 error "lfs find -m $UUID != getstripe -m $file_midx"
6908 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
6911 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6912 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6914 local dir=$DIR/$tdir
6916 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
6918 local stripe_size=$($LFS getstripe -S -d $dir) ||
6919 error "$LFS getstripe -S -d $dir failed"
6920 stripe_size=${stripe_size%% *}
6922 local file_size=$((stripe_size * OSTCOUNT))
6923 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
6924 local required_space=$((file_num * file_size))
6925 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
6927 [[ $free_space -le $((required_space / 1024)) ]] &&
6928 skip_env "need $required_space, have $free_space kbytes"
6931 local dd_count=$((file_size / dd_bs))
6933 # write data into the files
6938 for i in $(seq $NUMFILES); do
6940 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6941 error "write data into $file failed"
6943 for i in $(seq $NUMDIRS); do
6944 for j in $(seq $NUMFILES); do
6945 file=$dir/dir$i/file$j
6946 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6947 error "write data into $file failed"
6951 # $LFS_MIGRATE will fail if hard link migration is unsupported
6952 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
6953 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
6954 error "creating links to $dir/dir1/file1 failed"
6959 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
6962 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
6965 eval $cmd || error "$cmd failed"
6967 check_stripe_count $dir/file1 $expected
6969 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
6971 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
6972 # OST 1 if it is on OST 0. This file is small enough to
6973 # be on only one stripe.
6974 file=$dir/migr_1_ost
6975 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
6976 error "write data into $file failed"
6977 local obdidx=$($LFS getstripe -i $file)
6978 local oldmd5=$(md5sum $file)
6981 [[ $obdidx -eq 0 ]] && newobdidx=1
6982 cmd="$LFS migrate -i $newobdidx $file"
6984 eval $cmd || error "$cmd failed"
6986 local realobdix=$($LFS getstripe -i $file)
6987 local newmd5=$(md5sum $file)
6989 [[ $newobdidx -ne $realobdix ]] &&
6990 error "new OST is different (was=$obdidx, "\
6991 "wanted=$newobdidx, got=$realobdix)"
6992 [[ "$oldmd5" != "$newmd5" ]] &&
6993 error "md5sum differ: $oldmd5, $newmd5"
6997 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
6999 eval $cmd || error "$cmd failed"
7001 for j in $(seq $NUMFILES); do
7002 check_stripe_count $dir/dir1/file$j $expected
7005 # lfs_migrate works with lfs find
7006 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7007 $LFS_MIGRATE -y -c $expected"
7009 eval $cmd || error "$cmd failed"
7011 for i in $(seq 2 $NUMFILES); do
7012 check_stripe_count $dir/file$i $expected
7014 for i in $(seq 2 $NUMDIRS); do
7015 for j in $(seq $NUMFILES); do
7016 check_stripe_count $dir/dir$i/file$j $expected
7020 run_test 56w "check lfs_migrate -c stripe_count works"
7023 local file1=$DIR/$tdir/file1
7024 local create_pool=false
7025 local initial_pool=$($LFS getstripe -p $DIR)
7029 echo -n "Creating test dir..."
7030 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7033 echo -n "Creating test file..."
7034 touch $file1 || error "cannot create file"
7037 echo -n "Detecting existing pools..."
7038 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7040 if [ ${#pool_list[@]} -gt 0 ]; then
7041 echo "${pool_list[@]}"
7042 for thispool in "${pool_list[@]}"; do
7043 if [[ -z "$initial_pool" ||
7044 "$initial_pool" != "$thispool" ]]; then
7046 echo "Using existing pool '$pool'"
7051 echo "none detected."
7053 if [ -z "$pool" ]; then
7054 pool=${POOL:-testpool}
7055 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7056 echo -n "Creating pool '$pool'..."
7058 pool_add $pool &> /dev/null ||
7059 error "pool_add failed"
7062 echo -n "Adding target to pool..."
7063 pool_add_targets $pool 0 0 1 &> /dev/null ||
7064 error "pool_add_targets failed"
7068 echo -n "Setting pool using -p option..."
7069 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7070 error "migrate failed rc = $?"
7073 echo -n "Verifying test file is in pool after migrating..."
7074 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7075 error "file was not migrated to pool $pool"
7078 echo -n "Removing test file from pool '$pool'..."
7079 # "lfs migrate $file" won't remove the file from the pool
7080 # until some striping information is changed.
7081 $LFS migrate -c 1 $file1 &> /dev/null ||
7082 error "cannot remove from pool"
7083 [ "$($LFS getstripe -p $file1)" ] &&
7084 error "pool still set"
7087 echo -n "Setting pool using --pool option..."
7088 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7089 error "migrate failed rc = $?"
7094 if $create_pool; then
7095 destroy_test_pools 2> /dev/null ||
7096 error "destroy test pools failed"
7099 run_test 56wb "check lfs_migrate pool support"
7102 local file1="$DIR/$tdir/file1"
7109 echo -n "Creating test dir..."
7110 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7111 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7112 error "cannot set stripe by '-S 1M -c 1'"
7115 echo -n "Setting initial stripe for test file..."
7116 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7117 error "cannot set stripe"
7118 cur_ssize=$($LFS getstripe -S "$file1")
7119 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
7122 # File currently set to -S 512K -c 1
7124 # Ensure -c and -S options are rejected when -R is set
7125 echo -n "Verifying incompatible options are detected..."
7126 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
7127 error "incompatible -c and -R options not detected"
7128 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
7129 error "incompatible -S and -R options not detected"
7132 # Ensure unrecognized options are passed through to 'lfs migrate'
7133 echo -n "Verifying -S option is passed through to lfs migrate..."
7134 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
7135 error "migration failed"
7136 cur_ssize=$($LFS getstripe -S "$file1")
7137 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
7140 # File currently set to -S 1M -c 1
7142 # Ensure long options are supported
7143 echo -n "Verifying long options supported..."
7144 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
7145 error "long option without argument not supported"
7146 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
7147 error "long option with argument not supported"
7148 cur_ssize=$($LFS getstripe -S "$file1")
7149 [ $cur_ssize -eq 524288 ] ||
7150 error "migrate --stripe-size $cur_ssize != 524288"
7153 # File currently set to -S 512K -c 1
7155 if [ "$OSTCOUNT" -gt 1 ]; then
7156 echo -n "Verifying explicit stripe count can be set..."
7157 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
7158 error "migrate failed"
7159 cur_scount=$($LFS getstripe -c "$file1")
7160 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
7164 # File currently set to -S 512K -c 1 or -S 512K -c 2
7166 # Ensure parent striping is used if -R is set, and no stripe
7167 # count or size is specified
7168 echo -n "Setting stripe for parent directory..."
7169 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7170 error "cannot set stripe '-S 2M -c 1'"
7173 echo -n "Verifying restripe option uses parent stripe settings..."
7174 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7175 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7176 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
7177 error "migrate failed"
7178 cur_ssize=$($LFS getstripe -S "$file1")
7179 [ $cur_ssize -eq $parent_ssize ] ||
7180 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7181 cur_scount=$($LFS getstripe -c "$file1")
7182 [ $cur_scount -eq $parent_scount ] ||
7183 error "migrate -R stripe_count $cur_scount != $parent_scount"
7186 # File currently set to -S 1M -c 1
7188 # Ensure striping is preserved if -R is not set, and no stripe
7189 # count or size is specified
7190 echo -n "Verifying striping size preserved when not specified..."
7191 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7192 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7193 error "cannot set stripe on parent directory"
7194 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7195 error "migrate failed"
7196 cur_ssize=$($LFS getstripe -S "$file1")
7197 [ $cur_ssize -eq $orig_ssize ] ||
7198 error "migrate by default $cur_ssize != $orig_ssize"
7201 # Ensure file name properly detected when final option has no argument
7202 echo -n "Verifying file name properly detected..."
7203 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7204 error "file name interpreted as option argument"
7210 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7213 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7215 local file1=$DIR/$tdir/file1
7217 echo -n "Creating test dir..."
7218 test_mkdir $DIR/$tdir || error "cannot create dir"
7221 echo -n "Creating test file..."
7225 # Ensure 'lfs migrate' will fail by using a non-existent option,
7226 # and make sure rsync is not called to recover
7227 echo -n "Make sure --no-rsync option works..."
7228 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7229 grep -q 'refusing to fall back to rsync' ||
7230 error "rsync was called with --no-rsync set"
7233 # Ensure rsync is called without trying 'lfs migrate' first
7234 echo -n "Make sure --rsync option works..."
7235 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7236 grep -q 'falling back to rsync' &&
7237 error "lfs migrate was called with --rsync set"
7240 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
7241 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
7242 grep -q 'at the same time' ||
7243 error "--rsync and --no-rsync accepted concurrently"
7249 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7255 test_mkdir $td || error "cannot create $td"
7256 touch $tf || error "cannot touch $tf"
7258 echo -n "Make sure --non-direct|-D works..."
7259 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7260 grep -q "lfs migrate --non-direct" ||
7261 error "--non-direct option cannot work correctly"
7262 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7263 grep -q "lfs migrate -D" ||
7264 error "-D option cannot work correctly"
7267 run_test 56we "check lfs_migrate --non-direct|-D support"
7270 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7271 check_swap_layouts_support
7273 local dir=$DIR/$tdir
7274 local ref1=/etc/passwd
7275 local file1=$dir/file1
7277 test_mkdir $dir || error "creating dir $dir"
7278 $LFS setstripe -c 2 $file1
7280 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7281 stripe=$($LFS getstripe -c $file1)
7282 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7283 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7288 run_test 56x "lfs migration support"
7291 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7292 check_swap_layouts_support
7294 local dir=$DIR/$tdir/$testnum
7298 local ref1=/etc/passwd
7299 local file1=$dir/file1
7301 $LFS setstripe -c 2 $file1
7303 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7305 local stripe=$($LFS getstripe -c $file1)
7307 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7308 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7313 run_test 56xa "lfs migration --block support"
7315 check_migrate_links() {
7317 local file1="$dir/file1"
7321 local total_count=$(($begin + $count - 1))
7322 local symlink_count=10
7325 if [ ! -f "$file1" ]; then
7326 echo -n "creating initial file..."
7327 $LFS setstripe -c 1 -S "512k" "$file1" ||
7328 error "cannot setstripe initial file"
7331 echo -n "creating symlinks..."
7332 for s in $(seq 1 $symlink_count); do
7333 ln -s "$file1" "$dir/slink$s" ||
7334 error "cannot create symlinks"
7338 echo -n "creating nonlinked files..."
7339 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7340 error "cannot create nonlinked files"
7345 if [ ! -f "$dir/file$total_count" ]; then
7346 echo -n "creating hard links $begin:$total_count..."
7347 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7348 /dev/null || error "cannot create hard links"
7352 echo -n "checking number of hard links listed in xattrs..."
7353 local fid=$($LFS getstripe -F "$file1")
7354 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7357 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7358 skip "hard link list has unexpected size, skipping test"
7360 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7361 error "link names should exceed xattrs size"
7364 echo -n "migrating files..."
7365 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
7367 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7370 # make sure all links have been properly migrated
7371 echo -n "verifying files..."
7372 fid=$($LFS getstripe -F "$file1") ||
7373 error "cannot get fid for file $file1"
7374 for i in $(seq 2 $total_count); do
7375 local fid2=$($LFS getstripe -F $dir/file$i)
7377 [ "$fid2" == "$fid" ] ||
7378 error "migrated hard link has mismatched FID"
7381 # make sure hard links were properly detected, and migration was
7382 # performed only once for the entire link set; nonlinked files should
7384 local actual=$(grep -c 'done' <<< "$migrate_out")
7385 local expected=$(($uniq_count + 1))
7387 [ "$actual" -eq "$expected" ] ||
7388 error "hard links individually migrated ($actual != $expected)"
7390 # make sure the correct number of hard links are present
7391 local hardlinks=$(stat -c '%h' "$file1")
7393 [ $hardlinks -eq $total_count ] ||
7394 error "num hard links $hardlinks != $total_count"
7401 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7402 skip "Need MDS version at least 2.10.55"
7404 local dir="$DIR/$tdir"
7406 test_mkdir "$dir" || error "cannot create dir $dir"
7408 echo "testing lfs migrate mode when all links fit within xattrs"
7409 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
7411 echo "testing rsync mode when all links fit within xattrs"
7412 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
7414 echo "testing lfs migrate mode when all links do not fit within xattrs"
7415 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
7417 echo "testing rsync mode when all links do not fit within xattrs"
7418 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
7420 chown -R $RUNAS_ID $dir
7421 echo "testing non-root lfs migrate mode when not all links are in xattr"
7422 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
7427 run_test 56xb "lfs migration hard link support"
7430 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7432 local dir="$DIR/$tdir"
7434 test_mkdir "$dir" || error "cannot create dir $dir"
7436 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7437 echo -n "Setting initial stripe for 20MB test file..."
7438 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7439 error "cannot setstripe 20MB file"
7441 echo -n "Sizing 20MB test file..."
7442 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
7444 echo -n "Verifying small file autostripe count is 1..."
7445 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
7446 error "cannot migrate 20MB file"
7447 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7448 error "cannot get stripe for $dir/20mb"
7449 [ $stripe_count -eq 1 ] ||
7450 error "unexpected stripe count $stripe_count for 20MB file"
7454 # Test 2: File is small enough to fit within the available space on
7455 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7456 # have at least an additional 1KB for each desired stripe for test 3
7457 echo -n "Setting stripe for 1GB test file..."
7458 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7460 echo -n "Sizing 1GB test file..."
7461 # File size is 1GB + 3KB
7462 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7465 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7466 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7467 if (( avail > 524288 * OSTCOUNT )); then
7468 echo -n "Migrating 1GB file..."
7469 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7470 error "cannot migrate 1GB file"
7472 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7473 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7474 error "cannot getstripe for 1GB file"
7475 [ $stripe_count -eq 2 ] ||
7476 error "unexpected stripe count $stripe_count != 2"
7480 # Test 3: File is too large to fit within the available space on
7481 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7482 if [ $OSTCOUNT -ge 3 ]; then
7483 # The required available space is calculated as
7484 # file size (1GB + 3KB) / OST count (3).
7485 local kb_per_ost=349526
7487 echo -n "Migrating 1GB file with limit..."
7488 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7489 error "cannot migrate 1GB file with limit"
7492 stripe_count=$($LFS getstripe -c "$dir/1gb")
7493 echo -n "Verifying 1GB autostripe count with limited space..."
7494 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7495 error "unexpected stripe count $stripe_count (min 3)"
7502 run_test 56xc "lfs migration autostripe"
7505 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7507 local dir=$DIR/$tdir
7508 local f_mgrt=$dir/$tfile.mgrt
7509 local f_yaml=$dir/$tfile.yaml
7510 local f_copy=$dir/$tfile.copy
7511 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7512 local layout_copy="-c 2 -S 2M -i 1"
7513 local yamlfile=$dir/yamlfile
7514 local layout_before;
7517 test_mkdir "$dir" || error "cannot create dir $dir"
7518 $LFS setstripe $layout_yaml $f_yaml ||
7519 error "cannot setstripe $f_yaml with layout $layout_yaml"
7520 $LFS getstripe --yaml $f_yaml > $yamlfile
7521 $LFS setstripe $layout_copy $f_copy ||
7522 error "cannot setstripe $f_copy with layout $layout_copy"
7524 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7526 # 1. test option --yaml
7527 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7528 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7529 layout_before=$(get_layout_param $f_yaml)
7530 layout_after=$(get_layout_param $f_mgrt)
7531 [ "$layout_after" == "$layout_before" ] ||
7532 error "lfs_migrate --yaml: $layout_after != $layout_before"
7534 # 2. test option --copy
7535 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7536 error "cannot migrate $f_mgrt with --copy $f_copy"
7537 layout_before=$(get_layout_param $f_copy)
7538 layout_after=$(get_layout_param $f_mgrt)
7539 [ "$layout_after" == "$layout_before" ] ||
7540 error "lfs_migrate --copy: $layout_after != $layout_before"
7542 run_test 56xd "check lfs_migrate --yaml and --copy support"
7545 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7547 local dir=$DIR/$tdir
7548 local f_comp=$dir/$tfile
7549 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7550 local layout_before=""
7551 local layout_after=""
7553 test_mkdir "$dir" || error "cannot create dir $dir"
7554 $LFS setstripe $layout $f_comp ||
7555 error "cannot setstripe $f_comp with layout $layout"
7556 layout_before=$(get_layout_param $f_comp)
7557 dd if=/dev/zero of=$f_comp bs=1M count=4
7559 # 1. migrate a comp layout file by lfs_migrate
7560 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7561 layout_after=$(get_layout_param $f_comp)
7562 [ "$layout_before" == "$layout_after" ] ||
7563 error "lfs_migrate: $layout_before != $layout_after"
7565 # 2. migrate a comp layout file by lfs migrate
7566 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7567 layout_after=$(get_layout_param $f_comp)
7568 [ "$layout_before" == "$layout_after" ] ||
7569 error "lfs migrate: $layout_before != $layout_after"
7571 run_test 56xe "migrate a composite layout file"
7574 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7576 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7577 skip "Need server version at least 2.13.53"
7579 local dir=$DIR/$tdir
7580 local f_comp=$dir/$tfile
7581 local layout="-E 1M -c1 -E -1 -c2"
7585 test_mkdir "$dir" || error "cannot create dir $dir"
7586 $LFS setstripe $layout $f_comp ||
7587 error "cannot setstripe $f_comp with layout $layout"
7588 fid_before=$($LFS getstripe --fid $f_comp)
7589 dd if=/dev/zero of=$f_comp bs=1M count=4
7591 # 1. migrate a comp layout file to a comp layout
7592 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7593 fid_after=$($LFS getstripe --fid $f_comp)
7594 [ "$fid_before" == "$fid_after" ] ||
7595 error "comp-to-comp migrate: $fid_before != $fid_after"
7597 # 2. migrate a comp layout file to a plain layout
7598 $LFS migrate -c2 $f_comp ||
7599 error "cannot migrate $f_comp by lfs migrate"
7600 fid_after=$($LFS getstripe --fid $f_comp)
7601 [ "$fid_before" == "$fid_after" ] ||
7602 error "comp-to-plain migrate: $fid_before != $fid_after"
7604 # 3. migrate a plain layout file to a comp layout
7605 $LFS migrate $layout $f_comp ||
7606 error "cannot migrate $f_comp by lfs migrate"
7607 fid_after=$($LFS getstripe --fid $f_comp)
7608 [ "$fid_before" == "$fid_after" ] ||
7609 error "plain-to-comp migrate: $fid_before != $fid_after"
7611 run_test 56xf "FID is not lost during migration of a composite layout file"
7614 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
7615 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
7618 local dir=$DIR/$tdir
7622 test_mkdir -p $dir || error "creating dir $dir"
7623 touch $f1 || error "creating std file $f1"
7624 $MULTIOP $f2 H2c || error "creating released file $f2"
7626 # a directory can be raid0, so ask only for files
7627 res=$($LFS find $dir -L raid0 -type f | wc -l)
7628 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
7630 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
7631 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
7633 # only files can be released, so no need to force file search
7634 res=$($LFS find $dir -L released)
7635 [[ $res == $f2 ]] || error "search released: found $res != $f2"
7637 res=$($LFS find $dir -type f \! -L released)
7638 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
7640 run_test 56y "lfs find -L raid0|released"
7642 test_56z() { # LU-4824
7643 # This checks to make sure 'lfs find' continues after errors
7644 # There are two classes of errors that should be caught:
7645 # - If multiple paths are provided, all should be searched even if one
7647 # - If errors are encountered during the search, it should not terminate
7649 local dir=$DIR/$tdir
7653 for i in d{0..9}; do
7655 touch $dir/$i/$tfile
7657 $LFS find $DIR/non_existent_dir $dir &&
7658 error "$LFS find did not return an error"
7659 # Make a directory unsearchable. This should NOT be the last entry in
7660 # directory order. Arbitrarily pick the 6th entry
7661 chmod 700 $($LFS find $dir -type d | sed '6!d')
7663 $RUNAS $LFS find $DIR/non_existent $dir
7664 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
7666 # The user should be able to see 10 directories and 9 files
7667 (( count == 19 )) ||
7668 error "$LFS find found $count != 19 entries after error"
7670 run_test 56z "lfs find should continue after an error"
7672 test_56aa() { # LU-5937
7673 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
7675 local dir=$DIR/$tdir
7678 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
7680 createmany -o $dir/striped_dir/${tfile}- 1024
7681 local dirs=$($LFS find --size +8k $dir/)
7683 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
7685 run_test 56aa "lfs find --size under striped dir"
7687 test_56ab() { # LU-10705
7688 test_mkdir $DIR/$tdir
7689 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
7690 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
7691 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
7692 # Flush writes to ensure valid blocks. Need to be more thorough for
7693 # ZFS, since blocks are not allocated/returned to client immediately.
7695 wait_zfs_commit ost1 2
7696 cancel_lru_locks osc
7699 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
7701 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
7703 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
7704 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
7706 rm -f $DIR/$tdir/$tfile.[123]
7708 run_test 56ab "lfs find --blocks"
7712 local dir="$DIR/$tdir"
7713 local perms=(001 002 003 004 005 006 007
7714 010 020 030 040 050 060 070
7715 100 200 300 400 500 600 700
7716 111 222 333 444 555 666 777)
7717 local perm_minus=(8 8 4 8 4 4 2
7721 local perm_slash=(8 8 12 8 12 12 14
7724 16 16 24 16 24 24 28)
7727 for perm in ${perms[*]}; do
7728 touch "$dir/$tfile.$perm"
7729 chmod $perm "$dir/$tfile.$perm"
7732 for ((i = 0; i < ${#perms[*]}; i++)); do
7733 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
7735 error "lfs find -perm ${perms[i]}:"\
7738 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
7739 (( $num == ${perm_minus[i]} )) ||
7740 error "lfs find -perm -${perms[i]}:"\
7741 "$num != ${perm_minus[i]}"
7743 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
7744 (( $num == ${perm_slash[i]} )) ||
7745 error "lfs find -perm /${perms[i]}:"\
7746 "$num != ${perm_slash[i]}"
7749 run_test 56aca "check lfs find -perm with octal representation"
7752 local dir=$DIR/$tdir
7753 # p is the permission of write and execute for user, group and other
7754 # without the umask. It is used to test +wx.
7755 local p=$(printf "%o" "$((0333 & ~$(umask)))")
7756 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
7757 local symbolic=(+t a+t u+t g+t o+t
7763 o=r,ug+o,u+w u=r,a+u,u+w
7764 g=r,ugo=g,u+w u+x,+X +X
7765 u+x,u+X u+X u+x,g+X o+r,+X
7769 for perm in ${perms[*]}; do
7770 touch "$dir/$tfile.$perm"
7771 chmod $perm "$dir/$tfile.$perm"
7774 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
7775 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
7778 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
7781 run_test 56acb "check lfs find -perm with symbolic representation"
7784 local dir=$DIR/$tdir
7785 local tests="17777 787 789 abcd
7786 ug=uu ug=a ug=gu uo=ou urw
7790 for err in $tests; do
7791 if $LFS find $dir -perm $err 2>/dev/null; then
7792 error "lfs find -perm $err: parsing should have failed"
7796 run_test 56acc "check parsing error for lfs find -perm"
7799 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
7800 skip "Need MDS version at least 2.10.50"
7802 # Create composite files with one component
7803 local dir=$DIR/$tdir
7805 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
7806 # Create composite files with three components
7807 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
7808 # Create non-composite files
7809 createmany -o $dir/${tfile}- 10
7811 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
7813 [[ $nfiles == 10 ]] ||
7814 error "lfs find -E 1M found $nfiles != 10 files"
7816 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
7817 [[ $nfiles == 25 ]] ||
7818 error "lfs find ! -E 1M found $nfiles != 25 files"
7820 # All files have a component that starts at 0
7821 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
7822 [[ $nfiles == 35 ]] ||
7823 error "lfs find --component-start 0 - $nfiles != 35 files"
7825 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
7826 [[ $nfiles == 15 ]] ||
7827 error "lfs find --component-start 2M - $nfiles != 15 files"
7829 # All files created here have a componenet that does not starts at 2M
7830 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
7831 [[ $nfiles == 35 ]] ||
7832 error "lfs find ! --component-start 2M - $nfiles != 35 files"
7834 # Find files with a specified number of components
7835 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
7836 [[ $nfiles == 15 ]] ||
7837 error "lfs find --component-count 3 - $nfiles != 15 files"
7839 # Remember non-composite files have a component count of zero
7840 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
7841 [[ $nfiles == 10 ]] ||
7842 error "lfs find --component-count 0 - $nfiles != 10 files"
7844 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
7845 [[ $nfiles == 20 ]] ||
7846 error "lfs find ! --component-count 3 - $nfiles != 20 files"
7848 # All files have a flag called "init"
7849 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
7850 [[ $nfiles == 35 ]] ||
7851 error "lfs find --component-flags init - $nfiles != 35 files"
7853 # Multi-component files will have a component not initialized
7854 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
7855 [[ $nfiles == 15 ]] ||
7856 error "lfs find !--component-flags init - $nfiles != 15 files"
7861 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
7864 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
7865 skip "Need MDS version at least 2.10.57"
7875 # create mirrored directories and mirrored files
7876 mkdir $td || error "mkdir $td failed"
7877 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
7878 createmany -o $tf- 10 || error "create $tf- failed"
7880 for i in $(seq 2); do
7882 mkdir $dir || error "mkdir $dir failed"
7883 $LFS mirror create -N$((3 + i)) $dir ||
7884 error "create mirrored dir $dir failed"
7885 createmany -o $dir/$tfile- 10 ||
7886 error "create $dir/$tfile- failed"
7889 # change the states of some mirrored files
7891 for i in $(seq 2); do
7893 for j in $(seq 4 9); do
7894 echo foo > $dir/$tfile-$j
7898 # find mirrored files with specific mirror count
7899 cmd="$LFS find --mirror-count 3 --type f $td"
7900 nfiles=$($cmd | wc -l)
7901 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
7903 cmd="$LFS find ! --mirror-count 3 --type f $td"
7904 nfiles=$($cmd | wc -l)
7905 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
7907 cmd="$LFS find --mirror-count +2 --type f $td"
7908 nfiles=$($cmd | wc -l)
7909 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7911 cmd="$LFS find --mirror-count -6 --type f $td"
7912 nfiles=$($cmd | wc -l)
7913 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7915 # find mirrored files with specific file state
7916 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
7917 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
7919 cmd="$LFS find --mirror-state=ro --type f $td"
7920 nfiles=$($cmd | wc -l)
7921 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
7923 cmd="$LFS find ! --mirror-state=ro --type f $td"
7924 nfiles=$($cmd | wc -l)
7925 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7927 cmd="$LFS find --mirror-state=wp --type f $td"
7928 nfiles=$($cmd | wc -l)
7929 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7931 cmd="$LFS find ! --mirror-state=sp --type f $td"
7932 nfiles=$($cmd | wc -l)
7933 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7935 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
7937 test_56da() { # LU-14179
7938 local path=$DIR/$tdir
7943 local longdir=$(str_repeat 'a' 255)
7945 for i in {1..15}; do
7952 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
7957 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
7960 touch $(str_repeat 'f' 255)
7962 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
7963 error "lfs find reported an error"
7967 run_test 56da "test lfs find with long paths"
7970 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7971 # note test will not do anything if MDS is not local
7972 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7973 skip_env "ldiskfs only test"
7975 remote_mds_nodsh && skip "remote MDS with nodsh"
7977 local MNTDEV="osd*.*MDT*.mntdev"
7978 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
7979 [ -z "$DEV" ] && error "can't access $MNTDEV"
7980 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
7981 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
7982 error "can't access $DEV"
7983 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
7984 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
7988 run_test 57a "verify MDS filesystem created with large inodes =="
7991 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7992 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7993 skip_env "ldiskfs only test"
7995 remote_mds_nodsh && skip "remote MDS with nodsh"
7997 local dir=$DIR/$tdir
8000 local fileN=$dir/f$filecount
8002 rm -rf $dir || error "removing $dir"
8004 local mdtidx=$($LFS getstripe -m $dir)
8005 local mdtname=MDT$(printf %04x $mdtidx)
8006 local facet=mds$((mdtidx + 1))
8008 echo "mcreating $filecount files"
8009 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
8011 # verify that files do not have EAs yet
8012 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
8013 error "$file1 has an EA"
8014 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
8015 error "$fileN has an EA"
8019 df $dir #make sure we get new statfs data
8020 local mdsfree=$(do_facet $facet \
8021 lctl get_param -n osd*.*$mdtname.kbytesfree)
8022 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8025 echo "opening files to create objects/EAs"
8026 for file in $(seq -f $dir/f%g 1 $filecount); do
8027 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
8028 error "opening $file"
8031 # verify that files have EAs now
8032 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
8033 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
8035 sleep 1 #make sure we get new statfs data
8037 local mdsfree2=$(do_facet $facet \
8038 lctl get_param -n osd*.*$mdtname.kbytesfree)
8039 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8041 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
8042 if [ "$mdsfree" != "$mdsfree2" ]; then
8043 error "MDC before $mdcfree != after $mdcfree2"
8045 echo "MDC before $mdcfree != after $mdcfree2"
8046 echo "unable to confirm if MDS has large inodes"
8051 run_test 57b "default LOV EAs are stored inside large inodes ==="
8054 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8055 [ -z "$(which wiretest 2>/dev/null)" ] &&
8056 skip_env "could not find wiretest"
8060 run_test 58 "verify cross-platform wire constants =============="
8063 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8065 echo "touch 130 files"
8066 createmany -o $DIR/f59- 130
8068 unlinkmany $DIR/f59- 130
8070 # wait for commitment of removal
8071 wait_delete_completed
8073 run_test 59 "verify cancellation of llog records async ========="
8075 TEST60_HEAD="test_60 run $RANDOM"
8077 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8078 remote_mgs_nodsh && skip "remote MGS with nodsh"
8079 do_facet mgs "! which run-llog.sh &> /dev/null" &&
8080 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
8081 skip_env "missing subtest run-llog.sh"
8083 log "$TEST60_HEAD - from kernel mode"
8084 do_facet mgs "$LCTL dk > /dev/null"
8085 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
8086 do_facet mgs $LCTL dk > $TMP/$tfile
8088 # LU-6388: test llog_reader
8089 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
8090 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
8091 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
8092 skip_env "missing llog_reader"
8093 local fstype=$(facet_fstype mgs)
8094 [ $fstype != ldiskfs -a $fstype != zfs ] &&
8095 skip_env "Only for ldiskfs or zfs type mgs"
8097 local mntpt=$(facet_mntpt mgs)
8098 local mgsdev=$(mgsdevname 1)
8110 #get fid and record list
8111 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
8113 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
8115 #remount mgs as ldiskfs or zfs type
8116 stop mgs || error "stop mgs failed"
8117 mount_fstype mgs || error "remount mgs failed"
8118 for ((i = 0; i < ${#fid_list[@]}; i++)); do
8121 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
8122 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
8127 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
8129 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
8131 echo "obj_file is $obj_file"
8132 do_facet mgs $llog_reader $obj_file
8134 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
8135 awk '{ print $3 }' | sed -e "s/^type=//g")
8136 if [ $rec_type != $rec ]; then
8137 echo "FAILED test_60a wrong record type $rec_type," \
8143 #check obj path if record type is LLOG_LOGID_MAGIC
8144 if [ "$rec" == "1064553b" ]; then
8145 path=$(do_facet mgs $llog_reader $obj_file |
8146 grep "path=" | awk '{ print $NF }' |
8147 sed -e "s/^path=//g")
8148 if [ $obj_file != $mntpt/$path ]; then
8149 echo "FAILED test_60a wrong obj path" \
8150 "$montpt/$path, should be $obj_file"
8157 #restart mgs before "error", otherwise it will block the next test
8158 stop mgs || error "stop mgs failed"
8159 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
8160 $pass || error "test failed, see FAILED test_60a messages for specifics"
8162 run_test 60a "llog_test run from kernel module and test llog_reader"
8164 test_60b() { # bug 6411
8165 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8168 LLOG_COUNT=$(do_facet mgs dmesg |
8169 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
8170 /llog_[a-z]*.c:[0-9]/ {
8182 [[ $LLOG_COUNT -gt 120 ]] &&
8183 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
8185 run_test 60b "limit repeated messages from CERROR/CWARN"
8188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8190 echo "create 5000 files"
8191 createmany -o $DIR/f60c- 5000
8192 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
8193 lctl set_param fail_loc=0x80000137
8194 unlinkmany $DIR/f60c- 5000
8195 lctl set_param fail_loc=0
8197 run_test 60c "unlink file when mds full"
8200 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8202 SAVEPRINTK=$(lctl get_param -n printk)
8203 # verify "lctl mark" is even working"
8204 MESSAGE="test message ID $RANDOM $$"
8205 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8206 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
8208 lctl set_param printk=0 || error "set lnet.printk failed"
8209 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
8210 MESSAGE="new test message ID $RANDOM $$"
8211 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
8212 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8213 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
8215 lctl set_param -n printk="$SAVEPRINTK"
8217 run_test 60d "test printk console message masking"
8220 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8221 remote_mds_nodsh && skip "remote MDS with nodsh"
8224 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
8225 do_facet mds1 lctl set_param fail_loc=0x15b
8228 run_test 60e "no space while new llog is being created"
8231 local old_path=$($LCTL get_param -n debug_path)
8233 stack_trap "$LCTL set_param debug_path=$old_path"
8234 stack_trap "rm -f $TMP/$tfile*"
8235 rm -f $TMP/$tfile* 2> /dev/null
8236 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8237 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
8238 test_mkdir $DIR/$tdir
8239 # retry in case the open is cached and not released
8240 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
8241 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
8245 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
8247 run_test 60f "change debug_path works"
8253 test_mkdir -c $MDSCOUNT $DIR/$tdir
8258 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
8259 -c $MDSCOUNT $DIR/$tdir/subdir$index \
8261 mkdir $DIR/$tdir/subdir$index 2>/dev/null
8262 rmdir $DIR/$tdir/subdir$index 2>/dev/null
8263 index=$((index + 1))
8269 for i in {0..100}; do
8270 # define OBD_FAIL_OSD_TXN_START 0x19a
8271 local index=$((i % MDSCOUNT + 1))
8273 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
8280 for i in $(seq $MDSCOUNT); do
8281 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
8284 mkdir $DIR/$tdir/new || error "mkdir failed"
8285 rmdir $DIR/$tdir/new || error "rmdir failed"
8287 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
8289 for i in $(seq $MDSCOUNT); do
8290 wait_update_facet mds$i "$LCTL get_param -n \
8291 mdd.$(facet_svc mds$i).lfsck_namespace |
8292 awk '/^status/ { print \\\$2 }'" "completed"
8295 ls -R $DIR/$tdir || error "ls failed"
8296 rm -rf $DIR/$tdir || error "rmdir failed"
8298 run_test 60g "transaction abort won't cause MDT hung"
8301 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
8302 skip "Need MDS version at least 2.12.52"
8303 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
8307 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
8308 #define OBD_FAIL_MDS_STRIPE_FID 0x189
8309 for fail_loc in 0x80000188 0x80000189; do
8310 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
8311 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
8312 error "mkdir $dir-$fail_loc failed"
8313 for i in {0..10}; do
8314 # create may fail on missing stripe
8315 echo $i > $DIR/$tdir-$fail_loc/$i
8317 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8318 error "getdirstripe $tdir-$fail_loc failed"
8319 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
8320 error "migrate $tdir-$fail_loc failed"
8321 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8322 error "getdirstripe $tdir-$fail_loc failed"
8323 pushd $DIR/$tdir-$fail_loc
8325 echo $f | cmp $f - || error "$f data mismatch"
8328 rm -rf $DIR/$tdir-$fail_loc
8331 run_test 60h "striped directory with missing stripes can be accessed"
8333 function t60i_load() {
8335 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
8336 $LCTL set_param fail_loc=0x131c fail_val=1
8337 for ((i=0; i<5000; i++)); do
8338 touch $DIR/$tdir/f$i
8343 changelog_register || error "changelog_register failed"
8344 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
8345 changelog_users $SINGLEMDS | grep -q $cl_user ||
8346 error "User $cl_user not found in changelog_users"
8347 changelog_chmask "ALL"
8350 for((i=0; i<100; i++)); do
8351 changelog_dump >/dev/null ||
8352 error "can't read changelog"
8356 changelog_deregister || error "changelog_deregister failed"
8357 $LCTL set_param fail_loc=0
8359 run_test 60i "llog: new record vs reader race"
8362 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8365 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
8366 cancel_lru_locks osc
8367 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
8370 run_test 61a "mmap() writes don't make sync hang ================"
8373 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
8375 run_test 61b "mmap() of unstriped file is successful"
8377 # bug 2330 - insufficient obd_match error checking causes LBUG
8379 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8383 cancel_lru_locks osc
8384 lctl set_param fail_loc=0x405
8385 cat $f && error "cat succeeded, expect -EIO"
8386 lctl set_param fail_loc=0
8388 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
8389 # match every page all of the time.
8390 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
8392 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
8393 # Though this test is irrelevant anymore, it helped to reveal some
8394 # other grant bugs (LU-4482), let's keep it.
8395 test_63a() { # was test_63
8396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8398 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
8400 for i in `seq 10` ; do
8401 dd if=/dev/zero of=$DIR/f63 bs=8k &
8407 rm -f $DIR/f63 || true
8409 run_test 63a "Verify oig_wait interruption does not crash ======="
8411 # bug 2248 - async write errors didn't return to application on sync
8412 # bug 3677 - async write errors left page locked
8414 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8417 lctl set_param debug=-1
8419 # ensure we have a grant to do async writes
8420 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
8423 sync # sync lest earlier test intercept the fail_loc
8425 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8426 lctl set_param fail_loc=0x80000406
8427 $MULTIOP $DIR/$tfile Owy && \
8428 error "sync didn't return ENOMEM"
8429 sync; sleep 2; sync # do a real sync this time to flush page
8430 lctl get_param -n llite.*.dump_page_cache | grep locked && \
8431 error "locked page left in cache after async error" || true
8434 run_test 63b "async write errors should be returned to fsync ==="
8437 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8440 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
8442 run_test 64a "verify filter grant calculations (in kernel) ====="
8445 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8447 sh oos.sh $MOUNT || error "oos.sh failed: $?"
8449 run_test 64b "check out-of-space detection on client"
8452 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
8454 run_test 64c "verify grant shrink"
8460 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
8463 # this does exactly what osc_request.c:osc_announce_cached() does in
8464 # order to calculate max amount of grants to ask from server
8468 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
8469 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
8471 ((rpc_in_flight++));
8472 nrpages=$((nrpages * rpc_in_flight))
8474 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
8476 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
8478 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
8479 local undirty=$((nrpages * PAGE_SIZE))
8481 local max_extent_pages
8482 max_extent_pages=$(import_param $tgt grant_max_extent_size)
8483 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
8484 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
8485 local grant_extent_tax
8486 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8488 undirty=$((undirty + nrextents * grant_extent_tax))
8493 # this is size of unit for grant allocation. It should be equal to
8494 # what tgt_grant.c:tgt_grant_chunk() calculates
8498 local grant_extent_tax
8500 max_brw_size=$(import_param $tgt max_brw_size)
8502 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8504 echo $(((max_brw_size + grant_extent_tax) * 2))
8508 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
8509 skip "OST < 2.10.55 doesn't limit grants enough"
8511 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
8513 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
8514 skip "no grant_param connect flag"
8516 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
8518 $LCTL set_param -n -n debug="$OLDDEBUG" || true
8519 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
8522 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
8523 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
8525 $LFS setstripe $DIR/$tfile -i 0 -c 1
8526 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
8529 while kill -0 $ddpid; do
8530 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8532 if [[ $cur_grant -gt $max_cur_granted ]]; then
8534 error "cur_grant $cur_grant > $max_cur_granted"
8540 run_test 64d "check grant limit exceed"
8546 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8548 ((cur_grants == expected)) ||
8549 error "$msg: grants mismatch: $cur_grants, expected $expected"
8553 echo $((($1 + $2 - 1) & ~($2 - 1)))
8557 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8558 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
8559 skip "Need OSS version at least 2.11.56"
8561 # Remount client to reset grant
8562 remount_client $MOUNT || error "failed to remount client"
8563 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8565 local init_grants=$(import_param $osc_tgt initial_grant)
8567 check_grants $osc_tgt $init_grants "init grants"
8569 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
8570 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8571 local gbs=$(import_param $osc_tgt grant_block_size)
8573 # write random number of bytes from max_brw_size / 4 to max_brw_size
8574 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
8575 # align for direct io
8576 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
8577 # round to grant consumption unit
8578 local wb_round_up=$(round_up_p2 $write_bytes gbs)
8580 local grants=$((wb_round_up + extent_tax))
8582 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8584 # define OBD_FAIL_TGT_NO_GRANT 0x725
8585 # make the server not grant more back
8586 do_facet ost1 $LCTL set_param fail_loc=0x725
8587 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
8589 do_facet ost1 $LCTL set_param fail_loc=0
8591 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
8593 rm -f $DIR/$tfile || error "rm failed"
8595 # Remount client to reset grant
8596 remount_client $MOUNT || error "failed to remount client"
8597 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8599 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8601 # define OBD_FAIL_TGT_NO_GRANT 0x725
8602 # make the server not grant more back
8603 do_facet ost1 $LCTL set_param fail_loc=0x725
8604 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
8605 do_facet ost1 $LCTL set_param fail_loc=0
8607 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
8609 run_test 64e "check grant consumption (no grant allocation)"
8612 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8614 # Remount client to reset grant
8615 remount_client $MOUNT || error "failed to remount client"
8616 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8618 local init_grants=$(import_param $osc_tgt initial_grant)
8619 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
8620 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8621 local gbs=$(import_param $osc_tgt grant_block_size)
8622 local chunk=$(grant_chunk $osc_tgt)
8624 # write random number of bytes from max_brw_size / 4 to max_brw_size
8625 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
8626 # align for direct io
8627 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
8628 # round to grant consumption unit
8629 local wb_round_up=$(round_up_p2 $write_bytes gbs)
8631 local grants=$((wb_round_up + extent_tax))
8633 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8634 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
8635 error "error writing to $DIR/$tfile"
8637 check_grants $osc_tgt $((init_grants - grants + chunk)) \
8638 "direct io with grant allocation"
8640 rm -f $DIR/$tfile || error "rm failed"
8642 # Remount client to reset grant
8643 remount_client $MOUNT || error "failed to remount client"
8644 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8646 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8648 local cmd="oO_WRONLY:w${write_bytes}_yc"
8650 $MULTIOP $DIR/$tfile $cmd &
8654 check_grants $osc_tgt $((init_grants - grants)) \
8655 "buffered io, not write rpc"
8657 kill -USR1 $MULTIPID
8660 check_grants $osc_tgt $((init_grants - grants + chunk)) \
8661 "buffered io, one RPC"
8663 run_test 64f "check grant consumption (with grant allocation)"
8665 # bug 1414 - set/get directories' stripe info
8667 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8669 test_mkdir $DIR/$tdir
8671 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
8673 run_test 65a "directory with no stripe info"
8676 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8678 test_mkdir $DIR/$tdir
8679 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8681 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8684 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
8686 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
8689 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8690 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
8692 test_mkdir $DIR/$tdir
8693 local stripesize=$($LFS getstripe -S $DIR/$tdir)
8695 $LFS setstripe -S $((stripesize * 4)) -i 1 \
8696 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
8698 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
8700 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
8703 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8705 test_mkdir $DIR/$tdir
8706 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
8707 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8709 if [[ $STRIPECOUNT -le 0 ]]; then
8711 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
8712 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
8713 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
8715 sc=$(($STRIPECOUNT - 1))
8717 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
8718 touch $DIR/$tdir/f4 $DIR/$tdir/f5
8719 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
8720 error "lverify failed"
8722 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
8725 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8727 test_mkdir $DIR/$tdir
8729 $LFS setstripe $DIR/$tdir || error "setstripe"
8730 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
8731 error "no stripe info failed"
8733 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
8735 run_test 65e "directory setstripe defaults"
8738 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8740 test_mkdir $DIR/${tdir}f
8741 $RUNAS $LFS setstripe $DIR/${tdir}f &&
8742 error "setstripe succeeded" || true
8744 run_test 65f "dir setstripe permission (should return error) ==="
8747 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8749 test_mkdir $DIR/$tdir
8750 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8752 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8753 error "setstripe -S failed"
8754 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
8755 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
8756 error "delete default stripe failed"
8758 run_test 65g "directory setstripe -d"
8761 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8763 test_mkdir $DIR/$tdir
8764 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8766 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8767 error "setstripe -S failed"
8768 test_mkdir $DIR/$tdir/dd1
8769 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
8770 error "stripe info inherit failed"
8772 run_test 65h "directory stripe info inherit ===================="
8775 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8777 save_layout_restore_at_exit $MOUNT
8779 # bug6367: set non-default striping on root directory
8780 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
8782 # bug12836: getstripe on -1 default directory striping
8783 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
8785 # bug12836: getstripe -v on -1 default directory striping
8786 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
8788 # bug12836: new find on -1 default directory striping
8789 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
8791 run_test 65i "various tests to set root directory striping"
8793 test_65j() { # bug6367
8794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8798 # if we aren't already remounting for each test, do so for this test
8799 if [ "$I_MOUNTED" = "yes" ]; then
8800 cleanup || error "failed to unmount"
8804 save_layout_restore_at_exit $MOUNT
8806 $LFS setstripe -d $MOUNT || error "setstripe failed"
8808 run_test 65j "set default striping on root directory (bug 6367)="
8812 wait_delete_completed
8813 do_facet $SINGLEMDS "lctl set_param -n \
8814 osp.$ost*MDT0000.max_create_count=$max_count"
8815 do_facet $SINGLEMDS "lctl set_param -n \
8816 osp.$ost*MDT0000.create_count=$count"
8817 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
8818 echo $INACTIVE_OSC "is Activate"
8820 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
8823 test_65k() { # bug11679
8824 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8825 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8826 remote_mds_nodsh && skip "remote MDS with nodsh"
8828 local disable_precreate=true
8829 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
8830 disable_precreate=false
8832 echo "Check OST status: "
8833 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
8834 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
8836 for OSC in $MDS_OSCS; do
8837 echo $OSC "is active"
8838 do_facet $SINGLEMDS lctl --device %$OSC activate
8841 for INACTIVE_OSC in $MDS_OSCS; do
8842 local ost=$(osc_to_ost $INACTIVE_OSC)
8843 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
8844 lov.*md*.target_obd |
8845 awk -F: /$ost/'{ print $1 }' | head -n 1)
8848 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
8849 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
8851 echo "Deactivate: " $INACTIVE_OSC
8852 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
8854 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
8855 osp.$ost*MDT0000.create_count")
8856 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
8857 osp.$ost*MDT0000.max_create_count")
8858 $disable_precreate &&
8859 do_facet $SINGLEMDS "lctl set_param -n \
8860 osp.$ost*MDT0000.max_create_count=0"
8862 for idx in $(seq 0 $((OSTCOUNT - 1))); do
8863 [ -f $DIR/$tdir/$idx ] && continue
8864 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
8865 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
8867 error "setstripe $idx should succeed"; }
8868 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
8870 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
8873 do_facet $SINGLEMDS "lctl set_param -n \
8874 osp.$ost*MDT0000.max_create_count=$max_count"
8875 do_facet $SINGLEMDS "lctl set_param -n \
8876 osp.$ost*MDT0000.create_count=$count"
8877 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
8878 echo $INACTIVE_OSC "is Activate"
8880 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
8883 run_test 65k "validate manual striping works properly with deactivated OSCs"
8885 test_65l() { # bug 12836
8886 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8888 test_mkdir -p $DIR/$tdir/test_dir
8889 $LFS setstripe -c -1 $DIR/$tdir/test_dir
8890 $LFS find -mtime -1 $DIR/$tdir >/dev/null
8892 run_test 65l "lfs find on -1 stripe dir ========================"
8895 local layout=$(save_layout $MOUNT)
8896 $RUNAS $LFS setstripe -c 2 $MOUNT && {
8897 restore_layout $MOUNT $layout
8898 error "setstripe should fail by non-root users"
8902 run_test 65m "normal user can't set filesystem default stripe"
8905 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
8906 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
8907 skip "Need MDS version at least 2.12.50"
8908 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
8910 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
8911 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
8912 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
8914 save_layout_restore_at_exit $MOUNT
8916 # new subdirectory under root directory should not inherit
8917 # the default layout from root
8918 local dir1=$MOUNT/$tdir-1
8919 mkdir $dir1 || error "mkdir $dir1 failed"
8920 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
8921 error "$dir1 shouldn't have LOV EA"
8923 # delete the default layout on root directory
8924 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
8926 local dir2=$MOUNT/$tdir-2
8927 mkdir $dir2 || error "mkdir $dir2 failed"
8928 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
8929 error "$dir2 shouldn't have LOV EA"
8931 # set a new striping pattern on root directory
8932 local def_stripe_size=$($LFS getstripe -S $MOUNT)
8933 local new_def_stripe_size=$((def_stripe_size * 2))
8934 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
8935 error "set stripe size on $MOUNT failed"
8937 # new file created in $dir2 should inherit the new stripe size from
8938 # the filesystem default
8939 local file2=$dir2/$tfile-2
8940 touch $file2 || error "touch $file2 failed"
8942 local file2_stripe_size=$($LFS getstripe -S $file2)
8943 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
8945 echo "file2_stripe_size: '$file2_stripe_size'"
8946 echo "new_def_stripe_size: '$new_def_stripe_size'"
8947 error "$file2 didn't inherit stripe size $new_def_stripe_size"
8950 local dir3=$MOUNT/$tdir-3
8951 mkdir $dir3 || error "mkdir $dir3 failed"
8952 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
8953 # the root layout, which is the actual default layout that will be used
8954 # when new files are created in $dir3.
8955 local dir3_layout=$(get_layout_param $dir3)
8956 local root_dir_layout=$(get_layout_param $MOUNT)
8957 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
8959 echo "dir3_layout: '$dir3_layout'"
8960 echo "root_dir_layout: '$root_dir_layout'"
8961 error "$dir3 should show the default layout from $MOUNT"
8964 # set OST pool on root directory
8965 local pool=$TESTNAME
8966 pool_add $pool || error "add $pool failed"
8967 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8968 error "add targets to $pool failed"
8970 $LFS setstripe -p $pool $MOUNT ||
8971 error "set OST pool on $MOUNT failed"
8973 # new file created in $dir3 should inherit the pool from
8974 # the filesystem default
8975 local file3=$dir3/$tfile-3
8976 touch $file3 || error "touch $file3 failed"
8978 local file3_pool=$($LFS getstripe -p $file3)
8979 [[ "$file3_pool" = "$pool" ]] ||
8980 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
8982 local dir4=$MOUNT/$tdir-4
8983 mkdir $dir4 || error "mkdir $dir4 failed"
8984 local dir4_layout=$(get_layout_param $dir4)
8985 root_dir_layout=$(get_layout_param $MOUNT)
8986 echo "$LFS getstripe -d $dir4"
8987 $LFS getstripe -d $dir4
8988 echo "$LFS getstripe -d $MOUNT"
8989 $LFS getstripe -d $MOUNT
8990 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
8992 echo "dir4_layout: '$dir4_layout'"
8993 echo "root_dir_layout: '$root_dir_layout'"
8994 error "$dir4 should show the default layout from $MOUNT"
8997 # new file created in $dir4 should inherit the pool from
8998 # the filesystem default
8999 local file4=$dir4/$tfile-4
9000 touch $file4 || error "touch $file4 failed"
9002 local file4_pool=$($LFS getstripe -p $file4)
9003 [[ "$file4_pool" = "$pool" ]] ||
9004 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
9006 # new subdirectory under non-root directory should inherit
9007 # the default layout from its parent directory
9008 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
9009 error "set directory layout on $dir4 failed"
9011 local dir5=$dir4/$tdir-5
9012 mkdir $dir5 || error "mkdir $dir5 failed"
9014 dir4_layout=$(get_layout_param $dir4)
9015 local dir5_layout=$(get_layout_param $dir5)
9016 [[ "$dir4_layout" = "$dir5_layout" ]] ||
9018 echo "dir4_layout: '$dir4_layout'"
9019 echo "dir5_layout: '$dir5_layout'"
9020 error "$dir5 should inherit the default layout from $dir4"
9023 # though subdir under ROOT doesn't inherit default layout, but
9024 # its sub dir/file should be created with default layout.
9025 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
9026 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
9027 skip "Need MDS version at least 2.12.59"
9029 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
9030 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
9031 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
9033 if [ $default_lmv_hash == "none" ]; then
9034 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
9036 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
9037 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
9040 $LFS setdirstripe -D -c 2 $MOUNT ||
9041 error "setdirstripe -D -c 2 failed"
9042 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
9043 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
9044 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
9046 run_test 65n "don't inherit default layout from root for new subdirectories"
9048 # bug 2543 - update blocks count on client
9050 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9053 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
9054 sync; sync_all_data; sync; sync_all_data
9055 cancel_lru_locks osc
9056 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
9057 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
9059 run_test 66 "update inode blocks count on client ==============="
9062 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
9066 swapon -s | awk '($1 == "'$1'") { print $4 }'
9069 # bug5265, obdfilter oa2dentry return -ENOENT
9070 # #define OBD_FAIL_SRV_ENOENT 0x217
9072 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9073 remote_ost_nodsh && skip "remote OST with nodsh"
9076 $LFS setstripe -c 1 -i 0 $f
9078 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
9080 do_facet ost1 lctl set_param fail_loc=0x217
9081 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
9082 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
9084 do_facet ost1 lctl set_param fail_loc=0
9085 $DIRECTIO write $f 0 2 || error "write error"
9087 cancel_lru_locks osc
9088 $DIRECTIO read $f 0 1 || error "read error"
9090 do_facet ost1 lctl set_param fail_loc=0x217
9091 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
9093 do_facet ost1 lctl set_param fail_loc=0
9096 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
9099 test_mkdir $DIR/$tdir
9100 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
9101 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
9103 run_test 71 "Running dbench on lustre (don't segment fault) ===="
9105 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
9106 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9107 [ "$RUNAS_ID" = "$UID" ] &&
9108 skip_env "RUNAS_ID = UID = $UID -- skipping"
9109 # Check that testing environment is properly set up. Skip if not
9110 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
9111 skip_env "User $RUNAS_ID does not exist - skipping"
9114 chmod 777 $DIR/$tfile
9115 chmod ug+s $DIR/$tfile
9116 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
9117 error "$RUNAS dd $DIR/$tfile failed"
9118 # See if we are still setuid/sgid
9119 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9120 error "S/gid is not dropped on write"
9121 # Now test that MDS is updated too
9122 cancel_lru_locks mdc
9123 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9124 error "S/gid is not dropped on MDS"
9127 run_test 72a "Test that remove suid works properly (bug5695) ===="
9129 test_72b() { # bug 24226 -- keep mode setting when size is not changing
9132 [ "$RUNAS_ID" = "$UID" ] &&
9133 skip_env "RUNAS_ID = UID = $UID -- skipping"
9134 [ "$RUNAS_ID" -eq 0 ] &&
9135 skip_env "RUNAS_ID = 0 -- skipping"
9136 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9137 # Check that testing environment is properly set up. Skip if not
9138 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
9139 skip_env "User $RUNAS_ID does not exist - skipping"
9141 touch $DIR/${tfile}-f{g,u}
9142 test_mkdir $DIR/${tfile}-dg
9143 test_mkdir $DIR/${tfile}-du
9144 chmod 770 $DIR/${tfile}-{f,d}{g,u}
9145 chmod g+s $DIR/${tfile}-{f,d}g
9146 chmod u+s $DIR/${tfile}-{f,d}u
9147 for perm in 777 2777 4777; do
9148 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
9149 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
9150 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
9151 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
9155 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
9157 # bug 3462 - multiple simultaneous MDC requests
9159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9161 test_mkdir $DIR/d73-1
9162 test_mkdir $DIR/d73-2
9163 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
9166 lctl set_param fail_loc=0x80000129
9167 $MULTIOP $DIR/d73-1/f73-2 Oc &
9169 lctl set_param fail_loc=0
9171 $MULTIOP $DIR/d73-2/f73-3 Oc &
9175 wait $pid1 || return 1
9179 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
9180 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
9181 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
9185 run_test 73 "multiple MDC requests (should not deadlock)"
9187 test_74a() { # bug 6149, 6184
9188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9191 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9193 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9194 # will spin in a tight reconnection loop
9195 $LCTL set_param fail_loc=0x8000030e
9196 # get any lock that won't be difficult - lookup works.
9198 $LCTL set_param fail_loc=0
9202 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
9204 test_74b() { # bug 13310
9205 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9207 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9209 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9210 # will spin in a tight reconnection loop
9211 $LCTL set_param fail_loc=0x8000030e
9212 # get a "difficult" lock
9214 $LCTL set_param fail_loc=0
9218 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
9221 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9223 #define OBD_FAIL_LDLM_NEW_LOCK
9224 $LCTL set_param fail_loc=0x319
9225 touch $DIR/$tfile && error "touch successful"
9226 $LCTL set_param fail_loc=0
9229 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
9231 slab_lic=/sys/kernel/slab/lustre_inode_cache
9233 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
9234 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
9235 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
9238 test_76a() { # Now for b=20433, added originally in b=1443
9239 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9241 cancel_lru_locks osc
9242 # there may be some slab objects cached per core
9243 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
9244 local before=$(num_objects)
9245 local count=$((512 * cpus))
9246 [ "$SLOW" = "no" ] && count=$((128 * cpus))
9247 local margin=$((count / 10))
9248 if [[ -f $slab_lic/aliases ]]; then
9249 local aliases=$(cat $slab_lic/aliases)
9250 (( aliases > 0 )) && margin=$((margin * aliases))
9253 echo "before slab objects: $before"
9254 for i in $(seq $count); do
9258 cancel_lru_locks osc
9259 local after=$(num_objects)
9260 echo "created: $count, after slab objects: $after"
9261 # shared slab counts are not very accurate, allow significant margin
9262 # the main goal is that the cache growth is not permanently > $count
9263 while (( after > before + margin )); do
9265 after=$(num_objects)
9267 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9268 if (( wait > 60 )); then
9269 error "inode slab grew from $before+$margin to $after"
9273 run_test 76a "confirm clients recycle inodes properly ===="
9276 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9277 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
9280 local before=$(num_objects)
9282 for i in $(seq $count); do
9287 local after=$(num_objects)
9290 while (( after > before )); do
9292 after=$(num_objects)
9294 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9295 if (( wait > 60 )); then
9296 error "inode slab grew from $before to $after"
9300 echo "slab objects before: $before, after: $after"
9302 run_test 76b "confirm clients recycle directory inodes properly ===="
9307 # Note: in sptlrpc modes which enable its own bulk checksum, the
9308 # original crc32_le bulk checksum will be automatically disabled,
9309 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
9310 # will be checked by sptlrpc code against sptlrpc bulk checksum.
9311 # In this case set_checksums() will not be no-op, because sptlrpc
9312 # bulk checksum will be enabled all through the test.
9314 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
9315 lctl set_param -n osc.*.checksums $1
9319 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9320 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
9321 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9322 tr -d [] | head -n1)}
9325 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
9327 log "set checksum type to $1, rc = $rc"
9331 get_osc_checksum_type()
9333 # arugment 1: OST name, like OST0000
9335 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
9336 sed 's/.*\[\(.*\)\].*/\1/g')
9338 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
9342 F77_TMP=$TMP/f77-temp
9345 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
9346 error "error writing to $F77_TMP"
9349 test_77a() { # bug 10889
9350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9351 $GSS && skip_env "could not run with gss"
9353 [ ! -f $F77_TMP ] && setup_f77
9355 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
9359 run_test 77a "normal checksum read/write operation"
9361 test_77b() { # bug 10889
9362 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9363 $GSS && skip_env "could not run with gss"
9365 [ ! -f $F77_TMP ] && setup_f77
9366 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9367 $LCTL set_param fail_loc=0x80000409
9370 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9371 error "dd error: $?"
9372 $LCTL set_param fail_loc=0
9374 for algo in $CKSUM_TYPES; do
9375 cancel_lru_locks osc
9376 set_checksum_type $algo
9377 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9378 $LCTL set_param fail_loc=0x80000408
9379 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
9380 $LCTL set_param fail_loc=0
9383 set_checksum_type $ORIG_CSUM_TYPE
9386 run_test 77b "checksum error on client write, read"
9391 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
9393 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
9394 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
9395 $check_ost && [ -n "$ost_file_prefix" ] &&
9396 do_facet ost1 rm -f ${ost_file_prefix}\*
9400 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9401 $GSS && skip_env "could not run with gss"
9402 remote_ost_nodsh && skip "remote OST with nodsh"
9405 local osc_file_prefix
9407 local check_ost=false
9408 local ost_file_prefix
9414 # ensure corruption will occur on first OSS/OST
9415 $LFS setstripe -i 0 $DIR/$tfile
9417 [ ! -f $F77_TMP ] && setup_f77
9418 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9419 error "dd write error: $?"
9420 fid=$($LFS path2fid $DIR/$tfile)
9422 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
9425 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
9426 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
9428 echo "OSS do not support bulk pages dump upon error"
9431 osc_file_prefix=$($LCTL get_param -n debug_path)
9432 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
9434 trap cleanup_77c EXIT
9437 # enable bulk pages dump upon error on Client
9438 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
9439 # enable bulk pages dump upon error on OSS
9441 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
9443 # flush Client cache to allow next read to reach OSS
9444 cancel_lru_locks osc
9446 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9447 $LCTL set_param fail_loc=0x80000408
9448 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
9449 $LCTL set_param fail_loc=0
9453 # check cksum dump on Client
9454 osc_file=$(ls ${osc_file_prefix}*)
9455 [ -n "$osc_file" ] || error "no checksum dump file on Client"
9456 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
9457 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
9458 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
9459 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
9461 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
9462 [[ "$orig_cksum" == "$dump_cksum" ]] ||
9463 error "dump content does not match on Client"
9465 $check_ost || skip "No need to check cksum dump on OSS"
9467 # check cksum dump on OSS
9468 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
9469 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
9470 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
9471 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
9472 [[ "$orig_cksum" == "$dump_cksum" ]] ||
9473 error "dump content does not match on OSS"
9477 run_test 77c "checksum error on client read with debug"
9479 test_77d() { # bug 10889
9480 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9481 $GSS && skip_env "could not run with gss"
9483 stack_trap "rm -f $DIR/$tfile"
9484 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9485 $LCTL set_param fail_loc=0x80000409
9487 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
9488 error "direct write: rc=$?"
9489 $LCTL set_param fail_loc=0
9492 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9493 $LCTL set_param fail_loc=0x80000408
9495 cancel_lru_locks osc
9496 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
9497 error "direct read: rc=$?"
9498 $LCTL set_param fail_loc=0
9501 run_test 77d "checksum error on OST direct write, read"
9503 test_77f() { # bug 10889
9504 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9505 $GSS && skip_env "could not run with gss"
9508 stack_trap "rm -f $DIR/$tfile"
9509 for algo in $CKSUM_TYPES; do
9510 cancel_lru_locks osc
9511 set_checksum_type $algo
9512 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9513 $LCTL set_param fail_loc=0x409
9514 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
9515 error "direct write succeeded"
9516 $LCTL set_param fail_loc=0
9518 set_checksum_type $ORIG_CSUM_TYPE
9521 run_test 77f "repeat checksum error on write (expect error)"
9523 test_77g() { # bug 10889
9524 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9525 $GSS && skip_env "could not run with gss"
9526 remote_ost_nodsh && skip "remote OST with nodsh"
9528 [ ! -f $F77_TMP ] && setup_f77
9530 local file=$DIR/$tfile
9531 stack_trap "rm -f $file" EXIT
9533 $LFS setstripe -c 1 -i 0 $file
9534 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
9535 do_facet ost1 lctl set_param fail_loc=0x8000021a
9537 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
9538 error "write error: rc=$?"
9539 do_facet ost1 lctl set_param fail_loc=0
9542 cancel_lru_locks osc
9543 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
9544 do_facet ost1 lctl set_param fail_loc=0x8000021b
9546 cmp $F77_TMP $file || error "file compare failed"
9547 do_facet ost1 lctl set_param fail_loc=0
9550 run_test 77g "checksum error on OST write, read"
9552 test_77k() { # LU-10906
9553 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9554 $GSS && skip_env "could not run with gss"
9556 local cksum_param="osc.$FSNAME*.checksums"
9557 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
9561 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
9562 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
9563 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
9566 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
9567 error "failed to set checksum=$i on MGS"
9568 wait_update $HOSTNAME "$get_checksum" $i
9570 echo "remount client, checksum should be $i"
9571 remount_client $MOUNT || error "failed to remount client"
9572 checksum=$(eval $get_checksum)
9573 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
9575 # remove persistent param to avoid races with checksum mountopt below
9576 do_facet mgs $LCTL set_param -P -d $cksum_param ||
9577 error "failed to delete checksum on MGS"
9579 for opt in "checksum" "nochecksum"; do
9580 #remount with mount option
9581 echo "remount client with option $opt, checksum should be $i"
9582 umount_client $MOUNT || error "failed to umount client"
9583 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
9584 error "failed to mount client with option '$opt'"
9585 checksum=$(eval $get_checksum)
9586 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
9590 remount_client $MOUNT || error "failed to remount client"
9592 run_test 77k "enable/disable checksum correctly"
9595 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9596 $GSS && skip_env "could not run with gss"
9599 stack_trap "set_checksums $ORIG_CSUM" EXIT
9600 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
9602 set_checksum_type invalid && error "unexpected success of invalid checksum type"
9604 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9605 for algo in $CKSUM_TYPES; do
9606 set_checksum_type $algo || error "fail to set checksum type $algo"
9607 osc_algo=$(get_osc_checksum_type OST0000)
9608 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
9610 # no locks, no reqs to let the connection idle
9611 cancel_lru_locks osc
9612 lru_resize_disable osc
9613 wait_osc_import_state client ost1 IDLE
9615 # ensure ost1 is connected
9616 stat $DIR/$tfile >/dev/null || error "can't stat"
9617 wait_osc_import_state client ost1 FULL
9619 osc_algo=$(get_osc_checksum_type OST0000)
9620 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
9624 run_test 77l "preferred checksum type is remembered after reconnected"
9626 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
9631 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
9632 skip "Need at least version 2.14.52"
9633 local param=checksum_speed
9635 $LCTL get_param $param || error "reading $param failed"
9637 csum_speeds=$($LCTL get_param -n $param)
9639 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
9640 error "known checksum types are missing"
9642 run_test 77m "Verify checksum_speed is correctly read"
9649 test_78() { # bug 10901
9650 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9651 remote_ost || skip_env "local OST"
9654 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
9655 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
9656 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
9657 echo "MemTotal: $MEMTOTAL"
9659 # reserve 256MB of memory for the kernel and other running processes,
9660 # and then take 1/2 of the remaining memory for the read/write buffers.
9661 if [ $MEMTOTAL -gt 512 ] ;then
9662 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
9664 # for those poor memory-starved high-end clusters...
9665 MEMTOTAL=$((MEMTOTAL / 2))
9667 echo "Mem to use for directio: $MEMTOTAL"
9669 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
9670 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
9671 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
9672 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
9674 echo "Smallest OST: $SMALLESTOST"
9675 [[ $SMALLESTOST -lt 10240 ]] &&
9676 skip "too small OSTSIZE, useless to run large O_DIRECT test"
9678 trap cleanup_test_78 EXIT
9680 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
9681 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
9683 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
9684 echo "File size: $F78SIZE"
9685 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
9686 for i in $(seq 1 $NSEQ); do
9687 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
9688 echo directIO rdwr round $i of $NSEQ
9689 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
9694 run_test 78 "handle large O_DIRECT writes correctly ============"
9696 test_79() { # bug 12743
9697 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9699 wait_delete_completed
9701 BKTOTAL=$(calc_osc_kbytes kbytestotal)
9702 BKFREE=$(calc_osc_kbytes kbytesfree)
9703 BKAVAIL=$(calc_osc_kbytes kbytesavail)
9705 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
9706 DFTOTAL=`echo $STRING | cut -d, -f1`
9707 DFUSED=`echo $STRING | cut -d, -f2`
9708 DFAVAIL=`echo $STRING | cut -d, -f3`
9709 DFFREE=$(($DFTOTAL - $DFUSED))
9711 ALLOWANCE=$((64 * $OSTCOUNT))
9713 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
9714 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
9715 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
9717 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
9718 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
9719 error "df free($DFFREE) mismatch OST free($BKFREE)"
9721 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
9722 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
9723 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
9726 run_test 79 "df report consistency check ======================="
9728 test_80() { # bug 10718
9729 remote_ost_nodsh && skip "remote OST with nodsh"
9730 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9732 # relax strong synchronous semantics for slow backends like ZFS
9733 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
9734 local soc="obdfilter.*.sync_lock_cancel"
9735 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
9737 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
9738 if [ -z "$save" ]; then
9739 soc="obdfilter.*.sync_on_lock_cancel"
9740 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
9743 if [ "$save" != "never" ]; then
9744 local hosts=$(comma_list $(osts_nodes))
9746 do_nodes $hosts $LCTL set_param $soc=never
9747 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
9751 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
9753 local before=$(date +%s)
9754 cancel_lru_locks osc
9755 local after=$(date +%s)
9756 local diff=$((after - before))
9757 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
9761 run_test 80 "Page eviction is equally fast at high offsets too"
9763 test_81a() { # LU-456
9764 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9765 remote_ost_nodsh && skip "remote OST with nodsh"
9767 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
9768 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
9769 do_facet ost1 lctl set_param fail_loc=0x80000228
9771 # write should trigger a retry and success
9772 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9773 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9775 if [ $RC -ne 0 ] ; then
9776 error "write should success, but failed for $RC"
9779 run_test 81a "OST should retry write when get -ENOSPC ==============="
9781 test_81b() { # LU-456
9782 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9783 remote_ost_nodsh && skip "remote OST with nodsh"
9785 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
9786 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
9787 do_facet ost1 lctl set_param fail_loc=0x228
9789 # write should retry several times and return -ENOSPC finally
9790 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9791 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9794 if [ $RC -ne $ENOSPC ] ; then
9795 error "dd should fail for -ENOSPC, but succeed."
9798 run_test 81b "OST should return -ENOSPC when retry still fails ======="
9801 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
9803 test_mkdir $DIR/$tdir.cvsroot
9804 chown $RUNAS_ID $DIR/$tdir.cvsroot
9807 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
9810 # some versions of cvs import exit(1) when asked to import links or
9811 # files they can't read. ignore those files.
9812 local toignore=$(find . -type l -printf '-I %f\n' -o \
9813 ! -perm /4 -printf '-I %f\n')
9814 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
9815 $tdir.reposname vtag rtag
9818 test_mkdir $DIR/$tdir.reposname
9819 chown $RUNAS_ID $DIR/$tdir.reposname
9820 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
9822 cd $DIR/$tdir.reposname
9824 $RUNAS cvs add -m 'addmsg' foo99
9826 $RUNAS cvs commit -m 'nomsg' foo99
9827 rm -fr $DIR/$tdir.cvsroot
9829 run_test 99 "cvs strange file/directory operations"
9832 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9833 [[ "$NETTYPE" =~ tcp ]] ||
9834 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
9835 remote_ost_nodsh && skip "remote OST with nodsh"
9836 remote_mds_nodsh && skip "remote MDS with nodsh"
9838 skip "useless for local single node setup"
9840 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
9841 [ "$PROT" != "tcp" ] && continue
9842 RPORT=$(echo $REMOTE | cut -d: -f2)
9843 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
9846 LPORT=`echo $LOCAL | cut -d: -f2`
9847 if [ $LPORT -ge 1024 ]; then
9848 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
9850 error_exit "local: $LPORT > 1024, remote: $RPORT"
9853 [ "$rc" = 0 ] || error_exit "privileged port not found" )
9855 run_test 100 "check local port using privileged port ==========="
9857 function get_named_value()
9861 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
9864 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
9865 awk '/^max_cached_mb/ { print $2 }')
9868 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
9873 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9878 local cache_limit=32
9880 $LCTL set_param -n osc.*-osc*.rpc_stats=0
9881 trap cleanup_101a EXIT
9882 $LCTL set_param -n llite.*.read_ahead_stats=0
9883 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
9886 # randomly read 10000 of 64K chunks from file 3x 32MB in size
9888 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
9889 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
9892 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
9893 get_named_value 'read.but.discarded'); do
9894 discard=$(($discard + $s))
9898 $LCTL get_param osc.*-osc*.rpc_stats
9899 $LCTL get_param llite.*.read_ahead_stats
9901 # Discard is generally zero, but sometimes a few random reads line up
9902 # and trigger larger readahead, which is wasted & leads to discards.
9903 if [[ $(($discard)) -gt $nreads ]]; then
9904 error "too many ($discard) discarded pages"
9906 rm -f $DIR/$tfile || true
9908 run_test 101a "check read-ahead for random reads"
9911 test_mkdir $DIR/$tdir
9913 local FILE_LENGTH=$2
9916 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
9918 local list=$(comma_list $(osts_nodes))
9919 set_osd_param $list '' read_cache_enable 0
9920 set_osd_param $list '' writethrough_cache_enable 0
9922 trap cleanup_test101bc EXIT
9923 # prepare the read-ahead file
9924 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
9926 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
9927 count=$FILE_SIZE_MB 2> /dev/null
9931 cleanup_test101bc() {
9936 local list=$(comma_list $(osts_nodes))
9937 set_osd_param $list '' read_cache_enable 1
9938 set_osd_param $list '' writethrough_cache_enable 1
9942 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
9947 local STRIPE_SIZE=$2
9948 local FILE_LENGTH=$3
9949 local RA_INC=1048576
9950 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
9951 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
9952 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
9953 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
9954 get_named_value 'read.but.discarded' | calc_total)
9955 if [[ $DISCARD -gt $discard_limit ]]; then
9956 $LCTL get_param llite.*.read_ahead_stats
9957 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
9959 echo "Read-ahead success for size ${READ_SIZE}"
9964 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9965 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9967 local STRIPE_SIZE=1048576
9968 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
9970 if [ $SLOW == "yes" ]; then
9971 local FILE_LENGTH=$((STRIDE_SIZE * 64))
9973 local FILE_LENGTH=$((STRIDE_SIZE * 8))
9976 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
9978 # prepare the read-ahead file
9979 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
9980 cancel_lru_locks osc
9981 for BIDX in 2 4 8 16 32 64 128 256
9983 local BSIZE=$((BIDX*4096))
9984 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
9985 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
9986 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
9987 $LCTL set_param -n llite.*.read_ahead_stats=0
9988 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
9989 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
9990 cancel_lru_locks osc
9991 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
9996 run_test 101b "check stride-io mode read-ahead ================="
9999 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10001 local STRIPE_SIZE=1048576
10002 local FILE_LENGTH=$((STRIPE_SIZE*100))
10005 local osc_rpc_stats
10007 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10009 cancel_lru_locks osc
10010 $LCTL set_param osc.*.rpc_stats=0
10011 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
10012 $LCTL get_param osc.*.rpc_stats
10013 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
10014 local stats=$($LCTL get_param -n $osc_rpc_stats)
10015 local lines=$(echo "$stats" | awk 'END {print NR;}')
10018 if [ $lines -le 20 ]; then
10019 echo "continue debug"
10022 for size in 1 2 4 8; do
10023 local rpc=$(echo "$stats" |
10024 awk '($1 == "'$size':") {print $2; exit; }')
10025 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
10026 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
10028 echo "$osc_rpc_stats check passed!"
10033 run_test 101c "check stripe_size aligned read-ahead"
10036 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10038 local file=$DIR/$tfile
10039 local sz_MB=${FILESIZE_101d:-80}
10040 local ra_MB=${READAHEAD_MB:-40}
10042 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
10043 [ $free_MB -lt $sz_MB ] &&
10044 skip "Need free space ${sz_MB}M, have ${free_MB}M"
10046 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
10047 $LFS setstripe -c -1 $file || error "setstripe failed"
10049 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
10050 echo Cancel LRU locks on lustre client to flush the client cache
10051 cancel_lru_locks osc
10053 echo Disable read-ahead
10054 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10055 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10056 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
10057 $LCTL get_param -n llite.*.max_read_ahead_mb
10059 echo "Reading the test file $file with read-ahead disabled"
10060 local sz_KB=$((sz_MB * 1024 / 4))
10061 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
10062 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
10063 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10064 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10066 echo "Cancel LRU locks on lustre client to flush the client cache"
10067 cancel_lru_locks osc
10068 echo Enable read-ahead with ${ra_MB}MB
10069 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
10071 echo "Reading the test file $file with read-ahead enabled"
10072 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10073 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10075 echo "read-ahead disabled time read $raOFF"
10076 echo "read-ahead enabled time read $raON"
10079 wait_delete_completed
10081 # use awk for this check instead of bash because it handles decimals
10082 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
10083 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
10085 run_test 101d "file read with and without read-ahead enabled"
10088 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10090 local file=$DIR/$tfile
10091 local size_KB=500 #KB
10095 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
10096 local need_KB=$((count * size_KB))
10097 [[ $free_KB -le $need_KB ]] &&
10098 skip_env "Need free space $need_KB, have $free_KB"
10100 echo "Creating $count ${size_KB}K test files"
10101 for ((i = 0; i < $count; i++)); do
10102 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
10105 echo "Cancel LRU locks on lustre client to flush the client cache"
10106 cancel_lru_locks $OSC
10108 echo "Reset readahead stats"
10109 $LCTL set_param -n llite.*.read_ahead_stats=0
10111 for ((i = 0; i < $count; i++)); do
10112 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
10115 $LCTL get_param llite.*.max_cached_mb
10116 $LCTL get_param llite.*.read_ahead_stats
10117 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10118 get_named_value 'misses' | calc_total)
10120 for ((i = 0; i < $count; i++)); do
10121 rm -rf $file.$i 2>/dev/null
10124 #10000 means 20% reads are missing in readahead
10125 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
10127 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
10130 which iozone || skip_env "no iozone installed"
10132 local old_debug=$($LCTL get_param debug)
10133 old_debug=${old_debug#*=}
10134 $LCTL set_param debug="reada mmap"
10136 # create a test file
10137 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
10139 echo Cancel LRU locks on lustre client to flush the client cache
10140 cancel_lru_locks osc
10142 echo Reset readahead stats
10143 $LCTL set_param -n llite.*.read_ahead_stats=0
10145 echo mmap read the file with small block size
10146 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
10149 echo checking missing pages
10150 $LCTL get_param llite.*.read_ahead_stats
10151 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10152 get_named_value 'misses' | calc_total)
10154 $LCTL set_param debug="$old_debug"
10155 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
10158 run_test 101f "check mmap read performance"
10160 test_101g_brw_size_test() {
10162 local pages=$((mb * 1048576 / PAGE_SIZE))
10163 local file=$DIR/$tfile
10165 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
10166 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
10167 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
10168 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
10172 stack_trap "rm -f $file" EXIT
10173 $LCTL set_param -n osc.*.rpc_stats=0
10175 # 10 RPCs should be enough for the test
10177 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
10178 { error "dd write ${mb} MB blocks failed"; return 3; }
10179 cancel_lru_locks osc
10180 dd of=/dev/null if=$file bs=${mb}M count=$count ||
10181 { error "dd write ${mb} MB blocks failed"; return 4; }
10183 # calculate number of full-sized read and write RPCs
10184 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
10185 sed -n '/pages per rpc/,/^$/p' |
10186 awk '/'$pages':/ { reads += $2; writes += $6 }; \
10187 END { print reads,writes }'))
10188 # allow one extra full-sized read RPC for async readahead
10189 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
10190 { error "${rpcs[0]} != $count read RPCs"; return 5; }
10191 [[ ${rpcs[1]} == $count ]] ||
10192 { error "${rpcs[1]} != $count write RPCs"; return 6; }
10196 remote_ost_nodsh && skip "remote OST with nodsh"
10199 local osts=$(get_facets OST)
10200 local list=$(comma_list $(osts_nodes))
10201 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10202 local brw_size="obdfilter.*.brw_size"
10204 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10206 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
10208 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
10209 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
10210 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
10211 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
10212 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
10213 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
10215 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
10218 if [[ $orig_mb -lt 16 ]]; then
10219 save_lustre_params $osts "$brw_size" > $p
10220 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
10221 error "set 16MB RPC size failed"
10223 echo "remount client to enable new RPC size"
10224 remount_client $MOUNT || error "remount_client failed"
10227 test_101g_brw_size_test 16 || error "16MB RPC test failed"
10228 # should be able to set brw_size=12, but no rpc_stats for that
10229 test_101g_brw_size_test 8 || error "8MB RPC test failed"
10232 test_101g_brw_size_test 4 || error "4MB RPC test failed"
10234 if [[ $orig_mb -lt 16 ]]; then
10235 restore_lustre_params < $p
10236 remount_client $MOUNT || error "remount_client restore failed"
10239 rm -f $p $DIR/$tfile
10241 run_test 101g "Big bulk(4/16 MiB) readahead"
10244 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10246 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
10247 error "dd 70M file failed"
10248 echo Cancel LRU locks on lustre client to flush the client cache
10249 cancel_lru_locks osc
10251 echo "Reset readahead stats"
10252 $LCTL set_param -n llite.*.read_ahead_stats 0
10254 echo "Read 10M of data but cross 64M bundary"
10255 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
10256 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10257 get_named_value 'misses' | calc_total)
10258 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
10259 rm -f $p $DIR/$tfile
10261 run_test 101h "Readahead should cover current read window"
10264 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
10265 error "dd 10M file failed"
10267 local max_per_file_mb=$($LCTL get_param -n \
10268 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
10269 cancel_lru_locks osc
10270 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
10271 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
10272 error "set max_read_ahead_per_file_mb to 1 failed"
10274 echo "Reset readahead stats"
10275 $LCTL set_param llite.*.read_ahead_stats=0
10277 dd if=$DIR/$tfile of=/dev/null bs=2M
10279 $LCTL get_param llite.*.read_ahead_stats
10280 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10281 awk '/misses/ { print $2 }')
10282 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
10285 run_test 101i "allow current readahead to exceed reservation"
10288 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
10289 error "setstripe $DIR/$tfile failed"
10290 local file_size=$((1048576 * 16))
10291 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10292 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
10294 echo Disable read-ahead
10295 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10297 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
10298 for blk in $PAGE_SIZE 1048576 $file_size; do
10299 cancel_lru_locks osc
10300 echo "Reset readahead stats"
10301 $LCTL set_param -n llite.*.read_ahead_stats=0
10302 local count=$(($file_size / $blk))
10303 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
10304 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10305 get_named_value 'failed.to.fast.read' | calc_total)
10306 $LCTL get_param -n llite.*.read_ahead_stats
10307 [ $miss -eq $count ] || error "expected $count got $miss"
10310 rm -f $p $DIR/$tfile
10312 run_test 101j "A complete read block should be submitted when no RA"
10315 test_mkdir $DIR/$tdir
10316 chown $RUNAS_ID $DIR/$tdir
10319 STRIPE_COUNT=$OSTCOUNT
10320 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
10322 trap cleanup_test102 EXIT
10324 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
10326 for num in 1 2 3 4; do
10327 for count in $(seq 1 $STRIPE_COUNT); do
10328 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
10329 local size=`expr $STRIPE_SIZE \* $num`
10330 local file=file"$num-$idx-$count"
10331 $1 $LFS setstripe -S $size -i $idx -c $count $file
10337 $1 tar cf $TMP/f102.tar $tdir --xattrs
10340 cleanup_test102() {
10342 rm -f $TMP/f102.tar
10343 rm -rf $DIR/d0.sanity/d102
10347 [ "$UID" != 0 ] && skip "must run as root"
10348 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
10349 skip_env "must have user_xattr"
10351 [ -z "$(which setfattr 2>/dev/null)" ] &&
10352 skip_env "could not find setfattr"
10354 local testfile=$DIR/$tfile
10357 echo "set/get xattr..."
10358 setfattr -n trusted.name1 -v value1 $testfile ||
10359 error "setfattr -n trusted.name1=value1 $testfile failed"
10360 getfattr -n trusted.name1 $testfile 2> /dev/null |
10361 grep "trusted.name1=.value1" ||
10362 error "$testfile missing trusted.name1=value1"
10364 setfattr -n user.author1 -v author1 $testfile ||
10365 error "setfattr -n user.author1=author1 $testfile failed"
10366 getfattr -n user.author1 $testfile 2> /dev/null |
10367 grep "user.author1=.author1" ||
10368 error "$testfile missing trusted.author1=author1"
10370 echo "listxattr..."
10371 setfattr -n trusted.name2 -v value2 $testfile ||
10372 error "$testfile unable to set trusted.name2"
10373 setfattr -n trusted.name3 -v value3 $testfile ||
10374 error "$testfile unable to set trusted.name3"
10375 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
10376 grep "trusted.name" | wc -l) -eq 3 ] ||
10377 error "$testfile missing 3 trusted.name xattrs"
10379 setfattr -n user.author2 -v author2 $testfile ||
10380 error "$testfile unable to set user.author2"
10381 setfattr -n user.author3 -v author3 $testfile ||
10382 error "$testfile unable to set user.author3"
10383 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
10384 grep "user.author" | wc -l) -eq 3 ] ||
10385 error "$testfile missing 3 user.author xattrs"
10387 echo "remove xattr..."
10388 setfattr -x trusted.name1 $testfile ||
10389 error "$testfile error deleting trusted.name1"
10390 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
10391 error "$testfile did not delete trusted.name1 xattr"
10393 setfattr -x user.author1 $testfile ||
10394 error "$testfile error deleting user.author1"
10395 echo "set lustre special xattr ..."
10396 $LFS setstripe -c1 $testfile
10397 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
10398 awk -F "=" '/trusted.lov/ { print $2 }' )
10399 setfattr -n "trusted.lov" -v $lovea $testfile ||
10400 error "$testfile doesn't ignore setting trusted.lov again"
10401 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
10402 error "$testfile allow setting invalid trusted.lov"
10405 run_test 102a "user xattr test =================================="
10407 check_102b_layout() {
10409 local testfile=$DIR/$tfile
10411 echo "test layout '$layout'"
10412 $LFS setstripe $layout $testfile || error "setstripe failed"
10413 $LFS getstripe -y $testfile
10415 echo "get/set/list trusted.lov xattr ..." # b=10930
10416 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
10417 [[ "$value" =~ "trusted.lov" ]] ||
10418 error "can't get trusted.lov from $testfile"
10419 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
10420 error "getstripe failed"
10422 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
10424 value=$(cut -d= -f2 <<<$value)
10425 # LU-13168: truncated xattr should fail if short lov_user_md header
10426 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
10427 lens="${#value}" || lens="$(seq 4 2 ${#value})"
10428 for len in $lens; do
10429 echo "setfattr $len $testfile.2"
10430 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
10431 [ $len -lt 66 ] && error "short xattr len=$len worked"
10433 local stripe_size=$($LFS getstripe -S $testfile.2)
10434 local stripe_count=$($LFS getstripe -c $testfile.2)
10435 [[ $stripe_size -eq 65536 ]] ||
10436 error "stripe size $stripe_size != 65536"
10437 [[ $stripe_count -eq $stripe_count_orig ]] ||
10438 error "stripe count $stripe_count != $stripe_count_orig"
10439 rm $testfile $testfile.2
10443 [ -z "$(which setfattr 2>/dev/null)" ] &&
10444 skip_env "could not find setfattr"
10445 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10447 # check plain layout
10448 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
10450 # and also check composite layout
10451 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
10454 run_test 102b "getfattr/setfattr for trusted.lov EAs"
10457 [ -z "$(which setfattr 2>/dev/null)" ] &&
10458 skip_env "could not find setfattr"
10459 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10461 # b10930: get/set/list lustre.lov xattr
10462 echo "get/set/list lustre.lov xattr ..."
10463 test_mkdir $DIR/$tdir
10464 chown $RUNAS_ID $DIR/$tdir
10465 local testfile=$DIR/$tdir/$tfile
10466 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
10467 error "setstripe failed"
10468 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
10469 error "getstripe failed"
10470 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
10471 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
10473 local testfile2=${testfile}2
10474 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
10475 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
10477 $RUNAS $MCREATE $testfile2
10478 $RUNAS setfattr -n lustre.lov -v $value $testfile2
10479 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
10480 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
10481 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
10482 [ $stripe_count -eq $STRIPECOUNT ] ||
10483 error "stripe count $stripe_count != $STRIPECOUNT"
10485 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
10487 compare_stripe_info1() {
10488 local stripe_index_all_zero=true
10490 for num in 1 2 3 4; do
10491 for count in $(seq 1 $STRIPE_COUNT); do
10492 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
10493 local size=$((STRIPE_SIZE * num))
10494 local file=file"$num-$offset-$count"
10495 stripe_size=$($LFS getstripe -S $PWD/$file)
10496 [[ $stripe_size -ne $size ]] &&
10497 error "$file: size $stripe_size != $size"
10498 stripe_count=$($LFS getstripe -c $PWD/$file)
10499 # allow fewer stripes to be created, ORI-601
10500 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
10501 error "$file: count $stripe_count != $count"
10502 stripe_index=$($LFS getstripe -i $PWD/$file)
10503 [[ $stripe_index -ne 0 ]] &&
10504 stripe_index_all_zero=false
10508 $stripe_index_all_zero &&
10509 error "all files are being extracted starting from OST index 0"
10513 have_xattrs_include() {
10514 tar --help | grep -q xattrs-include &&
10515 echo --xattrs-include="lustre.*"
10519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10520 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10522 XINC=$(have_xattrs_include)
10524 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
10525 cd $DIR/$tdir/$tdir
10526 compare_stripe_info1
10528 run_test 102d "tar restore stripe info from tarfile,not keep osts"
10531 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10532 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10534 XINC=$(have_xattrs_include)
10536 test_mkdir $DIR/$tdir.restore
10538 tar cf - --xattrs $tdir | tar xf - \
10539 -C $DIR/$tdir.restore --xattrs $XINC
10540 cd $DIR/$tdir.restore/$tdir
10541 compare_stripe_info1
10543 run_test 102f "tar copy files, not keep osts"
10546 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
10547 skip "must have user_xattr"
10548 [ -z "$(which setfattr 2>/dev/null)" ] &&
10549 skip_env "could not find setfattr"
10550 [ -z "$(which getfattr 2>/dev/null)" ] &&
10551 skip_env "could not find getfattr"
10553 local xsize=${1:-1024} # in bytes
10554 local file=$DIR/$tfile
10555 local value="$(generate_string $xsize)"
10556 local xbig=trusted.big
10560 log "save $xbig on $file"
10561 if [ -z "$toobig" ]
10563 setfattr -n $xbig -v $value $file ||
10564 error "saving $xbig on $file failed"
10566 setfattr -n $xbig -v $value $file &&
10567 error "saving $xbig on $file succeeded"
10571 local orig=$(get_xattr_value $xbig $file)
10572 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
10574 local xsml=trusted.sml
10575 log "save $xsml on $file"
10576 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
10578 local new=$(get_xattr_value $xbig $file)
10579 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
10581 log "grow $xsml on $file"
10582 setfattr -n $xsml -v "$value" $file ||
10583 error "growing $xsml on $file failed"
10585 new=$(get_xattr_value $xbig $file)
10586 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
10587 log "$xbig still valid after growing $xsml"
10592 test_102h() { # bug 15777
10595 run_test 102h "grow xattr from inside inode to external block"
10598 large_xattr_enabled || skip_env "ea_inode feature disabled"
10600 echo "setting xattr of max xattr size: $(max_xattr_size)"
10601 grow_xattr $(max_xattr_size)
10603 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
10604 echo "This should fail:"
10605 grow_xattr $(($(max_xattr_size) + 10)) 1
10607 run_test 102ha "grow xattr from inside inode to external inode"
10609 test_102i() { # bug 17038
10610 [ -z "$(which getfattr 2>/dev/null)" ] &&
10611 skip "could not find getfattr"
10614 ln -s $DIR/$tfile $DIR/${tfile}link
10615 getfattr -n trusted.lov $DIR/$tfile ||
10616 error "lgetxattr on $DIR/$tfile failed"
10617 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
10618 grep -i "no such attr" ||
10619 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
10620 rm -f $DIR/$tfile $DIR/${tfile}link
10622 run_test 102i "lgetxattr test on symbolic link ============"
10625 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10626 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10628 XINC=$(have_xattrs_include)
10629 setup_test102 "$RUNAS"
10630 chown $RUNAS_ID $DIR/$tdir
10631 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
10632 cd $DIR/$tdir/$tdir
10633 compare_stripe_info1 "$RUNAS"
10635 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
10638 [ -z "$(which setfattr 2>/dev/null)" ] &&
10639 skip "could not find setfattr"
10642 # b22187 just check that does not crash for regular file.
10643 setfattr -n trusted.lov $DIR/$tfile
10644 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
10645 local test_kdir=$DIR/$tdir
10646 test_mkdir $test_kdir
10647 local default_size=$($LFS getstripe -S $test_kdir)
10648 local default_count=$($LFS getstripe -c $test_kdir)
10649 local default_offset=$($LFS getstripe -i $test_kdir)
10650 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
10651 error 'dir setstripe failed'
10652 setfattr -n trusted.lov $test_kdir
10653 local stripe_size=$($LFS getstripe -S $test_kdir)
10654 local stripe_count=$($LFS getstripe -c $test_kdir)
10655 local stripe_offset=$($LFS getstripe -i $test_kdir)
10656 [ $stripe_size -eq $default_size ] ||
10657 error "stripe size $stripe_size != $default_size"
10658 [ $stripe_count -eq $default_count ] ||
10659 error "stripe count $stripe_count != $default_count"
10660 [ $stripe_offset -eq $default_offset ] ||
10661 error "stripe offset $stripe_offset != $default_offset"
10662 rm -rf $DIR/$tfile $test_kdir
10664 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
10667 [ -z "$(which getfattr 2>/dev/null)" ] &&
10668 skip "could not find getfattr"
10670 # LU-532 trusted. xattr is invisible to non-root
10671 local testfile=$DIR/$tfile
10675 echo "listxattr as user..."
10676 chown $RUNAS_ID $testfile
10677 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
10678 grep -q "trusted" &&
10679 error "$testfile trusted xattrs are user visible"
10683 run_test 102l "listxattr size test =================================="
10685 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
10686 local path=$DIR/$tfile
10689 listxattr_size_check $path || error "listattr_size_check $path failed"
10691 run_test 102m "Ensure listxattr fails on small bufffer ========"
10695 getxattr() { # getxattr path name
10696 # Return the base64 encoding of the value of xattr name on path.
10700 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
10702 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
10704 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
10706 getfattr --absolute-names --encoding=base64 --name=$name $path |
10707 awk -F= -v name=$name '$1 == name {
10708 print substr($0, index($0, "=") + 1);
10712 test_102n() { # LU-4101 mdt: protect internal xattrs
10713 [ -z "$(which setfattr 2>/dev/null)" ] &&
10714 skip "could not find setfattr"
10715 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
10717 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
10720 local file0=$DIR/$tfile.0
10721 local file1=$DIR/$tfile.1
10722 local xattr0=$TMP/$tfile.0
10723 local xattr1=$TMP/$tfile.1
10724 local namelist="lov lma lmv link fid version som hsm"
10728 rm -rf $file0 $file1 $xattr0 $xattr1
10729 touch $file0 $file1
10731 # Get 'before' xattrs of $file1.
10732 getfattr --absolute-names --dump --match=- $file1 > $xattr0
10734 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
10735 namelist+=" lfsck_namespace"
10736 for name in $namelist; do
10737 # Try to copy xattr from $file0 to $file1.
10738 value=$(getxattr $file0 trusted.$name 2> /dev/null)
10740 setfattr --name=trusted.$name --value="$value" $file1 ||
10741 error "setxattr 'trusted.$name' failed"
10743 # Try to set a garbage xattr.
10744 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
10746 if [[ x$name == "xlov" ]]; then
10747 setfattr --name=trusted.lov --value="$value" $file1 &&
10748 error "setxattr invalid 'trusted.lov' success"
10750 setfattr --name=trusted.$name --value="$value" $file1 ||
10751 error "setxattr invalid 'trusted.$name' failed"
10754 # Try to remove the xattr from $file1. We don't care if this
10755 # appears to succeed or fail, we just don't want there to be
10756 # any changes or crashes.
10757 setfattr --remove=$trusted.$name $file1 2> /dev/null
10760 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
10763 # Try to copy xattr from $file0 to $file1.
10764 value=$(getxattr $file0 trusted.$name 2> /dev/null)
10766 setfattr --name=trusted.$name --value="$value" $file1 ||
10767 error "setxattr 'trusted.$name' failed"
10769 # Try to set a garbage xattr.
10770 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
10772 setfattr --name=trusted.$name --value="$value" $file1 ||
10773 error "setxattr 'trusted.$name' failed"
10775 # Try to remove the xattr from $file1. We don't care if this
10776 # appears to succeed or fail, we just don't want there to be
10777 # any changes or crashes.
10778 setfattr --remove=$trusted.$name $file1 2> /dev/null
10781 # Get 'after' xattrs of file1.
10782 getfattr --absolute-names --dump --match=- $file1 > $xattr1
10784 if ! diff $xattr0 $xattr1; then
10785 error "before and after xattrs of '$file1' differ"
10788 rm -rf $file0 $file1 $xattr0 $xattr1
10792 run_test 102n "silently ignore setxattr on internal trusted xattrs"
10794 test_102p() { # LU-4703 setxattr did not check ownership
10795 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
10796 skip "MDS needs to be at least 2.5.56"
10798 local testfile=$DIR/$tfile
10802 echo "setfacl as user..."
10803 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
10804 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
10806 echo "setfattr as user..."
10807 setfacl -m "u:$RUNAS_ID:---" $testfile
10808 $RUNAS setfattr -x system.posix_acl_access $testfile
10809 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
10811 run_test 102p "check setxattr(2) correctly fails without permission"
10814 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
10815 skip "MDS needs to be at least 2.6.92"
10817 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
10819 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
10822 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
10823 skip "MDS needs to be at least 2.6.93"
10825 touch $DIR/$tfile || error "touch"
10826 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
10827 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
10828 rm $DIR/$tfile || error "rm"
10831 mkdir -p $DIR/$tdir || error "mkdir"
10832 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
10833 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
10834 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
10835 error "$testfile error deleting user.author1"
10836 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
10837 grep "user.$(basename $tdir)" &&
10838 error "$tdir did not delete user.$(basename $tdir)"
10839 rmdir $DIR/$tdir || error "rmdir"
10842 test_mkdir $DIR/$tdir
10843 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
10844 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
10845 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
10846 error "$testfile error deleting user.author1"
10847 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
10848 grep "user.$(basename $tdir)" &&
10849 error "$tdir did not delete user.$(basename $tdir)"
10850 rmdir $DIR/$tdir || error "rm striped dir"
10852 run_test 102r "set EAs with empty values"
10855 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
10856 skip "MDS needs to be at least 2.11.52"
10858 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10860 save_lustre_params client "llite.*.xattr_cache" > $save
10862 for cache in 0 1; do
10863 lctl set_param llite.*.xattr_cache=$cache
10866 touch $DIR/$tfile || error "touch"
10867 for prefix in lustre security system trusted user; do
10868 # Note getxattr() may fail with 'Operation not
10869 # supported' or 'No such attribute' depending
10870 # on prefix and cache.
10871 getfattr -n $prefix.n102s $DIR/$tfile &&
10872 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
10876 restore_lustre_params < $save
10878 run_test 102s "getting nonexistent xattrs should fail"
10881 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
10882 skip "MDS needs to be at least 2.11.52"
10884 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10886 save_lustre_params client "llite.*.xattr_cache" > $save
10888 for cache in 0 1; do
10889 lctl set_param llite.*.xattr_cache=$cache
10891 for buf_size in 0 256; do
10893 touch $DIR/$tfile || error "touch"
10894 setfattr -n user.multiop $DIR/$tfile
10895 $MULTIOP $DIR/$tfile oa$buf_size ||
10896 error "cannot get zero length xattr value (buf_size = $buf_size)"
10900 restore_lustre_params < $save
10902 run_test 102t "zero length xattr values handled correctly"
10906 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
10911 [ "$UID" != 0 ] && skip "must run as root"
10912 $GSS && skip_env "could not run under gss"
10913 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
10914 skip_env "must have acl enabled"
10915 [ -z "$(which setfacl 2>/dev/null)" ] &&
10916 skip_env "could not find setfacl"
10917 remote_mds_nodsh && skip "remote MDS with nodsh"
10919 gpasswd -a daemon bin # LU-5641
10920 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
10922 declare -a identity_old
10924 for num in $(seq $MDSCOUNT); do
10925 switch_identity $num true || identity_old[$num]=$?
10928 SAVE_UMASK=$(umask)
10930 mkdir -p $DIR/$tdir
10933 echo "performing cp ..."
10934 run_acl_subtest cp || error "run_acl_subtest cp failed"
10935 echo "performing getfacl-noacl..."
10936 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
10937 echo "performing misc..."
10938 run_acl_subtest misc || error "misc test failed"
10939 echo "performing permissions..."
10940 run_acl_subtest permissions || error "permissions failed"
10941 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
10942 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
10943 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
10944 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
10946 echo "performing permissions xattr..."
10947 run_acl_subtest permissions_xattr ||
10948 error "permissions_xattr failed"
10950 echo "performing setfacl..."
10951 run_acl_subtest setfacl || error "setfacl test failed"
10953 # inheritance test got from HP
10954 echo "performing inheritance..."
10955 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
10956 chmod +x make-tree || error "chmod +x failed"
10957 run_acl_subtest inheritance || error "inheritance test failed"
10960 echo "LU-974 ignore umask when acl is enabled..."
10961 run_acl_subtest 974 || error "LU-974 umask test failed"
10962 if [ $MDSCOUNT -ge 2 ]; then
10963 run_acl_subtest 974_remote ||
10964 error "LU-974 umask test failed under remote dir"
10967 echo "LU-2561 newly created file is same size as directory..."
10968 if [ "$mds1_FSTYPE" != "zfs" ]; then
10969 run_acl_subtest 2561 || error "LU-2561 test failed"
10971 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
10974 run_acl_subtest 4924 || error "LU-4924 test failed"
10979 for num in $(seq $MDSCOUNT); do
10980 if [ "${identity_old[$num]}" = 1 ]; then
10981 switch_identity $num false || identity_old[$num]=$?
10985 run_test 103a "acl test"
10991 for U in {0..511}; do
10993 local O=$(printf "%04o" $U)
10995 umask $(printf "%04o" $((511 ^ $O)))
10996 $LFS setstripe -c 1 $DIR/$tfile.s$O
10997 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
10999 (( $S == ($O & 0666) )) ||
11000 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
11002 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
11003 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
11004 (( $S == ($O & 0666) )) ||
11005 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
11007 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
11008 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
11009 (( $S == ($O & 0666) )) ||
11010 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
11011 rm -f $DIR/$tfile.[smp]$0
11015 # limit the concurrently running threads to 64. LU-11878
11016 local idx=$((U % 64))
11017 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
11022 run_test 103b "umask lfs setstripe"
11025 mkdir -p $DIR/$tdir
11026 cp -rp $DIR/$tdir $DIR/$tdir.bak
11028 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
11029 error "$DIR/$tdir shouldn't contain default ACL"
11030 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
11031 error "$DIR/$tdir.bak shouldn't contain default ACL"
11034 run_test 103c "'cp -rp' won't set empty acl"
11039 local saved_debug=$($LCTL get_param -n debug)
11041 (( $MDS1_VERSION >= $(version_code 2.14.0) )) ||
11042 skip "MDS needs to be at least 2.14.0"
11044 large_xattr_enabled || skip_env "ea_inode feature disabled"
11046 mkdir -p $DIR/$tdir
11047 # add big LOV EA to cause reply buffer overflow earlier
11048 $LFS setstripe -C 1000 $DIR/$tdir
11049 lctl set_param mdc.*-mdc*.stats=clear
11051 $LCTL set_param debug=0
11052 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
11053 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
11055 # add a large number of default ACLs (expect 8000+ for 2.13+)
11056 for U in {2..7000}; do
11057 setfacl -d -m user:$U:rwx $DIR/$tdir ||
11058 error "Able to add just $U default ACLs"
11060 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
11061 echo "$numacl default ACLs created"
11063 stat $DIR/$tdir || error "Cannot stat directory"
11064 # check file creation
11065 touch $DIR/$tdir/$tfile ||
11066 error "failed to create $tfile with $numacl default ACLs"
11067 stat $DIR/$tdir/$tfile || error "Cannot stat file"
11068 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11069 echo "$fileacl ACLs were inherited"
11070 (( $fileacl == $numacl )) ||
11071 error "Not all default ACLs were inherited: $numacl != $fileacl"
11072 # check that new ACLs creation adds new ACLs to inherited ACLs
11073 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
11074 error "Cannot set new ACL"
11075 numacl=$((numacl + 1))
11076 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11077 (( $fileacl == $numacl )) ||
11078 error "failed to add new ACL: $fileacl != $numacl as expected"
11079 # adds more ACLs to a file to reach their maximum at 8000+
11081 for U in {20000..25000}; do
11082 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
11083 numacl=$((numacl + 1))
11085 echo "Added $numacl more ACLs to the file"
11086 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11087 echo "Total $fileacl ACLs in file"
11088 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
11089 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
11090 rmdir $DIR/$tdir || error "Cannot remove directory"
11092 run_test 103e "inheritance of big amount of default ACLs"
11095 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
11096 skip "MDS needs to be at least 2.14.51"
11098 large_xattr_enabled || skip_env "ea_inode feature disabled"
11100 # enable changelog to consume more internal MDD buffers
11103 mkdir -p $DIR/$tdir
11105 $LFS setstripe -C 1000 $DIR/$tdir
11106 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
11107 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
11108 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
11109 rmdir $DIR/$tdir || error "Cannot remove directory"
11111 run_test 103f "changelog doesn't interfere with default ACLs buffers"
11114 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11117 lfs df || error "lfs df failed"
11118 lfs df -ih || error "lfs df -ih failed"
11119 lfs df -h $DIR || error "lfs df -h $DIR failed"
11120 lfs df -i $DIR || error "lfs df -i $DIR failed"
11121 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
11122 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
11124 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
11125 lctl --device %$OSC deactivate
11126 lfs df || error "lfs df with deactivated OSC failed"
11127 lctl --device %$OSC activate
11128 # wait the osc back to normal
11129 wait_osc_import_ready client ost
11131 lfs df || error "lfs df with reactivated OSC failed"
11134 run_test 104a "lfs df [-ih] [path] test ========================="
11137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11138 [ $RUNAS_ID -eq $UID ] &&
11139 skip_env "RUNAS_ID = UID = $UID -- skipping"
11141 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
11142 grep "Permission denied" | wc -l)))
11143 if [ $denied_cnt -ne 0 ]; then
11144 error "lfs check servers test failed"
11147 run_test 104b "$RUNAS lfs check servers test ===================="
11150 # Verify $1 is within range of $2.
11151 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
11152 # $1 is <= 2% of $2. Else Fail.
11155 # Strip all units (M, G, T)
11156 actual=$(echo $1 | tr -d A-Z)
11157 expect=$(echo $2 | tr -d A-Z)
11159 expect_lo=$(($expect * 98 / 100)) # 2% below
11160 expect_hi=$(($expect * 102 / 100)) # 2% above
11162 # permit 2% drift above and below
11163 (( $actual >= $expect_lo && $actual <= $expect_hi ))
11167 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11168 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
11170 local ost_param="osd-zfs.$FSNAME-OST0000."
11171 local mdt_param="osd-zfs.$FSNAME-MDT0000."
11172 local ofacets=$(get_facets OST)
11173 local mfacets=$(get_facets MDS)
11174 local saved_ost_blocks=
11175 local saved_mdt_blocks=
11177 echo "Before recordsize change"
11178 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
11179 df=($(df -h | grep "/mnt/lustre"$))
11182 echo "lfs output : ${lfs_df[*]}"
11183 echo "df output : ${df[*]}"
11185 for facet in ${ofacets//,/ }; do
11186 if [ -z $saved_ost_blocks ]; then
11187 saved_ost_blocks=$(do_facet $facet \
11188 lctl get_param -n $ost_param.blocksize)
11189 echo "OST Blocksize: $saved_ost_blocks"
11191 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11192 do_facet $facet zfs set recordsize=32768 $ost
11195 # BS too small. Sufficient for functional testing.
11196 for facet in ${mfacets//,/ }; do
11197 if [ -z $saved_mdt_blocks ]; then
11198 saved_mdt_blocks=$(do_facet $facet \
11199 lctl get_param -n $mdt_param.blocksize)
11200 echo "MDT Blocksize: $saved_mdt_blocks"
11202 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11203 do_facet $facet zfs set recordsize=32768 $mdt
11206 # Give new values chance to reflect change
11209 echo "After recordsize change"
11210 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
11211 df_after=($(df -h | grep "/mnt/lustre"$))
11214 echo "lfs output : ${lfs_df_after[*]}"
11215 echo "df output : ${df_after[*]}"
11218 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
11219 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
11220 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
11221 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
11222 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
11223 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
11226 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
11227 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
11228 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
11229 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
11230 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
11231 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
11233 # Restore MDT recordize back to original
11234 for facet in ${mfacets//,/ }; do
11235 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11236 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
11239 # Restore OST recordize back to original
11240 for facet in ${ofacets//,/ }; do
11241 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11242 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
11247 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
11250 # doesn't work on 2.4 kernels
11252 if $(flock_is_enabled); then
11253 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
11255 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
11259 run_test 105a "flock when mounted without -o flock test ========"
11263 if $(flock_is_enabled); then
11264 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
11266 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
11270 run_test 105b "fcntl when mounted without -o flock test ========"
11274 if $(flock_is_enabled); then
11275 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
11277 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
11281 run_test 105c "lockf when mounted without -o flock test"
11283 test_105d() { # bug 15924
11284 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11286 test_mkdir $DIR/$tdir
11287 flock_is_enabled || skip_env "mount w/o flock enabled"
11288 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
11289 $LCTL set_param fail_loc=0x80000315
11290 flocks_test 2 $DIR/$tdir
11292 run_test 105d "flock race (should not freeze) ========"
11294 test_105e() { # bug 22660 && 22040
11295 flock_is_enabled || skip_env "mount w/o flock enabled"
11298 flocks_test 3 $DIR/$tfile
11300 run_test 105e "Two conflicting flocks from same process"
11302 test_106() { #bug 10921
11303 test_mkdir $DIR/$tdir
11304 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
11305 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
11307 run_test 106 "attempt exec of dir followed by chown of that dir"
11310 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11318 local save_pattern=$(sysctl -n kernel.core_pattern)
11319 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
11320 sysctl -w kernel.core_pattern=$file
11321 sysctl -w kernel.core_uses_pid=0
11323 ulimit -c unlimited
11329 kill -s 11 $SLEEPPID
11331 if [ -e $file ]; then
11332 size=`stat -c%s $file`
11333 [ $size -eq 0 ] && error "Fail to create core file $file"
11335 error "Fail to create core file $file"
11338 sysctl -w kernel.core_pattern=$save_pattern
11339 sysctl -w kernel.core_uses_pid=$save_uses_pid
11342 run_test 107 "Coredump on SIG"
11345 test_mkdir $DIR/$tdir
11346 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
11347 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
11348 error "mkdir with 256 char should fail, but did not"
11349 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
11350 error "create with 255 char failed"
11351 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
11352 error "create with 256 char should fail, but did not"
11357 run_test 110 "filename length checking"
11360 # Purpose: To verify dynamic thread (OSS) creation.
11363 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11364 remote_ost_nodsh && skip "remote OST with nodsh"
11366 # Lustre does not stop service threads once they are started.
11367 # Reset number of running threads to default.
11372 local save_params="$TMP/sanity-$TESTNAME.parameters"
11374 # Get ll_ost_io count before I/O
11375 OSTIO_pre=$(do_facet ost1 \
11376 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
11377 # Exit if lustre is not running (ll_ost_io not running).
11378 [ -z "$OSTIO_pre" ] && error "no OSS threads"
11380 echo "Starting with $OSTIO_pre threads"
11381 local thread_max=$((OSTIO_pre * 2))
11382 local rpc_in_flight=$((thread_max * 2))
11383 # Number of I/O Process proposed to be started.
11385 local facets=$(get_facets OST)
11387 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
11388 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
11390 # Set in_flight to $rpc_in_flight
11391 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
11392 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
11393 nfiles=${rpc_in_flight}
11394 # Set ost thread_max to $thread_max
11395 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
11397 # 5 Minutes should be sufficient for max number of OSS
11398 # threads(thread_max) to be created.
11402 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
11403 test_mkdir $DIR/$tdir
11404 for i in $(seq $nfiles); do
11405 local file=$DIR/$tdir/${tfile}-$i
11406 $LFS setstripe -c -1 -i 0 $file
11407 ($WTL $file $timeout)&
11410 # I/O Started - Wait for thread_started to reach thread_max or report
11411 # error if thread_started is more than thread_max.
11412 echo "Waiting for thread_started to reach thread_max"
11413 local thread_started=0
11414 local end_time=$((SECONDS + timeout))
11416 while [ $SECONDS -le $end_time ] ; do
11418 # Get ost i/o thread_started count.
11419 thread_started=$(do_facet ost1 \
11421 ost.OSS.ost_io.threads_started | cut -d= -f2")
11422 # Break out if thread_started is equal/greater than thread_max
11423 if [[ $thread_started -ge $thread_max ]]; then
11424 echo ll_ost_io thread_started $thread_started, \
11425 equal/greater than thread_max $thread_max
11431 # Cleanup - We have the numbers, Kill i/o jobs if running.
11432 jobcount=($(jobs -p))
11433 for i in $(seq 0 $((${#jobcount[@]}-1)))
11435 kill -9 ${jobcount[$i]}
11436 if [ $? -ne 0 ] ; then
11438 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
11442 # Cleanup files left by WTL binary.
11443 for i in $(seq $nfiles); do
11444 local file=$DIR/$tdir/${tfile}-$i
11446 if [ $? -ne 0 ] ; then
11447 echo "Warning: Failed to delete file $file"
11451 restore_lustre_params <$save_params
11452 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
11454 # Error out if no new thread has started or Thread started is greater
11456 if [[ $thread_started -le $OSTIO_pre ||
11457 $thread_started -gt $thread_max ]]; then
11458 error "ll_ost_io: thread_started $thread_started" \
11459 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
11460 "No new thread started or thread started greater " \
11464 run_test 115 "verify dynamic thread creation===================="
11467 wait_delete_completed
11468 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
11469 echo "OST kbytes available: ${AVAIL[@]}"
11474 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
11475 #echo OST $i: ${AVAIL[i]}kb
11476 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
11480 if [[ ${AVAIL[i]} -lt $MINV ]]; then
11485 echo "Min free space: OST $MINI: $MINV"
11486 echo "Max free space: OST $MAXI: $MAXV"
11489 test_116a() { # was previously test_116()
11490 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11491 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11492 remote_mds_nodsh && skip "remote MDS with nodsh"
11494 echo -n "Free space priority "
11495 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
11500 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
11501 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
11502 trap simple_cleanup_common EXIT
11504 # Check if we need to generate uneven OSTs
11505 test_mkdir -p $DIR/$tdir/OST${MINI}
11506 local FILL=$((MINV / 4))
11507 local DIFF=$((MAXV - MINV))
11508 local DIFF2=$((DIFF * 100 / MINV))
11510 local threshold=$(do_facet $SINGLEMDS \
11511 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
11512 threshold=${threshold%%%}
11513 echo -n "Check for uneven OSTs: "
11514 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
11516 if [[ $DIFF2 -gt $threshold ]]; then
11518 echo "Don't need to fill OST$MINI"
11520 # generate uneven OSTs. Write 2% over the QOS threshold value
11522 DIFF=$((threshold - DIFF2 + 2))
11523 DIFF2=$((MINV * DIFF / 100))
11524 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
11525 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
11526 error "setstripe failed"
11527 DIFF=$((DIFF2 / 2048))
11529 while [ $i -lt $DIFF ]; do
11531 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
11532 bs=2M count=1 2>/dev/null
11541 DIFF=$((MAXV - MINV))
11542 DIFF2=$((DIFF * 100 / MINV))
11543 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
11544 if [ $DIFF2 -gt $threshold ]; then
11547 echo "failed - QOS mode won't be used"
11548 simple_cleanup_common
11549 skip "QOS imbalance criteria not met"
11557 # now fill using QOS
11558 $LFS setstripe -c 1 $DIR/$tdir
11559 FILL=$((FILL / 200))
11560 if [ $FILL -gt 600 ]; then
11563 echo "writing $FILL files to QOS-assigned OSTs"
11565 while [ $i -lt $FILL ]; do
11567 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
11568 count=1 2>/dev/null
11571 echo "wrote $i 200k files"
11575 echo "Note: free space may not be updated, so measurements might be off"
11577 DIFF2=$((MAXV - MINV))
11578 echo "free space delta: orig $DIFF final $DIFF2"
11579 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
11580 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
11581 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
11582 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
11583 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
11584 if [[ $DIFF -gt 0 ]]; then
11585 FILL=$((DIFF2 * 100 / DIFF - 100))
11586 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
11589 # Figure out which files were written where
11590 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
11591 awk '/'$MINI1': / {print $2; exit}')
11593 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
11594 echo "$MINC files created on smaller OST $MINI1"
11595 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
11596 awk '/'$MAXI1': / {print $2; exit}')
11598 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
11599 echo "$MAXC files created on larger OST $MAXI1"
11600 if [[ $MINC -gt 0 ]]; then
11601 FILL=$((MAXC * 100 / MINC - 100))
11602 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
11604 [[ $MAXC -gt $MINC ]] ||
11605 error_ignore LU-9 "stripe QOS didn't balance free space"
11606 simple_cleanup_common
11608 run_test 116a "stripe QOS: free space balance ==================="
11610 test_116b() { # LU-2093
11611 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11612 remote_mds_nodsh && skip "remote MDS with nodsh"
11614 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
11615 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
11616 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
11617 [ -z "$old_rr" ] && skip "no QOS"
11618 do_facet $SINGLEMDS lctl set_param \
11619 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
11620 mkdir -p $DIR/$tdir
11621 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
11622 createmany -o $DIR/$tdir/f- 20 || error "can't create"
11623 do_facet $SINGLEMDS lctl set_param fail_loc=0
11625 do_facet $SINGLEMDS lctl set_param \
11626 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
11628 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
11630 test_117() # bug 10891
11632 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11634 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
11635 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
11636 lctl set_param fail_loc=0x21e
11637 > $DIR/$tfile || error "truncate failed"
11638 lctl set_param fail_loc=0
11639 echo "Truncate succeeded."
11642 run_test 117 "verify osd extend =========="
11644 NO_SLOW_RESENDCOUNT=4
11645 export OLD_RESENDCOUNT=""
11646 set_resend_count () {
11647 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
11648 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
11649 lctl set_param -n $PROC_RESENDCOUNT $1
11650 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
11653 # for reduce test_118* time (b=14842)
11654 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
11656 # Reset async IO behavior after error case
11658 FILE=$DIR/reset_async
11660 # Ensure all OSCs are cleared
11661 $LFS setstripe -c -1 $FILE
11662 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
11667 test_118a() #bug 11710
11669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11673 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11674 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11675 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
11677 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11678 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11683 run_test 118a "verify O_SYNC works =========="
11687 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11688 remote_ost_nodsh && skip "remote OST with nodsh"
11692 #define OBD_FAIL_SRV_ENOENT 0x217
11693 set_nodes_failloc "$(osts_nodes)" 0x217
11694 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11696 set_nodes_failloc "$(osts_nodes)" 0
11697 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11698 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11701 if [[ $RC -eq 0 ]]; then
11702 error "Must return error due to dropped pages, rc=$RC"
11706 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11707 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11711 echo "Dirty pages not leaked on ENOENT"
11713 # Due to the above error the OSC will issue all RPCs syncronously
11714 # until a subsequent RPC completes successfully without error.
11715 $MULTIOP $DIR/$tfile Ow4096yc
11720 run_test 118b "Reclaim dirty pages on fatal error =========="
11724 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11726 # for 118c, restore the original resend count, LU-1940
11727 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
11728 set_resend_count $OLD_RESENDCOUNT
11729 remote_ost_nodsh && skip "remote OST with nodsh"
11733 #define OBD_FAIL_OST_EROFS 0x216
11734 set_nodes_failloc "$(osts_nodes)" 0x216
11736 # multiop should block due to fsync until pages are written
11737 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
11741 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
11742 error "Multiop failed to block on fsync, pid=$MULTIPID"
11745 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11747 if [[ $WRITEBACK -eq 0 ]]; then
11748 error "No page in writeback, writeback=$WRITEBACK"
11751 set_nodes_failloc "$(osts_nodes)" 0
11754 if [[ $RC -ne 0 ]]; then
11755 error "Multiop fsync failed, rc=$RC"
11758 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11759 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11761 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11762 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11766 echo "Dirty pages flushed via fsync on EROFS"
11769 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
11771 # continue to use small resend count to reduce test_118* time (b=14842)
11772 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
11776 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11777 remote_ost_nodsh && skip "remote OST with nodsh"
11781 #define OBD_FAIL_OST_BRW_PAUSE_BULK
11782 set_nodes_failloc "$(osts_nodes)" 0x214
11783 # multiop should block due to fsync until pages are written
11784 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
11788 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
11789 error "Multiop failed to block on fsync, pid=$MULTIPID"
11792 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11794 if [[ $WRITEBACK -eq 0 ]]; then
11795 error "No page in writeback, writeback=$WRITEBACK"
11798 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
11799 set_nodes_failloc "$(osts_nodes)" 0
11801 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11802 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11804 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11805 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11809 echo "Dirty pages gaurenteed flushed via fsync"
11812 run_test 118d "Fsync validation inject a delay of the bulk =========="
11815 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11819 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
11820 lctl set_param fail_loc=0x8000040a
11822 # Should simulate EINVAL error which is fatal
11823 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11825 if [[ $RC -eq 0 ]]; then
11826 error "Must return error due to dropped pages, rc=$RC"
11829 lctl set_param fail_loc=0x0
11831 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11832 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11833 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11835 if [[ $LOCKED -ne 0 ]]; then
11836 error "Locked pages remain in cache, locked=$LOCKED"
11839 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11840 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11844 echo "No pages locked after fsync"
11849 run_test 118f "Simulate unrecoverable OSC side error =========="
11852 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11856 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
11857 lctl set_param fail_loc=0x406
11859 # simulate local -ENOMEM
11860 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11863 lctl set_param fail_loc=0
11864 if [[ $RC -eq 0 ]]; then
11865 error "Must return error due to dropped pages, rc=$RC"
11868 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11869 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11870 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11872 if [[ $LOCKED -ne 0 ]]; then
11873 error "Locked pages remain in cache, locked=$LOCKED"
11876 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11877 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11881 echo "No pages locked after fsync"
11886 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
11889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11890 remote_ost_nodsh && skip "remote OST with nodsh"
11894 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
11895 set_nodes_failloc "$(osts_nodes)" 0x20e
11896 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
11897 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11900 set_nodes_failloc "$(osts_nodes)" 0
11901 if [[ $RC -eq 0 ]]; then
11902 error "Must return error due to dropped pages, rc=$RC"
11905 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11906 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11907 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11909 if [[ $LOCKED -ne 0 ]]; then
11910 error "Locked pages remain in cache, locked=$LOCKED"
11913 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11914 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11918 echo "No pages locked after fsync"
11922 run_test 118h "Verify timeout in handling recoverables errors =========="
11924 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
11927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11928 remote_ost_nodsh && skip "remote OST with nodsh"
11932 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
11933 set_nodes_failloc "$(osts_nodes)" 0x20e
11935 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
11936 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
11939 set_nodes_failloc "$(osts_nodes)" 0
11943 if [[ $RC -ne 0 ]]; then
11944 error "got error, but should be not, rc=$RC"
11947 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11948 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11949 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
11950 if [[ $LOCKED -ne 0 ]]; then
11951 error "Locked pages remain in cache, locked=$LOCKED"
11954 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11955 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11959 echo "No pages locked after fsync"
11963 run_test 118i "Fix error before timeout in recoverable error =========="
11965 [ "$SLOW" = "no" ] && set_resend_count 4
11968 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11969 remote_ost_nodsh && skip "remote OST with nodsh"
11973 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
11974 set_nodes_failloc "$(osts_nodes)" 0x220
11976 # return -EIO from OST
11977 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11979 set_nodes_failloc "$(osts_nodes)" 0x0
11980 if [[ $RC -eq 0 ]]; then
11981 error "Must return error due to dropped pages, rc=$RC"
11984 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11985 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11986 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
11987 if [[ $LOCKED -ne 0 ]]; then
11988 error "Locked pages remain in cache, locked=$LOCKED"
11991 # in recoverable error on OST we want resend and stay until it finished
11992 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11993 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11997 echo "No pages locked after fsync"
12001 run_test 118j "Simulate unrecoverable OST side error =========="
12005 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12006 remote_ost_nodsh && skip "remote OSTs with nodsh"
12008 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12009 set_nodes_failloc "$(osts_nodes)" 0x20e
12010 test_mkdir $DIR/$tdir
12012 for ((i=0;i<10;i++)); do
12013 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
12014 error "dd to $DIR/$tdir/$tfile-$i failed" )&
12021 set_nodes_failloc "$(osts_nodes)" 0
12024 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
12026 test_118l() # LU-646
12028 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12030 test_mkdir $DIR/$tdir
12031 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
12034 run_test 118l "fsync dir"
12036 test_118m() # LU-3066
12038 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12040 test_mkdir $DIR/$tdir
12041 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
12044 run_test 118m "fdatasync dir ========="
12046 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12053 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12054 remote_ost_nodsh && skip "remote OSTs with nodsh"
12056 # Sleep to avoid a cached response.
12057 #define OBD_STATFS_CACHE_SECONDS 1
12060 # Inject a 10 second delay in the OST_STATFS handler.
12061 #define OBD_FAIL_OST_STATFS_DELAY 0x242
12062 set_nodes_failloc "$(osts_nodes)" 0x242
12065 stat --file-system $MOUNT > /dev/null
12068 set_nodes_failloc "$(osts_nodes)" 0
12070 if ((end - begin > 20)); then
12071 error "statfs took $((end - begin)) seconds, expected 10"
12074 run_test 118n "statfs() sends OST_STATFS requests in parallel"
12076 test_119a() # bug 11737
12078 BSIZE=$((512 * 1024))
12079 directio write $DIR/$tfile 0 1 $BSIZE
12080 # We ask to read two blocks, which is more than a file size.
12081 # directio will indicate an error when requested and actual
12082 # sizes aren't equeal (a normal situation in this case) and
12083 # print actual read amount.
12084 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
12085 if [ "$NOB" != "$BSIZE" ]; then
12086 error "read $NOB bytes instead of $BSIZE"
12090 run_test 119a "Short directIO read must return actual read amount"
12092 test_119b() # bug 11737
12094 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12096 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
12097 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
12099 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
12100 error "direct read failed"
12103 run_test 119b "Sparse directIO read must return actual read amount"
12105 test_119c() # bug 13099
12108 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
12109 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
12112 run_test 119c "Testing for direct read hitting hole"
12114 test_119d() # bug 15950
12116 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12118 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
12119 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
12121 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
12122 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
12123 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
12124 lctl set_param fail_loc=0x40d
12125 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
12128 cat $DIR/$tfile > /dev/null &
12129 lctl set_param fail_loc=0
12132 log "the DIO writes have completed, now wait for the reads (should not block very long)"
12134 [ -n "`ps h -p $pid_reads -o comm`" ] && \
12135 error "the read rpcs have not completed in 2s"
12137 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
12139 run_test 119d "The DIO path should try to send a new rpc once one is completed"
12142 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12143 remote_mds_nodsh && skip "remote MDS with nodsh"
12144 test_mkdir -i0 -c1 $DIR/$tdir
12145 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12146 skip_env "no early lock cancel on server"
12148 lru_resize_disable mdc
12149 lru_resize_disable osc
12150 cancel_lru_locks mdc
12151 # asynchronous object destroy at MDT could cause bl ast to client
12152 cancel_lru_locks osc
12154 stat $DIR/$tdir > /dev/null
12155 can1=$(do_facet mds1 \
12156 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12157 awk '/ldlm_cancel/ {print $2}')
12158 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12159 awk '/ldlm_bl_callback/ {print $2}')
12160 test_mkdir -i0 -c1 $DIR/$tdir/d1
12161 can2=$(do_facet mds1 \
12162 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12163 awk '/ldlm_cancel/ {print $2}')
12164 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12165 awk '/ldlm_bl_callback/ {print $2}')
12166 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12167 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12168 lru_resize_enable mdc
12169 lru_resize_enable osc
12171 run_test 120a "Early Lock Cancel: mkdir test"
12174 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12175 remote_mds_nodsh && skip "remote MDS with nodsh"
12176 test_mkdir $DIR/$tdir
12177 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12178 skip_env "no early lock cancel on server"
12180 lru_resize_disable mdc
12181 lru_resize_disable osc
12182 cancel_lru_locks mdc
12183 stat $DIR/$tdir > /dev/null
12184 can1=$(do_facet $SINGLEMDS \
12185 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12186 awk '/ldlm_cancel/ {print $2}')
12187 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12188 awk '/ldlm_bl_callback/ {print $2}')
12189 touch $DIR/$tdir/f1
12190 can2=$(do_facet $SINGLEMDS \
12191 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12192 awk '/ldlm_cancel/ {print $2}')
12193 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12194 awk '/ldlm_bl_callback/ {print $2}')
12195 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12196 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12197 lru_resize_enable mdc
12198 lru_resize_enable osc
12200 run_test 120b "Early Lock Cancel: create test"
12203 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12204 remote_mds_nodsh && skip "remote MDS with nodsh"
12205 test_mkdir -i0 -c1 $DIR/$tdir
12206 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12207 skip "no early lock cancel on server"
12209 lru_resize_disable mdc
12210 lru_resize_disable osc
12211 test_mkdir -i0 -c1 $DIR/$tdir/d1
12212 test_mkdir -i0 -c1 $DIR/$tdir/d2
12213 touch $DIR/$tdir/d1/f1
12214 cancel_lru_locks mdc
12215 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
12216 can1=$(do_facet mds1 \
12217 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12218 awk '/ldlm_cancel/ {print $2}')
12219 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12220 awk '/ldlm_bl_callback/ {print $2}')
12221 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
12222 can2=$(do_facet mds1 \
12223 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12224 awk '/ldlm_cancel/ {print $2}')
12225 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12226 awk '/ldlm_bl_callback/ {print $2}')
12227 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12228 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12229 lru_resize_enable mdc
12230 lru_resize_enable osc
12232 run_test 120c "Early Lock Cancel: link test"
12235 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12236 remote_mds_nodsh && skip "remote MDS with nodsh"
12237 test_mkdir -i0 -c1 $DIR/$tdir
12238 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12239 skip_env "no early lock cancel on server"
12241 lru_resize_disable mdc
12242 lru_resize_disable osc
12244 cancel_lru_locks mdc
12245 stat $DIR/$tdir > /dev/null
12246 can1=$(do_facet mds1 \
12247 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12248 awk '/ldlm_cancel/ {print $2}')
12249 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12250 awk '/ldlm_bl_callback/ {print $2}')
12251 chmod a+x $DIR/$tdir
12252 can2=$(do_facet mds1 \
12253 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12254 awk '/ldlm_cancel/ {print $2}')
12255 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12256 awk '/ldlm_bl_callback/ {print $2}')
12257 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12258 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12259 lru_resize_enable mdc
12260 lru_resize_enable osc
12262 run_test 120d "Early Lock Cancel: setattr test"
12265 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12266 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12267 skip_env "no early lock cancel on server"
12268 remote_mds_nodsh && skip "remote MDS with nodsh"
12270 local dlmtrace_set=false
12272 test_mkdir -i0 -c1 $DIR/$tdir
12273 lru_resize_disable mdc
12274 lru_resize_disable osc
12275 ! $LCTL get_param debug | grep -q dlmtrace &&
12276 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
12277 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
12278 cancel_lru_locks mdc
12279 cancel_lru_locks osc
12280 dd if=$DIR/$tdir/f1 of=/dev/null
12281 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
12282 # XXX client can not do early lock cancel of OST lock
12283 # during unlink (LU-4206), so cancel osc lock now.
12285 cancel_lru_locks osc
12286 can1=$(do_facet mds1 \
12287 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12288 awk '/ldlm_cancel/ {print $2}')
12289 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12290 awk '/ldlm_bl_callback/ {print $2}')
12291 unlink $DIR/$tdir/f1
12293 can2=$(do_facet mds1 \
12294 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12295 awk '/ldlm_cancel/ {print $2}')
12296 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12297 awk '/ldlm_bl_callback/ {print $2}')
12298 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
12299 $LCTL dk $TMP/cancel.debug.txt
12300 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
12301 $LCTL dk $TMP/blocking.debug.txt
12302 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
12303 lru_resize_enable mdc
12304 lru_resize_enable osc
12306 run_test 120e "Early Lock Cancel: unlink test"
12309 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12310 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12311 skip_env "no early lock cancel on server"
12312 remote_mds_nodsh && skip "remote MDS with nodsh"
12314 test_mkdir -i0 -c1 $DIR/$tdir
12315 lru_resize_disable mdc
12316 lru_resize_disable osc
12317 test_mkdir -i0 -c1 $DIR/$tdir/d1
12318 test_mkdir -i0 -c1 $DIR/$tdir/d2
12319 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
12320 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
12321 cancel_lru_locks mdc
12322 cancel_lru_locks osc
12323 dd if=$DIR/$tdir/d1/f1 of=/dev/null
12324 dd if=$DIR/$tdir/d2/f2 of=/dev/null
12325 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
12326 # XXX client can not do early lock cancel of OST lock
12327 # during rename (LU-4206), so cancel osc lock now.
12329 cancel_lru_locks osc
12330 can1=$(do_facet mds1 \
12331 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12332 awk '/ldlm_cancel/ {print $2}')
12333 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12334 awk '/ldlm_bl_callback/ {print $2}')
12335 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
12337 can2=$(do_facet mds1 \
12338 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12339 awk '/ldlm_cancel/ {print $2}')
12340 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12341 awk '/ldlm_bl_callback/ {print $2}')
12342 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12343 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12344 lru_resize_enable mdc
12345 lru_resize_enable osc
12347 run_test 120f "Early Lock Cancel: rename test"
12350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12351 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12352 skip_env "no early lock cancel on server"
12353 remote_mds_nodsh && skip "remote MDS with nodsh"
12355 lru_resize_disable mdc
12356 lru_resize_disable osc
12358 echo create $count files
12359 test_mkdir $DIR/$tdir
12360 cancel_lru_locks mdc
12361 cancel_lru_locks osc
12364 can0=$(do_facet $SINGLEMDS \
12365 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12366 awk '/ldlm_cancel/ {print $2}')
12367 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12368 awk '/ldlm_bl_callback/ {print $2}')
12369 createmany -o $DIR/$tdir/f $count
12371 can1=$(do_facet $SINGLEMDS \
12372 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12373 awk '/ldlm_cancel/ {print $2}')
12374 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12375 awk '/ldlm_bl_callback/ {print $2}')
12377 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
12378 echo rm $count files
12381 can2=$(do_facet $SINGLEMDS \
12382 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12383 awk '/ldlm_cancel/ {print $2}')
12384 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12385 awk '/ldlm_bl_callback/ {print $2}')
12387 echo total: $count removes in $((t2-t1))
12388 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
12390 # wait for commitment of removal
12391 lru_resize_enable mdc
12392 lru_resize_enable osc
12394 run_test 120g "Early Lock Cancel: performance test"
12396 test_121() { #bug #10589
12397 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12400 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
12401 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
12402 lctl set_param fail_loc=0x310
12403 cancel_lru_locks osc > /dev/null
12404 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
12405 lctl set_param fail_loc=0
12406 [[ $reads -eq $writes ]] ||
12407 error "read $reads blocks, must be $writes blocks"
12409 run_test 121 "read cancel race ========="
12411 test_123a_base() { # was test 123, statahead(bug 11401)
12415 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
12416 log "testing UP system. Performance may be lower than expected."
12421 test_mkdir $DIR/$tdir
12422 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
12423 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
12425 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
12426 createmany -o $DIR/$tdir/$tfile $j $((i - j))
12428 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
12429 lctl set_param -n llite.*.statahead_max 0
12430 lctl get_param llite.*.statahead_max
12431 cancel_lru_locks mdc
12432 cancel_lru_locks osc
12434 time $lsx $DIR/$tdir | wc -l
12436 delta=$((etime - stime))
12437 log "$lsx $i files without statahead: $delta sec"
12438 lctl set_param llite.*.statahead_max=$max
12440 swrong=$(lctl get_param -n llite.*.statahead_stats |
12441 grep "statahead wrong:" | awk '{print $3}')
12442 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
12443 cancel_lru_locks mdc
12444 cancel_lru_locks osc
12446 time $lsx $DIR/$tdir | wc -l
12448 delta_sa=$((etime - stime))
12449 log "$lsx $i files with statahead: $delta_sa sec"
12450 lctl get_param -n llite.*.statahead_stats
12451 ewrong=$(lctl get_param -n llite.*.statahead_stats |
12452 grep "statahead wrong:" | awk '{print $3}')
12454 [[ $swrong -lt $ewrong ]] &&
12455 log "statahead was stopped, maybe too many locks held!"
12456 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
12458 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
12459 max=$(lctl get_param -n llite.*.statahead_max |
12461 lctl set_param -n llite.*.statahead_max 0
12462 lctl get_param llite.*.statahead_max
12463 cancel_lru_locks mdc
12464 cancel_lru_locks osc
12466 time $lsx $DIR/$tdir | wc -l
12468 delta=$((etime - stime))
12469 log "$lsx $i files again without statahead: $delta sec"
12470 lctl set_param llite.*.statahead_max=$max
12471 if [ $((delta_sa * 100 > delta * 105 && delta_sa > delta + 2)) ]; then
12472 if [ $SLOWOK -eq 0 ]; then
12473 error "$lsx $i files is slower with statahead!"
12475 log "$lsx $i files is slower with statahead!"
12481 [ $delta -gt 20 ] && break
12482 [ $delta -gt 8 ] && MULT=$((50 / delta))
12483 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
12491 delta=$((etime - stime))
12492 log "rm -r $DIR/$tdir/: $delta seconds"
12494 lctl get_param -n llite.*.statahead_stats
12498 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12500 test_123a_base "ls -l"
12502 run_test 123aa "verify statahead work"
12505 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12507 statx_supported || skip_env "Test must be statx() syscall supported"
12509 test_123a_base "$STATX -l"
12511 run_test 123ab "verify statahead work by using statx"
12514 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12516 statx_supported || skip_env "Test must be statx() syscall supported"
12523 cancel_lru_locks $OSC
12524 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
12525 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
12526 awk '/agl.total:/ {print $3}')
12527 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
12528 test_123a_base "$STATX --cached=always -D"
12529 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
12530 awk '/agl.total:/ {print $3}')
12531 [ $agl_before -eq $agl_after ] ||
12532 error "Should not trigger AGL thread - $agl_before:$agl_after"
12533 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
12534 [ $rpcs_after -eq $rpcs_before ] ||
12535 error "$STATX should not send glimpse RPCs to $OSC"
12537 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
12539 test_123b () { # statahead(bug 15027)
12540 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12542 test_mkdir $DIR/$tdir
12543 createmany -o $DIR/$tdir/$tfile-%d 1000
12545 cancel_lru_locks mdc
12546 cancel_lru_locks osc
12548 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
12549 lctl set_param fail_loc=0x80000803
12550 ls -lR $DIR/$tdir > /dev/null
12552 lctl set_param fail_loc=0x0
12553 lctl get_param -n llite.*.statahead_stats
12558 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
12561 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
12563 test_mkdir -i 0 -c 1 $DIR/$tdir.0
12564 test_mkdir -i 1 -c 1 $DIR/$tdir.1
12565 touch $DIR/$tdir.1/{1..3}
12566 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
12568 remount_client $MOUNT
12570 $MULTIOP $DIR/$tdir.0 Q
12572 # let statahead to complete
12573 ls -l $DIR/$tdir.0 > /dev/null
12575 testid=$(echo $TESTNAME | tr '_' ' ')
12576 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
12577 error "statahead warning" || true
12579 run_test 123c "Can not initialize inode warning on DNE statahead"
12582 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12583 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
12584 skip_env "no lru resize on server"
12588 test_mkdir $DIR/$tdir
12590 log "create $NR files at $DIR/$tdir"
12591 createmany -o $DIR/$tdir/f $NR ||
12592 error "failed to create $NR files in $DIR/$tdir"
12594 cancel_lru_locks mdc
12595 ls -l $DIR/$tdir > /dev/null
12599 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
12600 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
12601 LRU_SIZE=$($LCTL get_param -n $PARAM)
12602 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
12603 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
12605 log "NS=$(basename $NSDIR)"
12610 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
12611 skip "Not enough cached locks created!"
12613 log "LRU=$LRU_SIZE"
12617 # We know that lru resize allows one client to hold $LIMIT locks
12618 # for 10h. After that locks begin to be killed by client.
12620 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
12622 if [ $LIMIT -lt $LRU_SIZE ]; then
12623 skip "Limit is too small $LIMIT"
12626 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
12627 # killing locks. Some time was spent for creating locks. This means
12628 # that up to the moment of sleep finish we must have killed some of
12629 # them (10-100 locks). This depends on how fast ther were created.
12630 # Many of them were touched in almost the same moment and thus will
12631 # be killed in groups.
12632 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
12634 # Use $LRU_SIZE_B here to take into account real number of locks
12635 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
12636 local LRU_SIZE_B=$LRU_SIZE
12638 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
12639 log "OLD_LVF=$OLD_LVF"
12640 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
12642 # Let's make sure that we really have some margin. Client checks
12643 # cached locks every 10 sec.
12644 SLEEP=$((SLEEP+20))
12645 log "Sleep ${SLEEP} sec"
12647 while ((SEC<$SLEEP)); do
12651 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
12652 echo -n "$LRU_SIZE"
12655 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
12656 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
12658 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
12659 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
12660 unlinkmany $DIR/$tdir/f $NR
12664 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
12665 log "unlink $NR files at $DIR/$tdir"
12666 unlinkmany $DIR/$tdir/f $NR
12668 run_test 124a "lru resize ======================================="
12670 get_max_pool_limit()
12672 local limit=$($LCTL get_param \
12673 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
12675 for l in $limit; do
12676 if [[ $l -gt $max ]]; then
12684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12685 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
12686 skip_env "no lru resize on server"
12688 LIMIT=$(get_max_pool_limit)
12690 NR=$(($(default_lru_size)*20))
12691 if [[ $NR -gt $LIMIT ]]; then
12692 log "Limit lock number by $LIMIT locks"
12696 IFree=$(mdsrate_inodes_available)
12697 if [ $IFree -lt $NR ]; then
12698 log "Limit lock number by $IFree inodes"
12702 lru_resize_disable mdc
12703 test_mkdir -p $DIR/$tdir/disable_lru_resize
12705 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
12706 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
12707 cancel_lru_locks mdc
12710 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
12713 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
12716 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
12720 nolruresize_delta=$((etime-stime))
12721 log "ls -la time: $nolruresize_delta seconds"
12722 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
12723 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
12725 lru_resize_enable mdc
12726 test_mkdir -p $DIR/$tdir/enable_lru_resize
12728 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
12729 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
12730 cancel_lru_locks mdc
12733 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
12736 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
12739 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
12743 lruresize_delta=$((etime-stime))
12744 log "ls -la time: $lruresize_delta seconds"
12745 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
12747 if [ $lruresize_delta -gt $nolruresize_delta ]; then
12748 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
12749 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
12750 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
12752 log "lru resize performs the same with no lru resize"
12754 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
12756 run_test 124b "lru resize (performance test) ======================="
12759 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12760 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
12761 skip_env "no lru resize on server"
12763 # cache ununsed locks on client
12765 cancel_lru_locks mdc
12766 test_mkdir $DIR/$tdir
12767 createmany -o $DIR/$tdir/f $nr ||
12768 error "failed to create $nr files in $DIR/$tdir"
12769 ls -l $DIR/$tdir > /dev/null
12771 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12772 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12773 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
12774 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
12775 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
12777 # set lru_max_age to 1 sec
12778 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
12779 echo "sleep $((recalc_p * 2)) seconds..."
12780 sleep $((recalc_p * 2))
12782 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
12783 # restore lru_max_age
12784 $LCTL set_param -n $nsdir.lru_max_age $max_age
12785 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
12786 unlinkmany $DIR/$tdir/f $nr
12788 run_test 124c "LRUR cancel very aged locks"
12791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12792 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
12793 skip_env "no lru resize on server"
12795 # cache ununsed locks on client
12798 lru_resize_disable mdc
12799 stack_trap "lru_resize_enable mdc" EXIT
12801 cancel_lru_locks mdc
12803 # asynchronous object destroy at MDT could cause bl ast to client
12804 test_mkdir $DIR/$tdir
12805 createmany -o $DIR/$tdir/f $nr ||
12806 error "failed to create $nr files in $DIR/$tdir"
12807 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
12809 ls -l $DIR/$tdir > /dev/null
12811 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12812 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12813 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
12814 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
12816 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
12818 # set lru_max_age to 1 sec
12819 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
12820 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
12822 echo "sleep $((recalc_p * 2)) seconds..."
12823 sleep $((recalc_p * 2))
12825 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
12827 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
12829 run_test 124d "cancel very aged locks if lru-resize diasbaled"
12831 test_125() { # 13358
12832 $LCTL get_param -n llite.*.client_type | grep -q local ||
12833 skip "must run as local client"
12834 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
12835 skip_env "must have acl enabled"
12836 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
12838 test_mkdir $DIR/$tdir
12839 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
12840 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
12841 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
12843 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
12845 test_126() { # bug 12829/13455
12846 $GSS && skip_env "must run as gss disabled"
12847 $LCTL get_param -n llite.*.client_type | grep -q local ||
12848 skip "must run as local client"
12849 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
12851 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
12852 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
12854 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
12856 run_test 126 "check that the fsgid provided by the client is taken into account"
12858 test_127a() { # bug 15521
12859 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12860 local name count samp unit min max sum sumsq
12862 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
12863 echo "stats before reset"
12864 $LCTL get_param osc.*.stats
12865 $LCTL set_param osc.*.stats=0
12866 local fsize=$((2048 * 1024))
12868 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
12869 cancel_lru_locks osc
12870 dd if=$DIR/$tfile of=/dev/null bs=$fsize
12872 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
12873 stack_trap "rm -f $TMP/$tfile.tmp"
12874 while read name count samp unit min max sum sumsq; do
12875 echo "got name=$name count=$count unit=$unit min=$min max=$max"
12876 [ ! $min ] && error "Missing min value for $name proc entry"
12877 eval $name=$count || error "Wrong proc format"
12880 read_bytes|write_bytes)
12881 [[ "$unit" =~ "bytes" ]] ||
12882 error "unit is not 'bytes': $unit"
12883 (( $min >= 4096 )) || error "min is too small: $min"
12884 (( $min <= $fsize )) || error "min is too big: $min"
12885 (( $max >= 4096 )) || error "max is too small: $max"
12886 (( $max <= $fsize )) || error "max is too big: $max"
12887 (( $sum == $fsize )) || error "sum is wrong: $sum"
12888 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
12889 error "sumsquare is too small: $sumsq"
12890 (( $sumsq <= $fsize * $fsize )) ||
12891 error "sumsquare is too big: $sumsq"
12893 ost_read|ost_write)
12894 [[ "$unit" =~ "usec" ]] ||
12895 error "unit is not 'usec': $unit"
12899 done < $DIR/$tfile.tmp
12901 #check that we actually got some stats
12902 [ "$read_bytes" ] || error "Missing read_bytes stats"
12903 [ "$write_bytes" ] || error "Missing write_bytes stats"
12904 [ "$read_bytes" != 0 ] || error "no read done"
12905 [ "$write_bytes" != 0 ] || error "no write done"
12907 run_test 127a "verify the client stats are sane"
12909 test_127b() { # bug LU-333
12910 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12911 local name count samp unit min max sum sumsq
12913 echo "stats before reset"
12914 $LCTL get_param llite.*.stats
12915 $LCTL set_param llite.*.stats=0
12917 # perform 2 reads and writes so MAX is different from SUM.
12918 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
12919 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
12920 cancel_lru_locks osc
12921 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
12922 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
12924 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
12925 stack_trap "rm -f $TMP/$tfile.tmp"
12926 while read name count samp unit min max sum sumsq; do
12927 echo "got name=$name count=$count unit=$unit min=$min max=$max"
12928 eval $name=$count || error "Wrong proc format"
12931 read_bytes|write_bytes)
12932 [[ "$unit" =~ "bytes" ]] ||
12933 error "unit is not 'bytes': $unit"
12934 (( $count == 2 )) || error "count is not 2: $count"
12935 (( $min == $PAGE_SIZE )) ||
12936 error "min is not $PAGE_SIZE: $min"
12937 (( $max == $PAGE_SIZE )) ||
12938 error "max is not $PAGE_SIZE: $max"
12939 (( $sum == $PAGE_SIZE * 2 )) ||
12940 error "sum is not $((PAGE_SIZE * 2)): $sum"
12943 [[ "$unit" =~ "usec" ]] ||
12944 error "unit is not 'usec': $unit"
12948 done < $TMP/$tfile.tmp
12950 #check that we actually got some stats
12951 [ "$read_bytes" ] || error "Missing read_bytes stats"
12952 [ "$write_bytes" ] || error "Missing write_bytes stats"
12953 [ "$read_bytes" != 0 ] || error "no read done"
12954 [ "$write_bytes" != 0 ] || error "no write done"
12956 run_test 127b "verify the llite client stats are sane"
12958 test_127c() { # LU-12394
12959 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
12966 $LCTL set_param llite.*.extents_stats=1
12967 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
12969 # Use two stripes so there is enough space in default config
12970 $LFS setstripe -c 2 $DIR/$tfile
12972 # Extent stats start at 0-4K and go in power of two buckets
12973 # LL_HIST_START = 12 --> 2^12 = 4K
12974 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
12975 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
12977 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
12979 # Write and read, 2x each, second time at a non-zero offset
12980 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
12981 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
12982 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
12983 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
12987 $LCTL get_param llite.*.extents_stats
12990 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
12992 local bucket=$($LCTL get_param -n llite.*.extents_stats |
12994 reads=$(echo $bucket | awk '{print $5}')
12995 writes=$(echo $bucket | awk '{print $9}')
12996 [ "$reads" -eq $count ] ||
12997 error "$reads reads in < $bsize bucket, expect $count"
12998 [ "$writes" -eq $count ] ||
12999 error "$writes writes in < $bsize bucket, expect $count"
13002 # Test mmap write and read
13003 $LCTL set_param llite.*.extents_stats=c
13005 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
13006 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
13007 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
13009 $LCTL get_param llite.*.extents_stats
13011 count=$(((size*1024) / PAGE_SIZE))
13013 bsize=$((2 * PAGE_SIZE / 1024))K
13015 bucket=$($LCTL get_param -n llite.*.extents_stats |
13017 reads=$(echo $bucket | awk '{print $5}')
13018 writes=$(echo $bucket | awk '{print $9}')
13019 # mmap writes fault in the page first, creating an additonal read
13020 [ "$reads" -eq $((2 * count)) ] ||
13021 error "$reads reads in < $bsize bucket, expect $count"
13022 [ "$writes" -eq $count ] ||
13023 error "$writes writes in < $bsize bucket, expect $count"
13025 run_test 127c "test llite extent stats with regular & mmap i/o"
13027 test_128() { # bug 15212
13029 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
13034 result=$(grep error $TMP/$tfile.log)
13035 rm -f $DIR/$tfile $TMP/$tfile.log
13036 [ -z "$result" ] ||
13037 error "consecutive find's under interactive lfs failed"
13039 run_test 128 "interactive lfs for 2 consecutive find's"
13041 set_dir_limits () {
13046 local ldproc=/proc/fs/ldiskfs
13047 local facets=$(get_facets MDS)
13049 for facet in ${facets//,/ }; do
13050 canondev=$(ldiskfs_canon \
13051 *.$(convert_facet2label $facet).mntdev $facet)
13052 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
13053 ldproc=/sys/fs/ldiskfs
13054 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
13055 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
13059 check_mds_dmesg() {
13060 local facets=$(get_facets MDS)
13061 for facet in ${facets//,/ }; do
13062 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
13068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13069 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
13070 skip "Need MDS version with at least 2.5.56"
13071 if [ "$mds1_FSTYPE" != ldiskfs ]; then
13072 skip_env "ldiskfs only test"
13074 remote_mds_nodsh && skip "remote MDS with nodsh"
13077 local has_warning=false
13080 mkdir -p $DIR/$tdir
13082 # block size of mds1
13083 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
13084 set_dir_limits $maxsize $((maxsize * 6 / 8))
13085 stack_trap "set_dir_limits 0 0"
13086 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
13087 local dirsize=$(stat -c%s "$DIR/$tdir")
13089 while (( $dirsize <= $maxsize )); do
13090 $MCREATE $DIR/$tdir/file_base_$nfiles
13092 # check two errors:
13093 # ENOSPC for ext4 max_dir_size, which has been used since
13094 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
13095 if (( rc == ENOSPC )); then
13097 echo "rc=$rc returned as expected after $nfiles files"
13099 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
13100 error "create failed w/o dir size limit"
13102 # messages may be rate limited if test is run repeatedly
13103 check_mds_dmesg '"is approaching max"' ||
13104 echo "warning message should be output"
13105 check_mds_dmesg '"has reached max"' ||
13106 echo "reached message should be output"
13108 dirsize=$(stat -c%s "$DIR/$tdir")
13110 [[ $dirsize -ge $maxsize ]] && return 0
13111 error "dirsize $dirsize < $maxsize after $nfiles files"
13112 elif (( rc != 0 )); then
13115 nfiles=$((nfiles + 1))
13116 dirsize=$(stat -c%s "$DIR/$tdir")
13119 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
13121 run_test 129 "test directory size limit ========================"
13130 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13131 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13133 trap cleanup_130 EXIT RETURN
13135 local fm_file=$DIR/$tfile
13136 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
13137 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
13138 error "dd failed for $fm_file"
13140 # LU-1795: test filefrag/FIEMAP once, even if unsupported
13141 filefrag -ves $fm_file
13143 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13144 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13145 [ $RC != 0 ] && error "filefrag $fm_file failed"
13147 filefrag_op=$(filefrag -ve -k $fm_file |
13148 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13149 lun=$($LFS getstripe -i $fm_file)
13151 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
13154 for line in $filefrag_op
13156 frag_lun=`echo $line | cut -d: -f5`
13157 ext_len=`echo $line | cut -d: -f4`
13158 if (( $frag_lun != $lun )); then
13160 error "FIEMAP on 1-stripe file($fm_file) failed"
13163 (( tot_len += ext_len ))
13166 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
13168 error "FIEMAP on 1-stripe file($fm_file) failed;"
13174 echo "FIEMAP on single striped file succeeded"
13176 run_test 130a "FIEMAP (1-stripe file)"
13179 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13181 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13182 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13184 trap cleanup_130 EXIT RETURN
13186 local fm_file=$DIR/$tfile
13187 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13188 error "setstripe on $fm_file"
13189 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13190 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13192 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
13193 error "dd failed on $fm_file"
13195 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13196 filefrag_op=$(filefrag -ve -k $fm_file |
13197 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13199 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13200 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13205 for line in $filefrag_op
13207 frag_lun=$(echo $line | cut -d: -f5 |
13208 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13209 ext_len=$(echo $line | cut -d: -f4)
13210 if (( $frag_lun != $last_lun )); then
13211 if (( tot_len != 1024 )); then
13213 error "FIEMAP on $fm_file failed; returned " \
13214 "len $tot_len for OST $last_lun instead of 1024"
13217 (( num_luns += 1 ))
13221 (( tot_len += ext_len ))
13224 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
13226 error "FIEMAP on $fm_file failed; returned wrong number of " \
13227 "luns or wrong len for OST $last_lun"
13233 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
13235 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
13238 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13240 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13241 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13243 trap cleanup_130 EXIT RETURN
13245 local fm_file=$DIR/$tfile
13246 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
13247 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13248 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13250 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
13251 error "dd failed on $fm_file"
13253 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13254 filefrag_op=$(filefrag -ve -k $fm_file |
13255 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13257 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13258 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13263 for line in $filefrag_op
13265 frag_lun=$(echo $line | cut -d: -f5 |
13266 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13267 ext_len=$(echo $line | cut -d: -f4)
13268 if (( $frag_lun != $last_lun )); then
13269 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
13270 if (( logical != 512 )); then
13272 error "FIEMAP on $fm_file failed; returned " \
13273 "logical start for lun $logical instead of 512"
13276 if (( tot_len != 512 )); then
13278 error "FIEMAP on $fm_file failed; returned " \
13279 "len $tot_len for OST $last_lun instead of 1024"
13282 (( num_luns += 1 ))
13286 (( tot_len += ext_len ))
13289 if (( num_luns != 2 || tot_len != 512 )); then
13291 error "FIEMAP on $fm_file failed; returned wrong number of " \
13292 "luns or wrong len for OST $last_lun"
13298 echo "FIEMAP on 2-stripe file with hole succeeded"
13300 run_test 130c "FIEMAP (2-stripe file with hole)"
13303 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
13305 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13306 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13308 trap cleanup_130 EXIT RETURN
13310 local fm_file=$DIR/$tfile
13311 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13312 error "setstripe on $fm_file"
13313 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13314 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13316 local actual_stripe_count=$($LFS getstripe -c $fm_file)
13317 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
13318 error "dd failed on $fm_file"
13320 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13321 filefrag_op=$(filefrag -ve -k $fm_file |
13322 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13324 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13325 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13330 for line in $filefrag_op
13332 frag_lun=$(echo $line | cut -d: -f5 |
13333 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13334 ext_len=$(echo $line | cut -d: -f4)
13335 if (( $frag_lun != $last_lun )); then
13336 if (( tot_len != 1024 )); then
13338 error "FIEMAP on $fm_file failed; returned " \
13339 "len $tot_len for OST $last_lun instead of 1024"
13342 (( num_luns += 1 ))
13346 (( tot_len += ext_len ))
13349 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
13351 error "FIEMAP on $fm_file failed; returned wrong number of " \
13352 "luns or wrong len for OST $last_lun"
13358 echo "FIEMAP on N-stripe file succeeded"
13360 run_test 130d "FIEMAP (N-stripe file)"
13363 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13365 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13366 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13368 trap cleanup_130 EXIT RETURN
13370 local fm_file=$DIR/$tfile
13371 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
13374 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
13375 for ((i = 0; i < $NUM_BLKS; i++)); do
13376 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
13377 conv=notrunc > /dev/null 2>&1
13380 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13381 filefrag_op=$(filefrag -ve -k $fm_file |
13382 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13384 last_lun=$(echo $filefrag_op | cut -d: -f5)
13389 for line in $filefrag_op; do
13390 frag_lun=$(echo $line | cut -d: -f5)
13391 ext_len=$(echo $line | cut -d: -f4)
13392 if [[ "$frag_lun" != "$last_lun" ]]; then
13393 if (( tot_len != $EXPECTED_LEN )); then
13395 error "OST$last_lun $tot_len != $EXPECTED_LEN"
13397 (( num_luns += 1 ))
13401 (( tot_len += ext_len ))
13404 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
13406 error "OST$last_lun $num_luns != 2, $tot_len != $EXPECTED_LEN"
13409 echo "FIEMAP with continuation calls succeeded"
13411 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
13414 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13415 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13417 local fm_file=$DIR/$tfile
13418 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
13419 error "multiop create with lov_delay_create on $fm_file"
13421 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13422 filefrag_extents=$(filefrag -vek $fm_file |
13423 awk '/extents? found/ { print $2 }')
13424 if [[ "$filefrag_extents" != "0" ]]; then
13425 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
13430 run_test 130f "FIEMAP (unstriped file)"
13433 local file=$DIR/$tfile
13434 local nr=$((OSTCOUNT * 100))
13436 $LFS setstripe -C $nr $file ||
13437 error "failed to setstripe -C $nr $file"
13439 dd if=/dev/zero of=$file count=$nr bs=1M
13441 nr=$($LFS getstripe -c $file)
13443 local extents=$(filefrag -v $file |
13444 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
13446 echo "filefrag list $extents extents in file with stripecount $nr"
13447 if (( extents < nr )); then
13448 $LFS getstripe $file
13450 error "filefrag printed $extents < $nr extents"
13455 run_test 130g "FIEMAP (overstripe file)"
13457 # Test for writev/readv
13459 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
13460 error "writev test failed"
13461 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
13462 error "readv failed"
13465 run_test 131a "test iov's crossing stripe boundary for writev/readv"
13468 local fsize=$((524288 + 1048576 + 1572864))
13469 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
13470 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
13471 error "append writev test failed"
13473 ((fsize += 1572864 + 1048576))
13474 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
13475 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
13476 error "append writev test failed"
13479 run_test 131b "test append writev"
13482 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
13485 run_test 131c "test read/write on file w/o objects"
13488 rwv -f $DIR/$tfile -w -n 1 1572864
13489 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
13490 if [ "$NOB" != 1572864 ]; then
13491 error "Short read filed: read $NOB bytes instead of 1572864"
13495 run_test 131d "test short read"
13498 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
13499 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
13500 error "read hitting hole failed"
13503 run_test 131e "test read hitting hole"
13512 mds*) res=$(do_facet $facet \
13513 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
13515 ost*) res=$(do_facet $facet \
13516 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
13518 *) error "Wrong facet '$facet'" ;;
13520 [ "$res" ] || error "The counter for $op on $facet was not incremented"
13521 # if the argument $3 is zero, it means any stat increment is ok.
13522 if [[ $want -gt 0 ]]; then
13523 local count=$(echo $res | awk '{ print $2 }')
13524 [[ $count -ne $want ]] &&
13525 error "The $op counter on $facet is $count, not $want"
13530 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13531 remote_ost_nodsh && skip "remote OST with nodsh"
13532 remote_mds_nodsh && skip "remote MDS with nodsh"
13533 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
13534 skip_env "MDS doesn't support rename stats"
13536 local testdir=$DIR/${tdir}/stats_testdir
13538 mkdir -p $DIR/${tdir}
13541 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13542 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
13544 # verify mdt stats first.
13545 mkdir ${testdir} || error "mkdir failed"
13546 check_stats $SINGLEMDS "mkdir" 1
13547 touch ${testdir}/${tfile} || error "touch failed"
13548 check_stats $SINGLEMDS "open" 1
13549 check_stats $SINGLEMDS "close" 1
13550 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
13551 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
13552 check_stats $SINGLEMDS "mknod" 2
13554 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
13555 check_stats $SINGLEMDS "unlink" 1
13556 rm -f ${testdir}/${tfile} || error "file remove failed"
13557 check_stats $SINGLEMDS "unlink" 2
13559 # remove working dir and check mdt stats again.
13560 rmdir ${testdir} || error "rmdir failed"
13561 check_stats $SINGLEMDS "rmdir" 1
13563 local testdir1=$DIR/${tdir}/stats_testdir1
13564 mkdir -p ${testdir}
13565 mkdir -p ${testdir1}
13566 touch ${testdir1}/test1
13567 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
13568 check_stats $SINGLEMDS "crossdir_rename" 1
13570 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
13571 check_stats $SINGLEMDS "samedir_rename" 1
13573 rm -rf $DIR/${tdir}
13575 run_test 133a "Verifying MDT stats ========================================"
13580 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13581 remote_ost_nodsh && skip "remote OST with nodsh"
13582 remote_mds_nodsh && skip "remote MDS with nodsh"
13584 local testdir=$DIR/${tdir}/stats_testdir
13586 mkdir -p ${testdir} || error "mkdir failed"
13587 touch ${testdir}/${tfile} || error "touch failed"
13588 cancel_lru_locks mdc
13591 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13592 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
13594 # extra mdt stats verification.
13595 chmod 444 ${testdir}/${tfile} || error "chmod failed"
13596 check_stats $SINGLEMDS "setattr" 1
13597 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13598 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
13600 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
13601 check_stats $SINGLEMDS "getattr" 1
13603 rm -rf $DIR/${tdir}
13605 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
13606 # so the check below is not reliable
13607 [ $MDSCOUNT -eq 1 ] || return 0
13609 # Sleep to avoid a cached response.
13610 #define OBD_STATFS_CACHE_SECONDS 1
13612 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13613 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
13614 $LFS df || error "lfs failed"
13615 check_stats $SINGLEMDS "statfs" 1
13617 # check aggregated statfs (LU-10018)
13618 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
13620 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
13623 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13624 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
13626 check_stats $SINGLEMDS "statfs" 1
13628 # We want to check that the client didn't send OST_STATFS to
13629 # ost1 but the MDT also uses OST_STATFS for precreate. So some
13630 # extra care is needed here.
13631 if remote_mds; then
13632 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
13633 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
13635 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
13636 [ "$res" ] && error "OST got STATFS"
13641 run_test 133b "Verifying extra MDT stats =================================="
13644 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13645 remote_ost_nodsh && skip "remote OST with nodsh"
13646 remote_mds_nodsh && skip "remote MDS with nodsh"
13648 local testdir=$DIR/$tdir/stats_testdir
13650 test_mkdir -p $testdir
13652 # verify obdfilter stats.
13653 $LFS setstripe -c 1 -i 0 $testdir/$tfile
13655 cancel_lru_locks osc
13656 wait_delete_completed
13659 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13660 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
13662 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
13665 cancel_lru_locks osc
13666 check_stats ost1 "write" 1
13668 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
13669 check_stats ost1 "read" 1
13671 > $testdir/$tfile || error "truncate failed"
13672 check_stats ost1 "punch" 1
13674 rm -f $testdir/$tfile || error "file remove failed"
13675 wait_delete_completed
13676 check_stats ost1 "destroy" 1
13680 run_test 133c "Verifying OST stats ========================================"
13687 while [ $value -ge 2 ]; do
13692 if [ $orig -gt $order ]; then
13700 local size=('K' 'M' 'G' 'T');
13702 local size_string=$value
13704 while [ $value -ge 1024 ]; do
13705 if [ $i -gt 3 ]; then
13706 #T is the biggest unit we get here, if that is bigger,
13708 size_string=${value}T
13711 value=$((value >> 10))
13712 if [ $value -lt 1024 ]; then
13713 size_string=${value}${size[$i]}
13722 get_rename_size() {
13724 local context=${2:-.}
13725 local sample=$(do_facet $SINGLEMDS $LCTL \
13726 get_param mdt.$FSNAME-MDT0000.rename_stats |
13727 grep -A1 $context |
13728 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
13733 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13734 remote_ost_nodsh && skip "remote OST with nodsh"
13735 remote_mds_nodsh && skip "remote MDS with nodsh"
13736 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
13737 skip_env "MDS doesn't support rename stats"
13739 local testdir1=$DIR/${tdir}/stats_testdir1
13740 local testdir2=$DIR/${tdir}/stats_testdir2
13741 mkdir -p $DIR/${tdir}
13743 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
13745 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
13746 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
13748 createmany -o $testdir1/test 512 || error "createmany failed"
13750 # check samedir rename size
13751 mv ${testdir1}/test0 ${testdir1}/test_0
13753 local testdir1_size=$(ls -l $DIR/${tdir} |
13754 awk '/stats_testdir1/ {print $5}')
13755 local testdir2_size=$(ls -l $DIR/${tdir} |
13756 awk '/stats_testdir2/ {print $5}')
13758 testdir1_size=$(order_2 $testdir1_size)
13759 testdir2_size=$(order_2 $testdir2_size)
13761 testdir1_size=$(size_in_KMGT $testdir1_size)
13762 testdir2_size=$(size_in_KMGT $testdir2_size)
13764 echo "source rename dir size: ${testdir1_size}"
13765 echo "target rename dir size: ${testdir2_size}"
13767 local cmd="do_facet $SINGLEMDS $LCTL "
13768 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
13770 eval $cmd || error "$cmd failed"
13771 local samedir=$($cmd | grep 'same_dir')
13772 local same_sample=$(get_rename_size $testdir1_size)
13773 [ -z "$samedir" ] && error "samedir_rename_size count error"
13774 [[ $same_sample -eq 1 ]] ||
13775 error "samedir_rename_size error $same_sample"
13776 echo "Check same dir rename stats success"
13778 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
13780 # check crossdir rename size
13781 mv ${testdir1}/test_0 ${testdir2}/test_0
13783 testdir1_size=$(ls -l $DIR/${tdir} |
13784 awk '/stats_testdir1/ {print $5}')
13785 testdir2_size=$(ls -l $DIR/${tdir} |
13786 awk '/stats_testdir2/ {print $5}')
13788 testdir1_size=$(order_2 $testdir1_size)
13789 testdir2_size=$(order_2 $testdir2_size)
13791 testdir1_size=$(size_in_KMGT $testdir1_size)
13792 testdir2_size=$(size_in_KMGT $testdir2_size)
13794 echo "source rename dir size: ${testdir1_size}"
13795 echo "target rename dir size: ${testdir2_size}"
13797 eval $cmd || error "$cmd failed"
13798 local crossdir=$($cmd | grep 'crossdir')
13799 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
13800 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
13801 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
13802 [[ $src_sample -eq 1 ]] ||
13803 error "crossdir_rename_size error $src_sample"
13804 [[ $tgt_sample -eq 1 ]] ||
13805 error "crossdir_rename_size error $tgt_sample"
13806 echo "Check cross dir rename stats success"
13807 rm -rf $DIR/${tdir}
13809 run_test 133d "Verifying rename_stats ========================================"
13812 remote_mds_nodsh && skip "remote MDS with nodsh"
13813 remote_ost_nodsh && skip "remote OST with nodsh"
13814 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13816 local testdir=$DIR/${tdir}/stats_testdir
13817 local ctr f0 f1 bs=32768 count=42 sum
13819 mkdir -p ${testdir} || error "mkdir failed"
13821 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
13823 for ctr in {write,read}_bytes; do
13825 cancel_lru_locks osc
13827 do_facet ost1 $LCTL set_param -n \
13828 "obdfilter.*.exports.clear=clear"
13830 if [ $ctr = write_bytes ]; then
13832 f1=${testdir}/${tfile}
13834 f0=${testdir}/${tfile}
13838 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
13841 cancel_lru_locks osc
13843 sum=$(do_facet ost1 $LCTL get_param \
13844 "obdfilter.*.exports.*.stats" |
13845 awk -v ctr=$ctr 'BEGIN { sum = 0 }
13846 $1 == ctr { sum += $7 }
13847 END { printf("%0.0f", sum) }')
13849 if ((sum != bs * count)); then
13850 error "Bad $ctr sum, expected $((bs * count)), got $sum"
13854 rm -rf $DIR/${tdir}
13856 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
13859 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
13860 skip "too old lustre for get_param -R ($facet_ver)"
13862 # verifying readability.
13863 $LCTL get_param -R '*' &> /dev/null
13865 # Verifing writability with badarea_io.
13866 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
13867 local skipped_params='force_lbug|changelog_mask|daemon_file'
13868 $LCTL list_param -FR '*' | grep '=' | tr -d = |
13869 egrep -v "$skipped_params" |
13870 xargs -n 1 find $proc_dirs -name |
13871 xargs -n 1 badarea_io ||
13872 error "client badarea_io failed"
13874 # remount the FS in case writes/reads /proc break the FS
13875 cleanup || error "failed to unmount"
13876 setup || error "failed to setup"
13878 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
13881 remote_mds_nodsh && skip "remote MDS with nodsh"
13882 remote_ost_nodsh && skip "remote OST with nodsh"
13884 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
13885 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
13887 for facet in mds1 ost1; do
13888 local facet_ver=$(lustre_version_code $facet)
13889 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
13890 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
13892 log "$facet: too old lustre for get_param -R"
13894 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
13895 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
13896 tr -d = | egrep -v $skipped_params |
13897 xargs -n 1 find $proc_dirs -name |
13898 xargs -n 1 badarea_io" ||
13899 error "$facet badarea_io failed"
13901 skip_noexit "$facet: too old lustre for get_param -R"
13905 # remount the FS in case writes/reads /proc break the FS
13906 cleanup || error "failed to unmount"
13907 setup || error "failed to setup"
13909 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
13912 remote_mds_nodsh && skip "remote MDS with nodsh"
13913 remote_ost_nodsh && skip "remote OST with nodsh"
13914 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
13915 skip "Need MDS version at least 2.9.54"
13918 for facet in client mds1 ost1; do
13919 # Get the list of files that are missing the terminating newline
13920 local plist=$(do_facet $facet
13921 $LCTL list_param -FR '*' | grep '=' | tr -d =)
13923 for ent in $plist; do
13924 local missing=$(do_facet $facet $LCTL get_param $ent \|\
13925 awk -v FS='\v' -v RS='\v\v' \
13926 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
13927 print FILENAME}'" 2>/dev/null)
13928 [ -z $missing ] || {
13929 do_facet $facet $LCTL get_param $ent | od -An -tx1
13930 error "file does not end with newline: $facet-$ent"
13935 run_test 133h "Proc files should end with newlines"
13938 remote_mds_nodsh && skip "remote MDS with nodsh"
13939 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
13940 skip "Need MDS version at least 2.7.54"
13942 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
13943 cancel_lru_locks mdc
13945 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13946 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13947 [ $unused -eq 0 ] || error "$unused locks are not cleared"
13950 createmany -o $DIR/$tdir/f $nr ||
13951 error "failed to create $nr files in $DIR/$tdir"
13952 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13954 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
13955 do_facet mds1 $LCTL set_param fail_loc=0x327
13956 do_facet mds1 $LCTL set_param fail_val=500
13959 echo "sleep 10 seconds ..."
13961 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
13963 do_facet mds1 $LCTL set_param fail_loc=0
13964 do_facet mds1 $LCTL set_param fail_val=0
13965 [ $lck_cnt -lt $unused ] ||
13966 error "No locks reclaimed, before:$unused, after:$lck_cnt"
13969 unlinkmany $DIR/$tdir/f $nr
13971 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
13974 remote_mds_nodsh && skip "remote MDS with nodsh"
13975 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
13976 skip "Need MDS version at least 2.7.54"
13978 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
13979 cancel_lru_locks mdc
13981 local low_wm=$(do_facet mds1 $LCTL get_param -n \
13982 ldlm.lock_reclaim_threshold_mb)
13983 # disable reclaim temporarily
13984 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
13986 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
13987 do_facet mds1 $LCTL set_param fail_loc=0x328
13988 do_facet mds1 $LCTL set_param fail_val=500
13990 $LCTL set_param debug=+trace
13993 createmany -o $DIR/$tdir/f $nr &
13994 local create_pid=$!
13996 echo "Sleep $TIMEOUT seconds ..."
13998 if ! ps -p $create_pid > /dev/null 2>&1; then
13999 do_facet mds1 $LCTL set_param fail_loc=0
14000 do_facet mds1 $LCTL set_param fail_val=0
14001 do_facet mds1 $LCTL set_param \
14002 ldlm.lock_reclaim_threshold_mb=${low_wm}m
14003 error "createmany finished incorrectly!"
14005 do_facet mds1 $LCTL set_param fail_loc=0
14006 do_facet mds1 $LCTL set_param fail_val=0
14007 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
14008 wait $create_pid || return 1
14010 unlinkmany $DIR/$tdir/f $nr
14012 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
14015 remote_mds_nodsh && skip "remote MDS with nodsh"
14016 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14017 skip "Need MDS version at least 2.13.50"
14020 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14022 #define OBD_FAIL_PLAIN_RECORDS 0x1319
14023 #set only one record at plain llog
14024 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
14026 #fill already existed plain llog each 64767
14027 #wrapping whole catalog
14028 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14030 createmany -o $DIR/$tdir/$tfile_ 64700
14031 for (( i = 0; i < 64700; i = i + 2 ))
14033 rm $DIR/$tdir/$tfile_$i &
14034 rm $DIR/$tdir/$tfile_$((i + 1)) &
14039 #waiting osp synchronization
14040 wait_delete_completed
14042 run_test 135 "Race catalog processing"
14045 remote_mds_nodsh && skip "remote MDS with nodsh"
14046 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14047 skip "Need MDS version at least 2.13.50"
14050 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14051 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
14052 #set only one record at plain llog
14053 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
14054 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
14056 #fill already existed 2 plain llogs each 64767
14057 #wrapping whole catalog
14058 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14059 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
14060 wait_delete_completed
14062 createmany -o $DIR/$tdir/$tfile_ 10
14065 do_facet $SINGLEMDS $LCTL set_param fail_val=3
14066 for (( i = 0; i < 10; i = i + 3 ))
14068 rm $DIR/$tdir/$tfile_$i &
14069 rm $DIR/$tdir/$tfile_$((i + 1)) &
14073 rm $DIR/$tdir/$tfile_$((i + 2)) &
14076 #waiting osp synchronization
14077 wait_delete_completed
14079 run_test 136 "Race catalog processing 2"
14081 test_140() { #bug-17379
14082 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14084 test_mkdir $DIR/$tdir
14085 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
14086 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
14088 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
14089 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
14091 while i=$((i + 1)); do
14093 cd $i || error "Changing to $i"
14094 ln -s ../stat stat || error "Creating stat symlink"
14095 # Read the symlink until ELOOP present,
14096 # not LBUGing the system is considered success,
14097 # we didn't overrun the stack.
14098 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
14099 if [ $ret -ne 0 ]; then
14100 if [ $ret -eq 40 ]; then
14103 error "Open stat symlink"
14109 echo "The symlink depth = $i"
14110 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
14111 error "Invalid symlink depth"
14113 # Test recursive symlink
14114 ln -s symlink_self symlink_self
14115 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
14116 echo "open symlink_self returns $ret"
14117 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
14119 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
14122 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14124 local TF="$TMP/$tfile"
14126 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14127 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
14129 cancel_lru_locks $OSC
14130 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
14131 remount_client $MOUNT
14133 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
14136 $TRUNCATE $DIR/$tfile 6000
14137 cancel_lru_locks $OSC
14138 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
14141 echo "12345" >>$DIR/$tfile
14142 cancel_lru_locks $OSC
14143 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
14146 echo "12345" >>$DIR/$tfile
14147 cancel_lru_locks $OSC
14148 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
14150 run_test 150a "truncate/append tests"
14153 check_set_fallocate_or_skip
14156 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14157 check_fallocate $DIR/$tfile || error "fallocate failed"
14159 run_test 150b "Verify fallocate (prealloc) functionality"
14162 check_set_fallocate_or_skip
14165 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14166 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
14168 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14169 # precomputed md5sum for 20MB of zeroes
14170 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
14171 local sum=($(md5sum $DIR/$tfile))
14173 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
14175 check_set_fallocate 1
14178 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14179 sum=($(md5sum $DIR/$tfile))
14181 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
14183 run_test 150bb "Verify fallocate modes both zero space"
14186 check_set_fallocate_or_skip
14187 local striping="-c2"
14189 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14190 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
14191 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
14192 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14193 local want=$((OSTCOUNT * 1048576))
14195 # Must allocate all requested space, not more than 5% extra
14196 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14197 error "bytes $bytes is not $want"
14201 echo "verify fallocate on PFL file"
14203 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14205 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
14206 error "Create $DIR/$tfile failed"
14207 fallocate -l $((1048576 * 512)) $DIR/$tfile ||
14208 error "fallocate failed"
14209 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14210 want=$((512 * 1048576))
14212 # Must allocate all requested space, not more than 5% extra
14213 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14214 error "bytes $bytes is not $want"
14216 run_test 150c "Verify fallocate Size and Blocks"
14219 check_set_fallocate_or_skip
14220 local striping="-c2"
14222 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14224 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14225 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
14226 error "setstripe failed"
14227 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
14228 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
14229 local want=$((OSTCOUNT * 1048576))
14231 # Must allocate all requested space, not more than 5% extra
14232 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14233 error "bytes $bytes is not $want"
14235 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
14238 check_set_fallocate_or_skip
14242 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14243 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
14244 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
14246 # Find OST with Minimum Size
14247 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
14248 sort -un | head -1)
14250 # Get 100MB per OST of the available space to reduce run time
14251 # else 60% of the available space if we are running SLOW tests
14252 if [ $SLOW == "no" ]; then
14253 local space=$((1024 * 100 * OSTCOUNT))
14255 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
14258 fallocate -l${space}k $DIR/$tfile ||
14259 error "fallocate ${space}k $DIR/$tfile failed"
14260 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
14262 # get size immediately after fallocate. This should be correctly
14264 local size=$(stat -c '%s' $DIR/$tfile)
14265 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
14267 # Sleep for a while for statfs to get updated. And not pull from cache.
14270 echo "df after fallocate:"
14273 (( size / 1024 == space )) || error "size $size != requested $space"
14274 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
14275 error "used $used < space $space"
14277 rm $DIR/$tfile || error "rm failed"
14279 wait_delete_completed
14281 echo "df after unlink:"
14284 run_test 150e "Verify 60% of available OST space consumed by fallocate"
14289 local want_size_before=20480 # in bytes
14290 local want_blocks_before=40 # 512 sized blocks
14291 local want_blocks_after=24 # 512 sized blocks
14292 local length=$(((want_blocks_before - want_blocks_after) * 512))
14294 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
14295 skip "need at least 2.14.0 for fallocate punch"
14297 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
14298 skip "LU-14160: punch mode is not implemented on OSD ZFS"
14301 check_set_fallocate_or_skip
14302 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14304 [[ "x$DOM" == "xyes" ]] &&
14305 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
14307 echo "Verify fallocate punch: Range within the file range"
14308 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
14309 error "dd failed for bs 4096 and count 5"
14311 # Call fallocate with punch range which is within the file range
14312 fallocate -p --offset 4096 -l $length $DIR/$tfile ||
14313 error "fallocate failed: offset 4096 and length $length"
14314 # client must see changes immediately after fallocate
14315 size=$(stat -c '%s' $DIR/$tfile)
14316 blocks=$(stat -c '%b' $DIR/$tfile)
14318 # Verify punch worked.
14319 (( blocks == want_blocks_after )) ||
14320 error "punch failed: blocks $blocks != $want_blocks_after"
14322 (( size == want_size_before )) ||
14323 error "punch failed: size $size != $want_size_before"
14325 # Verify there is hole in file
14326 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
14327 # precomputed md5sum
14328 local expect="4a9a834a2db02452929c0a348273b4aa"
14330 cksum=($(md5sum $DIR/$tfile))
14331 [[ "${cksum[0]}" == "$expect" ]] ||
14332 error "unexpected MD5SUM after punch: ${cksum[0]}"
14334 # Start second sub-case for fallocate punch.
14335 echo "Verify fallocate punch: Range overlapping and less than blocksize"
14336 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
14337 error "dd failed for bs 4096 and count 5"
14339 # Punch range less than block size will have no change in block count
14340 want_blocks_after=40 # 512 sized blocks
14342 # Punch overlaps two blocks and less than blocksize
14343 fallocate -p --offset 4000 -l 3000 $DIR/$tfile ||
14344 error "fallocate failed: offset 4000 length 3000"
14345 size=$(stat -c '%s' $DIR/$tfile)
14346 blocks=$(stat -c '%b' $DIR/$tfile)
14348 # Verify punch worked.
14349 (( blocks == want_blocks_after )) ||
14350 error "punch failed: blocks $blocks != $want_blocks_after"
14352 (( size == want_size_before )) ||
14353 error "punch failed: size $size != $want_size_before"
14355 # Verify if range is really zero'ed out. We expect Zeros.
14356 # precomputed md5sum
14357 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
14358 cksum=($(md5sum $DIR/$tfile))
14359 [[ "${cksum[0]}" == "$expect" ]] ||
14360 error "unexpected MD5SUM after punch: ${cksum[0]}"
14362 run_test 150f "Verify fallocate punch functionality"
14370 local BS=4096 # Block size in bytes
14372 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
14373 skip "need at least 2.14.0 for fallocate punch"
14375 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
14376 skip "LU-14160: punch mode is not implemented on OSD ZFS"
14379 check_set_fallocate_or_skip
14380 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14382 if [[ "x$DOM" == "xyes" ]]; then
14383 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
14384 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
14386 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
14387 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
14390 # Get 100MB per OST of the available space to reduce run time
14391 # else 60% of the available space if we are running SLOW tests
14392 if [ $SLOW == "no" ]; then
14393 space=$((1024 * 100 * OSTCOUNT))
14395 # Find OST with Minimum Size
14396 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
14397 sort -un | head -1)
14398 echo "min size OST: $space"
14399 space=$(((space * 60)/100 * OSTCOUNT))
14401 # space in 1k units, round to 4k blocks
14402 local blkcount=$((space * 1024 / $BS))
14404 echo "Verify fallocate punch: Very large Range"
14405 fallocate -l${space}k $DIR/$tfile ||
14406 error "fallocate ${space}k $DIR/$tfile failed"
14407 # write 1M at the end, start and in the middle
14408 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
14409 error "dd failed: bs $BS count 256"
14410 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
14411 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
14412 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
14413 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
14416 size=$(stat -c '%s' $DIR/$tfile)
14418 # gather punch length.
14419 local punch_size=$((size - (BS * 2)))
14421 echo "punch_size = $punch_size"
14422 echo "size - punch_size: $((size - punch_size))"
14423 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
14425 # Call fallocate to punch all except 2 blocks. We leave the
14426 # first and the last block
14427 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
14428 fallocate -p --offset $BS -l $punch_size $DIR/$tfile ||
14429 error "fallocate failed: offset $BS length $punch_size"
14431 size_after=$(stat -c '%s' $DIR/$tfile)
14432 blocks_after=$(stat -c '%b' $DIR/$tfile)
14434 # Verify punch worked.
14435 # Size should be kept
14436 (( size == size_after )) ||
14437 error "punch failed: size $size != $size_after"
14439 # two 4k data blocks to remain plus possible 1 extra extent block
14440 (( blocks_after <= ((BS / 512) * 3) )) ||
14441 error "too many blocks remains: $blocks_after"
14443 # Verify that file has hole between the first and the last blocks
14444 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
14445 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
14447 echo "Hole at [$hole_start, $hole_end)"
14448 (( hole_start == BS )) ||
14449 error "no hole at offset $BS after punch"
14451 (( hole_end == BS + punch_size )) ||
14452 error "data at offset $hole_end < $((BS + punch_size))"
14454 run_test 150g "Verify fallocate punch on large range"
14456 #LU-2902 roc_hit was not able to read all values from lproc
14457 function roc_hit_init() {
14458 local list=$(comma_list $(osts_nodes))
14459 local dir=$DIR/$tdir-check
14460 local file=$dir/$tfile
14466 #use setstripe to do a write to every ost
14467 for i in $(seq 0 $((OSTCOUNT-1))); do
14468 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
14469 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
14470 idx=$(printf %04x $i)
14471 BEFORE=$(get_osd_param $list *OST*$idx stats |
14472 awk '$1 == "cache_access" {sum += $7}
14473 END { printf("%0.0f", sum) }')
14475 cancel_lru_locks osc
14476 cat $file >/dev/null
14478 AFTER=$(get_osd_param $list *OST*$idx stats |
14479 awk '$1 == "cache_access" {sum += $7}
14480 END { printf("%0.0f", sum) }')
14482 echo BEFORE:$BEFORE AFTER:$AFTER
14483 if ! let "AFTER - BEFORE == 4"; then
14485 error "roc_hit is not safe to use"
14493 function roc_hit() {
14494 local list=$(comma_list $(osts_nodes))
14495 echo $(get_osd_param $list '' stats |
14496 awk '$1 == "cache_hit" {sum += $7}
14497 END { printf("%0.0f", sum) }')
14500 function set_cache() {
14503 if [ "$2" == "off" ]; then
14506 local list=$(comma_list $(osts_nodes))
14507 set_osd_param $list '' $1_cache_enable $on
14509 cancel_lru_locks osc
14513 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14514 remote_ost_nodsh && skip "remote OST with nodsh"
14517 local list=$(comma_list $(osts_nodes))
14519 # check whether obdfilter is cache capable at all
14520 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
14521 skip "not cache-capable obdfilter"
14524 # check cache is enabled on all obdfilters
14525 if get_osd_param $list '' read_cache_enable | grep 0; then
14526 skip "oss cache is disabled"
14529 set_osd_param $list '' writethrough_cache_enable 1
14531 # check write cache is enabled on all obdfilters
14532 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
14533 skip "oss write cache is NOT enabled"
14538 #define OBD_FAIL_OBD_NO_LRU 0x609
14539 do_nodes $list $LCTL set_param fail_loc=0x609
14541 # pages should be in the case right after write
14542 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
14545 local BEFORE=$(roc_hit)
14546 cancel_lru_locks osc
14547 cat $DIR/$tfile >/dev/null
14548 local AFTER=$(roc_hit)
14550 do_nodes $list $LCTL set_param fail_loc=0
14552 if ! let "AFTER - BEFORE == CPAGES"; then
14553 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
14556 cancel_lru_locks osc
14557 # invalidates OST cache
14558 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
14559 set_osd_param $list '' read_cache_enable 0
14560 cat $DIR/$tfile >/dev/null
14562 # now data shouldn't be found in the cache
14564 cancel_lru_locks osc
14565 cat $DIR/$tfile >/dev/null
14567 if let "AFTER - BEFORE != 0"; then
14568 error "IN CACHE: before: $BEFORE, after: $AFTER"
14571 set_osd_param $list '' read_cache_enable 1
14574 run_test 151 "test cache on oss and controls ==============================="
14577 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14579 local TF="$TMP/$tfile"
14581 # simulate ENOMEM during write
14582 #define OBD_FAIL_OST_NOMEM 0x226
14583 lctl set_param fail_loc=0x80000226
14584 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
14586 sync || error "sync failed"
14587 lctl set_param fail_loc=0
14589 # discard client's cache
14590 cancel_lru_locks osc
14592 # simulate ENOMEM during read
14593 lctl set_param fail_loc=0x80000226
14594 cmp $TF $DIR/$tfile || error "cmp failed"
14595 lctl set_param fail_loc=0
14599 run_test 152 "test read/write with enomem ============================"
14602 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
14604 run_test 153 "test if fdatasync does not crash ======================="
14606 dot_lustre_fid_permission_check() {
14608 local ffid=$MOUNT/.lustre/fid/$fid
14611 echo "stat fid $fid"
14612 stat $ffid > /dev/null || error "stat $ffid failed."
14613 echo "touch fid $fid"
14614 touch $ffid || error "touch $ffid failed."
14615 echo "write to fid $fid"
14616 cat /etc/hosts > $ffid || error "write $ffid failed."
14617 echo "read fid $fid"
14618 diff /etc/hosts $ffid || error "read $ffid failed."
14619 echo "append write to fid $fid"
14620 cat /etc/hosts >> $ffid || error "append write $ffid failed."
14621 echo "rename fid $fid"
14622 mv $ffid $test_dir/$tfile.1 &&
14623 error "rename $ffid to $tfile.1 should fail."
14624 touch $test_dir/$tfile.1
14625 mv $test_dir/$tfile.1 $ffid &&
14626 error "rename $tfile.1 to $ffid should fail."
14627 rm -f $test_dir/$tfile.1
14628 echo "truncate fid $fid"
14629 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
14630 echo "link fid $fid"
14631 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
14632 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
14633 echo "setfacl fid $fid"
14634 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
14635 echo "getfacl fid $fid"
14636 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
14638 echo "unlink fid $fid"
14639 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
14640 echo "mknod fid $fid"
14641 mknod $ffid c 1 3 && error "mknod $ffid should fail."
14643 fid=[0xf00000400:0x1:0x0]
14644 ffid=$MOUNT/.lustre/fid/$fid
14646 echo "stat non-exist fid $fid"
14647 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
14648 echo "write to non-exist fid $fid"
14649 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
14650 echo "link new fid $fid"
14651 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
14653 mkdir -p $test_dir/$tdir
14654 touch $test_dir/$tdir/$tfile
14655 fid=$($LFS path2fid $test_dir/$tdir)
14658 error "error: could not get fid for $test_dir/$dir/$tfile."
14660 ffid=$MOUNT/.lustre/fid/$fid
14663 ls $ffid > /dev/null || error "ls $ffid failed."
14664 echo "touch $fid/$tfile.1"
14665 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
14667 echo "touch $MOUNT/.lustre/fid/$tfile"
14668 touch $MOUNT/.lustre/fid/$tfile && \
14669 error "touch $MOUNT/.lustre/fid/$tfile should fail."
14671 echo "setxattr to $MOUNT/.lustre/fid"
14672 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
14674 echo "listxattr for $MOUNT/.lustre/fid"
14675 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
14677 echo "delxattr from $MOUNT/.lustre/fid"
14678 setfattr -x trusted.name1 $MOUNT/.lustre/fid
14680 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
14681 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
14682 error "touch invalid fid should fail."
14684 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
14685 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
14686 error "touch non-normal fid should fail."
14688 echo "rename $tdir to $MOUNT/.lustre/fid"
14689 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
14690 error "rename to $MOUNT/.lustre/fid should fail."
14692 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
14694 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
14695 local new_obf_mode=777
14697 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
14698 chmod $new_obf_mode $DIR/.lustre/fid ||
14699 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
14701 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
14702 [ $obf_mode -eq $new_obf_mode ] ||
14703 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
14705 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
14706 chmod $old_obf_mode $DIR/.lustre/fid ||
14707 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
14710 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
14711 fid=$($LFS path2fid $test_dir/$tfile-2)
14713 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
14715 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
14716 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
14717 error "create lov data thru .lustre failed"
14719 echo "cp /etc/passwd $test_dir/$tfile-2"
14720 cp /etc/passwd $test_dir/$tfile-2 ||
14721 error "copy to $test_dir/$tfile-2 failed."
14722 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
14723 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
14724 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
14726 rm -rf $test_dir/tfile.lnk
14727 rm -rf $test_dir/$tfile-2
14731 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
14732 skip "Need MDS version at least 2.4.1"
14734 local tf=$DIR/$tfile
14737 local fid=$($LFS path2fid $tf)
14738 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
14740 # check that we get the same pathname back
14743 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
14744 echo "$rootpath $fid"
14745 found=$($LFS fid2path $rootpath "$fid")
14746 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
14747 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
14750 # check wrong root path format
14751 rootpath=$MOUNT"_wrong"
14752 found=$($LFS fid2path $rootpath "$fid")
14753 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
14755 run_test 154A "lfs path2fid and fid2path basic checks"
14758 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
14759 skip "Need MDS version at least 2.4.1"
14761 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
14762 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
14763 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
14764 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
14766 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
14767 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
14769 # check that we get the same pathname
14770 echo "PFID: $PFID, name: $name"
14771 local FOUND=$($LFS fid2path $MOUNT "$PFID")
14772 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
14773 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
14774 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
14776 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
14778 run_test 154B "verify the ll_decode_linkea tool"
14781 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14782 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14783 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
14784 skip "Need MDS version at least 2.2.51"
14785 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
14787 cp /etc/hosts $DIR/$tfile
14789 fid=$($LFS path2fid $DIR/$tfile)
14791 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
14793 dot_lustre_fid_permission_check "$fid" $DIR ||
14794 error "dot lustre permission check $fid failed"
14796 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
14798 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
14800 touch $MOUNT/.lustre/file &&
14801 error "creation is not allowed under .lustre"
14803 mkdir $MOUNT/.lustre/dir &&
14804 error "mkdir is not allowed under .lustre"
14808 run_test 154a "Open-by-FID"
14811 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14812 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14813 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14814 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
14815 skip "Need MDS version at least 2.2.51"
14817 local remote_dir=$DIR/$tdir/remote_dir
14821 mkdir -p $DIR/$tdir
14822 $LFS mkdir -i $MDTIDX $remote_dir ||
14823 error "create remote directory failed"
14825 cp /etc/hosts $remote_dir/$tfile
14827 fid=$($LFS path2fid $remote_dir/$tfile)
14829 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
14831 dot_lustre_fid_permission_check "$fid" $remote_dir ||
14832 error "dot lustre permission check $fid failed"
14835 run_test 154b "Open-by-FID for remote directory"
14838 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
14839 skip "Need MDS version at least 2.4.1"
14841 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
14842 local FID1=$($LFS path2fid $DIR/$tfile.1)
14843 local FID2=$($LFS path2fid $DIR/$tfile.2)
14844 local FID3=$($LFS path2fid $DIR/$tfile.3)
14847 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
14848 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
14849 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
14851 [ "$FID" = "${!want}" ] ||
14852 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
14856 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
14858 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
14859 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
14863 run_test 154c "lfs path2fid and fid2path multiple arguments"
14866 remote_mds_nodsh && skip "remote MDS with nodsh"
14867 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
14868 skip "Need MDS version at least 2.5.53"
14870 if remote_mds; then
14871 nid=$($LCTL list_nids | sed "s/\./\\\./g")
14875 local proc_ofile="mdt.*.exports.'$nid'.open_files"
14882 local fid=$($LFS path2fid $DIR/$tfile)
14885 cmd="exec $fd<$DIR/$tfile"
14887 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
14888 echo "$fid_list" | grep "$fid"
14891 cmd="exec $fd>/dev/null"
14893 if [ $rc -ne 0 ]; then
14894 error "FID $fid not found in open files list $fid_list"
14897 run_test 154d "Verify open file fid"
14901 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
14902 skip "Need MDS version at least 2.6.50"
14904 if ls -a $MOUNT | grep -q '^\.lustre$'; then
14905 error ".lustre returned by readdir"
14908 run_test 154e ".lustre is not returned by readdir"
14911 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14913 # create parent directory on a single MDT to avoid cross-MDT hardlinks
14914 mkdir_on_mdt0 $DIR/$tdir
14915 # test dirs inherit from its stripe
14916 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
14917 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
14918 cp /etc/hosts $DIR/$tdir/foo1/$tfile
14919 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
14922 # get fid of parents
14923 local FID0=$($LFS path2fid $DIR/$tdir)
14924 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
14925 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
14926 local FID3=$($LFS path2fid $DIR)
14928 # check that path2fid --parents returns expected <parent_fid>/name
14929 # 1) test for a directory (single parent)
14930 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
14931 [ "$parent" == "$FID0/foo1" ] ||
14932 error "expected parent: $FID0/foo1, got: $parent"
14934 # 2) test for a file with nlink > 1 (multiple parents)
14935 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
14936 echo "$parent" | grep -F "$FID1/$tfile" ||
14937 error "$FID1/$tfile not returned in parent list"
14938 echo "$parent" | grep -F "$FID2/link" ||
14939 error "$FID2/link not returned in parent list"
14941 # 3) get parent by fid
14942 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
14943 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
14944 echo "$parent" | grep -F "$FID1/$tfile" ||
14945 error "$FID1/$tfile not returned in parent list (by fid)"
14946 echo "$parent" | grep -F "$FID2/link" ||
14947 error "$FID2/link not returned in parent list (by fid)"
14949 # 4) test for entry in root directory
14950 parent=$($LFS path2fid --parents $DIR/f)
14951 echo "$parent" | grep -F "$FID3/f" ||
14952 error "$FID3/f not returned in parent list"
14954 # 5) test it on root directory
14955 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
14956 error "$MOUNT should not have parents"
14958 # enable xattr caching and check that linkea is correctly updated
14959 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
14960 save_lustre_params client "llite.*.xattr_cache" > $save
14961 lctl set_param llite.*.xattr_cache 1
14963 # 6.1) linkea update on rename
14964 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
14966 # get parents by fid
14967 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
14968 # foo1 should no longer be returned in parent list
14969 echo "$parent" | grep -F "$FID1" &&
14970 error "$FID1 should no longer be in parent list"
14971 # the new path should appear
14972 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
14973 error "$FID2/$tfile.moved is not in parent list"
14975 # 6.2) linkea update on unlink
14976 rm -f $DIR/$tdir/foo2/link
14977 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
14978 # foo2/link should no longer be returned in parent list
14979 echo "$parent" | grep -F "$FID2/link" &&
14980 error "$FID2/link should no longer be in parent list"
14984 restore_lustre_params < $save
14987 run_test 154f "get parent fids by reading link ea"
14991 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14992 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
14993 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
14994 skip "Need MDS version at least 2.6.92"
14996 mkdir_on_mdt0 $DIR/$tdir
14997 llapi_fid_test -d $DIR/$tdir
14999 run_test 154g "various llapi FID tests"
15001 test_155_small_load() {
15002 local temp=$TMP/$tfile
15003 local file=$DIR/$tfile
15005 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
15006 error "dd of=$temp bs=6096 count=1 failed"
15008 cancel_lru_locks $OSC
15009 cmp $temp $file || error "$temp $file differ"
15011 $TRUNCATE $temp 6000
15012 $TRUNCATE $file 6000
15013 cmp $temp $file || error "$temp $file differ (truncate1)"
15015 echo "12345" >>$temp
15016 echo "12345" >>$file
15017 cmp $temp $file || error "$temp $file differ (append1)"
15019 echo "12345" >>$temp
15020 echo "12345" >>$file
15021 cmp $temp $file || error "$temp $file differ (append2)"
15027 test_155_big_load() {
15028 remote_ost_nodsh && skip "remote OST with nodsh"
15030 local temp=$TMP/$tfile
15031 local file=$DIR/$tfile
15034 local cache_size=$(do_facet ost$((MAXI+1)) \
15035 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
15036 local large_file_size=$((cache_size * 2))
15038 echo "OSS cache size: $cache_size KB"
15039 echo "Large file size: $large_file_size KB"
15041 [ $MAXV -le $large_file_size ] &&
15042 skip_env "max available OST size needs > $large_file_size KB"
15044 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
15046 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
15047 error "dd of=$temp bs=$large_file_size count=1k failed"
15050 cancel_lru_locks osc
15051 cmp $temp $file || error "$temp $file differ"
15057 save_writethrough() {
15058 local facets=$(get_facets OST)
15060 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
15064 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15066 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15068 save_writethrough $p
15071 set_cache writethrough on
15072 test_155_small_load
15073 restore_lustre_params < $p
15076 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
15079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15081 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15083 save_writethrough $p
15086 set_cache writethrough off
15087 test_155_small_load
15088 restore_lustre_params < $p
15091 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
15094 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15096 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15098 save_writethrough $p
15101 set_cache writethrough on
15102 test_155_small_load
15103 restore_lustre_params < $p
15106 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
15109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15111 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15113 save_writethrough $p
15116 set_cache writethrough off
15117 test_155_small_load
15118 restore_lustre_params < $p
15121 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
15124 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15126 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15128 save_writethrough $p
15131 set_cache writethrough on
15133 restore_lustre_params < $p
15136 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
15139 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15141 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15143 save_writethrough $p
15146 set_cache writethrough off
15148 restore_lustre_params < $p
15151 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
15154 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15156 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15158 save_writethrough $p
15161 set_cache writethrough on
15163 restore_lustre_params < $p
15166 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
15169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15171 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15173 save_writethrough $p
15176 set_cache writethrough off
15178 restore_lustre_params < $p
15181 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
15184 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15185 remote_ost_nodsh && skip "remote OST with nodsh"
15186 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
15187 skip "stats not implemented on old servers"
15188 [ "$ost1_FSTYPE" = "zfs" ] &&
15189 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
15194 local file="$DIR/$tfile"
15195 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15197 save_writethrough $p
15200 log "Turn on read and write cache"
15202 set_cache writethrough on
15204 log "Write data and read it back."
15205 log "Read should be satisfied from the cache."
15206 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15208 cancel_lru_locks osc
15209 cat $file >/dev/null
15211 if ! let "AFTER - BEFORE == CPAGES"; then
15212 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
15214 log "cache hits: before: $BEFORE, after: $AFTER"
15217 log "Read again; it should be satisfied from the cache."
15219 cancel_lru_locks osc
15220 cat $file >/dev/null
15222 if ! let "AFTER - BEFORE == CPAGES"; then
15223 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
15225 log "cache hits:: before: $BEFORE, after: $AFTER"
15228 log "Turn off the read cache and turn on the write cache"
15230 set_cache writethrough on
15232 log "Read again; it should be satisfied from the cache."
15234 cancel_lru_locks osc
15235 cat $file >/dev/null
15237 if ! let "AFTER - BEFORE == CPAGES"; then
15238 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
15240 log "cache hits:: before: $BEFORE, after: $AFTER"
15243 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
15244 # > 2.12.56 uses pagecache if cached
15245 log "Read again; it should not be satisfied from the cache."
15247 cancel_lru_locks osc
15248 cat $file >/dev/null
15250 if ! let "AFTER - BEFORE == 0"; then
15251 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
15253 log "cache hits:: before: $BEFORE, after: $AFTER"
15257 log "Write data and read it back."
15258 log "Read should be satisfied from the cache."
15259 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15261 cancel_lru_locks osc
15262 cat $file >/dev/null
15264 if ! let "AFTER - BEFORE == CPAGES"; then
15265 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
15267 log "cache hits:: before: $BEFORE, after: $AFTER"
15270 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
15271 # > 2.12.56 uses pagecache if cached
15272 log "Read again; it should not be satisfied from the cache."
15274 cancel_lru_locks osc
15275 cat $file >/dev/null
15277 if ! let "AFTER - BEFORE == 0"; then
15278 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
15280 log "cache hits:: before: $BEFORE, after: $AFTER"
15284 log "Turn off read and write cache"
15286 set_cache writethrough off
15288 log "Write data and read it back"
15289 log "It should not be satisfied from the cache."
15291 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15292 cancel_lru_locks osc
15294 cat $file >/dev/null
15296 if ! let "AFTER - BEFORE == 0"; then
15297 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
15299 log "cache hits:: before: $BEFORE, after: $AFTER"
15302 log "Turn on the read cache and turn off the write cache"
15304 set_cache writethrough off
15306 log "Write data and read it back"
15307 log "It should not be satisfied from the cache."
15309 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15311 cancel_lru_locks osc
15312 cat $file >/dev/null
15314 if ! let "AFTER - BEFORE == 0"; then
15315 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
15317 log "cache hits:: before: $BEFORE, after: $AFTER"
15320 log "Read again; it should be satisfied from the cache."
15322 cancel_lru_locks osc
15323 cat $file >/dev/null
15325 if ! let "AFTER - BEFORE == CPAGES"; then
15326 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
15328 log "cache hits:: before: $BEFORE, after: $AFTER"
15331 restore_lustre_params < $p
15334 run_test 156 "Verification of tunables"
15337 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15338 remote_mds_nodsh && skip "remote MDS with nodsh"
15339 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
15340 skip "Need MDS version at least 2.2.0"
15342 changelog_register || error "changelog_register failed"
15343 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
15344 changelog_users $SINGLEMDS | grep -q $cl_user ||
15345 error "User $cl_user not found in changelog_users"
15347 mkdir_on_mdt0 $DIR/$tdir
15350 test_mkdir -p $DIR/$tdir/pics/2008/zachy
15351 changelog_clear 0 || error "changelog_clear failed"
15352 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
15353 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
15354 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
15355 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
15356 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
15357 rm $DIR/$tdir/pics/desktop.jpg
15359 echo "verifying changelog mask"
15360 changelog_chmask "-MKDIR"
15361 changelog_chmask "-CLOSE"
15363 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
15364 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
15366 changelog_chmask "+MKDIR"
15367 changelog_chmask "+CLOSE"
15369 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
15370 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
15372 MKDIRS=$(changelog_dump | grep -c "MKDIR")
15373 CLOSES=$(changelog_dump | grep -c "CLOSE")
15374 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
15375 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
15378 echo "verifying target fid"
15379 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
15380 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
15381 [ "$fidc" == "$fidf" ] ||
15382 error "changelog '$tfile' fid $fidc != file fid $fidf"
15383 echo "verifying parent fid"
15384 # The FID returned from the Changelog may be the directory shard on
15385 # a different MDT, and not the FID returned by path2fid on the parent.
15386 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
15387 # since this is what will matter when recreating this file in the tree.
15388 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
15389 local pathp=$($LFS fid2path $MOUNT "$fidp")
15390 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
15391 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
15393 echo "getting records for $cl_user"
15394 changelog_users $SINGLEMDS
15395 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
15397 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
15398 error "changelog_clear failed"
15399 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
15400 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
15401 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
15402 error "user index expect $user_rec1 + $nclr != $user_rec2"
15404 local min0_rec=$(changelog_users $SINGLEMDS |
15405 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
15406 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
15407 awk '{ print $1; exit; }')
15409 changelog_dump | tail -n 5
15410 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
15411 [ $first_rec == $((min0_rec + 1)) ] ||
15412 error "first index should be $min0_rec + 1 not $first_rec"
15414 # LU-3446 changelog index reset on MDT restart
15415 local cur_rec1=$(changelog_users $SINGLEMDS |
15416 awk '/^current.index:/ { print $NF }')
15417 changelog_clear 0 ||
15418 error "clear all changelog records for $cl_user failed"
15419 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
15420 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
15421 error "Fail to start $SINGLEMDS"
15422 local cur_rec2=$(changelog_users $SINGLEMDS |
15423 awk '/^current.index:/ { print $NF }')
15424 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
15425 [ $cur_rec1 == $cur_rec2 ] ||
15426 error "current index should be $cur_rec1 not $cur_rec2"
15428 echo "verifying users from this test are deregistered"
15429 changelog_deregister || error "changelog_deregister failed"
15430 changelog_users $SINGLEMDS | grep -q $cl_user &&
15431 error "User '$cl_user' still in changelog_users"
15433 # lctl get_param -n mdd.*.changelog_users
15434 # current_index: 144
15435 # ID index (idle seconds)
15436 # cl3 144 (2) mask=<list>
15437 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
15438 # this is the normal case where all users were deregistered
15439 # make sure no new records are added when no users are present
15440 local last_rec1=$(changelog_users $SINGLEMDS |
15441 awk '/^current.index:/ { print $NF }')
15442 touch $DIR/$tdir/chloe
15443 local last_rec2=$(changelog_users $SINGLEMDS |
15444 awk '/^current.index:/ { print $NF }')
15445 echo "verify changelogs are off: $last_rec1 == $last_rec2"
15446 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
15448 # any changelog users must be leftovers from a previous test
15449 changelog_users $SINGLEMDS
15450 echo "other changelog users; can't verify off"
15453 run_test 160a "changelog sanity"
15455 test_160b() { # LU-3587
15456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15457 remote_mds_nodsh && skip "remote MDS with nodsh"
15458 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
15459 skip "Need MDS version at least 2.2.0"
15461 changelog_register || error "changelog_register failed"
15462 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
15463 changelog_users $SINGLEMDS | grep -q $cl_user ||
15464 error "User '$cl_user' not found in changelog_users"
15466 local longname1=$(str_repeat a 255)
15467 local longname2=$(str_repeat b 255)
15470 echo "creating very long named file"
15471 touch $longname1 || error "create of '$longname1' failed"
15472 echo "renaming very long named file"
15473 mv $longname1 $longname2
15475 changelog_dump | grep RENME | tail -n 5
15478 run_test 160b "Verify that very long rename doesn't crash in changelog"
15481 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15482 remote_mds_nodsh && skip "remote MDS with nodsh"
15484 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
15485 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
15486 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
15487 skip "Need MDS version at least 2.5.58 or 2.5.2+"
15491 # Registration step
15492 changelog_register || error "changelog_register failed"
15495 mkdir -p $DIR/$tdir
15496 $MCREATE $DIR/$tdir/foo_160c
15497 changelog_chmask "-TRUNC"
15498 $TRUNCATE $DIR/$tdir/foo_160c 200
15499 changelog_chmask "+TRUNC"
15500 $TRUNCATE $DIR/$tdir/foo_160c 199
15501 changelog_dump | tail -n 5
15502 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
15503 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
15505 run_test 160c "verify that changelog log catch the truncate event"
15508 remote_mds_nodsh && skip "remote MDS with nodsh"
15509 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15510 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15511 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
15512 skip "Need MDS version at least 2.7.60"
15514 # Registration step
15515 changelog_register || error "changelog_register failed"
15517 mkdir -p $DIR/$tdir/migrate_dir
15518 changelog_clear 0 || error "changelog_clear failed"
15520 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
15521 changelog_dump | tail -n 5
15522 local migrates=$(changelog_dump | grep -c "MIGRT")
15523 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
15525 run_test 160d "verify that changelog log catch the migrate event"
15528 remote_mds_nodsh && skip "remote MDS with nodsh"
15531 changelog_register || error "changelog_register failed"
15533 # Delete a future user (expect fail)
15534 local MDT0=$(facet_svc $SINGLEMDS)
15535 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
15538 if [ $rc -eq 0 ]; then
15539 error "Deleted non-existant user cl77"
15540 elif [ $rc -ne 2 ]; then
15541 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
15544 # Clear to a bad index (1 billion should be safe)
15545 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
15548 if [ $rc -eq 0 ]; then
15549 error "Successfully cleared to invalid CL index"
15550 elif [ $rc -ne 22 ]; then
15551 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
15554 run_test 160e "changelog negative testing (should return errors)"
15557 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15558 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
15559 skip "Need MDS version at least 2.10.56"
15561 local mdts=$(comma_list $(mdts_nodes))
15564 changelog_register || error "first changelog_register failed"
15565 changelog_register || error "second changelog_register failed"
15567 declare -A cl_user1
15568 declare -A cl_user2
15573 # generate some changelog records to accumulate on each MDT
15574 # use all_char because created files should be evenly distributed
15575 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
15576 error "test_mkdir $tdir failed"
15577 log "$(date +%s): creating first files"
15578 for ((i = 0; i < MDSCOUNT * 2; i++)); do
15579 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
15580 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
15583 # check changelogs have been generated
15584 local start=$SECONDS
15585 local idle_time=$((MDSCOUNT * 5 + 5))
15586 local nbcl=$(changelog_dump | wc -l)
15587 [[ $nbcl -eq 0 ]] && error "no changelogs found"
15589 for param in "changelog_max_idle_time=$idle_time" \
15591 "changelog_min_gc_interval=2" \
15592 "changelog_min_free_cat_entries=3"; do
15593 local MDT0=$(facet_svc $SINGLEMDS)
15594 local var="${param%=*}"
15595 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
15597 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
15598 do_nodes $mdts $LCTL set_param mdd.*.$param
15601 # force cl_user2 to be idle (1st part), but also cancel the
15602 # cl_user1 records so that it is not evicted later in the test.
15603 local sleep1=$((idle_time / 2))
15604 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
15607 # simulate changelog catalog almost full
15608 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
15609 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
15611 for i in $(seq $MDSCOUNT); do
15612 cl_users=(${CL_USERS[mds$i]})
15613 cl_user1[mds$i]="${cl_users[0]}"
15614 cl_user2[mds$i]="${cl_users[1]}"
15616 [ -n "${cl_user1[mds$i]}" ] ||
15617 error "mds$i: no user registered"
15618 [ -n "${cl_user2[mds$i]}" ] ||
15619 error "mds$i: only ${cl_user2[mds$i]} is registered"
15621 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15622 [ -n "$user_rec1" ] ||
15623 error "mds$i: User ${cl_user1[mds$i]} not registered"
15624 __changelog_clear mds$i ${cl_user1[mds$i]} +2
15625 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15626 [ -n "$user_rec2" ] ||
15627 error "mds$i: User ${cl_user1[mds$i]} not registered"
15628 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
15629 "$user_rec1 + 2 == $user_rec2"
15630 [ $((user_rec1 + 2)) == $user_rec2 ] ||
15631 error "mds$i: user ${cl_user1[mds$i]} index expected " \
15632 "$user_rec1 + 2, but is $user_rec2"
15633 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
15634 [ -n "$user_rec2" ] ||
15635 error "mds$i: User ${cl_user2[mds$i]} not registered"
15636 [ $user_rec1 == $user_rec2 ] ||
15637 error "mds$i: user ${cl_user2[mds$i]} index expected " \
15638 "$user_rec1, but is $user_rec2"
15641 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
15642 local sleep2=$((idle_time - (SECONDS - start) + 1))
15643 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
15646 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
15647 # cl_user1 should be OK because it recently processed records.
15648 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
15649 for ((i = 0; i < MDSCOUNT * 2; i++)); do
15650 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
15651 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
15654 # ensure gc thread is done
15655 for i in $(mdts_nodes); do
15656 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
15657 error "$i: GC-thread not done"
15661 for (( i = 1; i <= MDSCOUNT; i++ )); do
15662 # check cl_user1 still registered
15663 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
15664 error "mds$i: User ${cl_user1[mds$i]} not registered"
15665 # check cl_user2 unregistered
15666 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
15667 error "mds$i: User ${cl_user2[mds$i]} still registered"
15669 # check changelogs are present and starting at $user_rec1 + 1
15670 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15671 [ -n "$user_rec1" ] ||
15672 error "mds$i: User ${cl_user1[mds$i]} not registered"
15673 first_rec=$($LFS changelog $(facet_svc mds$i) |
15674 awk '{ print $1; exit; }')
15676 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
15677 [ $((user_rec1 + 1)) == $first_rec ] ||
15678 error "mds$i: rec $first_rec != $user_rec1 + 1"
15681 run_test 160f "changelog garbage collect (timestamped users)"
15684 remote_mds_nodsh && skip "remote MDS with nodsh"
15685 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
15686 skip "Need MDS version at least 2.10.56"
15688 local mdts=$(comma_list $(mdts_nodes))
15690 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
15691 do_nodes $mdts $LCTL set_param fail_loc=0x1314
15694 changelog_register || error "first changelog_register failed"
15695 changelog_register || error "second changelog_register failed"
15697 declare -A cl_user1
15698 declare -A cl_user2
15703 # generate some changelog records to accumulate on each MDT
15704 # use all_char because created files should be evenly distributed
15705 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
15706 error "test_mkdir $tdir failed"
15707 for ((i = 0; i < MDSCOUNT; i++)); do
15708 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
15709 error "create $DIR/$tdir/d$i.1 failed"
15712 # check changelogs have been generated
15713 local nbcl=$(changelog_dump | wc -l)
15714 (( $nbcl > 0 )) || error "no changelogs found"
15716 # reduce the max_idle_indexes value to make sure we exceed it
15717 for param in "changelog_max_idle_indexes=1" \
15719 "changelog_min_gc_interval=2" \
15720 "changelog_min_free_cat_entries=3"; do
15721 local MDT0=$(facet_svc $SINGLEMDS)
15722 local var="${param%=*}"
15723 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
15725 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
15726 do_nodes $mdts $LCTL set_param mdd.*.$param ||
15727 error "unable to set mdd.*.$param"
15730 # simulate changelog catalog almost full
15731 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
15732 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
15734 local start=$SECONDS
15735 for i in $(seq $MDSCOUNT); do
15736 cl_users=(${CL_USERS[mds$i]})
15737 cl_user1[mds$i]="${cl_users[0]}"
15738 cl_user2[mds$i]="${cl_users[1]}"
15740 [ -n "${cl_user1[mds$i]}" ] ||
15741 error "mds$i: no user registered"
15742 [ -n "${cl_user2[mds$i]}" ] ||
15743 error "mds$i: only ${cl_user1[mds$i]} is registered"
15745 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15746 [ -n "$user_rec1" ] ||
15747 error "mds$i: User ${cl_user1[mds$i]} not registered"
15748 __changelog_clear mds$i ${cl_user1[mds$i]} +2
15749 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15750 [ -n "$user_rec2" ] ||
15751 error "mds$i: User ${cl_user1[mds$i]} not registered"
15752 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
15753 "$user_rec1 + 2 == $user_rec2"
15754 [ $((user_rec1 + 2)) == $user_rec2 ] ||
15755 error "mds$i: user ${cl_user1[mds$i]} index expected " \
15756 "$user_rec1 + 2, but is $user_rec2"
15757 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
15758 [ -n "$user_rec2" ] ||
15759 error "mds$i: User ${cl_user2[mds$i]} not registered"
15760 [ $user_rec1 == $user_rec2 ] ||
15761 error "mds$i: user ${cl_user2[mds$i]} index expected " \
15762 "$user_rec1, but is $user_rec2"
15765 # ensure we are past the previous changelog_min_gc_interval set above
15766 local sleep2=$((start + 2 - SECONDS))
15767 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
15769 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
15770 # cl_user1 should be OK because it recently processed records.
15771 for ((i = 0; i < MDSCOUNT; i++)); do
15772 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
15773 error "create $DIR/$tdir/d$i.3 failed"
15776 # ensure gc thread is done
15777 for i in $(mdts_nodes); do
15778 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
15779 error "$i: GC-thread not done"
15783 for (( i = 1; i <= MDSCOUNT; i++ )); do
15784 # check cl_user1 still registered
15785 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
15786 error "mds$i: User ${cl_user1[mds$i]} not registered"
15787 # check cl_user2 unregistered
15788 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
15789 error "mds$i: User ${cl_user2[mds$i]} still registered"
15791 # check changelogs are present and starting at $user_rec1 + 1
15792 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15793 [ -n "$user_rec1" ] ||
15794 error "mds$i: User ${cl_user1[mds$i]} not registered"
15795 first_rec=$($LFS changelog $(facet_svc mds$i) |
15796 awk '{ print $1; exit; }')
15798 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
15799 [ $((user_rec1 + 1)) == $first_rec ] ||
15800 error "mds$i: rec $first_rec != $user_rec1 + 1"
15803 run_test 160g "changelog garbage collect (old users)"
15806 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15807 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
15808 skip "Need MDS version at least 2.10.56"
15810 local mdts=$(comma_list $(mdts_nodes))
15813 changelog_register || error "first changelog_register failed"
15814 changelog_register || error "second changelog_register failed"
15816 declare -A cl_user1
15817 declare -A cl_user2
15822 # generate some changelog records to accumulate on each MDT
15823 # use all_char because created files should be evenly distributed
15824 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
15825 error "test_mkdir $tdir failed"
15826 for ((i = 0; i < MDSCOUNT; i++)); do
15827 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
15828 error "create $DIR/$tdir/d$i.1 failed"
15831 # check changelogs have been generated
15832 local nbcl=$(changelog_dump | wc -l)
15833 [[ $nbcl -eq 0 ]] && error "no changelogs found"
15835 for param in "changelog_max_idle_time=10" \
15837 "changelog_min_gc_interval=2"; do
15838 local MDT0=$(facet_svc $SINGLEMDS)
15839 local var="${param%=*}"
15840 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
15842 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
15843 do_nodes $mdts $LCTL set_param mdd.*.$param
15846 # force cl_user2 to be idle (1st part)
15849 for i in $(seq $MDSCOUNT); do
15850 cl_users=(${CL_USERS[mds$i]})
15851 cl_user1[mds$i]="${cl_users[0]}"
15852 cl_user2[mds$i]="${cl_users[1]}"
15854 [ -n "${cl_user1[mds$i]}" ] ||
15855 error "mds$i: no user registered"
15856 [ -n "${cl_user2[mds$i]}" ] ||
15857 error "mds$i: only ${cl_user2[mds$i]} is registered"
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 __changelog_clear mds$i ${cl_user1[mds$i]} +2
15863 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15864 [ -n "$user_rec2" ] ||
15865 error "mds$i: User ${cl_user1[mds$i]} not registered"
15866 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
15867 "$user_rec1 + 2 == $user_rec2"
15868 [ $((user_rec1 + 2)) == $user_rec2 ] ||
15869 error "mds$i: user ${cl_user1[mds$i]} index expected " \
15870 "$user_rec1 + 2, but is $user_rec2"
15871 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
15872 [ -n "$user_rec2" ] ||
15873 error "mds$i: User ${cl_user2[mds$i]} not registered"
15874 [ $user_rec1 == $user_rec2 ] ||
15875 error "mds$i: user ${cl_user2[mds$i]} index expected " \
15876 "$user_rec1, but is $user_rec2"
15879 # force cl_user2 to be idle (2nd part) and to reach
15880 # changelog_max_idle_time
15883 # force each GC-thread start and block then
15884 # one per MDT/MDD, set fail_val accordingly
15885 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
15886 do_nodes $mdts $LCTL set_param fail_loc=0x1316
15888 # generate more changelogs to trigger fail_loc
15889 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
15890 error "create $DIR/$tdir/${tfile}bis failed"
15892 # stop MDT to stop GC-thread, should be done in back-ground as it will
15893 # block waiting for the thread to be released and exit
15894 declare -A stop_pids
15895 for i in $(seq $MDSCOUNT); do
15897 stop_pids[mds$i]=$!
15900 for i in $(mdts_nodes); do
15903 local facets=$(facets_up_on_host $i)
15905 for facet in ${facets//,/ }; do
15906 if [[ $facet == mds* ]]; then
15910 # ensure each MDS's gc threads are still present and all in "R"
15911 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
15912 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
15913 error "$i: expected $nb GC-thread"
15915 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
15917 error "$i: GC-thread not found in R-state"
15918 # check umounts of each MDT on MDS have reached kthread_stop()
15919 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
15920 error "$i: expected $nb umount"
15922 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
15923 error "$i: umount not found in D-state"
15926 # release all GC-threads
15927 do_nodes $mdts $LCTL set_param fail_loc=0
15929 # wait for MDT stop to complete
15930 for i in $(seq $MDSCOUNT); do
15931 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
15935 # may try to check if any orphan changelog records are present
15936 # via ldiskfs/zfs and llog_reader...
15938 # re-start/mount MDTs
15939 for i in $(seq $MDSCOUNT); do
15940 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
15941 error "Fail to start mds$i"
15945 for i in $(seq $MDSCOUNT); do
15946 # check cl_user1 still registered
15947 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
15948 error "mds$i: User ${cl_user1[mds$i]} not registered"
15949 # check cl_user2 unregistered
15950 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
15951 error "mds$i: User ${cl_user2[mds$i]} still registered"
15953 # check changelogs are present and starting at $user_rec1 + 1
15954 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
15955 [ -n "$user_rec1" ] ||
15956 error "mds$i: User ${cl_user1[mds$i]} not registered"
15957 first_rec=$($LFS changelog $(facet_svc mds$i) |
15958 awk '{ print $1; exit; }')
15960 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
15961 [ $((user_rec1 + 1)) == $first_rec ] ||
15962 error "mds$i: first index should be $user_rec1 + 1, " \
15963 "but is $first_rec"
15966 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
15971 local mdts=$(comma_list $(mdts_nodes))
15973 changelog_register || error "first changelog_register failed"
15975 # generate some changelog records to accumulate on each MDT
15976 # use all_char because created files should be evenly distributed
15977 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
15978 error "test_mkdir $tdir failed"
15979 for ((i = 0; i < MDSCOUNT; i++)); do
15980 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
15981 error "create $DIR/$tdir/d$i.1 failed"
15984 # check changelogs have been generated
15985 local nbcl=$(changelog_dump | wc -l)
15986 [[ $nbcl -eq 0 ]] && error "no changelogs found"
15988 # simulate race between register and unregister
15989 # XXX as fail_loc is set per-MDS, with DNE configs the race
15990 # simulation will only occur for one MDT per MDS and for the
15991 # others the normal race scenario will take place
15992 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
15993 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
15994 do_nodes $mdts $LCTL set_param fail_val=1
15996 # unregister 1st user
15997 changelog_deregister &
15999 # wait some time for deregister work to reach race rdv
16001 # register 2nd user
16002 changelog_register || error "2nd user register failed"
16004 wait $pid1 || error "1st user deregister failed"
16008 declare -A LAST_REC
16009 for i in $(seq $MDSCOUNT); do
16010 if changelog_users mds$i | grep "^cl"; then
16011 # make sure new records are added with one user present
16012 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
16013 awk '/^current.index:/ { print $NF }')
16015 error "mds$i has no user registered"
16019 # generate more changelog records to accumulate on each MDT
16020 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16021 error "create $DIR/$tdir/${tfile}bis failed"
16023 for i in $(seq $MDSCOUNT); do
16024 last_rec=$(changelog_users $SINGLEMDS |
16025 awk '/^current.index:/ { print $NF }')
16026 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
16027 [ $last_rec != ${LAST_REC[mds$i]} ] ||
16028 error "changelogs are off on mds$i"
16031 run_test 160i "changelog user register/unregister race"
16034 remote_mds_nodsh && skip "remote MDS with nodsh"
16035 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
16036 skip "Need MDS version at least 2.12.56"
16038 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
16039 stack_trap "umount $MOUNT2" EXIT
16041 changelog_register || error "first changelog_register failed"
16042 stack_trap "changelog_deregister" EXIT
16044 # generate some changelog
16045 # use all_char because created files should be evenly distributed
16046 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16047 error "mkdir $tdir failed"
16048 for ((i = 0; i < MDSCOUNT; i++)); do
16049 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16050 error "create $DIR/$tdir/d$i.1 failed"
16053 # open the changelog device
16054 exec 3>/dev/changelog-$FSNAME-MDT0000
16055 stack_trap "exec 3>&-" EXIT
16056 exec 4</dev/changelog-$FSNAME-MDT0000
16057 stack_trap "exec 4<&-" EXIT
16059 # umount the first lustre mount
16061 stack_trap "mount_client $MOUNT" EXIT
16063 # read changelog, which may or may not fail, but should not crash
16067 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16068 changelog_users $SINGLEMDS | grep -q $cl_user ||
16069 error "User $cl_user not found in changelog_users"
16071 printf 'clear:'$cl_user':0' >&3
16073 run_test 160j "client can be umounted while its chanangelog is being used"
16076 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16077 remote_mds_nodsh && skip "remote MDS with nodsh"
16079 mkdir -p $DIR/$tdir/1/1
16081 changelog_register || error "changelog_register failed"
16082 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16084 changelog_users $SINGLEMDS | grep -q $cl_user ||
16085 error "User '$cl_user' not found in changelog_users"
16086 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
16087 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
16088 rmdir $DIR/$tdir/1/1 & sleep 1
16090 touch $DIR/$tdir/2/2
16091 rm -rf $DIR/$tdir/2
16096 changelog_dump | grep rmdir || error "rmdir not recorded"
16098 run_test 160k "Verify that changelog records are not lost"
16100 # Verifies that a file passed as a parameter has recently had an operation
16101 # performed on it that has generated an MTIME changelog which contains the
16102 # correct parent FID. As files might reside on a different MDT from the
16103 # parent directory in DNE configurations, the FIDs are translated to paths
16104 # before being compared, which should be identical
16105 compare_mtime_changelog() {
16113 mdtidx=$($LFS getstripe --mdt-index $file)
16114 mdtidx=$(printf "%04x" $mdtidx)
16116 # Obtain the parent FID from the MTIME changelog
16117 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
16118 [ -z "$mtime" ] && error "MTIME changelog not recorded"
16120 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
16121 [ -z "$cl_fid" ] && error "parent FID not present"
16123 # Verify that the path for the parent FID is the same as the path for
16124 # the test directory
16125 pdir=$($LFS fid2path $MOUNT "$cl_fid")
16129 [[ "${pdir%/}" == "$dir" ]] ||
16130 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
16134 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16136 remote_mds_nodsh && skip "remote MDS with nodsh"
16137 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
16138 skip "Need MDS version at least 2.13.55"
16142 changelog_register || error "changelog_register failed"
16143 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16145 changelog_users $SINGLEMDS | grep -q $cl_user ||
16146 error "User '$cl_user' not found in changelog_users"
16148 # Clear some types so that MTIME changelogs are generated
16149 changelog_chmask "-CREAT"
16150 changelog_chmask "-CLOSE"
16152 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
16154 # Test CL_MTIME during setattr
16155 touch $DIR/$tdir/$tfile
16156 compare_mtime_changelog $DIR/$tdir/$tfile
16158 # Test CL_MTIME during close
16159 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
16160 compare_mtime_changelog $DIR/$tdir/${tfile}_2
16162 run_test 160l "Verify that MTIME changelog records contain the parent FID"
16165 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16166 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16167 skip "Need MDS version at least 2.14.51"
16174 changelog_register || error "first changelog_register failed"
16175 changelog_register || error "second changelog_register failed"
16177 cl_users=(${CL_USERS[mds1]})
16178 cl_user1="${cl_users[0]}"
16179 cl_user2="${cl_users[1]}"
16180 # generate some changelog records to accumulate on MDT0
16181 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16182 createmany -m $DIR/$tdir/$tfile 50 ||
16183 error "create $DIR/$tdir/$tfile failed"
16184 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16187 # check changelogs have been generated
16188 local nbcl=$(changelog_dump | wc -l)
16189 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16191 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
16192 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
16194 __changelog_clear mds1 $cl_user1 +10
16195 __changelog_clear mds1 $cl_user2 0 &
16198 __changelog_clear mds1 $cl_user1 0 ||
16199 error "fail to cancel record for $cl_user1"
16201 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
16203 run_test 160m "Changelog clear race"
16206 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16207 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16208 skip "Need MDS version at least 2.14.51"
16217 changelog_register || error "first changelog_register failed"
16219 cl_users=(${CL_USERS[mds1]})
16220 cl_user1="${cl_users[0]}"
16222 # generate some changelog records to accumulate on MDT0
16223 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16224 first_rec=$(changelog_users $SINGLEMDS |
16225 awk '/^current.index:/ { print $NF }')
16226 while (( last_rec < (( first_rec + 65000)) )); do
16227 createmany -m $DIR/$tdir/$tfile 10000 ||
16228 error "create $DIR/$tdir/$tfile failed"
16230 for i in $(seq 0 10000); do
16231 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
16235 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
16236 error "unlinkmany failed unlink"
16237 last_rec=$(changelog_users $SINGLEMDS |
16238 awk '/^current.index:/ { print $NF }')
16239 echo last record $last_rec
16240 (( last_rec == 0 )) && error "no changelog found"
16243 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
16244 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
16246 __changelog_clear mds1 $cl_user1 0 &
16249 __changelog_clear mds1 $cl_user1 0 ||
16250 error "fail to cancel record for $cl_user1"
16252 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
16254 run_test 160n "Changelog destroy race"
16257 local mdt="$(facet_svc $SINGLEMDS)"
16259 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
16260 remote_mds_nodsh && skip "remote MDS with nodsh"
16261 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
16262 skip "Need MDS version at least 2.14.52"
16264 changelog_register --user test_160o -m unlnk+close+open ||
16265 error "changelog_register failed"
16266 # drop server mask so it doesn't interfere
16267 do_facet $SINGLEMDS $LCTL --device $mdt \
16268 changelog_register -u "Tt3_-#" &&
16269 error "bad symbols in name should fail"
16271 do_facet $SINGLEMDS $LCTL --device $mdt \
16272 changelog_register -u test_160o &&
16273 error "the same name registration should fail"
16275 do_facet $SINGLEMDS $LCTL --device $mdt \
16276 changelog_register -u test_160toolongname &&
16277 error "too long name registration should fail"
16279 changelog_chmask "MARK+HSM"
16280 lctl get_param mdd.*.changelog*mask
16281 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16282 changelog_users $SINGLEMDS | grep -q $cl_user ||
16283 error "User $cl_user not found in changelog_users"
16285 echo $cl_user | grep -q test_160o ||
16286 error "User $cl_user has no specific name 'test160o'"
16289 changelog_clear 0 || error "changelog_clear failed"
16290 # generate some changelog records to accumulate on MDT0
16291 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16292 touch $DIR/$tdir/$tfile # open 1
16294 OPENS=$(changelog_dump | grep -c "OPEN")
16295 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
16297 # must be no MKDIR it wasn't set as user mask
16298 MKDIR=$(changelog_dump | grep -c "MKDIR")
16299 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
16301 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
16302 mdd.$mdt.changelog_current_mask -n)
16303 # register maskless user
16304 changelog_register || error "changelog_register failed"
16305 # effective mask should be not changed because it is not minimal
16306 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16307 mdd.$mdt.changelog_current_mask -n)
16308 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
16309 # set server mask to minimal value
16310 changelog_chmask "MARK"
16311 # check effective mask again, should be treated as DEFMASK now
16312 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16313 mdd.$mdt.changelog_current_mask -n)
16314 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
16316 do_facet $SINGLEMDS $LCTL --device $mdt \
16317 changelog_deregister -u test_160o ||
16318 error "cannot deregister by name"
16320 run_test 160o "changelog user name and mask"
16323 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16324 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16325 skip "Need MDS version at least 2.14.51"
16326 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
16332 changelog_register || error "first changelog_register failed"
16334 cl_users=(${CL_USERS[mds1]})
16335 cl_user1="${cl_users[0]}"
16337 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16338 createmany -m $DIR/$tdir/$tfile 50 ||
16339 error "create $DIR/$tdir/$tfile failed"
16340 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16343 # check changelogs have been generated
16344 entry_count=$(changelog_dump | wc -l)
16345 ((entry_count != 0)) || error "no changelog entries found"
16347 # remove changelog_users and check that orphan entries are removed
16349 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $(mdsdevname 1)"
16350 start mds1 || error "cannot start mdt"
16351 entry_count=$(changelog_dump | wc -l)
16352 ((entry_count == 0)) ||
16353 error "found $entry_count changelog entries, expected none"
16355 run_test 160p "Changelog orphan cleanup with no users"
16358 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16360 test_mkdir -c1 $DIR/$tdir
16361 cp /etc/hosts $DIR/$tdir/$tfile
16362 test_mkdir -c1 $DIR/$tdir/foo1
16363 test_mkdir -c1 $DIR/$tdir/foo2
16364 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
16365 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
16366 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
16367 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
16368 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
16369 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
16370 $LFS fid2path $DIR $FID
16371 error "bad link ea"
16374 rm $DIR/$tdir/foo2/zachary
16376 rm $DIR/$tdir/foo2/thor
16378 rm $DIR/$tdir/$tfile
16380 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
16381 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
16382 { $LFS fid2path $DIR $FID; error "bad link rename"; }
16383 rm $DIR/$tdir/foo2/maggie
16386 local longname=$tfile.avg_len_is_thirty_two_
16387 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
16388 error_noexit 'failed to unlink many hardlinks'" EXIT
16389 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
16390 error "failed to hardlink many files"
16391 links=$($LFS fid2path $DIR $FID | wc -l)
16392 echo -n "${links}/1000 links in link EA"
16393 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
16395 run_test 161a "link ea sanity"
16398 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16399 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
16402 local remote_dir=$DIR/$tdir/remote_dir
16404 mkdir -p $DIR/$tdir
16405 $LFS mkdir -i $MDTIDX $remote_dir ||
16406 error "create remote directory failed"
16408 cp /etc/hosts $remote_dir/$tfile
16409 mkdir -p $remote_dir/foo1
16410 mkdir -p $remote_dir/foo2
16411 ln $remote_dir/$tfile $remote_dir/foo1/sofia
16412 ln $remote_dir/$tfile $remote_dir/foo2/zachary
16413 ln $remote_dir/$tfile $remote_dir/foo1/luna
16414 ln $remote_dir/$tfile $remote_dir/foo2/thor
16416 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
16418 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
16419 $LFS fid2path $DIR $FID
16420 error "bad link ea"
16423 rm $remote_dir/foo2/zachary
16425 rm $remote_dir/foo2/thor
16427 rm $remote_dir/$tfile
16429 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
16430 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
16431 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
16432 $LFS fid2path $DIR $FID
16433 error "bad link rename"
16435 rm $remote_dir/foo2/maggie
16438 local longname=filename_avg_len_is_thirty_two_
16439 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
16440 error "failed to hardlink many files"
16441 links=$($LFS fid2path $DIR $FID | wc -l)
16442 echo -n "${links}/1000 links in link EA"
16443 [[ ${links} -gt 60 ]] ||
16444 error "expected at least 60 links in link EA"
16445 unlinkmany $remote_dir/foo2/$longname 1000 ||
16446 error "failed to unlink many hardlinks"
16448 run_test 161b "link ea sanity under remote directory"
16451 remote_mds_nodsh && skip "remote MDS with nodsh"
16452 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16453 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
16454 skip "Need MDS version at least 2.1.5"
16456 # define CLF_RENAME_LAST 0x0001
16457 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
16458 changelog_register || error "changelog_register failed"
16461 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
16462 touch $DIR/$tdir/foo_161c
16463 touch $DIR/$tdir/bar_161c
16464 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
16465 changelog_dump | grep RENME | tail -n 5
16466 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
16467 changelog_clear 0 || error "changelog_clear failed"
16468 if [ x$flags != "x0x1" ]; then
16469 error "flag $flags is not 0x1"
16472 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
16473 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
16474 touch $DIR/$tdir/foo_161c
16475 touch $DIR/$tdir/bar_161c
16476 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
16477 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
16478 changelog_dump | grep RENME | tail -n 5
16479 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
16480 changelog_clear 0 || error "changelog_clear failed"
16481 if [ x$flags != "x0x0" ]; then
16482 error "flag $flags is not 0x0"
16484 echo "rename overwrite a target having nlink > 1," \
16485 "changelog record has flags of $flags"
16487 # rename doesn't overwrite a target (changelog flag 0x0)
16488 touch $DIR/$tdir/foo_161c
16489 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
16490 changelog_dump | grep RENME | tail -n 5
16491 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
16492 changelog_clear 0 || error "changelog_clear failed"
16493 if [ x$flags != "x0x0" ]; then
16494 error "flag $flags is not 0x0"
16496 echo "rename doesn't overwrite a target," \
16497 "changelog record has flags of $flags"
16499 # define CLF_UNLINK_LAST 0x0001
16500 # unlink a file having nlink = 1 (changelog flag 0x1)
16501 rm -f $DIR/$tdir/foo2_161c
16502 changelog_dump | grep UNLNK | tail -n 5
16503 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
16504 changelog_clear 0 || error "changelog_clear failed"
16505 if [ x$flags != "x0x1" ]; then
16506 error "flag $flags is not 0x1"
16508 echo "unlink a file having nlink = 1," \
16509 "changelog record has flags of $flags"
16511 # unlink a file having nlink > 1 (changelog flag 0x0)
16512 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
16513 rm -f $DIR/$tdir/foobar_161c
16514 changelog_dump | grep UNLNK | tail -n 5
16515 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
16516 changelog_clear 0 || error "changelog_clear failed"
16517 if [ x$flags != "x0x0" ]; then
16518 error "flag $flags is not 0x0"
16520 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
16522 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
16525 remote_mds_nodsh && skip "remote MDS with nodsh"
16526 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
16531 changelog_register || error "changelog_register failed"
16533 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
16534 # interfer with $MOUNT/.lustre/fid/ access
16536 [[ $? -eq 0 ]] || error "mkdir failed"
16538 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
16539 $LCTL set_param fail_loc=0x8000140c
16541 $LCTL set_param fail_val=5
16544 echo foofoo > $DIR/$tdir/$tfile &
16547 # wait for create to be delayed
16551 [[ $? -eq 0 ]] || error "create should be blocked"
16553 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
16554 stack_trap "rm -f $tempfile"
16555 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
16556 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
16557 # some delay may occur during ChangeLog publishing and file read just
16558 # above, that could allow file write to happen finally
16559 [[ -s $tempfile ]] && echo "file should be empty"
16561 $LCTL set_param fail_loc=0
16564 [[ $? -eq 0 ]] || error "create failed"
16566 run_test 161d "create with concurrent .lustre/fid access"
16569 local expected="$1"
16574 path=$($LFS fid2path "$@")
16577 if [ $rc -ne 0 ]; then
16578 error "path looked up of '$expected' failed: rc=$rc"
16579 elif [ "$path" != "$expected" ]; then
16580 error "path looked up '$path' instead of '$expected'"
16582 echo "FID '$fid' resolves to path '$path' as expected"
16586 test_162a() { # was test_162
16587 test_mkdir -p -c1 $DIR/$tdir/d2
16588 touch $DIR/$tdir/d2/$tfile
16589 touch $DIR/$tdir/d2/x1
16590 touch $DIR/$tdir/d2/x2
16591 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
16592 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
16594 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
16595 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
16598 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
16599 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
16600 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
16602 # softlink to wrong file
16603 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
16604 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
16605 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
16608 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
16609 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
16610 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
16611 # fid2path dir/fsname should both work
16612 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
16613 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
16615 # hardlink count: check that there are 2 links
16616 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
16617 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
16619 # hardlink indexing: remove the first link
16620 rm $DIR/$tdir/d2/p/q/r/hlink
16621 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
16623 run_test 162a "path lookup sanity"
16626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16627 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16630 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
16631 error "create striped dir failed"
16633 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
16634 tail -n 1 | awk '{print $2}')
16635 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
16637 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
16638 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
16641 for ((i=0;i<5;i++)); do
16642 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
16643 error "get fid for f$i failed"
16644 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
16646 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
16647 error "get fid for d$i failed"
16648 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
16653 run_test 162b "striped directory path lookup sanity"
16655 # LU-4239: Verify fid2path works with paths 100 or more directories deep
16657 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
16658 skip "Need MDS version at least 2.7.51"
16660 local lpath=$tdir.local
16661 local rpath=$tdir.remote
16663 test_mkdir $DIR/$lpath
16664 test_mkdir $DIR/$rpath
16666 for ((i = 0; i <= 101; i++)); do
16669 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
16670 error "get fid for local directory $DIR/$lpath failed"
16671 check_path "$DIR/$lpath" $MOUNT $FID --link 0
16674 test_mkdir $DIR/$rpath
16675 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
16676 error "get fid for remote directory $DIR/$rpath failed"
16677 check_path "$DIR/$rpath" $MOUNT $FID --link 0
16682 run_test 162c "fid2path works with paths 100 or more directories deep"
16684 oalr_event_count() {
16688 awk -v name="${FSNAME}-OST0000" \
16689 -v event="${event}" \
16690 '$1 == "TRACE" && $2 == event && $3 == name' \
16695 oalr_expect_event_count() {
16698 local expect="${3}"
16701 count=$(oalr_event_count "${event}" "${trace}")
16702 if ((count == expect)); then
16706 error_noexit "${event} event count was '${count}', expected ${expect}"
16712 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
16714 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
16718 sync # Flush previous IOs so we can count log entries.
16719 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
16720 stack_trap cleanup_165 EXIT
16724 local trace="/tmp/${tfile}.trace"
16728 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
16729 skip "OFD access log unsupported"
16732 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
16735 do_facet ost1 ofd_access_log_reader --list
16738 do_facet ost1 killall -TERM ofd_access_log_reader
16742 if ((rc != 0)); then
16743 error "ofd_access_log_reader exited with rc = '${rc}'"
16746 # Parse trace file for discovery events:
16747 oalr_expect_event_count alr_log_add "${trace}" 1
16748 oalr_expect_event_count alr_log_eof "${trace}" 1
16749 oalr_expect_event_count alr_log_free "${trace}" 1
16751 run_test 165a "ofd access log discovery"
16754 local trace="/tmp/${tfile}.trace"
16755 local file="${DIR}/${tfile}"
16764 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
16765 skip "OFD access log unsupported"
16768 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
16771 do_facet ost1 ofd_access_log_reader --list
16773 lfs setstripe -c 1 -i 0 "${file}"
16774 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
16775 error "cannot create '${file}'"
16778 do_facet ost1 killall -TERM ofd_access_log_reader
16782 if ((rc != 0)); then
16783 error "ofd_access_log_reader exited with rc = '${rc}'"
16786 oalr_expect_event_count alr_log_entry "${trace}" 1
16788 pfid1=$($LFS path2fid "${file}")
16790 # 1 2 3 4 5 6 7 8 9 10
16791 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
16792 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
16794 echo "entry = '${entry[*]}'" >&2
16797 if [[ "${pfid1}" != "${pfid2}" ]]; then
16798 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
16802 if ((size != 1048576)); then
16803 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
16807 if [[ "${flags}" != "w" ]]; then
16808 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
16811 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
16814 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
16815 error "cannot read '${file}'"
16818 do_facet ost1 killall -TERM ofd_access_log_reader
16822 if ((rc != 0)); then
16823 error "ofd_access_log_reader exited with rc = '${rc}'"
16826 oalr_expect_event_count alr_log_entry "${trace}" 1
16828 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
16829 echo "entry = '${entry[*]}'" >&2
16832 if [[ "${pfid1}" != "${pfid2}" ]]; then
16833 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
16837 if ((size != 524288)); then
16838 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
16842 if [[ "${flags}" != "r" ]]; then
16843 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
16846 run_test 165b "ofd access log entries are produced and consumed"
16849 local trace="/tmp/${tfile}.trace"
16850 local file="${DIR}/${tdir}/${tfile}"
16852 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
16853 skip "OFD access log unsupported"
16855 test_mkdir "${DIR}/${tdir}"
16858 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
16861 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
16863 # 4096 / 64 = 64. Create twice as many entries.
16864 for ((i = 0; i < 128; i++)); do
16865 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
16866 error "cannot create file"
16871 do_facet ost1 killall -TERM ofd_access_log_reader
16874 if ((rc != 0)); then
16875 error "ofd_access_log_reader exited with rc = '${rc}'"
16878 unlinkmany "${file}-%d" 128
16880 run_test 165c "full ofd access logs do not block IOs"
16882 oal_get_read_count() {
16885 # STATS lustre-OST0001 alr_read_count 1
16887 do_facet ost1 cat "${stats}" |
16888 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
16889 END { print count; }'
16892 oal_expect_read_count() {
16897 # Ask ofd_access_log_reader to write stats.
16898 do_facet ost1 killall -USR1 ofd_access_log_reader
16900 # Allow some time for things to happen.
16903 count=$(oal_get_read_count "${stats}")
16904 if ((count == expect)); then
16908 error_noexit "bad read count, got ${count}, expected ${expect}"
16909 do_facet ost1 cat "${stats}" >&2
16914 local stats="/tmp/${tfile}.stats"
16915 local file="${DIR}/${tdir}/${tfile}"
16916 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
16918 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
16919 skip "OFD access log unsupported"
16921 test_mkdir "${DIR}/${tdir}"
16924 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
16927 lfs setstripe -c 1 -i 0 "${file}"
16929 do_facet ost1 lctl set_param "${param}=rw"
16930 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
16931 error "cannot create '${file}'"
16932 oal_expect_read_count "${stats}" 1
16934 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
16935 error "cannot read '${file}'"
16936 oal_expect_read_count "${stats}" 2
16938 do_facet ost1 lctl set_param "${param}=r"
16939 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
16940 error "cannot create '${file}'"
16941 oal_expect_read_count "${stats}" 2
16943 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
16944 error "cannot read '${file}'"
16945 oal_expect_read_count "${stats}" 3
16947 do_facet ost1 lctl set_param "${param}=w"
16948 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
16949 error "cannot create '${file}'"
16950 oal_expect_read_count "${stats}" 4
16952 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
16953 error "cannot read '${file}'"
16954 oal_expect_read_count "${stats}" 4
16956 do_facet ost1 lctl set_param "${param}=0"
16957 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
16958 error "cannot create '${file}'"
16959 oal_expect_read_count "${stats}" 4
16961 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
16962 error "cannot read '${file}'"
16963 oal_expect_read_count "${stats}" 4
16965 do_facet ost1 killall -TERM ofd_access_log_reader
16968 if ((rc != 0)); then
16969 error "ofd_access_log_reader exited with rc = '${rc}'"
16972 run_test 165d "ofd_access_log mask works"
16975 local stats="/tmp/${tfile}.stats"
16976 local file0="${DIR}/${tdir}-0/${tfile}"
16977 local file1="${DIR}/${tdir}-1/${tfile}"
16979 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
16980 skip "OFD access log unsupported"
16982 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
16984 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
16985 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
16987 lfs setstripe -c 1 -i 0 "${file0}"
16988 lfs setstripe -c 1 -i 0 "${file1}"
16991 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
16994 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
16995 error "cannot create '${file0}'"
16997 oal_expect_read_count "${stats}" 0
16999 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
17000 error "cannot create '${file1}'"
17002 oal_expect_read_count "${stats}" 1
17004 do_facet ost1 killall -TERM ofd_access_log_reader
17007 if ((rc != 0)); then
17008 error "ofd_access_log_reader exited with rc = '${rc}'"
17011 run_test 165e "ofd_access_log MDT index filter works"
17014 local trace="/tmp/${tfile}.trace"
17019 do_facet ost1 timeout 60 ofd_access_log_reader \
17020 --exit-on-close --debug=- --trace=- > "${trace}" &
17027 if ((rc != 0)); then
17028 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
17033 run_test 165f "ofd_access_log_reader --exit-on-close works"
17036 # do directio so as not to populate the page cache
17037 log "creating a 10 Mb file"
17038 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
17039 error "multiop failed while creating a file"
17040 log "starting reads"
17041 dd if=$DIR/$tfile of=/dev/null bs=4096 &
17042 log "truncating the file"
17043 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
17044 error "multiop failed while truncating the file"
17046 kill %+ || true # reads might have finished
17047 echo "wait until dd is finished"
17049 log "removing the temporary file"
17050 rm -rf $DIR/$tfile || error "tmp file removal failed"
17052 run_test 169 "parallel read and truncate should not deadlock"
17055 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17057 $LCTL clear # bug 18514
17058 $LCTL debug_daemon start $TMP/${tfile}_log_good
17060 $LCTL debug_daemon stop
17061 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
17062 error "sed failed to read log_good"
17064 $LCTL debug_daemon start $TMP/${tfile}_log_good
17066 $LCTL debug_daemon stop
17068 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
17069 error "lctl df log_bad failed"
17071 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
17072 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
17074 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
17075 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
17077 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
17078 error "bad_line good_line1 good_line2 are empty"
17080 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
17081 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
17082 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
17084 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
17085 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
17086 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
17088 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
17089 error "bad_line_new good_line_new are empty"
17091 local expected_good=$((good_line1 + good_line2*2))
17093 rm -f $TMP/${tfile}*
17094 # LU-231, short malformed line may not be counted into bad lines
17095 if [ $bad_line -ne $bad_line_new ] &&
17096 [ $bad_line -ne $((bad_line_new - 1)) ]; then
17097 error "expected $bad_line bad lines, but got $bad_line_new"
17101 if [ $expected_good -ne $good_line_new ]; then
17102 error "expected $expected_good good lines, but got $good_line_new"
17107 run_test 170 "test lctl df to handle corrupted log ====================="
17109 test_171() { # bug20592
17110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17112 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
17113 $LCTL set_param fail_loc=0x50e
17114 $LCTL set_param fail_val=3000
17115 multiop_bg_pause $DIR/$tfile O_s || true
17117 kill -USR1 $MULTIPID
17121 if dmesg | grep "recursive fault"; then
17122 error "caught a recursive fault"
17124 $LCTL set_param fail_loc=0
17127 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
17129 # it would be good to share it with obdfilter-survey/iokit-libecho code
17130 setup_obdecho_osc () {
17133 local obdfilter_name=$2
17134 echo "Creating new osc for $obdfilter_name on $ost_nid"
17135 # make sure we can find loopback nid
17136 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
17138 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
17139 ${obdfilter_name}_osc_UUID || rc=2; }
17140 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
17141 ${obdfilter_name}_UUID $ost_nid || rc=3; }
17145 cleanup_obdecho_osc () {
17146 local obdfilter_name=$1
17147 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
17148 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
17155 local pages=${3:-64}
17160 local obd_size=$(get_obd_size $node $OBD)
17161 local page_size=$(get_page_size $node)
17162 if [[ -n "$obd_size" ]]; then
17163 local new_count=$((obd_size / (pages * page_size / 1024)))
17164 [[ $new_count -ge $count ]] || count=$new_count
17167 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
17168 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
17170 if [ $rc -eq 0 ]; then
17171 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
17172 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
17174 echo "New object id is $id"
17175 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
17177 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
17178 "test_brw $count w v $pages $id" || rc=4; }
17179 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
17181 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
17182 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
17183 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
17184 { do_facet $node "$LCTL --device ec detach" || rc=6; }
17185 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
17190 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17192 if ! [ -d /sys/fs/lustre/echo_client ] &&
17193 ! module_loaded obdecho; then
17194 load_module obdecho/obdecho &&
17195 stack_trap "rmmod obdecho" EXIT ||
17196 error "unable to load obdecho on client"
17199 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
17200 local host=$($LCTL get_param -n osc.$osc.import |
17201 awk '/current_connection:/ { print $2 }' )
17202 local target=$($LCTL get_param -n osc.$osc.import |
17203 awk '/target:/ { print $2 }' )
17204 target=${target%_UUID}
17206 if [ -n "$target" ]; then
17207 setup_obdecho_osc $host $target &&
17208 stack_trap "cleanup_obdecho_osc $target" EXIT ||
17209 { error "obdecho setup failed with $?"; return; }
17211 obdecho_test ${target}_osc client ||
17212 error "obdecho_test failed on ${target}_osc"
17214 $LCTL get_param osc.$osc.import
17215 error "there is no osc.$osc.import target"
17218 run_test 180a "test obdecho on osc"
17221 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17222 remote_ost_nodsh && skip "remote OST with nodsh"
17224 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
17225 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
17226 error "failed to load module obdecho"
17228 local target=$(do_facet ost1 $LCTL dl |
17229 awk '/obdfilter/ { print $4; exit; }')
17231 if [ -n "$target" ]; then
17232 obdecho_test $target ost1 || error "obdecho_test failed with $?"
17234 do_facet ost1 $LCTL dl
17235 error "there is no obdfilter target on ost1"
17238 run_test 180b "test obdecho directly on obdfilter"
17240 test_180c() { # LU-2598
17241 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17242 remote_ost_nodsh && skip "remote OST with nodsh"
17243 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
17244 skip "Need MDS version at least 2.4.0"
17246 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
17247 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
17248 error "failed to load module obdecho"
17250 local target=$(do_facet ost1 $LCTL dl |
17251 awk '/obdfilter/ { print $4; exit; }')
17253 if [ -n "$target" ]; then
17254 local pages=16384 # 64MB bulk I/O RPC size
17256 obdecho_test "$target" ost1 "$pages" ||
17257 error "obdecho_test with pages=$pages failed with $?"
17259 do_facet ost1 $LCTL dl
17260 error "there is no obdfilter target on ost1"
17263 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
17265 test_181() { # bug 22177
17266 test_mkdir $DIR/$tdir
17267 # create enough files to index the directory
17268 createmany -o $DIR/$tdir/foobar 4000
17269 # print attributes for debug purpose
17272 multiop_bg_pause $DIR/$tdir D_Sc || return 1
17274 # remove the files & current working dir
17275 unlinkmany $DIR/$tdir/foobar 4000
17277 kill -USR1 $MULTIPID
17279 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
17282 run_test 181 "Test open-unlinked dir ========================"
17288 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
17290 $LCTL set_param mdc.*.rpc_stats=clear
17292 for (( i = 0; i < $tcount; i++ )) ; do
17293 mkdir $DIR/$tdir/$i
17296 for (( i = 0; i < $tcount; i++ )) ; do
17297 createmany -o $DIR/$tdir/$i/f- $fcount &
17301 for (( i = 0; i < $tcount; i++ )) ; do
17302 unlinkmany $DIR/$tdir/$i/f- $fcount &
17306 $LCTL get_param mdc.*.rpc_stats
17310 run_test 182 "Test parallel modify metadata operations ================"
17312 test_183() { # LU-2275
17313 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17314 remote_mds_nodsh && skip "remote MDS with nodsh"
17315 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
17316 skip "Need MDS version at least 2.3.56"
17318 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
17319 echo aaa > $DIR/$tdir/$tfile
17321 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
17322 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
17324 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
17325 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
17327 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17329 # Flush negative dentry cache
17330 touch $DIR/$tdir/$tfile
17332 # We are not checking for any leaked references here, they'll
17333 # become evident next time we do cleanup with module unload.
17336 run_test 183 "No crash or request leak in case of strange dispositions ========"
17338 # test suite 184 is for LU-2016, LU-2017
17340 check_swap_layouts_support
17342 dir0=$DIR/$tdir/$testnum
17343 test_mkdir -p -c1 $dir0
17348 $LFS setstripe -c1 $file1
17350 $LFS setstripe -c2 $file2
17352 gen1=$($LFS getstripe -g $file1)
17353 gen2=$($LFS getstripe -g $file2)
17355 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
17356 gen=$($LFS getstripe -g $file1)
17357 [[ $gen1 != $gen ]] ||
17358 "Layout generation on $file1 does not change"
17359 gen=$($LFS getstripe -g $file2)
17360 [[ $gen2 != $gen ]] ||
17361 "Layout generation on $file2 does not change"
17363 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
17364 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
17366 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
17368 run_test 184a "Basic layout swap"
17371 check_swap_layouts_support
17373 dir0=$DIR/$tdir/$testnum
17374 mkdir -p $dir0 || error "creating dir $dir0"
17381 $LFS setstripe -c1 $file1
17382 $LFS setstripe -c2 $file2
17383 $LFS setstripe -c1 $file3
17384 chown $RUNAS_ID $file3
17385 gen1=$($LFS getstripe -g $file1)
17386 gen2=$($LFS getstripe -g $file2)
17388 $LFS swap_layouts $dir1 $dir2 &&
17389 error "swap of directories layouts should fail"
17390 $LFS swap_layouts $dir1 $file1 &&
17391 error "swap of directory and file layouts should fail"
17392 $RUNAS $LFS swap_layouts $file1 $file2 &&
17393 error "swap of file we cannot write should fail"
17394 $LFS swap_layouts $file1 $file3 &&
17395 error "swap of file with different owner should fail"
17396 /bin/true # to clear error code
17398 run_test 184b "Forbidden layout swap (will generate errors)"
17401 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
17402 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
17403 check_swap_layouts_support
17404 check_swap_layout_no_dom $DIR
17406 local dir0=$DIR/$tdir/$testnum
17407 mkdir -p $dir0 || error "creating dir $dir0"
17409 local ref1=$dir0/ref1
17410 local ref2=$dir0/ref2
17411 local file1=$dir0/file1
17412 local file2=$dir0/file2
17413 # create a file large enough for the concurrent test
17414 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
17415 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
17416 echo "ref file size: ref1($(stat -c %s $ref1))," \
17417 "ref2($(stat -c %s $ref2))"
17420 dd if=$ref1 of=$file1 bs=16k &
17423 # Make sure dd starts to copy file, but wait at most 5 seconds
17425 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
17427 $LFS swap_layouts $file1 $file2
17430 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
17431 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
17433 # how many bytes copied before swapping layout
17434 local copied=$(stat -c %s $file2)
17435 local remaining=$(stat -c %s $ref1)
17436 remaining=$((remaining - copied))
17437 echo "Copied $copied bytes before swapping layout..."
17439 cmp -n $copied $file1 $ref2 | grep differ &&
17440 error "Content mismatch [0, $copied) of ref2 and file1"
17441 cmp -n $copied $file2 $ref1 ||
17442 error "Content mismatch [0, $copied) of ref1 and file2"
17443 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
17444 error "Content mismatch [$copied, EOF) of ref1 and file1"
17447 rm -f $ref1 $ref2 $file1 $file2
17449 run_test 184c "Concurrent write and layout swap"
17452 check_swap_layouts_support
17453 check_swap_layout_no_dom $DIR
17454 [ -z "$(which getfattr 2>/dev/null)" ] &&
17455 skip_env "no getfattr command"
17457 local file1=$DIR/$tdir/$tfile-1
17458 local file2=$DIR/$tdir/$tfile-2
17459 local file3=$DIR/$tdir/$tfile-3
17463 mkdir -p $DIR/$tdir
17464 touch $file1 || error "create $file1 failed"
17465 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
17466 error "create $file2 failed"
17467 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
17468 error "create $file3 failed"
17469 lovea1=$(get_layout_param $file1)
17471 $LFS swap_layouts $file2 $file3 ||
17472 error "swap $file2 $file3 layouts failed"
17473 $LFS swap_layouts $file1 $file2 ||
17474 error "swap $file1 $file2 layouts failed"
17476 lovea2=$(get_layout_param $file2)
17479 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
17481 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
17482 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
17484 run_test 184d "allow stripeless layouts swap"
17487 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
17488 skip "Need MDS version at least 2.6.94"
17489 check_swap_layouts_support
17490 check_swap_layout_no_dom $DIR
17491 [ -z "$(which getfattr 2>/dev/null)" ] &&
17492 skip_env "no getfattr command"
17494 local file1=$DIR/$tdir/$tfile-1
17495 local file2=$DIR/$tdir/$tfile-2
17496 local file3=$DIR/$tdir/$tfile-3
17499 mkdir -p $DIR/$tdir
17500 touch $file1 || error "create $file1 failed"
17501 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
17502 error "create $file2 failed"
17503 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
17504 error "create $file3 failed"
17506 $LFS swap_layouts $file1 $file2 ||
17507 error "swap $file1 $file2 layouts failed"
17509 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
17510 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
17512 echo 123 > $file1 || error "Should be able to write into $file1"
17514 $LFS swap_layouts $file1 $file3 ||
17515 error "swap $file1 $file3 layouts failed"
17517 echo 123 > $file1 || error "Should be able to write into $file1"
17519 rm -rf $file1 $file2 $file3
17521 run_test 184e "Recreate layout after stripeless layout swaps"
17524 # Create a file with name longer than sizeof(struct stat) ==
17525 # 144 to see if we can get chars from the file name to appear
17526 # in the returned striping. Note that 'f' == 0x66.
17527 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
17529 mkdir -p $DIR/$tdir
17530 mcreate $DIR/$tdir/$file
17531 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
17532 error "IOC_MDC_GETFILEINFO returned garbage striping"
17535 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
17537 test_185() { # LU-2441
17538 # LU-3553 - no volatile file support in old servers
17539 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
17540 skip "Need MDS version at least 2.3.60"
17542 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
17543 touch $DIR/$tdir/spoo
17544 local mtime1=$(stat -c "%Y" $DIR/$tdir)
17545 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
17546 error "cannot create/write a volatile file"
17547 [ "$FILESET" == "" ] &&
17548 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
17549 error "FID is still valid after close"
17551 multiop_bg_pause $DIR/$tdir vVw4096_c
17558 # assume that the next FID for this client is sequential, since stdout
17559 # is unfortunately eaten by multiop_bg_pause
17560 local n=$((${fidv[1]} + 1))
17561 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
17562 if [ "$FILESET" == "" ]; then
17563 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
17564 error "FID is missing before close"
17566 kill -USR1 $multi_pid
17567 # 1 second delay, so if mtime change we will see it
17569 local mtime2=$(stat -c "%Y" $DIR/$tdir)
17570 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
17572 run_test 185 "Volatile file support"
17574 function create_check_volatile() {
17578 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
17581 local FID=$(cat /tmp/${tfile}.fid)
17582 [ "$FID" == "" ] && error "can't get FID for volatile"
17583 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
17584 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
17585 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
17589 cancel_lru_locks mdc # flush opencache
17590 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
17595 # LU-12516 - volatile creation via .lustre
17596 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
17597 skip "Need MDS version at least 2.3.55"
17599 create_check_volatile 0
17600 [ $MDSCOUNT -lt 2 ] && return 0
17603 create_check_volatile 1
17607 run_test 185a "Volatile file creation in .lustre/fid/"
17610 remote_mds_nodsh && skip "remote MDS with nodsh"
17611 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
17612 skip "Need MDS version at least 2.3.0"
17614 local dir0=$DIR/$tdir/$testnum
17615 mkdir -p $dir0 || error "creating dir $dir0"
17617 local file=$dir0/file1
17618 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
17619 local dv1=$($LFS data_version $file)
17620 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
17621 local dv2=$($LFS data_version $file)
17622 [[ $dv1 != $dv2 ]] ||
17623 error "data version did not change on write $dv1 == $dv2"
17628 run_test 187a "Test data version change"
17631 remote_mds_nodsh && skip "remote MDS with nodsh"
17632 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
17633 skip "Need MDS version at least 2.3.0"
17635 local dir0=$DIR/$tdir/$testnum
17636 mkdir -p $dir0 || error "creating dir $dir0"
17638 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
17639 [[ ${DV[0]} != ${DV[1]} ]] ||
17640 error "data version did not change on write"\
17641 " ${DV[0]} == ${DV[1]}"
17646 run_test 187b "Test data version change on volatile file"
17649 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17650 remote_mgs_nodsh && skip "remote MGS with nodsh"
17651 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
17653 local POOL=${POOL:-cea1}
17654 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
17655 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
17658 local last_ost=$(($OSTCOUNT - 1))
17660 local ost_list=$(seq $first_ost $ost_step $last_ost)
17661 local ost_range="$first_ost $last_ost $ost_step"
17662 local test_path=$POOL_ROOT/$POOL_DIR_NAME
17663 local file_dir=$POOL_ROOT/file_tst
17664 local subdir=$test_path/subdir
17668 # former test_200a test_200b
17669 pool_add $POOL || { rc=$? ; break; }
17670 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
17671 # former test_200c test_200d
17672 mkdir -p $test_path
17673 pool_set_dir $POOL $test_path || { rc=$? ; break; }
17674 pool_check_dir $POOL $test_path || { rc=$? ; break; }
17676 pool_check_dir $POOL $subdir || { rc=$? ; break; }
17677 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
17678 || { rc=$? ; break; }
17679 # former test_200e test_200f
17680 local files=$((OSTCOUNT*3))
17681 pool_alloc_files $POOL $test_path $files "$ost_list" \
17682 || { rc=$? ; break; }
17683 pool_create_files $POOL $file_dir $files "$ost_list" \
17684 || { rc=$? ; break; }
17685 # former test_200g test_200h
17686 pool_lfs_df $POOL || { rc=$? ; break; }
17687 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
17689 # former test_201a test_201b test_201c
17690 pool_remove_first_target $POOL || { rc=$? ; break; }
17692 local f=$test_path/$tfile
17693 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
17694 pool_remove $POOL $f || { rc=$? ; break; }
17702 run_test 200 "OST pools"
17704 # usage: default_attr <count | size | offset>
17706 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
17709 # usage: check_default_stripe_attr
17710 check_default_stripe_attr() {
17711 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
17714 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
17716 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
17720 error "unknown getstripe attr '$1'"
17723 [ $ACTUAL == $EXPECTED ] ||
17724 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
17728 test_mkdir $DIR/$tdir
17729 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
17731 check_default_stripe_attr --stripe-count
17732 check_default_stripe_attr --stripe-size
17733 check_default_stripe_attr --stripe-index
17735 run_test 204a "Print default stripe attributes"
17738 test_mkdir $DIR/$tdir
17739 $LFS setstripe --stripe-count 1 $DIR/$tdir
17741 check_default_stripe_attr --stripe-size
17742 check_default_stripe_attr --stripe-index
17744 run_test 204b "Print default stripe size and offset"
17747 test_mkdir $DIR/$tdir
17748 $LFS setstripe --stripe-size 65536 $DIR/$tdir
17750 check_default_stripe_attr --stripe-count
17751 check_default_stripe_attr --stripe-index
17753 run_test 204c "Print default stripe count and offset"
17756 test_mkdir $DIR/$tdir
17757 $LFS setstripe --stripe-index 0 $DIR/$tdir
17759 check_default_stripe_attr --stripe-count
17760 check_default_stripe_attr --stripe-size
17762 run_test 204d "Print default stripe count and size"
17765 test_mkdir $DIR/$tdir
17766 $LFS setstripe -d $DIR/$tdir
17768 check_default_stripe_attr --stripe-count --raw
17769 check_default_stripe_attr --stripe-size --raw
17770 check_default_stripe_attr --stripe-index --raw
17772 run_test 204e "Print raw stripe attributes"
17775 test_mkdir $DIR/$tdir
17776 $LFS setstripe --stripe-count 1 $DIR/$tdir
17778 check_default_stripe_attr --stripe-size --raw
17779 check_default_stripe_attr --stripe-index --raw
17781 run_test 204f "Print raw stripe size and offset"
17784 test_mkdir $DIR/$tdir
17785 $LFS setstripe --stripe-size 65536 $DIR/$tdir
17787 check_default_stripe_attr --stripe-count --raw
17788 check_default_stripe_attr --stripe-index --raw
17790 run_test 204g "Print raw stripe count and offset"
17793 test_mkdir $DIR/$tdir
17794 $LFS setstripe --stripe-index 0 $DIR/$tdir
17796 check_default_stripe_attr --stripe-count --raw
17797 check_default_stripe_attr --stripe-size --raw
17799 run_test 204h "Print raw stripe count and size"
17801 # Figure out which job scheduler is being used, if any,
17802 # or use a fake one
17803 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
17804 JOBENV=SLURM_JOB_ID
17805 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
17807 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
17809 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
17810 JOBENV=LOADL_STEP_ID
17811 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
17814 $LCTL list_param jobid_name > /dev/null 2>&1
17815 if [ $? -eq 0 ]; then
17821 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
17823 verify_jobstats() {
17828 # we don't really need to clear the stats for this test to work, since each
17829 # command has a unique jobid, but it makes debugging easier if needed.
17830 # for facet in $facets; do
17831 # local dev=$(convert_facet2label $facet)
17832 # # clear old jobstats
17833 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
17836 # use a new JobID for each test, or we might see an old one
17837 [ "$JOBENV" = "FAKE_JOBID" ] &&
17838 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
17840 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
17842 [ "$JOBENV" = "nodelocal" ] && {
17843 FAKE_JOBID=id.$testnum.%e.$RANDOM
17844 $LCTL set_param jobid_name=$FAKE_JOBID
17845 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
17848 log "Test: ${cmd[*]}"
17849 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
17851 if [ $JOBENV = "FAKE_JOBID" ]; then
17852 FAKE_JOBID=$JOBVAL ${cmd[*]}
17857 # all files are created on OST0000
17858 for facet in $facets; do
17859 local stats="*.$(convert_facet2label $facet).job_stats"
17861 # strip out libtool wrappers for in-tree executables
17862 if [ $(do_facet $facet lctl get_param $stats |
17863 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
17864 do_facet $facet lctl get_param $stats
17865 error "No jobstats for $JOBVAL found on $facet::$stats"
17871 local new_jobenv=$1
17873 set_persistent_param_and_check client "jobid_var" \
17874 "$FSNAME.sys.jobid_var" $new_jobenv
17877 test_205a() { # Job stats
17878 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17879 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
17880 skip "Need MDS version with at least 2.7.1"
17881 remote_mgs_nodsh && skip "remote MGS with nodsh"
17882 remote_mds_nodsh && skip "remote MDS with nodsh"
17883 remote_ost_nodsh && skip "remote OST with nodsh"
17884 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
17885 skip "Server doesn't support jobstats"
17886 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
17888 local old_jobenv=$($LCTL get_param -n jobid_var)
17889 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
17891 if [[ $PERM_CMD == *"set_param -P"* ]]; then
17892 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
17894 stack_trap "do_facet mgs $PERM_CMD \
17895 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
17899 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
17900 mdt.*.job_cleanup_interval | head -n 1)
17901 local new_interval=5
17902 do_facet $SINGLEMDS \
17903 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
17904 stack_trap "do_facet $SINGLEMDS \
17905 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
17906 local start=$SECONDS
17910 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
17911 verify_jobstats "$cmd" "$SINGLEMDS"
17913 cmd="rmdir $DIR/$tdir"
17914 verify_jobstats "$cmd" "$SINGLEMDS"
17915 # mkdir on secondary MDT
17916 if [ $MDSCOUNT -gt 1 ]; then
17917 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
17918 verify_jobstats "$cmd" "mds2"
17921 cmd="mknod $DIR/$tfile c 1 3"
17922 verify_jobstats "$cmd" "$SINGLEMDS"
17924 cmd="rm -f $DIR/$tfile"
17925 verify_jobstats "$cmd" "$SINGLEMDS"
17926 # create all files on OST0000 so verify_jobstats can find OST stats
17928 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
17929 verify_jobstats "$cmd" "$SINGLEMDS"
17931 cmd="touch $DIR/$tfile"
17932 verify_jobstats "$cmd" "$SINGLEMDS ost1"
17934 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
17935 verify_jobstats "$cmd" "ost1"
17937 cancel_lru_locks osc
17938 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
17939 verify_jobstats "$cmd" "ost1"
17941 cmd="$TRUNCATE $DIR/$tfile 0"
17942 verify_jobstats "$cmd" "$SINGLEMDS ost1"
17944 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
17945 verify_jobstats "$cmd" "$SINGLEMDS"
17946 # jobstats expiry - sleep until old stats should be expired
17947 local left=$((new_interval + 5 - (SECONDS - start)))
17948 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
17949 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
17951 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
17952 verify_jobstats "$cmd" "$SINGLEMDS"
17953 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
17954 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
17956 # Ensure that jobid are present in changelog (if supported by MDS)
17957 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
17958 changelog_dump | tail -10
17959 jobids=$(changelog_dump | tail -9 | grep -c "j=")
17960 [ $jobids -eq 9 ] ||
17961 error "Wrong changelog jobid count $jobids != 9"
17965 jobstats_set $JOBENV
17967 changelog_dump | grep $tfile
17968 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
17969 [ $jobids -eq 0 ] ||
17970 error "Unexpected jobids when jobid_var=$JOBENV"
17973 # test '%j' access to environment variable - if supported
17974 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
17975 JOBENV="JOBCOMPLEX"
17976 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
17978 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
17981 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
17982 JOBENV="JOBCOMPLEX"
17983 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
17985 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
17988 # test '%j' access to per-session jobid - if supported
17989 if lctl list_param jobid_this_session > /dev/null 2>&1
17991 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
17992 lctl set_param jobid_this_session=$USER
17994 JOBENV="JOBCOMPLEX"
17995 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
17997 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18000 run_test 205a "Verify job stats"
18002 # LU-13117, LU-13597
18004 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
18005 skip "Need MDS version at least 2.13.54.91"
18007 job_stats="mdt.*.job_stats"
18008 $LCTL set_param $job_stats=clear
18009 # Setting jobid_var to USER might not be supported
18010 $LCTL set_param jobid_var=USER || true
18011 $LCTL set_param jobid_name="%e.%u"
18012 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
18013 do_facet $SINGLEMDS $LCTL get_param $job_stats |
18014 grep "job_id:.*foolish" &&
18015 error "Unexpected jobid found"
18016 do_facet $SINGLEMDS $LCTL get_param $job_stats |
18017 grep "open:.*min.*max.*sum" ||
18018 error "wrong job_stats format found"
18020 run_test 205b "Verify job stats jobid and output format"
18024 $LCTL set_param llite.*.stats=0
18025 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
18026 $LCTL get_param llite.*.stats
18027 $LCTL get_param llite.*.stats | grep \
18028 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
18029 error "wrong client stats format found"
18031 run_test 205c "Verify client stats format"
18033 # LU-1480, LU-1773 and LU-1657
18035 mkdir -p $DIR/$tdir
18036 $LFS setstripe -c -1 $DIR/$tdir
18037 #define OBD_FAIL_LOV_INIT 0x1403
18038 $LCTL set_param fail_loc=0xa0001403
18039 $LCTL set_param fail_val=1
18040 touch $DIR/$tdir/$tfile || true
18042 run_test 206 "fail lov_init_raid0() doesn't lbug"
18045 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
18046 local fsz=`stat -c %s $DIR/$tfile`
18047 cancel_lru_locks mdc
18049 # do not return layout in getattr intent
18050 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
18051 $LCTL set_param fail_loc=0x170
18052 local sz=`stat -c %s $DIR/$tfile`
18054 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
18058 run_test 207a "can refresh layout at glimpse"
18061 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
18062 local cksum=`md5sum $DIR/$tfile`
18063 local fsz=`stat -c %s $DIR/$tfile`
18064 cancel_lru_locks mdc
18065 cancel_lru_locks osc
18067 # do not return layout in getattr intent
18068 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
18069 $LCTL set_param fail_loc=0x171
18071 # it will refresh layout after the file is opened but before read issues
18072 echo checksum is "$cksum"
18073 echo "$cksum" |md5sum -c --quiet || error "file differs"
18077 run_test 207b "can refresh layout at open"
18080 # FIXME: in this test suite, only RD lease is used. This is okay
18081 # for now as only exclusive open is supported. After generic lease
18082 # is done, this test suite should be revised. - Jinshan
18084 remote_mds_nodsh && skip "remote MDS with nodsh"
18085 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
18086 skip "Need MDS version at least 2.4.52"
18088 echo "==== test 1: verify get lease work"
18089 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
18091 echo "==== test 2: verify lease can be broken by upcoming open"
18092 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
18096 $MULTIOP $DIR/$tfile oO_RDONLY:c
18097 kill -USR1 $PID && wait $PID || error "break lease error"
18099 echo "==== test 3: verify lease can't be granted if an open already exists"
18100 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
18104 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
18105 kill -USR1 $PID && wait $PID || error "open file error"
18107 echo "==== test 4: lease can sustain over recovery"
18108 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
18114 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
18116 echo "==== test 5: lease broken can't be regained by replay"
18117 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
18121 # open file to break lease and then recovery
18122 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
18125 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
18129 run_test 208 "Exclusive open"
18132 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
18133 skip_env "must have disp_stripe"
18136 sync; sleep 5; sync;
18138 echo 3 > /proc/sys/vm/drop_caches
18139 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
18140 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
18141 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
18143 # open/close 500 times
18144 for i in $(seq 500); do
18148 echo 3 > /proc/sys/vm/drop_caches
18149 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
18150 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
18151 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
18153 echo "before: $req_before, after: $req_after"
18154 [ $((req_after - req_before)) -ge 300 ] &&
18155 error "open/close requests are not freed"
18158 run_test 209 "read-only open/close requests should be freed promptly"
18163 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
18167 $LFS getstripe $DIR/$tfile
18169 wait $pid || error "multiop failed"
18171 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
18175 $LFS getstripe $DIR/$tfile
18177 wait $pid || error "multiop failed"
18179 run_test 210 "lfs getstripe does not break leases"
18183 size=$((size % 8192 + 1))
18184 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
18185 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
18186 rm -f $DIR/f212 $DIR/f212.xyz
18188 run_test 212 "Sendfile test ============================================"
18191 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
18192 cancel_lru_locks osc
18193 lctl set_param fail_loc=0x8000040f
18194 # generate a read lock
18195 cat $DIR/$tfile > /dev/null
18196 # write to the file, it will try to cancel the above read lock.
18197 cat /etc/hosts >> $DIR/$tfile
18199 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
18201 test_214() { # for bug 20133
18202 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
18203 for (( i=0; i < 340; i++ )) ; do
18204 touch $DIR/$tdir/d214c/a$i
18207 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
18208 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
18209 ls $DIR/d214c || error "ls $DIR/d214c failed"
18210 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
18211 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
18213 run_test 214 "hash-indexed directory test - bug 20133"
18215 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
18216 create_lnet_proc_files() {
18217 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
18220 # counterpart of create_lnet_proc_files
18221 remove_lnet_proc_files() {
18222 rm -f $TMP/lnet_$1.sys
18225 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
18226 # 3rd arg as regexp for body
18227 check_lnet_proc_stats() {
18228 local l=$(cat "$TMP/lnet_$1" |wc -l)
18229 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
18231 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
18234 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
18235 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
18236 # optional and can be regexp for 2nd line (lnet.routes case)
18237 check_lnet_proc_entry() {
18238 local blp=2 # blp stands for 'position of 1st line of body'
18239 [ -z "$5" ] || blp=3 # lnet.routes case
18241 local l=$(cat "$TMP/lnet_$1" |wc -l)
18242 # subtracting one from $blp because the body can be empty
18243 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
18245 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
18246 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
18248 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
18249 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
18251 # bail out if any unexpected line happened
18252 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
18253 [ "$?" != 0 ] || error "$2 misformatted"
18256 test_215() { # for bugs 18102, 21079, 21517
18257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18259 local N='(0|[1-9][0-9]*)' # non-negative numeric
18260 local P='[1-9][0-9]*' # positive numeric
18261 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
18262 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
18263 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
18264 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
18266 local L1 # regexp for 1st line
18267 local L2 # regexp for 2nd line (optional)
18268 local BR # regexp for the rest (body)
18270 # lnet.stats should look as 11 space-separated non-negative numerics
18271 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
18272 create_lnet_proc_files "stats"
18273 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
18274 remove_lnet_proc_files "stats"
18276 # lnet.routes should look like this:
18277 # Routing disabled/enabled
18278 # net hops priority state router
18279 # where net is a string like tcp0, hops > 0, priority >= 0,
18280 # state is up/down,
18281 # router is a string like 192.168.1.1@tcp2
18282 L1="^Routing (disabled|enabled)$"
18283 L2="^net +hops +priority +state +router$"
18284 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
18285 create_lnet_proc_files "routes"
18286 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
18287 remove_lnet_proc_files "routes"
18289 # lnet.routers should look like this:
18290 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
18291 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
18292 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
18293 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
18294 L1="^ref +rtr_ref +alive +router$"
18295 BR="^$P +$P +(up|down) +$NID$"
18296 create_lnet_proc_files "routers"
18297 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
18298 remove_lnet_proc_files "routers"
18300 # lnet.peers should look like this:
18301 # nid refs state last max rtr min tx min queue
18302 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
18303 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
18304 # numeric (0 or >0 or <0), queue >= 0.
18305 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
18306 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
18307 create_lnet_proc_files "peers"
18308 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
18309 remove_lnet_proc_files "peers"
18311 # lnet.buffers should look like this:
18312 # pages count credits min
18313 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
18314 L1="^pages +count +credits +min$"
18315 BR="^ +$N +$N +$I +$I$"
18316 create_lnet_proc_files "buffers"
18317 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
18318 remove_lnet_proc_files "buffers"
18320 # lnet.nis should look like this:
18321 # nid status alive refs peer rtr max tx min
18322 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
18323 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
18324 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
18325 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
18326 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
18327 create_lnet_proc_files "nis"
18328 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
18329 remove_lnet_proc_files "nis"
18331 # can we successfully write to lnet.stats?
18332 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
18334 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
18336 test_216() { # bug 20317
18337 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18338 remote_ost_nodsh && skip "remote OST with nodsh"
18341 local facets=$(get_facets OST)
18342 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
18344 save_lustre_params client "osc.*.contention_seconds" > $p
18345 save_lustre_params $facets \
18346 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
18347 save_lustre_params $facets \
18348 "ldlm.namespaces.filter-*.contended_locks" >> $p
18349 save_lustre_params $facets \
18350 "ldlm.namespaces.filter-*.contention_seconds" >> $p
18351 clear_stats osc.*.osc_stats
18353 # agressive lockless i/o settings
18354 do_nodes $(comma_list $(osts_nodes)) \
18355 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
18356 ldlm.namespaces.filter-*.contended_locks=0 \
18357 ldlm.namespaces.filter-*.contention_seconds=60"
18358 lctl set_param -n osc.*.contention_seconds=60
18360 $DIRECTIO write $DIR/$tfile 0 10 4096
18361 $CHECKSTAT -s 40960 $DIR/$tfile
18363 # disable lockless i/o
18364 do_nodes $(comma_list $(osts_nodes)) \
18365 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
18366 ldlm.namespaces.filter-*.contended_locks=32 \
18367 ldlm.namespaces.filter-*.contention_seconds=0"
18368 lctl set_param -n osc.*.contention_seconds=0
18369 clear_stats osc.*.osc_stats
18371 dd if=/dev/zero of=$DIR/$tfile count=0
18372 $CHECKSTAT -s 0 $DIR/$tfile
18374 restore_lustre_params <$p
18378 run_test 216 "check lockless direct write updates file size and kms correctly"
18380 test_217() { # bug 22430
18381 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18386 for node in $(nodes_list); do
18387 nid=$(host_nids_address $node $NETTYPE)
18388 if [[ $nid = *-* ]] ; then
18389 echo "lctl ping $(h2nettype $nid)"
18390 lctl ping $(h2nettype $nid)
18392 echo "skipping $node (no hyphen detected)"
18396 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
18399 # do directio so as not to populate the page cache
18400 log "creating a 10 Mb file"
18401 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
18402 log "starting reads"
18403 dd if=$DIR/$tfile of=/dev/null bs=4096 &
18404 log "truncating the file"
18405 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
18407 kill %+ || true # reads might have finished
18408 echo "wait until dd is finished"
18410 log "removing the temporary file"
18411 rm -rf $DIR/$tfile || error "tmp file removal failed"
18413 run_test 218 "parallel read and truncate should not deadlock"
18416 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18418 # write one partial page
18419 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
18420 # set no grant so vvp_io_commit_write will do sync write
18421 $LCTL set_param fail_loc=0x411
18422 # write a full page at the end of file
18423 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
18425 $LCTL set_param fail_loc=0
18426 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
18427 $LCTL set_param fail_loc=0x411
18428 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
18431 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
18432 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
18434 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
18436 test_220() { #LU-325
18437 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18438 remote_ost_nodsh && skip "remote OST with nodsh"
18439 remote_mds_nodsh && skip "remote MDS with nodsh"
18440 remote_mgs_nodsh && skip "remote MGS with nodsh"
18444 # create on MDT0000 so the last_id and next_id are correct
18445 mkdir_on_mdt0 $DIR/$tdir
18446 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
18450 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
18451 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
18452 osp.$mdtosc_proc1.prealloc_last_id)
18453 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
18454 osp.$mdtosc_proc1.prealloc_next_id)
18458 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
18459 #define OBD_FAIL_OST_ENOINO 0x229
18460 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
18461 create_pool $FSNAME.$TESTNAME || return 1
18462 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
18464 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
18466 MDSOBJS=$((last_id - next_id))
18467 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
18469 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
18470 echo "OST still has $count kbytes free"
18472 echo "create $MDSOBJS files @next_id..."
18473 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
18475 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
18476 osp.$mdtosc_proc1.prealloc_last_id)
18477 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
18478 osp.$mdtosc_proc1.prealloc_next_id)
18480 echo "after creation, last_id=$last_id2, next_id=$next_id2"
18485 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
18486 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
18488 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
18489 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
18490 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
18491 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
18492 echo "unlink $MDSOBJS files @$next_id..."
18493 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
18495 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
18498 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18500 dd if=`which date` of=$MOUNT/date oflag=sync
18501 chmod +x $MOUNT/date
18503 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
18504 $LCTL set_param fail_loc=0x80001401
18506 $MOUNT/date > /dev/null
18509 run_test 221 "make sure fault and truncate race to not cause OOM"
18512 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18515 test_mkdir $DIR/$tdir
18516 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18517 createmany -o $DIR/$tdir/$tfile 10
18518 cancel_lru_locks mdc
18519 cancel_lru_locks osc
18520 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
18521 $LCTL set_param fail_loc=0x31a
18522 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
18523 $LCTL set_param fail_loc=0
18526 run_test 222a "AGL for ls should not trigger CLIO lock failure"
18529 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18532 test_mkdir $DIR/$tdir
18533 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18534 createmany -o $DIR/$tdir/$tfile 10
18535 cancel_lru_locks mdc
18536 cancel_lru_locks osc
18537 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
18538 $LCTL set_param fail_loc=0x31a
18539 rm -r $DIR/$tdir || error "AGL for rmdir failed"
18540 $LCTL set_param fail_loc=0
18542 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
18545 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18548 test_mkdir $DIR/$tdir
18549 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18550 createmany -o $DIR/$tdir/$tfile 10
18551 cancel_lru_locks mdc
18552 cancel_lru_locks osc
18553 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
18554 $LCTL set_param fail_loc=0x31b
18555 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
18556 $LCTL set_param fail_loc=0
18559 run_test 223 "osc reenqueue if without AGL lock granted ======================="
18561 test_224a() { # LU-1039, MRP-303
18562 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18564 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
18565 $LCTL set_param fail_loc=0x508
18566 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
18567 $LCTL set_param fail_loc=0
18570 run_test 224a "Don't panic on bulk IO failure"
18572 test_224b() { # LU-1039, MRP-303
18573 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18575 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
18576 cancel_lru_locks osc
18577 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
18578 $LCTL set_param fail_loc=0x515
18579 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
18580 $LCTL set_param fail_loc=0
18583 run_test 224b "Don't panic on bulk IO failure"
18585 test_224c() { # LU-6441
18586 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18587 remote_mds_nodsh && skip "remote MDS with nodsh"
18589 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
18590 save_writethrough $p
18591 set_cache writethrough on
18593 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
18594 local at_max=$($LCTL get_param -n at_max)
18595 local timeout=$($LCTL get_param -n timeout)
18596 local test_at="at_max"
18597 local param_at="$FSNAME.sys.at_max"
18598 local test_timeout="timeout"
18599 local param_timeout="$FSNAME.sys.timeout"
18601 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
18603 set_persistent_param_and_check client "$test_at" "$param_at" 0
18604 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
18606 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
18607 do_facet ost1 "$LCTL set_param fail_loc=0x520"
18608 $LFS setstripe -c 1 -i 0 $DIR/$tfile
18609 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
18611 do_facet ost1 "$LCTL set_param fail_loc=0"
18613 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
18614 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
18617 $LCTL set_param -n $pages_per_rpc
18618 restore_lustre_params < $p
18621 run_test 224c "Don't hang if one of md lost during large bulk RPC"
18623 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
18625 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18626 if [ -z ${MDSSURVEY} ]; then
18627 skip_env "mds-survey not found"
18629 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
18630 skip "Need MDS version at least 2.2.51"
18632 local mds=$(facet_host $SINGLEMDS)
18633 local target=$(do_nodes $mds 'lctl dl' |
18634 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
18636 local cmd1="file_count=1000 thrhi=4"
18637 local cmd2="dir_count=2 layer=mdd stripe_count=0"
18638 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
18639 local cmd="$cmd1 $cmd2 $cmd3"
18641 rm -f ${TMP}/mds_survey*
18643 eval $cmd || error "mds-survey with zero-stripe failed"
18644 cat ${TMP}/mds_survey*
18645 rm -f ${TMP}/mds_survey*
18647 run_test 225a "Metadata survey sanity with zero-stripe"
18650 if [ -z ${MDSSURVEY} ]; then
18651 skip_env "mds-survey not found"
18653 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
18654 skip "Need MDS version at least 2.2.51"
18655 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18656 remote_mds_nodsh && skip "remote MDS with nodsh"
18657 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
18658 skip_env "Need to mount OST to test"
18661 local mds=$(facet_host $SINGLEMDS)
18662 local target=$(do_nodes $mds 'lctl dl' |
18663 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
18665 local cmd1="file_count=1000 thrhi=4"
18666 local cmd2="dir_count=2 layer=mdd stripe_count=1"
18667 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
18668 local cmd="$cmd1 $cmd2 $cmd3"
18670 rm -f ${TMP}/mds_survey*
18672 eval $cmd || error "mds-survey with stripe_count failed"
18673 cat ${TMP}/mds_survey*
18674 rm -f ${TMP}/mds_survey*
18676 run_test 225b "Metadata survey sanity with stripe_count = 1"
18678 mcreate_path2fid () {
18684 local path=$DIR/$tdir/$name
18689 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
18690 error "cannot create $desc"
18692 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
18694 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
18696 fid_path=$($LFS fid2path $MOUNT $fid)
18698 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
18700 [ "$path" == "$fid_path" ] ||
18701 error "fid2path returned $fid_path, expected $path"
18703 echo "pass with $path and $fid"
18708 mkdir -p $DIR/$tdir
18710 mcreate_path2fid 0010666 0 0 fifo "FIFO"
18711 mcreate_path2fid 0020666 1 3 null "character special file (null)"
18712 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
18713 mcreate_path2fid 0040666 0 0 dir "directory"
18714 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
18715 mcreate_path2fid 0100666 0 0 file "regular file"
18716 mcreate_path2fid 0120666 0 0 link "symbolic link"
18717 mcreate_path2fid 0140666 0 0 sock "socket"
18719 run_test 226a "call path2fid and fid2path on files of all type"
18722 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18727 mkdir -p $DIR/$tdir
18728 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
18729 error "create remote directory failed"
18730 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
18731 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
18732 "character special file (null)"
18733 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
18734 "character special file (no device)"
18735 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
18736 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
18737 "block special file (loop)"
18738 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
18739 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
18740 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
18742 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
18745 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18746 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
18747 skip "Need MDS version at least 2.13.55"
18749 local submnt=/mnt/submnt
18750 local srcfile=/etc/passwd
18751 local dstfile=$submnt/passwd
18757 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
18758 error "create remote directory failed"
18759 mkdir -p $submnt || error "create $submnt failed"
18760 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
18761 error "mount $submnt failed"
18762 stack_trap "umount $submnt" EXIT
18764 cp $srcfile $dstfile
18765 fid=$($LFS path2fid $dstfile)
18766 path=$($LFS fid2path $submnt "$fid")
18767 [ "$path" = "$dstfile" ] ||
18768 error "fid2path $submnt $fid failed ($path != $dstfile)"
18770 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
18772 # LU-1299 Executing or running ldd on a truncated executable does not
18773 # cause an out-of-memory condition.
18775 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18776 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
18778 dd if=$(which date) of=$MOUNT/date bs=1k count=1
18779 chmod +x $MOUNT/date
18781 $MOUNT/date > /dev/null
18782 ldd $MOUNT/date > /dev/null
18785 run_test 227 "running truncated executable does not cause OOM"
18787 # LU-1512 try to reuse idle OI blocks
18789 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18790 remote_mds_nodsh && skip "remote MDS with nodsh"
18791 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
18793 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
18794 local myDIR=$DIR/$tdir
18797 #define OBD_FAIL_SEQ_EXHAUST 0x1002
18798 $LCTL set_param fail_loc=0x80001002
18799 createmany -o $myDIR/t- 10000
18800 $LCTL set_param fail_loc=0
18801 # The guard is current the largest FID holder
18803 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
18805 local IDX=$(($SEQ % 64))
18807 do_facet $SINGLEMDS sync
18808 # Make sure journal flushed.
18810 local blk1=$(do_facet $SINGLEMDS \
18811 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18812 grep Blockcount | awk '{print $4}')
18814 # Remove old files, some OI blocks will become idle.
18815 unlinkmany $myDIR/t- 10000
18816 # Create new files, idle OI blocks should be reused.
18817 createmany -o $myDIR/t- 2000
18818 do_facet $SINGLEMDS sync
18819 # Make sure journal flushed.
18821 local blk2=$(do_facet $SINGLEMDS \
18822 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18823 grep Blockcount | awk '{print $4}')
18825 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
18827 run_test 228a "try to reuse idle OI blocks"
18830 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18831 remote_mds_nodsh && skip "remote MDS with nodsh"
18832 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
18834 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
18835 local myDIR=$DIR/$tdir
18838 #define OBD_FAIL_SEQ_EXHAUST 0x1002
18839 $LCTL set_param fail_loc=0x80001002
18840 createmany -o $myDIR/t- 10000
18841 $LCTL set_param fail_loc=0
18842 # The guard is current the largest FID holder
18844 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
18846 local IDX=$(($SEQ % 64))
18848 do_facet $SINGLEMDS sync
18849 # Make sure journal flushed.
18851 local blk1=$(do_facet $SINGLEMDS \
18852 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18853 grep Blockcount | awk '{print $4}')
18855 # Remove old files, some OI blocks will become idle.
18856 unlinkmany $myDIR/t- 10000
18859 stop $SINGLEMDS || error "Fail to stop MDT."
18861 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
18863 df $MOUNT || error "Fail to df."
18864 # Create new files, idle OI blocks should be reused.
18865 createmany -o $myDIR/t- 2000
18866 do_facet $SINGLEMDS sync
18867 # Make sure journal flushed.
18869 local blk2=$(do_facet $SINGLEMDS \
18870 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18871 grep Blockcount | awk '{print $4}')
18873 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
18875 run_test 228b "idle OI blocks can be reused after MDT restart"
18879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18880 remote_mds_nodsh && skip "remote MDS with nodsh"
18881 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
18883 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
18884 local myDIR=$DIR/$tdir
18887 #define OBD_FAIL_SEQ_EXHAUST 0x1002
18888 $LCTL set_param fail_loc=0x80001002
18889 # 20000 files can guarantee there are index nodes in the OI file
18890 createmany -o $myDIR/t- 20000
18891 $LCTL set_param fail_loc=0
18892 # The guard is current the largest FID holder
18894 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
18896 local IDX=$(($SEQ % 64))
18898 do_facet $SINGLEMDS sync
18899 # Make sure journal flushed.
18901 local blk1=$(do_facet $SINGLEMDS \
18902 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18903 grep Blockcount | awk '{print $4}')
18905 # Remove old files, some OI blocks will become idle.
18906 unlinkmany $myDIR/t- 20000
18908 # The OI file should become empty now
18910 # Create new files, idle OI blocks should be reused.
18911 createmany -o $myDIR/t- 2000
18912 do_facet $SINGLEMDS sync
18913 # Make sure journal flushed.
18915 local blk2=$(do_facet $SINGLEMDS \
18916 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
18917 grep Blockcount | awk '{print $4}')
18919 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
18921 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
18923 test_229() { # LU-2482, LU-3448
18924 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18925 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
18926 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
18927 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
18931 # Create a file with a released layout and stripe count 2.
18932 $MULTIOP $DIR/$tfile H2c ||
18933 error "failed to create file with released layout"
18935 $LFS getstripe -v $DIR/$tfile
18937 local pattern=$($LFS getstripe -L $DIR/$tfile)
18938 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
18940 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
18942 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
18943 stat $DIR/$tfile || error "failed to stat released file"
18945 chown $RUNAS_ID $DIR/$tfile ||
18946 error "chown $RUNAS_ID $DIR/$tfile failed"
18948 chgrp $RUNAS_ID $DIR/$tfile ||
18949 error "chgrp $RUNAS_ID $DIR/$tfile failed"
18951 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
18952 rm $DIR/$tfile || error "failed to remove released file"
18954 run_test 229 "getstripe/stat/rm/attr changes work on released files"
18957 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18958 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18959 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
18960 skip "Need MDS version at least 2.11.52"
18964 test_mkdir $DIR/$tdir
18965 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
18966 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
18967 [ $mdt_idx -ne 0 ] &&
18968 error "create local directory on wrong MDT $mdt_idx"
18970 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
18971 error "create remote directory failed"
18972 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
18973 [ $mdt_idx -ne $MDTIDX ] &&
18974 error "create remote directory on wrong MDT $mdt_idx"
18976 createmany -o $DIR/$tdir/test_230/t- 10 ||
18977 error "create files on remote directory failed"
18978 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
18979 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
18980 rm -r $DIR/$tdir || error "unlink remote directory failed"
18982 run_test 230a "Create remote directory and files under the remote directory"
18985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18986 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18987 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
18988 skip "Need MDS version at least 2.11.52"
18996 local migrate_dir=$DIR/$tdir/migrate_dir
18997 local other_dir=$DIR/$tdir/other_dir
18999 test_mkdir $DIR/$tdir
19000 test_mkdir -i0 -c1 $migrate_dir
19001 test_mkdir -i0 -c1 $other_dir
19002 for ((i=0; i<10; i++)); do
19003 mkdir -p $migrate_dir/dir_${i}
19004 createmany -o $migrate_dir/dir_${i}/f 10 ||
19005 error "create files under remote dir failed $i"
19008 cp /etc/passwd $migrate_dir/$tfile
19009 cp /etc/passwd $other_dir/$tfile
19010 chattr +SAD $migrate_dir
19011 chattr +SAD $migrate_dir/$tfile
19013 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19014 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19015 local old_dir_mode=$(stat -c%f $migrate_dir)
19016 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
19018 mkdir -p $migrate_dir/dir_default_stripe2
19019 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
19020 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
19022 mkdir -p $other_dir
19023 ln $migrate_dir/$tfile $other_dir/luna
19024 ln $migrate_dir/$tfile $migrate_dir/sofia
19025 ln $other_dir/$tfile $migrate_dir/david
19026 ln -s $migrate_dir/$tfile $other_dir/zachary
19027 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
19028 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
19034 for len in 58 59 60; do
19035 lnktgt=$(str_repeat 'l' $len)
19036 touch $migrate_dir/$lnktgt
19037 ln -s $lnktgt $migrate_dir/${len}char_ln
19041 for len in 4094 4095; do
19042 lnktgt=$(str_repeat 'l' $len)
19043 ln -s $lnktgt $migrate_dir/${len}char_ln
19047 for len in 254 255; do
19048 touch $migrate_dir/$(str_repeat 'l' $len)
19051 $LFS migrate -m $MDTIDX $migrate_dir ||
19052 error "fails on migrating remote dir to MDT1"
19054 echo "migratate to MDT1, then checking.."
19055 for ((i = 0; i < 10; i++)); do
19056 for file in $(find $migrate_dir/dir_${i}); do
19057 mdt_index=$($LFS getstripe -m $file)
19058 # broken symlink getstripe will fail
19059 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
19060 error "$file is not on MDT${MDTIDX}"
19064 # the multiple link file should still in MDT0
19065 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
19066 [ $mdt_index == 0 ] ||
19067 error "$file is not on MDT${MDTIDX}"
19069 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19070 [ "$old_dir_flag" = "$new_dir_flag" ] ||
19071 error " expect $old_dir_flag get $new_dir_flag"
19073 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19074 [ "$old_file_flag" = "$new_file_flag" ] ||
19075 error " expect $old_file_flag get $new_file_flag"
19077 local new_dir_mode=$(stat -c%f $migrate_dir)
19078 [ "$old_dir_mode" = "$new_dir_mode" ] ||
19079 error "expect mode $old_dir_mode get $new_dir_mode"
19081 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
19082 [ "$old_file_mode" = "$new_file_mode" ] ||
19083 error "expect mode $old_file_mode get $new_file_mode"
19085 diff /etc/passwd $migrate_dir/$tfile ||
19086 error "$tfile different after migration"
19088 diff /etc/passwd $other_dir/luna ||
19089 error "luna different after migration"
19091 diff /etc/passwd $migrate_dir/sofia ||
19092 error "sofia different after migration"
19094 diff /etc/passwd $migrate_dir/david ||
19095 error "david different after migration"
19097 diff /etc/passwd $other_dir/zachary ||
19098 error "zachary different after migration"
19100 diff /etc/passwd $migrate_dir/${tfile}_ln ||
19101 error "${tfile}_ln different after migration"
19103 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
19104 error "${tfile}_ln_other different after migration"
19106 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
19107 [ $stripe_count = 2 ] ||
19108 error "dir strpe_count $d != 2 after migration."
19110 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
19111 [ $stripe_count = 2 ] ||
19112 error "file strpe_count $d != 2 after migration."
19114 #migrate back to MDT0
19117 $LFS migrate -m $MDTIDX $migrate_dir ||
19118 error "fails on migrating remote dir to MDT0"
19120 echo "migrate back to MDT0, checking.."
19121 for file in $(find $migrate_dir); do
19122 mdt_index=$($LFS getstripe -m $file)
19123 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
19124 error "$file is not on MDT${MDTIDX}"
19127 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19128 [ "$old_dir_flag" = "$new_dir_flag" ] ||
19129 error " expect $old_dir_flag get $new_dir_flag"
19131 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19132 [ "$old_file_flag" = "$new_file_flag" ] ||
19133 error " expect $old_file_flag get $new_file_flag"
19135 local new_dir_mode=$(stat -c%f $migrate_dir)
19136 [ "$old_dir_mode" = "$new_dir_mode" ] ||
19137 error "expect mode $old_dir_mode get $new_dir_mode"
19139 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
19140 [ "$old_file_mode" = "$new_file_mode" ] ||
19141 error "expect mode $old_file_mode get $new_file_mode"
19143 diff /etc/passwd ${migrate_dir}/$tfile ||
19144 error "$tfile different after migration"
19146 diff /etc/passwd ${other_dir}/luna ||
19147 error "luna different after migration"
19149 diff /etc/passwd ${migrate_dir}/sofia ||
19150 error "sofia different after migration"
19152 diff /etc/passwd ${other_dir}/zachary ||
19153 error "zachary different after migration"
19155 diff /etc/passwd $migrate_dir/${tfile}_ln ||
19156 error "${tfile}_ln different after migration"
19158 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
19159 error "${tfile}_ln_other different after migration"
19161 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
19162 [ $stripe_count = 2 ] ||
19163 error "dir strpe_count $d != 2 after migration."
19165 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
19166 [ $stripe_count = 2 ] ||
19167 error "file strpe_count $d != 2 after migration."
19169 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19171 run_test 230b "migrate directory"
19174 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19175 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19176 remote_mds_nodsh && skip "remote MDS with nodsh"
19177 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19178 skip "Need MDS version at least 2.11.52"
19184 local migrate_dir=$DIR/$tdir/migrate_dir
19186 #If migrating directory fails in the middle, all entries of
19187 #the directory is still accessiable.
19188 test_mkdir $DIR/$tdir
19189 test_mkdir -i0 -c1 $migrate_dir
19190 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
19192 createmany -o $migrate_dir/f $total ||
19193 error "create files under ${migrate_dir} failed"
19195 # fail after migrating top dir, and this will fail only once, so the
19196 # first sub file migration will fail (currently f3), others succeed.
19197 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
19198 do_facet mds1 lctl set_param fail_loc=0x1801
19199 local t=$(ls $migrate_dir | wc -l)
19200 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
19201 error "migrate should fail"
19202 local u=$(ls $migrate_dir | wc -l)
19203 [ "$u" == "$t" ] || error "$u != $t during migration"
19205 # add new dir/file should succeed
19206 mkdir $migrate_dir/dir ||
19207 error "mkdir failed under migrating directory"
19208 touch $migrate_dir/file ||
19209 error "create file failed under migrating directory"
19211 # add file with existing name should fail
19212 for file in $migrate_dir/f*; do
19213 stat $file > /dev/null || error "stat $file failed"
19214 $OPENFILE -f O_CREAT:O_EXCL $file &&
19215 error "open(O_CREAT|O_EXCL) $file should fail"
19216 $MULTIOP $file m && error "create $file should fail"
19217 touch $DIR/$tdir/remote_dir/$tfile ||
19218 error "touch $tfile failed"
19219 ln $DIR/$tdir/remote_dir/$tfile $file &&
19220 error "link $file should fail"
19221 mdt_index=$($LFS getstripe -m $file)
19222 if [ $mdt_index == 0 ]; then
19223 # file failed to migrate is not allowed to rename to
19224 mv $DIR/$tdir/remote_dir/$tfile $file &&
19225 error "rename to $file should fail"
19227 mv $DIR/$tdir/remote_dir/$tfile $file ||
19228 error "rename to $file failed"
19230 echo hello >> $file || error "write $file failed"
19233 # resume migration with different options should fail
19234 $LFS migrate -m 0 $migrate_dir &&
19235 error "migrate -m 0 $migrate_dir should fail"
19237 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
19238 error "migrate -c 2 $migrate_dir should fail"
19240 # resume migration should succeed
19241 $LFS migrate -m $MDTIDX $migrate_dir ||
19242 error "migrate $migrate_dir failed"
19244 echo "Finish migration, then checking.."
19245 for file in $(find $migrate_dir); do
19246 mdt_index=$($LFS getstripe -m $file)
19247 [ $mdt_index == $MDTIDX ] ||
19248 error "$file is not on MDT${MDTIDX}"
19251 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19253 run_test 230c "check directory accessiblity if migration failed"
19256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19257 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19258 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19259 skip "Need MDS version at least 2.11.52"
19261 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
19263 local migrate_dir=$DIR/$tdir/migrate_dir
19273 old_index=$((RANDOM % MDSCOUNT))
19274 old_count=$((MDSCOUNT - old_index))
19275 new_index=$((RANDOM % MDSCOUNT))
19276 new_count=$((MDSCOUNT - new_index))
19277 new_hash=1 # for all_char
19279 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
19280 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
19282 test_mkdir $DIR/$tdir
19283 test_mkdir -i $old_index -c $old_count $migrate_dir
19285 for ((i=0; i<100; i++)); do
19286 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
19287 createmany -o $migrate_dir/dir_${i}/f 100 ||
19288 error "create files under remote dir failed $i"
19291 echo -n "Migrate from MDT$old_index "
19292 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
19293 echo -n "to MDT$new_index"
19294 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
19297 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
19298 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
19299 error "migrate remote dir error"
19301 echo "Finish migration, then checking.."
19302 for file in $(find $migrate_dir); do
19303 mdt_index=$($LFS getstripe -m $file)
19304 if [ $mdt_index -lt $new_index ] ||
19305 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
19306 error "$file is on MDT$mdt_index"
19310 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19312 run_test 230d "check migrate big directory"
19315 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19316 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19317 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19318 skip "Need MDS version at least 2.11.52"
19325 mkdir_on_mdt0 $DIR/$tdir
19326 mkdir $DIR/$tdir/migrate_dir
19327 mkdir $DIR/$tdir/other_dir
19328 touch $DIR/$tdir/migrate_dir/a
19329 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
19330 ls $DIR/$tdir/other_dir
19332 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
19333 error "migrate dir fails"
19335 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
19336 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
19338 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19339 [ $mdt_index == 0 ] || error "a is not on MDT0"
19341 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
19342 error "migrate dir fails"
19344 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
19345 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
19347 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19348 [ $mdt_index == 1 ] || error "a is not on MDT1"
19350 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
19351 [ $mdt_index == 1 ] || error "b is not on MDT1"
19353 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
19354 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
19356 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
19358 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19360 run_test 230e "migrate mulitple local link files"
19363 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19364 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19365 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19366 skip "Need MDS version at least 2.11.52"
19371 mkdir -p $DIR/$tdir
19372 mkdir $DIR/$tdir/migrate_dir
19373 $LFS mkdir -i1 $DIR/$tdir/other_dir
19374 touch $DIR/$tdir/migrate_dir/a
19375 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
19376 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
19377 ls $DIR/$tdir/other_dir
19379 # a should be migrated to MDT1, since no other links on MDT0
19380 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
19381 error "#1 migrate dir fails"
19382 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
19383 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
19384 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19385 [ $mdt_index == 1 ] || error "a is not on MDT1"
19387 # a should stay on MDT1, because it is a mulitple link file
19388 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
19389 error "#2 migrate dir fails"
19390 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19391 [ $mdt_index == 1 ] || error "a is not on MDT1"
19393 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
19394 error "#3 migrate dir fails"
19396 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
19397 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
19398 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
19400 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
19401 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
19403 # a should be migrated to MDT0, since no other links on MDT1
19404 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
19405 error "#4 migrate dir fails"
19406 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19407 [ $mdt_index == 0 ] || error "a is not on MDT0"
19409 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19411 run_test 230f "migrate mulitple remote link files"
19414 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19415 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19416 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19417 skip "Need MDS version at least 2.11.52"
19419 mkdir -p $DIR/$tdir/migrate_dir
19421 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
19422 error "migrating dir to non-exist MDT succeeds"
19425 run_test 230g "migrate dir to non-exist MDT"
19428 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19429 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19430 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19431 skip "Need MDS version at least 2.11.52"
19435 mkdir -p $DIR/$tdir/migrate_dir
19437 $LFS migrate -m1 $DIR &&
19438 error "migrating mountpoint1 should fail"
19440 $LFS migrate -m1 $DIR/$tdir/.. &&
19441 error "migrating mountpoint2 should fail"
19444 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
19445 error "migrating $tdir/migrate_dir/.. should fail"
19449 run_test 230h "migrate .. and root"
19452 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19453 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19454 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19455 skip "Need MDS version at least 2.11.52"
19457 mkdir -p $DIR/$tdir/migrate_dir
19459 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
19460 error "migration fails with a tailing slash"
19462 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
19463 error "migration fails with two tailing slashes"
19465 run_test 230i "lfs migrate -m tolerates trailing slashes"
19468 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19469 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
19470 skip "Need MDS version at least 2.11.52"
19472 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
19473 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
19474 error "create $tfile failed"
19475 cat /etc/passwd > $DIR/$tdir/$tfile
19477 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
19479 cmp /etc/passwd $DIR/$tdir/$tfile ||
19480 error "DoM file mismatch after migration"
19482 run_test 230j "DoM file data not changed after dir migration"
19485 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
19486 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
19487 skip "Need MDS version at least 2.11.56"
19490 local files_on_starting_mdt=0
19492 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
19493 $LFS getdirstripe $DIR/$tdir
19494 for i in $(seq $total); do
19495 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
19496 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
19497 files_on_starting_mdt=$((files_on_starting_mdt + 1))
19500 echo "$files_on_starting_mdt files on MDT0"
19502 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
19503 $LFS getdirstripe $DIR/$tdir
19505 files_on_starting_mdt=0
19506 for i in $(seq $total); do
19507 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
19508 error "file $tfile.$i mismatch after migration"
19509 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
19510 files_on_starting_mdt=$((files_on_starting_mdt + 1))
19513 echo "$files_on_starting_mdt files on MDT1 after migration"
19514 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
19516 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
19517 $LFS getdirstripe $DIR/$tdir
19519 files_on_starting_mdt=0
19520 for i in $(seq $total); do
19521 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
19522 error "file $tfile.$i mismatch after 2nd migration"
19523 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
19524 files_on_starting_mdt=$((files_on_starting_mdt + 1))
19527 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
19528 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
19532 run_test 230k "file data not changed after dir migration"
19535 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19536 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
19537 skip "Need MDS version at least 2.11.56"
19539 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
19540 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
19541 error "create files under remote dir failed $i"
19542 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
19544 run_test 230l "readdir between MDTs won't crash"
19547 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19548 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
19549 skip "Need MDS version at least 2.11.56"
19552 local mig_dir=$DIR/$tdir/migrate_dir
19553 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
19557 echo "Creating files and dirs with xattrs"
19558 test_mkdir $DIR/$tdir
19559 test_mkdir -i0 -c1 $mig_dir
19561 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
19562 error "cannot set xattr attr1 on dir"
19563 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
19564 error "cannot set xattr attr2 on dir"
19565 touch $mig_dir/dir/f0
19566 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
19567 error "cannot set xattr attr1 on file"
19568 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
19569 error "cannot set xattr attr2 on file"
19570 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
19571 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
19572 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
19573 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
19574 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
19575 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
19576 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
19577 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
19578 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
19580 echo "Migrating to MDT1"
19581 $LFS migrate -m $MDTIDX $mig_dir ||
19582 error "fails on migrating dir to MDT1"
19584 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
19585 echo "Checking xattrs"
19586 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
19587 [ "$val" = $longstr ] ||
19588 error "expecting xattr1 $longstr on dir, found $val"
19589 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
19590 [ "$val" = $shortstr ] ||
19591 error "expecting xattr2 $shortstr on dir, found $val"
19592 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
19593 [ "$val" = $longstr ] ||
19594 error "expecting xattr1 $longstr on file, found $val"
19595 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
19596 [ "$val" = $shortstr ] ||
19597 error "expecting xattr2 $shortstr on file, found $val"
19599 run_test 230m "xattrs not changed after dir migration"
19602 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19603 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
19604 skip "Need MDS version at least 2.13.53"
19606 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
19607 cat /etc/hosts > $DIR/$tdir/$tfile
19608 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
19609 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
19611 cmp /etc/hosts $DIR/$tdir/$tfile ||
19612 error "File data mismatch after migration"
19614 run_test 230n "Dir migration with mirrored file"
19617 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
19618 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
19619 skip "Need MDS version at least 2.13.52"
19621 local mdts=$(comma_list $(mdts_nodes))
19623 local restripe_status
19627 [[ $mds1_FSTYPE == zfs ]] && timeout=300
19629 # in case "crush" hash type is not set
19630 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
19632 restripe_status=$(do_facet mds1 $LCTL get_param -n \
19633 mdt.*MDT0000.enable_dir_restripe)
19634 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
19635 stack_trap "do_nodes $mdts $LCTL set_param \
19636 mdt.*.enable_dir_restripe=$restripe_status"
19639 createmany -m $DIR/$tdir/f 100 ||
19640 error "create files under remote dir failed $i"
19641 createmany -d $DIR/$tdir/d 100 ||
19642 error "create dirs under remote dir failed $i"
19644 for i in $(seq 2 $MDSCOUNT); do
19645 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
19646 $LFS setdirstripe -c $i $DIR/$tdir ||
19647 error "split -c $i $tdir failed"
19648 wait_update $HOSTNAME \
19649 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
19650 error "dir split not finished"
19651 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
19652 awk '/migrate/ {sum += $2} END { print sum }')
19653 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
19654 # delta is around total_files/stripe_count
19655 (( $delta < 200 / (i - 1) + 4 )) ||
19656 error "$delta files migrated >= $((200 / (i - 1) + 4))"
19659 run_test 230o "dir split"
19662 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
19663 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
19664 skip "Need MDS version at least 2.13.52"
19666 local mdts=$(comma_list $(mdts_nodes))
19668 local restripe_status
19672 [[ $mds1_FSTYPE == zfs ]] && timeout=300
19674 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
19676 restripe_status=$(do_facet mds1 $LCTL get_param -n \
19677 mdt.*MDT0000.enable_dir_restripe)
19678 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
19679 stack_trap "do_nodes $mdts $LCTL set_param \
19680 mdt.*.enable_dir_restripe=$restripe_status"
19682 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
19683 createmany -m $DIR/$tdir/f 100 ||
19684 error "create files under remote dir failed"
19685 createmany -d $DIR/$tdir/d 100 ||
19686 error "create dirs under remote dir failed"
19688 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
19689 local mdt_hash="crush"
19691 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
19692 $LFS setdirstripe -c $c $DIR/$tdir ||
19693 error "split -c $c $tdir failed"
19694 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
19695 mdt_hash="$mdt_hash,fixed"
19696 elif [ $c -eq 1 ]; then
19699 wait_update $HOSTNAME \
19700 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
19701 error "dir merge not finished"
19702 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
19703 awk '/migrate/ {sum += $2} END { print sum }')
19704 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
19705 # delta is around total_files/stripe_count
19706 (( delta < 200 / c + 4 )) ||
19707 error "$delta files migrated >= $((200 / c + 4))"
19710 run_test 230p "dir merge"
19713 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
19714 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
19715 skip "Need MDS version at least 2.13.52"
19717 local mdts=$(comma_list $(mdts_nodes))
19718 local saved_threshold=$(do_facet mds1 \
19719 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
19720 local saved_delta=$(do_facet mds1 \
19721 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
19722 local threshold=100
19725 local stripe_count=0
19730 # test with fewer files on ZFS
19731 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
19733 stack_trap "do_nodes $mdts $LCTL set_param \
19734 mdt.*.dir_split_count=$saved_threshold"
19735 stack_trap "do_nodes $mdts $LCTL set_param \
19736 mdt.*.dir_split_delta=$saved_delta"
19737 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
19738 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
19739 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
19740 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
19741 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
19742 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
19744 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
19745 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
19747 create=$((threshold * 3 / 2))
19748 while [ $stripe_count -lt $MDSCOUNT ]; do
19749 createmany -m $DIR/$tdir/f $total $create ||
19750 error "create sub files failed"
19751 stat $DIR/$tdir > /dev/null
19752 total=$((total + create))
19753 stripe_count=$((stripe_count + delta))
19754 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
19756 wait_update $HOSTNAME \
19757 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
19758 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
19760 wait_update $HOSTNAME \
19761 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
19762 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
19764 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
19765 echo "$nr_files/$total files on MDT$stripe_index after split"
19766 # allow 10% margin of imbalance with crush hash
19767 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
19768 error "$nr_files files on MDT$stripe_index after split"
19770 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
19771 [ $nr_files -eq $total ] ||
19772 error "total sub files $nr_files != $total"
19775 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
19777 echo "fixed layout directory won't auto split"
19778 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
19779 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
19780 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
19781 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
19782 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
19784 run_test 230q "dir auto split"
19787 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
19788 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
19789 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
19790 skip "Need MDS version at least 2.13.54"
19792 # maximum amount of local locks:
19793 # parent striped dir - 2 locks
19794 # new stripe in parent to migrate to - 1 lock
19795 # source and target - 2 locks
19796 # Total 5 locks for regular file
19797 mkdir -p $DIR/$tdir
19798 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
19799 touch $DIR/$tdir/dir1/eee
19801 # create 4 hardlink for 4 more locks
19802 # Total: 9 locks > RS_MAX_LOCKS (8)
19803 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
19804 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
19805 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
19806 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
19807 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
19808 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
19809 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
19810 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
19812 cancel_lru_locks mdc
19814 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
19815 error "migrate dir fails"
19817 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19819 run_test 230r "migrate with too many local locks"
19822 [ $MDS1_VERSION -ge $(version_code 2.13.57) ] ||
19823 skip "Need MDS version at least 2.13.57"
19825 local mdts=$(comma_list $(mdts_nodes))
19826 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
19827 mdt.*MDT0000.enable_dir_restripe)
19829 stack_trap "do_nodes $mdts $LCTL set_param \
19830 mdt.*.enable_dir_restripe=$restripe_status"
19834 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
19835 test_mkdir $DIR/$tdir
19836 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
19837 error "$LFS mkdir doesn't return -EEXIST if target exists"
19841 run_test 230s "lfs mkdir should return -EEXIST if target exists"
19845 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
19846 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
19847 skip "Need MDS version at least 2.14.50"
19849 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
19850 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
19851 $LFS project -p 1 -s $DIR/$tdir ||
19852 error "set $tdir project id failed"
19853 $LFS project -p 2 -s $DIR/$tdir/subdir ||
19854 error "set subdir project id failed"
19855 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
19857 run_test 230t "migrate directory with project ID set"
19861 # For simplicity this test assumes that max_pages_per_rpc
19862 # is the same across all OSCs
19863 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
19864 local bulk_size=$((max_pages * PAGE_SIZE))
19865 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
19868 mkdir -p $DIR/$tdir
19869 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
19870 error "failed to set stripe with -S ${brw_size}M option"
19872 # clear the OSC stats
19873 $LCTL set_param osc.*.stats=0 &>/dev/null
19876 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
19877 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
19878 oflag=direct &>/dev/null || error "dd failed"
19880 sync; sleep 1; sync # just to be safe
19881 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
19882 if [ x$nrpcs != "x1" ]; then
19883 $LCTL get_param osc.*.stats
19884 error "found $nrpcs ost_write RPCs, not 1 as expected"
19888 # Drop the OSC cache, otherwise we will read from it
19889 cancel_lru_locks osc
19891 # clear the OSC stats
19892 $LCTL set_param osc.*.stats=0 &>/dev/null
19894 # Client reads $bulk_size.
19895 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
19896 iflag=direct &>/dev/null || error "dd failed"
19898 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
19899 if [ x$nrpcs != "x1" ]; then
19900 $LCTL get_param osc.*.stats
19901 error "found $nrpcs ost_read RPCs, not 1 as expected"
19904 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
19907 mkdir -p $DIR/$tdir
19909 for i in {0..1023}; do
19910 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
19911 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
19912 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
19916 run_test 231b "must not assert on fully utilized OST request buffer"
19919 mkdir -p $DIR/$tdir
19920 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
19922 #define OBD_FAIL_LDLM_OST_LVB 0x31c
19923 do_facet ost1 $LCTL set_param fail_loc=0x31c
19925 # ignore dd failure
19926 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
19928 do_facet ost1 $LCTL set_param fail_loc=0
19929 umount_client $MOUNT || error "umount failed"
19930 mount_client $MOUNT || error "mount failed"
19931 stop ost1 || error "cannot stop ost1"
19932 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
19934 run_test 232a "failed lock should not block umount"
19937 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
19938 skip "Need MDS version at least 2.10.58"
19940 mkdir -p $DIR/$tdir
19941 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
19942 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
19944 cancel_lru_locks osc
19946 #define OBD_FAIL_LDLM_OST_LVB 0x31c
19947 do_facet ost1 $LCTL set_param fail_loc=0x31c
19950 $LFS data_version $DIR/$tdir/$tfile || true
19952 do_facet ost1 $LCTL set_param fail_loc=0
19953 umount_client $MOUNT || error "umount failed"
19954 mount_client $MOUNT || error "mount failed"
19955 stop ost1 || error "cannot stop ost1"
19956 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
19958 run_test 232b "failed data version lock should not block umount"
19961 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
19962 skip "Need MDS version at least 2.3.64"
19963 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
19965 local fid=$($LFS path2fid $MOUNT)
19967 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
19968 error "cannot access $MOUNT using its FID '$fid'"
19970 run_test 233a "checking that OBF of the FS root succeeds"
19973 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
19974 skip "Need MDS version at least 2.5.90"
19975 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
19977 local fid=$($LFS path2fid $MOUNT/.lustre)
19979 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
19980 error "cannot access $MOUNT/.lustre using its FID '$fid'"
19982 fid=$($LFS path2fid $MOUNT/.lustre/fid)
19983 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
19984 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
19986 run_test 233b "checking that OBF of the FS .lustre succeeds"
19989 local p="$TMP/sanityN-$TESTNAME.parameters"
19990 save_lustre_params client "llite.*.xattr_cache" > $p
19991 lctl set_param llite.*.xattr_cache 1 ||
19992 skip_env "xattr cache is not supported"
19994 mkdir -p $DIR/$tdir || error "mkdir failed"
19995 touch $DIR/$tdir/$tfile || error "touch failed"
19996 # OBD_FAIL_LLITE_XATTR_ENOMEM
19997 $LCTL set_param fail_loc=0x1405
19998 getfattr -n user.attr $DIR/$tdir/$tfile &&
19999 error "getfattr should have failed with ENOMEM"
20000 $LCTL set_param fail_loc=0x0
20003 restore_lustre_params < $p
20006 run_test 234 "xattr cache should not crash on ENOMEM"
20009 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
20010 skip "Need MDS version at least 2.4.52"
20012 flock_deadlock $DIR/$tfile
20017 124) error "process hangs on a deadlock"
20019 *) error "error executing flock_deadlock $DIR/$tfile"
20023 run_test 235 "LU-1715: flock deadlock detection does not work properly"
20027 check_swap_layouts_support
20029 local ref1=/etc/passwd
20030 local ref2=/etc/group
20031 local file1=$DIR/$tdir/f1
20032 local file2=$DIR/$tdir/f2
20034 test_mkdir -c1 $DIR/$tdir
20035 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
20036 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
20037 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
20038 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
20039 local fd=$(free_fd)
20040 local cmd="exec $fd<>$file2"
20043 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
20044 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
20047 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
20052 run_test 236 "Layout swap on open unlinked file"
20054 # LU-4659 linkea consistency
20056 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
20057 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
20058 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
20059 skip "Need MDS version at least 2.5.58 or 2.5.2+"
20062 ln $DIR/$tfile $DIR/$tfile.lnk
20063 touch $DIR/$tfile.new
20064 mv $DIR/$tfile.new $DIR/$tfile
20065 local fid1=$($LFS path2fid $DIR/$tfile)
20066 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
20067 local path1=$($LFS fid2path $FSNAME "$fid1")
20068 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
20069 local path2=$($LFS fid2path $FSNAME "$fid2")
20070 [ $tfile.lnk == $path2 ] ||
20071 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
20074 run_test 238 "Verify linkea consistency"
20076 test_239A() { # was test_239
20077 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
20078 skip "Need MDS version at least 2.5.60"
20080 local list=$(comma_list $(mdts_nodes))
20082 mkdir -p $DIR/$tdir
20083 createmany -o $DIR/$tdir/f- 5000
20084 unlinkmany $DIR/$tdir/f- 5000
20085 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
20086 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
20087 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
20088 osp.*MDT*.sync_in_flight" | calc_sum)
20089 [ "$changes" -eq 0 ] || error "$changes not synced"
20091 run_test 239A "osp_sync test"
20093 test_239a() { #LU-5297
20094 remote_mds_nodsh && skip "remote MDS with nodsh"
20097 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
20098 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
20099 chgrp $RUNAS_GID $DIR/$tfile
20100 wait_delete_completed
20102 run_test 239a "process invalid osp sync record correctly"
20104 test_239b() { #LU-5297
20105 remote_mds_nodsh && skip "remote MDS with nodsh"
20108 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
20109 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
20110 chgrp $RUNAS_GID $DIR/$tfile1
20111 wait_delete_completed
20112 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
20114 chgrp $RUNAS_GID $DIR/$tfile2
20115 wait_delete_completed
20117 run_test 239b "process osp sync record with ENOMEM error correctly"
20120 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20121 remote_mds_nodsh && skip "remote MDS with nodsh"
20123 mkdir -p $DIR/$tdir
20125 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
20126 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
20127 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
20128 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
20130 umount_client $MOUNT || error "umount failed"
20131 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
20132 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
20133 mount_client $MOUNT || error "failed to mount client"
20135 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
20136 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
20138 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
20144 for LOOP in $(seq $count); do
20145 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
20146 cancel_lru_locks $OSC || true
20154 for LOOP in $(seq $1); do
20155 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
20160 test_241a() { # was test_241
20161 local bsize=$PAGE_SIZE
20163 (( bsize < 40960 )) && bsize=40960
20164 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
20166 cancel_lru_locks $OSC
20167 test_241_bio 1000 $bsize &
20169 test_241_dio 1000 $bsize
20172 run_test 241a "bio vs dio"
20175 local bsize=$PAGE_SIZE
20177 (( bsize < 40960 )) && bsize=40960
20178 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
20180 test_241_dio 1000 $bsize &
20182 test_241_dio 1000 $bsize
20185 run_test 241b "dio vs dio"
20188 remote_mds_nodsh && skip "remote MDS with nodsh"
20190 mkdir_on_mdt0 $DIR/$tdir
20191 touch $DIR/$tdir/$tfile
20193 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
20194 do_facet mds1 lctl set_param fail_loc=0x105
20195 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
20197 do_facet mds1 lctl set_param fail_loc=0
20198 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
20200 run_test 242 "mdt_readpage failure should not cause directory unreadable"
20204 test_mkdir $DIR/$tdir
20205 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
20207 run_test 243 "various group lock tests"
20211 test_mkdir $DIR/$tdir
20212 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
20213 sendfile_grouplock $DIR/$tdir/$tfile || \
20214 error "sendfile+grouplock failed"
20217 run_test 244a "sendfile with group lock tests"
20221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
20224 local size=$((1024*1024))
20226 test_mkdir $DIR/$tdir
20227 for i in $(seq 1 $threads); do
20228 local file=$DIR/$tdir/file_$((i / 10))
20229 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
20232 for i in $(seq 1 $threads); do
20236 run_test 244b "multi-threaded write with group lock"
20239 local flagname="multi_mod_rpcs"
20240 local connect_data_name="max_mod_rpcs"
20243 # check if multiple modify RPCs flag is set
20244 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
20245 grep "connect_flags:")
20248 echo "$out" | grep -qw $flagname
20249 if [ $? -ne 0 ]; then
20250 echo "connect flag $flagname is not set"
20254 # check if multiple modify RPCs data is set
20255 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
20258 echo "$out" | grep -qw $connect_data_name ||
20259 error "import should have connect data $connect_data_name"
20261 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
20267 umount_client $submount
20272 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
20274 skip_env "Fileset feature is not supported"
20276 local submount=${MOUNT}_$tdir
20279 mkdir -p $submount || error "mkdir $submount failed"
20280 FILESET="$FILESET/$tdir" mount_client $submount ||
20281 error "mount $submount failed"
20282 trap "cleanup_247 $submount" EXIT
20283 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
20284 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
20285 error "read $MOUNT/$tdir/$tfile failed"
20286 cleanup_247 $submount
20288 run_test 247a "mount subdir as fileset"
20291 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
20292 skip_env "Fileset feature is not supported"
20294 local submount=${MOUNT}_$tdir
20296 rm -rf $MOUNT/$tdir
20297 mkdir -p $submount || error "mkdir $submount failed"
20299 FILESET="$FILESET/$tdir" mount_client $submount &&
20300 error "mount $submount should fail"
20303 run_test 247b "mount subdir that dose not exist"
20306 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
20307 skip_env "Fileset feature is not supported"
20309 local submount=${MOUNT}_$tdir
20311 mkdir -p $MOUNT/$tdir/dir1
20312 mkdir -p $submount || error "mkdir $submount failed"
20313 trap "cleanup_247 $submount" EXIT
20314 FILESET="$FILESET/$tdir" mount_client $submount ||
20315 error "mount $submount failed"
20316 local fid=$($LFS path2fid $MOUNT/)
20317 $LFS fid2path $submount $fid && error "fid2path should fail"
20318 cleanup_247 $submount
20320 run_test 247c "running fid2path outside subdirectory root"
20323 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
20324 skip "Fileset feature is not supported"
20326 local submount=${MOUNT}_$tdir
20328 mkdir -p $MOUNT/$tdir/dir1
20329 mkdir -p $submount || error "mkdir $submount failed"
20330 FILESET="$FILESET/$tdir" mount_client $submount ||
20331 error "mount $submount failed"
20332 trap "cleanup_247 $submount" EXIT
20334 local td=$submount/dir1
20335 local fid=$($LFS path2fid $td)
20336 [ -z "$fid" ] && error "path2fid unable to get $td FID"
20338 # check that we get the same pathname back
20341 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
20342 echo "$rootpath $fid"
20343 found=$($LFS fid2path $rootpath "$fid")
20344 [ -n "found" ] || error "fid2path should succeed"
20345 [ "$found" == "$td" ] || error "fid2path $found != $td"
20347 # check wrong root path format
20348 rootpath=$submount"_wrong"
20349 found=$($LFS fid2path $rootpath "$fid")
20350 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
20352 cleanup_247 $submount
20354 run_test 247d "running fid2path inside subdirectory root"
20358 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
20360 skip "Fileset feature is not supported"
20362 local submount=${MOUNT}_$tdir
20365 mkdir -p $submount || error "mkdir $submount failed"
20366 FILESET="$FILESET/.." mount_client $submount &&
20367 error "mount $submount should fail"
20370 run_test 247e "mount .. as fileset"
20373 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20374 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
20375 skip "Need at least version 2.13.52"
20376 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
20377 skip "Need at least version 2.14.50"
20378 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
20380 skip "Fileset feature is not supported"
20382 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
20383 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
20384 error "mkdir remote failed"
20385 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
20386 error "mkdir remote/subdir failed"
20387 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
20388 error "mkdir striped failed"
20389 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
20391 local submount=${MOUNT}_$tdir
20393 mkdir -p $submount || error "mkdir $submount failed"
20394 stack_trap "rmdir $submount"
20398 local fileset=$FILESET
20399 local mdts=$(comma_list $(mdts_nodes))
20401 stat=$(do_facet mds1 $LCTL get_param -n \
20402 mdt.*MDT0000.enable_remote_subdir_mount)
20403 stack_trap "do_nodes $mdts $LCTL set_param \
20404 mdt.*.enable_remote_subdir_mount=$stat"
20406 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
20407 stack_trap "umount_client $submount"
20408 FILESET="$fileset/$tdir/remote" mount_client $submount &&
20409 error "mount remote dir $dir should fail"
20411 for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
20412 $tdir/striped/. ; do
20413 FILESET="$fileset/$dir" mount_client $submount ||
20414 error "mount $dir failed"
20415 umount_client $submount
20418 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
20419 FILESET="$fileset/$tdir/remote" mount_client $submount ||
20420 error "mount $tdir/remote failed"
20422 run_test 247f "mount striped or remote directory as fileset"
20425 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
20426 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
20427 skip "Need at least version 2.14.50"
20429 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
20430 error "mkdir $tdir failed"
20431 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
20433 local submount=${MOUNT}_$tdir
20435 mkdir -p $submount || error "mkdir $submount failed"
20436 stack_trap "rmdir $submount"
20438 FILESET="$fileset/$tdir" mount_client $submount ||
20439 error "mount $dir failed"
20440 stack_trap "umount $submount"
20442 local mdts=$(comma_list $(mdts_nodes))
20446 stat $submount > /dev/null
20447 cancel_lru_locks $MDC
20448 stat $submount > /dev/null
20449 stat $submount/$tfile > /dev/null
20450 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
20451 stat $submount/$tfile > /dev/null
20452 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
20453 awk '/getattr/ {sum += $2} END {print sum}')
20455 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
20457 run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
20460 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
20461 [ -z "$fast_read_sav" ] && skip "no fast read support"
20463 # create a large file for fast read verification
20464 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
20466 # make sure the file is created correctly
20467 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
20468 { rm -f $DIR/$tfile; skip "file creation error"; }
20470 echo "Test 1: verify that fast read is 4 times faster on cache read"
20472 # small read with fast read enabled
20473 $LCTL set_param -n llite.*.fast_read=1
20474 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
20475 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20476 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20477 # small read with fast read disabled
20478 $LCTL set_param -n llite.*.fast_read=0
20479 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
20480 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20481 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20483 # verify that fast read is 4 times faster for cache read
20484 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
20485 error_not_in_vm "fast read was not 4 times faster: " \
20486 "$t_fast vs $t_slow"
20488 echo "Test 2: verify the performance between big and small read"
20489 $LCTL set_param -n llite.*.fast_read=1
20491 # 1k non-cache read
20492 cancel_lru_locks osc
20493 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
20494 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20495 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20497 # 1M non-cache read
20498 cancel_lru_locks osc
20499 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
20500 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20501 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20503 # verify that big IO is not 4 times faster than small IO
20504 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
20505 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
20507 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
20510 run_test 248a "fast read verification"
20513 # Default short_io_bytes=16384, try both smaller and larger sizes.
20514 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
20515 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
20516 echo "bs=53248 count=113 normal buffered write"
20517 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
20518 error "dd of initial data file failed"
20519 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
20521 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
20522 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
20523 error "dd with sync normal writes failed"
20524 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
20526 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
20527 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
20528 error "dd with sync small writes failed"
20529 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
20531 cancel_lru_locks osc
20533 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
20534 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
20535 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
20536 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
20537 iflag=direct || error "dd with O_DIRECT small read failed"
20538 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
20539 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
20540 error "compare $TMP/$tfile.1 failed"
20542 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
20543 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
20545 # just to see what the maximum tunable value is, and test parsing
20546 echo "test invalid parameter 2MB"
20547 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
20548 error "too-large short_io_bytes allowed"
20549 echo "test maximum parameter 512KB"
20550 # if we can set a larger short_io_bytes, run test regardless of version
20551 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
20552 # older clients may not allow setting it this large, that's OK
20553 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
20554 skip "Need at least client version 2.13.50"
20555 error "medium short_io_bytes failed"
20557 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
20558 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
20560 echo "test large parameter 64KB"
20561 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
20562 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
20564 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
20565 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
20566 error "dd with sync large writes failed"
20567 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
20569 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
20570 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
20571 num=$((113 * 4096 / PAGE_SIZE))
20572 echo "bs=$size count=$num oflag=direct large write $tfile.3"
20573 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
20574 error "dd with O_DIRECT large writes failed"
20575 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
20576 error "compare $DIR/$tfile.3 failed"
20578 cancel_lru_locks osc
20580 echo "bs=$size count=$num iflag=direct large read $tfile.2"
20581 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
20582 error "dd with O_DIRECT large read failed"
20583 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
20584 error "compare $TMP/$tfile.2 failed"
20586 echo "bs=$size count=$num iflag=direct large read $tfile.3"
20587 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
20588 error "dd with O_DIRECT large read failed"
20589 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
20590 error "compare $TMP/$tfile.3 failed"
20592 run_test 248b "test short_io read and write for both small and large sizes"
20594 test_249() { # LU-7890
20595 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
20596 skip "Need at least version 2.8.54"
20599 $LFS setstripe -c 1 $DIR/$tfile
20600 # Offset 2T == 4k * 512M
20601 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
20602 error "dd to 2T offset failed"
20604 run_test 249 "Write above 2T file size"
20607 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
20608 && skip "no 16TB file size limit on ZFS"
20610 $LFS setstripe -c 1 $DIR/$tfile
20611 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
20612 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
20613 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
20614 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
20615 conv=notrunc,fsync && error "append succeeded"
20618 run_test 250 "Write above 16T limit"
20621 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
20623 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
20624 #Skip once - writing the first stripe will succeed
20625 $LCTL set_param fail_loc=0xa0001407 fail_val=1
20626 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
20627 error "short write happened"
20629 $LCTL set_param fail_loc=0xa0001407 fail_val=1
20630 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
20631 error "short read happened"
20635 run_test 251 "Handling short read and write correctly"
20638 remote_mds_nodsh && skip "remote MDS with nodsh"
20639 remote_ost_nodsh && skip "remote OST with nodsh"
20640 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
20641 skip_env "ldiskfs only test"
20651 # check lr_reader on OST0000
20653 dev=$(facet_device $tgt)
20654 out=$(do_facet $tgt $LR_READER $dev)
20655 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
20657 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
20658 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
20659 error "Invalid uuid returned by $LR_READER on target $tgt"
20660 echo -e "uuid returned by $LR_READER is '$uuid'\n"
20662 # check lr_reader -c on MDT0000
20664 dev=$(facet_device $tgt)
20665 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
20666 skip "$LR_READER does not support additional options"
20668 out=$(do_facet $tgt $LR_READER -c $dev)
20669 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
20671 num=$(echo "$out" | grep -c "mdtlov")
20672 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
20673 error "Invalid number of mdtlov clients returned by $LR_READER"
20674 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
20676 # check lr_reader -cr on MDT0000
20677 out=$(do_facet $tgt $LR_READER -cr $dev)
20678 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
20680 echo "$out" | grep -q "^reply_data:$" ||
20681 error "$LR_READER should have returned 'reply_data' section"
20682 num=$(echo "$out" | grep -c "client_generation")
20683 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
20685 run_test 252 "check lr_reader tool"
20688 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20689 remote_mds_nodsh && skip "remote MDS with nodsh"
20690 remote_mgs_nodsh && skip "remote MGS with nodsh"
20694 local ost_name=$(ostname_from_index $ostidx)
20697 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
20698 do_facet $SINGLEMDS $LCTL get_param -n \
20699 osp.$mdtosc_proc1.reserved_mb_high ||
20700 skip "remote MDS does not support reserved_mb_high"
20704 wait_delete_completed
20707 pool_add $TESTNAME || error "Pool creation failed"
20708 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
20710 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
20711 error "Setstripe failed"
20713 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
20715 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
20717 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
20719 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
20720 osp.$mdtosc_proc1.prealloc_status)
20721 echo "prealloc_status $oa_status"
20723 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
20724 error "File creation should fail"
20726 #object allocation was stopped, but we still able to append files
20727 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
20728 oflag=append || error "Append failed"
20730 rm -f $DIR/$tdir/$tfile.0
20732 # For this test, we want to delete the files we created to go out of
20733 # space but leave the watermark, so we remain nearly out of space
20734 ost_watermarks_enospc_delete_files $tfile $ostidx
20736 wait_delete_completed
20740 for i in $(seq 10 12); do
20741 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
20742 2>/dev/null || error "File creation failed after rm"
20745 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
20746 osp.$mdtosc_proc1.prealloc_status)
20747 echo "prealloc_status $oa_status"
20749 if (( oa_status != 0 )); then
20750 error "Object allocation still disable after rm"
20753 run_test 253 "Check object allocation limit"
20756 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20757 remote_mds_nodsh && skip "remote MDS with nodsh"
20758 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
20759 skip "MDS does not support changelog_size"
20762 local MDT0=$(facet_svc $SINGLEMDS)
20764 changelog_register || error "changelog_register failed"
20766 changelog_clear 0 || error "changelog_clear failed"
20768 local size1=$(do_facet $SINGLEMDS \
20769 $LCTL get_param -n mdd.$MDT0.changelog_size)
20770 echo "Changelog size $size1"
20773 $LFS mkdir -i 0 $DIR/$tdir
20775 mkdir -p $DIR/$tdir/pics/2008/zachy
20776 touch $DIR/$tdir/pics/2008/zachy/timestamp
20777 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
20778 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
20779 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
20780 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
20781 rm $DIR/$tdir/pics/desktop.jpg
20783 local size2=$(do_facet $SINGLEMDS \
20784 $LCTL get_param -n mdd.$MDT0.changelog_size)
20785 echo "Changelog size after work $size2"
20787 (( $size2 > $size1 )) ||
20788 error "new Changelog size=$size2 less than old size=$size1"
20790 run_test 254 "Check changelog size"
20797 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
20798 awk -F: '{print $2}' | grep $type > /dev/null
20799 if [ $? -ne 0 ]; then
20809 lfs ladvise -a willread $file > /dev/null 2>&1
20810 if [ $? -eq 0 ]; then
20814 lfs ladvise -a willread $file 2>&1 |
20815 grep "Inappropriate ioctl for device" > /dev/null
20816 if [ $? -eq 0 ]; then
20823 bc <<<"scale=2; ($1 - $2) * 100 / $2"
20826 # run a random read IO workload
20827 # usage: random_read_iops <filename> <filesize> <iosize>
20828 random_read_iops() {
20831 local iosize=${3:-4096}
20833 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
20834 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
20837 drop_file_oss_cache() {
20841 $LFS ladvise -a dontneed $file 2>/dev/null ||
20842 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
20845 ladvise_willread_performance()
20848 local average_origin=0
20849 local average_cache=0
20850 local average_ladvise=0
20852 for ((i = 1; i <= $repeat; i++)); do
20853 echo "Iter $i/$repeat: reading without willread hint"
20854 cancel_lru_locks osc
20855 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
20856 local speed_origin=$(random_read_iops $DIR/$tfile $size)
20857 echo "Iter $i/$repeat: uncached speed: $speed_origin"
20858 average_origin=$(bc <<<"$average_origin + $speed_origin")
20860 cancel_lru_locks osc
20861 local speed_cache=$(random_read_iops $DIR/$tfile $size)
20862 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
20863 average_cache=$(bc <<<"$average_cache + $speed_cache")
20865 cancel_lru_locks osc
20866 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
20867 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
20868 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
20869 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
20870 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
20872 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
20873 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
20874 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
20876 speedup_cache=$(percent $average_cache $average_origin)
20877 speedup_ladvise=$(percent $average_ladvise $average_origin)
20879 echo "Average uncached read: $average_origin"
20880 echo "Average speedup with OSS cached read: " \
20881 "$average_cache = +$speedup_cache%"
20882 echo "Average speedup with ladvise willread: " \
20883 "$average_ladvise = +$speedup_ladvise%"
20885 local lowest_speedup=20
20886 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
20887 echo "Speedup with OSS cached read less than $lowest_speedup%," \
20888 "got $average_cache%. Skipping ladvise willread check."
20892 # the test won't work on ZFS until it supports 'ladvise dontneed', but
20893 # it is still good to run until then to exercise 'ladvise willread'
20894 ! $LFS ladvise -a dontneed $DIR/$tfile &&
20895 [ "$ost1_FSTYPE" = "zfs" ] &&
20896 echo "osd-zfs does not support dontneed or drop_caches" &&
20899 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
20900 [[ ${average_ladvise%.*} > $lowest_speedup ]] ||
20901 error_not_in_vm "Speedup with willread is less than " \
20902 "$lowest_speedup%, got $average_ladvise%"
20906 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
20907 skip "lustre < 2.8.54 does not support ladvise "
20908 remote_ost_nodsh && skip "remote OST with nodsh"
20910 stack_trap "rm -f $DIR/$tfile"
20911 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
20913 ladvise_no_type willread $DIR/$tfile &&
20914 skip "willread ladvise is not supported"
20916 ladvise_no_ioctl $DIR/$tfile &&
20917 skip "ladvise ioctl is not supported"
20920 local size=$((size_mb * 1048576))
20921 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
20922 error "dd to $DIR/$tfile failed"
20924 lfs ladvise -a willread $DIR/$tfile ||
20925 error "Ladvise failed with no range argument"
20927 lfs ladvise -a willread -s 0 $DIR/$tfile ||
20928 error "Ladvise failed with no -l or -e argument"
20930 lfs ladvise -a willread -e 1 $DIR/$tfile ||
20931 error "Ladvise failed with only -e argument"
20933 lfs ladvise -a willread -l 1 $DIR/$tfile ||
20934 error "Ladvise failed with only -l argument"
20936 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
20937 error "End offset should not be smaller than start offset"
20939 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
20940 error "End offset should not be equal to start offset"
20942 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
20943 error "Ladvise failed with overflowing -s argument"
20945 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
20946 error "Ladvise failed with overflowing -e argument"
20948 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
20949 error "Ladvise failed with overflowing -l argument"
20951 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
20952 error "Ladvise succeeded with conflicting -l and -e arguments"
20954 echo "Synchronous ladvise should wait"
20956 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
20957 do_nodes $(comma_list $(osts_nodes)) \
20958 $LCTL set_param fail_val=$delay fail_loc=0x237
20960 local start_ts=$SECONDS
20961 lfs ladvise -a willread $DIR/$tfile ||
20962 error "Ladvise failed with no range argument"
20963 local end_ts=$SECONDS
20964 local inteval_ts=$((end_ts - start_ts))
20966 if [ $inteval_ts -lt $(($delay - 1)) ]; then
20967 error "Synchronous advice didn't wait reply"
20970 echo "Asynchronous ladvise shouldn't wait"
20971 local start_ts=$SECONDS
20972 lfs ladvise -a willread -b $DIR/$tfile ||
20973 error "Ladvise failed with no range argument"
20974 local end_ts=$SECONDS
20975 local inteval_ts=$((end_ts - start_ts))
20977 if [ $inteval_ts -gt $(($delay / 2)) ]; then
20978 error "Asynchronous advice blocked"
20981 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
20982 ladvise_willread_performance
20984 run_test 255a "check 'lfs ladvise -a willread'"
20990 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
20994 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
20995 skip "lustre < 2.8.54 does not support ladvise "
20996 remote_ost_nodsh && skip "remote OST with nodsh"
20998 stack_trap "rm -f $DIR/$tfile"
20999 lfs setstripe -c 1 -i 0 $DIR/$tfile
21001 ladvise_no_type dontneed $DIR/$tfile &&
21002 skip "dontneed ladvise is not supported"
21004 ladvise_no_ioctl $DIR/$tfile &&
21005 skip "ladvise ioctl is not supported"
21007 ! $LFS ladvise -a dontneed $DIR/$tfile &&
21008 [ "$ost1_FSTYPE" = "zfs" ] &&
21009 skip "zfs-osd does not support 'ladvise dontneed'"
21012 local size=$((size_mb * 1048576))
21013 # In order to prevent disturbance of other processes, only check 3/4
21014 # of the memory usage
21015 local kibibytes=$((size_mb * 1024 * 3 / 4))
21017 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
21018 error "dd to $DIR/$tfile failed"
21020 #force write to complete before dropping OST cache & checking memory
21023 local total=$(facet_meminfo ost1 MemTotal)
21024 echo "Total memory: $total KiB"
21026 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
21027 local before_read=$(facet_meminfo ost1 Cached)
21028 echo "Cache used before read: $before_read KiB"
21030 lfs ladvise -a willread $DIR/$tfile ||
21031 error "Ladvise willread failed"
21032 local after_read=$(facet_meminfo ost1 Cached)
21033 echo "Cache used after read: $after_read KiB"
21035 lfs ladvise -a dontneed $DIR/$tfile ||
21036 error "Ladvise dontneed again failed"
21037 local no_read=$(facet_meminfo ost1 Cached)
21038 echo "Cache used after dontneed ladvise: $no_read KiB"
21040 if [ $total -lt $((before_read + kibibytes)) ]; then
21041 echo "Memory is too small, abort checking"
21045 if [ $((before_read + kibibytes)) -gt $after_read ]; then
21046 error "Ladvise willread should use more memory" \
21047 "than $kibibytes KiB"
21050 if [ $((no_read + kibibytes)) -gt $after_read ]; then
21051 error "Ladvise dontneed should release more memory" \
21052 "than $kibibytes KiB"
21055 run_test 255b "check 'lfs ladvise -a dontneed'"
21058 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
21059 skip "lustre < 2.10.50 does not support lockahead"
21061 local ost1_imp=$(get_osc_import_name client ost1)
21062 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
21070 test_mkdir -p $DIR/$tdir
21071 $LFS setstripe -i 0 -c 1 $DIR/$tdir
21073 #test 10 returns only success/failure
21075 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21077 if [ $rc -eq 255 ]; then
21078 error "Ladvise test${i} failed, ${rc}"
21081 #test 11 counts lock enqueue requests, all others count new locks
21083 count=$(do_facet ost1 \
21084 $LCTL get_param -n ost.OSS.ost.stats)
21085 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
21087 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21089 if [ $rc -eq 255 ]; then
21090 error "Ladvise test${i} failed, ${rc}"
21093 new_count=$(do_facet ost1 \
21094 $LCTL get_param -n ost.OSS.ost.stats)
21095 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
21096 awk '{ print $2 }')
21098 difference="$((new_count - count))"
21099 if [ $difference -ne $rc ]; then
21100 error "Ladvise test${i}, bad enqueue count, returned " \
21101 "${rc}, actual ${difference}"
21104 for i in $(seq 12 21); do
21105 # If we do not do this, we run the risk of having too many
21106 # locks and starting lock cancellation while we are checking
21108 cancel_lru_locks osc
21110 count=$($LCTL get_param -n \
21111 ldlm.namespaces.$imp_name.lock_unused_count)
21113 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21115 if [ $rc -eq 255 ]; then
21116 error "Ladvise test ${i} failed, ${rc}"
21119 new_count=$($LCTL get_param -n \
21120 ldlm.namespaces.$imp_name.lock_unused_count)
21121 difference="$((new_count - count))"
21123 # Test 15 output is divided by 100 to map down to valid return
21124 if [ $i -eq 15 ]; then
21128 if [ $difference -ne $rc ]; then
21129 error "Ladvise test ${i}, bad lock count, returned " \
21130 "${rc}, actual ${difference}"
21134 #test 22 returns only success/failure
21136 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21138 if [ $rc -eq 255 ]; then
21139 error "Ladvise test${i} failed, ${rc}"
21142 run_test 255c "suite of ladvise lockahead tests"
21145 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21146 remote_mds_nodsh && skip "remote MDS with nodsh"
21147 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
21148 changelog_users $SINGLEMDS | grep "^cl" &&
21149 skip "active changelog user"
21155 mdt_dev=$(mdsdevname 1)
21158 changelog_register || error "changelog_register failed"
21161 mkdir_on_mdt0 $DIR/$tdir
21163 changelog_clear 0 || error "changelog_clear failed"
21166 touch $DIR/$tdir/{1..10}
21169 stop $SINGLEMDS || error "Fail to stop MDT"
21173 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
21175 #after mount new plainllog is used
21176 touch $DIR/$tdir/{11..19}
21177 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
21178 stack_trap "rm -f $tmpfile"
21179 cat_sl=$(do_facet $SINGLEMDS "sync; \
21180 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
21181 llog_reader $tmpfile | grep -c type=1064553b")
21182 do_facet $SINGLEMDS llog_reader $tmpfile
21184 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
21186 changelog_clear 0 || error "changelog_clear failed"
21188 cat_sl=$(do_facet $SINGLEMDS "sync; \
21189 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
21190 llog_reader $tmpfile | grep -c type=1064553b")
21192 if (( cat_sl == 2 )); then
21193 error "Empty plain llog was not deleted from changelog catalog"
21194 elif (( cat_sl != 1 )); then
21195 error "Active plain llog shouldn't be deleted from catalog"
21198 run_test 256 "Check llog delete for empty and not full state"
21201 remote_mds_nodsh && skip "remote MDS with nodsh"
21202 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
21203 skip "Need MDS version at least 2.8.55"
21205 test_mkdir $DIR/$tdir
21207 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
21208 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
21211 #define OBD_FAIL_MDS_XATTR_REP 0x161
21212 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
21213 local facet=mds$((mdtidx + 1))
21214 set_nodes_failloc $(facet_active_host $facet) 0x80000161
21215 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
21217 stop $facet || error "stop MDS failed"
21218 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
21219 error "start MDS fail"
21220 wait_recovery_complete $facet
21222 run_test 257 "xattr locks are not lost"
21224 # Verify we take the i_mutex when security requires it
21226 #define OBD_FAIL_IMUTEX_SEC 0x141c
21227 $LCTL set_param fail_loc=0x141c
21229 chmod u+s $DIR/$tfile
21230 chmod a+rwx $DIR/$tfile
21231 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
21233 if [ $RC -ne 0 ]; then
21234 error "error, failed to take i_mutex, rc=$?"
21238 run_test 258a "verify i_mutex security behavior when suid attributes is set"
21240 # Verify we do NOT take the i_mutex in the normal case
21242 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
21243 $LCTL set_param fail_loc=0x141d
21246 chmod a+rw $DIR/$tfile
21247 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
21249 if [ $RC -ne 0 ]; then
21250 error "error, took i_mutex unnecessarily, rc=$?"
21255 run_test 258b "verify i_mutex security behavior"
21258 local file=$DIR/$tfile
21262 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
21264 stack_trap "rm -f $file" EXIT
21266 wait_delete_completed
21267 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21268 echo "before: $before"
21270 $LFS setstripe -i 0 -c 1 $file
21271 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
21273 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21274 echo "after write: $after"
21276 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
21277 do_facet ost1 $LCTL set_param fail_loc=0x2301
21279 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21280 echo "after truncate: $after"
21283 do_facet ost1 $LCTL set_param fail_loc=0
21284 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21286 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21287 echo "after restart: $after"
21288 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
21289 error "missing truncate?"
21293 run_test 259 "crash at delayed truncate"
21296 #define OBD_FAIL_MDC_CLOSE 0x806
21297 $LCTL set_param fail_loc=0x80000806
21301 run_test 260 "Check mdc_close fail"
21303 ### Data-on-MDT sanity tests ###
21305 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21306 skip "Need MDS version at least 2.10.55 for DoM"
21309 local dom=$DIR/$tdir/dom_file
21310 local tmp=$DIR/$tdir/tmp_file
21312 mkdir_on_mdt0 $DIR/$tdir
21314 # basic checks for DoM component creation
21315 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
21316 error "Can set MDT layout to non-first entry"
21318 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
21319 error "Can define multiple entries as MDT layout"
21321 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
21323 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
21324 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
21325 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
21327 local mdtidx=$($LFS getstripe -m $dom)
21328 local mdtname=MDT$(printf %04x $mdtidx)
21329 local facet=mds$((mdtidx + 1))
21330 local space_check=1
21332 # Skip free space checks with ZFS
21333 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
21337 local size_tmp=$((65536 * 3))
21338 local mdtfree1=$(do_facet $facet \
21339 lctl get_param -n osd*.*$mdtname.kbytesfree)
21341 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
21342 # check also direct IO along write
21343 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
21344 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
21346 cmp $tmp $dom || error "file data is different"
21347 [ $(stat -c%s $dom) == $size_tmp ] ||
21348 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
21349 if [ $space_check == 1 ]; then
21350 local mdtfree2=$(do_facet $facet \
21351 lctl get_param -n osd*.*$mdtname.kbytesfree)
21353 # increase in usage from by $size_tmp
21354 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
21355 error "MDT free space wrong after write: " \
21356 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
21360 local size_dom=10000
21362 $TRUNCATE $dom $size_dom
21363 [ $(stat -c%s $dom) == $size_dom ] ||
21364 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
21365 if [ $space_check == 1 ]; then
21366 mdtfree1=$(do_facet $facet \
21367 lctl get_param -n osd*.*$mdtname.kbytesfree)
21368 # decrease in usage from $size_tmp to new $size_dom
21369 [ $(($mdtfree1 - $mdtfree2)) -ge \
21370 $(((size_tmp - size_dom) / 1024)) ] ||
21371 error "MDT free space is wrong after truncate: " \
21372 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
21378 size_dom=$((size_dom + size_tmp))
21379 [ $(stat -c%s $dom) == $size_dom ] ||
21380 error "bad size after append: $(stat -c%s $dom) != $size_dom"
21381 if [ $space_check == 1 ]; then
21382 mdtfree2=$(do_facet $facet \
21383 lctl get_param -n osd*.*$mdtname.kbytesfree)
21384 # increase in usage by $size_tmp from previous
21385 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
21386 error "MDT free space is wrong after append: " \
21387 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
21392 if [ $space_check == 1 ]; then
21393 mdtfree1=$(do_facet $facet \
21394 lctl get_param -n osd*.*$mdtname.kbytesfree)
21395 # decrease in usage by $size_dom from previous
21396 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
21397 error "MDT free space is wrong after removal: " \
21398 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
21401 # combined striping
21402 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
21403 error "Can't create DoM + OST striping"
21405 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
21406 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
21407 # check also direct IO along write
21408 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
21410 cmp $tmp $dom || error "file data is different"
21411 [ $(stat -c%s $dom) == $size_tmp ] ||
21412 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
21417 run_test 270a "DoM: basic functionality tests"
21420 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21421 skip "Need MDS version at least 2.10.55"
21423 local dom=$DIR/$tdir/dom_file
21424 local max_size=1048576
21426 mkdir -p $DIR/$tdir
21427 $LFS setstripe -E $max_size -L mdt $dom
21429 # truncate over the limit
21430 $TRUNCATE $dom $(($max_size + 1)) &&
21431 error "successful truncate over the maximum size"
21432 # write over the limit
21433 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
21434 error "successful write over the maximum size"
21435 # append over the limit
21436 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
21437 echo "12345" >> $dom && error "successful append over the maximum size"
21442 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
21445 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21446 skip "Need MDS version at least 2.10.55"
21448 mkdir -p $DIR/$tdir
21449 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21451 # check files inherit DoM EA
21452 touch $DIR/$tdir/first
21453 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
21454 error "bad pattern"
21455 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
21456 error "bad stripe count"
21457 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
21458 error "bad stripe size"
21460 # check directory inherits DoM EA and uses it as default
21461 mkdir $DIR/$tdir/subdir
21462 touch $DIR/$tdir/subdir/second
21463 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
21464 error "bad pattern in sub-directory"
21465 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
21466 error "bad stripe count in sub-directory"
21467 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
21468 error "bad stripe size in sub-directory"
21471 run_test 270c "DoM: DoM EA inheritance tests"
21474 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21475 skip "Need MDS version at least 2.10.55"
21477 mkdir -p $DIR/$tdir
21478 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21480 # inherit default DoM striping
21481 mkdir $DIR/$tdir/subdir
21482 touch $DIR/$tdir/subdir/f1
21484 # change default directory striping
21485 $LFS setstripe -c 1 $DIR/$tdir/subdir
21486 touch $DIR/$tdir/subdir/f2
21487 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
21488 error "wrong default striping in file 2"
21489 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
21490 error "bad pattern in file 2"
21493 run_test 270d "DoM: change striping from DoM to RAID0"
21496 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21497 skip "Need MDS version at least 2.10.55"
21499 mkdir -p $DIR/$tdir/dom
21500 mkdir -p $DIR/$tdir/norm
21503 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
21504 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
21506 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
21507 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
21509 # find DoM files by layout
21510 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
21511 [ $NUM -eq $DOMFILES ] ||
21512 error "lfs find -L: found $NUM, expected $DOMFILES"
21513 echo "Test 1: lfs find 20 DOM files by layout: OK"
21515 # there should be 1 dir with default DOM striping
21516 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
21518 error "lfs find -L: found $NUM, expected 1 dir"
21519 echo "Test 2: lfs find 1 DOM dir by layout: OK"
21521 # find DoM files by stripe size
21522 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
21523 [ $NUM -eq $DOMFILES ] ||
21524 error "lfs find -S: found $NUM, expected $DOMFILES"
21525 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
21527 # find files by stripe offset except DoM files
21528 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
21529 [ $NUM -eq $NORMFILES ] ||
21530 error "lfs find -i: found $NUM, expected $NORMFILES"
21531 echo "Test 5: lfs find no DOM files by stripe index: OK"
21534 run_test 270e "DoM: lfs find with DoM files test"
21537 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21538 skip "Need MDS version at least 2.10.55"
21540 local mdtname=${FSNAME}-MDT0000-mdtlov
21541 local dom=$DIR/$tdir/dom_file
21542 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
21543 lod.$mdtname.dom_stripesize)
21544 local dom_limit=131072
21546 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
21547 local dom_current=$(do_facet mds1 $LCTL get_param -n \
21548 lod.$mdtname.dom_stripesize)
21549 [ ${dom_limit} -eq ${dom_current} ] ||
21550 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
21552 $LFS mkdir -i 0 -c 1 $DIR/$tdir
21553 $LFS setstripe -d $DIR/$tdir
21554 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
21555 error "Can't set directory default striping"
21557 # exceed maximum stripe size
21558 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
21559 error "Can't create file with $((dom_limit * 2)) DoM stripe"
21560 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
21561 error "Able to create DoM component size more than LOD limit"
21563 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
21564 dom_current=$(do_facet mds1 $LCTL get_param -n \
21565 lod.$mdtname.dom_stripesize)
21566 [ 0 -eq ${dom_current} ] ||
21567 error "Can't set zero DoM stripe limit"
21570 # attempt to create DoM file on server with disabled DoM should
21571 # remove DoM entry from layout and be succeed
21572 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
21573 error "Can't create DoM file (DoM is disabled)"
21574 [ $($LFS getstripe -L $dom) == "mdt" ] &&
21575 error "File has DoM component while DoM is disabled"
21578 # attempt to create DoM file with only DoM stripe should return error
21579 $LFS setstripe -E $dom_limit -L mdt $dom &&
21580 error "Able to create DoM-only file while DoM is disabled"
21582 # too low values to be aligned with smallest stripe size 64K
21583 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
21584 dom_current=$(do_facet mds1 $LCTL get_param -n \
21585 lod.$mdtname.dom_stripesize)
21586 [ 30000 -eq ${dom_current} ] &&
21587 error "Can set too small DoM stripe limit"
21589 # 64K is a minimal stripe size in Lustre, expect limit of that size
21590 [ 65536 -eq ${dom_current} ] ||
21591 error "Limit is not set to 64K but ${dom_current}"
21593 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
21594 dom_current=$(do_facet mds1 $LCTL get_param -n \
21595 lod.$mdtname.dom_stripesize)
21597 [ 2147483648 -eq ${dom_current} ] &&
21598 error "Can set too large DoM stripe limit"
21600 do_facet mds1 $LCTL set_param -n \
21601 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
21602 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
21603 error "Can't create DoM component size after limit change"
21604 do_facet mds1 $LCTL set_param -n \
21605 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
21606 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
21607 error "Can't create DoM file after limit decrease"
21608 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
21609 error "Can create big DoM component after limit decrease"
21610 touch ${dom}_def ||
21611 error "Can't create file with old default layout"
21613 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
21616 run_test 270f "DoM: maximum DoM stripe size checks"
21619 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
21620 skip "Need MDS version at least 2.13.52"
21621 local dom=$DIR/$tdir/$tfile
21623 $LFS mkdir -i 0 -c 1 $DIR/$tdir
21624 local lodname=${FSNAME}-MDT0000-mdtlov
21626 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21627 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
21628 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
21629 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
21631 local dom_limit=1024
21632 local dom_threshold="50%"
21634 $LFS setstripe -d $DIR/$tdir
21635 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
21636 error "Can't set directory default striping"
21638 do_facet mds1 $LCTL set_param -n \
21639 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
21640 # set 0 threshold and create DOM file to change tunable stripesize
21641 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
21642 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
21643 error "Failed to create $dom file"
21644 # now tunable dom_cur_stripesize should reach maximum
21645 local dom_current=$(do_facet mds1 $LCTL get_param -n \
21646 lod.${lodname}.dom_stripesize_cur_kb)
21647 [[ $dom_current == $dom_limit ]] ||
21648 error "Current DOM stripesize is not maximum"
21651 # set threshold for further tests
21652 do_facet mds1 $LCTL set_param -n \
21653 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
21654 echo "DOM threshold is $dom_threshold free space"
21657 # Spoof bfree to exceed threshold
21658 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
21659 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
21660 for spfree in 40 20 0 15 30 55; do
21661 do_facet mds1 $LCTL set_param -n fail_val=$spfree
21662 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
21663 error "Failed to create $dom file"
21664 dom_def=$(do_facet mds1 $LCTL get_param -n \
21665 lod.${lodname}.dom_stripesize_cur_kb)
21666 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
21667 [[ $dom_def != $dom_current ]] ||
21668 error "Default stripe size was not changed"
21669 if [[ $spfree > 0 ]] ; then
21670 dom_set=$($LFS getstripe -S $dom)
21671 [[ $dom_set == $((dom_def * 1024)) ]] ||
21672 error "DOM component size is still old"
21674 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
21675 error "DoM component is set with no free space"
21678 dom_current=$dom_def
21681 run_test 270g "DoM: default DoM stripe size depends on free space"
21684 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
21685 skip "Need MDS version at least 2.13.53"
21687 local mdtname=${FSNAME}-MDT0000-mdtlov
21688 local dom=$DIR/$tdir/$tfile
21689 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21691 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
21692 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
21694 $LFS mkdir -i 0 -c 1 $DIR/$tdir
21695 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
21696 error "can't create OST file"
21697 # mirrored file with DOM entry in the second mirror
21698 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
21699 error "can't create mirror with DoM component"
21701 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
21703 # DOM component in the middle and has other enries in the same mirror,
21704 # should succeed but lost DoM component
21705 $LFS setstripe --copy=${dom}_1 $dom ||
21706 error "Can't create file from OST|DOM mirror layout"
21707 # check new file has no DoM layout after all
21708 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
21709 error "File has DoM component while DoM is disabled"
21711 run_test 270h "DoM: DoM stripe removal when disabled on server"
21714 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21715 skip "Need MDS version at least 2.10.55"
21717 local dom=$DIR/$tdir/dom
21719 mkdir -p $DIR/$tdir
21721 $LFS setstripe -E 1024K -L mdt $dom
21723 lctl set_param -n mdc.*.stats=clear
21724 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
21725 cat $dom > /dev/null
21726 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
21727 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
21731 run_test 271a "DoM: data is cached for read after write"
21734 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21735 skip "Need MDS version at least 2.10.55"
21737 local dom=$DIR/$tdir/dom
21739 mkdir -p $DIR/$tdir
21741 $LFS setstripe -E 1024K -L mdt -E EOF $dom
21743 lctl set_param -n mdc.*.stats=clear
21744 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
21745 cancel_lru_locks mdc
21746 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
21747 # second stat to check size is cached on client
21748 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
21749 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
21750 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
21753 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
21756 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21757 skip "Need MDS version at least 2.10.55"
21759 local dom=$DIR/$tdir/dom
21761 mkdir -p $DIR/$tdir
21763 $LFS setstripe -E 1024K -L mdt -E EOF $dom
21765 lctl set_param -n mdc.*.stats=clear
21766 lctl set_param -n osc.*.stats=clear
21767 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
21768 cancel_lru_locks mdc
21769 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
21770 # second stat to check size is cached on client
21771 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
21772 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
21773 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
21774 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
21775 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
21778 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
21784 local mdt=MDT$(printf %04x $mdtidx)
21786 if [ -z $param ]; then
21787 lctl get_param -n mdc.*$mdt*.stats
21789 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
21794 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21795 skip "Need MDS version at least 2.10.55"
21797 local dom=$DIR/$tdir/dom
21799 mkdir -p $DIR/$tdir
21801 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21803 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
21804 local facet=mds$((mdtidx + 1))
21806 cancel_lru_locks mdc
21807 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
21808 createmany -o $dom 1000
21809 lctl set_param -n mdc.*.stats=clear
21810 smalliomany -w $dom 1000 200
21811 get_mdc_stats $mdtidx
21812 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
21813 # Each file has 1 open, 1 IO enqueues, total 2000
21814 # but now we have also +1 getxattr for security.capability, total 3000
21815 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
21816 unlinkmany $dom 1000
21818 cancel_lru_locks mdc
21819 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
21820 createmany -o $dom 1000
21821 lctl set_param -n mdc.*.stats=clear
21822 smalliomany -w $dom 1000 200
21823 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
21824 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
21825 # for OPEN and IO lock.
21826 [ $((enq - enq_2)) -ge 1000 ] ||
21827 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
21828 unlinkmany $dom 1000
21831 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
21833 cleanup_271def_tests() {
21839 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
21840 skip "Need MDS version at least 2.10.57"
21842 local dom=$DIR/$tdir/dom
21843 local tmp=$TMP/$tfile
21844 trap "cleanup_271def_tests $tmp" EXIT
21846 mkdir -p $DIR/$tdir
21848 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21850 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
21852 cancel_lru_locks mdc
21853 dd if=/dev/urandom of=$tmp bs=1000 count=1
21854 dd if=$tmp of=$dom bs=1000 count=1
21855 cancel_lru_locks mdc
21857 cat /etc/hosts >> $tmp
21858 lctl set_param -n mdc.*.stats=clear
21860 # append data to the same file it should update local page
21861 echo "Append to the same page"
21862 cat /etc/hosts >> $dom
21863 local num=$(get_mdc_stats $mdtidx ost_read)
21864 local ra=$(get_mdc_stats $mdtidx req_active)
21865 local rw=$(get_mdc_stats $mdtidx req_waittime)
21867 [ -z $num ] || error "$num READ RPC occured"
21868 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
21872 cmp $tmp $dom || error "file miscompare"
21874 cancel_lru_locks mdc
21875 lctl set_param -n mdc.*.stats=clear
21877 echo "Open and read file"
21878 cat $dom > /dev/null
21879 local num=$(get_mdc_stats $mdtidx ost_read)
21880 local ra=$(get_mdc_stats $mdtidx req_active)
21881 local rw=$(get_mdc_stats $mdtidx req_waittime)
21883 [ -z $num ] || error "$num READ RPC occured"
21884 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
21888 cmp $tmp $dom || error "file miscompare"
21892 run_test 271d "DoM: read on open (1K file in reply buffer)"
21895 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
21896 skip "Need MDS version at least 2.10.57"
21898 local dom=$DIR/$tdir/dom
21899 local tmp=$TMP/$tfile
21900 trap "cleanup_271def_tests $tmp" EXIT
21902 mkdir -p $DIR/$tdir
21904 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21906 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
21908 cancel_lru_locks mdc
21909 dd if=/dev/urandom of=$tmp bs=265000 count=1
21910 dd if=$tmp of=$dom bs=265000 count=1
21911 cancel_lru_locks mdc
21912 cat /etc/hosts >> $tmp
21913 lctl set_param -n mdc.*.stats=clear
21915 echo "Append to the same page"
21916 cat /etc/hosts >> $dom
21917 local num=$(get_mdc_stats $mdtidx ost_read)
21918 local ra=$(get_mdc_stats $mdtidx req_active)
21919 local rw=$(get_mdc_stats $mdtidx req_waittime)
21921 [ -z $num ] || error "$num READ RPC occured"
21922 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
21926 cmp $tmp $dom || error "file miscompare"
21928 cancel_lru_locks mdc
21929 lctl set_param -n mdc.*.stats=clear
21931 echo "Open and read file"
21932 cat $dom > /dev/null
21933 local num=$(get_mdc_stats $mdtidx ost_read)
21934 local ra=$(get_mdc_stats $mdtidx req_active)
21935 local rw=$(get_mdc_stats $mdtidx req_waittime)
21937 [ -z $num ] && num=0
21938 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
21939 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
21943 cmp $tmp $dom || error "file miscompare"
21947 run_test 271f "DoM: read on open (200K file and read tail)"
21950 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
21951 skip "Skipping due to old client or server version"
21953 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
21955 $CHECKSTAT -t file $DIR1/$tfile
21957 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
21960 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
21961 $LCTL set_param fail_loc=0x80000314
21962 rm $DIR1/$tfile || error "Unlink fails"
21964 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
21965 [ $RC -eq 0 ] || error "Failed write to stale object"
21967 run_test 271g "Discard DoM data vs client flush race"
21970 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
21971 skip "Need MDS version at least 2.11.50"
21973 local dom=$DIR/$tdir/dom
21974 mkdir -p $DIR/$tdir
21976 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
21977 dd if=/dev/urandom of=$dom bs=512K count=1 ||
21978 error "failed to write data into $dom"
21979 local old_md5=$(md5sum $dom)
21981 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
21982 error "failed to migrate to the same DoM component"
21984 local new_md5=$(md5sum $dom)
21986 [ "$old_md5" == "$new_md5" ] ||
21987 error "md5sum differ: $old_md5, $new_md5"
21989 [ $($LFS getstripe -c $dom) -eq 2 ] ||
21990 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
21992 run_test 272a "DoM migration: new layout with the same DOM component"
21995 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
21996 skip "Need MDS version at least 2.11.50"
21998 local dom=$DIR/$tdir/dom
21999 mkdir -p $DIR/$tdir
22000 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22002 local mdtidx=$($LFS getstripe -m $dom)
22003 local mdtname=MDT$(printf %04x $mdtidx)
22004 local facet=mds$((mdtidx + 1))
22006 local mdtfree1=$(do_facet $facet \
22007 lctl get_param -n osd*.*$mdtname.kbytesfree)
22008 dd if=/dev/urandom of=$dom bs=2M count=1 ||
22009 error "failed to write data into $dom"
22010 local old_md5=$(md5sum $dom)
22011 cancel_lru_locks mdc
22012 local mdtfree1=$(do_facet $facet \
22013 lctl get_param -n osd*.*$mdtname.kbytesfree)
22015 $LFS migrate -c2 $dom ||
22016 error "failed to migrate to the new composite layout"
22017 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22018 error "MDT stripe was not removed"
22020 cancel_lru_locks mdc
22021 local new_md5=$(md5sum $dom)
22022 [ "$old_md5" == "$new_md5" ] ||
22023 error "$old_md5 != $new_md5"
22025 # Skip free space checks with ZFS
22026 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22027 local mdtfree2=$(do_facet $facet \
22028 lctl get_param -n osd*.*$mdtname.kbytesfree)
22029 [ $mdtfree2 -gt $mdtfree1 ] ||
22030 error "MDT space is not freed after migration"
22034 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
22037 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22038 skip "Need MDS version at least 2.11.50"
22040 local dom=$DIR/$tdir/$tfile
22041 mkdir -p $DIR/$tdir
22042 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22044 local mdtidx=$($LFS getstripe -m $dom)
22045 local mdtname=MDT$(printf %04x $mdtidx)
22046 local facet=mds$((mdtidx + 1))
22048 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
22049 error "failed to write data into $dom"
22050 local old_md5=$(md5sum $dom)
22051 cancel_lru_locks mdc
22052 local mdtfree1=$(do_facet $facet \
22053 lctl get_param -n osd*.*$mdtname.kbytesfree)
22055 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
22056 error "failed to migrate to the new composite layout"
22057 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
22058 error "MDT stripe was not removed"
22060 cancel_lru_locks mdc
22061 local new_md5=$(md5sum $dom)
22062 [ "$old_md5" == "$new_md5" ] ||
22063 error "$old_md5 != $new_md5"
22065 # Skip free space checks with ZFS
22066 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22067 local mdtfree2=$(do_facet $facet \
22068 lctl get_param -n osd*.*$mdtname.kbytesfree)
22069 [ $mdtfree2 -gt $mdtfree1 ] ||
22070 error "MDS space is not freed after migration"
22074 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
22077 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22078 skip "Need MDS version at least 2.12.55"
22080 local dom=$DIR/$tdir/$tfile
22081 mkdir -p $DIR/$tdir
22082 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22084 local mdtidx=$($LFS getstripe -m $dom)
22085 local mdtname=MDT$(printf %04x $mdtidx)
22086 local facet=mds$((mdtidx + 1))
22088 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
22089 error "failed to write data into $dom"
22090 local old_md5=$(md5sum $dom)
22091 cancel_lru_locks mdc
22092 local mdtfree1=$(do_facet $facet \
22093 lctl get_param -n osd*.*$mdtname.kbytesfree)
22095 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
22096 error "failed mirroring to the new composite layout"
22097 $LFS mirror resync $dom ||
22098 error "failed mirror resync"
22099 $LFS mirror split --mirror-id 1 -d $dom ||
22100 error "failed mirror split"
22102 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22103 error "MDT stripe was not removed"
22105 cancel_lru_locks mdc
22106 local new_md5=$(md5sum $dom)
22107 [ "$old_md5" == "$new_md5" ] ||
22108 error "$old_md5 != $new_md5"
22110 # Skip free space checks with ZFS
22111 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22112 local mdtfree2=$(do_facet $facet \
22113 lctl get_param -n osd*.*$mdtname.kbytesfree)
22114 [ $mdtfree2 -gt $mdtfree1 ] ||
22115 error "MDS space is not freed after DOM mirror deletion"
22119 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
22122 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22123 skip "Need MDS version at least 2.12.55"
22125 local dom=$DIR/$tdir/$tfile
22126 mkdir -p $DIR/$tdir
22127 $LFS setstripe -c 2 $dom
22129 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
22130 error "failed to write data into $dom"
22131 local old_md5=$(md5sum $dom)
22132 cancel_lru_locks mdc
22134 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
22135 error "failed mirroring to the DOM layout"
22136 $LFS mirror resync $dom ||
22137 error "failed mirror resync"
22138 $LFS mirror split --mirror-id 1 -d $dom ||
22139 error "failed mirror split"
22141 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22142 error "MDT stripe was not removed"
22144 cancel_lru_locks mdc
22145 local new_md5=$(md5sum $dom)
22146 [ "$old_md5" == "$new_md5" ] ||
22147 error "$old_md5 != $new_md5"
22151 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
22154 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22155 skip "Need MDS version at least 2.12.55"
22157 local dom=$DIR/$tdir/$tfile
22158 mkdir -p $DIR/$tdir
22159 $LFS setstripe -c 2 $dom
22161 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
22162 error "failed to write data into $dom"
22163 local old_md5=$(md5sum $dom)
22164 cancel_lru_locks mdc
22166 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
22167 error "failed migrating to the DOM file"
22169 cancel_lru_locks mdc
22170 local new_md5=$(md5sum $dom)
22171 [ "$old_md5" != "$new_md5" ] &&
22172 error "$old_md5 != $new_md5"
22176 run_test 272f "DoM migration: OST-striped file to DOM file"
22179 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22180 skip "Need MDS version at least 2.11.50"
22182 # Layout swap cannot be done if either file has DOM component,
22183 # this will never be supported, migration should be used instead
22185 local dom=$DIR/$tdir/$tfile
22186 mkdir -p $DIR/$tdir
22188 $LFS setstripe -c2 ${dom}_plain
22189 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
22190 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
22191 error "can swap layout with DoM component"
22192 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
22193 error "can swap layout with DoM component"
22195 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
22196 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
22197 error "can swap layout with DoM component"
22198 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
22199 error "can swap layout with DoM component"
22202 run_test 273a "DoM: layout swapping should fail with DOM"
22205 mkdir -p $DIR/$tdir
22206 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
22208 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
22209 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
22211 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
22213 run_test 273b "DoM: race writeback and object destroy"
22216 remote_ost_nodsh && skip "remote OST with nodsh"
22217 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
22218 skip "Need OST version >= 2.10.57"
22220 local file=$DIR/$tfile
22223 oss=$(comma_list $(osts_nodes))
22225 dd if=/dev/urandom of=$file bs=1M count=2 ||
22226 error "failed to create a file"
22227 cancel_lru_locks osc
22230 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
22231 error "failed to read a file"
22233 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
22234 $LCTL set_param fail_loc=0x8000031f
22236 cancel_lru_locks osc &
22239 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
22240 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
22241 #IO takes another lock, but matches the PENDING one
22242 #and places it to the IO RPC
22243 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
22244 error "failed to read a file with PENDING lock"
22246 run_test 275 "Read on a canceled duplicate lock"
22249 remote_ost_nodsh && skip "remote OST with nodsh"
22252 do_facet ost1 "(while true; do \
22253 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
22254 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
22257 for LOOP in $(seq 20); do
22259 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
22262 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
22263 rm $TMP/sanity_276_pid"
22265 run_test 276 "Race between mount and obd_statfs"
22268 $LCTL set_param ldlm.namespaces.*.lru_size=0
22269 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
22270 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
22271 grep ^used_mb | awk '{print $2}')
22272 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
22273 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
22274 oflag=direct conv=notrunc
22275 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
22276 grep ^used_mb | awk '{print $2}')
22277 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
22279 run_test 277 "Direct IO shall drop page cache"
22282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
22283 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
22284 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
22285 skip "needs the same host for mdt1 mdt2" && return
22290 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
22291 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
22297 echo "Starting MDTs"
22298 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
22300 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
22302 do_facet mds2 $LCTL set_param fail_loc=0
22304 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
22305 wait_recovery_complete mds2
22307 run_test 278 "Race starting MDS between MDTs stop/start"
22310 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
22311 skip "Need MGS version at least 2.13.52"
22312 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22313 combined_mgs_mds || skip "needs combined MGS/MDT"
22315 umount_client $MOUNT
22316 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
22317 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
22319 mount_client $MOUNT &
22321 stop mgs || error "stop mgs failed"
22322 #for a race mgs would crash
22323 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
22324 # make sure we unmount client before remounting
22326 umount_client $MOUNT
22327 mount_client $MOUNT || error "mount client failed"
22329 run_test 280 "Race between MGS umount and client llog processing"
22331 cleanup_test_300() {
22335 test_striped_dir() {
22340 mkdir -p $DIR/$tdir
22342 SAVE_UMASK=$(umask)
22343 trap cleanup_test_300 RETURN EXIT
22345 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
22346 $DIR/$tdir/striped_dir ||
22347 error "set striped dir error"
22349 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
22350 [ "$mode" = "755" ] || error "expect 755 got $mode"
22352 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
22353 error "getdirstripe failed"
22354 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
22355 if [ "$stripe_count" != "2" ]; then
22356 error "1:stripe_count is $stripe_count, expect 2"
22358 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
22359 if [ "$stripe_count" != "2" ]; then
22360 error "2:stripe_count is $stripe_count, expect 2"
22363 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
22364 if [ "$stripe_index" != "$mdt_index" ]; then
22365 error "stripe_index is $stripe_index, expect $mdt_index"
22368 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
22369 error "nlink error after create striped dir"
22371 mkdir $DIR/$tdir/striped_dir/a
22372 mkdir $DIR/$tdir/striped_dir/b
22374 stat $DIR/$tdir/striped_dir/a ||
22375 error "create dir under striped dir failed"
22376 stat $DIR/$tdir/striped_dir/b ||
22377 error "create dir under striped dir failed"
22379 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
22380 error "nlink error after mkdir"
22382 rmdir $DIR/$tdir/striped_dir/a
22383 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
22384 error "nlink error after rmdir"
22386 rmdir $DIR/$tdir/striped_dir/b
22387 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
22388 error "nlink error after rmdir"
22390 chattr +i $DIR/$tdir/striped_dir
22391 createmany -o $DIR/$tdir/striped_dir/f 10 &&
22392 error "immutable flags not working under striped dir!"
22393 chattr -i $DIR/$tdir/striped_dir
22395 rmdir $DIR/$tdir/striped_dir ||
22396 error "rmdir striped dir error"
22404 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22405 skip "skipped for lustre < 2.7.0"
22406 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22407 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22409 test_striped_dir 0 || error "failed on striped dir on MDT0"
22410 test_striped_dir 1 || error "failed on striped dir on MDT0"
22412 run_test 300a "basic striped dir sanity test"
22415 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22416 skip "skipped for lustre < 2.7.0"
22417 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22418 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22425 test_mkdir $DIR/$tdir || error "mkdir fail"
22426 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
22427 error "set striped dir error"
22428 for i in {0..9}; do
22429 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
22431 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
22432 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
22433 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
22435 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
22436 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
22437 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
22441 run_test 300b "check ctime/mtime for striped dir"
22444 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22445 skip "skipped for lustre < 2.7.0"
22446 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22447 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22451 mkdir_on_mdt0 $DIR/$tdir
22452 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
22453 error "set striped dir error"
22455 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
22456 error "chown striped dir failed"
22458 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
22459 error "create 5k files failed"
22461 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
22463 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
22467 run_test 300c "chown && check ls under striped directory"
22470 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22471 skip "skipped for lustre < 2.7.0"
22472 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22473 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22478 mkdir -p $DIR/$tdir
22479 $LFS setstripe -c 2 $DIR/$tdir
22481 #local striped directory
22482 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
22483 error "set striped dir error"
22484 #look at the directories for debug purposes
22486 $LFS getdirstripe $DIR/$tdir
22487 ls -l $DIR/$tdir/striped_dir
22488 $LFS getdirstripe $DIR/$tdir/striped_dir
22489 createmany -o $DIR/$tdir/striped_dir/f 10 ||
22490 error "create 10 files failed"
22492 #remote striped directory
22493 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
22494 error "set striped dir error"
22495 #look at the directories for debug purposes
22497 $LFS getdirstripe $DIR/$tdir
22498 ls -l $DIR/$tdir/remote_striped_dir
22499 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
22500 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
22501 error "create 10 files failed"
22503 for file in $(find $DIR/$tdir); do
22504 stripe_count=$($LFS getstripe -c $file)
22505 [ $stripe_count -eq 2 ] ||
22506 error "wrong stripe $stripe_count for $file"
22511 run_test 300d "check default stripe under striped directory"
22514 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22515 skip "Need MDS version at least 2.7.55"
22516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22517 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22522 mkdir -p $DIR/$tdir
22524 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
22525 error "set striped dir error"
22527 touch $DIR/$tdir/striped_dir/a
22528 touch $DIR/$tdir/striped_dir/b
22529 touch $DIR/$tdir/striped_dir/c
22531 mkdir $DIR/$tdir/striped_dir/dir_a
22532 mkdir $DIR/$tdir/striped_dir/dir_b
22533 mkdir $DIR/$tdir/striped_dir/dir_c
22535 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
22536 error "set striped adir under striped dir error"
22538 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
22539 error "set striped bdir under striped dir error"
22541 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
22542 error "set striped cdir under striped dir error"
22544 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
22545 error "rename dir under striped dir fails"
22547 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
22548 error "rename dir under different stripes fails"
22550 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
22551 error "rename file under striped dir should succeed"
22553 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
22554 error "rename dir under striped dir should succeed"
22558 run_test 300e "check rename under striped directory"
22561 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22562 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22563 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22564 skip "Need MDS version at least 2.7.55"
22570 mkdir -p $DIR/$tdir
22572 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
22573 error "set striped dir error"
22575 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
22576 error "set striped dir error"
22578 touch $DIR/$tdir/striped_dir/a
22579 mkdir $DIR/$tdir/striped_dir/dir_a
22580 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
22581 error "create striped dir under striped dir fails"
22583 touch $DIR/$tdir/striped_dir1/b
22584 mkdir $DIR/$tdir/striped_dir1/dir_b
22585 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
22586 error "create striped dir under striped dir fails"
22588 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
22589 error "rename dir under different striped dir should fail"
22591 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
22592 error "rename striped dir under diff striped dir should fail"
22594 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
22595 error "rename file under diff striped dirs fails"
22599 run_test 300f "check rename cross striped directory"
22601 test_300_check_default_striped_dir()
22604 local default_count=$2
22605 local default_index=$3
22608 local dir_stripe_index
22611 echo "checking $dirname $default_count $default_index"
22612 $LFS setdirstripe -D -c $default_count -i $default_index \
22613 -H all_char $DIR/$tdir/$dirname ||
22614 error "set default stripe on striped dir error"
22615 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
22616 [ $stripe_count -eq $default_count ] ||
22617 error "expect $default_count get $stripe_count for $dirname"
22619 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
22620 [ $stripe_index -eq $default_index ] ||
22621 error "expect $default_index get $stripe_index for $dirname"
22623 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
22624 error "create dirs failed"
22626 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
22627 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
22628 for dir in $(find $DIR/$tdir/$dirname/*); do
22629 stripe_count=$($LFS getdirstripe -c $dir)
22630 (( $stripe_count == $default_count )) ||
22631 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
22632 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
22633 error "stripe count $default_count != $stripe_count for $dir"
22635 stripe_index=$($LFS getdirstripe -i $dir)
22636 [ $default_index -eq -1 ] ||
22637 [ $stripe_index -eq $default_index ] ||
22638 error "$stripe_index != $default_index for $dir"
22640 #check default stripe
22641 stripe_count=$($LFS getdirstripe -D -c $dir)
22642 [ $stripe_count -eq $default_count ] ||
22643 error "default count $default_count != $stripe_count for $dir"
22645 stripe_index=$($LFS getdirstripe -D -i $dir)
22646 [ $stripe_index -eq $default_index ] ||
22647 error "default index $default_index != $stripe_index for $dir"
22649 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
22653 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22654 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22655 skip "Need MDS version at least 2.7.55"
22661 mkdir_on_mdt0 $DIR/$tdir
22662 mkdir $DIR/$tdir/normal_dir
22664 #Checking when client cache stripe index
22665 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
22666 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
22667 error "create striped_dir failed"
22669 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
22670 error "create dir0 fails"
22671 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
22672 [ $stripe_index -eq 0 ] ||
22673 error "dir0 expect index 0 got $stripe_index"
22675 mkdir $DIR/$tdir/striped_dir/dir1 ||
22676 error "create dir1 fails"
22677 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
22678 [ $stripe_index -eq 1 ] ||
22679 error "dir1 expect index 1 got $stripe_index"
22681 #check default stripe count/stripe index
22682 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
22683 test_300_check_default_striped_dir normal_dir 1 0
22684 test_300_check_default_striped_dir normal_dir -1 1
22685 test_300_check_default_striped_dir normal_dir 2 -1
22687 #delete default stripe information
22688 echo "delete default stripeEA"
22689 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
22690 error "set default stripe on striped dir error"
22692 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
22693 for dir in $(find $DIR/$tdir/normal_dir/*); do
22694 stripe_count=$($LFS getdirstripe -c $dir)
22695 [ $stripe_count -eq 0 ] ||
22696 error "expect 1 get $stripe_count for $dir"
22699 run_test 300g "check default striped directory for normal directory"
22702 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22703 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22704 skip "Need MDS version at least 2.7.55"
22710 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
22711 error "set striped dir error"
22713 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
22714 test_300_check_default_striped_dir striped_dir 1 0
22715 test_300_check_default_striped_dir striped_dir -1 1
22716 test_300_check_default_striped_dir striped_dir 2 -1
22718 #delete default stripe information
22719 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
22720 error "set default stripe on striped dir error"
22722 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
22723 for dir in $(find $DIR/$tdir/striped_dir/*); do
22724 stripe_count=$($LFS getdirstripe -c $dir)
22725 [ $stripe_count -eq 0 ] ||
22726 error "expect 1 get $stripe_count for $dir"
22729 run_test 300h "check default striped directory for striped directory"
22732 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22733 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22734 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22735 skip "Need MDS version at least 2.7.55"
22742 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
22743 error "set striped dir error"
22745 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
22746 error "create files under striped dir failed"
22748 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
22749 error "set striped hashdir error"
22751 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
22752 error "create dir0 under hash dir failed"
22753 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
22754 error "create dir1 under hash dir failed"
22755 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
22756 error "create dir2 under hash dir failed"
22758 # unfortunately, we need to umount to clear dir layout cache for now
22759 # once we fully implement dir layout, we can drop this
22760 umount_client $MOUNT || error "umount failed"
22761 mount_client $MOUNT || error "mount failed"
22763 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
22764 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
22765 [ $dircnt -eq 2 ] || error "lfs find striped dir got:$dircnt,except:1"
22767 #set the stripe to be unknown hash type
22768 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
22769 $LCTL set_param fail_loc=0x1901
22770 for ((i = 0; i < 10; i++)); do
22771 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
22772 error "stat f-$i failed"
22773 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
22776 touch $DIR/$tdir/striped_dir/f0 &&
22777 error "create under striped dir with unknown hash should fail"
22779 $LCTL set_param fail_loc=0
22781 umount_client $MOUNT || error "umount failed"
22782 mount_client $MOUNT || error "mount failed"
22786 run_test 300i "client handle unknown hash type striped directory"
22789 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22790 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22791 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22792 skip "Need MDS version at least 2.7.55"
22799 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
22800 $LCTL set_param fail_loc=0x1702
22801 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
22802 error "set striped dir error"
22804 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
22805 error "create files under striped dir failed"
22807 $LCTL set_param fail_loc=0
22809 rm -rf $DIR/$tdir || error "unlink striped dir fails"
22813 run_test 300j "test large update record"
22816 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22817 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22818 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22819 skip "Need MDS version at least 2.7.55"
22821 # this test needs a huge transaction
22823 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
22824 osd*.$FSNAME-MDT0000.kbytestotal")
22825 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
22832 #define OBD_FAIL_LARGE_STRIPE 0x1703
22833 $LCTL set_param fail_loc=0x1703
22834 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
22835 error "set striped dir error"
22836 $LCTL set_param fail_loc=0
22838 $LFS getdirstripe $DIR/$tdir/striped_dir ||
22839 error "getstripeddir fails"
22840 rm -rf $DIR/$tdir/striped_dir ||
22841 error "unlink striped dir fails"
22845 run_test 300k "test large striped directory"
22848 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22849 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22850 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22851 skip "Need MDS version at least 2.7.55"
22855 test_mkdir -p $DIR/$tdir/striped_dir
22856 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
22857 error "chown $RUNAS_ID failed"
22858 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
22859 error "set default striped dir failed"
22861 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
22862 $LCTL set_param fail_loc=0x80000158
22863 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
22865 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
22866 [ $stripe_index -eq 1 ] ||
22867 error "expect 1 get $stripe_index for $dir"
22869 run_test 300l "non-root user to create dir under striped dir with stale layout"
22872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22873 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
22874 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22875 skip "Need MDS version at least 2.7.55"
22877 mkdir -p $DIR/$tdir/striped_dir
22878 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
22879 error "set default stripes dir error"
22881 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
22883 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
22884 [ $stripe_count -eq 0 ] ||
22885 error "expect 0 get $stripe_count for a"
22887 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
22888 error "set default stripes dir error"
22890 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
22892 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
22893 [ $stripe_count -eq 0 ] ||
22894 error "expect 0 get $stripe_count for b"
22896 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
22897 error "set default stripes dir error"
22899 mkdir $DIR/$tdir/striped_dir/c &&
22900 error "default stripe_index is invalid, mkdir c should fails"
22902 rm -rf $DIR/$tdir || error "rmdir fails"
22904 run_test 300m "setstriped directory on single MDT FS"
22907 local list=$(comma_list $(mdts_nodes))
22910 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
22914 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22915 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22916 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22917 skip "Need MDS version at least 2.7.55"
22918 remote_mds_nodsh && skip "remote MDS with nodsh"
22921 local list=$(comma_list $(mdts_nodes))
22923 trap cleanup_300n RETURN EXIT
22924 mkdir -p $DIR/$tdir
22925 chmod 777 $DIR/$tdir
22926 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
22927 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
22928 error "create striped dir succeeds with gid=0"
22930 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
22931 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
22932 error "create striped dir fails with gid=-1"
22934 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
22935 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
22936 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
22937 error "set default striped dir succeeds with gid=0"
22940 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
22941 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
22942 error "set default striped dir fails with gid=-1"
22945 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
22946 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
22947 error "create test_dir fails"
22948 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
22949 error "create test_dir1 fails"
22950 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
22951 error "create test_dir2 fails"
22954 run_test 300n "non-root user to create dir under striped dir with default EA"
22957 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22958 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22959 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
22960 skip "Need MDS version at least 2.7.55"
22965 mkdir -p $DIR/$tdir
22967 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
22968 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
22969 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
22970 skip "not enough free inodes $numfree1 $numfree2"
22973 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
22974 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
22975 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
22976 skip "not enough free space $numfree1 $numfree2"
22979 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
22980 error "setdirstripe fails"
22982 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
22983 error "create dirs fails"
22985 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
22986 ls $DIR/$tdir/striped_dir > /dev/null ||
22987 error "ls striped dir fails"
22988 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
22989 error "unlink big striped dir fails"
22991 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
22994 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22995 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22996 remote_mds_nodsh && skip "remote MDS with nodsh"
22998 mkdir_on_mdt0 $DIR/$tdir
23000 #define OBD_FAIL_OUT_ENOSPC 0x1704
23001 do_facet mds2 lctl set_param fail_loc=0x80001704
23002 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
23003 && error "create striped directory should fail"
23005 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
23007 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
23010 run_test 300p "create striped directory without space"
23013 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23014 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23016 local fd=$(free_fd)
23017 local cmd="exec $fd<$tdir"
23019 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
23022 trap "eval $cmd" EXIT
23023 cd $tdir || error "cd $tdir fails"
23024 rmdir ../$tdir || error "rmdir $tdir fails"
23025 mkdir local_dir && error "create dir succeeds"
23026 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
23030 run_test 300q "create remote directory under orphan directory"
23033 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23034 skip "Need MDS version at least 2.7.55" && return
23035 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23039 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
23040 error "set striped dir error"
23042 $LFS getdirstripe $DIR/$tdir/striped_dir ||
23043 error "getstripeddir fails"
23046 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
23047 awk '/lmv_stripe_count:/ { print $2 }')
23049 [ $MDSCOUNT -ne $stripe_count ] &&
23050 error "wrong stripe count $stripe_count expected $MDSCOUNT"
23052 rm -rf $DIR/$tdir/striped_dir ||
23053 error "unlink striped dir fails"
23055 run_test 300r "test -1 striped directory"
23057 test_300s_helper() {
23060 local stripe_dir=$DIR/$tdir/striped_dir.$count
23062 $LFS mkdir -c $count $stripe_dir ||
23063 error "lfs mkdir -c error"
23065 $LFS getdirstripe $stripe_dir ||
23066 error "lfs getdirstripe fails"
23069 stripe_count=$($LFS getdirstripe $stripe_dir |
23070 awk '/lmv_stripe_count:/ { print $2 }')
23072 [ $count -ne $stripe_count ] &&
23073 error_noexit "bad stripe count $stripe_count expected $count"
23076 dupe_stripes=$($LFS getdirstripe $stripe_dir |
23077 awk '/0x/ {count[$1] += 1}; END {
23078 for (idx in count) {
23079 if (count[idx]>1) {
23080 print "index " idx " count " count[idx]
23085 if [[ -n "$dupe_stripes" ]] ; then
23086 lfs getdirstripe $stripe_dir
23087 error_noexit "Dupe MDT above: $dupe_stripes "
23090 rm -rf $stripe_dir ||
23091 error_noexit "unlink $stripe_dir fails"
23095 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23096 skip "Need MDS version at least 2.7.55" && return
23097 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23100 for count in $(seq 2 $MDSCOUNT); do
23101 test_300s_helper $count
23104 run_test 300s "test lfs mkdir -c without -i"
23107 prepare_remote_file() {
23108 mkdir $DIR/$tdir/src_dir ||
23109 error "create remote source failed"
23111 cp /etc/hosts $DIR/$tdir/src_dir/a ||
23112 error "cp to remote source failed"
23113 touch $DIR/$tdir/src_dir/a
23115 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
23116 error "create remote target dir failed"
23118 touch $DIR/$tdir/tgt_dir/b
23120 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
23121 error "rename dir cross MDT failed!"
23123 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
23124 error "src_child still exists after rename"
23126 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
23127 error "missing file(a) after rename"
23129 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
23130 error "diff after rename"
23134 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
23135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23137 local remote_file=$DIR/$tdir/tgt_dir/b
23139 mkdir -p $DIR/$tdir
23141 prepare_remote_file || error "prepare remote file failed"
23144 $OPENUNLINK $remote_file $remote_file ||
23145 error "openunlink $remote_file failed"
23146 $CHECKSTAT -a $remote_file || error "$remote_file exists"
23148 run_test 310a "open unlink remote file"
23151 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
23152 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23154 local remote_file=$DIR/$tdir/tgt_dir/b
23156 mkdir -p $DIR/$tdir
23158 prepare_remote_file || error "prepare remote file failed"
23160 ln $remote_file $DIR/$tfile || error "link failed for remote file"
23161 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
23162 $CHECKSTAT -t file $remote_file || error "check file failed"
23164 run_test 310b "unlink remote file with multiple links while open"
23167 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23168 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
23170 local remote_file=$DIR/$tdir/tgt_dir/b
23172 mkdir -p $DIR/$tdir
23174 prepare_remote_file || error "prepare remote file failed"
23176 ln $remote_file $DIR/$tfile || error "link failed for remote file"
23177 multiop_bg_pause $remote_file O_uc ||
23178 error "mulitop failed for remote file"
23180 $MULTIOP $DIR/$tfile Ouc
23181 kill -USR1 $MULTIPID
23184 run_test 310c "open-unlink remote file with multiple links"
23188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23189 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
23190 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
23191 skip "lustre < 2.8.54 does not contain LU-4825 fix"
23192 remote_mds_nodsh && skip "remote MDS with nodsh"
23194 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
23195 local mdts=$(comma_list $(mdts_nodes))
23197 mkdir -p $DIR/$tdir
23198 $LFS setstripe -i 0 -c 1 $DIR/$tdir
23199 createmany -o $DIR/$tdir/$tfile. 1000
23201 # statfs data is not real time, let's just calculate it
23202 old_iused=$((old_iused + 1000))
23204 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
23205 osp.*OST0000*MDT0000.create_count")
23206 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
23207 osp.*OST0000*MDT0000.max_create_count")
23208 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
23210 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
23211 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
23212 [ $index -ne 0 ] || error "$tfile stripe index is 0"
23214 unlinkmany $DIR/$tdir/$tfile. 1000
23216 do_nodes $mdts "$LCTL set_param -n \
23217 osp.*OST0000*.max_create_count=$max_count"
23218 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
23219 do_nodes $mdts "$LCTL set_param -n \
23220 osp.*OST0000*.create_count=$count"
23221 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
23222 grep "=0" && error "create_count is zero"
23225 for i in $(seq 120); do
23226 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
23227 # system may be too busy to destroy all objs in time, use
23228 # a somewhat small value to not fail autotest
23229 [ $((old_iused - new_iused)) -gt 400 ] && break
23233 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
23234 [ $((old_iused - new_iused)) -gt 400 ] ||
23235 error "objs not destroyed after unlink"
23237 run_test 311 "disable OSP precreate, and unlink should destroy objs"
23244 local vdevdir=$(dirname $(facet_vdevice $ost))
23245 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
23246 local zfs_zapid=$(do_facet $ost $cmd |
23247 grep -w "/O/0/d$((objid%32))" -C 5 |
23248 awk '/Object/{getline; print $1}')
23249 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
23250 awk "/$objid = /"'{printf $3}')
23255 zfs_object_blksz() {
23259 local vdevdir=$(dirname $(facet_vdevice $ost))
23260 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
23261 local blksz=$(do_facet $ost $cmd $objid |
23262 awk '/dblk/{getline; printf $4}')
23264 case "${blksz: -1}" in
23265 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
23266 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
23273 test_312() { # LU-4856
23274 remote_ost_nodsh && skip "remote OST with nodsh"
23275 [ "$ost1_FSTYPE" = "zfs" ] ||
23276 skip_env "the test only applies to zfs"
23278 local max_blksz=$(do_facet ost1 \
23279 $ZFS get -p recordsize $(facet_device ost1) |
23280 awk '!/VALUE/{print $3}')
23282 # to make life a little bit easier
23283 $LFS mkdir -c 1 -i 0 $DIR/$tdir
23284 $LFS setstripe -c 1 -i 0 $DIR/$tdir
23286 local tf=$DIR/$tdir/$tfile
23288 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
23290 # Get ZFS object id
23291 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
23292 # block size change by sequential overwrite
23295 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
23296 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
23298 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
23299 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
23303 # block size change by sequential append write
23304 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
23305 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
23306 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
23309 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
23310 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
23311 oflag=sync conv=notrunc
23313 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23314 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
23315 error "blksz error, actual $blksz, " \
23316 "expected: 2 * $count * $PAGE_SIZE"
23322 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
23323 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
23325 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
23326 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23327 [ $blksz -eq $PAGE_SIZE ] ||
23328 error "blksz error: $blksz, expected: $PAGE_SIZE"
23330 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
23331 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23332 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
23334 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
23335 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23336 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
23338 run_test 312 "make sure ZFS adjusts its block size by write pattern"
23341 remote_ost_nodsh && skip "remote OST with nodsh"
23343 local file=$DIR/$tfile
23346 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
23348 # define OBD_FAIL_TGT_RCVD_EIO 0x720
23349 do_facet ost1 "$LCTL set_param fail_loc=0x720"
23350 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
23351 error "write should failed"
23352 do_facet ost1 "$LCTL set_param fail_loc=0"
23355 run_test 313 "io should fail after last_rcvd update fail"
23358 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
23360 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
23361 do_facet ost1 "$LCTL set_param fail_loc=0x720"
23363 wait_delete_completed
23364 do_facet ost1 "$LCTL set_param fail_loc=0"
23366 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
23368 test_315() { # LU-618
23369 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
23371 local file=$DIR/$tfile
23374 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
23375 error "multiop file write failed"
23376 $MULTIOP $file oO_RDONLY:r4063232_c &
23381 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
23384 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
23387 run_test 315 "read should be accounted"
23390 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
23391 large_xattr_enabled || skip_env "ea_inode feature disabled"
23393 rm -rf $DIR/$tdir/d
23394 mkdir -p $DIR/$tdir/d
23395 chown nobody $DIR/$tdir/d
23396 touch $DIR/$tdir/d/file
23398 $LFS mv -m1 $DIR/$tdir/d || error "lfs mv failed"
23400 run_test 316 "lfs mv"
23403 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
23404 skip "Need MDS version at least 2.11.53"
23405 if [ "$ost1_FSTYPE" == "zfs" ]; then
23406 skip "LU-10370: no implementation for ZFS"
23410 local grant_blk_size
23412 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
23413 awk '/grant_block_size:/ { print $2; exit; }')
23415 # Create File of size 5M. Truncate it to below size's and verify
23418 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
23419 error "Create file $DIR/$tfile failed"
23420 stack_trap "rm -f $DIR/$tfile" EXIT
23422 for trunc_sz in 2097152 4097 4000 509 0; do
23423 $TRUNCATE $DIR/$tfile $trunc_sz ||
23424 error "truncate $tfile to $trunc_sz failed"
23425 local sz=$(stat --format=%s $DIR/$tfile)
23426 local blk=$(stat --format=%b $DIR/$tfile)
23427 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
23428 grant_blk_size) * 8))
23430 if [[ $blk -ne $trunc_blk ]]; then
23431 $(which stat) $DIR/$tfile
23432 error "Expected Block $trunc_blk got $blk for $tfile"
23435 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
23436 error "Expected Size $trunc_sz got $sz for $tfile"
23441 # Create file with a hole and write actual two blocks. Block count
23444 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
23445 conv=fsync || error "Create file : $DIR/$tfile"
23447 # Calculate the final truncate size.
23448 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
23451 # truncate to size $trunc_sz bytes. Strip the last block
23452 # The block count must drop to 8
23454 $TRUNCATE $DIR/$tfile $trunc_sz ||
23455 error "truncate $tfile to $trunc_sz failed"
23457 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
23458 sz=$(stat --format=%s $DIR/$tfile)
23459 blk=$(stat --format=%b $DIR/$tfile)
23461 if [[ $blk -ne $trunc_bsz ]]; then
23462 $(which stat) $DIR/$tfile
23463 error "Expected Block $trunc_bsz got $blk for $tfile"
23466 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
23467 error "Expected Size $trunc_sz got $sz for $tfile"
23469 run_test 317 "Verify blocks get correctly update after truncate"
23472 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
23473 local old_max_active=$($LCTL get_param -n \
23474 ${llite_name}.max_read_ahead_async_active \
23477 $LCTL set_param llite.*.max_read_ahead_async_active=256
23478 local max_active=$($LCTL get_param -n \
23479 ${llite_name}.max_read_ahead_async_active \
23481 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
23483 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
23484 error "set max_read_ahead_async_active should succeed"
23486 $LCTL set_param llite.*.max_read_ahead_async_active=512
23487 max_active=$($LCTL get_param -n \
23488 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
23489 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
23491 # restore @max_active
23492 [ $old_max_active -ne 0 ] && $LCTL set_param \
23493 llite.*.max_read_ahead_async_active=$old_max_active
23495 local old_threshold=$($LCTL get_param -n \
23496 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
23497 local max_per_file_mb=$($LCTL get_param -n \
23498 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
23500 local invalid=$(($max_per_file_mb + 1))
23502 llite.*.read_ahead_async_file_threshold_mb=$invalid\
23503 && error "set $invalid should fail"
23505 local valid=$(($invalid - 1))
23507 llite.*.read_ahead_async_file_threshold_mb=$valid ||
23508 error "set $valid should succeed"
23509 local threshold=$($LCTL get_param -n \
23510 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
23511 [ $threshold -eq $valid ] || error \
23512 "expect threshold $valid got $threshold"
23514 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
23516 run_test 318 "Verify async readahead tunables"
23519 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
23521 local before=$(date +%s)
23523 local mdir=$DIR/$tdir
23524 local file=$mdir/xxx
23526 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
23529 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
23530 $LCTL set_param fail_val=5 fail_loc=0x8000032c
23531 $LFS mv -m1 $file &
23534 dd if=$file of=/dev/null
23536 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
23537 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
23539 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
23541 run_test 319 "lost lease lock on migrate error"
23543 test_398a() { # LU-4198
23544 local ost1_imp=$(get_osc_import_name client ost1)
23545 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
23548 $LFS setstripe -c 1 -i 0 $DIR/$tfile
23549 $LCTL set_param ldlm.namespaces.*.lru_size=clear
23551 # request a new lock on client
23552 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23554 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
23555 local lock_count=$($LCTL get_param -n \
23556 ldlm.namespaces.$imp_name.lru_size)
23557 [[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
23559 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
23561 # no lock cached, should use lockless IO and not enqueue new lock
23562 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
23563 lock_count=$($LCTL get_param -n \
23564 ldlm.namespaces.$imp_name.lru_size)
23565 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
23567 run_test 398a "direct IO should cancel lock otherwise lockless"
23569 test_398b() { # LU-4198
23570 which fio || skip_env "no fio installed"
23571 $LFS setstripe -c -1 $DIR/$tfile
23574 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
23577 echo "mix direct rw ${size}M to OST0 by fio with $njobs jobs..."
23578 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
23579 --numjobs=$njobs --fallocate=none \
23580 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
23581 --filename=$DIR/$tfile &
23584 echo "mix buffer rw ${size}M to OST0 by fio with $njobs jobs..."
23585 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE \
23586 --numjobs=$njobs --fallocate=none \
23587 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
23588 --filename=$DIR/$tfile || true
23593 run_test 398b "DIO and buffer IO race"
23595 test_398c() { # LU-4198
23596 local ost1_imp=$(get_osc_import_name client ost1)
23597 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
23600 which fio || skip_env "no fio installed"
23602 saved_debug=$($LCTL get_param -n debug)
23603 $LCTL set_param debug=0
23605 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
23606 ((size /= 1024)) # by megabytes
23607 ((size /= 2)) # write half of the OST at most
23608 [ $size -gt 40 ] && size=40 #reduce test time anyway
23610 $LFS setstripe -c 1 $DIR/$tfile
23612 # it seems like ldiskfs reserves more space than necessary if the
23613 # writing blocks are not mapped, so it extends the file firstly
23614 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
23615 cancel_lru_locks osc
23617 # clear and verify rpc_stats later
23618 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
23621 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
23622 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
23623 --numjobs=$njobs --fallocate=none --ioengine=libaio \
23624 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
23625 --filename=$DIR/$tfile
23626 [ $? -eq 0 ] || error "fio write error"
23628 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
23629 error "Locks were requested while doing AIO"
23631 # get the percentage of 1-page I/O
23632 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
23633 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
23635 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
23637 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
23638 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
23639 --numjobs=$njobs --fallocate=none --ioengine=libaio \
23640 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
23641 --filename=$DIR/$tfile
23642 [ $? -eq 0 ] || error "fio mixed read write error"
23644 echo "AIO with large block size ${size}M"
23645 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
23646 --numjobs=1 --fallocate=none --ioengine=libaio \
23647 --iodepth=16 --allow_file_create=0 --size=${size}M \
23648 --filename=$DIR/$tfile
23649 [ $? -eq 0 ] || error "fio large block size failed"
23652 $LCTL set_param debug="$saved_debug"
23654 run_test 398c "run fio to test AIO"
23656 test_398d() { # LU-13846
23657 which aiocp || skip_env "no aiocp installed"
23658 local aio_file=$DIR/$tfile.aio
23660 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
23662 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
23663 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
23664 stack_trap "rm -f $DIR/$tfile $aio_file"
23666 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
23668 # make sure we don't crash and fail properly
23669 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
23670 error "aio not aligned with PAGE SIZE should fail"
23672 rm -f $DIR/$tfile $aio_file
23674 run_test 398d "run aiocp to verify block size > stripe size"
23677 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
23678 touch $DIR/$tfile.new
23679 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
23681 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
23683 test_398f() { # LU-14687
23684 which aiocp || skip_env "no aiocp installed"
23685 local aio_file=$DIR/$tfile.aio
23687 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
23689 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
23690 stack_trap "rm -f $DIR/$tfile $aio_file"
23692 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
23693 $LCTL set_param fail_loc=0x1418
23694 # make sure we don't crash and fail properly
23695 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
23696 error "aio with page allocation failure succeeded"
23697 $LCTL set_param fail_loc=0
23698 diff $DIR/$tfile $aio_file
23699 [[ $? != 0 ]] || error "no diff after failed aiocp"
23701 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
23703 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
23704 # stripe and i/o size must be > stripe size
23705 # Old style synchronous DIO waits after submitting each chunk, resulting in a
23706 # single RPC in flight. This test shows async DIO submission is working by
23707 # showing multiple RPCs in flight.
23708 test_398g() { # LU-13798
23709 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
23711 # We need to do some i/o first to acquire enough grant to put our RPCs
23712 # in flight; otherwise a new connection may not have enough grant
23714 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
23715 error "parallel dio failed"
23716 stack_trap "rm -f $DIR/$tfile"
23718 # Reduce RPC size to 1M to avoid combination in to larger RPCs
23719 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
23720 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
23721 stack_trap "$LCTL set_param -n $pages_per_rpc"
23723 # Recreate file so it's empty
23725 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
23726 #Pause rpc completion to guarantee we see multiple rpcs in flight
23727 #define OBD_FAIL_OST_BRW_PAUSE_BULK
23728 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
23729 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
23732 $LCTL set_param osc.*.rpc_stats=c
23734 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
23735 error "parallel dio failed"
23736 stack_trap "rm -f $DIR/$tfile"
23738 $LCTL get_param osc.*-OST0000-*.rpc_stats
23739 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
23740 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
23741 grep "8:" | awk '{print $8}')
23742 # We look at the "8 rpcs in flight" field, and verify A) it is present
23743 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
23744 # as expected for an 8M DIO to a file with 1M stripes.
23745 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
23747 # Verify turning off parallel dio works as expected
23749 $LCTL set_param osc.*.rpc_stats=c
23750 $LCTL set_param llite.*.parallel_dio=0
23751 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
23753 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
23754 error "dio with parallel dio disabled failed"
23756 # Ideally, we would see only one RPC in flight here, but there is an
23757 # unavoidable race between i/o completion and RPC in flight counting,
23758 # so while only 1 i/o is in flight at a time, the RPC in flight counter
23759 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
23760 # So instead we just verify it's always < 8.
23761 $LCTL get_param osc.*-OST0000-*.rpc_stats
23762 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
23763 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
23764 grep '^$' -B1 | grep . | awk '{print $1}')
23765 [ $ret != "8:" ] ||
23766 error "we should see fewer than 8 RPCs in flight (saw $ret)"
23768 run_test 398g "verify parallel dio async RPC submission"
23770 test_398h() { # LU-13798
23771 local dio_file=$DIR/$tfile.dio
23773 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
23775 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
23776 stack_trap "rm -f $DIR/$tfile $dio_file"
23778 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
23779 error "parallel dio failed"
23780 diff $DIR/$tfile $dio_file
23781 [[ $? == 0 ]] || error "file diff after aiocp"
23783 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
23785 test_398i() { # LU-13798
23786 local dio_file=$DIR/$tfile.dio
23788 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
23790 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
23791 stack_trap "rm -f $DIR/$tfile $dio_file"
23793 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
23794 $LCTL set_param fail_loc=0x1418
23795 # make sure we don't crash and fail properly
23796 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
23797 error "parallel dio page allocation failure succeeded"
23798 diff $DIR/$tfile $dio_file
23799 [[ $? != 0 ]] || error "no diff after failed aiocp"
23801 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
23803 test_398j() { # LU-13798
23804 # Stripe size > RPC size but less than i/o size tests split across
23805 # stripes and RPCs for individual i/o op
23806 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
23808 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
23809 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
23810 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
23811 stack_trap "$LCTL set_param -n $pages_per_rpc"
23813 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
23814 error "parallel dio write failed"
23815 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
23817 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
23818 error "parallel dio read failed"
23819 diff $DIR/$tfile $DIR/$tfile.2
23820 [[ $? == 0 ]] || error "file diff after parallel dio read"
23822 run_test 398j "test parallel dio where stripe size > rpc_size"
23824 test_398k() { # LU-13798
23825 wait_delete_completed
23828 # 4 stripe file; we will cause out of space on OST0
23829 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
23831 # Fill OST0 (if it's not too large)
23832 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
23834 if [[ $ORIGFREE -gt $MAXFREE ]]; then
23835 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
23837 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
23838 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
23839 error "dd should fill OST0"
23840 stack_trap "rm -f $DIR/$tfile.1"
23842 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
23846 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
23847 error "file is not 0 bytes in size"
23849 # dd above should not succeed, but don't error until here so we can
23850 # get debug info above
23852 error "parallel dio write with enospc succeeded"
23853 stack_trap "rm -f $DIR/$tfile"
23855 run_test 398k "test enospc on first stripe"
23857 test_398l() { # LU-13798
23858 wait_delete_completed
23861 # 4 stripe file; we will cause out of space on OST0
23862 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
23863 # happens on the second i/o chunk we issue
23864 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
23866 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
23867 stack_trap "rm -f $DIR/$tfile"
23869 # Fill OST0 (if it's not too large)
23870 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
23872 if [[ $ORIGFREE -gt $MAXFREE ]]; then
23873 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
23875 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
23876 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
23877 error "dd should fill OST0"
23878 stack_trap "rm -f $DIR/$tfile.1"
23880 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
23882 stack_trap "rm -f $DIR/$tfile.2"
23884 # Check that short write completed as expected
23885 ls -la $DIR/$tfile.2
23886 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
23887 error "file is not 1M in size"
23889 # dd above should not succeed, but don't error until here so we can
23890 # get debug info above
23892 error "parallel dio write with enospc succeeded"
23894 # Truncate source file to same length as output file and diff them
23895 $TRUNCATE $DIR/$tfile 1048576
23896 diff $DIR/$tfile $DIR/$tfile.2
23897 [[ $? == 0 ]] || error "data incorrect after short write"
23899 run_test 398l "test enospc on intermediate stripe/RPC"
23901 test_398m() { # LU-13798
23902 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
23904 # Set up failure on OST0, the first stripe:
23905 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
23906 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
23907 # So this fail_val specifies OST0
23908 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
23909 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
23911 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
23912 error "parallel dio write with failure on first stripe succeeded"
23913 stack_trap "rm -f $DIR/$tfile"
23914 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
23916 # Place data in file for read
23917 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
23918 error "parallel dio write failed"
23920 # Fail read on OST0, first stripe
23921 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
23922 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
23923 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
23924 error "parallel dio read with error on first stripe succeeded"
23925 rm -f $DIR/$tfile.2
23926 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
23928 # Switch to testing on OST1, second stripe
23929 # Clear file contents, maintain striping
23931 # Set up failure on OST1, second stripe:
23932 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=2
23933 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
23935 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
23936 error "parallel dio write with failure on first stripe succeeded"
23937 stack_trap "rm -f $DIR/$tfile"
23938 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
23940 # Place data in file for read
23941 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
23942 error "parallel dio write failed"
23944 # Fail read on OST1, second stripe
23945 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
23946 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
23947 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
23948 error "parallel dio read with error on first stripe succeeded"
23949 rm -f $DIR/$tfile.2
23950 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
23952 run_test 398m "test RPC failures with parallel dio"
23954 # Parallel submission of DIO should not cause problems for append, but it's
23955 # important to verify.
23956 test_398n() { # LU-13798
23957 $LFS setstripe -C 2 -S 1M $DIR/$tfile
23959 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
23960 error "dd to create source file failed"
23961 stack_trap "rm -f $DIR/$tfile"
23963 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
23964 error "parallel dio write with failure on second stripe succeeded"
23965 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
23966 diff $DIR/$tfile $DIR/$tfile.1
23967 [[ $? == 0 ]] || error "data incorrect after append"
23970 run_test 398n "test append with parallel DIO"
23973 local read_write=$1
23974 if [ "$read_write" = "write" ]; then
23975 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
23976 elif [ "$read_write" = "read" ]; then
23977 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
23979 error "argument error"
23982 # turn off debug for performance testing
23983 local saved_debug=$($LCTL get_param -n debug)
23984 $LCTL set_param debug=0
23986 $LFS setstripe -c 1 -i 0 $DIR/$tfile
23988 # get ost1 size - $FSNAME-OST0000
23989 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
23990 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
23991 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
23993 if [ "$read_write" = "read" ]; then
23994 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
23997 local start_time=$(date +%s.%N)
23998 $dd_cmd bs=1M count=$blocks oflag=sync ||
23999 error "real dd $read_write error"
24000 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
24002 if [ "$read_write" = "write" ]; then
24006 # define OBD_FAIL_OST_FAKE_RW 0x238
24007 do_facet ost1 $LCTL set_param fail_loc=0x238
24009 local start_time=$(date +%s.%N)
24010 $dd_cmd bs=1M count=$blocks oflag=sync ||
24011 error "fake dd $read_write error"
24012 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
24014 if [ "$read_write" = "write" ]; then
24016 cancel_lru_locks osc
24017 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
24018 error "$tfile size not $blocks MB"
24020 do_facet ost1 $LCTL set_param fail_loc=0
24022 echo "fake $read_write $duration_fake vs. normal $read_write" \
24023 "$duration in seconds"
24024 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
24025 error_not_in_vm "fake write is slower"
24027 $LCTL set_param -n debug="$saved_debug"
24030 test_399a() { # LU-7655 for OST fake write
24031 remote_ost_nodsh && skip "remote OST with nodsh"
24035 run_test 399a "fake write should not be slower than normal write"
24037 test_399b() { # LU-8726 for OST fake read
24038 remote_ost_nodsh && skip "remote OST with nodsh"
24039 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
24040 skip_env "ldiskfs only test"
24045 run_test 399b "fake read should not be slower than normal read"
24047 test_400a() { # LU-1606, was conf-sanity test_74
24048 if ! which $CC > /dev/null 2>&1; then
24049 skip_env "$CC is not installed"
24052 local extra_flags=''
24053 local out=$TMP/$tfile
24054 local prefix=/usr/include/lustre
24057 # Oleg removes c files in his test rig so test if any c files exist
24058 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
24059 skip_env "Needed c test files are missing"
24061 if ! [[ -d $prefix ]]; then
24062 # Assume we're running in tree and fixup the include path.
24063 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
24064 extra_flags+=" -L$LUSTRE/utils/.lib"
24067 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
24068 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
24069 error "client api broken"
24073 run_test 400a "Lustre client api program can compile and link"
24075 test_400b() { # LU-1606, LU-5011
24077 local out=$TMP/$tfile
24078 local prefix=/usr/include/linux/lustre
24080 # We use a hard coded prefix so that this test will not fail
24081 # when run in tree. There are headers in lustre/include/lustre/
24082 # that are not packaged (like lustre_idl.h) and have more
24083 # complicated include dependencies (like config.h and lnet/types.h).
24084 # Since this test about correct packaging we just skip them when
24085 # they don't exist (see below) rather than try to fixup cppflags.
24087 if ! which $CC > /dev/null 2>&1; then
24088 skip_env "$CC is not installed"
24091 for header in $prefix/*.h; do
24092 if ! [[ -f "$header" ]]; then
24096 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
24097 continue # lustre_ioctl.h is internal header
24100 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
24101 error "cannot compile '$header'"
24105 run_test 400b "packaged headers can be compiled"
24107 test_401a() { #LU-7437
24108 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
24109 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
24111 #count the number of parameters by "list_param -R"
24112 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
24113 #count the number of parameters by listing proc files
24114 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
24115 echo "proc_dirs='$proc_dirs'"
24116 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
24117 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
24120 [ $params -eq $procs ] ||
24121 error "found $params parameters vs. $procs proc files"
24123 # test the list_param -D option only returns directories
24124 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
24125 #count the number of parameters by listing proc directories
24126 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
24129 [ $params -eq $procs ] ||
24130 error "found $params parameters vs. $procs proc files"
24132 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
24135 # jobid_var may not allow arbitrary values, so use jobid_name
24137 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24138 local testname=jobid_name tmp='testing%p'
24140 local testname=jobid_var tmp=testing
24143 local save=$($LCTL get_param -n $testname)
24145 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
24146 error "no error returned when setting bad parameters"
24148 local jobid_new=$($LCTL get_param -n foe $testname baz)
24149 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
24151 $LCTL set_param -n fog=bam $testname=$save bat=fog
24152 local jobid_old=$($LCTL get_param -n foe $testname bag)
24153 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
24155 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
24158 # jobid_var may not allow arbitrary values, so use jobid_name
24160 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24161 local testname=jobid_name
24163 local testname=jobid_var
24166 local jobid_var_old=$($LCTL get_param -n $testname)
24167 local jobid_var_new
24169 $LCTL set_param $testname= &&
24170 error "no error returned for 'set_param a='"
24172 jobid_var_new=$($LCTL get_param -n $testname)
24173 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
24174 error "$testname was changed by setting without value"
24176 $LCTL set_param $testname &&
24177 error "no error returned for 'set_param a'"
24179 jobid_var_new=$($LCTL get_param -n $testname)
24180 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
24181 error "$testname was changed by setting without value"
24183 run_test 401c "Verify 'lctl set_param' without value fails in either format."
24186 # jobid_var may not allow arbitrary values, so use jobid_name
24188 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24189 local testname=jobid_name new_value='foo=bar%p'
24191 local testname=jobid_var new_valuie=foo=bar
24194 local jobid_var_old=$($LCTL get_param -n $testname)
24195 local jobid_var_new
24197 $LCTL set_param $testname=$new_value ||
24198 error "'set_param a=b' did not accept a value containing '='"
24200 jobid_var_new=$($LCTL get_param -n $testname)
24201 [[ "$jobid_var_new" == "$new_value" ]] ||
24202 error "'set_param a=b' failed on a value containing '='"
24204 # Reset the $testname to test the other format
24205 $LCTL set_param $testname=$jobid_var_old
24206 jobid_var_new=$($LCTL get_param -n $testname)
24207 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
24208 error "failed to reset $testname"
24210 $LCTL set_param $testname $new_value ||
24211 error "'set_param a b' did not accept a value containing '='"
24213 jobid_var_new=$($LCTL get_param -n $testname)
24214 [[ "$jobid_var_new" == "$new_value" ]] ||
24215 error "'set_param a b' failed on a value containing '='"
24217 $LCTL set_param $testname $jobid_var_old
24218 jobid_var_new=$($LCTL get_param -n $testname)
24219 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
24220 error "failed to reset $testname"
24222 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
24224 test_401e() { # LU-14779
24225 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
24226 error "lctl list_param MGC* failed"
24227 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
24228 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
24229 error "lctl get_param lru_size failed"
24231 run_test 401e "verify 'lctl get_param' works with NID in parameter"
24234 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
24235 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
24236 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
24237 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
24238 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
24239 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
24240 remote_mds_nodsh && skip "remote MDS with nodsh"
24242 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
24243 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
24244 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
24245 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
24246 echo "Touch failed - OK"
24248 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
24251 local file1=$DIR/$tfile.1
24252 local file2=$DIR/$tfile.2
24253 local tfile=$TMP/$tfile
24255 rm -f $file1 $file2 $tfile
24260 # 30 sec OBD_TIMEOUT in ll_getattr()
24261 # right before populating st_nlink
24262 $LCTL set_param fail_loc=0x80001409
24263 stat -c %h $file1 > $tfile &
24265 # create an alias, drop all locks and reclaim the dentry
24267 cancel_lru_locks mdc
24268 cancel_lru_locks osc
24269 sysctl -w vm.drop_caches=2
24273 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
24275 rm -f $tfile $file1 $file2
24277 run_test 403 "i_nlink should not drop to zero due to aliasing"
24279 test_404() { # LU-6601
24280 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
24281 skip "Need server version newer than 2.8.52"
24282 remote_mds_nodsh && skip "remote MDS with nodsh"
24284 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
24285 awk '/osp .*-osc-MDT/ { print $4}')
24288 for osp in $mosps; do
24289 echo "Deactivate: " $osp
24290 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
24291 local stat=$(do_facet $SINGLEMDS $LCTL dl |
24292 awk -vp=$osp '$4 == p { print $2 }')
24293 [ $stat = IN ] || {
24294 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
24295 error "deactivate error"
24297 echo "Activate: " $osp
24298 do_facet $SINGLEMDS $LCTL --device %$osp activate
24299 local stat=$(do_facet $SINGLEMDS $LCTL dl |
24300 awk -vp=$osp '$4 == p { print $2 }')
24301 [ $stat = UP ] || {
24302 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
24303 error "activate error"
24307 run_test 404 "validate manual {de}activated works properly for OSPs"
24310 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
24311 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
24312 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
24313 skip "Layout swap lock is not supported"
24315 check_swap_layouts_support
24316 check_swap_layout_no_dom $DIR
24318 test_mkdir $DIR/$tdir
24319 swap_lock_test -d $DIR/$tdir ||
24320 error "One layout swap locked test failed"
24322 run_test 405 "Various layout swap lock tests"
24325 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24326 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
24327 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
24328 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24329 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
24330 skip "Need MDS version at least 2.8.50"
24332 local def_stripe_size=$($LFS getstripe -S $MOUNT)
24333 local test_pool=$TESTNAME
24335 pool_add $test_pool || error "pool_add failed"
24336 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
24337 error "pool_add_targets failed"
24339 save_layout_restore_at_exit $MOUNT
24341 # parent set default stripe count only, child will stripe from both
24342 # parent and fs default
24343 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
24344 error "setstripe $MOUNT failed"
24345 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
24346 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
24347 for i in $(seq 10); do
24348 local f=$DIR/$tdir/$tfile.$i
24349 touch $f || error "touch failed"
24350 local count=$($LFS getstripe -c $f)
24351 [ $count -eq $OSTCOUNT ] ||
24352 error "$f stripe count $count != $OSTCOUNT"
24353 local offset=$($LFS getstripe -i $f)
24354 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
24355 local size=$($LFS getstripe -S $f)
24356 [ $size -eq $((def_stripe_size * 2)) ] ||
24357 error "$f stripe size $size != $((def_stripe_size * 2))"
24358 local pool=$($LFS getstripe -p $f)
24359 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
24362 # change fs default striping, delete parent default striping, now child
24363 # will stripe from new fs default striping only
24364 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
24365 error "change $MOUNT default stripe failed"
24366 $LFS setstripe -c 0 $DIR/$tdir ||
24367 error "delete $tdir default stripe failed"
24368 for i in $(seq 11 20); do
24369 local f=$DIR/$tdir/$tfile.$i
24370 touch $f || error "touch $f failed"
24371 local count=$($LFS getstripe -c $f)
24372 [ $count -eq 1 ] || error "$f stripe count $count != 1"
24373 local offset=$($LFS getstripe -i $f)
24374 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
24375 local size=$($LFS getstripe -S $f)
24376 [ $size -eq $def_stripe_size ] ||
24377 error "$f stripe size $size != $def_stripe_size"
24378 local pool=$($LFS getstripe -p $f)
24379 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
24382 unlinkmany $DIR/$tdir/$tfile. 1 20
24384 local f=$DIR/$tdir/$tfile
24385 pool_remove_all_targets $test_pool $f
24386 pool_remove $test_pool $f
24388 run_test 406 "DNE support fs default striping"
24391 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24392 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
24393 skip "Need MDS version at least 2.8.55"
24394 remote_mds_nodsh && skip "remote MDS with nodsh"
24396 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
24397 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
24398 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
24399 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
24400 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
24402 #define OBD_FAIL_DT_TXN_STOP 0x2019
24403 for idx in $(seq $MDSCOUNT); do
24404 do_facet mds$idx "lctl set_param fail_loc=0x2019"
24406 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
24407 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
24408 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
24411 run_test 407 "transaction fail should cause operation fail"
24414 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
24416 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
24417 lctl set_param fail_loc=0x8000040a
24418 # let ll_prepare_partial_page() fail
24419 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
24423 # create at least 100 unused inodes so that
24424 # shrink_icache_memory(0) should not return 0
24425 touch $DIR/$tfile-{0..100}
24426 rm -f $DIR/$tfile-{0..100}
24429 echo 2 > /proc/sys/vm/drop_caches
24431 run_test 408 "drop_caches should not hang due to page leaks"
24435 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
24437 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
24438 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
24439 touch $DIR/$tdir/guard || error "(2) Fail to create"
24441 local PREFIX=$(str_repeat 'A' 128)
24442 echo "Create 1K hard links start at $(date)"
24443 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
24444 error "(3) Fail to hard link"
24446 echo "Links count should be right although linkEA overflow"
24447 stat $DIR/$tdir/guard || error "(4) Fail to stat"
24448 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
24449 [ $linkcount -eq 1001 ] ||
24450 error "(5) Unexpected hard links count: $linkcount"
24452 echo "List all links start at $(date)"
24453 ls -l $DIR/$tdir/foo > /dev/null ||
24454 error "(6) Fail to list $DIR/$tdir/foo"
24456 echo "Unlink hard links start at $(date)"
24457 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
24458 error "(7) Fail to unlink"
24459 echo "Unlink hard links finished at $(date)"
24461 run_test 409 "Large amount of cross-MDTs hard links on the same file"
24465 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
24466 skip "Need client version at least 2.9.59"
24467 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
24468 skip "Need MODULES build"
24470 # Create a file, and stat it from the kernel
24471 local testfile=$DIR/$tfile
24474 local run_id=$RANDOM
24475 local my_ino=$(stat --format "%i" $testfile)
24477 # Try to insert the module. This will always fail as the
24478 # module is designed to not be inserted.
24479 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
24482 # Anything but success is a test failure
24484 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
24485 error "no inode match"
24487 run_test 410 "Test inode number returned from kernel thread"
24489 cleanup_test411_cgroup() {
24495 local cg_basedir=/sys/fs/cgroup/memory
24497 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
24498 skip "no setup for cgroup"
24500 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
24501 error "test file creation failed"
24502 cancel_lru_locks osc
24504 # Create a very small memory cgroup to force a slab allocation error
24505 local cgdir=$cg_basedir/osc_slab_alloc
24506 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
24507 trap "cleanup_test411_cgroup $cgdir" EXIT
24508 echo 2M > $cgdir/memory.kmem.limit_in_bytes
24509 echo 1M > $cgdir/memory.limit_in_bytes
24511 # Should not LBUG, just be killed by oom-killer
24512 # dd will return 0 even allocation failure in some environment.
24513 # So don't check return value
24514 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
24515 cleanup_test411_cgroup $cgdir
24519 run_test 411 "Slab allocation error with cgroup does not LBUG"
24522 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24523 if [ $MDS1_VERSION -lt $(version_code 2.10.55) ]; then
24524 skip "Need server version at least 2.10.55"
24527 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
24528 error "mkdir failed"
24529 $LFS getdirstripe $DIR/$tdir
24530 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
24531 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
24532 error "expect $((MDSCOUT - 1)) get $stripe_index"
24533 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
24534 [ $stripe_count -eq 2 ] ||
24535 error "expect 2 get $stripe_count"
24537 run_test 412 "mkdir on specific MDTs"
24539 generate_uneven_mdts() {
24551 echo "Check for uneven MDTs: "
24553 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
24554 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
24555 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
24557 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
24558 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
24561 for ((i = 1; i < ${#ffree[@]}; i++)); do
24562 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
24563 if [ $tmp -gt $max ]; then
24567 if [ $tmp -lt $min ]; then
24573 # Check if we need to generate uneven MDTs
24574 local diff=$(((max - min) * 100 / min))
24575 local testdir=$DIR/$tdir-fillmdt
24580 while (( diff < threshold )); do
24581 # generate uneven MDTs, create till $threshold% diff
24582 echo -n "weight diff=$diff% must be > $threshold% ..."
24583 echo "Fill MDT$min_index with 100 files: loop $i"
24584 testdir=$DIR/$tdir-fillmdt/$i
24585 [ -d $testdir ] || $LFS mkdir -i $min_index $testdir ||
24586 error "mkdir $testdir failed"
24587 $LFS setstripe -E 1M -L mdt $testdir ||
24588 error "setstripe $testdir failed"
24589 for F in f.{0..99}; do
24590 dd if=/dev/zero of=$testdir/$F bs=1M count=1 > \
24591 /dev/null 2>&1 || error "dd $F failed"
24594 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
24595 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
24596 max=$(((${ffree[max_index]} >> 8) * \
24597 (${bavail[max_index]} * bsize >> 16)))
24598 min=$(((${ffree[min_index]} >> 8) * \
24599 (${bavail[min_index]} * bsize >> 16)))
24600 diff=$(((max - min) * 100 / min))
24604 echo "MDT filesfree available: ${ffree[@]}"
24605 echo "MDT blocks available: ${bavail[@]}"
24606 echo "weight diff=$diff%"
24611 local stripe_count=$2
24612 local mdts=$(comma_list $(mdts_nodes))
24615 local lmv_qos_prio_free
24616 local lmv_qos_threshold_rr
24617 local lmv_qos_maxage
24618 local lod_qos_prio_free
24619 local lod_qos_threshold_rr
24620 local lod_qos_maxage
24624 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
24625 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
24626 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
24628 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
24629 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
24630 stack_trap "$LCTL set_param \
24631 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
24632 stack_trap "$LCTL set_param \
24633 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
24634 stack_trap "$LCTL set_param \
24635 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
24637 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
24638 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
24639 lod_qos_prio_free=${lod_qos_prio_free%%%}
24640 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
24641 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
24642 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
24643 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
24644 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
24645 stack_trap "do_nodes $mdts $LCTL set_param \
24646 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
24647 stack_trap "do_nodes $mdts $LCTL set_param \
24648 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
24649 stack_trap "do_nodes $mdts $LCTL set_param \
24650 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
24652 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
24653 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
24655 testdir=$DIR/$tdir-s$stripe_count/rr
24657 local stripe_index=$($LFS getstripe -m $testdir)
24658 local test_mkdir_rr=true
24660 echo "dirstripe: '$($LFS getdirstripe $testdir)'"
24661 getfattr -d -m dmv -e hex $testdir | grep dmv
24662 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
24663 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
24664 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
24665 test_mkdir_rr=false
24670 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
24671 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
24673 stack_trap "unlinkmany -d $testdir/subdir $((100 * MDSCOUNT))"
24674 for (( i = 0; i < 100 * MDSCOUNT; i++ )); do
24675 eval $mkdir_cmd $testdir/subdir$i ||
24676 error "$mkdir_cmd subdir$i failed"
24679 for (( i = 0; i < $MDSCOUNT; i++ )); do
24680 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
24681 echo "$count directories created on MDT$i"
24682 if $test_mkdir_rr; then
24683 (( $count == 100 )) ||
24684 error "subdirs are not evenly distributed"
24685 elif (( $i == $stripe_index )); then
24686 (( $count == 100 * MDSCOUNT )) ||
24687 error "$count subdirs created on MDT$i"
24689 (( $count == 0 )) ||
24690 error "$count subdirs created on MDT$i"
24693 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
24694 count=$($LFS getdirstripe $testdir/* |
24695 grep -c -P "^\s+$i\t")
24696 echo "$count stripes created on MDT$i"
24697 # deviation should < 5% of average
24698 (( $count >= 95 * stripe_count &&
24699 $count <= 105 * stripe_count)) ||
24700 error "stripes are not evenly distributed"
24705 echo "Check for uneven MDTs: "
24715 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
24716 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
24717 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
24719 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
24720 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
24723 for ((i = 1; i < ${#ffree[@]}; i++)); do
24724 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
24725 if [ $tmp -gt $max ]; then
24729 if [ $tmp -lt $min ]; then
24735 (( ${ffree[min_index]} > 0 )) ||
24736 skip "no free files in MDT$min_index"
24737 (( ${ffree[min_index]} < 100000000 )) ||
24738 skip "too many free files in MDT$min_index"
24740 echo "MDT filesfree available: ${ffree[@]}"
24741 echo "MDT blocks available: ${bavail[@]}"
24742 echo "weight diff=$(((max - min) * 100 / min))%"
24744 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
24746 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
24747 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
24748 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
24749 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
24750 # decrease statfs age, so that it can be updated in time
24751 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
24752 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
24756 testdir=$DIR/$tdir-s$stripe_count/qos
24759 stack_trap "unlinkmany -d $testdir/subdir $((num * MDSCOUNT))"
24760 for (( i = 0; i < num * MDSCOUNT; i++ )); do
24761 eval $mkdir_cmd $testdir/subdir$i ||
24762 error "$mkdir_cmd subdir$i failed"
24765 for (( i = 0; i < $MDSCOUNT; i++ )); do
24766 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
24767 echo "$count directories created on MDT$i"
24769 if [ $stripe_count -gt 1 ]; then
24770 count=$($LFS getdirstripe $testdir/* |
24771 grep -c -P "^\s+$i\t")
24772 echo "$count stripes created on MDT$i"
24776 max=$($LFS getdirstripe -i $testdir/* | grep -c "^$max_index$")
24777 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
24779 # D-value should > 10% of averge
24780 (( max - min >= num / 10 )) ||
24781 error "subdirs shouldn't be evenly distributed: $max - $min < $((num / 10))"
24784 if (( stripe_count > 1 )); then
24785 max=$($LFS getdirstripe $testdir/* |
24786 grep -c -P "^\s+$max_index\t")
24787 min=$($LFS getdirstripe $testdir/* |
24788 grep -c -P "^\s+$min_index\t")
24789 (( max - min >= num * stripe_count / 20 )) ||
24790 error "stripes shouldn't be evenly distributed: $max - $min < $((num / 20)) * $stripe_count"
24802 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
24803 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
24804 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
24806 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
24808 for ((i = 1; i < ${#ffree[@]}; i++)); do
24809 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
24810 (( tmp < min )) && min=$tmp && min_index=$i
24817 [ $MDSCOUNT -lt 2 ] &&
24818 skip "We need at least 2 MDTs for this test"
24820 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
24821 skip "Need server version at least 2.12.52"
24825 generate_uneven_mdts 100
24826 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
24827 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
24828 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
24829 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
24830 error "mkdir failed"
24831 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
24834 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
24837 [ $MDSCOUNT -lt 2 ] &&
24838 skip "We need at least 2 MDTs for this test"
24840 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
24841 skip "Need server version at least 2.12.52"
24846 generate_uneven_mdts 100
24847 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
24848 testdir=$DIR/$tdir-s$stripe_count
24849 mkdir $testdir || error "mkdir $testdir failed"
24850 mkdir $testdir/rr || error "mkdir rr failed"
24851 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
24852 error "mkdir qos failed"
24853 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
24854 $testdir/rr || error "setdirstripe rr failed"
24855 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
24856 error "setdirstripe failed"
24857 test_qos_mkdir "mkdir" $stripe_count
24860 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
24863 (( $MDSCOUNT >= 2 )) ||
24864 skip "We need at least 2 MDTs for this test"
24866 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
24867 skip "Need server version at least 2.14.51"
24873 testdir=$DIR/${tdir}-s1
24874 mkdir $testdir || error "mkdir $testdir failed"
24875 mkdir $testdir/rr || error "mkdir rr failed"
24876 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
24877 # default max_inherit is -1, default max_inherit_rr is 0
24878 $LFS setdirstripe -D -c 1 $testdir/rr ||
24879 error "setdirstripe rr failed"
24880 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
24881 error "setdirstripe qos failed"
24882 test_qos_mkdir "mkdir" 1
24884 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
24885 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
24886 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
24887 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
24888 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
24890 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
24891 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
24892 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
24893 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
24894 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
24895 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
24896 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
24897 error "level2 shouldn't have default LMV" || true
24899 run_test 413c "mkdir with default LMV max inherit rr"
24902 (( MDSCOUNT >= 2 )) ||
24903 skip "We need at least 2 MDTs for this test"
24905 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
24906 skip "Need server version at least 2.14.51"
24908 local lmv_qos_threshold_rr
24910 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
24912 stack_trap "$LCTL set_param \
24913 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
24915 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
24916 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
24917 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
24918 error "$tdir shouldn't have default LMV"
24919 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
24920 error "mkdir sub failed"
24922 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
24924 (( count == 100 )) || error "$count subdirs on MDT0"
24926 run_test 413d "inherit ROOT default LMV"
24933 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
24934 unlinkmany $subdir/f. 100 &
24938 for pid in $pids; do
24942 run_test 413z "413 test cleanup"
24945 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
24946 $LCTL set_param fail_loc=0x80000521
24947 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
24950 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
24953 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24954 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
24955 skip "Need server version at least 2.11.52"
24965 # this test may be slow on ZFS
24966 [ "$mds1_FSTYPE" == "zfs" ] && total=100
24968 # though this test is designed for striped directory, let's test normal
24969 # directory too since lock is always saved as CoS lock.
24970 test_mkdir $DIR/$tdir || error "mkdir $tdir"
24971 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
24980 start_time=$(date +%s)
24981 for i in $(seq $total); do
24982 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
24985 end_time=$(date +%s)
24986 duration=$((end_time - start_time))
24988 kill -9 $setattr_pid
24990 echo "rename $total files took $duration sec"
24991 [ $duration -lt 100 ] || error "rename took $duration sec"
24993 run_test 415 "lock revoke is not missing"
24996 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
24997 skip "Need server version at least 2.11.55"
24999 # define OBD_FAIL_OSD_TXN_START 0x19a
25000 do_facet mds1 lctl set_param fail_loc=0x19a
25002 lfs mkdir -c $MDSCOUNT $DIR/$tdir
25006 run_test 416 "transaction start failure won't cause system hung"
25010 do_nodes $(comma_list $(mdts_nodes)) \
25011 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
25012 do_nodes $(comma_list $(mdts_nodes)) \
25013 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
25014 do_nodes $(comma_list $(mdts_nodes)) \
25015 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
25019 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25020 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
25021 skip "Need MDS version at least 2.11.56"
25023 trap cleanup_417 RETURN EXIT
25025 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
25026 do_nodes $(comma_list $(mdts_nodes)) \
25027 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
25028 $LFS migrate -m 0 $DIR/$tdir.1 &&
25029 error "migrate dir $tdir.1 should fail"
25031 do_nodes $(comma_list $(mdts_nodes)) \
25032 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
25033 $LFS mkdir -i 1 $DIR/$tdir.2 &&
25034 error "create remote dir $tdir.2 should fail"
25036 do_nodes $(comma_list $(mdts_nodes)) \
25037 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
25038 $LFS mkdir -c 2 $DIR/$tdir.3 &&
25039 error "create striped dir $tdir.3 should fail"
25042 run_test 417 "disable remote dir, striped dir and dir migration"
25044 # Checks that the outputs of df [-i] and lfs df [-i] match
25046 # usage: check_lfs_df <blocks | inodes> <mountpoint>
25056 [ "$1" == "blocks" ] && inodes= || inodes="-i"
25058 for count in {1..100}; do
25062 # read the lines of interest
25063 df_out=($(df -P $inodes $dir | tail -n +2)) ||
25064 error "df $inodes $dir | tail -n +2 failed"
25065 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
25066 error "lfs df $inodes $dir | grep summary: failed"
25068 # skip first substrings of each output as they are different
25069 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
25070 # compare the two outputs
25072 for i in {1..5}; do
25073 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
25081 lfs df $inodes $dir
25082 error "df and lfs df $1 output mismatch: " \
25083 "df ${inodes}: ${df_out[*]}, " \
25084 "lfs df ${inodes}: ${lfs_df_out[*]}"
25089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25091 local dir=$DIR/$tdir
25092 local numfiles=$((RANDOM % 4096 + 2))
25093 local numblocks=$((RANDOM % 256 + 1))
25095 wait_delete_completed
25098 # check block output
25099 check_lfs_df blocks $dir
25100 # check inode output
25101 check_lfs_df inodes $dir
25103 # create a single file and retest
25104 echo "Creating a single file and testing"
25105 createmany -o $dir/$tfile- 1 &>/dev/null ||
25106 error "creating 1 file in $dir failed"
25107 check_lfs_df blocks $dir
25108 check_lfs_df inodes $dir
25110 # create a random number of files
25111 echo "Creating $((numfiles - 1)) files and testing"
25112 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
25113 error "creating $((numfiles - 1)) files in $dir failed"
25115 # write a random number of blocks to the first test file
25116 echo "Writing $numblocks 4K blocks and testing"
25117 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
25118 count=$numblocks &>/dev/null ||
25119 error "dd to $dir/${tfile}-0 failed"
25122 check_lfs_df blocks $dir
25123 check_lfs_df inodes $dir
25125 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
25126 error "unlinking $numfiles files in $dir failed"
25128 run_test 418 "df and lfs df outputs match"
25132 local dir=$DIR/$tdir
25137 cancel_lru_locks mdc
25139 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
25140 $LCTL set_param fail_loc=0x1410
25142 $LCTL set_param fail_loc=0
25145 run_test 419 "Verify open file by name doesn't crash kernel"
25149 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
25150 skip "Need MDS version at least 2.12.53"
25152 local SAVE_UMASK=$(umask)
25153 local dir=$DIR/$tdir
25154 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
25158 mkdir -m03777 $dir/testdir
25159 ls -dn $dir/testdir
25160 # Need to remove trailing '.' when SELinux is enabled
25161 local dirperms=$(ls -dn $dir/testdir |
25162 awk '{ sub(/\.$/, "", $1); print $1}')
25163 [ $dirperms == "drwxrwsrwt" ] ||
25164 error "incorrect perms on $dir/testdir"
25166 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
25167 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
25168 ls -n $dir/testdir/testfile
25169 local fileperms=$(ls -n $dir/testdir/testfile |
25170 awk '{ sub(/\.$/, "", $1); print $1}')
25171 [ $fileperms == "-rwxr-xr-x" ] ||
25172 error "incorrect perms on $dir/testdir/testfile"
25176 run_test 420 "clear SGID bit on non-directories for non-members"
25183 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25184 skip "Need MDS version at least 2.12.54"
25186 test_mkdir $DIR/$tdir
25187 createmany -o $DIR/$tdir/f 3
25188 cnt=$(ls -1 $DIR/$tdir | wc -l)
25189 [ $cnt != 3 ] && error "unexpected #files: $cnt"
25191 fid1=$(lfs path2fid $DIR/$tdir/f1)
25192 fid2=$(lfs path2fid $DIR/$tdir/f2)
25193 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
25195 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
25196 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
25198 cnt=$(ls -1 $DIR/$tdir | wc -l)
25199 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
25201 rm -f $DIR/$tdir/f3 || error "can't remove f3"
25202 createmany -o $DIR/$tdir/f 3
25203 cnt=$(ls -1 $DIR/$tdir | wc -l)
25204 [ $cnt != 3 ] && error "unexpected #files: $cnt"
25206 fid1=$(lfs path2fid $DIR/$tdir/f1)
25207 fid2=$(lfs path2fid $DIR/$tdir/f2)
25208 echo "remove using fsname $FSNAME"
25209 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
25211 cnt=$(ls -1 $DIR/$tdir | wc -l)
25212 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
25214 run_test 421a "simple rm by fid"
25221 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25222 skip "Need MDS version at least 2.12.54"
25224 test_mkdir $DIR/$tdir
25225 createmany -o $DIR/$tdir/f 3
25226 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
25229 FID1=$(lfs path2fid $DIR/$tdir/f1)
25230 FID2=$(lfs path2fid $DIR/$tdir/f2)
25231 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
25233 kill -USR1 $MULTIPID
25236 cnt=$(ls $DIR/$tdir | wc -l)
25237 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
25239 run_test 421b "rm by fid on open file"
25245 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25246 skip "Need MDS version at least 2.12.54"
25248 test_mkdir $DIR/$tdir
25249 createmany -o $DIR/$tdir/f 3
25250 touch $DIR/$tdir/$tfile
25251 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
25252 cnt=$(ls -1 $DIR/$tdir | wc -l)
25253 [ $cnt != 184 ] && error "unexpected #files: $cnt"
25255 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
25256 $LFS rmfid $DIR $FID1 || error "rmfid failed"
25258 cnt=$(ls $DIR/$tdir | wc -l)
25259 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
25261 run_test 421c "rm by fid against hardlinked files"
25267 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25268 skip "Need MDS version at least 2.12.54"
25270 test_mkdir $DIR/$tdir
25271 createmany -o $DIR/$tdir/f 4097
25272 cnt=$(ls -1 $DIR/$tdir | wc -l)
25273 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
25275 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
25276 $LFS rmfid $DIR $FIDS || error "rmfid failed"
25278 cnt=$(ls $DIR/$tdir | wc -l)
25280 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
25282 run_test 421d "rmfid en masse"
25288 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25289 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25290 skip "Need MDS version at least 2.12.54"
25292 mkdir -p $DIR/$tdir
25293 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
25294 createmany -o $DIR/$tdir/striped_dir/f 512
25295 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
25296 [ $cnt != 512 ] && error "unexpected #files: $cnt"
25298 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
25299 sed "s/[/][^:]*://g")
25300 $LFS rmfid $DIR $FIDS || error "rmfid failed"
25302 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
25304 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
25306 run_test 421e "rmfid in DNE"
25312 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25313 skip "Need MDS version at least 2.12.54"
25315 test_mkdir $DIR/$tdir
25317 cnt=$(ls -1 $DIR/$tdir | wc -l)
25318 [ $cnt != 1 ] && error "unexpected #files: $cnt"
25320 FID=$(lfs path2fid $DIR/$tdir/f)
25321 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
25322 # rmfid should fail
25323 cnt=$(ls -1 $DIR/$tdir | wc -l)
25324 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
25326 chmod a+rw $DIR/$tdir
25328 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
25329 # rmfid should fail
25330 cnt=$(ls -1 $DIR/$tdir | wc -l)
25331 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
25334 $RUNAS touch $DIR/$tdir/f
25335 FID=$(lfs path2fid $DIR/$tdir/f)
25336 echo "rmfid as root"
25337 $LFS rmfid $DIR $FID || error "rmfid as root failed"
25338 cnt=$(ls -1 $DIR/$tdir | wc -l)
25339 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
25342 $RUNAS touch $DIR/$tdir/f
25343 cnt=$(ls -1 $DIR/$tdir | wc -l)
25344 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
25345 FID=$(lfs path2fid $DIR/$tdir/f)
25346 # rmfid w/o user_fid2path mount option should fail
25347 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
25348 cnt=$(ls -1 $DIR/$tdir | wc -l)
25349 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
25351 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
25352 stack_trap "rmdir $tmpdir"
25353 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
25354 error "failed to mount client'"
25355 stack_trap "umount_client $tmpdir"
25357 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
25358 # rmfid should succeed
25359 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
25360 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
25362 # rmfid shouldn't allow to remove files due to dir's permission
25363 chmod a+rwx $tmpdir/$tdir
25364 touch $tmpdir/$tdir/f
25365 ls -la $tmpdir/$tdir
25366 FID=$(lfs path2fid $tmpdir/$tdir/f)
25367 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
25370 run_test 421f "rmfid checks permissions"
25376 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25377 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25378 skip "Need MDS version at least 2.12.54"
25380 mkdir -p $DIR/$tdir
25381 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
25382 createmany -o $DIR/$tdir/striped_dir/f 512
25383 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
25384 [ $cnt != 512 ] && error "unexpected #files: $cnt"
25386 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
25387 sed "s/[/][^:]*://g")
25389 rm -f $DIR/$tdir/striped_dir/f1*
25390 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
25391 removed=$((512 - cnt))
25393 # few files have been just removed, so we expect
25394 # rmfid to fail on their fids
25395 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
25396 [ $removed != $errors ] && error "$errors != $removed"
25398 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
25400 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
25402 run_test 421g "rmfid to return errors properly"
25405 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
25406 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
25407 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
25408 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
25409 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
25411 local amc=$(at_max_get client)
25412 local amo=$(at_max_get mds1)
25413 local timeout=`lctl get_param -n timeout`
25415 at_max_set 0 client
25418 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
25419 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
25420 fail_val=$(((2*timeout + 10)*1000))
25421 touch $DIR/$tdir/d3/file &
25423 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
25424 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
25425 fail_val=$((2*timeout + 5))
25426 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
25430 sleep $((2 * timeout))
25434 touch $DIR/$tdir/d2/file3
25435 touch $DIR/$tdir/d2/file4
25436 touch $DIR/$tdir/d2/file5
25439 at_max_set $amc client
25440 at_max_set $amo mds1
25442 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
25443 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
25444 error "Watchdog is always throttled"
25446 run_test 422 "kill a process with RPC in progress"
25459 # ensure statfs cache is expired
25462 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
25463 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
25467 run_test 423 "statfs should return a right data"
25470 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
25471 $LCTL set_param fail_loc=0x80000522
25472 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
25475 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
25478 test_mkdir -c -1 $DIR/$tdir
25479 $LFS setstripe -c -1 $DIR/$tdir
25481 lru_resize_disable "" 100
25482 stack_trap "lru_resize_enable" EXIT
25486 for i in $(seq $((MDSCOUNT * 125))); do
25487 local t=$DIR/$tdir/$tfile_$i
25489 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
25490 error_noexit "Create file $t"
25492 stack_trap "rm -rf $DIR/$tdir" EXIT
25494 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
25495 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
25496 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
25498 [ $lock_count -le $lru_size ] ||
25499 error "osc lock count $lock_count > lru size $lru_size"
25502 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
25503 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
25504 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
25506 [ $lock_count -le $lru_size ] ||
25507 error "mdc lock count $lock_count > lru size $lru_size"
25510 run_test 425 "lock count should not exceed lru size"
25513 splice-test -r $DIR/$tfile
25514 splice-test -rd $DIR/$tfile
25515 splice-test $DIR/$tfile
25516 splice-test -d $DIR/$tfile
25518 run_test 426 "splice test on Lustre"
25521 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
25522 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
25523 skip "Need MDS version at least 2.12.4"
25529 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
25530 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
25532 $LFS getdirstripe $DIR/$tdir/1/dir
25534 #first setfattr for creating updatelog
25535 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
25537 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
25538 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
25539 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
25540 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
25544 wait_recovery_complete mds2 $((2*TIMEOUT))
25546 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
25547 echo $log | grep "get update log failed" &&
25548 error "update log corruption is detected" || true
25550 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
25553 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25554 local cache_limit=$CACHE_MAX
25556 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$cache_limit"
25557 $LCTL set_param -n llite.*.max_cached_mb=64
25560 $LFS setstripe -c 1 $DIR/$tdir
25561 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
25562 stack_trap "rm -f $DIR/$tdir/$tfile.*"
25564 for f in $(seq 4); do
25565 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
25569 cancel_lru_locks osc
25571 for f in $(seq 4); do
25572 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
25576 run_test 428 "large block size IO should not hang"
25578 test_429() { # LU-7915 / LU-10948
25579 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
25580 local testfile=$DIR/$tfile
25581 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
25587 $LCTL get_param $ll_opencache_threshold_count ||
25588 skip "client does not have opencache parameter"
25590 set_opencache $new_flag
25591 stack_trap "restore_opencache"
25592 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
25593 error "enable opencache failed"
25595 # drop MDC DLM locks
25596 cancel_lru_locks mdc
25597 # clear MDC RPC stats counters
25598 $LCTL set_param $mdc_rpcstats=clear
25600 # According to the current implementation, we need to run 3 times
25601 # open & close file to verify if opencache is enabled correctly.
25602 # 1st, RPCs are sent for lookup/open and open handle is released on
25604 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
25605 # so open handle won't be released thereafter.
25606 # 3rd, No RPC is sent out.
25607 $MULTIOP $testfile oc || error "multiop failed"
25608 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
25609 echo "1st: $first_rpc RPCs in flight"
25611 $MULTIOP $testfile oc || error "multiop failed"
25612 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
25613 echo "2nd: $second_rpc RPCs in flight"
25615 $MULTIOP $testfile oc || error "multiop failed"
25616 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
25617 echo "3rd: $third_rpc RPCs in flight"
25619 #verify no MDC RPC is sent
25620 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
25622 run_test 429 "verify if opencache flag on client side does work"
25628 # data at [200K, 400K)
25629 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
25630 error "256K->512K dd fails"
25632 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
25633 error "2M->3M dd fails"
25635 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
25636 error "4M->5M dd fails"
25637 echo "Data at 256K...512K, 2M...3M and 4M...5M"
25638 # start at first component hole #1
25639 printf "Seeking hole from 1000 ... "
25640 offset=$(lseek_test -l 1000 $file)
25642 [[ $offset == 1000 ]] || error "offset $offset != 1000"
25643 printf "Seeking data from 1000 ... "
25644 offset=$(lseek_test -d 1000 $file)
25646 [[ $offset == 262144 ]] || error "offset $offset != 262144"
25648 # start at first component data block
25649 printf "Seeking hole from 300000 ... "
25650 offset=$(lseek_test -l 300000 $file)
25652 [[ $offset == 524288 ]] || error "offset $offset != 524288"
25653 printf "Seeking data from 300000 ... "
25654 offset=$(lseek_test -d 300000 $file)
25656 [[ $offset == 300000 ]] || error "offset $offset != 300000"
25658 # start at the first component but beyond end of object size
25659 printf "Seeking hole from 1000000 ... "
25660 offset=$(lseek_test -l 1000000 $file)
25662 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
25663 printf "Seeking data from 1000000 ... "
25664 offset=$(lseek_test -d 1000000 $file)
25666 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
25668 # start at second component stripe 2 (empty file)
25669 printf "Seeking hole from 1500000 ... "
25670 offset=$(lseek_test -l 1500000 $file)
25672 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
25673 printf "Seeking data from 1500000 ... "
25674 offset=$(lseek_test -d 1500000 $file)
25676 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
25678 # start at second component stripe 1 (all data)
25679 printf "Seeking hole from 3000000 ... "
25680 offset=$(lseek_test -l 3000000 $file)
25682 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
25683 printf "Seeking data from 3000000 ... "
25684 offset=$(lseek_test -d 3000000 $file)
25686 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
25688 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
25689 error "2nd dd fails"
25690 echo "Add data block at 640K...1280K"
25692 # start at before new data block, in hole
25693 printf "Seeking hole from 600000 ... "
25694 offset=$(lseek_test -l 600000 $file)
25696 [[ $offset == 600000 ]] || error "offset $offset != 600000"
25697 printf "Seeking data from 600000 ... "
25698 offset=$(lseek_test -d 600000 $file)
25700 [[ $offset == 655360 ]] || error "offset $offset != 655360"
25702 # start at the first component new data block
25703 printf "Seeking hole from 1000000 ... "
25704 offset=$(lseek_test -l 1000000 $file)
25706 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
25707 printf "Seeking data from 1000000 ... "
25708 offset=$(lseek_test -d 1000000 $file)
25710 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
25712 # start at second component stripe 2, new data
25713 printf "Seeking hole from 1200000 ... "
25714 offset=$(lseek_test -l 1200000 $file)
25716 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
25717 printf "Seeking data from 1200000 ... "
25718 offset=$(lseek_test -d 1200000 $file)
25720 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
25722 # start beyond file end
25723 printf "Using offset > filesize ... "
25724 lseek_test -l 4000000 $file && error "lseek should fail"
25725 printf "Using offset > filesize ... "
25726 lseek_test -d 4000000 $file && error "lseek should fail"
25732 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
25733 skip "MDT does not support SEEK_HOLE"
25735 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
25736 skip "OST does not support SEEK_HOLE"
25738 local file=$DIR/$tdir/$tfile
25740 mkdir -p $DIR/$tdir
25742 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
25743 # OST stripe #1 will have continuous data at [1M, 3M)
25744 # OST stripe #2 is empty
25745 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
25746 lseek_test_430 $file
25748 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
25749 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
25750 lseek_test_430 $file
25752 $LFS setstripe -c2 -S 512K $file
25753 echo "Two stripes, stripe size 512K"
25754 lseek_test_430 $file
25756 # FLR with stale mirror
25757 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
25759 echo "Mirrored file:"
25760 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
25761 echo "Plain 2 stripes 1M"
25762 lseek_test_430 $file
25765 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
25768 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
25769 skip "OST does not support SEEK_HOLE"
25772 local file=$DIR/$tdir/$tfile
25774 mkdir -p $DIR/$tdir
25775 # Empty layout lseek should fail
25778 printf "Seeking hole from 0 ... "
25779 lseek_test -l 0 $file && error "lseek should fail"
25780 printf "Seeking data from 0 ... "
25781 lseek_test -d 0 $file && error "lseek should fail"
25785 $LFS setstripe -E 1M -c2 -E eof $file
25786 $TRUNCATE $file 1048576
25787 printf "Seeking hole from 1000000 ... "
25788 offset=$(lseek_test -l 1000000 $file)
25790 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
25791 printf "Seeking data from 1000000 ... "
25792 lseek_test -d 1000000 $file && error "lseek should fail"
25795 # full component followed by non-inited one
25796 $LFS setstripe -E 1M -c2 -E eof $file
25797 dd if=/dev/urandom of=$file bs=1M count=1
25798 printf "Seeking hole from 1000000 ... "
25799 offset=$(lseek_test -l 1000000 $file)
25801 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
25802 printf "Seeking hole from 1048576 ... "
25803 lseek_test -l 1048576 $file && error "lseek should fail"
25804 # init second component and truncate back
25805 echo "123" >> $file
25806 $TRUNCATE $file 1048576
25807 printf "Seeking hole from 1000000 ... "
25808 offset=$(lseek_test -l 1000000 $file)
25810 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
25811 printf "Seeking hole from 1048576 ... "
25812 lseek_test -l 1048576 $file && error "lseek should fail"
25813 # boundary checks for big values
25814 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
25815 offset=$(lseek_test -d 0 $file.10g)
25816 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
25817 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
25818 offset=$(lseek_test -d 0 $file.100g)
25819 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
25822 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
25825 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
25826 skip "OST does not support SEEK_HOLE"
25828 local file=$DIR/$tdir/$tfile
25831 mkdir -p $DIR/$tdir
25832 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M
25834 # cp version 8.33+ prefers lseek over fiemap
25835 if [[ $(cp --version | head -n1 | sed "s/[^0-9]//g") -ge 833 ]]; then
25837 time cp $file /dev/null
25838 (( SECONDS - start < 5 )) ||
25839 error "cp: too long runtime $((SECONDS - start))"
25842 # tar version 1.29+ supports SEEK_HOLE/DATA
25843 if [[ $(tar --version | head -n1 | sed "s/[^0-9]//g") -ge 129 ]]; then
25845 time tar cS $file - | cat > /dev/null
25846 (( SECONDS - start < 5 )) ||
25847 error "tar: too long runtime $((SECONDS - start))"
25850 run_test 430c "lseek: external tools check"
25852 test_431() { # LU-14187
25853 local file=$DIR/$tdir/$tfile
25855 mkdir -p $DIR/$tdir
25856 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
25857 dd if=/dev/urandom of=$file bs=4k count=1
25858 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
25859 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
25860 #define OBD_FAIL_OST_RESTART_IO 0x251
25861 do_facet ost1 "$LCTL set_param fail_loc=0x251"
25862 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
25866 echo 3 > /proc/sys/vm/drop_caches
25867 diff $file $file.0 || error "data diff"
25869 run_test 431 "Restart transaction for IO"
25871 cleanup_test_432() {
25872 do_facet mgs $LCTL nodemap_activate 0
25873 wait_nm_sync active
25877 local tmpdir=$TMP/dir432
25879 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
25880 skip "Need MDS version at least 2.14.52"
25882 stack_trap cleanup_test_432 EXIT
25886 do_facet mgs $LCTL nodemap_activate 1
25887 wait_nm_sync active
25888 do_facet mgs $LCTL nodemap_modify --name default \
25889 --property admin --value 1
25890 do_facet mgs $LCTL nodemap_modify --name default \
25891 --property trusted --value 1
25892 cancel_lru_locks mdc
25893 wait_nm_sync default admin_nodemap
25894 wait_nm_sync default trusted_nodemap
25896 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
25897 grep -ci "Operation not permitted") -ne 0 ]; then
25898 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
25901 run_test 432 "mv dir from outside Lustre"
25904 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
25905 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
25906 skip "Need server version at least 2.9.55"
25908 start_full_debug_logging
25912 stop_full_debug_logging
25916 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
25917 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
25918 awk '/The barrier for/ { print $7 }')
25921 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
25926 barrier_expired() {
25929 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
25930 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
25931 awk '/will be expired/ { print $7 }')
25933 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
25942 echo "Start barrier_freeze at: $(date)"
25943 #define OBD_FAIL_BARRIER_DELAY 0x2202
25944 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
25945 # Do not reduce barrier time - See LU-11873
25946 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
25949 local b_status=$(barrier_stat)
25950 echo "Got barrier status at: $(date)"
25951 [ "$b_status" = "'freezing_p1'" ] ||
25952 error "(1) unexpected barrier status $b_status"
25954 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
25956 b_status=$(barrier_stat)
25957 [ "$b_status" = "'frozen'" ] ||
25958 error "(2) unexpected barrier status $b_status"
25960 local expired=$(barrier_expired)
25961 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
25962 sleep $((expired + 3))
25964 b_status=$(barrier_stat)
25965 [ "$b_status" = "'expired'" ] ||
25966 error "(3) unexpected barrier status $b_status"
25968 # Do not reduce barrier time - See LU-11873
25969 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
25970 error "(4) fail to freeze barrier"
25972 b_status=$(barrier_stat)
25973 [ "$b_status" = "'frozen'" ] ||
25974 error "(5) unexpected barrier status $b_status"
25976 echo "Start barrier_thaw at: $(date)"
25977 #define OBD_FAIL_BARRIER_DELAY 0x2202
25978 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
25979 do_facet mgs $LCTL barrier_thaw $FSNAME &
25982 b_status=$(barrier_stat)
25983 echo "Got barrier status at: $(date)"
25984 [ "$b_status" = "'thawing'" ] ||
25985 error "(6) unexpected barrier status $b_status"
25987 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
25989 b_status=$(barrier_stat)
25990 [ "$b_status" = "'thawed'" ] ||
25991 error "(7) unexpected barrier status $b_status"
25993 #define OBD_FAIL_BARRIER_FAILURE 0x2203
25994 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
25995 do_facet mgs $LCTL barrier_freeze $FSNAME
25997 b_status=$(barrier_stat)
25998 [ "$b_status" = "'failed'" ] ||
25999 error "(8) unexpected barrier status $b_status"
26001 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
26002 do_facet mgs $LCTL barrier_thaw $FSNAME
26006 run_test 801a "write barrier user interfaces and stat machine"
26011 mkdir $DIR/$tdir || error "(1) fail to mkdir"
26012 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
26013 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
26014 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
26015 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
26017 cancel_lru_locks mdc
26019 # 180 seconds should be long enough
26020 do_facet mgs $LCTL barrier_freeze $FSNAME 180
26022 local b_status=$(barrier_stat)
26023 [ "$b_status" = "'frozen'" ] ||
26024 error "(6) unexpected barrier status $b_status"
26026 mkdir $DIR/$tdir/d0/d10 &
26029 touch $DIR/$tdir/d1/f13 &
26032 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
26035 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
26038 rm -f $DIR/$tdir/d4/f12 &
26041 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
26043 # To guarantee taht the 'stat' is not blocked
26044 b_status=$(barrier_stat)
26045 [ "$b_status" = "'frozen'" ] ||
26046 error "(8) unexpected barrier status $b_status"
26048 # let above commands to run at background
26051 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
26052 ps -p $touch_pid || error "(10) touch should be blocked"
26053 ps -p $ln_pid || error "(11) link should be blocked"
26054 ps -p $mv_pid || error "(12) rename should be blocked"
26055 ps -p $rm_pid || error "(13) unlink should be blocked"
26057 b_status=$(barrier_stat)
26058 [ "$b_status" = "'frozen'" ] ||
26059 error "(14) unexpected barrier status $b_status"
26061 do_facet mgs $LCTL barrier_thaw $FSNAME
26062 b_status=$(barrier_stat)
26063 [ "$b_status" = "'thawed'" ] ||
26064 error "(15) unexpected barrier status $b_status"
26066 wait $mkdir_pid || error "(16) mkdir should succeed"
26067 wait $touch_pid || error "(17) touch should succeed"
26068 wait $ln_pid || error "(18) link should succeed"
26069 wait $mv_pid || error "(19) rename should succeed"
26070 wait $rm_pid || error "(20) unlink should succeed"
26074 run_test 801b "modification will be blocked by write barrier"
26077 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26081 stop mds2 || error "(1) Fail to stop mds2"
26083 do_facet mgs $LCTL barrier_freeze $FSNAME 30
26085 local b_status=$(barrier_stat)
26086 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
26087 do_facet mgs $LCTL barrier_thaw $FSNAME
26088 error "(2) unexpected barrier status $b_status"
26091 do_facet mgs $LCTL barrier_rescan $FSNAME ||
26092 error "(3) Fail to rescan barrier bitmap"
26094 # Do not reduce barrier time - See LU-11873
26095 do_facet mgs $LCTL barrier_freeze $FSNAME 20
26097 b_status=$(barrier_stat)
26098 [ "$b_status" = "'frozen'" ] ||
26099 error "(4) unexpected barrier status $b_status"
26101 do_facet mgs $LCTL barrier_thaw $FSNAME
26102 b_status=$(barrier_stat)
26103 [ "$b_status" = "'thawed'" ] ||
26104 error "(5) unexpected barrier status $b_status"
26106 local devname=$(mdsdevname 2)
26108 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
26110 do_facet mgs $LCTL barrier_rescan $FSNAME ||
26111 error "(7) Fail to rescan barrier bitmap"
26115 run_test 801c "rescan barrier bitmap"
26117 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
26118 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
26119 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
26120 saved_MOUNT_OPTS=$MOUNT_OPTS
26126 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
26127 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
26128 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
26129 MOUNT_OPTS=$saved_MOUNT_OPTS
26134 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
26135 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
26136 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
26137 skip "Need server version at least 2.9.55"
26139 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
26141 mkdir $DIR/$tdir || error "(1) fail to mkdir"
26143 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
26144 error "(2) Fail to copy"
26146 trap cleanup_802a EXIT
26148 # sync by force before remount as readonly
26149 sync; sync_all_data; sleep 3; sync_all_data
26153 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
26154 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
26155 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
26157 echo "Mount the server as read only"
26158 setupall server_only || error "(3) Fail to start servers"
26160 echo "Mount client without ro should fail"
26161 mount_client $MOUNT &&
26162 error "(4) Mount client without 'ro' should fail"
26164 echo "Mount client with ro should succeed"
26165 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
26166 mount_client $MOUNT ||
26167 error "(5) Mount client with 'ro' should succeed"
26169 echo "Modify should be refused"
26170 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
26172 echo "Read should be allowed"
26173 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
26174 error "(7) Read should succeed under ro mode"
26178 run_test 802a "simulate readonly device"
26181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26182 remote_mds_nodsh && skip "remote MDS with nodsh"
26184 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
26185 skip "readonly option not available"
26187 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
26189 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
26190 error "(2) Fail to copy"
26192 # write back all cached data before setting MDT to readonly
26196 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
26197 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
26199 echo "Modify should be refused"
26200 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
26202 echo "Read should be allowed"
26203 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
26204 error "(7) Read should succeed under ro mode"
26207 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
26209 run_test 802b "be able to set MDTs to readonly"
26212 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26213 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
26214 skip "MDS needs to be newer than 2.10.54"
26216 mkdir_on_mdt0 $DIR/$tdir
26217 # Create some objects on all MDTs to trigger related logs objects
26218 for idx in $(seq $MDSCOUNT); do
26219 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
26220 $DIR/$tdir/dir${idx} ||
26221 error "Fail to create $DIR/$tdir/dir${idx}"
26225 wait_delete_completed # ensure old test cleanups are finished
26226 echo "before create:"
26228 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
26230 for i in {1..10}; do
26231 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
26232 error "Fail to create $DIR/$tdir/foo$i"
26236 echo "after create:"
26238 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
26240 # allow for an llog to be cleaned up during the test
26241 [ $after_used -ge $((before_used + 10 - 1)) ] ||
26242 error "before ($before_used) + 10 > after ($after_used)"
26244 for i in {1..10}; do
26245 rm -rf $DIR/$tdir/foo$i ||
26246 error "Fail to remove $DIR/$tdir/foo$i"
26249 sleep 3 # avoid MDT return cached statfs
26250 wait_delete_completed
26251 echo "after unlink:"
26253 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
26255 # allow for an llog to be created during the test
26256 [ $after_used -le $((before_used + 1)) ] ||
26257 error "after ($after_used) > before ($before_used) + 1"
26259 run_test 803a "verify agent object for remote object"
26262 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26263 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
26264 skip "MDS needs to be newer than 2.13.56"
26265 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26267 for i in $(seq 0 $((MDSCOUNT - 1))); do
26268 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
26276 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
26277 for i in $(seq 0 $((MDSCOUNT - 1))); do
26278 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
26279 awk '/getattr/ { print $2 }')
26280 before=$((before + tmp))
26282 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
26283 for i in $(seq 0 $((MDSCOUNT - 1))); do
26284 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
26285 awk '/getattr/ { print $2 }')
26286 after=$((after + tmp))
26289 [ $before -eq $after ] || error "getattr count $before != $after"
26291 run_test 803b "remote object can getattr from cache"
26294 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26295 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
26296 skip "MDS needs to be newer than 2.10.54"
26297 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
26299 mkdir -p $DIR/$tdir
26300 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
26301 error "Fail to create $DIR/$tdir/dir0"
26303 local fid=$($LFS path2fid $DIR/$tdir/dir0)
26304 local dev=$(mdsdevname 2)
26306 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26307 grep ${fid} || error "NOT found agent entry for dir0"
26309 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
26310 error "Fail to create $DIR/$tdir/dir1"
26312 touch $DIR/$tdir/dir1/foo0 ||
26313 error "Fail to create $DIR/$tdir/dir1/foo0"
26314 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
26317 for idx in $(seq $MDSCOUNT); do
26318 dev=$(mdsdevname $idx)
26319 do_facet mds${idx} \
26320 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26321 grep ${fid} && rc=$idx
26324 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
26325 error "Fail to rename foo0 to foo1"
26326 if [ $rc -eq 0 ]; then
26327 for idx in $(seq $MDSCOUNT); do
26328 dev=$(mdsdevname $idx)
26329 do_facet mds${idx} \
26330 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26331 grep ${fid} && rc=$idx
26335 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
26336 error "Fail to rename foo1 to foo2"
26337 if [ $rc -eq 0 ]; then
26338 for idx in $(seq $MDSCOUNT); do
26339 dev=$(mdsdevname $idx)
26340 do_facet mds${idx} \
26341 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26342 grep ${fid} && rc=$idx
26346 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
26348 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
26349 error "Fail to link to $DIR/$tdir/dir1/foo2"
26350 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
26351 error "Fail to rename foo2 to foo0"
26352 unlink $DIR/$tdir/dir1/foo0 ||
26353 error "Fail to unlink $DIR/$tdir/dir1/foo0"
26354 rm -rf $DIR/$tdir/dir0 ||
26355 error "Fail to rm $DIR/$tdir/dir0"
26357 for idx in $(seq $MDSCOUNT); do
26358 dev=$(mdsdevname $idx)
26362 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
26364 start mds${idx} $dev $MDS_MOUNT_OPTS ||
26365 error "mount mds$idx failed"
26366 df $MOUNT > /dev/null 2>&1
26368 # e2fsck should not return error
26370 error "e2fsck detected error on MDT${idx}: rc=$rc"
26373 run_test 804 "verify agent entry for remote entry"
26376 do_facet $SINGLEMDS zfs set quota=$old $fsset
26377 unlinkmany $DIR/$tdir/f- 1000000
26382 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
26383 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
26384 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
26385 skip "netfree not implemented before 0.7"
26386 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
26387 skip "Need MDS version at least 2.10.57"
26394 local pref="osd-zfs.$FSNAME-MDT0000."
26396 # limit available space on MDS dataset to meet nospace issue
26397 # quickly. then ZFS 0.7.2 can use reserved space if asked
26398 # properly (using netfree flag in osd_declare_destroy()
26399 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
26400 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
26402 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
26403 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
26404 let "usedkb=usedkb-freekb"
26405 let "freekb=freekb/2"
26406 if let "freekb > 5000"; then
26409 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
26410 trap cleanup_805 EXIT
26411 mkdir_on_mdt0 $DIR/$tdir
26412 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
26413 error "Can't set PFL layout"
26414 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
26415 rm -rf $DIR/$tdir || error "not able to remove"
26416 do_facet $SINGLEMDS zfs set quota=$old $fsset
26419 run_test 805 "ZFS can remove from full fs"
26425 local expect=$(stat -c %s $file)
26427 check_lsom_size $1 $expect
26429 local blocks=$($LFS getsom -b $file)
26430 expect=$(stat -c %b $file)
26431 [[ $blocks == $expect ]] ||
26432 error "$file expected blocks: $expect, got: $blocks"
26440 cancel_lru_locks mdc
26442 size=$($LFS getsom -s $1)
26443 [[ $size == $expect ]] ||
26444 error "$file expected size: $expect, got: $size"
26448 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
26449 skip "Need MDS version at least 2.11.52"
26453 touch $DIR/$tfile || error "touch $tfile failed"
26455 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
26456 save_lustre_params client "llite.*.xattr_cache" > $save
26457 lctl set_param llite.*.xattr_cache=0
26458 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
26460 # single-threaded write
26461 echo "Test SOM for single-threaded write"
26462 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
26463 error "write $tfile failed"
26464 check_lsom_size $DIR/$tfile $bs
26467 local size=$(($num * $bs))
26471 echo "Test SOM for single client multi-threaded($num) write"
26472 $TRUNCATE $DIR/$tfile 0
26473 for ((i = 0; i < $num; i++)); do
26474 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
26476 offset=$((offset + $bs))
26478 for (( i=0; i < $num; i++ )); do
26481 check_lsom_size $DIR/$tfile $size
26483 $TRUNCATE $DIR/$tfile 0
26484 for ((i = 0; i < $num; i++)); do
26485 offset=$((offset - $bs))
26486 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
26489 for (( i=0; i < $num; i++ )); do
26492 check_lsom_size $DIR/$tfile $size
26494 # multi-client writes
26495 num=$(get_node_count ${CLIENTS//,/ })
26496 size=$(($num * $bs))
26500 echo "Test SOM for multi-client ($num) writes"
26501 $TRUNCATE $DIR/$tfile 0
26502 for client in ${CLIENTS//,/ }; do
26503 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
26506 offset=$((offset + $bs))
26508 for (( i=0; i < $num; i++ )); do
26511 check_lsom_size $DIR/$tfile $offset
26514 $TRUNCATE $DIR/$tfile 0
26515 for client in ${CLIENTS//,/ }; do
26516 offset=$((offset - $bs))
26517 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
26521 for (( i=0; i < $num; i++ )); do
26524 check_lsom_size $DIR/$tfile $size
26527 echo "Test SOM for truncate"
26528 $TRUNCATE $DIR/$tfile 1048576
26529 check_lsom_size $DIR/$tfile 1048576
26530 $TRUNCATE $DIR/$tfile 1234
26531 check_lsom_size $DIR/$tfile 1234
26533 # verify SOM blocks count
26534 echo "Verify SOM block count"
26535 $TRUNCATE $DIR/$tfile 0
26536 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
26537 error "failed to write file $tfile"
26538 check_lsom_data $DIR/$tfile
26540 run_test 806 "Verify Lazy Size on MDS"
26543 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
26544 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
26545 skip "Need MDS version at least 2.11.52"
26547 # Registration step
26548 changelog_register || error "changelog_register failed"
26549 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
26550 changelog_users $SINGLEMDS | grep -q $cl_user ||
26551 error "User $cl_user not found in changelog_users"
26553 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
26554 save_lustre_params client "llite.*.xattr_cache" > $save
26555 lctl set_param llite.*.xattr_cache=0
26556 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
26558 rm -rf $DIR/$tdir || error "rm $tdir failed"
26559 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
26560 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
26561 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
26562 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
26563 error "truncate $tdir/trunc failed"
26566 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
26567 error "write $tfile failed"
26569 # multi-client wirtes
26570 local num=$(get_node_count ${CLIENTS//,/ })
26574 echo "Test SOM for multi-client ($num) writes"
26575 touch $DIR/$tfile || error "touch $tfile failed"
26576 $TRUNCATE $DIR/$tfile 0
26577 for client in ${CLIENTS//,/ }; do
26578 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
26581 offset=$((offset + $bs))
26583 for (( i=0; i < $num; i++ )); do
26587 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
26588 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
26589 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
26590 check_lsom_data $DIR/$tdir/trunc
26591 check_lsom_data $DIR/$tdir/single_dd
26592 check_lsom_data $DIR/$tfile
26595 # Deregistration step
26596 changelog_deregister || error "changelog_deregister failed"
26598 run_test 807 "verify LSOM syncing tool"
26600 check_som_nologged()
26602 local lines=$($LFS changelog $FSNAME-MDT0000 |
26603 grep 'x=trusted.som' | wc -l)
26604 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
26608 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
26609 skip "Need MDS version at least 2.11.55"
26611 # Registration step
26612 changelog_register || error "changelog_register failed"
26614 touch $DIR/$tfile || error "touch $tfile failed"
26617 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
26618 error "write $tfile failed"
26621 $TRUNCATE $DIR/$tfile 1234
26624 $TRUNCATE $DIR/$tfile 1048576
26627 # Deregistration step
26628 changelog_deregister || error "changelog_deregister failed"
26630 run_test 808 "Check trusted.som xattr not logged in Changelogs"
26635 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
26639 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
26640 skip "Need MDS version at least 2.11.56"
26642 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
26643 error "failed to create DoM-only file $DIR/$tfile"
26644 touch $DIR/$tfile || error "touch $tfile failed"
26645 check_som_nodata $DIR/$tfile
26647 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
26648 error "write $tfile failed"
26649 check_som_nodata $DIR/$tfile
26651 $TRUNCATE $DIR/$tfile 1234
26652 check_som_nodata $DIR/$tfile
26654 $TRUNCATE $DIR/$tfile 4097
26655 check_som_nodata $DIR/$file
26657 run_test 809 "Verify no SOM xattr store for DoM-only files"
26660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26661 $GSS && skip_env "could not run with gss"
26662 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
26663 skip "OST < 2.12.58 doesn't align checksum"
26666 stack_trap "set_checksums $ORIG_CSUM" EXIT
26667 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
26672 for csum in $CKSUM_TYPES; do
26673 #define OBD_FAIL_OSC_NO_GRANT 0x411
26674 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
26675 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
26677 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
26678 before=$(md5sum $DIR/$tfile)
26679 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
26680 after=$(md5sum $DIR/$tfile)
26681 [ "$before" == "$after" ] ||
26682 error "$csum: $before != $after bs=$1 seek=$2"
26686 run_test 810 "partial page writes on ZFS (LU-11663)"
26689 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
26690 skip "OST < 2.12.51 doesn't support this fail_loc"
26692 $LFS setstripe -c 1 -i 0 $DIR/$tfile
26693 # ensure ost1 is connected
26694 stat $DIR/$tfile >/dev/null || error "can't stat"
26695 wait_osc_import_state client ost1 FULL
26696 # no locks, no reqs to let the connection idle
26697 cancel_lru_locks osc
26699 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
26700 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
26701 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
26702 wait_osc_import_state client ost1 CONNECTING
26703 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
26705 stat $DIR/$tfile >/dev/null || error "can't stat file"
26707 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
26709 test_812b() { # LU-12378
26710 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
26711 skip "OST < 2.12.51 doesn't support this fail_loc"
26713 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
26714 # ensure ost1 is connected
26715 stat $DIR/$tfile >/dev/null || error "can't stat"
26716 wait_osc_import_state client ost1 FULL
26717 # no locks, no reqs to let the connection idle
26718 cancel_lru_locks osc
26720 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
26721 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
26722 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
26723 wait_osc_import_state client ost1 CONNECTING
26724 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
26726 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
26727 wait_osc_import_state client ost1 IDLE
26729 run_test 812b "do not drop no resend request for idle connect"
26734 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
26736 $LFS setstripe -c 1 -o 0 $DIR/$tfile
26737 $LFS getstripe $DIR/$tfile
26738 $LCTL set_param osc.*.idle_timeout=10
26739 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
26740 # ensure ost1 is connected
26741 stat $DIR/$tfile >/dev/null || error "can't stat"
26742 wait_osc_import_state client ost1 FULL
26743 # no locks, no reqs to let the connection idle
26744 cancel_lru_locks osc
26746 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
26747 $LCTL set_param fail_loc=0x80000533
26749 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
26751 run_test 812c "idle import vs lock enqueue race"
26754 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
26755 [ -z "$file_heat_sav" ] && skip "no file heat support"
26766 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
26767 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
26769 $LCTL set_param -n llite.*.file_heat=1
26770 echo "Turn on file heat"
26771 echo "Period second: $period_second, Decay percentage: $decay_pct"
26773 echo "QQQQ" > $DIR/$tfile
26774 echo "QQQQ" > $DIR/$tfile
26775 echo "QQQQ" > $DIR/$tfile
26776 cat $DIR/$tfile > /dev/null
26777 cat $DIR/$tfile > /dev/null
26778 cat $DIR/$tfile > /dev/null
26779 cat $DIR/$tfile > /dev/null
26781 local out=$($LFS heat_get $DIR/$tfile)
26783 $LFS heat_get $DIR/$tfile
26784 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26785 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26786 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26787 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26789 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
26790 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
26791 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
26792 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
26794 sleep $((period_second + 3))
26795 echo "Sleep $((period_second + 3)) seconds..."
26796 # The recursion formula to calculate the heat of the file f is as
26798 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
26799 # Where Hi is the heat value in the period between time points i*I and
26800 # (i+1)*I; Ci is the access count in the period; the symbol P refers
26801 # to the weight of Ci.
26802 out=$($LFS heat_get $DIR/$tfile)
26803 $LFS heat_get $DIR/$tfile
26804 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26805 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26806 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26807 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26809 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
26810 error "read sample ($readsample) is wrong"
26811 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
26812 error "write sample ($writesample) is wrong"
26813 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
26814 error "read bytes ($readbyte) is wrong"
26815 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
26816 error "write bytes ($writebyte) is wrong"
26818 echo "QQQQ" > $DIR/$tfile
26819 echo "QQQQ" > $DIR/$tfile
26820 echo "QQQQ" > $DIR/$tfile
26821 cat $DIR/$tfile > /dev/null
26822 cat $DIR/$tfile > /dev/null
26823 cat $DIR/$tfile > /dev/null
26824 cat $DIR/$tfile > /dev/null
26826 sleep $((period_second + 3))
26827 echo "Sleep $((period_second + 3)) seconds..."
26829 out=$($LFS heat_get $DIR/$tfile)
26830 $LFS heat_get $DIR/$tfile
26831 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26832 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26833 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26834 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26836 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
26837 4 * $decay_pct) / 100") -eq 1 ] ||
26838 error "read sample ($readsample1) is wrong"
26839 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
26840 3 * $decay_pct) / 100") -eq 1 ] ||
26841 error "write sample ($writesample1) is wrong"
26842 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
26843 20 * $decay_pct) / 100") -eq 1 ] ||
26844 error "read bytes ($readbyte1) is wrong"
26845 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
26846 15 * $decay_pct) / 100") -eq 1 ] ||
26847 error "write bytes ($writebyte1) is wrong"
26849 echo "Turn off file heat for the file $DIR/$tfile"
26850 $LFS heat_set -o $DIR/$tfile
26852 echo "QQQQ" > $DIR/$tfile
26853 echo "QQQQ" > $DIR/$tfile
26854 echo "QQQQ" > $DIR/$tfile
26855 cat $DIR/$tfile > /dev/null
26856 cat $DIR/$tfile > /dev/null
26857 cat $DIR/$tfile > /dev/null
26858 cat $DIR/$tfile > /dev/null
26860 out=$($LFS heat_get $DIR/$tfile)
26861 $LFS heat_get $DIR/$tfile
26862 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26863 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26864 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26865 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26867 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
26868 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
26869 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
26870 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
26872 echo "Trun on file heat for the file $DIR/$tfile"
26873 $LFS heat_set -O $DIR/$tfile
26875 echo "QQQQ" > $DIR/$tfile
26876 echo "QQQQ" > $DIR/$tfile
26877 echo "QQQQ" > $DIR/$tfile
26878 cat $DIR/$tfile > /dev/null
26879 cat $DIR/$tfile > /dev/null
26880 cat $DIR/$tfile > /dev/null
26881 cat $DIR/$tfile > /dev/null
26883 out=$($LFS heat_get $DIR/$tfile)
26884 $LFS heat_get $DIR/$tfile
26885 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26886 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26887 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26888 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26890 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
26891 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
26892 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
26893 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
26895 $LFS heat_set -c $DIR/$tfile
26896 $LCTL set_param -n llite.*.file_heat=0
26897 echo "Turn off file heat support for the Lustre filesystem"
26899 echo "QQQQ" > $DIR/$tfile
26900 echo "QQQQ" > $DIR/$tfile
26901 echo "QQQQ" > $DIR/$tfile
26902 cat $DIR/$tfile > /dev/null
26903 cat $DIR/$tfile > /dev/null
26904 cat $DIR/$tfile > /dev/null
26905 cat $DIR/$tfile > /dev/null
26907 out=$($LFS heat_get $DIR/$tfile)
26908 $LFS heat_get $DIR/$tfile
26909 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
26910 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
26911 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
26912 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
26914 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
26915 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
26916 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
26917 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
26919 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
26922 run_test 813 "File heat verfication"
26926 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
26927 echo -n y >> $DIR/$tfile
26928 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
26929 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
26931 run_test 814 "sparse cp works as expected (LU-12361)"
26935 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
26936 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
26938 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
26941 local ost1_imp=$(get_osc_import_name client ost1)
26942 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
26945 $LFS setstripe -c 1 -i 0 $DIR/$tfile
26946 # ensure ost1 is connected
26948 stat $DIR/$tfile >/dev/null || error "can't stat"
26949 wait_osc_import_state client ost1 FULL
26950 # no locks, no reqs to let the connection idle
26951 cancel_lru_locks osc
26952 lru_resize_disable osc
26955 before=$($LCTL get_param -n \
26956 ldlm.namespaces.$imp_name.lru_size)
26958 wait_osc_import_state client ost1 IDLE
26959 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
26960 now=$($LCTL get_param -n \
26961 ldlm.namespaces.$imp_name.lru_size)
26962 [ $before == $now ] || error "lru_size changed $before != $now"
26964 run_test 816 "do not reset lru_resize on idle reconnect"
26968 exportfs -u localhost:$DIR/nfsexp
26973 systemctl restart nfs-server.service || skip "failed to restart nfsd"
26975 mkdir -p $DIR/nfsexp
26976 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
26977 error "failed to export nfs"
26979 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
26980 stack_trap cleanup_817 EXIT
26982 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
26983 error "failed to mount nfs to $tmpdir"
26985 cp /bin/true $tmpdir
26986 $DIR/nfsexp/true || error "failed to execute 'true' command"
26988 run_test 817 "nfsd won't cache write lock for exec file"
26992 $LFS setstripe -c1 -i0 $DIR/$tfile
26993 $LFS setstripe -c1 -i1 $DIR/$tfile
26995 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
26996 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
26997 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
26998 error "start $SINGLEMDS failed"
27001 run_test 818 "unlink with failed llog"
27004 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
27005 cancel_lru_locks osc
27006 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
27007 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
27008 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
27011 run_test 819a "too big niobuf in read"
27014 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
27015 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
27016 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
27017 cancel_lru_locks osc
27021 run_test 819b "too big niobuf in write"
27024 function test_820_start_ost() {
27027 for num in $(seq $OSTCOUNT); do
27028 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
27033 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27036 umount_client $MOUNT || error "umount failed"
27037 for num in $(seq $OSTCOUNT); do
27041 # mount client with no active OSTs
27042 # so that the client can't initialize max LOV EA size
27043 # from OSC notifications
27044 mount_client $MOUNT || error "mount failed"
27045 # delay OST starting to keep this 0 max EA size for a while
27046 test_820_start_ost &
27048 # create a directory on MDS2
27049 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
27050 error "Failed to create directory"
27051 # open intent should update default EA size
27052 # see mdc_update_max_ea_from_body()
27053 # notice this is the very first RPC to MDS2
27054 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
27057 # With SSK, this situation can lead to -EPERM being returned.
27058 # In that case, simply retry.
27059 if [ $ret -ne 0 ] && $SHARED_KEY; then
27060 if echo "$out" | grep -q "not permitted"; then
27061 cp /etc/services $DIR/$tdir/mds2
27065 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
27067 run_test 820 "update max EA from open intent"
27070 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
27072 save_lustre_params mds1 \
27073 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
27074 do_facet $SINGLEMDS "$LCTL set_param -n \
27075 osp.$FSNAME-OST*MDT0000.max_create_count=0"
27076 do_facet $SINGLEMDS "$LCTL set_param -n \
27077 osp.$FSNAME-OST0000*MDT0000.max_create_count=20000"
27079 # wait for statfs update to clear OS_STATFS_NOPRECREATE
27080 local maxage=$(do_facet mds1 $LCTL get_param -n \
27081 osp.$FSNAME-OST0000*MDT0000.maxage)
27082 sleep $((maxage + 1))
27084 #define OBD_FAIL_NET_ERROR_RPC 0x532
27085 do_facet mds1 "$LCTL set_param fail_loc=0x80000532 fail_val=5"
27087 stack_trap "restore_lustre_params < $p; rm $p"
27089 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
27090 osp.$FSNAME-OST0000*MDT0000.create_count")
27091 for i in $(seq 1 $count); do
27092 touch $DIR/$tfile.${i} || error "touch failed"
27095 run_test 822 "test precreate failure"
27098 # tests that do cleanup/setup should be run at the end
27102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27105 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
27106 $LCTL set_param fail_loc=0x903
27108 cancel_lru_locks MGC
27110 FAIL_ON_ERROR=true cleanup
27111 FAIL_ON_ERROR=true setup
27113 run_test 900 "umount should not race with any mgc requeue thread"
27115 # LUS-6253/LU-11185
27121 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27123 # some get_param have a bug to handle dot in param name
27124 cancel_lru_locks MGC
27125 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
27126 olds=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
27127 umount_client $MOUNT || error "umount failed"
27128 mount_client $MOUNT || error "mount failed"
27129 cancel_lru_locks MGC
27130 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
27131 news=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
27133 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
27134 [ $olds -lt $news ] && error "mgs lock leak ($olds != $news)"
27138 run_test 901 "don't leak a mgc lock on client umount"
27142 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
27143 skip "client does not have LU-13377 fix"
27144 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
27145 $LCTL set_param fail_loc=0x1415
27146 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
27147 cancel_lru_locks osc
27150 run_test 902 "test short write doesn't hang lustre"
27153 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
27154 check_and_cleanup_lustre
27155 if [ "$I_MOUNTED" != "yes" ]; then
27156 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true