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
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 230d 300o"
83 if [ "$mds1_FSTYPE" = "zfs" ]; then
84 # bug number for skipped test:
87 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
90 if [ "$ost1_FSTYPE" = "zfs" ]; then
91 # bug number for skipped test: LU-1941 LU-1941 LU-1941 LU-1941
92 ALWAYS_EXCEPT+=" 130a 130b 130c 130d 130e 130f 130g"
95 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
97 # Get the SLES distro version
99 # Returns a version string that should only be used in comparing
100 # strings returned by version_code()
103 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
105 # All SuSE Linux versions have one decimal. version_code expects two
106 local sles_version=$version.0
107 version_code $sles_version
110 # Check if we are running on Ubuntu or SLES so we can make decisions on
112 if [ -r /etc/SuSE-release ]; then
113 sles_version=$(sles_version_code)
114 [ $sles_version -lt $(version_code 11.4.0) ] &&
115 # bug number for skipped test: LU-4341
116 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
117 [ $sles_version -lt $(version_code 12.0.0) ] &&
118 # bug number for skipped test: LU-3703
119 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
120 elif [ -r /etc/os-release ]; then
121 if grep -qi ubuntu /etc/os-release; then
122 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
123 -e 's/^VERSION=//p' \
127 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
128 # bug number for skipped test:
130 ALWAYS_EXCEPT+=" 103a 410"
140 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
141 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
150 check_swap_layouts_support()
152 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
153 skip "Does not support layout lock."
156 check_swap_layout_no_dom()
159 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
160 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
163 check_and_setup_lustre
167 MAXFREE=${MAXFREE:-$((300000 * $OSTCOUNT))}
169 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
170 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
171 rm -rf $DIR/[Rdfs][0-9]*
173 # $RUNAS_ID may get set incorrectly somewhere else
174 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
175 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
177 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
179 if [ "${ONLY}" = "MOUNT" ] ; then
180 echo "Lustre is up, please go on"
184 echo "preparing for tests involving mounts"
185 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
187 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
188 echo # add a newline after mke2fs.
192 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
193 lctl set_param debug=-1 2> /dev/null || true
196 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
198 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
200 run_test 0a "touch; rm ====================="
203 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
204 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
206 run_test 0b "chmod 0755 $DIR ============================="
209 $LCTL get_param mdc.*.import | grep "state: FULL" ||
210 error "import not FULL"
211 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
214 run_test 0c "check import proc"
216 test_0d() { # LU-3397
217 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
218 skip "proc exports not supported before 2.10.57"
220 local mgs_exp="mgs.MGS.exports"
221 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
223 local exp_client_version
226 local temp_imp=$DIR/$tfile.import
227 local temp_exp=$DIR/$tfile.export
229 # save mgc import file to $temp_imp
230 $LCTL get_param mgc.*.import | tee $temp_imp
231 # Check if client uuid is found in MGS export
232 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
233 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
237 # save mgs export file to $temp_exp
238 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
240 # Compare the value of field "connect_flags"
241 imp_val=$(grep "connect_flags" $temp_imp)
242 exp_val=$(grep "connect_flags" $temp_exp)
243 [ "$exp_val" == "$imp_val" ] ||
244 error "export flags '$exp_val' != import flags '$imp_val'"
246 # Compare client versions. Only compare top-3 fields for compatibility
247 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
248 exp_val=$(version_code $(cut -d. -f1,2,3 <<<$exp_client_version))
249 imp_val=$(version_code $(lustre_build_version client | cut -d. -f1,2,3))
250 [ "$exp_val" == "$imp_val" ] ||
251 error "exp version '$exp_client_version'($exp_val) != " \
252 "'$(lustre_build_version client)'($imp_val)"
254 run_test 0d "check export proc ============================="
256 test_0e() { # LU-13417
257 (( $MDSCOUNT > 1 )) ||
258 skip "We need at least 2 MDTs for this test"
260 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
261 skip "Need server version at least 2.14.51"
263 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
264 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
266 [ $default_lmv_count -eq 1 ] ||
267 error "$MOUNT default stripe count $default_lmv_count"
269 [ $default_lmv_index -eq -1 ] ||
270 error "$MOUNT default stripe index $default_lmv_index"
272 mkdir $MOUNT/$tdir.1 || error "mkdir $MOUNT/$tdir.1 failed"
273 mkdir $MOUNT/$tdir.2 || error "mkdir $MOUNT/$tdir.2 failed"
275 local mdt_index1=$($LFS getdirstripe -i $MOUNT/$tdir.1)
276 local mdt_index2=$($LFS getdirstripe -i $MOUNT/$tdir.2)
278 [ $mdt_index1 -eq $mdt_index2 ] &&
279 error "directories are on the same MDT $mdt_index1=$mdt_index2"
281 rmdir $MOUNT/$tdir.1 $MOUNT/$tdir.2
283 run_test 0e "Enable DNE MDT balancing for mkdir in the ROOT"
286 test_mkdir $DIR/$tdir
287 test_mkdir $DIR/$tdir/d2
288 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
289 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
292 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
294 run_test 1 "mkdir; remkdir; rmdir"
297 test_mkdir $DIR/$tdir
298 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
299 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
301 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
303 run_test 2 "mkdir; touch; rmdir; check file"
306 test_mkdir $DIR/$tdir
307 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
308 touch $DIR/$tdir/$tfile
309 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
311 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
313 run_test 3 "mkdir; touch; rmdir; check dir"
315 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
317 test_mkdir -i 1 $DIR/$tdir
319 touch $DIR/$tdir/$tfile ||
320 error "Create file under remote directory failed"
323 error "Expect error removing in-use dir $DIR/$tdir"
325 test -d $DIR/$tdir || error "Remote directory disappeared"
327 rm -rf $DIR/$tdir || error "remove remote dir error"
329 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
332 test_mkdir $DIR/$tdir
333 test_mkdir $DIR/$tdir/d2
334 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
335 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
336 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
338 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
341 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
342 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
343 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
344 error "$tfile does not have perm 0666 or UID $UID"
345 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
346 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
347 error "$tfile should be 0666 and owned by UID $UID"
349 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
352 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
355 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
356 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
357 error "$tfile should be owned by UID $RUNAS_ID"
358 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
359 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
360 error "$tfile should be owned by UID $RUNAS_ID"
362 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
365 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
368 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
369 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
370 error "$tfile should be owned by GID $UID"
371 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
372 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
373 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
375 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
378 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
380 test_mkdir $DIR/$tdir
381 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
382 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
383 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
384 test_mkdir $DIR/$tdir/d/subdir
385 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
386 error "$tdir/d/subdir should be GID $RUNAS_GID"
387 if [[ $MDSCOUNT -gt 1 ]]; then
388 # check remote dir sgid inherite
389 $LFS mkdir -i 0 $DIR/$tdir.local ||
390 error "mkdir $tdir.local failed"
391 chmod g+s $DIR/$tdir.local ||
392 error "chmod $tdir.local failed"
393 chgrp $RUNAS_GID $DIR/$tdir.local ||
394 error "chgrp $tdir.local failed"
395 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
396 error "mkdir $tdir.remote failed"
397 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
398 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
399 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
400 error "$tdir.remote should be mode 02755"
403 run_test 6g "verify new dir in sgid dir inherits group"
405 test_6h() { # bug 7331
406 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
408 touch $DIR/$tfile || error "touch failed"
409 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
410 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
411 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
412 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
413 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
415 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
418 test_mkdir $DIR/$tdir
419 $MCREATE $DIR/$tdir/$tfile
420 chmod 0666 $DIR/$tdir/$tfile
421 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
422 error "$tdir/$tfile should be mode 0666"
424 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
427 if [ ! -d $DIR/$tdir ]; then
428 test_mkdir $DIR/$tdir
430 $MCREATE $DIR/$tdir/$tfile
431 echo -n foo > $DIR/$tdir/$tfile
432 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
433 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
435 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
438 test_mkdir $DIR/$tdir
439 touch $DIR/$tdir/$tfile
440 chmod 0666 $DIR/$tdir/$tfile
441 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
442 error "$tfile mode not 0666"
444 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
447 test_mkdir $DIR/$tdir
448 test_mkdir $DIR/$tdir/d2
449 test_mkdir $DIR/$tdir/d2/d3
450 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
452 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
455 test_mkdir $DIR/$tdir
456 test_mkdir $DIR/$tdir/d2
457 touch $DIR/$tdir/d2/$tfile
458 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
459 error "$tdir/d2/$tfile not a file"
461 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
464 test_mkdir $DIR/$tdir
465 test_mkdir $DIR/$tdir/d2
466 chmod 0666 $DIR/$tdir/d2
467 chmod 0705 $DIR/$tdir/d2
468 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
469 error "$tdir/d2 mode not 0705"
471 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
474 test_mkdir $DIR/$tdir
475 touch $DIR/$tdir/$tfile
476 chmod 0666 $DIR/$tdir/$tfile
477 chmod 0654 $DIR/$tdir/$tfile
478 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
479 error "$tdir/d2 mode not 0654"
481 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
484 test_mkdir $DIR/$tdir
485 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
487 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
488 error "$tdir/$tfile size not 0 after truncate"
490 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
493 test_mkdir $DIR/$tdir
494 touch $DIR/$tdir/$tfile
496 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
498 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
501 test_mkdir $DIR/$tdir
502 touch $DIR/$tdir/$tfile
503 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
504 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
505 error "$tdir/${tfile_2} not a file after rename"
506 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
508 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
511 test_mkdir $DIR/$tdir
512 touch $DIR/$tdir/$tfile
513 rm -rf $DIR/$tdir/$tfile
514 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
516 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
519 test_mkdir $DIR/$tdir
520 touch $DIR/$tdir/$tfile
521 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
523 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
524 error "$tdir/l-exist not a symlink"
525 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
526 error "$tdir/l-exist not referencing a file"
527 rm -f $DIR/$tdir/l-exist
528 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
530 run_test 17a "symlinks: create, remove (real)"
533 test_mkdir $DIR/$tdir
534 ln -s no-such-file $DIR/$tdir/l-dangle
536 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
537 error "$tdir/l-dangle not referencing no-such-file"
538 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
539 error "$tdir/l-dangle not referencing non-existent file"
540 rm -f $DIR/$tdir/l-dangle
541 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
543 run_test 17b "symlinks: create, remove (dangling)"
545 test_17c() { # bug 3440 - don't save failed open RPC for replay
546 test_mkdir $DIR/$tdir
547 ln -s foo $DIR/$tdir/$tfile
548 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
550 run_test 17c "symlinks: open dangling (should return error)"
553 test_mkdir $DIR/$tdir
554 ln -s foo $DIR/$tdir/$tfile
555 touch $DIR/$tdir/$tfile || error "creating to new symlink"
557 run_test 17d "symlinks: create dangling"
560 test_mkdir $DIR/$tdir
561 local foo=$DIR/$tdir/$tfile
562 ln -s $foo $foo || error "create symlink failed"
563 ls -l $foo || error "ls -l failed"
564 ls $foo && error "ls not failed" || true
566 run_test 17e "symlinks: create recursive symlink (should return error)"
569 test_mkdir $DIR/$tdir
570 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
571 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
572 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
573 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
574 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
575 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
578 run_test 17f "symlinks: long and very long symlink name"
580 # str_repeat(S, N) generate a string that is string S repeated N times
585 while [ $((n -= 1)) -ge 0 ]; do
591 # Long symlinks and LU-2241
593 test_mkdir $DIR/$tdir
594 local TESTS="59 60 61 4094 4095"
596 # Fix for inode size boundary in 2.1.4
597 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
600 # Patch not applied to 2.2 or 2.3 branches
601 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
602 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
606 local SYMNAME=$(str_repeat 'x' $i)
607 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
608 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
611 run_test 17g "symlinks: really long symlink name and inode boundaries"
613 test_17h() { #bug 17378
614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
615 remote_mds_nodsh && skip "remote MDS with nodsh"
619 test_mkdir $DIR/$tdir
620 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
621 $LFS setstripe -c -1 $DIR/$tdir
622 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
623 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
624 touch $DIR/$tdir/$tfile || true
626 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
628 test_17i() { #bug 20018
629 [ $PARALLEL == "yes" ] && skip "skip parallel run"
630 remote_mds_nodsh && skip "remote MDS with nodsh"
632 local foo=$DIR/$tdir/$tfile
635 test_mkdir -c1 $DIR/$tdir
636 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
637 ln -s $foo $foo || error "create symlink failed"
638 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
639 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
640 ls -l $foo && error "error not detected"
643 run_test 17i "don't panic on short symlink (should return error)"
645 test_17k() { #bug 22301
646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
647 [[ -z "$(which rsync 2>/dev/null)" ]] &&
648 skip "no rsync command"
649 rsync --help | grep -q xattr ||
650 skip_env "$(rsync --version | head -n1) does not support xattrs"
651 test_mkdir $DIR/$tdir
652 test_mkdir $DIR/$tdir.new
653 touch $DIR/$tdir/$tfile
654 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
655 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
656 error "rsync failed with xattrs enabled"
658 run_test 17k "symlinks: rsync with xattrs enabled"
660 test_17l() { # LU-279
661 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
662 skip "no getfattr command"
664 test_mkdir $DIR/$tdir
665 touch $DIR/$tdir/$tfile
666 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
667 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
668 # -h to not follow symlinks. -m '' to list all the xattrs.
669 # grep to remove first line: '# file: $path'.
670 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
672 lgetxattr_size_check $path $xattr ||
673 error "lgetxattr_size_check $path $xattr failed"
677 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
681 [ $PARALLEL == "yes" ] && skip "skip parallel run"
682 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
683 remote_mds_nodsh && skip "remote MDS with nodsh"
684 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
685 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
686 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
688 local short_sym="0123456789"
689 local wdir=$DIR/$tdir
694 # create a long symlink file
695 for ((i = 0; i < 4; ++i)); do
696 long_sym=${long_sym}${long_sym}
699 echo "create 512 short and long symlink files under $wdir"
700 for ((i = 0; i < 256; ++i)); do
701 ln -sf ${long_sym}"a5a5" $wdir/long-$i
702 ln -sf ${short_sym}"a5a5" $wdir/short-$i
708 wait_delete_completed
710 echo "recreate the 512 symlink files with a shorter string"
711 for ((i = 0; i < 512; ++i)); do
712 # rewrite the symlink file with a shorter string
713 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
714 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
717 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
718 local devname=$(mdsdevname $mds_index)
720 echo "stop and checking mds${mds_index}:"
721 # e2fsck should not return error
723 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
726 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
727 error "start mds${mds_index} failed"
728 df $MOUNT > /dev/null 2>&1
730 error "e2fsck detected error for short/long symlink: rc=$rc"
733 run_test 17m "run e2fsck against MDT which contains short/long symlink"
735 check_fs_consistency_17n() {
739 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
740 # so it only check MDT1/MDT2 instead of all of MDTs.
741 for mdt_index in 1 2; do
742 local devname=$(mdsdevname $mdt_index)
743 # e2fsck should not return error
745 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
748 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
749 error "mount mds$mdt_index failed"
750 df $MOUNT > /dev/null 2>&1
756 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
757 [ $PARALLEL == "yes" ] && skip "skip parallel run"
758 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
759 remote_mds_nodsh && skip "remote MDS with nodsh"
760 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
761 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
762 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
766 test_mkdir $DIR/$tdir
767 for ((i=0; i<10; i++)); do
768 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
769 error "create remote dir error $i"
770 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
771 error "create files under remote dir failed $i"
774 check_fs_consistency_17n ||
775 error "e2fsck report error after create files under remote dir"
777 for ((i = 0; i < 10; i++)); do
778 rm -rf $DIR/$tdir/remote_dir_${i} ||
779 error "destroy remote dir error $i"
782 check_fs_consistency_17n ||
783 error "e2fsck report error after unlink files under remote dir"
785 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
786 skip "lustre < 2.4.50 does not support migrate mv"
788 for ((i = 0; i < 10; i++)); do
789 mkdir -p $DIR/$tdir/remote_dir_${i}
790 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
791 error "create files under remote dir failed $i"
792 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
793 error "migrate remote dir error $i"
795 check_fs_consistency_17n || error "e2fsck report error after migration"
797 for ((i = 0; i < 10; i++)); do
798 rm -rf $DIR/$tdir/remote_dir_${i} ||
799 error "destroy remote dir error $i"
802 check_fs_consistency_17n || error "e2fsck report error after unlink"
804 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
807 remote_mds_nodsh && skip "remote MDS with nodsh"
808 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
809 skip "Need MDS version at least 2.3.64"
811 local wdir=$DIR/${tdir}o
817 mdt_index=$($LFS getstripe -m $wdir/$tfile)
818 mdt_index=$((mdt_index + 1))
821 #fail mds will wait the failover finish then set
822 #following fail_loc to avoid interfer the recovery process.
825 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
826 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
827 ls -l $wdir/$tfile && rc=1
828 do_facet mds${mdt_index} lctl set_param fail_loc=0
829 [[ $rc -eq 0 ]] || error "stat file should fail"
831 run_test 17o "stat file with incompat LMA feature"
834 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
835 ls $DIR || error "Failed to ls $DIR: $?"
837 run_test 18 "touch .../f ; ls ... =============================="
843 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
845 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
848 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
850 run_test 19b "ls -l .../f19 (should return error) =============="
853 [ $RUNAS_ID -eq $UID ] &&
854 skip_env "RUNAS_ID = UID = $UID -- skipping"
856 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
858 run_test 19c "$RUNAS touch .../f19 (should return error) =="
861 cat $DIR/f19 && error || true
863 run_test 19d "cat .../f19 (should return error) =============="
872 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
874 run_test 20 "touch .../f ; ls -l ..."
877 test_mkdir $DIR/$tdir
878 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
879 ln -s dangle $DIR/$tdir/link
880 echo foo >> $DIR/$tdir/link
881 cat $DIR/$tdir/dangle
882 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
883 $CHECKSTAT -f -t file $DIR/$tdir/link ||
884 error "$tdir/link not linked to a file"
886 run_test 21 "write to dangling link"
889 local wdir=$DIR/$tdir
891 chown $RUNAS_ID:$RUNAS_GID $wdir
892 (cd $wdir || error "cd $wdir failed";
893 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
895 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
896 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
897 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
898 error "checkstat -u failed"
900 run_test 22 "unpack tar archive as non-root user"
904 test_mkdir $DIR/$tdir
905 local file=$DIR/$tdir/$tfile
907 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
908 openfile -f O_CREAT:O_EXCL $file &&
909 error "$file recreate succeeded" || true
911 run_test 23a "O_CREAT|O_EXCL in subdir"
913 test_23b() { # bug 18988
914 test_mkdir $DIR/$tdir
915 local file=$DIR/$tdir/$tfile
918 echo foo > $file || error "write filed"
919 echo bar >> $file || error "append filed"
920 $CHECKSTAT -s 8 $file || error "wrong size"
923 run_test 23b "O_APPEND check"
925 # LU-9409, size with O_APPEND and tiny writes
927 local file=$DIR/$tfile
930 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
931 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
935 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
936 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
938 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
941 #racing tiny & normal writes
942 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
943 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
945 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
948 #racing tiny & normal writes 2, ugly numbers
949 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
950 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
952 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
955 run_test 23c "O_APPEND size checks for tiny writes"
957 # LU-11069 file offset is correct after appending writes
959 local file=$DIR/$tfile
962 echo CentaurHauls > $file
963 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
964 if ((offset != 26)); then
965 error "wrong offset, expected 26, got '$offset'"
968 run_test 23d "file offset is correct after appending writes"
972 echo '-- same directory rename'
973 test_mkdir $DIR/$tdir
974 touch $DIR/$tdir/$tfile.1
975 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
976 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
978 run_test 24a "rename file to non-existent target"
981 test_mkdir $DIR/$tdir
982 touch $DIR/$tdir/$tfile.{1,2}
983 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
984 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
985 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
987 run_test 24b "rename file to existing target"
990 test_mkdir $DIR/$tdir
991 test_mkdir $DIR/$tdir/d$testnum.1
992 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
993 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
994 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
996 run_test 24c "rename directory to non-existent target"
999 test_mkdir -c1 $DIR/$tdir
1000 test_mkdir -c1 $DIR/$tdir/d$testnum.1
1001 test_mkdir -c1 $DIR/$tdir/d$testnum.2
1002 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
1003 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
1004 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
1006 run_test 24d "rename directory to existing target"
1009 echo '-- cross directory renames --'
1013 mv $DIR/R5a/f $DIR/R5b/g
1014 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
1015 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
1017 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
1022 touch $DIR/R6a/f $DIR/R6b/g
1023 mv $DIR/R6a/f $DIR/R6b/g
1024 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
1025 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
1027 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
1032 test_mkdir $DIR/R7a/d
1033 mv $DIR/R7a/d $DIR/R7b/e
1034 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
1035 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
1037 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1040 test_mkdir -c1 $DIR/R8a
1041 test_mkdir -c1 $DIR/R8b
1042 test_mkdir -c1 $DIR/R8a/d
1043 test_mkdir -c1 $DIR/R8b/e
1044 mrename $DIR/R8a/d $DIR/R8b/e
1045 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1046 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1048 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1051 echo "-- rename error cases"
1053 test_mkdir $DIR/R9/a
1055 mrename $DIR/R9/f $DIR/R9/a
1056 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1057 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1058 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1060 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1064 mrename $DIR/R10/f $DIR/R10/g
1065 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1066 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1067 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1069 run_test 24j "source does not exist ============================"
1072 test_mkdir $DIR/R11a
1073 test_mkdir $DIR/R11a/d
1075 mv $DIR/R11a/f $DIR/R11a/d
1076 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1077 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1079 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1081 # bug 2429 - rename foo foo foo creates invalid file
1084 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1086 run_test 24l "Renaming a file to itself ========================"
1090 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1091 # on ext3 this does not remove either the source or target files
1092 # though the "expected" operation would be to remove the source
1093 $CHECKSTAT -t file ${f} || error "${f} missing"
1094 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1096 run_test 24m "Renaming a file to a hard link to itself ========="
1100 # this stats the old file after it was renamed, so it should fail
1102 $CHECKSTAT ${f} || error "${f} missing"
1104 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1105 $CHECKSTAT -a ${f} || error "${f} exists"
1107 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1110 test_mkdir $DIR/$tdir
1111 rename_many -s random -v -n 10 $DIR/$tdir
1113 run_test 24o "rename of files during htree split"
1116 test_mkdir $DIR/R12a
1117 test_mkdir $DIR/R12b
1118 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1119 mrename $DIR/R12a $DIR/R12b
1120 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1121 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1122 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1123 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1125 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1127 cleanup_multiop_pause() {
1129 kill -USR1 $MULTIPID
1133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1135 test_mkdir $DIR/R13a
1136 test_mkdir $DIR/R13b
1137 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1138 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1141 trap cleanup_multiop_pause EXIT
1142 mrename $DIR/R13a $DIR/R13b
1143 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1144 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1145 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1146 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1147 cleanup_multiop_pause
1148 wait $MULTIPID || error "multiop close failed"
1150 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1152 test_24r() { #bug 3789
1153 test_mkdir $DIR/R14a
1154 test_mkdir $DIR/R14a/b
1155 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1156 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1157 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1159 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1162 test_mkdir $DIR/R15a
1163 test_mkdir $DIR/R15a/b
1164 test_mkdir $DIR/R15a/b/c
1165 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1166 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1167 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1169 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1171 test_mkdir $DIR/R16a
1172 test_mkdir $DIR/R16a/b
1173 test_mkdir $DIR/R16a/b/c
1174 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1175 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1176 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1178 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1180 test_24u() { # bug12192
1181 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1182 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1184 run_test 24u "create stripe file"
1186 simple_cleanup_common() {
1189 [ -z "$DIR" ] || [ -z "$tdir" ] && return 0
1191 local start=$SECONDS
1194 wait_delete_completed
1195 echo "cleanup time $((SECONDS - start))"
1199 max_pages_per_rpc() {
1200 local mdtname="$(printf "MDT%04x" ${1:-0})"
1201 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1205 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1207 local nrfiles=${COUNT:-100000}
1208 local fname="$DIR/$tdir/$tfile"
1210 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1211 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1213 test_mkdir "$(dirname $fname)"
1214 # assume MDT0000 has the fewest inodes
1215 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1216 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1217 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1219 trap simple_cleanup_common EXIT
1221 createmany -m "$fname" $nrfiles
1223 cancel_lru_locks mdc
1224 lctl set_param mdc.*.stats clear
1226 # was previously test_24D: LU-6101
1227 # readdir() returns correct number of entries after cursor reload
1228 local num_ls=$(ls $DIR/$tdir | wc -l)
1229 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1230 local num_all=$(ls -a $DIR/$tdir | wc -l)
1231 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1232 [ $num_all -ne $((nrfiles + 2)) ]; then
1233 error "Expected $nrfiles files, got $num_ls " \
1234 "($num_uniq unique $num_all .&..)"
1236 # LU-5 large readdir
1237 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1238 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1239 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1240 # take into account of overhead in lu_dirpage header and end mark in
1241 # each page, plus one in rpc_num calculation.
1242 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1243 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1244 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1245 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1246 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1247 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1248 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1249 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1250 error "large readdir doesn't take effect: " \
1251 "$mds_readpage should be about $rpc_max"
1253 simple_cleanup_common
1255 run_test 24v "list large directory (test hash collision, b=17560)"
1257 test_24w() { # bug21506
1259 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1260 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1261 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1262 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1263 [[ "$SZ1" -eq "$SZ2" ]] ||
1264 error "Error reading at the end of the file $tfile"
1266 run_test 24w "Reading a file larger than 4Gb"
1269 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1270 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1271 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1272 skip "Need MDS version at least 2.7.56"
1275 local remote_dir=$DIR/$tdir/remote_dir
1277 test_mkdir $DIR/$tdir
1278 $LFS mkdir -i $MDTIDX $remote_dir ||
1279 error "create remote directory failed"
1281 test_mkdir $DIR/$tdir/src_dir
1282 touch $DIR/$tdir/src_file
1283 test_mkdir $remote_dir/tgt_dir
1284 touch $remote_dir/tgt_file
1286 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1287 error "rename dir cross MDT failed!"
1289 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1290 error "rename file cross MDT failed!"
1292 touch $DIR/$tdir/ln_file
1293 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1294 error "ln file cross MDT failed"
1296 rm -rf $DIR/$tdir || error "Can not delete directories"
1298 run_test 24x "cross MDT rename/link"
1301 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1302 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1304 local remote_dir=$DIR/$tdir/remote_dir
1307 test_mkdir $DIR/$tdir
1308 $LFS mkdir -i $mdtidx $remote_dir ||
1309 error "create remote directory failed"
1311 test_mkdir $remote_dir/src_dir
1312 touch $remote_dir/src_file
1313 test_mkdir $remote_dir/tgt_dir
1314 touch $remote_dir/tgt_file
1316 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1317 error "rename subdir in the same remote dir failed!"
1319 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1320 error "rename files in the same remote dir failed!"
1322 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1323 error "link files in the same remote dir failed!"
1325 rm -rf $DIR/$tdir || error "Can not delete directories"
1327 run_test 24y "rename/link on the same dir should succeed"
1330 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1331 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1332 skip "Need MDS version at least 2.12.51"
1336 for index in 0 1; do
1337 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1338 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1341 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1343 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1344 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1346 local mdts=$(comma_list $(mdts_nodes))
1348 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1349 stack_trap "do_nodes $mdts $LCTL \
1350 set_param mdt.*.enable_remote_rename=1" EXIT
1352 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1354 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1355 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1357 run_test 24z "cross-MDT rename is done as cp"
1359 test_24A() { # LU-3182
1363 test_mkdir $DIR/$tdir
1364 trap simple_cleanup_common EXIT
1365 createmany -m $DIR/$tdir/$tfile $NFILES
1366 local t=$(ls $DIR/$tdir | wc -l)
1367 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1368 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1369 if [ $t -ne $NFILES ] || [ $u -ne $NFILES ] ||
1370 [ $v -ne $((NFILES + 2)) ] ; then
1371 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1374 simple_cleanup_common || error "Can not delete directories"
1376 run_test 24A "readdir() returns correct number of entries."
1378 test_24B() { # LU-4805
1379 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1383 test_mkdir $DIR/$tdir
1384 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1385 error "create striped dir failed"
1387 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1388 [ $count -eq 2 ] || error "Expected 2, got $count"
1390 touch $DIR/$tdir/striped_dir/a
1392 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1393 [ $count -eq 3 ] || error "Expected 3, got $count"
1395 touch $DIR/$tdir/striped_dir/.f
1397 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1398 [ $count -eq 4 ] || error "Expected 4, got $count"
1400 rm -rf $DIR/$tdir || error "Can not delete directories"
1402 run_test 24B "readdir for striped dir return correct number of entries"
1405 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1411 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1412 error "create striped dir failed"
1414 cd $DIR/$tdir/d0/striped_dir
1416 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1417 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1418 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1420 [ "$d0_ino" = "$parent_ino" ] ||
1421 error ".. wrong, expect $d0_ino, get $parent_ino"
1423 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1424 error "mv striped dir failed"
1426 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1428 [ "$d1_ino" = "$parent_ino" ] ||
1429 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1431 run_test 24C "check .. in striped dir"
1434 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1438 mkdir $DIR/$tdir/src_dir
1439 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1440 error "create remote source failed"
1442 touch $DIR/$tdir/src_dir/src_child/a
1444 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1445 error "create remote target dir failed"
1447 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1448 error "create remote target child failed"
1450 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1451 error "rename dir cross MDT failed!"
1455 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1456 error "src_child still exists after rename"
1458 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1459 error "missing file(a) after rename"
1461 rm -rf $DIR/$tdir || error "Can not delete directories"
1463 run_test 24E "cross MDT rename/link"
1466 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1469 [ "$SLOW" = "no" ] && repeats=100
1473 echo "$repeats repeats"
1474 for ((i = 0; i < repeats; i++)); do
1475 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1476 touch $DIR/$tdir/test/a || error "touch fails"
1477 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1478 rm -rf $DIR/$tdir/test || error "rmdir fails"
1483 run_test 24F "hash order vs readdir (LU-11330)"
1486 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1491 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1492 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1493 touch $DIR/$tdir-0/f1 || error "touch f1"
1494 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1495 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1496 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1497 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1498 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1500 run_test 24G "migrate symlink in rename"
1503 echo '== symlink sanity ============================================='
1507 touch $DIR/s25/foo ||
1508 error "File creation in symlinked directory failed"
1510 run_test 25a "create file in symlinked directory ==============="
1513 [ ! -d $DIR/d25 ] && test_25a
1514 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1516 run_test 25b "lookup file in symlinked directory ==============="
1520 test_mkdir $DIR/d26/d26-2
1521 ln -s d26/d26-2 $DIR/s26
1522 touch $DIR/s26/foo || error "File creation failed"
1524 run_test 26a "multiple component symlink ======================="
1527 test_mkdir -p $DIR/$tdir/d26-2
1528 ln -s $tdir/d26-2/foo $DIR/s26-2
1529 touch $DIR/s26-2 || error "File creation failed"
1531 run_test 26b "multiple component symlink at end of lookup ======"
1534 test_mkdir $DIR/d26.2
1535 touch $DIR/d26.2/foo
1536 ln -s d26.2 $DIR/s26.2-1
1537 ln -s s26.2-1 $DIR/s26.2-2
1538 ln -s s26.2-2 $DIR/s26.2-3
1539 chmod 0666 $DIR/s26.2-3/foo
1541 run_test 26c "chain of symlinks"
1543 # recursive symlinks (bug 439)
1545 ln -s d26-3/foo $DIR/d26-3
1547 run_test 26d "create multiple component recursive symlink"
1550 [ ! -h $DIR/d26-3 ] && test_26d
1553 run_test 26e "unlink multiple component recursive symlink"
1555 # recursive symlinks (bug 7022)
1557 test_mkdir $DIR/$tdir
1558 test_mkdir $DIR/$tdir/$tfile
1559 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1560 test_mkdir -p lndir/bar1
1561 test_mkdir $DIR/$tdir/$tfile/$tfile
1562 cd $tfile || error "cd $tfile failed"
1563 ln -s .. dotdot || error "ln dotdot failed"
1564 ln -s dotdot/lndir lndir || error "ln lndir failed"
1565 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1566 output=`ls $tfile/$tfile/lndir/bar1`
1567 [ "$output" = bar1 ] && error "unexpected output"
1568 rm -r $tfile || error "rm $tfile failed"
1569 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1571 run_test 26f "rm -r of a directory which has recursive symlink"
1574 test_mkdir $DIR/$tdir
1575 $LFS getstripe $DIR/$tdir
1576 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1577 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1578 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1580 run_test 27a "one stripe file"
1583 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1585 test_mkdir $DIR/$tdir
1586 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1587 $LFS getstripe -c $DIR/$tdir/$tfile
1588 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1589 error "two-stripe file doesn't have two stripes"
1591 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1593 run_test 27b "create and write to two stripe file"
1595 # 27c family tests specific striping, setstripe -o
1597 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1598 test_mkdir -p $DIR/$tdir
1601 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1602 $LFS getstripe -i $DIR/$tdir/$tfile
1603 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1604 error "stripe not on specified OST"
1606 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1608 run_test 27ca "one stripe on specified OST"
1611 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1612 test_mkdir -p $DIR/$tdir
1614 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1615 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1618 # Strip getstripe output to a space separated list of OSTs
1619 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1620 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1621 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1622 error "stripes not on specified OSTs"
1624 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1626 run_test 27cb "two stripes on specified OSTs"
1629 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1630 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1631 skip "server does not support overstriping"
1633 test_mkdir -p $DIR/$tdir
1635 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1636 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1639 # Strip getstripe output to a space separated list of OSTs
1640 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1641 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1642 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1643 error "stripes not on specified OSTs"
1645 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1647 run_test 27cc "two stripes on the same OST"
1650 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1651 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1652 skip "server does not support overstriping"
1653 test_mkdir -p $DIR/$tdir
1654 local osts="0,1,1,0"
1655 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1656 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1659 # Strip getstripe output to a space separated list of OSTs
1660 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1661 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1662 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1663 error "stripes not on specified OSTs"
1665 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1667 run_test 27cd "four stripes on two OSTs"
1670 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1671 skip_env "too many osts, skipping"
1672 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1673 skip "server does not support overstriping"
1674 # We do one more stripe than we have OSTs
1675 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1676 skip_env "ea_inode feature disabled"
1678 test_mkdir -p $DIR/$tdir
1680 for i in $(seq 0 $OSTCOUNT);
1683 if [ $i -ne $OSTCOUNT ]; then
1687 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1688 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1691 # Strip getstripe output to a space separated list of OSTs
1692 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1693 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1694 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1695 error "stripes not on specified OSTs"
1697 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1699 run_test 27ce "more stripes than OSTs with -o"
1702 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1705 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1706 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1707 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1708 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1709 error "failed to set $osp_proc=0"
1711 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1714 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1715 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1716 error "failed to set $osp_proc=1"
1719 error "should return error due to $osp_proc=0"
1721 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1724 test_mkdir $DIR/$tdir
1725 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1726 error "setstripe failed"
1727 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1728 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1730 run_test 27d "create file with default settings"
1733 # LU-5839 adds check for existed layout before setting it
1734 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1735 skip "Need MDS version at least 2.7.56"
1737 test_mkdir $DIR/$tdir
1738 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1739 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1740 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1742 run_test 27e "setstripe existing file (should return error)"
1745 test_mkdir $DIR/$tdir
1746 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1747 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1748 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1749 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1750 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1751 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1753 run_test 27f "setstripe with bad stripe size (should return error)"
1756 test_mkdir $DIR/$tdir
1757 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1758 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1759 error "$DIR/$tdir/$tfile has object"
1761 run_test 27g "$LFS getstripe with no objects"
1764 test_mkdir $DIR/$tdir
1765 touch $DIR/$tdir/$tfile || error "touch failed"
1766 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1767 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1769 (( rc == 2 )) || error "getstripe did not return ENOENT"
1771 run_test 27ga "$LFS getstripe with missing file (should return error)"
1774 test_mkdir $DIR/$tdir
1775 touch $DIR/$tdir/$tfile || error "touch failed"
1776 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1777 error "missing objects"
1779 run_test 27i "$LFS getstripe with some objects"
1782 test_mkdir $DIR/$tdir
1783 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1784 error "setstripe failed" || true
1786 run_test 27j "setstripe with bad stripe offset (should return error)"
1788 test_27k() { # bug 2844
1789 test_mkdir $DIR/$tdir
1790 local file=$DIR/$tdir/$tfile
1791 local ll_max_blksize=$((4 * 1024 * 1024))
1792 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1793 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1794 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1795 dd if=/dev/zero of=$file bs=4k count=1
1796 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1797 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1799 run_test 27k "limit i_blksize for broken user apps"
1802 mcreate $DIR/$tfile || error "creating file"
1803 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1804 error "setstripe should have failed" || true
1806 run_test 27l "check setstripe permissions (should return error)"
1809 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1811 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1812 skip_env "multiple clients -- skipping"
1814 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1816 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1817 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1819 trap simple_cleanup_common EXIT
1820 test_mkdir $DIR/$tdir
1821 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1822 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1823 error "dd should fill OST0"
1825 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1827 [ $i -gt 256 ] && break
1830 touch $DIR/$tdir/$tfile.$i
1831 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1832 awk '{print $1}'| grep -w "0") ] &&
1833 error "OST0 was full but new created file still use it"
1835 touch $DIR/$tdir/$tfile.$i
1836 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1837 awk '{print $1}'| grep -w "0") ] &&
1838 error "OST0 was full but new created file still use it"
1839 simple_cleanup_common
1841 run_test 27m "create file while OST0 was full"
1843 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1844 # if the OST isn't full anymore.
1846 local ostidx=${1:-""}
1851 local list=$(comma_list $(osts_nodes))
1852 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1854 do_nodes $list lctl set_param fail_loc=0
1855 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1856 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1857 awk '{print $1 * 2;exit;}')
1858 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1860 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1863 __exhaust_precreations() {
1866 local FAILIDX=${3:-$OSTIDX}
1867 local ofacet=ost$((OSTIDX + 1))
1869 mkdir_on_mdt0 $DIR/$tdir
1870 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1871 local mfacet=mds$((mdtidx + 1))
1872 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1874 local OST=$(ostname_from_index $OSTIDX)
1877 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1878 local last_id=$(do_facet $mfacet lctl get_param -n \
1879 osp.$mdtosc_proc1.prealloc_last_id)
1880 local next_id=$(do_facet $mfacet lctl get_param -n \
1881 osp.$mdtosc_proc1.prealloc_next_id)
1883 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1884 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1886 test_mkdir -p $DIR/$tdir/${OST}
1887 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1888 #define OBD_FAIL_OST_ENOSPC 0x215
1889 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1890 echo "Creating to objid $last_id on ost $OST..."
1891 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1892 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1893 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1896 exhaust_precreations() {
1897 __exhaust_precreations $1 $2 $3
1901 exhaust_all_precreations() {
1903 for (( i=0; i < OSTCOUNT; i++ )) ; do
1904 __exhaust_precreations $i $1 -1
1910 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1911 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1912 remote_mds_nodsh && skip "remote MDS with nodsh"
1913 remote_ost_nodsh && skip "remote OST with nodsh"
1916 rm -f $DIR/$tdir/$tfile
1917 exhaust_precreations 0 0x80000215
1918 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1919 touch $DIR/$tdir/$tfile || error "touch failed"
1920 $LFS getstripe $DIR/$tdir/$tfile
1923 run_test 27n "create file with some full OSTs"
1926 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1928 remote_mds_nodsh && skip "remote MDS with nodsh"
1929 remote_ost_nodsh && skip "remote OST with nodsh"
1932 rm -f $DIR/$tdir/$tfile
1933 exhaust_all_precreations 0x215
1935 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1940 run_test 27o "create file with all full OSTs (should error)"
1942 function create_and_checktime() {
1947 for ((i=0; i < $loops; i++)); do
1948 local start=$SECONDS
1949 multiop $fname-$i Oc
1950 ((SECONDS-start < TIMEOUT)) ||
1951 error "creation took " $((SECONDS-$start)) && return 1
1956 local mdts=$(comma_list $(mdts_nodes))
1958 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1959 skip "Need MDS version at least 2.13.57"
1961 local f0=$DIR/${tfile}-0
1962 local f1=$DIR/${tfile}-1
1964 wait_delete_completed
1966 # refill precreated objects
1967 $LFS setstripe -i0 -c1 $f0
1969 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1970 # force QoS allocation policy
1971 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1972 stack_trap "do_nodes $mdts $LCTL set_param \
1973 lov.*.qos_threshold_rr=$saved" EXIT
1976 # one OST is unavailable, but still have few objects preallocated
1978 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1979 rm -rf $f1 $DIR/$tdir*" EXIT
1981 for ((i=0; i < 7; i++)); do
1982 mkdir $DIR/$tdir$i || error "can't create dir"
1983 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1984 error "can't set striping"
1986 for ((i=0; i < 7; i++)); do
1987 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1991 run_test 27oo "don't let few threads to reserve too many objects"
1994 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1995 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1996 remote_mds_nodsh && skip "remote MDS with nodsh"
1997 remote_ost_nodsh && skip "remote OST with nodsh"
2000 rm -f $DIR/$tdir/$tfile
2001 test_mkdir $DIR/$tdir
2003 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
2004 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
2005 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
2007 exhaust_precreations 0 0x80000215
2008 echo foo >> $DIR/$tdir/$tfile || error "append failed"
2009 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
2010 $LFS getstripe $DIR/$tdir/$tfile
2014 run_test 27p "append to a truncated file with some full OSTs"
2017 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2018 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2019 remote_mds_nodsh && skip "remote MDS with nodsh"
2020 remote_ost_nodsh && skip "remote OST with nodsh"
2023 rm -f $DIR/$tdir/$tfile
2025 mkdir_on_mdt0 $DIR/$tdir
2026 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
2027 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
2028 error "truncate $DIR/$tdir/$tfile failed"
2029 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
2031 exhaust_all_precreations 0x215
2033 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
2034 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
2038 run_test 27q "append to truncated file with all OSTs full (should error)"
2041 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2042 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2043 remote_mds_nodsh && skip "remote MDS with nodsh"
2044 remote_ost_nodsh && skip "remote OST with nodsh"
2047 rm -f $DIR/$tdir/$tfile
2048 exhaust_precreations 0 0x80000215
2050 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
2054 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
2056 test_27s() { # bug 10725
2057 test_mkdir $DIR/$tdir
2058 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2059 local stripe_count=0
2060 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2061 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2062 error "stripe width >= 2^32 succeeded" || true
2065 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2067 test_27t() { # bug 10864
2072 $WLFS getstripe $tfile
2075 run_test 27t "check that utils parse path correctly"
2077 test_27u() { # bug 4900
2078 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2079 remote_mds_nodsh && skip "remote MDS with nodsh"
2082 local list=$(comma_list $(mdts_nodes))
2084 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2085 do_nodes $list $LCTL set_param fail_loc=0x139
2086 test_mkdir -p $DIR/$tdir
2087 trap simple_cleanup_common EXIT
2088 createmany -o $DIR/$tdir/t- 1000
2089 do_nodes $list $LCTL set_param fail_loc=0
2091 TLOG=$TMP/$tfile.getstripe
2092 $LFS getstripe $DIR/$tdir > $TLOG
2093 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2094 unlinkmany $DIR/$tdir/t- 1000
2096 [[ $OBJS -gt 0 ]] &&
2097 error "$OBJS objects created on OST-0. See $TLOG" ||
2100 run_test 27u "skip object creation on OSC w/o objects"
2102 test_27v() { # bug 4900
2103 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2104 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2105 remote_mds_nodsh && skip "remote MDS with nodsh"
2106 remote_ost_nodsh && skip "remote OST with nodsh"
2108 exhaust_all_precreations 0x215
2111 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2113 touch $DIR/$tdir/$tfile
2114 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2116 for (( i=1; i < OSTCOUNT; i++ )); do
2117 do_facet ost$i lctl set_param fail_loc=0x705
2119 local START=`date +%s`
2120 createmany -o $DIR/$tdir/$tfile 32
2122 local FINISH=`date +%s`
2123 local TIMEOUT=`lctl get_param -n timeout`
2124 local PROCESS=$((FINISH - START))
2125 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2126 error "$FINISH - $START >= $TIMEOUT / 2"
2127 sleep $((TIMEOUT / 2 - PROCESS))
2130 run_test 27v "skip object creation on slow OST"
2132 test_27w() { # bug 10997
2133 test_mkdir $DIR/$tdir
2134 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2135 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2136 error "stripe size $size != 65536" || true
2137 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2138 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2140 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2143 [[ $OSTCOUNT -lt 2 ]] &&
2144 skip_env "skipping multiple stripe count/offset test"
2146 test_mkdir $DIR/$tdir
2147 for i in $(seq 1 $OSTCOUNT); do
2149 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2150 error "setstripe -c $i -i $offset failed"
2151 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2152 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2153 [ $count -ne $i ] && error "stripe count $count != $i" || true
2154 [ $index -ne $offset ] &&
2155 error "stripe offset $index != $offset" || true
2158 run_test 27wa "check $LFS setstripe -c -i options"
2161 remote_ost_nodsh && skip "remote OST with nodsh"
2162 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2163 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2165 OFFSET=$(($OSTCOUNT - 1))
2167 local OST=$(ostname_from_index $OSTIDX)
2169 test_mkdir $DIR/$tdir
2170 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2171 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2173 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2174 for i in $(seq 0 $OFFSET); do
2175 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2176 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2177 error "OST0 was degraded but new created file still use it"
2179 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2181 run_test 27x "create files while OST0 is degraded"
2184 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2185 remote_mds_nodsh && skip "remote MDS with nodsh"
2186 remote_ost_nodsh && skip "remote OST with nodsh"
2187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2189 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2190 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2191 osp.$mdtosc.prealloc_last_id)
2192 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2193 osp.$mdtosc.prealloc_next_id)
2194 local fcount=$((last_id - next_id))
2195 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2196 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2198 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2199 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2200 local OST_DEACTIVE_IDX=-1
2205 for OSC in $MDS_OSCS; do
2206 OST=$(osc_to_ost $OSC)
2207 OSTIDX=$(index_from_ostuuid $OST)
2208 if [ $OST_DEACTIVE_IDX == -1 ]; then
2209 OST_DEACTIVE_IDX=$OSTIDX
2211 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2212 echo $OSC "is Deactivated:"
2213 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2217 OSTIDX=$(index_from_ostuuid $OST)
2218 test_mkdir $DIR/$tdir
2219 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2221 for OSC in $MDS_OSCS; do
2222 OST=$(osc_to_ost $OSC)
2223 OSTIDX=$(index_from_ostuuid $OST)
2224 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2225 echo $OST "is degraded:"
2226 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2227 obdfilter.$OST.degraded=1
2232 createmany -o $DIR/$tdir/$tfile $fcount
2234 for OSC in $MDS_OSCS; do
2235 OST=$(osc_to_ost $OSC)
2236 OSTIDX=$(index_from_ostuuid $OST)
2237 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2238 echo $OST "is recovered from degraded:"
2239 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2240 obdfilter.$OST.degraded=0
2242 do_facet $SINGLEMDS lctl --device %$OSC activate
2246 # all osp devices get activated, hence -1 stripe count restored
2247 local stripe_count=0
2249 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2250 # devices get activated.
2252 $LFS setstripe -c -1 $DIR/$tfile
2253 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2255 [ $stripe_count -ne $OSTCOUNT ] &&
2256 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2259 run_test 27y "create files while OST0 is degraded and the rest inactive"
2265 lmm_count=$($LFS getstripe -c $1)
2266 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2267 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2269 local old_ifs="$IFS"
2271 fid=($($LFS path2fid $1))
2274 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2275 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2277 # compare lmm_seq and lu_fid->f_seq
2278 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2279 # compare lmm_object_id and lu_fid->oid
2280 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2282 # check the trusted.fid attribute of the OST objects of the file
2283 local have_obdidx=false
2285 $LFS getstripe $1 | while read obdidx oid hex seq; do
2286 # skip lines up to and including "obdidx"
2287 [ -z "$obdidx" ] && break
2288 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2289 $have_obdidx || continue
2291 local ost=$((obdidx + 1))
2292 local dev=$(ostdevname $ost)
2295 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2297 seq=$(echo $seq | sed -e "s/^0x//g")
2298 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2299 oid_hex=$(echo $oid)
2301 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2303 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2307 # Don't unmount/remount the OSTs if we don't need to do that.
2308 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2309 # update too, until that use mount/ll_decode_filter_fid/mount.
2310 # Re-enable when debugfs will understand new filter_fid.
2312 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2313 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2314 $dev 2>/dev/null" | grep "parent=")
2316 if [ -z "$ff" ]; then
2318 mount_fstype ost$ost
2319 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2320 $(facet_mntpt ost$ost)/$obj_file)
2321 unmount_fstype ost$ost
2322 start ost$ost $dev $OST_MOUNT_OPTS
2326 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2328 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2330 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2331 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2333 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2334 # stripe_size=1048576 component_id=1 component_start=0 \
2335 # component_end=33554432
2336 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2337 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2338 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2340 if grep -q 'stripe=' <<<$ff; then
2341 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2343 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2344 # into f_ver in this case. See comment on ff_parent.
2345 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2348 # compare lmm_seq and filter_fid->ff_parent.f_seq
2349 [ $ff_pseq = $lmm_seq ] ||
2350 error "FF parent SEQ $ff_pseq != $lmm_seq"
2351 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2352 [ $ff_poid = $lmm_oid ] ||
2353 error "FF parent OID $ff_poid != $lmm_oid"
2354 (($ff_pstripe == $stripe_nr)) ||
2355 error "FF stripe $ff_pstripe != $stripe_nr"
2357 stripe_nr=$((stripe_nr + 1))
2358 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2360 if grep -q 'stripe_count=' <<<$ff; then
2361 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2362 -e 's/ .*//' <<<$ff)
2363 [ $lmm_count = $ff_scnt ] ||
2364 error "FF stripe count $lmm_count != $ff_scnt"
2370 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2371 remote_ost_nodsh && skip "remote OST with nodsh"
2373 test_mkdir $DIR/$tdir
2374 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2375 { error "setstripe -c -1 failed"; return 1; }
2376 # We need to send a write to every object to get parent FID info set.
2377 # This _should_ also work for setattr, but does not currently.
2378 # touch $DIR/$tdir/$tfile-1 ||
2379 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2380 { error "dd $tfile-1 failed"; return 2; }
2381 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2382 { error "setstripe -c -1 failed"; return 3; }
2383 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2384 { error "dd $tfile-2 failed"; return 4; }
2386 # make sure write RPCs have been sent to OSTs
2389 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2390 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2392 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2394 test_27A() { # b=19102
2395 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2397 save_layout_restore_at_exit $MOUNT
2398 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2399 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2400 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2401 local default_size=$($LFS getstripe -S $MOUNT)
2402 local default_offset=$($LFS getstripe -i $MOUNT)
2403 local dsize=$(do_facet $SINGLEMDS \
2404 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2405 [ $default_size -eq $dsize ] ||
2406 error "stripe size $default_size != $dsize"
2407 [ $default_offset -eq -1 ] ||
2408 error "stripe offset $default_offset != -1"
2410 run_test 27A "check filesystem-wide default LOV EA values"
2412 test_27B() { # LU-2523
2413 test_mkdir $DIR/$tdir
2414 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2416 # open f1 with O_LOV_DELAY_CREATE
2418 # call setstripe ioctl on open file descriptor for f1
2420 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2424 # open f1 with O_LOV_DELAY_CREATE
2426 # call setstripe ioctl on open file descriptor for f1
2428 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2430 # Allow multiop to fail in imitation of NFS's busted semantics.
2433 run_test 27B "call setstripe on open unlinked file/rename victim"
2435 # 27C family tests full striping and overstriping
2436 test_27Ca() { #LU-2871
2437 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2445 test_mkdir $DIR/$tdir
2447 for i in $(seq 0 $((OSTCOUNT - 1))); do
2448 # set stripe across all OSTs starting from OST$i
2449 $LFS setstripe -i $i -c -1 $tfile$i
2450 # get striping information
2451 ost_idx=($($LFS getstripe $tfile$i |
2452 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2456 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2457 error "${#ost_idx[@]} != $OSTCOUNT"
2459 for index in $(seq 0 $((OSTCOUNT - 1))); do
2461 for j in $(echo ${ost_idx[@]}); do
2462 if [ $index -eq $j ]; then
2468 error "Can not find $index in ${ost_idx[@]}"
2472 run_test 27Ca "check full striping across all OSTs"
2475 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2476 skip "server does not support overstriping"
2477 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2478 skip_env "too many osts, skipping"
2480 test_mkdir -p $DIR/$tdir
2481 local setcount=$(($OSTCOUNT * 2))
2482 [ $setcount -lt 160 ] || large_xattr_enabled ||
2483 skip_env "ea_inode feature disabled"
2485 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2486 error "setstripe failed"
2488 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2489 [ $count -eq $setcount ] ||
2490 error "stripe count $count, should be $setcount"
2492 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2493 error "overstriped should be set in pattern"
2495 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2498 run_test 27Cb "more stripes than OSTs with -C"
2501 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2502 skip "server does not support overstriping"
2503 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2505 test_mkdir -p $DIR/$tdir
2506 local setcount=$(($OSTCOUNT - 1))
2508 [ $setcount -lt 160 ] || large_xattr_enabled ||
2509 skip_env "ea_inode feature disabled"
2511 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2512 error "setstripe failed"
2514 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2515 [ $count -eq $setcount ] ||
2516 error "stripe count $count, should be $setcount"
2518 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2519 error "overstriped should not be set in pattern"
2521 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2524 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2527 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2528 skip "server does not support overstriping"
2529 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2530 large_xattr_enabled || skip_env "ea_inode feature disabled"
2532 test_mkdir -p $DIR/$tdir
2533 local setcount=$LOV_MAX_STRIPE_COUNT
2535 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2536 error "setstripe failed"
2538 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2539 [ $count -eq $setcount ] ||
2540 error "stripe count $count, should be $setcount"
2542 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2543 error "overstriped should be set in pattern"
2545 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2548 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2550 run_test 27Cd "test maximum stripe count"
2553 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2554 skip "server does not support overstriping"
2555 test_mkdir -p $DIR/$tdir
2557 pool_add $TESTNAME || error "Pool creation failed"
2558 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2562 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2563 error "setstripe failed"
2565 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2566 [ $count -eq $setcount ] ||
2567 error "stripe count $count, should be $setcount"
2569 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2570 error "overstriped should be set in pattern"
2572 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2575 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2577 run_test 27Ce "test pool with overstriping"
2580 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2581 skip "server does not support overstriping"
2582 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2583 skip_env "too many osts, skipping"
2585 test_mkdir -p $DIR/$tdir
2587 local setcount=$(($OSTCOUNT * 2))
2588 [ $setcount -lt 160 ] || large_xattr_enabled ||
2589 skip_env "ea_inode feature disabled"
2591 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2592 error "setstripe failed"
2594 echo 1 > $DIR/$tdir/$tfile
2596 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2597 [ $count -eq $setcount ] ||
2598 error "stripe count $count, should be $setcount"
2600 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2601 error "overstriped should be set in pattern"
2603 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2606 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2608 run_test 27Cf "test default inheritance with overstriping"
2611 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2612 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2613 remote_mds_nodsh && skip "remote MDS with nodsh"
2615 local POOL=${POOL:-testpool}
2617 local last_ost=$(($OSTCOUNT - 1))
2619 local ost_list=$(seq $first_ost $ost_step $last_ost)
2620 local ost_range="$first_ost $last_ost $ost_step"
2622 test_mkdir $DIR/$tdir
2623 pool_add $POOL || error "pool_add failed"
2624 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2627 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2629 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2630 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2631 skip27D+=" -s 30,31"
2632 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2633 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2634 skip27D+=" -s 32,33"
2635 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2637 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2638 error "llapi_layout_test failed"
2640 destroy_test_pools || error "destroy test pools failed"
2642 run_test 27D "validate llapi_layout API"
2644 # Verify that default_easize is increased from its initial value after
2645 # accessing a widely striped file.
2647 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2648 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2649 skip "client does not have LU-3338 fix"
2651 # 72 bytes is the minimum space required to store striping
2652 # information for a file striped across one OST:
2653 # (sizeof(struct lov_user_md_v3) +
2654 # sizeof(struct lov_user_ost_data_v1))
2656 $LCTL set_param -n llite.*.default_easize $min_easize ||
2657 error "lctl set_param failed"
2658 local easize=$($LCTL get_param -n llite.*.default_easize)
2660 [ $easize -eq $min_easize ] ||
2661 error "failed to set default_easize"
2663 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2664 error "setstripe failed"
2665 # In order to ensure stat() call actually talks to MDS we need to
2666 # do something drastic to this file to shake off all lock, e.g.
2667 # rename it (kills lookup lock forcing cache cleaning)
2668 mv $DIR/$tfile $DIR/${tfile}-1
2669 ls -l $DIR/${tfile}-1
2672 easize=$($LCTL get_param -n llite.*.default_easize)
2674 [ $easize -gt $min_easize ] ||
2675 error "default_easize not updated"
2677 run_test 27E "check that default extended attribute size properly increases"
2679 test_27F() { # LU-5346/LU-7975
2680 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2681 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2682 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2683 skip "Need MDS version at least 2.8.51"
2684 remote_ost_nodsh && skip "remote OST with nodsh"
2686 test_mkdir $DIR/$tdir
2688 $LFS setstripe -c 2 $DIR/$tdir
2690 # stop all OSTs to reproduce situation for LU-7975 ticket
2691 for num in $(seq $OSTCOUNT); do
2695 # open/create f0 with O_LOV_DELAY_CREATE
2696 # truncate f0 to a non-0 size
2698 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2700 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2701 # open/write it again to force delayed layout creation
2702 cat /etc/hosts > $DIR/$tdir/f0 &
2706 for num in $(seq $OSTCOUNT); do
2707 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2708 error "ost$num failed to start"
2711 wait $catpid || error "cat failed"
2713 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2714 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2715 error "wrong stripecount"
2718 run_test 27F "Client resend delayed layout creation with non-zero size"
2720 test_27G() { #LU-10629
2721 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2722 skip "Need MDS version at least 2.11.51"
2723 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2724 remote_mds_nodsh && skip "remote MDS with nodsh"
2725 local POOL=${POOL:-testpool}
2726 local ostrange="0 0 1"
2728 test_mkdir $DIR/$tdir
2729 touch $DIR/$tdir/$tfile.nopool
2730 pool_add $POOL || error "pool_add failed"
2731 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2732 $LFS setstripe -p $POOL $DIR/$tdir
2734 local pool=$($LFS getstripe -p $DIR/$tdir)
2736 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2737 touch $DIR/$tdir/$tfile.default
2738 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2739 $LFS find $DIR/$tdir -type f --pool $POOL
2740 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2741 [[ "$found" == "2" ]] ||
2742 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2744 $LFS setstripe -d $DIR/$tdir
2746 pool=$($LFS getstripe -p -d $DIR/$tdir)
2748 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2750 run_test 27G "Clear OST pool from stripe"
2753 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2754 skip "Need MDS version newer than 2.11.54"
2755 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2756 test_mkdir $DIR/$tdir
2757 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2758 touch $DIR/$tdir/$tfile
2759 $LFS getstripe -c $DIR/$tdir/$tfile
2760 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2761 error "two-stripe file doesn't have two stripes"
2763 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2764 $LFS getstripe -y $DIR/$tdir/$tfile
2765 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2766 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2767 error "expected l_ost_idx: [02]$ not matched"
2769 # make sure ost list has been cleared
2770 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2771 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2772 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2774 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2776 run_test 27H "Set specific OSTs stripe"
2779 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2780 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2781 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2782 skip "Need MDS version newer than 2.12.52"
2783 local pool=$TESTNAME
2784 local ostrange="1 1 1"
2786 save_layout_restore_at_exit $MOUNT
2787 $LFS setstripe -c 2 -i 0 $MOUNT
2788 pool_add $pool || error "pool_add failed"
2789 pool_add_targets $pool $ostrange ||
2790 error "pool_add_targets failed"
2791 test_mkdir $DIR/$tdir
2792 $LFS setstripe -p $pool $DIR/$tdir
2793 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2794 $LFS getstripe $DIR/$tdir/$tfile
2796 run_test 27I "check that root dir striping does not break parent dir one"
2799 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2800 skip "Need MDS version newer than 2.12.51"
2802 test_mkdir $DIR/$tdir
2803 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2804 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2806 # create foreign file (raw way)
2807 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2808 error "creating $tfile w/ hex flags w/o --foreign should fail"
2810 ! $LFS setstripe --foreign --flags foo \
2811 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2812 error "creating $tfile with '--flags foo' should fail"
2814 ! $LFS setstripe --foreign --flags 0xffffffff \
2815 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2816 error "creating $tfile w/ 0xffffffff flags should fail"
2818 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2819 -t 1 -F 0xda08 || error "create_foreign_file failed"
2821 # verify foreign file (raw way)
2822 parse_foreign_file -f $DIR/$tdir/$tfile |
2823 grep "lov_foreign_magic: 0x0BD70BD0" ||
2824 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2825 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2826 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2827 parse_foreign_file -f $DIR/$tdir/$tfile |
2828 grep "lov_foreign_size: 73" ||
2829 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2830 parse_foreign_file -f $DIR/$tdir/$tfile |
2831 grep "lov_foreign_type: 1" ||
2832 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2833 parse_foreign_file -f $DIR/$tdir/$tfile |
2834 grep "lov_foreign_flags: 0x0000DA08" ||
2835 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2836 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2837 grep "lov_foreign_value: 0x" |
2838 sed -e 's/lov_foreign_value: 0x//')
2839 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2840 [[ $lov = ${lov2// /} ]] ||
2841 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2843 # create foreign file (lfs + API)
2844 $LFS setstripe --foreign=none --flags 0xda08 \
2845 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2846 error "$DIR/$tdir/${tfile}2: create failed"
2848 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2849 grep "lfm_magic:.*0x0BD70BD0" ||
2850 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2851 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2852 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2853 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2854 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2855 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2856 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2857 grep "lfm_flags:.*0x0000DA08" ||
2858 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2859 $LFS getstripe $DIR/$tdir/${tfile}2 |
2860 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2861 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2863 # modify striping should fail
2864 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2865 error "$DIR/$tdir/$tfile: setstripe should fail"
2866 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2867 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2870 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2871 cat $DIR/$tdir/${tfile}2 &&
2872 error "$DIR/$tdir/${tfile}2: read should fail"
2873 cat /etc/passwd > $DIR/$tdir/$tfile &&
2874 error "$DIR/$tdir/$tfile: write should fail"
2875 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2876 error "$DIR/$tdir/${tfile}2: write should fail"
2879 chmod 222 $DIR/$tdir/$tfile ||
2880 error "$DIR/$tdir/$tfile: chmod failed"
2881 chmod 222 $DIR/$tdir/${tfile}2 ||
2882 error "$DIR/$tdir/${tfile}2: chmod failed"
2885 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2886 error "$DIR/$tdir/$tfile: chown failed"
2887 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2888 error "$DIR/$tdir/${tfile}2: chown failed"
2890 # rename should work
2891 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2892 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2893 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2894 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2896 #remove foreign file
2897 rm $DIR/$tdir/${tfile}.new ||
2898 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2899 rm $DIR/$tdir/${tfile}2.new ||
2900 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2902 run_test 27J "basic ops on file with foreign LOV"
2905 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2906 skip "Need MDS version newer than 2.12.49"
2908 test_mkdir $DIR/$tdir
2909 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2910 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2912 # create foreign dir (raw way)
2913 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2914 error "creating $tdir w/ hex flags w/o --foreign should fail"
2916 ! $LFS setdirstripe --foreign --flags foo \
2917 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2918 error "creating $tdir with '--flags foo' should fail"
2920 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2921 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2922 error "creating $tdir w/ 0xffffffff flags should fail"
2924 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2925 error "create_foreign_dir FAILED"
2927 # verify foreign dir (raw way)
2928 parse_foreign_dir -d $DIR/$tdir/$tdir |
2929 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2930 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2931 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2932 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2933 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2934 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2935 parse_foreign_dir -d $DIR/$tdir/$tdir |
2936 grep "lmv_foreign_flags: 55813$" ||
2937 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2938 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2939 grep "lmv_foreign_value: 0x" |
2940 sed 's/lmv_foreign_value: 0x//')
2941 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2943 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2945 # create foreign dir (lfs + API)
2946 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2947 $DIR/$tdir/${tdir}2 ||
2948 error "$DIR/$tdir/${tdir}2: create failed"
2950 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2951 grep "lfm_magic:.*0x0CD50CD0" ||
2952 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2953 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2954 # - sizeof(lfm_type) - sizeof(lfm_flags)
2955 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2956 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2957 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2958 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2959 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2960 grep "lfm_flags:.*0x0000DA05" ||
2961 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2962 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2963 grep "lfm_value.*${uuid1}@${uuid2}" ||
2964 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2966 # file create in dir should fail
2967 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2968 touch $DIR/$tdir/${tdir}2/$tfile &&
2969 "$DIR/${tdir}2: file create should fail"
2972 chmod 777 $DIR/$tdir/$tdir ||
2973 error "$DIR/$tdir: chmod failed"
2974 chmod 777 $DIR/$tdir/${tdir}2 ||
2975 error "$DIR/${tdir}2: chmod failed"
2978 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2979 error "$DIR/$tdir: chown failed"
2980 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2981 error "$DIR/${tdir}2: chown failed"
2983 # rename should work
2984 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2985 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2986 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2987 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2990 rmdir $DIR/$tdir/${tdir}.new ||
2991 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2992 rmdir $DIR/$tdir/${tdir}2.new ||
2993 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2995 run_test 27K "basic ops on dir with foreign LMV"
2998 remote_mds_nodsh && skip "remote MDS with nodsh"
3000 local POOL=${POOL:-$TESTNAME}
3002 pool_add $POOL || error "pool_add failed"
3004 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
3005 error "pool_list does not contain ${FSNAME}.${POOL}:" \
3006 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
3008 run_test 27L "lfs pool_list gives correct pool name"
3011 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
3012 skip "Need MDS version >= than 2.12.57"
3013 remote_mds_nodsh && skip "remote MDS with nodsh"
3014 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
3016 test_mkdir $DIR/$tdir
3018 # Set default striping on directory
3022 # if we run against a 2.12 server which lacks overstring support
3023 # then the connect_flag will not report overstriping, even if client
3025 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
3026 stripe_opt="-C $setcount"
3027 elif (( $OSTCOUNT >= $setcount )); then
3028 stripe_opt="-c $setcount"
3030 skip "server does not support overstriping"
3032 $LFS setstripe $stripe_opt $DIR/$tdir
3034 echo 1 > $DIR/$tdir/${tfile}.1
3035 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
3036 [ $count -eq $setcount ] ||
3037 error "(1) stripe count $count, should be $setcount"
3039 # Capture existing append_stripe_count setting for restore
3040 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3041 local mdts=$(comma_list $(mdts_nodes))
3042 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
3044 local appendcount=$orig_count
3045 echo 1 >> $DIR/$tdir/${tfile}.2_append
3046 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
3047 [ $count -eq $appendcount ] ||
3048 error "(2)stripe count $count, should be $appendcount for append"
3050 # Disable O_APPEND striping, verify it works
3051 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3053 # Should now get the default striping, which is 4
3055 echo 1 >> $DIR/$tdir/${tfile}.3_append
3056 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3057 [ $count -eq $setcount ] ||
3058 error "(3) stripe count $count, should be $setcount"
3060 # Try changing the stripe count for append files
3061 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3063 # Append striping is now 2 (directory default is still 4)
3065 echo 1 >> $DIR/$tdir/${tfile}.4_append
3066 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3067 [ $count -eq $appendcount ] ||
3068 error "(4) stripe count $count, should be $appendcount for append"
3070 # Test append stripe count of -1
3071 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3072 appendcount=$OSTCOUNT
3073 echo 1 >> $DIR/$tdir/${tfile}.5
3074 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3075 [ $count -eq $appendcount ] ||
3076 error "(5) stripe count $count, should be $appendcount for append"
3078 # Set append striping back to default of 1
3079 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3081 # Try a new default striping, PFL + DOM
3082 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3084 # Create normal DOM file, DOM returns stripe count == 0
3086 touch $DIR/$tdir/${tfile}.6
3087 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3088 [ $count -eq $setcount ] ||
3089 error "(6) stripe count $count, should be $setcount"
3093 echo 1 >> $DIR/$tdir/${tfile}.7_append
3094 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3095 [ $count -eq $appendcount ] ||
3096 error "(7) stripe count $count, should be $appendcount for append"
3098 # Clean up DOM layout
3099 $LFS setstripe -d $DIR/$tdir
3101 save_layout_restore_at_exit $MOUNT
3102 # Now test that append striping works when layout is from root
3103 $LFS setstripe -c 2 $MOUNT
3104 # Make a special directory for this
3105 mkdir $DIR/${tdir}/${tdir}.2
3107 # Verify for normal file
3109 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3110 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3111 [ $count -eq $setcount ] ||
3112 error "(8) stripe count $count, should be $setcount"
3115 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3116 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3117 [ $count -eq $appendcount ] ||
3118 error "(9) stripe count $count, should be $appendcount for append"
3120 # Now test O_APPEND striping with pools
3121 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3122 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
3125 pool_add $TESTNAME || error "pool creation failed"
3126 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3128 echo 1 >> $DIR/$tdir/${tfile}.10_append
3130 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3131 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3133 # Check that count is still correct
3135 echo 1 >> $DIR/$tdir/${tfile}.11_append
3136 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3137 [ $count -eq $appendcount ] ||
3138 error "(11) stripe count $count, should be $appendcount for append"
3140 # Disable O_APPEND stripe count, verify pool works separately
3141 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3143 echo 1 >> $DIR/$tdir/${tfile}.12_append
3145 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3146 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3148 # Remove pool setting, verify it's not applied
3149 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3151 echo 1 >> $DIR/$tdir/${tfile}.13_append
3153 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3154 [ "$pool" = "" ] || error "(13) pool found: $pool"
3156 run_test 27M "test O_APPEND striping"
3159 combined_mgs_mds && skip "needs separate MGS/MDT"
3161 pool_add $TESTNAME || error "pool_add failed"
3162 do_facet mgs "$LCTL pool_list $FSNAME" |
3163 grep -Fx "${FSNAME}.${TESTNAME}" ||
3164 error "lctl pool_list on MGS failed"
3166 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3168 clean_foreign_symlink() {
3170 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3171 for i in $DIR/$tdir/* ; do
3172 $LFS unlink_foreign $i || true
3177 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3178 skip "Need MDS version newer than 2.12.51"
3180 test_mkdir $DIR/$tdir
3181 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3182 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3184 trap clean_foreign_symlink EXIT
3186 # enable foreign_symlink behaviour
3187 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3189 # foreign symlink LOV format is a partial path by default
3191 # create foreign file (lfs + API)
3192 $LFS setstripe --foreign=symlink --flags 0xda05 \
3193 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3194 error "$DIR/$tdir/${tfile}: create failed"
3196 $LFS getstripe -v $DIR/$tdir/${tfile} |
3197 grep "lfm_magic:.*0x0BD70BD0" ||
3198 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3199 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3200 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3201 $LFS getstripe -v $DIR/$tdir/${tfile} |
3202 grep "lfm_flags:.*0x0000DA05" ||
3203 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3204 $LFS getstripe $DIR/$tdir/${tfile} |
3205 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3206 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3208 # modify striping should fail
3209 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3210 error "$DIR/$tdir/$tfile: setstripe should fail"
3212 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3213 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3214 cat /etc/passwd > $DIR/$tdir/$tfile &&
3215 error "$DIR/$tdir/$tfile: write should fail"
3217 # rename should succeed
3218 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3219 error "$DIR/$tdir/$tfile: rename has failed"
3221 #remove foreign_symlink file should fail
3222 rm $DIR/$tdir/${tfile}.new &&
3223 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3226 mkdir /tmp/${uuid1} ||
3227 error "/tmp/${uuid1}: mkdir has failed"
3228 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3229 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3230 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3231 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3232 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3233 #read should succeed now
3234 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3235 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3236 #write should succeed now
3237 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3238 error "$DIR/$tdir/${tfile}.new: write should succeed"
3239 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3240 error "$DIR/$tdir/${tfile}.new: diff has failed"
3241 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3242 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3244 #check that getstripe still works
3245 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3246 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3248 # chmod should still succeed
3249 chmod 644 $DIR/$tdir/${tfile}.new ||
3250 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3252 # chown should still succeed
3253 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3254 error "$DIR/$tdir/${tfile}.new: chown has failed"
3256 # rename should still succeed
3257 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3258 error "$DIR/$tdir/${tfile}.new: rename has failed"
3260 #remove foreign_symlink file should still fail
3261 rm $DIR/$tdir/${tfile} &&
3262 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3264 #use special ioctl() to unlink foreign_symlink file
3265 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3266 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3269 run_test 27O "basic ops on foreign file of symlink type"
3272 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3273 skip "Need MDS version newer than 2.12.49"
3275 test_mkdir $DIR/$tdir
3276 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3277 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3279 trap clean_foreign_symlink EXIT
3281 # enable foreign_symlink behaviour
3282 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3284 # foreign symlink LMV format is a partial path by default
3286 # create foreign dir (lfs + API)
3287 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3288 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3289 error "$DIR/$tdir/${tdir}: create failed"
3291 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3292 grep "lfm_magic:.*0x0CD50CD0" ||
3293 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3294 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3295 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3296 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3297 grep "lfm_flags:.*0x0000DA05" ||
3298 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3299 $LFS getdirstripe $DIR/$tdir/${tdir} |
3300 grep "lfm_value.*${uuid1}/${uuid2}" ||
3301 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3303 # file create in dir should fail
3304 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3305 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
3307 # rename should succeed
3308 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3309 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3311 #remove foreign_symlink dir should fail
3312 rmdir $DIR/$tdir/${tdir}.new &&
3313 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3316 mkdir -p /tmp/${uuid1}/${uuid2} ||
3317 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3318 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3319 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3320 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3321 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3322 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3323 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3324 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3326 #check that getstripe fails now that foreign_symlink enabled
3327 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3328 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3330 # file create in dir should work now
3331 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3332 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3333 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3334 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3335 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3336 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3338 # chmod should still succeed
3339 chmod 755 $DIR/$tdir/${tdir}.new ||
3340 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3342 # chown should still succeed
3343 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3344 error "$DIR/$tdir/${tdir}.new: chown has failed"
3346 # rename should still succeed
3347 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3348 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3350 #remove foreign_symlink dir should still fail
3351 rmdir $DIR/$tdir/${tdir} &&
3352 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3354 #use special ioctl() to unlink foreign_symlink file
3355 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3356 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3358 #created file should still exist
3359 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3360 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3361 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3362 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3364 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3367 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3368 stack_trap "rm -f $TMP/$tfile*"
3370 test_mkdir $DIR/$tdir-1
3371 test_mkdir $DIR/$tdir-2
3373 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3374 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3376 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3377 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3379 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3380 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3382 # Create some bad symlinks and ensure that we don't loop
3383 # forever or something. These should return ELOOP (40) and
3384 # ENOENT (2) but I don't want to test for that because there's
3385 # always some weirdo architecture that needs to ruin
3386 # everything by defining these error numbers differently.
3388 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3389 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3391 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3392 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3396 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3398 # createtest also checks that device nodes are created and
3399 # then visible correctly (#2091)
3400 test_28() { # bug 2091
3402 $CREATETEST $DIR/d28/ct || error "createtest failed"
3404 run_test 28 "create/mknod/mkdir with bad file types ============"
3407 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3409 sync; sleep 1; sync # flush out any dirty pages from previous tests
3416 declare -i LOCKCOUNTORIG=0
3417 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3418 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3420 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3422 declare -i LOCKUNUSEDCOUNTORIG=0
3423 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3424 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3431 declare -i LOCKCOUNTCURRENT=0
3432 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3433 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3436 declare -i LOCKUNUSEDCOUNTCURRENT=0
3437 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3438 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3441 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3442 $LCTL set_param -n ldlm.dump_namespaces ""
3443 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3444 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3445 log "dumped log to $TMP/test_29.dk (bug 5793)"
3448 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3449 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3450 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3451 log "dumped log to $TMP/test_29.dk (bug 5793)"
3455 run_test 29 "IT_GETATTR regression ============================"
3457 test_30a() { # was test_30
3458 cp $(which ls) $DIR || cp /bin/ls $DIR
3459 $DIR/ls / || error "Can't execute binary from lustre"
3462 run_test 30a "execute binary from Lustre (execve) =============="
3465 cp `which ls` $DIR || cp /bin/ls $DIR
3467 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3470 run_test 30b "execute binary from Lustre as non-root ==========="
3472 test_30c() { # b=22376
3473 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3475 cp $(which ls) $DIR || cp /bin/ls $DIR
3477 cancel_lru_locks mdc
3478 cancel_lru_locks osc
3479 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3482 run_test 30c "execute binary from Lustre without read perms ===="
3485 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3487 for i in {1..10}; do
3488 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3491 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3492 wait $PID || error "executing dd from Lustre failed"
3498 run_test 30d "execute binary from Lustre while clear locks"
3501 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3502 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3504 run_test 31a "open-unlink file =================================="
3507 touch $DIR/f31 || error "touch $DIR/f31 failed"
3508 ln $DIR/f31 $DIR/f31b || error "ln failed"
3509 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3510 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3512 run_test 31b "unlink file with multiple links while open ======="
3515 touch $DIR/f31 || error "touch $DIR/f31 failed"
3516 ln $DIR/f31 $DIR/f31c || error "ln failed"
3517 multiop_bg_pause $DIR/f31 O_uc ||
3518 error "multiop_bg_pause for $DIR/f31 failed"
3520 $MULTIOP $DIR/f31c Ouc
3521 kill -USR1 $MULTIPID
3524 run_test 31c "open-unlink file with multiple links ============="
3527 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3528 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3530 run_test 31d "remove of open directory ========================="
3532 test_31e() { # bug 2904
3533 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3535 run_test 31e "remove of open non-empty directory ==============="
3537 test_31f() { # bug 4554
3538 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3541 test_mkdir $DIR/d31f
3542 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3543 cp /etc/hosts $DIR/d31f
3545 $LFS getstripe $DIR/d31f/hosts
3546 multiop_bg_pause $DIR/d31f D_c || return 1
3549 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3550 test_mkdir $DIR/d31f
3551 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3552 cp /etc/hosts $DIR/d31f
3554 $LFS getstripe $DIR/d31f/hosts
3555 multiop_bg_pause $DIR/d31f D_c || return 1
3558 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3559 wait $MULTIPID || error "first opendir $MULTIPID failed"
3563 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3564 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3567 run_test 31f "remove of open directory with open-unlink file ==="
3570 echo "-- cross directory link --"
3571 test_mkdir -c1 $DIR/${tdir}ga
3572 test_mkdir -c1 $DIR/${tdir}gb
3573 touch $DIR/${tdir}ga/f
3574 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3575 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3576 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3577 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3578 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3580 run_test 31g "cross directory link==============="
3583 echo "-- cross directory link --"
3584 test_mkdir -c1 $DIR/${tdir}
3585 test_mkdir -c1 $DIR/${tdir}/dir
3586 touch $DIR/${tdir}/f
3587 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3588 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3589 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3590 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3591 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3593 run_test 31h "cross directory link under child==============="
3596 echo "-- cross directory link --"
3597 test_mkdir -c1 $DIR/$tdir
3598 test_mkdir -c1 $DIR/$tdir/dir
3599 touch $DIR/$tdir/dir/f
3600 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3601 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3602 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3603 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3604 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3606 run_test 31i "cross directory link under parent==============="
3609 test_mkdir -c1 -p $DIR/$tdir
3610 test_mkdir -c1 -p $DIR/$tdir/dir1
3611 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3612 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3613 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3614 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3617 run_test 31j "link for directory==============="
3620 test_mkdir -c1 -p $DIR/$tdir
3622 touch $DIR/$tdir/exist
3623 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3624 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3625 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3626 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3627 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3628 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3629 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3632 run_test 31k "link to file: the same, non-existing, dir==============="
3638 touch $DIR/d31m2/exist
3639 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3640 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3641 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3642 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3643 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3644 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3647 run_test 31m "link to file: the same, non-existing, dir==============="
3650 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3651 nlink=$(stat --format=%h $DIR/$tfile)
3652 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3654 local cmd="exec $fd<$DIR/$tfile"
3657 trap "eval $cmd" EXIT
3658 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3659 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3660 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3661 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3662 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3665 run_test 31n "check link count of unlinked file"
3668 local tempfile=$(mktemp $1_XXXXXX)
3669 mlink $tempfile $1 2> /dev/null &&
3670 echo "$BASHPID: link $tempfile to $1 succeeded"
3674 test_31o() { # LU-2901
3675 test_mkdir $DIR/$tdir
3676 for LOOP in $(seq 100); do
3677 rm -f $DIR/$tdir/$tfile*
3678 for THREAD in $(seq 8); do
3679 link_one $DIR/$tdir/$tfile.$LOOP &
3682 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3683 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3684 error "$LINKS duplicate links to $tfile.$LOOP" &&
3688 run_test 31o "duplicate hard links with same filename"
3691 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3693 test_mkdir $DIR/$tdir
3694 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3695 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3697 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3698 error "open unlink test1 failed"
3699 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3700 error "open unlink test2 failed"
3702 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3703 error "test1 still exists"
3704 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3705 error "test2 still exists"
3707 run_test 31p "remove of open striped directory"
3710 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3712 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3713 index=$($LFS getdirstripe -i $DIR/$tdir)
3714 [ $index -eq 3 ] || error "first stripe index $index != 3"
3715 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3716 [ $index -eq 1 ] || error "second stripe index $index != 1"
3718 # when "-c <stripe_count>" is set, the number of MDTs specified after
3719 # "-i" should equal to the stripe count
3720 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3722 run_test 31q "create striped directory on specific MDTs"
3726 touch $DIR/$tfile.target
3727 touch $DIR/$tfile.source
3729 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
3730 $LCTL set_param fail_loc=0x1419 fail_val=3
3731 cat $DIR/$tfile.target &
3734 # Guarantee open is waiting before we get here
3736 mv $DIR/$tfile.source $DIR/$tfile.target
3740 if [[ $RC -ne 0 ]]; then
3741 error "open with cat failed, rc=$RC"
3744 run_test 31r "open-rename(replace) race"
3746 cleanup_test32_mount() {
3749 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3750 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3751 losetup -d $loopdev || true
3757 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3759 echo "== more mountpoints and symlinks ================="
3760 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3761 trap cleanup_test32_mount EXIT
3762 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3763 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3764 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3765 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3766 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3767 cleanup_test32_mount
3769 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3772 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3774 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3775 trap cleanup_test32_mount EXIT
3776 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3777 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3778 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3779 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3780 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3781 cleanup_test32_mount
3783 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3788 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3789 trap cleanup_test32_mount EXIT
3790 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3791 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3792 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3793 test_mkdir -p $DIR/$tdir/d2/test_dir
3794 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3795 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3796 cleanup_test32_mount
3798 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3801 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3803 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3804 trap cleanup_test32_mount EXIT
3805 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3806 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3807 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3808 test_mkdir -p $DIR/$tdir/d2/test_dir
3809 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3810 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3811 cleanup_test32_mount
3813 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3817 test_mkdir -p $DIR/$tdir/tmp
3818 local tmp_dir=$DIR/$tdir/tmp
3819 ln -s $DIR/$tdir $tmp_dir/symlink11
3820 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3821 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3822 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3824 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3828 test_mkdir -p $DIR/$tdir/tmp
3829 local tmp_dir=$DIR/$tdir/tmp
3830 ln -s $DIR/$tdir $tmp_dir/symlink11
3831 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3832 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3833 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3835 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3838 local tmp_dir=$DIR/$tdir/tmp
3839 test_mkdir -p $tmp_dir
3840 test_mkdir $DIR/${tdir}2
3841 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3842 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3843 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3844 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3845 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3846 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3848 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3851 rm -fr $DIR/$tdir $DIR/${tdir}2
3852 tmp_dir=$DIR/$tdir/tmp
3853 test_mkdir -p $tmp_dir
3854 test_mkdir $DIR/${tdir}2
3855 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3856 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3857 ls $tmp_dir/symlink12 || error "listing symlink12"
3858 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3860 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3863 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3865 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3866 trap cleanup_test32_mount EXIT
3867 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3868 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3869 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3870 touch $DIR/$tdir/test_file
3871 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3872 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3873 cleanup_test32_mount
3875 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3878 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3880 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3881 trap cleanup_test32_mount EXIT
3882 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3883 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3884 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3885 touch $DIR/$tdir/test_file
3886 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3887 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3888 cleanup_test32_mount
3890 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3893 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3896 trap cleanup_test32_mount EXIT
3897 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3898 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3899 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3900 test_mkdir -p $DIR/$tdir/d2
3901 touch $DIR/$tdir/d2/test_file || error "touch failed"
3902 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3903 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3904 cleanup_test32_mount
3906 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3912 trap cleanup_test32_mount EXIT
3913 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3914 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3915 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3916 test_mkdir -p $DIR/$tdir/d2
3917 touch $DIR/$tdir/d2/test_file || error "touch failed"
3918 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3919 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3920 cleanup_test32_mount
3922 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3926 test_mkdir -p $DIR/d32m/tmp
3927 TMP_DIR=$DIR/d32m/tmp
3928 ln -s $DIR $TMP_DIR/symlink11
3929 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3930 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3931 error "symlink11 not a link"
3932 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3933 error "symlink01 not a link"
3935 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3939 test_mkdir -p $DIR/d32n/tmp
3940 TMP_DIR=$DIR/d32n/tmp
3941 ln -s $DIR $TMP_DIR/symlink11
3942 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3943 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3944 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3946 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3950 test_mkdir -p $DIR/d32o/tmp
3951 TMP_DIR=$DIR/d32o/tmp
3952 ln -s $DIR/$tfile $TMP_DIR/symlink12
3953 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3954 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3955 error "symlink12 not a link"
3956 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3957 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3958 error "$DIR/d32o/tmp/symlink12 not file type"
3959 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3960 error "$DIR/d32o/symlink02 not file type"
3962 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3972 test_mkdir -p $DIR/d32p/tmp
3974 TMP_DIR=$DIR/d32p/tmp
3976 ln -s $DIR/$tfile $TMP_DIR/symlink12
3978 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3980 cat $DIR/d32p/tmp/symlink12 ||
3981 error "Can't open $DIR/d32p/tmp/symlink12"
3983 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3986 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3991 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3992 trap cleanup_test32_mount EXIT
3993 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3994 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3995 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3996 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3997 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3998 cleanup_test32_mount
4000 run_test 32q "stat follows mountpoints in Lustre (should return error)"
4003 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4005 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4006 trap cleanup_test32_mount EXIT
4007 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4008 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4009 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4010 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4011 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
4012 cleanup_test32_mount
4014 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
4019 chmod 444 $DIR/$tfile
4020 chown $RUNAS_ID $DIR/$tfile
4022 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4025 run_test 33aa "write file with mode 444 (should return error)"
4029 test_mkdir $DIR/$tdir
4030 chown $RUNAS_ID $DIR/$tdir
4031 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
4032 error "$RUNAS create $tdir/$tfile failed"
4033 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4034 error "open RDWR" || true
4036 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4040 test_mkdir $DIR/$tdir
4041 chown $RUNAS_ID $DIR/$tdir
4042 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4044 run_test 33b "test open file with malformed flags (No panic)"
4047 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4048 remote_ost_nodsh && skip "remote OST with nodsh"
4056 test_mkdir $DIR/$tdir
4057 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4060 for ostnum in $(seq $OSTCOUNT); do
4061 # test-framework's OST numbering is one-based, while Lustre's
4063 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4064 # check if at least some write_bytes stats are counted
4065 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4066 obdfilter.$ostname.stats |
4067 awk '/^write_bytes/ {print $7}' )
4068 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4069 if (( ${write_bytes:-0} > 0 )); then
4075 $all_zeros || return 0
4078 echo foo > $DIR/$tdir/bar
4082 # Total up write_bytes after writing. We'd better find non-zeros.
4083 for ostnum in $(seq $OSTCOUNT); do
4084 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4085 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4086 obdfilter/$ostname/stats |
4087 awk '/^write_bytes/ {print $7}' )
4088 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4089 if (( ${write_bytes:-0} > 0 )); then
4096 for ostnum in $(seq $OSTCOUNT); do
4097 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4098 echo "Check write_bytes is in obdfilter.*.stats:"
4099 do_facet ost$ostnum lctl get_param -n \
4100 obdfilter.$ostname.stats
4102 error "OST not keeping write_bytes stats (b=22312)"
4105 run_test 33c "test write_bytes stats"
4108 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4112 local remote_dir=$DIR/$tdir/remote_dir
4114 test_mkdir $DIR/$tdir
4115 $LFS mkdir -i $MDTIDX $remote_dir ||
4116 error "create remote directory failed"
4118 touch $remote_dir/$tfile
4119 chmod 444 $remote_dir/$tfile
4120 chown $RUNAS_ID $remote_dir/$tfile
4122 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4124 chown $RUNAS_ID $remote_dir
4125 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4126 error "create" || true
4127 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4128 error "open RDWR" || true
4129 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4131 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4134 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4138 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4139 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4140 mkdir $DIR/$tdir/local_dir
4142 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4143 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4144 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4146 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4147 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4149 rmdir $DIR/$tdir/* || error "rmdir failed"
4152 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4153 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4154 mkdir $DIR/$tdir/local_dir
4156 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4157 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4158 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4160 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4161 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4163 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4166 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4167 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4168 mkdir $DIR/$tdir/local_dir
4170 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4171 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4172 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4174 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4175 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4177 run_test 33e "mkdir and striped directory should have same mode"
4181 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4185 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4186 remote_mds_nodsh && skip "remote MDS with nodsh"
4189 chmod go+rwx $DIR/$tdir
4190 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4191 trap cleanup_33f EXIT
4193 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4194 error "cannot create striped directory"
4196 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4197 error "cannot create files in striped directory"
4199 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4200 error "cannot remove files in striped directory"
4202 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4203 error "cannot remove striped directory"
4207 run_test 33f "nonroot user can create, access, and remove a striped directory"
4210 mkdir -p $DIR/$tdir/dir2
4212 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4214 [[ $err =~ "exists" ]] || error "Not exists error"
4216 run_test 33g "nonroot user create already existing root created file"
4219 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4220 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
4221 skip "Need MDS version at least 2.13.50"
4223 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir ||
4224 error "mkdir $tdir failed"
4225 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4227 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4230 for fname in $DIR/$tdir/$tfile.bak \
4231 $DIR/$tdir/$tfile.SAV \
4232 $DIR/$tdir/$tfile.orig \
4233 $DIR/$tdir/$tfile~; do
4234 touch $fname || error "touch $fname failed"
4235 index2=$($LFS getstripe -m $fname)
4236 [ $index -eq $index2 ] ||
4237 error "$fname MDT index mismatch $index != $index2"
4241 for i in {1..250}; do
4242 for fname in $(mktemp -u $DIR/$tdir/.$tfile.XXXXXX) \
4243 $(mktemp $DIR/$tdir/$tfile.XXXXXXXX); do
4244 touch $fname || error "touch $fname failed"
4245 index2=$($LFS getstripe -m $fname)
4246 if [[ $index != $index2 ]]; then
4247 failed=$((failed + 1))
4248 echo "$fname MDT index mismatch $index != $index2"
4252 echo "$failed MDT index mismatches"
4253 (( failed < 20 )) || error "MDT index mismatch $failed times"
4256 run_test 33h "temp file is located on the same MDT as target"
4258 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4261 $MCREATE $DIR/f34 || error "mcreate failed"
4262 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4263 error "getstripe failed"
4264 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4265 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4266 error "getstripe failed"
4267 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4268 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4270 run_test 34a "truncate file that has not been opened ==========="
4273 [ ! -f $DIR/f34 ] && test_34a
4274 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4275 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4276 $OPENFILE -f O_RDONLY $DIR/f34
4277 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4278 error "getstripe failed"
4279 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4280 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4282 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4285 [ ! -f $DIR/f34 ] && test_34a
4286 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4287 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4288 $OPENFILE -f O_RDWR $DIR/f34
4289 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4290 error "$LFS getstripe failed"
4291 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4292 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4294 run_test 34c "O_RDWR opening file-with-size works =============="
4297 [ ! -f $DIR/f34 ] && test_34a
4298 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4300 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4301 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4304 run_test 34d "write to sparse file ============================="
4308 $MCREATE $DIR/f34e || error "mcreate failed"
4309 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4310 $CHECKSTAT -s 1000 $DIR/f34e ||
4311 error "Size of $DIR/f34e not equal to 1000 bytes"
4312 $OPENFILE -f O_RDWR $DIR/f34e
4313 $CHECKSTAT -s 1000 $DIR/f34e ||
4314 error "Size of $DIR/f34e not equal to 1000 bytes"
4316 run_test 34e "create objects, some with size and some without =="
4318 test_34f() { # bug 6242, 6243
4319 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4323 $MCREATE $DIR/f34f || error "mcreate failed"
4324 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4325 dd if=$DIR/f34f of=$TMP/f34f
4326 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4327 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4328 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4329 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4330 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4332 run_test 34f "read from a file with no objects until EOF ======="
4335 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4337 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4339 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4340 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4341 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4342 cancel_lru_locks osc
4343 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4344 error "wrong size after lock cancel"
4346 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4347 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4348 error "expanding truncate failed"
4349 cancel_lru_locks osc
4350 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4351 error "wrong expanded size after lock cancel"
4353 run_test 34g "truncate long file ==============================="
4356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4361 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4362 sync # Flush the cache so that multiop below does not block on cache
4363 # flush when getting the group lock
4364 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4367 # Since just timed wait is not good enough, let's do a sync write
4368 # that way we are sure enough time for a roundtrip + processing
4369 # passed + 2 seconds of extra margin.
4370 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4374 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4375 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4379 local nsz=`stat -c %s $DIR/$tfile`
4380 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4382 run_test 34h "ftruncate file under grouplock should not block"
4385 cp /bin/sh $DIR/f35a
4387 chown $RUNAS_ID $DIR/f35a
4388 $RUNAS $DIR/f35a && error || true
4391 run_test 35a "exec file with mode 444 (should return and not leak)"
4395 utime $DIR/f36 || error "utime failed for MDS"
4397 run_test 36a "MDS utime check (mknod, utime)"
4401 utime $DIR/f36 || error "utime failed for OST"
4403 run_test 36b "OST utime check (open, utime)"
4408 chown $RUNAS_ID $DIR/d36
4409 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4411 run_test 36c "non-root MDS utime check (mknod, utime)"
4414 [ ! -d $DIR/d36 ] && test_36c
4415 echo "" > $DIR/d36/f36
4416 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4418 run_test 36d "non-root OST utime check (open, utime)"
4421 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4423 test_mkdir $DIR/$tdir
4424 touch $DIR/$tdir/$tfile
4425 $RUNAS utime $DIR/$tdir/$tfile &&
4426 error "utime worked, expected failure" || true
4428 run_test 36e "utime on non-owned file (should return error)"
4432 local LANG_SAVE=$LANG
4433 local LC_LANG_SAVE=$LC_LANG
4434 export LANG=C LC_LANG=C # for date language
4436 DATESTR="Dec 20 2000"
4437 test_mkdir $DIR/$tdir
4438 lctl set_param fail_loc=$fl
4440 cp /etc/hosts $DIR/$tdir/$tfile
4441 sync & # write RPC generated with "current" inode timestamp, but delayed
4443 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4444 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4445 cancel_lru_locks $OSC
4446 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4448 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4449 echo "BEFORE: $LS_BEFORE" && \
4450 echo "AFTER : $LS_AFTER" && \
4451 echo "WANT : $DATESTR" && \
4452 error "$DIR/$tdir/$tfile timestamps changed" || true
4454 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4458 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4460 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4461 subr_36fh "0x80000214"
4463 run_test 36f "utime on file racing with OST BRW write =========="
4466 remote_ost_nodsh && skip "remote OST with nodsh"
4467 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4468 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4469 skip "Need MDS version at least 2.12.51"
4474 local tgt="obdfilter"
4476 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4478 test_mkdir $DIR/$tdir
4479 fmd_max_age=$(do_facet $facet \
4480 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4483 echo "FMD max age: ${fmd_max_age}s"
4484 touch $DIR/$tdir/$tfile
4485 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4486 gawk '{cnt=cnt+$1} END{print cnt}')
4487 echo "FMD before: $fmd"
4489 error "FMD wasn't create by touch"
4490 sleep $((fmd_max_age + 12))
4491 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4492 gawk '{cnt=cnt+$1} END{print cnt}')
4493 echo "FMD after: $fmd"
4495 error "FMD wasn't expired by ping"
4497 run_test 36g "FMD cache expiry ====================="
4500 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4502 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4503 subr_36fh "0x80000227"
4505 run_test 36h "utime on file racing with OST BRW write =========="
4508 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4510 test_mkdir $DIR/$tdir
4511 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4513 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4514 local new_mtime=$((mtime + 200))
4516 #change Modify time of striped dir
4517 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4518 error "change mtime failed"
4520 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4522 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4524 run_test 36i "change mtime on striped directory"
4526 # test_37 - duplicate with tests 32q 32r
4529 local file=$DIR/$tfile
4531 openfile -f O_DIRECTORY $file
4534 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4535 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4537 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4539 test_39a() { # was test_39
4541 touch $DIR/${tfile}2
4542 # ls -l $DIR/$tfile $DIR/${tfile}2
4543 # ls -lu $DIR/$tfile $DIR/${tfile}2
4544 # ls -lc $DIR/$tfile $DIR/${tfile}2
4546 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4547 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4549 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4551 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4553 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4554 error "O_TRUNC didn't change timestamps"
4557 run_test 39a "mtime changed on create"
4560 test_mkdir -c1 $DIR/$tdir
4561 cp -p /etc/passwd $DIR/$tdir/fopen
4562 cp -p /etc/passwd $DIR/$tdir/flink
4563 cp -p /etc/passwd $DIR/$tdir/funlink
4564 cp -p /etc/passwd $DIR/$tdir/frename
4565 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4568 echo "aaaaaa" >> $DIR/$tdir/fopen
4569 echo "aaaaaa" >> $DIR/$tdir/flink
4570 echo "aaaaaa" >> $DIR/$tdir/funlink
4571 echo "aaaaaa" >> $DIR/$tdir/frename
4573 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4574 local link_new=`stat -c %Y $DIR/$tdir/flink`
4575 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4576 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4578 cat $DIR/$tdir/fopen > /dev/null
4579 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4580 rm -f $DIR/$tdir/funlink2
4581 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4583 for (( i=0; i < 2; i++ )) ; do
4584 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4585 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4586 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4587 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4589 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4590 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4591 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4592 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4594 cancel_lru_locks $OSC
4595 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4598 run_test 39b "mtime change on open, link, unlink, rename ======"
4600 # this should be set to past
4601 TEST_39_MTIME=`date -d "1 year ago" +%s`
4607 local mtime0=`stat -c %Y $DIR1/$tfile`
4609 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4610 local mtime1=`stat -c %Y $DIR1/$tfile`
4611 [ "$mtime1" = $TEST_39_MTIME ] || \
4612 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4615 echo hello >> $DIR1/$tfile
4617 local mtime2=`stat -c %Y $DIR1/$tfile`
4618 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4619 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4621 mv $DIR1/$tfile $DIR1/$tfile-1
4623 for (( i=0; i < 2; i++ )) ; do
4624 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4625 [ "$mtime2" = "$mtime3" ] || \
4626 error "mtime ($mtime2) changed (to $mtime3) on rename"
4628 cancel_lru_locks $OSC
4629 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4632 run_test 39c "mtime change on rename ==========================="
4636 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4639 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4641 for (( i=0; i < 2; i++ )) ; do
4642 local mtime=`stat -c %Y $DIR1/$tfile`
4643 [ $mtime = $TEST_39_MTIME ] || \
4644 error "mtime($mtime) is not set to $TEST_39_MTIME"
4646 cancel_lru_locks $OSC
4647 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4650 run_test 39d "create, utime, stat =============================="
4654 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4657 local mtime1=`stat -c %Y $DIR1/$tfile`
4659 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4661 for (( i=0; i < 2; i++ )) ; do
4662 local mtime2=`stat -c %Y $DIR1/$tfile`
4663 [ $mtime2 = $TEST_39_MTIME ] || \
4664 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4666 cancel_lru_locks $OSC
4667 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4670 run_test 39e "create, stat, utime, stat ========================"
4674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4677 mtime1=`stat -c %Y $DIR1/$tfile`
4680 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4682 for (( i=0; i < 2; i++ )) ; do
4683 local mtime2=`stat -c %Y $DIR1/$tfile`
4684 [ $mtime2 = $TEST_39_MTIME ] || \
4685 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4687 cancel_lru_locks $OSC
4688 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4691 run_test 39f "create, stat, sleep, utime, stat ================="
4695 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4697 echo hello >> $DIR1/$tfile
4698 local mtime1=`stat -c %Y $DIR1/$tfile`
4701 chmod o+r $DIR1/$tfile
4703 for (( i=0; i < 2; i++ )) ; do
4704 local mtime2=`stat -c %Y $DIR1/$tfile`
4705 [ "$mtime1" = "$mtime2" ] || \
4706 error "lost mtime: $mtime2, should be $mtime1"
4708 cancel_lru_locks $OSC
4709 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4712 run_test 39g "write, chmod, stat ==============================="
4716 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4722 echo hello >> $DIR1/$tfile
4723 local mtime1=`stat -c %Y $DIR1/$tfile`
4725 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4727 if [ "$d1" != "$d2" ]; then
4728 echo "write and touch not within one second"
4730 for (( i=0; i < 2; i++ )) ; do
4731 local mtime2=`stat -c %Y $DIR1/$tfile`
4732 [ "$mtime2" = $TEST_39_MTIME ] || \
4733 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4735 cancel_lru_locks $OSC
4736 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4740 run_test 39h "write, utime within one second, stat ============="
4743 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4748 echo hello >> $DIR1/$tfile
4749 local mtime1=`stat -c %Y $DIR1/$tfile`
4751 mv $DIR1/$tfile $DIR1/$tfile-1
4753 for (( i=0; i < 2; i++ )) ; do
4754 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4756 [ "$mtime1" = "$mtime2" ] || \
4757 error "lost mtime: $mtime2, should be $mtime1"
4759 cancel_lru_locks $OSC
4760 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4763 run_test 39i "write, rename, stat =============================="
4766 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4768 start_full_debug_logging
4772 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4773 lctl set_param fail_loc=0x80000412
4774 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4775 error "multiop failed"
4777 local mtime1=`stat -c %Y $DIR1/$tfile`
4779 mv $DIR1/$tfile $DIR1/$tfile-1
4781 kill -USR1 $multipid
4782 wait $multipid || error "multiop close failed"
4784 for (( i=0; i < 2; i++ )) ; do
4785 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4786 [ "$mtime1" = "$mtime2" ] ||
4787 error "mtime is lost on close: $mtime2, " \
4791 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4793 lctl set_param fail_loc=0
4794 stop_full_debug_logging
4796 run_test 39j "write, rename, close, stat ======================="
4799 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4804 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4806 local mtime1=`stat -c %Y $DIR1/$tfile`
4808 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4810 kill -USR1 $multipid
4811 wait $multipid || error "multiop close failed"
4813 for (( i=0; i < 2; i++ )) ; do
4814 local mtime2=`stat -c %Y $DIR1/$tfile`
4816 [ "$mtime2" = $TEST_39_MTIME ] || \
4817 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4820 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4823 run_test 39k "write, utime, close, stat ========================"
4825 # this should be set to future
4826 TEST_39_ATIME=`date -d "1 year" +%s`
4829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4830 remote_mds_nodsh && skip "remote MDS with nodsh"
4832 local atime_diff=$(do_facet $SINGLEMDS \
4833 lctl get_param -n mdd.*MDT0000*.atime_diff)
4835 mkdir_on_mdt0 $DIR/$tdir
4837 # test setting directory atime to future
4838 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4839 local atime=$(stat -c %X $DIR/$tdir)
4840 [ "$atime" = $TEST_39_ATIME ] ||
4841 error "atime is not set to future: $atime, $TEST_39_ATIME"
4843 # test setting directory atime from future to now
4844 local now=$(date +%s)
4845 touch -a -d @$now $DIR/$tdir
4847 atime=$(stat -c %X $DIR/$tdir)
4848 [ "$atime" -eq "$now" ] ||
4849 error "atime is not updated from future: $atime, $now"
4851 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
4854 # test setting directory atime when now > dir atime + atime_diff
4855 local d1=$(date +%s)
4857 local d2=$(date +%s)
4858 cancel_lru_locks mdc
4859 atime=$(stat -c %X $DIR/$tdir)
4860 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4861 error "atime is not updated : $atime, should be $d2"
4863 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
4866 # test not setting directory atime when now < dir atime + atime_diff
4868 cancel_lru_locks mdc
4869 atime=$(stat -c %X $DIR/$tdir)
4870 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4871 error "atime is updated to $atime, should remain $d1<atime<$d2"
4873 do_facet $SINGLEMDS \
4874 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4876 run_test 39l "directory atime update ==========================="
4879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4883 local far_past_mtime=$(date -d "May 29 1953" +%s)
4884 local far_past_atime=$(date -d "Dec 17 1903" +%s)
4886 touch -m -d @$far_past_mtime $DIR1/$tfile
4887 touch -a -d @$far_past_atime $DIR1/$tfile
4889 for (( i=0; i < 2; i++ )) ; do
4890 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
4891 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
4892 error "atime or mtime set incorrectly"
4894 cancel_lru_locks $OSC
4895 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4898 run_test 39m "test atime and mtime before 1970"
4900 test_39n() { # LU-3832
4901 remote_mds_nodsh && skip "remote MDS with nodsh"
4903 local atime_diff=$(do_facet $SINGLEMDS \
4904 lctl get_param -n mdd.*MDT0000*.atime_diff)
4909 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4912 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4913 atime0=$(stat -c %X $DIR/$tfile)
4916 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4917 atime1=$(stat -c %X $DIR/$tfile)
4920 cancel_lru_locks mdc
4921 cancel_lru_locks osc
4922 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4923 atime2=$(stat -c %X $DIR/$tfile)
4925 do_facet $SINGLEMDS \
4926 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4928 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4929 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4931 run_test 39n "check that O_NOATIME is honored"
4934 TESTDIR=$DIR/$tdir/$tfile
4935 [ -e $TESTDIR ] && rm -rf $TESTDIR
4942 links2=$(stat -c %h .)
4943 [ $(($links1 + 2)) != $links2 ] &&
4944 error "wrong links count $(($links1 + 2)) != $links2"
4946 links3=$(stat -c %h .)
4947 [ $(($links1 + 1)) != $links3 ] &&
4948 error "wrong links count $links1 != $links3"
4951 run_test 39o "directory cached attributes updated after create"
4954 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4957 TESTDIR=$DIR/$tdir/$tdir
4958 [ -e $TESTDIR ] && rm -rf $TESTDIR
4959 test_mkdir -p $TESTDIR
4963 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4964 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4966 links2=$(stat -c %h .)
4967 [ $(($links1 + 2)) != $links2 ] &&
4968 error "wrong links count $(($links1 + 2)) != $links2"
4970 links3=$(stat -c %h .)
4971 [ $(($links1 + 1)) != $links3 ] &&
4972 error "wrong links count $links1 != $links3"
4975 run_test 39p "remote directory cached attributes updated after create ========"
4978 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
4979 skip "no atime update on old OST"
4980 if [ "$ost1_FSTYPE" != ldiskfs ]; then
4981 skip_env "ldiskfs only test"
4985 saved_adiff=$(do_facet ost1 \
4986 lctl get_param -n obdfilter.*OST0000.atime_diff)
4987 stack_trap "do_facet ost1 \
4988 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
4990 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
4992 $LFS setstripe -i 0 $DIR/$tfile
4993 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
4994 error "can't write initial file"
4995 cancel_lru_locks osc
4997 # exceed atime_diff and access file
4999 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
5000 error "can't udpate atime"
5002 local atime_cli=$(stat -c %X $DIR/$tfile)
5003 echo "client atime: $atime_cli"
5004 # allow atime update to be written to device
5005 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
5008 local ostdev=$(ostdevname 1)
5009 local fid=($(lfs getstripe -y $DIR/$tfile |
5010 awk '/l_fid:/ { print $2 }' | tr ':' ' '))
5011 local objpath="O/0/d$((${fid[1]} % 32))/$((${fid[1]}))"
5012 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
5014 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
5015 local atime_ost=$(do_facet ost1 "$cmd" |&
5016 awk -F'[: ]' '/atime:/ { print $4 }')
5017 (( atime_cli == atime_ost )) ||
5018 error "atime on client $atime_cli != ost $atime_ost"
5020 run_test 39r "lazy atime update on OST"
5022 test_39q() { # LU-8041
5023 local testdir=$DIR/$tdir
5025 multiop_bg_pause $testdir D_c || error "multiop failed"
5027 cancel_lru_locks mdc
5028 kill -USR1 $multipid
5029 local atime=$(stat -c %X $testdir)
5030 [ "$atime" -ne 0 ] || error "atime is zero"
5032 run_test 39q "close won't zero out atime"
5035 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5036 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5037 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5038 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5039 error "$tfile is not 4096 bytes in size"
5041 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5045 small_write $DIR/f41 18
5047 run_test 41 "test small file write + fstat ====================="
5049 count_ost_writes() {
5050 lctl get_param -n ${OSC}.*.stats |
5051 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5052 END { printf("%0.0f", writes) }'
5059 BG_DIRTY_RATIO_SAVE=10
5060 MAX_BG_DIRTY_RATIO=25
5064 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5065 # dirty_ratio, dirty_background_ratio
5066 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5067 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5068 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5069 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5071 # if file not here, we are a 2.4 kernel
5072 kill -CONT `pidof kupdated`
5077 # setup the trap first, so someone cannot exit the test at the
5078 # exact wrong time and mess up a machine
5079 trap start_writeback EXIT
5080 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5081 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5082 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5083 sysctl -w vm.dirty_writeback_centisecs=0
5084 sysctl -w vm.dirty_writeback_centisecs=0
5085 # save and increase /proc/sys/vm/dirty_ratio
5086 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5087 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5088 # save and increase /proc/sys/vm/dirty_background_ratio
5089 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5090 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5092 # if file not here, we are a 2.4 kernel
5093 kill -STOP `pidof kupdated`
5097 # ensure that all stripes have some grant before we test client-side cache
5099 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5100 dd if=/dev/zero of=$i bs=4k count=1
5105 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5106 # file truncation, and file removal.
5108 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5111 cancel_lru_locks $OSC
5113 sync; sleep 1; sync # just to be safe
5114 BEFOREWRITES=`count_ost_writes`
5115 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5116 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5117 AFTERWRITES=`count_ost_writes`
5118 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5119 error "$BEFOREWRITES < $AFTERWRITES"
5122 run_test 42a "ensure that we don't flush on close"
5125 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5128 cancel_lru_locks $OSC
5131 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5132 BEFOREWRITES=$(count_ost_writes)
5133 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
5134 AFTERWRITES=$(count_ost_writes)
5135 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5136 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5138 BEFOREWRITES=$(count_ost_writes)
5139 sync || error "sync: $?"
5140 AFTERWRITES=$(count_ost_writes)
5141 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5142 error "$BEFOREWRITES < $AFTERWRITES on sync"
5144 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5148 run_test 42b "test destroy of file with cached dirty data ======"
5150 # if these tests just want to test the effect of truncation,
5151 # they have to be very careful. consider:
5152 # - the first open gets a {0,EOF}PR lock
5153 # - the first write conflicts and gets a {0, count-1}PW
5154 # - the rest of the writes are under {count,EOF}PW
5155 # - the open for truncate tries to match a {0,EOF}PR
5156 # for the filesize and cancels the PWs.
5157 # any number of fixes (don't get {0,EOF} on open, match
5158 # composite locks, do smarter file size management) fix
5159 # this, but for now we want these tests to verify that
5160 # the cancellation with truncate intent works, so we
5161 # start the file with a full-file pw lock to match against
5162 # until the truncate.
5167 cancel_lru_locks $OSC
5169 # prime the file with 0,EOF PW to match
5173 # now the real test..
5174 dd if=/dev/zero of=$file bs=1024 count=100
5175 BEFOREWRITES=`count_ost_writes`
5176 $TRUNCATE $file $offset
5177 cancel_lru_locks $OSC
5178 AFTERWRITES=`count_ost_writes`
5183 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5186 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5187 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5190 run_test 42c "test partial truncate of file with cached dirty data"
5193 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5196 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5197 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5200 run_test 42d "test complete truncate of file with cached dirty data"
5202 test_42e() { # bug22074
5203 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5205 local TDIR=$DIR/${tdir}e
5206 local pages=16 # hardcoded 16 pages, don't change it.
5207 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5208 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5212 test_mkdir $DIR/${tdir}e
5213 $LFS setstripe -c 1 $TDIR
5214 createmany -o $TDIR/f $files
5216 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5218 # we assume that with $OSTCOUNT files, at least one of them will
5219 # be allocated on OST0.
5220 warmup_files=$((OSTCOUNT * max_dirty_mb))
5221 createmany -o $TDIR/w $warmup_files
5223 # write a large amount of data into one file and sync, to get good
5224 # avail_grant number from OST.
5225 for ((i=0; i<$warmup_files; i++)); do
5226 idx=$($LFS getstripe -i $TDIR/w$i)
5227 [ $idx -ne 0 ] && continue
5228 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5231 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5233 $LCTL get_param $proc_osc0/cur_dirty_bytes
5234 $LCTL get_param $proc_osc0/cur_grant_bytes
5236 # create as much dirty pages as we can while not to trigger the actual
5237 # RPCs directly. but depends on the env, VFS may trigger flush during this
5238 # period, hopefully we are good.
5239 for ((i=0; i<$warmup_files; i++)); do
5240 idx=$($LFS getstripe -i $TDIR/w$i)
5241 [ $idx -ne 0 ] && continue
5242 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5244 $LCTL get_param $proc_osc0/cur_dirty_bytes
5245 $LCTL get_param $proc_osc0/cur_grant_bytes
5247 # perform the real test
5248 $LCTL set_param $proc_osc0/rpc_stats 0
5249 for ((;i<$files; i++)); do
5250 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5251 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5254 $LCTL get_param $proc_osc0/rpc_stats
5257 local have_ppr=false
5258 $LCTL get_param $proc_osc0/rpc_stats |
5259 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5260 # skip lines until we are at the RPC histogram data
5261 [ "$PPR" == "pages" ] && have_ppr=true && continue
5262 $have_ppr || continue
5264 # we only want the percent stat for < 16 pages
5265 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5267 percent=$((percent + WPCT))
5268 if [[ $percent -gt 15 ]]; then
5269 error "less than 16-pages write RPCs" \
5276 run_test 42e "verify sub-RPC writes are not done synchronously"
5278 test_43A() { # was test_43
5279 test_mkdir $DIR/$tdir
5280 cp -p /bin/ls $DIR/$tdir/$tfile
5281 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5283 # give multiop a chance to open
5286 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5288 # Wait for multiop to exit
5291 run_test 43A "execution of file opened for write should return -ETXTBSY"
5294 test_mkdir $DIR/$tdir
5295 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5296 $DIR/$tdir/sleep 60 &
5298 # Make sure exec of $tdir/sleep wins race with truncate
5300 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5303 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5306 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5308 test_mkdir $DIR/$tdir
5309 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5310 $DIR/$tdir/sleep 60 &
5312 # Make sure exec of $tdir/sleep wins race with truncate
5314 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5317 run_test 43b "truncate of file being executed should return -ETXTBSY"
5320 local testdir="$DIR/$tdir"
5323 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5324 ( cd $testdir && md5sum -c )
5326 run_test 43c "md5sum of copy into lustre"
5328 test_44A() { # was test_44
5329 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5331 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5332 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5334 run_test 44A "zero length read from a sparse stripe"
5337 local nstripe=$($LFS getstripe -c -d $DIR)
5338 [ -z "$nstripe" ] && skip "can't get stripe info"
5339 [[ $nstripe -gt $OSTCOUNT ]] &&
5340 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5342 local stride=$($LFS getstripe -S -d $DIR)
5343 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5344 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5347 OFFSETS="0 $((stride/2)) $((stride-1))"
5348 for offset in $OFFSETS; do
5349 for i in $(seq 0 $((nstripe-1))); do
5350 local GLOBALOFFSETS=""
5352 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5353 local myfn=$DIR/d44a-$size
5354 echo "--------writing $myfn at $size"
5355 ll_sparseness_write $myfn $size ||
5356 error "ll_sparseness_write"
5357 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5358 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5359 error "ll_sparseness_verify $GLOBALOFFSETS"
5361 for j in $(seq 0 $((nstripe-1))); do
5363 size=$((((j + $nstripe )*$stride + $offset)))
5364 ll_sparseness_write $myfn $size ||
5365 error "ll_sparseness_write"
5366 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5368 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5369 error "ll_sparseness_verify $GLOBALOFFSETS"
5374 run_test 44a "test sparse pwrite ==============================="
5378 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5384 before=`dirty_osc_total`
5385 echo executing "\"$*\""
5387 after=`dirty_osc_total`
5388 echo before $before, after $after
5391 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5394 # Obtain grants from OST if it supports it
5395 echo blah > ${f}_grant
5398 do_dirty_record "echo blah > $f"
5399 [[ $before -eq $after ]] && error "write wasn't cached"
5400 do_dirty_record "> $f"
5401 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5402 do_dirty_record "echo blah > $f"
5403 [[ $before -eq $after ]] && error "write wasn't cached"
5404 do_dirty_record "sync"
5405 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5406 do_dirty_record "echo blah > $f"
5407 [[ $before -eq $after ]] && error "write wasn't cached"
5408 do_dirty_record "cancel_lru_locks osc"
5409 [[ $before -gt $after ]] ||
5410 error "lock cancellation didn't lower dirty count"
5413 run_test 45 "osc io page accounting ============================"
5415 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5416 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5417 # objects offset and an assert hit when an rpc was built with 1023's mapped
5418 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5420 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5425 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5427 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5428 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5432 run_test 46 "dirtying a previously written page ================"
5434 # test_47 is removed "Device nodes check" is moved to test_28
5436 test_48a() { # bug 2399
5437 [ "$mds1_FSTYPE" = "zfs" ] &&
5438 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5439 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5441 test_mkdir $DIR/$tdir
5443 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5444 test_mkdir $DIR/$tdir
5445 touch foo || error "'touch foo' failed after recreating cwd"
5447 touch .foo || error "'touch .foo' failed after recreating cwd"
5449 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5450 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5451 cd . || error "'cd .' failed after recreating cwd"
5452 mkdir . && error "'mkdir .' worked after recreating cwd"
5453 rmdir . && error "'rmdir .' worked after recreating cwd"
5454 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5455 cd .. || error "'cd ..' failed after recreating cwd"
5457 run_test 48a "Access renamed working dir (should return errors)="
5459 test_48b() { # bug 2399
5461 test_mkdir $DIR/$tdir
5463 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5464 touch foo && error "'touch foo' worked after removing cwd"
5465 mkdir foo && error "'mkdir foo' worked after removing cwd"
5466 touch .foo && error "'touch .foo' worked after removing cwd"
5467 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5468 ls . > /dev/null && error "'ls .' worked after removing cwd"
5469 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5470 mkdir . && error "'mkdir .' worked after removing cwd"
5471 rmdir . && error "'rmdir .' worked after removing cwd"
5472 ln -s . foo && error "'ln -s .' worked after removing cwd"
5473 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5475 run_test 48b "Access removed working dir (should return errors)="
5477 test_48c() { # bug 2350
5478 #lctl set_param debug=-1
5481 test_mkdir -p $DIR/$tdir/dir
5483 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5484 $TRACE touch foo && error "touch foo worked after removing cwd"
5485 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5486 touch .foo && error "touch .foo worked after removing cwd"
5487 mkdir .foo && error "mkdir .foo worked after removing cwd"
5488 $TRACE ls . && error "'ls .' worked after removing cwd"
5489 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5490 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5491 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5492 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5493 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5495 run_test 48c "Access removed working subdir (should return errors)"
5497 test_48d() { # bug 2350
5498 #lctl set_param debug=-1
5501 test_mkdir -p $DIR/$tdir/dir
5503 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5504 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5505 $TRACE touch foo && error "'touch foo' worked after removing parent"
5506 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5507 touch .foo && error "'touch .foo' worked after removing parent"
5508 mkdir .foo && error "mkdir .foo worked after removing parent"
5509 $TRACE ls . && error "'ls .' worked after removing parent"
5510 $TRACE ls .. && error "'ls ..' worked after removing parent"
5511 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5512 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5513 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5516 run_test 48d "Access removed parent subdir (should return errors)"
5518 test_48e() { # bug 4134
5519 #lctl set_param debug=-1
5522 test_mkdir -p $DIR/$tdir/dir
5524 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5525 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5526 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5527 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5528 # On a buggy kernel addition of "touch foo" after cd .. will
5529 # produce kernel oops in lookup_hash_it
5530 touch ../foo && error "'cd ..' worked after recreate parent"
5532 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5534 run_test 48e "Access to recreated parent subdir (should return errors)"
5537 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5538 skip "need MDS >= 2.13.55"
5539 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5540 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5541 skip "needs different host for mdt1 mdt2"
5542 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5544 $LFS mkdir -i0 $DIR/$tdir
5545 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5547 for d in sub1 sub2 sub3; do
5548 #define OBD_FAIL_OSD_REF_DEL 0x19c
5549 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5550 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5553 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5555 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5557 test_49() { # LU-1030
5558 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5559 remote_ost_nodsh && skip "remote OST with nodsh"
5561 # get ost1 size - $FSNAME-OST0000
5562 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5564 # write 800M at maximum
5565 [[ $ost1_size -lt 2 ]] && ost1_size=2
5566 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5568 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5569 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5572 # change max_pages_per_rpc while writing the file
5573 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5574 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5575 # loop until dd process exits
5576 while ps ax -opid | grep -wq $dd_pid; do
5577 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5578 sleep $((RANDOM % 5 + 1))
5580 # restore original max_pages_per_rpc
5581 $LCTL set_param $osc1_mppc=$orig_mppc
5582 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5584 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5588 test_mkdir $DIR/$tdir
5590 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5592 run_test 50 "special situations: /proc symlinks ==============="
5594 test_51a() { # was test_51
5595 # bug 1516 - create an empty entry right after ".." then split dir
5596 test_mkdir -c1 $DIR/$tdir
5597 touch $DIR/$tdir/foo
5598 $MCREATE $DIR/$tdir/bar
5600 createmany -m $DIR/$tdir/longfile 201
5602 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5603 $MCREATE $DIR/$tdir/longfile$FNUM
5608 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5610 run_test 51a "special situations: split htree with empty entry =="
5612 cleanup_print_lfs_df () {
5619 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5621 local dir=$DIR/$tdir
5622 local nrdirs=$((65536 + 100))
5624 # cleanup the directory
5627 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5631 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5632 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5633 [[ $numfree -lt $nrdirs ]] &&
5634 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5636 # need to check free space for the directories as well
5637 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5638 numfree=$(( blkfree / $(fs_inode_ksize) ))
5639 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5641 trap cleanup_print_lfs_df EXIT
5644 createmany -d $dir/d $nrdirs || {
5645 unlinkmany $dir/d $nrdirs
5646 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5650 nrdirs=$(ls -U $dir | wc -l)
5652 # unlink all but 100 subdirectories, then check it still works
5654 local delete=$((nrdirs - left))
5659 # for ldiskfs the nlink count should be 1, but this is OSD specific
5660 # and so this is listed for informational purposes only
5661 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5662 unlinkmany -d $dir/d $delete ||
5663 error "unlink of first $delete subdirs failed"
5665 echo "nlink between: $(stat -c %h $dir)"
5666 local found=$(ls -U $dir | wc -l)
5667 [ $found -ne $left ] &&
5668 error "can't find subdirs: found only $found, expected $left"
5670 unlinkmany -d $dir/d $delete $left ||
5671 error "unlink of second $left subdirs failed"
5672 # regardless of whether the backing filesystem tracks nlink accurately
5673 # or not, the nlink count shouldn't be more than "." and ".." here
5674 local after=$(stat -c %h $dir)
5675 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5676 echo "nlink after: $after"
5678 cleanup_print_lfs_df
5680 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5684 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5687 test_mkdir $DIR/$tdir
5688 $LFS setstripe -c $OSTCOUNT $DIR/$tdir
5690 qos_old=$(do_facet mds1 \
5691 "$LCTL get_param -n lod.$FSNAME-*.qos_threshold_rr" | head -n 1)
5692 do_nodes $(comma_list $(mdts_nodes)) \
5693 "$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=100"
5694 stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
5695 '$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=${qos_old%%%}'"
5697 createmany -o $DIR/$tdir/t- 1000
5698 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5699 for ((n = 0; n < $OSTCOUNT; n++)); do
5700 objs[$n]=$(awk -vobjs=0 '($1 == '$n') { objs += 1 } \
5701 END { printf("%0.0f", objs) }' $TMP/$tfile)
5702 objs0[$n]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5703 '($1 == '$n') { objs += 1 } \
5704 END { printf("%0.0f", objs) }')
5705 log "OST$n has ${objs[$n]} objects, ${objs0[$n]} are index 0"
5707 unlinkmany $DIR/$tdir/t- 1000
5710 for ((n = 0; n < $OSTCOUNT; n++)); do
5711 (( ${objs[$n]} > ${objs[$nlast]} * 4 / 5 )) ||
5712 { $LFS df && $LFS df -i &&
5713 error "OST $n has fewer objects vs. OST $nlast" \
5714 " (${objs[$n]} < ${objs[$nlast]}"; }
5715 (( ${objs[$n]} < ${objs[$nlast]} * 5 / 4 )) ||
5716 { $LFS df && $LFS df -i &&
5717 error "OST $n has fewer objects vs. OST $nlast" \
5718 " (${objs[$n]} < ${objs[$nlast]}"; }
5720 (( ${objs0[$n]} > ${objs0[$nlast]} * 4 / 5 )) ||
5721 { $LFS df && $LFS df -i &&
5722 error "OST $n has fewer #0 objects vs. OST $nlast" \
5723 " (${objs0[$n]} < ${objs0[$nlast]}"; }
5724 (( ${objs0[$n]} < ${objs0[$nlast]} * 5 / 4 )) ||
5725 { $LFS df && $LFS df -i &&
5726 error "OST $n has fewer #0 objects vs. OST $nlast" \
5727 " (${objs0[$n]} < ${objs0[$nlast]}"; }
5731 run_test 51d "check object distribution"
5734 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5735 skip_env "ldiskfs only test"
5738 test_mkdir -c1 $DIR/$tdir
5739 test_mkdir -c1 $DIR/$tdir/d0
5741 touch $DIR/$tdir/d0/foo
5742 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5743 error "file exceed 65000 nlink limit!"
5744 unlinkmany $DIR/$tdir/d0/f- 65001
5747 run_test 51e "check file nlink limit"
5750 test_mkdir $DIR/$tdir
5753 local ulimit_old=$(ulimit -n)
5754 local spare=20 # number of spare fd's for scripts/libraries, etc.
5755 local mdt=$($LFS getstripe -m $DIR/$tdir)
5756 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5758 echo "MDT$mdt numfree=$numfree, max=$max"
5759 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5760 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5761 while ! ulimit -n $((numfree + spare)); do
5762 numfree=$((numfree * 3 / 4))
5764 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5766 echo "left ulimit at $ulimit_old"
5769 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5770 unlinkmany $DIR/$tdir/f $numfree
5771 error "create+open $numfree files in $DIR/$tdir failed"
5773 ulimit -n $ulimit_old
5775 # if createmany exits at 120s there will be fewer than $numfree files
5776 unlinkmany $DIR/$tdir/f $numfree || true
5778 run_test 51f "check many open files limit"
5781 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5782 test_mkdir $DIR/$tdir
5783 touch $DIR/$tdir/foo
5784 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5785 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5786 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5787 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5788 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5790 echo foo >> $DIR/$tdir/foo || error "append foo failed"
5791 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5792 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
5794 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
5795 cp -r $DIR/$tdir $TMP/
5796 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
5798 run_test 52a "append-only flag test (should return errors)"
5801 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
5802 test_mkdir $DIR/$tdir
5803 touch $DIR/$tdir/foo
5804 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
5805 cat test > $DIR/$tdir/foo && error "cat test worked"
5806 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5807 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5808 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5810 echo foo >> $DIR/$tdir/foo && error "echo worked"
5811 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5812 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
5813 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
5814 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
5816 chattr -i $DIR/$tdir/foo || error "chattr failed"
5818 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
5820 run_test 52b "immutable flag test (should return errors) ======="
5823 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5824 remote_mds_nodsh && skip "remote MDS with nodsh"
5825 remote_ost_nodsh && skip "remote OST with nodsh"
5838 local support_last_seq=true
5840 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
5841 support_last_seq=false
5844 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
5846 for value in $(do_facet $SINGLEMDS \
5847 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
5848 param=$(echo ${value[0]} | cut -d "=" -f1)
5849 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
5851 if $support_last_seq; then
5852 param_seq=$(echo $param |
5853 sed -e s/prealloc_last_id/prealloc_last_seq/g)
5854 mds_last_seq=$(do_facet $SINGLEMDS \
5855 $LCTL get_param -n $param_seq)
5857 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
5859 ostnum=$(index_from_ostuuid ${ostname}_UUID)
5860 node=$(facet_active_host ost$((ostnum+1)))
5861 param="obdfilter.$ostname.last_id"
5862 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
5863 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
5864 ost_last_id=$ost_last
5866 if $support_last_seq; then
5867 ost_last_id=$(echo $ost_last |
5868 awk -F':' '{print $2}' |
5870 ost_last_seq=$(echo $ost_last |
5871 awk -F':' '{print $1}')
5872 [[ $ost_last_seq = $mds_last_seq ]] || continue
5875 if [[ $ost_last_id != $mds_last ]]; then
5876 error "$ost_last_id != $mds_last"
5883 $found || error "can not match last_seq/last_id for $mdtosc"
5886 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
5889 perl -MSocket -e ';' || skip "no Socket perl module installed"
5891 $SOCKETSERVER $DIR/socket ||
5892 error "$SOCKETSERVER $DIR/socket failed: $?"
5893 $SOCKETCLIENT $DIR/socket ||
5894 error "$SOCKETCLIENT $DIR/socket failed: $?"
5895 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
5897 run_test 54a "unix domain socket test =========================="
5903 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
5905 run_test 54b "char device works in lustre ======================"
5908 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
5909 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
5910 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
5912 for i in $(seq 3 7); do
5913 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
5922 loopdev="$DIR/loop54c"
5925 $UMOUNT $DIR/$tdir || rc=$?
5926 losetup -d $loopdev || true
5927 losetup -d $LOOPDEV || true
5928 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
5933 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5935 loopdev="$DIR/loop54c"
5938 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
5939 trap cleanup_54c EXIT
5940 mknod $loopdev b 7 $LOOPNUM
5941 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
5942 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
5943 losetup $loopdev $DIR/$tfile ||
5944 error "can't set up $loopdev for $DIR/$tfile"
5945 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
5946 test_mkdir $DIR/$tdir
5947 mount -t ext2 $loopdev $DIR/$tdir ||
5948 error "error mounting $loopdev on $DIR/$tdir"
5949 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
5952 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
5956 run_test 54c "block device works in lustre ====================="
5962 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
5964 run_test 54d "fifo device works in lustre ======================"
5969 cp -aL /dev/console $f
5970 echo $string > $f || error "echo $string to $f failed"
5972 run_test 54e "console/tty device works in lustre ======================"
5977 local dir=$DIR/$tdir
5980 test_mkdir -p $dir/dir
5981 for i in $(seq $numfiles); do
5983 touch $dir/dir/file$i
5986 local numcomp=$($LFS getstripe --component-count $dir)
5988 [[ $numcomp == 0 ]] && numcomp=1
5990 # test lfs getstripe with --recursive
5991 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5993 [[ $filenum -eq $((numfiles * 2)) ]] ||
5994 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5995 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5996 [[ $filenum -eq $numfiles ]] ||
5997 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5998 echo "$LFS getstripe showed obdidx or l_ost_idx"
6000 # test lfs getstripe with file instead of dir
6001 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
6002 [[ $filenum -eq 1 ]] ||
6003 error "$LFS getstripe $dir/file1: found $filenum, not 1"
6004 echo "$LFS getstripe file1 passed"
6006 #test lfs getstripe with --verbose
6007 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
6008 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
6009 error "$LFS getstripe --verbose $dir: "\
6010 "got $filenum want $((numfiles * numcomp)) lmm_magic"
6011 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
6012 error "$LFS getstripe $dir: showed lmm_magic"
6014 #test lfs getstripe with -v prints lmm_fid
6015 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
6016 local countfids=$((numdirs + numfiles * numcomp))
6017 [[ $filenum -eq $countfids ]] ||
6018 error "$LFS getstripe -v $dir: "\
6019 "got $filenum want $countfids lmm_fid"
6020 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
6021 error "$LFS getstripe $dir: showed lmm_fid by default"
6022 echo "$LFS getstripe --verbose passed"
6024 #check for FID information
6025 local fid1=$($LFS getstripe --fid $dir/file1)
6026 local fid2=$($LFS getstripe --verbose $dir/file1 |
6027 awk '/lmm_fid: / { print $2; exit; }')
6028 local fid3=$($LFS path2fid $dir/file1)
6030 [ "$fid1" != "$fid2" ] &&
6031 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
6032 [ "$fid1" != "$fid3" ] &&
6033 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
6034 echo "$LFS getstripe --fid passed"
6036 #test lfs getstripe with --obd
6037 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6038 error "$LFS getstripe --obd wrong_uuid: should return error"
6040 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6043 local obduuid=$(ostuuid_from_index $ostidx)
6044 local found=$($LFS getstripe -r --obd $obduuid $dir |
6045 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6047 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6048 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6050 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6053 [[ $found -eq $filenum ]] ||
6054 error "$LFS getstripe --obd: found $found expect $filenum"
6055 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6056 sed '/^[ ]*'${ostidx}'[ ]/d' |
6057 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6058 error "$LFS getstripe --obd: should not show file on other obd"
6059 echo "$LFS getstripe --obd passed"
6061 run_test 56a "check $LFS getstripe"
6064 local dir=$DIR/$tdir
6068 for i in $(seq $numdirs); do
6069 test_mkdir $dir/dir$i
6072 # test lfs getdirstripe default mode is non-recursion, which is
6073 # different from lfs getstripe
6074 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6076 [[ $dircnt -eq 1 ]] ||
6077 error "$LFS getdirstripe: found $dircnt, not 1"
6078 dircnt=$($LFS getdirstripe --recursive $dir |
6079 grep -c lmv_stripe_count)
6080 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6081 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6083 run_test 56b "check $LFS getdirstripe"
6086 remote_ost_nodsh && skip "remote OST with nodsh"
6089 local ost_name=$(ostname_from_index $ost_idx)
6090 local old_status=$(ost_dev_status $ost_idx)
6091 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6093 [[ -z "$old_status" ]] ||
6094 skip_env "OST $ost_name is in $old_status status"
6096 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6097 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6098 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6099 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6100 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6101 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6104 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6105 error "$LFS df -v showing inactive devices"
6108 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6110 [[ "$new_status" =~ "D" ]] ||
6111 error "$ost_name status is '$new_status', missing 'D'"
6112 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6113 [[ "$new_status" =~ "N" ]] ||
6114 error "$ost_name status is '$new_status', missing 'N'"
6116 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6117 [[ "$new_status" =~ "f" ]] ||
6118 error "$ost_name status is '$new_status', missing 'f'"
6121 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6122 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6123 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6124 [[ -z "$p" ]] && restore_lustre_params < $p || true
6127 new_status=$(ost_dev_status $ost_idx)
6128 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6129 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6130 # can't check 'f' as devices may actually be on flash
6132 run_test 56c "check 'lfs df' showing device status"
6135 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6136 local osts=$($LFS df -v $MOUNT | grep -c OST)
6140 (( mdts == MDSCOUNT )) ||
6141 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6142 (( osts == OSTCOUNT )) ||
6143 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6145 run_test 56d "'lfs df -v' prints only configured devices"
6148 err_enoent=2 # No such file or directory
6149 err_eopnotsupp=95 # Operation not supported
6151 enoent_mnt=/pmt1 # Invalid dentry. Path not present
6152 notsup_mnt=/tmp # Valid dentry, but Not a lustreFS
6154 # Check for handling of path not exists
6155 output=$($LFS df $enoent_mnt 2>&1)
6158 fs=$(echo $output | awk -F: '{print $2}' | awk '{print $3}' | tr -d \')
6159 [[ $fs = $enoent_mnt && $ret -eq $err_enoent ]] ||
6160 error "expect failure $err_enoent, not $ret"
6162 # Check for handling of non-Lustre FS
6163 output=$($LFS df $notsup_mnt)
6166 fs=$(echo $output | awk '{print $1}' | awk -F: '{print $2}')
6167 [[ $fs = $notsup_mnt && $ret -eq $err_eopnotsupp ]] ||
6168 error "expect success $err_eopnotsupp, not $ret"
6170 # Check for multiple LustreFS argument
6171 output=$($LFS df $MOUNT $MOUNT $MOUNT | grep -c "filesystem_summary:")
6174 [[ $output -eq 3 && $ret -eq 0 ]] ||
6175 error "expect success 3, not $output, rc = $ret"
6177 # Check for correct non-Lustre FS handling among multiple
6179 output=$($LFS df $MOUNT $notsup_mnt $MOUNT |
6180 grep -c "filesystem_summary:"; exit ${PIPESTATUS[0]})
6183 [[ $output -eq 2 && $ret -eq $err_eopnotsupp ]] ||
6184 error "expect success 2, not $output, rc = $ret"
6186 run_test 56e "'lfs df' Handle non LustreFS & multiple LustreFS"
6191 local local_tdir="$1"
6192 local local_numfiles="$2"
6193 local local_numdirs="$3"
6194 local dir_params="$4"
6195 local dir_stripe_params="$5"
6197 if [ ! -d "$local_tdir" ] ; then
6198 test_mkdir -p $dir_stripe_params $local_tdir
6199 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6200 for i in $(seq $local_numfiles) ; do
6201 touch $local_tdir/file$i
6203 for i in $(seq $local_numdirs) ; do
6204 test_mkdir $dir_stripe_params $local_tdir/dir$i
6205 for j in $(seq $local_numfiles) ; do
6206 touch $local_tdir/dir$i/file$j
6212 setup_56_special() {
6214 local local_numfiles=$2
6215 local local_numdirs=$3
6217 setup_56 $local_tdir $local_numfiles $local_numdirs
6219 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6220 for i in $(seq $local_numfiles) ; do
6221 mknod $local_tdir/loop${i}b b 7 $i
6222 mknod $local_tdir/null${i}c c 1 3
6223 ln -s $local_tdir/file1 $local_tdir/link${i}
6225 for i in $(seq $local_numdirs) ; do
6226 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6227 mknod $local_tdir/dir$i/null${i}c c 1 3
6228 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6234 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6235 local expected=$(($NUMDIRS + 2))
6237 setup_56 $dir $NUMFILES $NUMDIRS
6239 # test lfs find with -name
6240 for i in $(seq $NUMFILES) ; do
6241 local nums=$($LFS find -name "*$i" $dir | wc -l)
6243 [ $nums -eq $expected ] ||
6244 error "lfs find -name '*$i' $dir wrong: "\
6245 "found $nums, expected $expected"
6248 run_test 56g "check lfs find -name"
6251 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6252 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6254 setup_56 $dir $NUMFILES $NUMDIRS
6256 # test lfs find with ! -name
6257 for i in $(seq $NUMFILES) ; do
6258 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6260 [ $nums -eq $expected ] ||
6261 error "lfs find ! -name '*$i' $dir wrong: "\
6262 "found $nums, expected $expected"
6265 run_test 56h "check lfs find ! -name"
6268 local dir=$DIR/$tdir
6272 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6275 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6277 run_test 56i "check 'lfs find -ost UUID' skips directories"
6280 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6282 setup_56_special $dir $NUMFILES $NUMDIRS
6284 local expected=$((NUMDIRS + 1))
6285 local cmd="$LFS find -type d $dir"
6286 local nums=$($cmd | wc -l)
6288 [ $nums -eq $expected ] ||
6289 error "'$cmd' wrong: found $nums, expected $expected"
6291 run_test 56j "check lfs find -type d"
6294 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6296 setup_56_special $dir $NUMFILES $NUMDIRS
6298 local expected=$(((NUMDIRS + 1) * NUMFILES))
6299 local cmd="$LFS find -type f $dir"
6300 local nums=$($cmd | wc -l)
6302 [ $nums -eq $expected ] ||
6303 error "'$cmd' wrong: found $nums, expected $expected"
6305 run_test 56k "check lfs find -type f"
6308 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6310 setup_56_special $dir $NUMFILES $NUMDIRS
6312 local expected=$((NUMDIRS + NUMFILES))
6313 local cmd="$LFS find -type b $dir"
6314 local nums=$($cmd | wc -l)
6316 [ $nums -eq $expected ] ||
6317 error "'$cmd' wrong: found $nums, expected $expected"
6319 run_test 56l "check lfs find -type b"
6322 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6324 setup_56_special $dir $NUMFILES $NUMDIRS
6326 local expected=$((NUMDIRS + NUMFILES))
6327 local cmd="$LFS find -type c $dir"
6328 local nums=$($cmd | wc -l)
6329 [ $nums -eq $expected ] ||
6330 error "'$cmd' wrong: found $nums, expected $expected"
6332 run_test 56m "check lfs find -type c"
6335 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6336 setup_56_special $dir $NUMFILES $NUMDIRS
6338 local expected=$((NUMDIRS + NUMFILES))
6339 local cmd="$LFS find -type l $dir"
6340 local nums=$($cmd | wc -l)
6342 [ $nums -eq $expected ] ||
6343 error "'$cmd' wrong: found $nums, expected $expected"
6345 run_test 56n "check lfs find -type l"
6348 local dir=$DIR/$tdir
6350 setup_56 $dir $NUMFILES $NUMDIRS
6351 utime $dir/file1 > /dev/null || error "utime (1)"
6352 utime $dir/file2 > /dev/null || error "utime (2)"
6353 utime $dir/dir1 > /dev/null || error "utime (3)"
6354 utime $dir/dir2 > /dev/null || error "utime (4)"
6355 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6356 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6359 local nums=$($LFS find -mtime +0 $dir | wc -l)
6361 [ $nums -eq $expected ] ||
6362 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6365 cmd="$LFS find -mtime 0 $dir"
6366 nums=$($cmd | wc -l)
6367 [ $nums -eq $expected ] ||
6368 error "'$cmd' wrong: found $nums, expected $expected"
6370 run_test 56o "check lfs find -mtime for old files"
6373 local dir=$DIR/$tdir
6377 # just to make sure there is something that won't be found
6379 touch $dir/$tfile.now
6381 for age in year week day hour min; do
6382 count=$((count + 1))
6384 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6385 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6386 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6388 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6389 local nums=$($cmd | wc -l)
6390 [ $nums -eq $expected ] ||
6391 error "'$cmd' wrong: found $nums, expected $expected"
6393 cmd="$LFS find $dir -atime $count${age:0:1}"
6394 nums=$($cmd | wc -l)
6395 [ $nums -eq $expected ] ||
6396 error "'$cmd' wrong: found $nums, expected $expected"
6400 cmd="$LFS find $dir -ctime +1s -type f"
6401 nums=$($cmd | wc -l)
6402 (( $nums == $count * 2 + 1)) ||
6403 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6405 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6407 test_newerXY_base() {
6410 local dir=$DIR/$tdir
6414 if [ $y == "t" ]; then
6415 if [ $x == "b" ]; then
6416 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6418 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6421 ref=$DIR/$tfile.newer.$x$y
6422 touch $ref || error "touch $ref failed"
6425 echo "before = $ref"
6427 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6429 if [ $y == "t" ]; then
6430 if [ $x == "b" ]; then
6431 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6433 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6436 negref=$DIR/$tfile.negnewer.$x$y
6437 touch $negref || error "touch $negref failed"
6440 echo "after = $negref"
6441 local cmd="$LFS find $dir -newer$x$y $ref"
6442 local nums=$(eval $cmd | wc -l)
6443 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6445 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6446 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6448 cmd="$LFS find $dir ! -newer$x$y $negref"
6449 nums=$(eval $cmd | wc -l)
6450 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6451 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6453 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6454 nums=$(eval $cmd | wc -l)
6455 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6456 error "'$cmd' wrong: found $nums between, expected $expected"; }
6462 test_newerXY_base "a" "a"
6463 test_newerXY_base "a" "m"
6464 test_newerXY_base "a" "c"
6465 test_newerXY_base "m" "a"
6466 test_newerXY_base "m" "m"
6467 test_newerXY_base "m" "c"
6468 test_newerXY_base "c" "a"
6469 test_newerXY_base "c" "m"
6470 test_newerXY_base "c" "c"
6472 [[ -n "$sles_version" ]] &&
6473 echo "skip timestamp tests on SLES, LU-13665" && return 0
6475 test_newerXY_base "a" "t"
6476 test_newerXY_base "m" "t"
6477 test_newerXY_base "c" "t"
6479 [[ $MDS1_VERSION -lt $(version_code 2.13.54) ||
6480 $CLIENT_VERSION -lt $(version_code 2.13.54) ]] &&
6481 ! btime_supported && echo "btime unsupported" && return 0
6483 test_newerXY_base "b" "b"
6484 test_newerXY_base "b" "t"
6486 run_test 56oc "check lfs find -newerXY work"
6489 local dir=$DIR/$tdir
6494 $LFS find $dir -btime -1d -type f
6501 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
6502 ! btime_supported && skip "btime unsupported on MDS"
6504 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6505 ! btime_supported && skip "btime unsupported on clients"
6507 local dir=$DIR/$tdir
6508 local ref=$DIR/$tfile.ref
6509 local negref=$DIR/$tfile.negref
6511 mkdir $dir || error "mkdir $dir failed"
6512 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6513 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6514 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6515 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6516 touch $ref || error "touch $ref failed"
6517 # sleep 3 seconds at least
6520 local before=$(do_facet mds1 date +%s)
6521 local skew=$(($(date +%s) - before + 1))
6523 if (( skew < 0 && skew > -5 )); then
6524 sleep $((0 - skew + 1))
6528 # Set the dir stripe params to limit files all on MDT0,
6529 # otherwise we need to calc the max clock skew between
6530 # the client and MDTs.
6531 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6533 touch $negref || error "touch $negref failed"
6535 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6536 local nums=$($cmd | wc -l)
6537 local expected=$(((NUMFILES + 1) * NUMDIRS))
6539 [ $nums -eq $expected ] ||
6540 error "'$cmd' wrong: found $nums, expected $expected"
6542 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6543 nums=$($cmd | wc -l)
6544 expected=$((NUMFILES + 1))
6545 [ $nums -eq $expected ] ||
6546 error "'$cmd' wrong: found $nums, expected $expected"
6548 [ $skew -lt 0 ] && return
6550 local after=$(do_facet mds1 date +%s)
6551 local age=$((after - before + 1 + skew))
6553 cmd="$LFS find $dir -btime -${age}s -type f"
6554 nums=$($cmd | wc -l)
6555 expected=$(((NUMFILES + 1) * NUMDIRS))
6557 echo "Clock skew between client and server: $skew, age:$age"
6558 [ $nums -eq $expected ] ||
6559 error "'$cmd' wrong: found $nums, expected $expected"
6561 expected=$(($NUMDIRS + 1))
6562 cmd="$LFS find $dir -btime -${age}s -type d"
6563 nums=$($cmd | wc -l)
6564 [ $nums -eq $expected ] ||
6565 error "'$cmd' wrong: found $nums, expected $expected"
6566 rm -f $ref $negref || error "Failed to remove $ref $negref"
6568 run_test 56od "check lfs find -btime with units"
6571 [ $RUNAS_ID -eq $UID ] &&
6572 skip_env "RUNAS_ID = UID = $UID -- skipping"
6574 local dir=$DIR/$tdir
6576 setup_56 $dir $NUMFILES $NUMDIRS
6577 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6579 local expected=$NUMFILES
6580 local cmd="$LFS find -uid $RUNAS_ID $dir"
6581 local nums=$($cmd | wc -l)
6583 [ $nums -eq $expected ] ||
6584 error "'$cmd' wrong: found $nums, expected $expected"
6586 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6587 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6588 nums=$($cmd | wc -l)
6589 [ $nums -eq $expected ] ||
6590 error "'$cmd' wrong: found $nums, expected $expected"
6592 run_test 56p "check lfs find -uid and ! -uid"
6595 [ $RUNAS_ID -eq $UID ] &&
6596 skip_env "RUNAS_ID = UID = $UID -- skipping"
6598 local dir=$DIR/$tdir
6600 setup_56 $dir $NUMFILES $NUMDIRS
6601 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6603 local expected=$NUMFILES
6604 local cmd="$LFS find -gid $RUNAS_GID $dir"
6605 local nums=$($cmd | wc -l)
6607 [ $nums -eq $expected ] ||
6608 error "'$cmd' wrong: found $nums, expected $expected"
6610 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6611 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6612 nums=$($cmd | wc -l)
6613 [ $nums -eq $expected ] ||
6614 error "'$cmd' wrong: found $nums, expected $expected"
6616 run_test 56q "check lfs find -gid and ! -gid"
6619 local dir=$DIR/$tdir
6621 setup_56 $dir $NUMFILES $NUMDIRS
6624 local cmd="$LFS find -size 0 -type f -lazy $dir"
6625 local nums=$($cmd | wc -l)
6627 [ $nums -eq $expected ] ||
6628 error "'$cmd' wrong: found $nums, expected $expected"
6629 cmd="$LFS find -size 0 -type f $dir"
6630 nums=$($cmd | wc -l)
6631 [ $nums -eq $expected ] ||
6632 error "'$cmd' wrong: found $nums, expected $expected"
6635 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6636 nums=$($cmd | wc -l)
6637 [ $nums -eq $expected ] ||
6638 error "'$cmd' wrong: found $nums, expected $expected"
6639 cmd="$LFS find ! -size 0 -type f $dir"
6640 nums=$($cmd | wc -l)
6641 [ $nums -eq $expected ] ||
6642 error "'$cmd' wrong: found $nums, expected $expected"
6644 echo "test" > $dir/$tfile
6645 echo "test2" > $dir/$tfile.2 && sync
6647 cmd="$LFS find -size 5 -type f -lazy $dir"
6648 nums=$($cmd | wc -l)
6649 [ $nums -eq $expected ] ||
6650 error "'$cmd' wrong: found $nums, expected $expected"
6651 cmd="$LFS find -size 5 -type f $dir"
6652 nums=$($cmd | wc -l)
6653 [ $nums -eq $expected ] ||
6654 error "'$cmd' wrong: found $nums, expected $expected"
6657 cmd="$LFS find -size +5 -type f -lazy $dir"
6658 nums=$($cmd | wc -l)
6659 [ $nums -eq $expected ] ||
6660 error "'$cmd' wrong: found $nums, expected $expected"
6661 cmd="$LFS find -size +5 -type f $dir"
6662 nums=$($cmd | wc -l)
6663 [ $nums -eq $expected ] ||
6664 error "'$cmd' wrong: found $nums, expected $expected"
6667 cmd="$LFS find -size +0 -type f -lazy $dir"
6668 nums=$($cmd | wc -l)
6669 [ $nums -eq $expected ] ||
6670 error "'$cmd' wrong: found $nums, expected $expected"
6671 cmd="$LFS find -size +0 -type f $dir"
6672 nums=$($cmd | wc -l)
6673 [ $nums -eq $expected ] ||
6674 error "'$cmd' wrong: found $nums, expected $expected"
6677 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6678 nums=$($cmd | wc -l)
6679 [ $nums -eq $expected ] ||
6680 error "'$cmd' wrong: found $nums, expected $expected"
6681 cmd="$LFS find ! -size -5 -type f $dir"
6682 nums=$($cmd | wc -l)
6683 [ $nums -eq $expected ] ||
6684 error "'$cmd' wrong: found $nums, expected $expected"
6687 cmd="$LFS find -size -5 -type f -lazy $dir"
6688 nums=$($cmd | wc -l)
6689 [ $nums -eq $expected ] ||
6690 error "'$cmd' wrong: found $nums, expected $expected"
6691 cmd="$LFS find -size -5 -type f $dir"
6692 nums=$($cmd | wc -l)
6693 [ $nums -eq $expected ] ||
6694 error "'$cmd' wrong: found $nums, expected $expected"
6696 run_test 56r "check lfs find -size works"
6703 cancel_lru_locks $OSC
6705 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6706 local nums=$($cmd | wc -l)
6708 [ $nums -eq $expected ] ||
6709 error "'$cmd' wrong: found $nums, expected $expected"
6711 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6713 if (( rpcs_before + glimpses != rpcs_after )); then
6714 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6715 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
6717 if [[ $glimpses == 0 ]]; then
6718 error "'$cmd' should not send glimpse RPCs to OST"
6720 error "'$cmd' should send $glimpses glimpse RPCs to OST"
6726 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
6727 skip "MDS < 2.12.58 doesn't return LSOM data"
6728 local dir=$DIR/$tdir
6729 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
6731 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
6733 # statahead_agl may cause extra glimpse which confuses results. LU-13017
6734 $LCTL set_param -n llite.*.statahead_agl=0
6735 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
6737 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6738 # open and close all files to ensure LSOM is updated
6739 cancel_lru_locks $OSC
6740 find $dir -type f | xargs cat > /dev/null
6742 # expect_found glimpse_rpcs command_to_run
6743 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
6744 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
6745 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
6746 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
6748 echo "test" > $dir/$tfile
6749 echo "test2" > $dir/$tfile.2 && sync
6750 cancel_lru_locks $OSC
6751 cat $dir/$tfile $dir/$tfile.2 > /dev/null
6753 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
6754 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
6755 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
6756 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
6758 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
6759 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
6760 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
6761 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
6762 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
6763 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
6765 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6768 local dir=$DIR/$tdir
6769 local tmp=$TMP/$tfile.log
6772 test_mkdir -p $dir || error "failed to mkdir $dir"
6773 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
6774 error "failed to setstripe $dir/$tfile"
6775 mdt_idx=$($LFS getdirstripe -i $dir)
6776 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
6778 stack_trap "rm -f $tmp" EXIT
6779 $LFS find --size +100K --ost 0 $dir |& tee $tmp
6780 ! grep -q obd_uuid $tmp ||
6781 error "failed to find --size +100K --ost 0 $dir"
6782 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
6783 ! grep -q obd_uuid $tmp ||
6784 error "failed to find --size +100K --mdt $mdt_idx $dir"
6786 run_test 56rb "check lfs find --size --ost/--mdt works"
6789 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
6790 local dir=$DIR/$tdir
6793 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
6794 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
6795 (( $MDSCOUNT > 2 )) &&
6796 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
6797 mkdir $dir/$tdir-{1..10}
6798 touch $dir/$tfile-{1..10}
6800 found=$($LFS find $dir --mdt-count 2 | wc -l)
6802 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
6804 found=$($LFS find $dir -T +1 | wc -l)
6805 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
6806 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
6808 found=$($LFS find $dir --mdt-hash all_char | wc -l)
6810 (( $found == $expect )) || error "found $found all_char, expect $expect"
6812 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
6813 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
6814 (( $found == $expect )) || error "found $found all_char, expect $expect"
6816 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
6818 test_56s() { # LU-611 #LU-9369
6819 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
6821 local dir=$DIR/$tdir
6822 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
6824 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6825 for i in $(seq $NUMDIRS); do
6826 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
6829 local expected=$NUMDIRS
6830 local cmd="$LFS find -c $OSTCOUNT $dir"
6831 local nums=$($cmd | wc -l)
6833 [ $nums -eq $expected ] || {
6834 $LFS getstripe -R $dir
6835 error "'$cmd' wrong: found $nums, expected $expected"
6838 expected=$((NUMDIRS + onestripe))
6839 cmd="$LFS find -stripe-count +0 -type f $dir"
6840 nums=$($cmd | wc -l)
6841 [ $nums -eq $expected ] || {
6842 $LFS getstripe -R $dir
6843 error "'$cmd' wrong: found $nums, expected $expected"
6847 cmd="$LFS find -stripe-count 1 -type f $dir"
6848 nums=$($cmd | wc -l)
6849 [ $nums -eq $expected ] || {
6850 $LFS getstripe -R $dir
6851 error "'$cmd' wrong: found $nums, expected $expected"
6854 cmd="$LFS find -stripe-count -2 -type f $dir"
6855 nums=$($cmd | wc -l)
6856 [ $nums -eq $expected ] || {
6857 $LFS getstripe -R $dir
6858 error "'$cmd' wrong: found $nums, expected $expected"
6862 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
6863 nums=$($cmd | wc -l)
6864 [ $nums -eq $expected ] || {
6865 $LFS getstripe -R $dir
6866 error "'$cmd' wrong: found $nums, expected $expected"
6869 run_test 56s "check lfs find -stripe-count works"
6871 test_56t() { # LU-611 #LU-9369
6872 local dir=$DIR/$tdir
6874 setup_56 $dir 0 $NUMDIRS
6875 for i in $(seq $NUMDIRS); do
6876 $LFS setstripe -S 8M $dir/dir$i/$tfile
6879 local expected=$NUMDIRS
6880 local cmd="$LFS find -S 8M $dir"
6881 local nums=$($cmd | wc -l)
6883 [ $nums -eq $expected ] || {
6884 $LFS getstripe -R $dir
6885 error "'$cmd' wrong: found $nums, expected $expected"
6889 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
6891 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
6893 expected=$(((NUMDIRS + 1) * NUMFILES))
6894 cmd="$LFS find -stripe-size 512k -type f $dir"
6895 nums=$($cmd | wc -l)
6896 [ $nums -eq $expected ] ||
6897 error "'$cmd' wrong: found $nums, expected $expected"
6899 cmd="$LFS find -stripe-size +320k -type f $dir"
6900 nums=$($cmd | wc -l)
6901 [ $nums -eq $expected ] ||
6902 error "'$cmd' wrong: found $nums, expected $expected"
6904 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
6905 cmd="$LFS find -stripe-size +200k -type f $dir"
6906 nums=$($cmd | wc -l)
6907 [ $nums -eq $expected ] ||
6908 error "'$cmd' wrong: found $nums, expected $expected"
6910 cmd="$LFS find -stripe-size -640k -type f $dir"
6911 nums=$($cmd | wc -l)
6912 [ $nums -eq $expected ] ||
6913 error "'$cmd' wrong: found $nums, expected $expected"
6916 cmd="$LFS find -stripe-size 256k -type f $dir"
6917 nums=$($cmd | wc -l)
6918 [ $nums -eq $expected ] ||
6919 error "'$cmd' wrong: found $nums, expected $expected"
6921 cmd="$LFS find -stripe-size -320k -type f $dir"
6922 nums=$($cmd | wc -l)
6923 [ $nums -eq $expected ] ||
6924 error "'$cmd' wrong: found $nums, expected $expected"
6927 cmd="$LFS find -stripe-size 1024k -type f $dir"
6928 nums=$($cmd | wc -l)
6929 [ $nums -eq $expected ] ||
6930 error "'$cmd' wrong: found $nums, expected $expected"
6932 run_test 56t "check lfs find -stripe-size works"
6934 test_56u() { # LU-611
6935 local dir=$DIR/$tdir
6937 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
6939 if [[ $OSTCOUNT -gt 1 ]]; then
6940 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
6946 local expected=$(((NUMDIRS + 1) * NUMFILES))
6947 local cmd="$LFS find -stripe-index 0 -type f $dir"
6948 local nums=$($cmd | wc -l)
6950 [ $nums -eq $expected ] ||
6951 error "'$cmd' wrong: found $nums, expected $expected"
6954 cmd="$LFS find -stripe-index 1 -type f $dir"
6955 nums=$($cmd | wc -l)
6956 [ $nums -eq $expected ] ||
6957 error "'$cmd' wrong: found $nums, expected $expected"
6959 cmd="$LFS find ! -stripe-index 0 -type f $dir"
6960 nums=$($cmd | wc -l)
6961 [ $nums -eq $expected ] ||
6962 error "'$cmd' wrong: found $nums, expected $expected"
6965 # This should produce an error and not return any files
6966 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
6967 nums=$($cmd 2>/dev/null | wc -l)
6968 [ $nums -eq $expected ] ||
6969 error "'$cmd' wrong: found $nums, expected $expected"
6971 if [[ $OSTCOUNT -gt 1 ]]; then
6972 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
6973 cmd="$LFS find -stripe-index 0,1 -type f $dir"
6974 nums=$($cmd | wc -l)
6975 [ $nums -eq $expected ] ||
6976 error "'$cmd' wrong: found $nums, expected $expected"
6979 run_test 56u "check lfs find -stripe-index works"
6983 local dir=$DIR/$tdir
6985 setup_56 $dir $NUMFILES $NUMDIRS
6987 UUID=$(mdtuuid_from_index $mdt_idx $dir)
6988 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
6990 for file in $($LFS find -m $UUID $dir); do
6991 file_midx=$($LFS getstripe -m $file)
6992 [ $file_midx -eq $mdt_idx ] ||
6993 error "lfs find -m $UUID != getstripe -m $file_midx"
6996 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
6999 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7000 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7002 local dir=$DIR/$tdir
7004 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
7006 local stripe_size=$($LFS getstripe -S -d $dir) ||
7007 error "$LFS getstripe -S -d $dir failed"
7008 stripe_size=${stripe_size%% *}
7010 local file_size=$((stripe_size * OSTCOUNT))
7011 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
7012 local required_space=$((file_num * file_size))
7013 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
7015 [[ $free_space -le $((required_space / 1024)) ]] &&
7016 skip_env "need $required_space, have $free_space kbytes"
7019 local dd_count=$((file_size / dd_bs))
7021 # write data into the files
7026 for i in $(seq $NUMFILES); do
7028 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7029 error "write data into $file failed"
7031 for i in $(seq $NUMDIRS); do
7032 for j in $(seq $NUMFILES); do
7033 file=$dir/dir$i/file$j
7034 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7035 error "write data into $file failed"
7039 # $LFS_MIGRATE will fail if hard link migration is unsupported
7040 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
7041 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
7042 error "creating links to $dir/dir1/file1 failed"
7047 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
7050 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
7053 eval $cmd || error "$cmd failed"
7055 check_stripe_count $dir/file1 $expected
7057 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
7059 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
7060 # OST 1 if it is on OST 0. This file is small enough to
7061 # be on only one stripe.
7062 file=$dir/migr_1_ost
7063 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
7064 error "write data into $file failed"
7065 local obdidx=$($LFS getstripe -i $file)
7066 local oldmd5=$(md5sum $file)
7069 [[ $obdidx -eq 0 ]] && newobdidx=1
7070 cmd="$LFS migrate -i $newobdidx $file"
7072 eval $cmd || error "$cmd failed"
7074 local realobdix=$($LFS getstripe -i $file)
7075 local newmd5=$(md5sum $file)
7077 [[ $newobdidx -ne $realobdix ]] &&
7078 error "new OST is different (was=$obdidx, "\
7079 "wanted=$newobdidx, got=$realobdix)"
7080 [[ "$oldmd5" != "$newmd5" ]] &&
7081 error "md5sum differ: $oldmd5, $newmd5"
7085 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7087 eval $cmd || error "$cmd failed"
7089 for j in $(seq $NUMFILES); do
7090 check_stripe_count $dir/dir1/file$j $expected
7093 # lfs_migrate works with lfs find
7094 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7095 $LFS_MIGRATE -y -c $expected"
7097 eval $cmd || error "$cmd failed"
7099 for i in $(seq 2 $NUMFILES); do
7100 check_stripe_count $dir/file$i $expected
7102 for i in $(seq 2 $NUMDIRS); do
7103 for j in $(seq $NUMFILES); do
7104 check_stripe_count $dir/dir$i/file$j $expected
7108 run_test 56w "check lfs_migrate -c stripe_count works"
7111 local file1=$DIR/$tdir/file1
7112 local create_pool=false
7113 local initial_pool=$($LFS getstripe -p $DIR)
7117 echo -n "Creating test dir..."
7118 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7121 echo -n "Creating test file..."
7122 touch $file1 || error "cannot create file"
7125 echo -n "Detecting existing pools..."
7126 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7128 if [ ${#pool_list[@]} -gt 0 ]; then
7129 echo "${pool_list[@]}"
7130 for thispool in "${pool_list[@]}"; do
7131 if [[ -z "$initial_pool" ||
7132 "$initial_pool" != "$thispool" ]]; then
7134 echo "Using existing pool '$pool'"
7139 echo "none detected."
7141 if [ -z "$pool" ]; then
7142 pool=${POOL:-testpool}
7143 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7144 echo -n "Creating pool '$pool'..."
7146 pool_add $pool &> /dev/null ||
7147 error "pool_add failed"
7150 echo -n "Adding target to pool..."
7151 pool_add_targets $pool 0 0 1 &> /dev/null ||
7152 error "pool_add_targets failed"
7156 echo -n "Setting pool using -p option..."
7157 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7158 error "migrate failed rc = $?"
7161 echo -n "Verifying test file is in pool after migrating..."
7162 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7163 error "file was not migrated to pool $pool"
7166 echo -n "Removing test file from pool '$pool'..."
7167 # "lfs migrate $file" won't remove the file from the pool
7168 # until some striping information is changed.
7169 $LFS migrate -c 1 $file1 &> /dev/null ||
7170 error "cannot remove from pool"
7171 [ "$($LFS getstripe -p $file1)" ] &&
7172 error "pool still set"
7175 echo -n "Setting pool using --pool option..."
7176 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7177 error "migrate failed rc = $?"
7182 if $create_pool; then
7183 destroy_test_pools 2> /dev/null ||
7184 error "destroy test pools failed"
7187 run_test 56wb "check lfs_migrate pool support"
7190 local file1="$DIR/$tdir/file1"
7197 echo -n "Creating test dir..."
7198 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7199 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7200 error "cannot set stripe by '-S 1M -c 1'"
7203 echo -n "Setting initial stripe for test file..."
7204 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7205 error "cannot set stripe"
7206 cur_ssize=$($LFS getstripe -S "$file1")
7207 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
7210 # File currently set to -S 512K -c 1
7212 # Ensure -c and -S options are rejected when -R is set
7213 echo -n "Verifying incompatible options are detected..."
7214 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
7215 error "incompatible -c and -R options not detected"
7216 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
7217 error "incompatible -S and -R options not detected"
7220 # Ensure unrecognized options are passed through to 'lfs migrate'
7221 echo -n "Verifying -S option is passed through to lfs migrate..."
7222 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
7223 error "migration failed"
7224 cur_ssize=$($LFS getstripe -S "$file1")
7225 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
7228 # File currently set to -S 1M -c 1
7230 # Ensure long options are supported
7231 echo -n "Verifying long options supported..."
7232 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
7233 error "long option without argument not supported"
7234 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
7235 error "long option with argument not supported"
7236 cur_ssize=$($LFS getstripe -S "$file1")
7237 [ $cur_ssize -eq 524288 ] ||
7238 error "migrate --stripe-size $cur_ssize != 524288"
7241 # File currently set to -S 512K -c 1
7243 if [ "$OSTCOUNT" -gt 1 ]; then
7244 echo -n "Verifying explicit stripe count can be set..."
7245 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
7246 error "migrate failed"
7247 cur_scount=$($LFS getstripe -c "$file1")
7248 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
7252 # File currently set to -S 512K -c 1 or -S 512K -c 2
7254 # Ensure parent striping is used if -R is set, and no stripe
7255 # count or size is specified
7256 echo -n "Setting stripe for parent directory..."
7257 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7258 error "cannot set stripe '-S 2M -c 1'"
7261 echo -n "Verifying restripe option uses parent stripe settings..."
7262 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7263 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7264 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
7265 error "migrate failed"
7266 cur_ssize=$($LFS getstripe -S "$file1")
7267 [ $cur_ssize -eq $parent_ssize ] ||
7268 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7269 cur_scount=$($LFS getstripe -c "$file1")
7270 [ $cur_scount -eq $parent_scount ] ||
7271 error "migrate -R stripe_count $cur_scount != $parent_scount"
7274 # File currently set to -S 1M -c 1
7276 # Ensure striping is preserved if -R is not set, and no stripe
7277 # count or size is specified
7278 echo -n "Verifying striping size preserved when not specified..."
7279 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7280 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7281 error "cannot set stripe on parent directory"
7282 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7283 error "migrate failed"
7284 cur_ssize=$($LFS getstripe -S "$file1")
7285 [ $cur_ssize -eq $orig_ssize ] ||
7286 error "migrate by default $cur_ssize != $orig_ssize"
7289 # Ensure file name properly detected when final option has no argument
7290 echo -n "Verifying file name properly detected..."
7291 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7292 error "file name interpreted as option argument"
7298 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7301 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7303 local file1=$DIR/$tdir/file1
7305 echo -n "Creating test dir..."
7306 test_mkdir $DIR/$tdir || error "cannot create dir"
7309 echo -n "Creating test file..."
7313 # Ensure 'lfs migrate' will fail by using a non-existent option,
7314 # and make sure rsync is not called to recover
7315 echo -n "Make sure --no-rsync option works..."
7316 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7317 grep -q 'refusing to fall back to rsync' ||
7318 error "rsync was called with --no-rsync set"
7321 # Ensure rsync is called without trying 'lfs migrate' first
7322 echo -n "Make sure --rsync option works..."
7323 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7324 grep -q 'falling back to rsync' &&
7325 error "lfs migrate was called with --rsync set"
7328 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
7329 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
7330 grep -q 'at the same time' ||
7331 error "--rsync and --no-rsync accepted concurrently"
7337 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7343 test_mkdir $td || error "cannot create $td"
7344 touch $tf || error "cannot touch $tf"
7346 echo -n "Make sure --non-direct|-D works..."
7347 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7348 grep -q "lfs migrate --non-direct" ||
7349 error "--non-direct option cannot work correctly"
7350 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7351 grep -q "lfs migrate -D" ||
7352 error "-D option cannot work correctly"
7355 run_test 56we "check lfs_migrate --non-direct|-D support"
7358 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7359 check_swap_layouts_support
7361 local dir=$DIR/$tdir
7362 local ref1=/etc/passwd
7363 local file1=$dir/file1
7365 test_mkdir $dir || error "creating dir $dir"
7366 $LFS setstripe -c 2 $file1
7368 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7369 stripe=$($LFS getstripe -c $file1)
7370 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7371 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7376 run_test 56x "lfs migration support"
7379 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7380 check_swap_layouts_support
7382 local dir=$DIR/$tdir/$testnum
7386 local ref1=/etc/passwd
7387 local file1=$dir/file1
7389 $LFS setstripe -c 2 $file1
7391 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7393 local stripe=$($LFS getstripe -c $file1)
7395 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7396 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7401 run_test 56xa "lfs migration --block support"
7403 check_migrate_links() {
7405 local file1="$dir/file1"
7409 local total_count=$(($begin + $count - 1))
7410 local symlink_count=10
7413 if [ ! -f "$file1" ]; then
7414 echo -n "creating initial file..."
7415 $LFS setstripe -c 1 -S "512k" "$file1" ||
7416 error "cannot setstripe initial file"
7419 echo -n "creating symlinks..."
7420 for s in $(seq 1 $symlink_count); do
7421 ln -s "$file1" "$dir/slink$s" ||
7422 error "cannot create symlinks"
7426 echo -n "creating nonlinked files..."
7427 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7428 error "cannot create nonlinked files"
7433 if [ ! -f "$dir/file$total_count" ]; then
7434 echo -n "creating hard links $begin:$total_count..."
7435 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7436 /dev/null || error "cannot create hard links"
7440 echo -n "checking number of hard links listed in xattrs..."
7441 local fid=$($LFS getstripe -F "$file1")
7442 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7445 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7446 skip "hard link list has unexpected size, skipping test"
7448 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7449 error "link names should exceed xattrs size"
7452 echo -n "migrating files..."
7453 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
7455 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7458 # make sure all links have been properly migrated
7459 echo -n "verifying files..."
7460 fid=$($LFS getstripe -F "$file1") ||
7461 error "cannot get fid for file $file1"
7462 for i in $(seq 2 $total_count); do
7463 local fid2=$($LFS getstripe -F $dir/file$i)
7465 [ "$fid2" == "$fid" ] ||
7466 error "migrated hard link has mismatched FID"
7469 # make sure hard links were properly detected, and migration was
7470 # performed only once for the entire link set; nonlinked files should
7472 local actual=$(grep -c 'done' <<< "$migrate_out")
7473 local expected=$(($uniq_count + 1))
7475 [ "$actual" -eq "$expected" ] ||
7476 error "hard links individually migrated ($actual != $expected)"
7478 # make sure the correct number of hard links are present
7479 local hardlinks=$(stat -c '%h' "$file1")
7481 [ $hardlinks -eq $total_count ] ||
7482 error "num hard links $hardlinks != $total_count"
7489 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7490 skip "Need MDS version at least 2.10.55"
7492 local dir="$DIR/$tdir"
7494 test_mkdir "$dir" || error "cannot create dir $dir"
7496 echo "testing lfs migrate mode when all links fit within xattrs"
7497 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
7499 echo "testing rsync mode when all links fit within xattrs"
7500 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
7502 echo "testing lfs migrate mode when all links do not fit within xattrs"
7503 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
7505 echo "testing rsync mode when all links do not fit within xattrs"
7506 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
7508 chown -R $RUNAS_ID $dir
7509 echo "testing non-root lfs migrate mode when not all links are in xattr"
7510 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
7515 run_test 56xb "lfs migration hard link support"
7518 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7520 local dir="$DIR/$tdir"
7522 test_mkdir "$dir" || error "cannot create dir $dir"
7524 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7525 echo -n "Setting initial stripe for 20MB test file..."
7526 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7527 error "cannot setstripe 20MB file"
7529 echo -n "Sizing 20MB test file..."
7530 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
7532 echo -n "Verifying small file autostripe count is 1..."
7533 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
7534 error "cannot migrate 20MB file"
7535 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7536 error "cannot get stripe for $dir/20mb"
7537 [ $stripe_count -eq 1 ] ||
7538 error "unexpected stripe count $stripe_count for 20MB file"
7542 # Test 2: File is small enough to fit within the available space on
7543 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7544 # have at least an additional 1KB for each desired stripe for test 3
7545 echo -n "Setting stripe for 1GB test file..."
7546 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7548 echo -n "Sizing 1GB test file..."
7549 # File size is 1GB + 3KB
7550 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7553 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7554 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7555 if (( avail > 524288 * OSTCOUNT )); then
7556 echo -n "Migrating 1GB file..."
7557 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7558 error "cannot migrate 1GB file"
7560 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7561 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7562 error "cannot getstripe for 1GB file"
7563 [ $stripe_count -eq 2 ] ||
7564 error "unexpected stripe count $stripe_count != 2"
7568 # Test 3: File is too large to fit within the available space on
7569 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7570 if [ $OSTCOUNT -ge 3 ]; then
7571 # The required available space is calculated as
7572 # file size (1GB + 3KB) / OST count (3).
7573 local kb_per_ost=349526
7575 echo -n "Migrating 1GB file with limit..."
7576 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7577 error "cannot migrate 1GB file with limit"
7580 stripe_count=$($LFS getstripe -c "$dir/1gb")
7581 echo -n "Verifying 1GB autostripe count with limited space..."
7582 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7583 error "unexpected stripe count $stripe_count (min 3)"
7590 run_test 56xc "lfs migration autostripe"
7593 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7595 local dir=$DIR/$tdir
7596 local f_mgrt=$dir/$tfile.mgrt
7597 local f_yaml=$dir/$tfile.yaml
7598 local f_copy=$dir/$tfile.copy
7599 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7600 local layout_copy="-c 2 -S 2M -i 1"
7601 local yamlfile=$dir/yamlfile
7602 local layout_before;
7605 test_mkdir "$dir" || error "cannot create dir $dir"
7606 $LFS setstripe $layout_yaml $f_yaml ||
7607 error "cannot setstripe $f_yaml with layout $layout_yaml"
7608 $LFS getstripe --yaml $f_yaml > $yamlfile
7609 $LFS setstripe $layout_copy $f_copy ||
7610 error "cannot setstripe $f_copy with layout $layout_copy"
7612 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7614 # 1. test option --yaml
7615 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7616 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7617 layout_before=$(get_layout_param $f_yaml)
7618 layout_after=$(get_layout_param $f_mgrt)
7619 [ "$layout_after" == "$layout_before" ] ||
7620 error "lfs_migrate --yaml: $layout_after != $layout_before"
7622 # 2. test option --copy
7623 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7624 error "cannot migrate $f_mgrt with --copy $f_copy"
7625 layout_before=$(get_layout_param $f_copy)
7626 layout_after=$(get_layout_param $f_mgrt)
7627 [ "$layout_after" == "$layout_before" ] ||
7628 error "lfs_migrate --copy: $layout_after != $layout_before"
7630 run_test 56xd "check lfs_migrate --yaml and --copy support"
7633 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7635 local dir=$DIR/$tdir
7636 local f_comp=$dir/$tfile
7637 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7638 local layout_before=""
7639 local layout_after=""
7641 test_mkdir "$dir" || error "cannot create dir $dir"
7642 $LFS setstripe $layout $f_comp ||
7643 error "cannot setstripe $f_comp with layout $layout"
7644 layout_before=$(get_layout_param $f_comp)
7645 dd if=/dev/zero of=$f_comp bs=1M count=4
7647 # 1. migrate a comp layout file by lfs_migrate
7648 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7649 layout_after=$(get_layout_param $f_comp)
7650 [ "$layout_before" == "$layout_after" ] ||
7651 error "lfs_migrate: $layout_before != $layout_after"
7653 # 2. migrate a comp layout file by lfs migrate
7654 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7655 layout_after=$(get_layout_param $f_comp)
7656 [ "$layout_before" == "$layout_after" ] ||
7657 error "lfs migrate: $layout_before != $layout_after"
7659 run_test 56xe "migrate a composite layout file"
7662 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7664 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7665 skip "Need server version at least 2.13.53"
7667 local dir=$DIR/$tdir
7668 local f_comp=$dir/$tfile
7669 local layout="-E 1M -c1 -E -1 -c2"
7673 test_mkdir "$dir" || error "cannot create dir $dir"
7674 $LFS setstripe $layout $f_comp ||
7675 error "cannot setstripe $f_comp with layout $layout"
7676 fid_before=$($LFS getstripe --fid $f_comp)
7677 dd if=/dev/zero of=$f_comp bs=1M count=4
7679 # 1. migrate a comp layout file to a comp layout
7680 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7681 fid_after=$($LFS getstripe --fid $f_comp)
7682 [ "$fid_before" == "$fid_after" ] ||
7683 error "comp-to-comp migrate: $fid_before != $fid_after"
7685 # 2. migrate a comp layout file to a plain layout
7686 $LFS migrate -c2 $f_comp ||
7687 error "cannot migrate $f_comp by lfs migrate"
7688 fid_after=$($LFS getstripe --fid $f_comp)
7689 [ "$fid_before" == "$fid_after" ] ||
7690 error "comp-to-plain migrate: $fid_before != $fid_after"
7692 # 3. migrate a plain layout file to a comp layout
7693 $LFS migrate $layout $f_comp ||
7694 error "cannot migrate $f_comp by lfs migrate"
7695 fid_after=$($LFS getstripe --fid $f_comp)
7696 [ "$fid_before" == "$fid_after" ] ||
7697 error "plain-to-comp migrate: $fid_before != $fid_after"
7699 run_test 56xf "FID is not lost during migration of a composite layout file"
7701 check_file_ost_range() {
7708 file_range=($($LFS getstripe -y "$file" |
7709 awk '/l_ost_idx:/ { print $NF }'))
7711 if [[ "${#file_range[@]}" = 0 ]]; then
7712 echo "No osts found for $file"
7716 for idx in "${file_range[@]}"; do
7717 [[ " $range " =~ " $idx " ]] ||
7725 local stripe_opt="$1"
7728 local pool_ostidx="$(seq $* | tr '\n' ' ')"
7730 $LFS migrate $stripe_opt -p $pool $DIR/$tfile ||
7731 error "Fail to migrate $tfile on $pool"
7732 [[ "$($LFS getstripe -p $DIR/$tfile)" = "$pool" ]] ||
7733 error "$tfile is not in pool $pool"
7734 check_file_ost_range "$DIR/$tfile" $pool_ostidx ||
7735 error "$tfile osts mismatch with pool $pool (osts $pool_ostidx)"
7739 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7740 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
7741 [[ $MDS1_VERSION -gt $(version_code 2.14.52) ]] ||
7742 skip "Need MDS version newer than 2.14.52"
7744 local -a pool_names=("${TESTNAME}_0" "${TESTNAME}_1" "${TESTNAME}_2")
7745 local -a pool_ranges=("0 0" "1 1" "0 1")
7748 for i in "${!pool_names[@]}"; do
7749 pool_add ${pool_names[$i]} ||
7750 error "pool_add failed (pool: ${pool_names[$i]})"
7751 pool_add_targets ${pool_names[$i]} ${pool_ranges[$i]} ||
7752 error "pool_add_targets failed (pool: ${pool_names[$i]})"
7755 # init the file to migrate
7756 $LFS setstripe -c1 -i1 $DIR/$tfile ||
7757 error "Unable to create $tfile on OST1"
7758 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=4 status=none ||
7759 error "Unable to write on $tfile"
7761 echo "1. migrate $tfile on pool ${pool_names[0]}"
7762 sub_test_56xg "-c-1" "${pool_names[0]}" ${pool_ranges[0]}
7764 echo "2. migrate $tfile on pool ${pool_names[2]}"
7765 sub_test_56xg "-c-1 -S2M" "${pool_names[2]}" ${pool_ranges[2]}
7767 echo "3. migrate $tfile on pool ${pool_names[1]}"
7768 sub_test_56xg "-n -c-1" "${pool_names[1]}" ${pool_ranges[1]}
7770 echo "4. migrate $tfile on pool ${pool_names[2]} with default stripe parameters"
7771 sub_test_56xg "" "${pool_names[2]}" ${pool_ranges[2]}
7775 destroy_test_pools ||
7776 error "pool_destroy failed"
7778 run_test 56xg "lfs migrate pool support"
7781 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
7782 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
7785 local dir=$DIR/$tdir
7789 test_mkdir -p $dir || error "creating dir $dir"
7790 touch $f1 || error "creating std file $f1"
7791 $MULTIOP $f2 H2c || error "creating released file $f2"
7793 # a directory can be raid0, so ask only for files
7794 res=$($LFS find $dir -L raid0 -type f | wc -l)
7795 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
7797 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
7798 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
7800 # only files can be released, so no need to force file search
7801 res=$($LFS find $dir -L released)
7802 [[ $res == $f2 ]] || error "search released: found $res != $f2"
7804 res=$($LFS find $dir -type f \! -L released)
7805 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
7807 run_test 56y "lfs find -L raid0|released"
7809 test_56z() { # LU-4824
7810 # This checks to make sure 'lfs find' continues after errors
7811 # There are two classes of errors that should be caught:
7812 # - If multiple paths are provided, all should be searched even if one
7814 # - If errors are encountered during the search, it should not terminate
7816 local dir=$DIR/$tdir
7820 for i in d{0..9}; do
7822 touch $dir/$i/$tfile
7824 $LFS find $DIR/non_existent_dir $dir &&
7825 error "$LFS find did not return an error"
7826 # Make a directory unsearchable. This should NOT be the last entry in
7827 # directory order. Arbitrarily pick the 6th entry
7828 chmod 700 $($LFS find $dir -type d | sed '6!d')
7830 $RUNAS $LFS find $DIR/non_existent $dir
7831 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
7833 # The user should be able to see 10 directories and 9 files
7834 (( count == 19 )) ||
7835 error "$LFS find found $count != 19 entries after error"
7837 run_test 56z "lfs find should continue after an error"
7839 test_56aa() { # LU-5937
7840 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
7842 local dir=$DIR/$tdir
7845 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
7847 createmany -o $dir/striped_dir/${tfile}- 1024
7848 local dirs=$($LFS find --size +8k $dir/)
7850 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
7852 run_test 56aa "lfs find --size under striped dir"
7854 test_56ab() { # LU-10705
7855 test_mkdir $DIR/$tdir
7856 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
7857 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
7858 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
7859 # Flush writes to ensure valid blocks. Need to be more thorough for
7860 # ZFS, since blocks are not allocated/returned to client immediately.
7862 wait_zfs_commit ost1 2
7863 cancel_lru_locks osc
7866 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
7868 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
7870 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
7871 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
7873 rm -f $DIR/$tdir/$tfile.[123]
7875 run_test 56ab "lfs find --blocks"
7879 local dir="$DIR/$tdir"
7880 local perms=(001 002 003 004 005 006 007
7881 010 020 030 040 050 060 070
7882 100 200 300 400 500 600 700
7883 111 222 333 444 555 666 777)
7884 local perm_minus=(8 8 4 8 4 4 2
7888 local perm_slash=(8 8 12 8 12 12 14
7891 16 16 24 16 24 24 28)
7894 for perm in ${perms[*]}; do
7895 touch "$dir/$tfile.$perm"
7896 chmod $perm "$dir/$tfile.$perm"
7899 for ((i = 0; i < ${#perms[*]}; i++)); do
7900 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
7902 error "lfs find -perm ${perms[i]}:"\
7905 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
7906 (( $num == ${perm_minus[i]} )) ||
7907 error "lfs find -perm -${perms[i]}:"\
7908 "$num != ${perm_minus[i]}"
7910 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
7911 (( $num == ${perm_slash[i]} )) ||
7912 error "lfs find -perm /${perms[i]}:"\
7913 "$num != ${perm_slash[i]}"
7916 run_test 56aca "check lfs find -perm with octal representation"
7919 local dir=$DIR/$tdir
7920 # p is the permission of write and execute for user, group and other
7921 # without the umask. It is used to test +wx.
7922 local p=$(printf "%o" "$((0333 & ~$(umask)))")
7923 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
7924 local symbolic=(+t a+t u+t g+t o+t
7930 o=r,ug+o,u+w u=r,a+u,u+w
7931 g=r,ugo=g,u+w u+x,+X +X
7932 u+x,u+X u+X u+x,g+X o+r,+X
7936 for perm in ${perms[*]}; do
7937 touch "$dir/$tfile.$perm"
7938 chmod $perm "$dir/$tfile.$perm"
7941 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
7942 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
7945 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
7948 run_test 56acb "check lfs find -perm with symbolic representation"
7951 local dir=$DIR/$tdir
7952 local tests="17777 787 789 abcd
7953 ug=uu ug=a ug=gu uo=ou urw
7957 for err in $tests; do
7958 if $LFS find $dir -perm $err 2>/dev/null; then
7959 error "lfs find -perm $err: parsing should have failed"
7963 run_test 56acc "check parsing error for lfs find -perm"
7966 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
7967 skip "Need MDS version at least 2.10.50"
7969 # Create composite files with one component
7970 local dir=$DIR/$tdir
7972 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
7973 # Create composite files with three components
7974 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
7975 # Create non-composite files
7976 createmany -o $dir/${tfile}- 10
7978 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
7980 [[ $nfiles == 10 ]] ||
7981 error "lfs find -E 1M found $nfiles != 10 files"
7983 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
7984 [[ $nfiles == 25 ]] ||
7985 error "lfs find ! -E 1M found $nfiles != 25 files"
7987 # All files have a component that starts at 0
7988 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
7989 [[ $nfiles == 35 ]] ||
7990 error "lfs find --component-start 0 - $nfiles != 35 files"
7992 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
7993 [[ $nfiles == 15 ]] ||
7994 error "lfs find --component-start 2M - $nfiles != 15 files"
7996 # All files created here have a componenet that does not starts at 2M
7997 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
7998 [[ $nfiles == 35 ]] ||
7999 error "lfs find ! --component-start 2M - $nfiles != 35 files"
8001 # Find files with a specified number of components
8002 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
8003 [[ $nfiles == 15 ]] ||
8004 error "lfs find --component-count 3 - $nfiles != 15 files"
8006 # Remember non-composite files have a component count of zero
8007 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
8008 [[ $nfiles == 10 ]] ||
8009 error "lfs find --component-count 0 - $nfiles != 10 files"
8011 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
8012 [[ $nfiles == 20 ]] ||
8013 error "lfs find ! --component-count 3 - $nfiles != 20 files"
8015 # All files have a flag called "init"
8016 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
8017 [[ $nfiles == 35 ]] ||
8018 error "lfs find --component-flags init - $nfiles != 35 files"
8020 # Multi-component files will have a component not initialized
8021 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
8022 [[ $nfiles == 15 ]] ||
8023 error "lfs find !--component-flags init - $nfiles != 15 files"
8028 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
8031 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
8032 skip "Need MDS version at least 2.10.57"
8042 # create mirrored directories and mirrored files
8043 mkdir $td || error "mkdir $td failed"
8044 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
8045 createmany -o $tf- 10 || error "create $tf- failed"
8047 for i in $(seq 2); do
8049 mkdir $dir || error "mkdir $dir failed"
8050 $LFS mirror create -N$((3 + i)) $dir ||
8051 error "create mirrored dir $dir failed"
8052 createmany -o $dir/$tfile- 10 ||
8053 error "create $dir/$tfile- failed"
8056 # change the states of some mirrored files
8058 for i in $(seq 2); do
8060 for j in $(seq 4 9); do
8061 echo foo > $dir/$tfile-$j
8065 # find mirrored files with specific mirror count
8066 cmd="$LFS find --mirror-count 3 --type f $td"
8067 nfiles=$($cmd | wc -l)
8068 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
8070 cmd="$LFS find ! --mirror-count 3 --type f $td"
8071 nfiles=$($cmd | wc -l)
8072 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
8074 cmd="$LFS find --mirror-count +2 --type f $td"
8075 nfiles=$($cmd | wc -l)
8076 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8078 cmd="$LFS find --mirror-count -6 --type f $td"
8079 nfiles=$($cmd | wc -l)
8080 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8082 # find mirrored files with specific file state
8083 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
8084 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
8086 cmd="$LFS find --mirror-state=ro --type f $td"
8087 nfiles=$($cmd | wc -l)
8088 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
8090 cmd="$LFS find ! --mirror-state=ro --type f $td"
8091 nfiles=$($cmd | wc -l)
8092 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8094 cmd="$LFS find --mirror-state=wp --type f $td"
8095 nfiles=$($cmd | wc -l)
8096 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8098 cmd="$LFS find ! --mirror-state=sp --type f $td"
8099 nfiles=$($cmd | wc -l)
8100 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8102 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
8104 test_56da() { # LU-14179
8105 local path=$DIR/$tdir
8110 local longdir=$(str_repeat 'a' 255)
8112 for i in {1..15}; do
8119 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
8124 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
8127 touch $(str_repeat 'f' 255)
8129 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
8130 error "lfs find reported an error"
8134 run_test 56da "test lfs find with long paths"
8137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8138 # note test will not do anything if MDS is not local
8139 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8140 skip_env "ldiskfs only test"
8142 remote_mds_nodsh && skip "remote MDS with nodsh"
8144 local MNTDEV="osd*.*MDT*.mntdev"
8145 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
8146 [ -z "$DEV" ] && error "can't access $MNTDEV"
8147 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
8148 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
8149 error "can't access $DEV"
8150 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
8151 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
8155 run_test 57a "verify MDS filesystem created with large inodes =="
8158 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8159 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8160 skip_env "ldiskfs only test"
8162 remote_mds_nodsh && skip "remote MDS with nodsh"
8164 local dir=$DIR/$tdir
8167 local fileN=$dir/f$filecount
8169 rm -rf $dir || error "removing $dir"
8171 local mdtidx=$($LFS getstripe -m $dir)
8172 local mdtname=MDT$(printf %04x $mdtidx)
8173 local facet=mds$((mdtidx + 1))
8175 echo "mcreating $filecount files"
8176 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
8178 # verify that files do not have EAs yet
8179 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
8180 error "$file1 has an EA"
8181 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
8182 error "$fileN has an EA"
8186 df $dir #make sure we get new statfs data
8187 local mdsfree=$(do_facet $facet \
8188 lctl get_param -n osd*.*$mdtname.kbytesfree)
8189 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8192 echo "opening files to create objects/EAs"
8193 for file in $(seq -f $dir/f%g 1 $filecount); do
8194 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
8195 error "opening $file"
8198 # verify that files have EAs now
8199 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
8200 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
8202 sleep 1 #make sure we get new statfs data
8204 local mdsfree2=$(do_facet $facet \
8205 lctl get_param -n osd*.*$mdtname.kbytesfree)
8206 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8208 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
8209 if [ "$mdsfree" != "$mdsfree2" ]; then
8210 error "MDC before $mdcfree != after $mdcfree2"
8212 echo "MDC before $mdcfree != after $mdcfree2"
8213 echo "unable to confirm if MDS has large inodes"
8218 run_test 57b "default LOV EAs are stored inside large inodes ==="
8221 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8222 [ -z "$(which wiretest 2>/dev/null)" ] &&
8223 skip_env "could not find wiretest"
8227 run_test 58 "verify cross-platform wire constants =============="
8230 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8232 echo "touch 130 files"
8233 createmany -o $DIR/f59- 130
8235 unlinkmany $DIR/f59- 130
8237 # wait for commitment of removal
8238 wait_delete_completed
8240 run_test 59 "verify cancellation of llog records async ========="
8242 TEST60_HEAD="test_60 run $RANDOM"
8244 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8245 remote_mgs_nodsh && skip "remote MGS with nodsh"
8246 do_facet mgs "! which run-llog.sh &> /dev/null" &&
8247 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
8248 skip_env "missing subtest run-llog.sh"
8250 log "$TEST60_HEAD - from kernel mode"
8251 do_facet mgs "$LCTL dk > /dev/null"
8252 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
8253 do_facet mgs $LCTL dk > $TMP/$tfile
8255 # LU-6388: test llog_reader
8256 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
8257 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
8258 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
8259 skip_env "missing llog_reader"
8260 local fstype=$(facet_fstype mgs)
8261 [ $fstype != ldiskfs -a $fstype != zfs ] &&
8262 skip_env "Only for ldiskfs or zfs type mgs"
8264 local mntpt=$(facet_mntpt mgs)
8265 local mgsdev=$(mgsdevname 1)
8277 #get fid and record list
8278 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
8280 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
8282 #remount mgs as ldiskfs or zfs type
8283 stop mgs || error "stop mgs failed"
8284 mount_fstype mgs || error "remount mgs failed"
8285 for ((i = 0; i < ${#fid_list[@]}; i++)); do
8288 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
8289 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
8294 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
8296 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
8298 echo "obj_file is $obj_file"
8299 do_facet mgs $llog_reader $obj_file
8301 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
8302 awk '{ print $3 }' | sed -e "s/^type=//g")
8303 if [ $rec_type != $rec ]; then
8304 echo "FAILED test_60a wrong record type $rec_type," \
8310 #check obj path if record type is LLOG_LOGID_MAGIC
8311 if [ "$rec" == "1064553b" ]; then
8312 path=$(do_facet mgs $llog_reader $obj_file |
8313 grep "path=" | awk '{ print $NF }' |
8314 sed -e "s/^path=//g")
8315 if [ $obj_file != $mntpt/$path ]; then
8316 echo "FAILED test_60a wrong obj path" \
8317 "$montpt/$path, should be $obj_file"
8324 #restart mgs before "error", otherwise it will block the next test
8325 stop mgs || error "stop mgs failed"
8326 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
8327 $pass || error "test failed, see FAILED test_60a messages for specifics"
8329 run_test 60a "llog_test run from kernel module and test llog_reader"
8331 test_60b() { # bug 6411
8332 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8335 LLOG_COUNT=$(do_facet mgs dmesg |
8336 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
8337 /llog_[a-z]*.c:[0-9]/ {
8349 [[ $LLOG_COUNT -gt 120 ]] &&
8350 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
8352 run_test 60b "limit repeated messages from CERROR/CWARN"
8355 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8357 echo "create 5000 files"
8358 createmany -o $DIR/f60c- 5000
8359 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
8360 lctl set_param fail_loc=0x80000137
8361 unlinkmany $DIR/f60c- 5000
8362 lctl set_param fail_loc=0
8364 run_test 60c "unlink file when mds full"
8367 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8369 SAVEPRINTK=$(lctl get_param -n printk)
8370 # verify "lctl mark" is even working"
8371 MESSAGE="test message ID $RANDOM $$"
8372 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8373 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
8375 lctl set_param printk=0 || error "set lnet.printk failed"
8376 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
8377 MESSAGE="new test message ID $RANDOM $$"
8378 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
8379 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8380 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
8382 lctl set_param -n printk="$SAVEPRINTK"
8384 run_test 60d "test printk console message masking"
8387 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8388 remote_mds_nodsh && skip "remote MDS with nodsh"
8391 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
8392 do_facet mds1 lctl set_param fail_loc=0x15b
8395 run_test 60e "no space while new llog is being created"
8398 local old_path=$($LCTL get_param -n debug_path)
8400 stack_trap "$LCTL set_param debug_path=$old_path"
8401 stack_trap "rm -f $TMP/$tfile*"
8402 rm -f $TMP/$tfile* 2> /dev/null
8403 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8404 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
8405 test_mkdir $DIR/$tdir
8406 # retry in case the open is cached and not released
8407 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
8408 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
8412 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
8414 run_test 60f "change debug_path works"
8420 test_mkdir -c $MDSCOUNT $DIR/$tdir
8425 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
8426 -c $MDSCOUNT $DIR/$tdir/subdir$index \
8428 mkdir $DIR/$tdir/subdir$index 2>/dev/null
8429 rmdir $DIR/$tdir/subdir$index 2>/dev/null
8430 index=$((index + 1))
8436 for i in {0..100}; do
8437 # define OBD_FAIL_OSD_TXN_START 0x19a
8438 local index=$((i % MDSCOUNT + 1))
8440 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
8447 for i in $(seq $MDSCOUNT); do
8448 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
8451 mkdir $DIR/$tdir/new || error "mkdir failed"
8452 rmdir $DIR/$tdir/new || error "rmdir failed"
8454 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
8456 for i in $(seq $MDSCOUNT); do
8457 wait_update_facet mds$i "$LCTL get_param -n \
8458 mdd.$(facet_svc mds$i).lfsck_namespace |
8459 awk '/^status/ { print \\\$2 }'" "completed"
8462 ls -R $DIR/$tdir || error "ls failed"
8463 rm -rf $DIR/$tdir || error "rmdir failed"
8465 run_test 60g "transaction abort won't cause MDT hung"
8468 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
8469 skip "Need MDS version at least 2.12.52"
8470 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
8474 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
8475 #define OBD_FAIL_MDS_STRIPE_FID 0x189
8476 for fail_loc in 0x80000188 0x80000189; do
8477 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
8478 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
8479 error "mkdir $dir-$fail_loc failed"
8480 for i in {0..10}; do
8481 # create may fail on missing stripe
8482 echo $i > $DIR/$tdir-$fail_loc/$i
8484 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8485 error "getdirstripe $tdir-$fail_loc failed"
8486 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
8487 error "migrate $tdir-$fail_loc failed"
8488 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8489 error "getdirstripe $tdir-$fail_loc failed"
8490 pushd $DIR/$tdir-$fail_loc
8492 echo $f | cmp $f - || error "$f data mismatch"
8495 rm -rf $DIR/$tdir-$fail_loc
8498 run_test 60h "striped directory with missing stripes can be accessed"
8500 function t60i_load() {
8502 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
8503 $LCTL set_param fail_loc=0x131c fail_val=1
8504 for ((i=0; i<5000; i++)); do
8505 touch $DIR/$tdir/f$i
8510 changelog_register || error "changelog_register failed"
8511 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
8512 changelog_users $SINGLEMDS | grep -q $cl_user ||
8513 error "User $cl_user not found in changelog_users"
8514 changelog_chmask "ALL"
8517 for((i=0; i<100; i++)); do
8518 changelog_dump >/dev/null ||
8519 error "can't read changelog"
8523 changelog_deregister || error "changelog_deregister failed"
8524 $LCTL set_param fail_loc=0
8526 run_test 60i "llog: new record vs reader race"
8529 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8532 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
8533 cancel_lru_locks osc
8534 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
8537 run_test 61a "mmap() writes don't make sync hang ================"
8540 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
8542 run_test 61b "mmap() of unstriped file is successful"
8544 # bug 2330 - insufficient obd_match error checking causes LBUG
8546 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8550 cancel_lru_locks osc
8551 lctl set_param fail_loc=0x405
8552 cat $f && error "cat succeeded, expect -EIO"
8553 lctl set_param fail_loc=0
8555 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
8556 # match every page all of the time.
8557 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
8559 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
8560 # Though this test is irrelevant anymore, it helped to reveal some
8561 # other grant bugs (LU-4482), let's keep it.
8562 test_63a() { # was test_63
8563 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8565 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
8567 for i in `seq 10` ; do
8568 dd if=/dev/zero of=$DIR/f63 bs=8k &
8574 rm -f $DIR/f63 || true
8576 run_test 63a "Verify oig_wait interruption does not crash ======="
8578 # bug 2248 - async write errors didn't return to application on sync
8579 # bug 3677 - async write errors left page locked
8581 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8584 lctl set_param debug=-1
8586 # ensure we have a grant to do async writes
8587 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
8590 sync # sync lest earlier test intercept the fail_loc
8592 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8593 lctl set_param fail_loc=0x80000406
8594 $MULTIOP $DIR/$tfile Owy && \
8595 error "sync didn't return ENOMEM"
8596 sync; sleep 2; sync # do a real sync this time to flush page
8597 lctl get_param -n llite.*.dump_page_cache | grep locked && \
8598 error "locked page left in cache after async error" || true
8601 run_test 63b "async write errors should be returned to fsync ==="
8604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8607 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
8609 run_test 64a "verify filter grant calculations (in kernel) ====="
8612 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8614 sh oos.sh $MOUNT || error "oos.sh failed: $?"
8616 run_test 64b "check out-of-space detection on client"
8619 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
8621 run_test 64c "verify grant shrink"
8627 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
8630 # this does exactly what osc_request.c:osc_announce_cached() does in
8631 # order to calculate max amount of grants to ask from server
8635 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
8636 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
8638 ((rpc_in_flight++));
8639 nrpages=$((nrpages * rpc_in_flight))
8641 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
8643 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
8645 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
8646 local undirty=$((nrpages * PAGE_SIZE))
8648 local max_extent_pages
8649 max_extent_pages=$(import_param $tgt grant_max_extent_size)
8650 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
8651 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
8652 local grant_extent_tax
8653 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8655 undirty=$((undirty + nrextents * grant_extent_tax))
8660 # this is size of unit for grant allocation. It should be equal to
8661 # what tgt_grant.c:tgt_grant_chunk() calculates
8665 local grant_extent_tax
8667 max_brw_size=$(import_param $tgt max_brw_size)
8669 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8671 echo $(((max_brw_size + grant_extent_tax) * 2))
8675 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
8676 skip "OST < 2.10.55 doesn't limit grants enough"
8678 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
8680 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
8681 skip "no grant_param connect flag"
8683 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
8685 $LCTL set_param -n -n debug="$OLDDEBUG" || true
8686 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
8689 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
8690 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
8692 $LFS setstripe $DIR/$tfile -i 0 -c 1
8693 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
8696 while kill -0 $ddpid; do
8697 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8699 if [[ $cur_grant -gt $max_cur_granted ]]; then
8701 error "cur_grant $cur_grant > $max_cur_granted"
8707 run_test 64d "check grant limit exceed"
8713 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8715 ((cur_grants == expected)) ||
8716 error "$msg: grants mismatch: $cur_grants, expected $expected"
8720 echo $((($1 + $2 - 1) & ~($2 - 1)))
8724 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8725 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
8726 skip "Need OSS version at least 2.11.56"
8728 # Remount client to reset grant
8729 remount_client $MOUNT || error "failed to remount client"
8730 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8732 local init_grants=$(import_param $osc_tgt initial_grant)
8734 check_grants $osc_tgt $init_grants "init grants"
8736 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
8737 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8738 local gbs=$(import_param $osc_tgt grant_block_size)
8740 # write random number of bytes from max_brw_size / 4 to max_brw_size
8741 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
8742 # align for direct io
8743 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
8744 # round to grant consumption unit
8745 local wb_round_up=$(round_up_p2 $write_bytes gbs)
8747 local grants=$((wb_round_up + extent_tax))
8749 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8751 # define OBD_FAIL_TGT_NO_GRANT 0x725
8752 # make the server not grant more back
8753 do_facet ost1 $LCTL set_param fail_loc=0x725
8754 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
8756 do_facet ost1 $LCTL set_param fail_loc=0
8758 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
8760 rm -f $DIR/$tfile || error "rm failed"
8762 # Remount client to reset grant
8763 remount_client $MOUNT || error "failed to remount client"
8764 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8766 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8768 # define OBD_FAIL_TGT_NO_GRANT 0x725
8769 # make the server not grant more back
8770 do_facet ost1 $LCTL set_param fail_loc=0x725
8771 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
8772 do_facet ost1 $LCTL set_param fail_loc=0
8774 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
8776 run_test 64e "check grant consumption (no grant allocation)"
8779 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8781 # Remount client to reset grant
8782 remount_client $MOUNT || error "failed to remount client"
8783 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8785 local init_grants=$(import_param $osc_tgt initial_grant)
8786 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
8787 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8788 local gbs=$(import_param $osc_tgt grant_block_size)
8789 local chunk=$(grant_chunk $osc_tgt)
8791 # write random number of bytes from max_brw_size / 4 to max_brw_size
8792 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
8793 # align for direct io
8794 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
8795 # round to grant consumption unit
8796 local wb_round_up=$(round_up_p2 $write_bytes gbs)
8798 local grants=$((wb_round_up + extent_tax))
8800 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8801 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
8802 error "error writing to $DIR/$tfile"
8804 check_grants $osc_tgt $((init_grants - grants + chunk)) \
8805 "direct io with grant allocation"
8807 rm -f $DIR/$tfile || error "rm failed"
8809 # Remount client to reset grant
8810 remount_client $MOUNT || error "failed to remount client"
8811 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8813 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8815 local cmd="oO_WRONLY:w${write_bytes}_yc"
8817 $MULTIOP $DIR/$tfile $cmd &
8821 check_grants $osc_tgt $((init_grants - grants)) \
8822 "buffered io, not write rpc"
8824 kill -USR1 $MULTIPID
8827 check_grants $osc_tgt $((init_grants - grants + chunk)) \
8828 "buffered io, one RPC"
8830 run_test 64f "check grant consumption (with grant allocation)"
8833 #[ $MDS1_VERSION -lt $(version_code 2.14.54) ] &&
8834 # skip "Need MDS version at least 2.14.54"
8836 local mdts=$(comma_list $(mdts_nodes))
8838 local old=$($LCTL get_param mdc.$FSNAME-*.grant_shrink_interval |
8840 stack_trap "$LCTL set_param $old"
8842 # generate dirty pages and increase dirty granted on MDT
8843 stack_trap "rm -f $DIR/$tfile-*"
8844 for (( i = 0; i < 10; i++)); do
8845 $LFS setstripe -E 1M -L mdt $DIR/$tfile-$i ||
8846 error "can't set stripe"
8847 dd if=/dev/zero of=$DIR/$tfile-$i bs=128k count=1 ||
8849 $LFS getstripe $DIR/$tfile-$i | grep -q pattern.*mdt || {
8850 $LFS getstripe $DIR/$tfile-$i
8851 error "not DoM file"
8858 # wait until grant shrink reset grant dirty on MDTs
8859 for ((i = 0; i < 120; i++)); do
8860 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
8861 awk '{sum=sum+$1} END {print sum}')
8862 vm_dirty=$(awk '/Dirty:/{print $2}' /proc/meminfo)
8863 echo "$grant_dirty grants, $vm_dirty pages"
8864 (( grant_dirty + vm_dirty == 0 )) && break
8865 (( i == 3 )) && sync &&
8866 $LCTL set_param mdc.$FSNAME-*.grant_shrink_interval=5
8870 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
8871 awk '{sum=sum+$1} END {print sum}')
8872 (( grant_dirty == 0 )) || error "$grant_dirty on MDT"
8874 run_test 64g "grant shrink on MDT"
8877 local instance=$($LFS getname -i $DIR)
8878 local osc_tgt="$FSNAME-OST0000-osc-$instance"
8879 local num_exps=$(do_facet ost1 \
8880 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
8881 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8882 local avail=$($LCTL get_param -n osc.*OST0000-osc-$instance.kbytesavail)
8883 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
8885 # 10MiB is for file to be written, max_brw_size * 16 *
8886 # num_exps is space reserve so that tgt_grant_shrink() decided
8888 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
8889 (( avail * 1024 < expect )) &&
8890 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
8892 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
8893 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
8894 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
8895 $LCTL set_param osc.*OST0000*.grant_shrink=1
8896 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
8898 $LFS setstripe -c 1 -i 0 $DIR/$tfile
8899 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
8901 # drop cache so that coming read would do rpc
8902 cancel_lru_locks osc
8904 # shrink interval is set to 10, pause for 7 seconds so that
8905 # grant thread did not wake up yet but coming read entered
8906 # shrink mode for rpc (osc_should_shrink_grant())
8909 declare -a cur_grant_bytes
8910 declare -a tot_granted
8911 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
8912 tot_granted[0]=$(do_facet ost1 \
8913 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
8915 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
8917 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
8918 tot_granted[1]=$(do_facet ost1 \
8919 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
8921 # grant change should be equal on both sides
8922 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
8923 tot_granted[0] - tot_granted[1])) ||
8924 error "grant change mismatch, " \
8925 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
8926 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
8928 run_test 64h "grant shrink on read"
8931 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
8932 skip "need OST at least 2.14.55 to avoid grant shrink on replay"
8934 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8935 remote_ost_nodsh && skip "remote OSTs with nodsh"
8937 $LFS setstripe -c 1 -i 0 $DIR/$tfile
8939 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
8941 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
8942 local instance=$($LFS getname -i $DIR)
8944 local osc_tgt="$FSNAME-OST0000-osc-$instance"
8945 local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
8947 # shrink grants and simulate rpc loss
8948 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
8949 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
8950 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
8954 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
8956 local testid=$(echo $TESTNAME | tr '_' ' ')
8958 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
8959 grep "GRANT, real grant" &&
8960 error "client has more grants then it owns" || true
8962 run_test 64i "shrink on reconnect"
8964 # bug 1414 - set/get directories' stripe info
8966 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8968 test_mkdir $DIR/$tdir
8970 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
8972 run_test 65a "directory with no stripe info"
8975 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8977 test_mkdir $DIR/$tdir
8978 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8980 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8983 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
8985 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
8988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8989 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
8991 test_mkdir $DIR/$tdir
8992 local stripesize=$($LFS getstripe -S $DIR/$tdir)
8994 $LFS setstripe -S $((stripesize * 4)) -i 1 \
8995 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
8997 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
8999 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
9002 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9004 test_mkdir $DIR/$tdir
9005 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
9006 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9008 if [[ $STRIPECOUNT -le 0 ]]; then
9010 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
9011 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
9012 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
9014 sc=$(($STRIPECOUNT - 1))
9016 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
9017 touch $DIR/$tdir/f4 $DIR/$tdir/f5
9018 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
9019 error "lverify failed"
9021 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
9024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9026 test_mkdir $DIR/$tdir
9028 $LFS setstripe $DIR/$tdir || error "setstripe"
9029 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9030 error "no stripe info failed"
9032 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
9034 run_test 65e "directory setstripe defaults"
9037 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9039 test_mkdir $DIR/${tdir}f
9040 $RUNAS $LFS setstripe $DIR/${tdir}f &&
9041 error "setstripe succeeded" || true
9043 run_test 65f "dir setstripe permission (should return error) ==="
9046 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9048 test_mkdir $DIR/$tdir
9049 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9051 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9052 error "setstripe -S failed"
9053 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
9054 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9055 error "delete default stripe failed"
9057 run_test 65g "directory setstripe -d"
9060 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9062 test_mkdir $DIR/$tdir
9063 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9065 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9066 error "setstripe -S failed"
9067 test_mkdir $DIR/$tdir/dd1
9068 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
9069 error "stripe info inherit failed"
9071 run_test 65h "directory stripe info inherit ===================="
9074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9076 save_layout_restore_at_exit $MOUNT
9078 # bug6367: set non-default striping on root directory
9079 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
9081 # bug12836: getstripe on -1 default directory striping
9082 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
9084 # bug12836: getstripe -v on -1 default directory striping
9085 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
9087 # bug12836: new find on -1 default directory striping
9088 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
9090 run_test 65i "various tests to set root directory striping"
9092 test_65j() { # bug6367
9093 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9097 # if we aren't already remounting for each test, do so for this test
9098 if [ "$I_MOUNTED" = "yes" ]; then
9099 cleanup || error "failed to unmount"
9103 save_layout_restore_at_exit $MOUNT
9105 $LFS setstripe -d $MOUNT || error "setstripe failed"
9107 run_test 65j "set default striping on root directory (bug 6367)="
9111 wait_delete_completed
9112 do_facet $SINGLEMDS "lctl set_param -n \
9113 osp.$ost*MDT0000.max_create_count=$max_count"
9114 do_facet $SINGLEMDS "lctl set_param -n \
9115 osp.$ost*MDT0000.create_count=$count"
9116 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9117 echo $INACTIVE_OSC "is Activate"
9119 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9122 test_65k() { # bug11679
9123 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9124 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9125 remote_mds_nodsh && skip "remote MDS with nodsh"
9127 local disable_precreate=true
9128 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
9129 disable_precreate=false
9131 echo "Check OST status: "
9132 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
9133 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
9135 for OSC in $MDS_OSCS; do
9136 echo $OSC "is active"
9137 do_facet $SINGLEMDS lctl --device %$OSC activate
9140 for INACTIVE_OSC in $MDS_OSCS; do
9141 local ost=$(osc_to_ost $INACTIVE_OSC)
9142 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
9143 lov.*md*.target_obd |
9144 awk -F: /$ost/'{ print $1 }' | head -n 1)
9147 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
9148 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
9150 echo "Deactivate: " $INACTIVE_OSC
9151 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
9153 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
9154 osp.$ost*MDT0000.create_count")
9155 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
9156 osp.$ost*MDT0000.max_create_count")
9157 $disable_precreate &&
9158 do_facet $SINGLEMDS "lctl set_param -n \
9159 osp.$ost*MDT0000.max_create_count=0"
9161 for idx in $(seq 0 $((OSTCOUNT - 1))); do
9162 [ -f $DIR/$tdir/$idx ] && continue
9163 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
9164 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
9166 error "setstripe $idx should succeed"; }
9167 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
9169 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
9172 do_facet $SINGLEMDS "lctl set_param -n \
9173 osp.$ost*MDT0000.max_create_count=$max_count"
9174 do_facet $SINGLEMDS "lctl set_param -n \
9175 osp.$ost*MDT0000.create_count=$count"
9176 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9177 echo $INACTIVE_OSC "is Activate"
9179 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9182 run_test 65k "validate manual striping works properly with deactivated OSCs"
9184 test_65l() { # bug 12836
9185 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9187 test_mkdir -p $DIR/$tdir/test_dir
9188 $LFS setstripe -c -1 $DIR/$tdir/test_dir
9189 $LFS find -mtime -1 $DIR/$tdir >/dev/null
9191 run_test 65l "lfs find on -1 stripe dir ========================"
9194 local layout=$(save_layout $MOUNT)
9195 $RUNAS $LFS setstripe -c 2 $MOUNT && {
9196 restore_layout $MOUNT $layout
9197 error "setstripe should fail by non-root users"
9201 run_test 65m "normal user can't set filesystem default stripe"
9204 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
9205 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
9206 skip "Need MDS version at least 2.12.50"
9207 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9209 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
9210 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
9211 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
9213 save_layout_restore_at_exit $MOUNT
9215 # new subdirectory under root directory should not inherit
9216 # the default layout from root
9217 local dir1=$MOUNT/$tdir-1
9218 mkdir $dir1 || error "mkdir $dir1 failed"
9219 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
9220 error "$dir1 shouldn't have LOV EA"
9222 # delete the default layout on root directory
9223 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
9225 local dir2=$MOUNT/$tdir-2
9226 mkdir $dir2 || error "mkdir $dir2 failed"
9227 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
9228 error "$dir2 shouldn't have LOV EA"
9230 # set a new striping pattern on root directory
9231 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9232 local new_def_stripe_size=$((def_stripe_size * 2))
9233 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
9234 error "set stripe size on $MOUNT failed"
9236 # new file created in $dir2 should inherit the new stripe size from
9237 # the filesystem default
9238 local file2=$dir2/$tfile-2
9239 touch $file2 || error "touch $file2 failed"
9241 local file2_stripe_size=$($LFS getstripe -S $file2)
9242 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
9244 echo "file2_stripe_size: '$file2_stripe_size'"
9245 echo "new_def_stripe_size: '$new_def_stripe_size'"
9246 error "$file2 didn't inherit stripe size $new_def_stripe_size"
9249 local dir3=$MOUNT/$tdir-3
9250 mkdir $dir3 || error "mkdir $dir3 failed"
9251 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
9252 # the root layout, which is the actual default layout that will be used
9253 # when new files are created in $dir3.
9254 local dir3_layout=$(get_layout_param $dir3)
9255 local root_dir_layout=$(get_layout_param $MOUNT)
9256 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
9258 echo "dir3_layout: '$dir3_layout'"
9259 echo "root_dir_layout: '$root_dir_layout'"
9260 error "$dir3 should show the default layout from $MOUNT"
9263 # set OST pool on root directory
9264 local pool=$TESTNAME
9265 pool_add $pool || error "add $pool failed"
9266 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9267 error "add targets to $pool failed"
9269 $LFS setstripe -p $pool $MOUNT ||
9270 error "set OST pool on $MOUNT failed"
9272 # new file created in $dir3 should inherit the pool from
9273 # the filesystem default
9274 local file3=$dir3/$tfile-3
9275 touch $file3 || error "touch $file3 failed"
9277 local file3_pool=$($LFS getstripe -p $file3)
9278 [[ "$file3_pool" = "$pool" ]] ||
9279 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
9281 local dir4=$MOUNT/$tdir-4
9282 mkdir $dir4 || error "mkdir $dir4 failed"
9283 local dir4_layout=$(get_layout_param $dir4)
9284 root_dir_layout=$(get_layout_param $MOUNT)
9285 echo "$LFS getstripe -d $dir4"
9286 $LFS getstripe -d $dir4
9287 echo "$LFS getstripe -d $MOUNT"
9288 $LFS getstripe -d $MOUNT
9289 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
9291 echo "dir4_layout: '$dir4_layout'"
9292 echo "root_dir_layout: '$root_dir_layout'"
9293 error "$dir4 should show the default layout from $MOUNT"
9296 # new file created in $dir4 should inherit the pool from
9297 # the filesystem default
9298 local file4=$dir4/$tfile-4
9299 touch $file4 || error "touch $file4 failed"
9301 local file4_pool=$($LFS getstripe -p $file4)
9302 [[ "$file4_pool" = "$pool" ]] ||
9303 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
9305 # new subdirectory under non-root directory should inherit
9306 # the default layout from its parent directory
9307 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
9308 error "set directory layout on $dir4 failed"
9310 local dir5=$dir4/$tdir-5
9311 mkdir $dir5 || error "mkdir $dir5 failed"
9313 dir4_layout=$(get_layout_param $dir4)
9314 local dir5_layout=$(get_layout_param $dir5)
9315 [[ "$dir4_layout" = "$dir5_layout" ]] ||
9317 echo "dir4_layout: '$dir4_layout'"
9318 echo "dir5_layout: '$dir5_layout'"
9319 error "$dir5 should inherit the default layout from $dir4"
9322 # though subdir under ROOT doesn't inherit default layout, but
9323 # its sub dir/file should be created with default layout.
9324 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
9325 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
9326 skip "Need MDS version at least 2.12.59"
9328 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
9329 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
9330 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
9332 if [ $default_lmv_hash == "none" ]; then
9333 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
9335 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
9336 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
9339 $LFS setdirstripe -D -c 2 $MOUNT ||
9340 error "setdirstripe -D -c 2 failed"
9341 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
9342 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
9343 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
9345 run_test 65n "don't inherit default layout from root for new subdirectories"
9347 # bug 2543 - update blocks count on client
9349 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9352 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
9353 sync; sync_all_data; sync; sync_all_data
9354 cancel_lru_locks osc
9355 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
9356 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
9358 run_test 66 "update inode blocks count on client ==============="
9361 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
9365 swapon -s | awk '($1 == "'$1'") { print $4 }'
9368 # bug5265, obdfilter oa2dentry return -ENOENT
9369 # #define OBD_FAIL_SRV_ENOENT 0x217
9371 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9372 remote_ost_nodsh && skip "remote OST with nodsh"
9375 $LFS setstripe -c 1 -i 0 $f
9377 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
9379 do_facet ost1 lctl set_param fail_loc=0x217
9380 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
9381 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
9383 do_facet ost1 lctl set_param fail_loc=0
9384 $DIRECTIO write $f 0 2 || error "write error"
9386 cancel_lru_locks osc
9387 $DIRECTIO read $f 0 1 || error "read error"
9389 do_facet ost1 lctl set_param fail_loc=0x217
9390 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
9392 do_facet ost1 lctl set_param fail_loc=0
9395 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
9398 test_mkdir $DIR/$tdir
9399 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
9400 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
9402 run_test 71 "Running dbench on lustre (don't segment fault) ===="
9404 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
9405 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9406 [ "$RUNAS_ID" = "$UID" ] &&
9407 skip_env "RUNAS_ID = UID = $UID -- skipping"
9408 # Check that testing environment is properly set up. Skip if not
9409 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
9410 skip_env "User $RUNAS_ID does not exist - skipping"
9413 chmod 777 $DIR/$tfile
9414 chmod ug+s $DIR/$tfile
9415 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
9416 error "$RUNAS dd $DIR/$tfile failed"
9417 # See if we are still setuid/sgid
9418 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9419 error "S/gid is not dropped on write"
9420 # Now test that MDS is updated too
9421 cancel_lru_locks mdc
9422 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9423 error "S/gid is not dropped on MDS"
9426 run_test 72a "Test that remove suid works properly (bug5695) ===="
9428 test_72b() { # bug 24226 -- keep mode setting when size is not changing
9431 [ "$RUNAS_ID" = "$UID" ] &&
9432 skip_env "RUNAS_ID = UID = $UID -- skipping"
9433 [ "$RUNAS_ID" -eq 0 ] &&
9434 skip_env "RUNAS_ID = 0 -- skipping"
9435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9436 # Check that testing environment is properly set up. Skip if not
9437 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
9438 skip_env "User $RUNAS_ID does not exist - skipping"
9440 touch $DIR/${tfile}-f{g,u}
9441 test_mkdir $DIR/${tfile}-dg
9442 test_mkdir $DIR/${tfile}-du
9443 chmod 770 $DIR/${tfile}-{f,d}{g,u}
9444 chmod g+s $DIR/${tfile}-{f,d}g
9445 chmod u+s $DIR/${tfile}-{f,d}u
9446 for perm in 777 2777 4777; do
9447 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
9448 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
9449 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
9450 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
9454 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
9456 # bug 3462 - multiple simultaneous MDC requests
9458 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9460 test_mkdir $DIR/d73-1
9461 test_mkdir $DIR/d73-2
9462 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
9465 lctl set_param fail_loc=0x80000129
9466 $MULTIOP $DIR/d73-1/f73-2 Oc &
9468 lctl set_param fail_loc=0
9470 $MULTIOP $DIR/d73-2/f73-3 Oc &
9474 wait $pid1 || return 1
9478 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
9479 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
9480 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
9484 run_test 73 "multiple MDC requests (should not deadlock)"
9486 test_74a() { # bug 6149, 6184
9487 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9490 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9492 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9493 # will spin in a tight reconnection loop
9494 $LCTL set_param fail_loc=0x8000030e
9495 # get any lock that won't be difficult - lookup works.
9497 $LCTL set_param fail_loc=0
9501 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
9503 test_74b() { # bug 13310
9504 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9506 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9508 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9509 # will spin in a tight reconnection loop
9510 $LCTL set_param fail_loc=0x8000030e
9511 # get a "difficult" lock
9513 $LCTL set_param fail_loc=0
9517 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
9520 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9522 #define OBD_FAIL_LDLM_NEW_LOCK
9523 $LCTL set_param fail_loc=0x319
9524 touch $DIR/$tfile && error "touch successful"
9525 $LCTL set_param fail_loc=0
9528 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
9530 slab_lic=/sys/kernel/slab/lustre_inode_cache
9532 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
9533 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
9534 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
9537 test_76a() { # Now for b=20433, added originally in b=1443
9538 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9540 cancel_lru_locks osc
9541 # there may be some slab objects cached per core
9542 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
9543 local before=$(num_objects)
9544 local count=$((512 * cpus))
9545 [ "$SLOW" = "no" ] && count=$((128 * cpus))
9546 local margin=$((count / 10))
9547 if [[ -f $slab_lic/aliases ]]; then
9548 local aliases=$(cat $slab_lic/aliases)
9549 (( aliases > 0 )) && margin=$((margin * aliases))
9552 echo "before slab objects: $before"
9553 for i in $(seq $count); do
9557 cancel_lru_locks osc
9558 local after=$(num_objects)
9559 echo "created: $count, after slab objects: $after"
9560 # shared slab counts are not very accurate, allow significant margin
9561 # the main goal is that the cache growth is not permanently > $count
9562 while (( after > before + margin )); do
9564 after=$(num_objects)
9566 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9567 if (( wait > 60 )); then
9568 error "inode slab grew from $before+$margin to $after"
9572 run_test 76a "confirm clients recycle inodes properly ===="
9575 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9576 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
9579 local before=$(num_objects)
9581 for i in $(seq $count); do
9586 local after=$(num_objects)
9589 while (( after > before )); do
9591 after=$(num_objects)
9593 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9594 if (( wait > 60 )); then
9595 error "inode slab grew from $before to $after"
9599 echo "slab objects before: $before, after: $after"
9601 run_test 76b "confirm clients recycle directory inodes properly ===="
9606 # Note: in sptlrpc modes which enable its own bulk checksum, the
9607 # original crc32_le bulk checksum will be automatically disabled,
9608 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
9609 # will be checked by sptlrpc code against sptlrpc bulk checksum.
9610 # In this case set_checksums() will not be no-op, because sptlrpc
9611 # bulk checksum will be enabled all through the test.
9613 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
9614 lctl set_param -n osc.*.checksums $1
9618 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9619 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
9620 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9621 tr -d [] | head -n1)}
9624 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
9626 log "set checksum type to $1, rc = $rc"
9630 get_osc_checksum_type()
9632 # arugment 1: OST name, like OST0000
9634 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
9635 sed 's/.*\[\(.*\)\].*/\1/g')
9637 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
9641 F77_TMP=$TMP/f77-temp
9644 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
9645 error "error writing to $F77_TMP"
9648 test_77a() { # bug 10889
9649 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9650 $GSS && skip_env "could not run with gss"
9652 [ ! -f $F77_TMP ] && setup_f77
9654 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
9658 run_test 77a "normal checksum read/write operation"
9660 test_77b() { # bug 10889
9661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9662 $GSS && skip_env "could not run with gss"
9664 [ ! -f $F77_TMP ] && setup_f77
9665 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9666 $LCTL set_param fail_loc=0x80000409
9669 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9670 error "dd error: $?"
9671 $LCTL set_param fail_loc=0
9673 for algo in $CKSUM_TYPES; do
9674 cancel_lru_locks osc
9675 set_checksum_type $algo
9676 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9677 $LCTL set_param fail_loc=0x80000408
9678 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
9679 $LCTL set_param fail_loc=0
9682 set_checksum_type $ORIG_CSUM_TYPE
9685 run_test 77b "checksum error on client write, read"
9690 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
9692 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
9693 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
9694 $check_ost && [ -n "$ost_file_prefix" ] &&
9695 do_facet ost1 rm -f ${ost_file_prefix}\*
9699 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9700 $GSS && skip_env "could not run with gss"
9701 remote_ost_nodsh && skip "remote OST with nodsh"
9704 local osc_file_prefix
9706 local check_ost=false
9707 local ost_file_prefix
9713 # ensure corruption will occur on first OSS/OST
9714 $LFS setstripe -i 0 $DIR/$tfile
9716 [ ! -f $F77_TMP ] && setup_f77
9717 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9718 error "dd write error: $?"
9719 fid=$($LFS path2fid $DIR/$tfile)
9721 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
9724 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
9725 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
9727 echo "OSS do not support bulk pages dump upon error"
9730 osc_file_prefix=$($LCTL get_param -n debug_path)
9731 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
9733 trap cleanup_77c EXIT
9736 # enable bulk pages dump upon error on Client
9737 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
9738 # enable bulk pages dump upon error on OSS
9740 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
9742 # flush Client cache to allow next read to reach OSS
9743 cancel_lru_locks osc
9745 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9746 $LCTL set_param fail_loc=0x80000408
9747 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
9748 $LCTL set_param fail_loc=0
9752 # check cksum dump on Client
9753 osc_file=$(ls ${osc_file_prefix}*)
9754 [ -n "$osc_file" ] || error "no checksum dump file on Client"
9755 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
9756 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
9757 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
9758 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
9760 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
9761 [[ "$orig_cksum" == "$dump_cksum" ]] ||
9762 error "dump content does not match on Client"
9764 $check_ost || skip "No need to check cksum dump on OSS"
9766 # check cksum dump on OSS
9767 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
9768 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
9769 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
9770 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
9771 [[ "$orig_cksum" == "$dump_cksum" ]] ||
9772 error "dump content does not match on OSS"
9776 run_test 77c "checksum error on client read with debug"
9778 test_77d() { # bug 10889
9779 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9780 $GSS && skip_env "could not run with gss"
9782 stack_trap "rm -f $DIR/$tfile"
9783 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9784 $LCTL set_param fail_loc=0x80000409
9786 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
9787 error "direct write: rc=$?"
9788 $LCTL set_param fail_loc=0
9791 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9792 $LCTL set_param fail_loc=0x80000408
9794 cancel_lru_locks osc
9795 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
9796 error "direct read: rc=$?"
9797 $LCTL set_param fail_loc=0
9800 run_test 77d "checksum error on OST direct write, read"
9802 test_77f() { # bug 10889
9803 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9804 $GSS && skip_env "could not run with gss"
9807 stack_trap "rm -f $DIR/$tfile"
9808 for algo in $CKSUM_TYPES; do
9809 cancel_lru_locks osc
9810 set_checksum_type $algo
9811 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9812 $LCTL set_param fail_loc=0x409
9813 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
9814 error "direct write succeeded"
9815 $LCTL set_param fail_loc=0
9817 set_checksum_type $ORIG_CSUM_TYPE
9820 run_test 77f "repeat checksum error on write (expect error)"
9822 test_77g() { # bug 10889
9823 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9824 $GSS && skip_env "could not run with gss"
9825 remote_ost_nodsh && skip "remote OST with nodsh"
9827 [ ! -f $F77_TMP ] && setup_f77
9829 local file=$DIR/$tfile
9830 stack_trap "rm -f $file" EXIT
9832 $LFS setstripe -c 1 -i 0 $file
9833 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
9834 do_facet ost1 lctl set_param fail_loc=0x8000021a
9836 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
9837 error "write error: rc=$?"
9838 do_facet ost1 lctl set_param fail_loc=0
9841 cancel_lru_locks osc
9842 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
9843 do_facet ost1 lctl set_param fail_loc=0x8000021b
9845 cmp $F77_TMP $file || error "file compare failed"
9846 do_facet ost1 lctl set_param fail_loc=0
9849 run_test 77g "checksum error on OST write, read"
9851 test_77k() { # LU-10906
9852 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9853 $GSS && skip_env "could not run with gss"
9855 local cksum_param="osc.$FSNAME*.checksums"
9856 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
9860 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
9861 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
9862 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
9865 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
9866 error "failed to set checksum=$i on MGS"
9867 wait_update $HOSTNAME "$get_checksum" $i
9869 echo "remount client, checksum should be $i"
9870 remount_client $MOUNT || error "failed to remount client"
9871 checksum=$(eval $get_checksum)
9872 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
9874 # remove persistent param to avoid races with checksum mountopt below
9875 do_facet mgs $LCTL set_param -P -d $cksum_param ||
9876 error "failed to delete checksum on MGS"
9878 for opt in "checksum" "nochecksum"; do
9879 #remount with mount option
9880 echo "remount client with option $opt, checksum should be $i"
9881 umount_client $MOUNT || error "failed to umount client"
9882 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
9883 error "failed to mount client with option '$opt'"
9884 checksum=$(eval $get_checksum)
9885 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
9889 remount_client $MOUNT || error "failed to remount client"
9891 run_test 77k "enable/disable checksum correctly"
9894 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9895 $GSS && skip_env "could not run with gss"
9898 stack_trap "set_checksums $ORIG_CSUM" EXIT
9899 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
9901 set_checksum_type invalid && error "unexpected success of invalid checksum type"
9903 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9904 for algo in $CKSUM_TYPES; do
9905 set_checksum_type $algo || error "fail to set checksum type $algo"
9906 osc_algo=$(get_osc_checksum_type OST0000)
9907 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
9909 # no locks, no reqs to let the connection idle
9910 cancel_lru_locks osc
9911 lru_resize_disable osc
9912 wait_osc_import_state client ost1 IDLE
9914 # ensure ost1 is connected
9915 stat $DIR/$tfile >/dev/null || error "can't stat"
9916 wait_osc_import_state client ost1 FULL
9918 osc_algo=$(get_osc_checksum_type OST0000)
9919 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
9923 run_test 77l "preferred checksum type is remembered after reconnected"
9925 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
9930 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
9931 skip "Need at least version 2.14.52"
9932 local param=checksum_speed
9934 $LCTL get_param $param || error "reading $param failed"
9936 csum_speeds=$($LCTL get_param -n $param)
9938 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
9939 error "known checksum types are missing"
9941 run_test 77m "Verify checksum_speed is correctly read"
9943 check_filefrag_77n() {
9948 while read extidx a b start end rest; do
9949 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
9950 nr_ext=$(( $nr_ext + 1 ))
9951 starts+=( ${start%..} )
9954 done < <( filefrag -sv $1 )
9956 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
9961 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
9964 $TRUNCATE $DIR/$tfile 0
9965 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
9966 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
9967 check_filefrag_77n $DIR/$tfile ||
9968 skip "$tfile blocks not contiguous around hole"
9971 stack_trap "set_checksums $ORIG_CSUM" EXIT
9972 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
9973 stack_trap "rm -f $DIR/$tfile"
9975 for algo in $CKSUM_TYPES; do
9976 if [[ "$algo" =~ ^t10 ]]; then
9977 set_checksum_type $algo ||
9978 error "fail to set checksum type $algo"
9979 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
9980 error "fail to read $tfile with $algo"
9986 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
9989 (( $CLIENT_VERSION >= $(version_code 2.14.54) )) ||
9990 skip "Need at least version 2.14.54"
9994 # print OST checksum_type
9995 echo "$ofd.$FSNAME-*.checksum_type:"
9996 do_nodes $(comma_list $(osts_nodes)) \
9997 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type
9999 # print MDT checksum_type
10000 echo "$mdt.$FSNAME-*.checksum_type:"
10001 do_nodes $(comma_list $(mdts_nodes)) \
10002 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type
10004 local o_count=$(do_nodes $(comma_list $(osts_nodes)) \
10005 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l)
10007 (( $o_count == $OSTCOUNT )) ||
10008 error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT"
10010 local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \
10011 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l)
10013 (( $m_count == $MDSCOUNT )) ||
10014 error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT"
10016 run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))"
10018 cleanup_test_78() {
10023 test_78() { # bug 10901
10024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10025 remote_ost || skip_env "local OST"
10028 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
10029 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
10030 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
10031 echo "MemTotal: $MEMTOTAL"
10033 # reserve 256MB of memory for the kernel and other running processes,
10034 # and then take 1/2 of the remaining memory for the read/write buffers.
10035 if [ $MEMTOTAL -gt 512 ] ;then
10036 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
10038 # for those poor memory-starved high-end clusters...
10039 MEMTOTAL=$((MEMTOTAL / 2))
10041 echo "Mem to use for directio: $MEMTOTAL"
10043 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
10044 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
10045 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
10046 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
10048 echo "Smallest OST: $SMALLESTOST"
10049 [[ $SMALLESTOST -lt 10240 ]] &&
10050 skip "too small OSTSIZE, useless to run large O_DIRECT test"
10052 trap cleanup_test_78 EXIT
10054 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
10055 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
10057 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
10058 echo "File size: $F78SIZE"
10059 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
10060 for i in $(seq 1 $NSEQ); do
10061 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
10062 echo directIO rdwr round $i of $NSEQ
10063 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
10068 run_test 78 "handle large O_DIRECT writes correctly ============"
10070 test_79() { # bug 12743
10071 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10073 wait_delete_completed
10075 BKTOTAL=$(calc_osc_kbytes kbytestotal)
10076 BKFREE=$(calc_osc_kbytes kbytesfree)
10077 BKAVAIL=$(calc_osc_kbytes kbytesavail)
10079 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
10080 DFTOTAL=`echo $STRING | cut -d, -f1`
10081 DFUSED=`echo $STRING | cut -d, -f2`
10082 DFAVAIL=`echo $STRING | cut -d, -f3`
10083 DFFREE=$(($DFTOTAL - $DFUSED))
10085 ALLOWANCE=$((64 * $OSTCOUNT))
10087 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
10088 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
10089 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
10091 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
10092 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
10093 error "df free($DFFREE) mismatch OST free($BKFREE)"
10095 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
10096 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
10097 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
10100 run_test 79 "df report consistency check ======================="
10102 test_80() { # bug 10718
10103 remote_ost_nodsh && skip "remote OST with nodsh"
10104 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10106 # relax strong synchronous semantics for slow backends like ZFS
10107 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
10108 local soc="obdfilter.*.sync_lock_cancel"
10109 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10111 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
10112 if [ -z "$save" ]; then
10113 soc="obdfilter.*.sync_on_lock_cancel"
10114 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10117 if [ "$save" != "never" ]; then
10118 local hosts=$(comma_list $(osts_nodes))
10120 do_nodes $hosts $LCTL set_param $soc=never
10121 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
10125 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
10126 sync; sleep 1; sync
10127 local before=$(date +%s)
10128 cancel_lru_locks osc
10129 local after=$(date +%s)
10130 local diff=$((after - before))
10131 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
10135 run_test 80 "Page eviction is equally fast at high offsets too"
10137 test_81a() { # LU-456
10138 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10139 remote_ost_nodsh && skip "remote OST with nodsh"
10141 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10142 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
10143 do_facet ost1 lctl set_param fail_loc=0x80000228
10145 # write should trigger a retry and success
10146 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10147 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10149 if [ $RC -ne 0 ] ; then
10150 error "write should success, but failed for $RC"
10153 run_test 81a "OST should retry write when get -ENOSPC ==============="
10155 test_81b() { # LU-456
10156 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10157 remote_ost_nodsh && skip "remote OST with nodsh"
10159 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10160 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
10161 do_facet ost1 lctl set_param fail_loc=0x228
10163 # write should retry several times and return -ENOSPC finally
10164 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10165 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10168 if [ $RC -ne $ENOSPC ] ; then
10169 error "dd should fail for -ENOSPC, but succeed."
10172 run_test 81b "OST should return -ENOSPC when retry still fails ======="
10175 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
10177 test_mkdir $DIR/$tdir.cvsroot
10178 chown $RUNAS_ID $DIR/$tdir.cvsroot
10181 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
10184 # some versions of cvs import exit(1) when asked to import links or
10185 # files they can't read. ignore those files.
10186 local toignore=$(find . -type l -printf '-I %f\n' -o \
10187 ! -perm /4 -printf '-I %f\n')
10188 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
10189 $tdir.reposname vtag rtag
10192 test_mkdir $DIR/$tdir.reposname
10193 chown $RUNAS_ID $DIR/$tdir.reposname
10194 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
10196 cd $DIR/$tdir.reposname
10198 $RUNAS cvs add -m 'addmsg' foo99
10200 $RUNAS cvs commit -m 'nomsg' foo99
10201 rm -fr $DIR/$tdir.cvsroot
10203 run_test 99 "cvs strange file/directory operations"
10206 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10207 [[ "$NETTYPE" =~ tcp ]] ||
10208 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
10209 remote_ost_nodsh && skip "remote OST with nodsh"
10210 remote_mds_nodsh && skip "remote MDS with nodsh"
10212 skip "useless for local single node setup"
10214 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
10215 [ "$PROT" != "tcp" ] && continue
10216 RPORT=$(echo $REMOTE | cut -d: -f2)
10217 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
10220 LPORT=`echo $LOCAL | cut -d: -f2`
10221 if [ $LPORT -ge 1024 ]; then
10222 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
10224 error_exit "local: $LPORT > 1024, remote: $RPORT"
10227 [ "$rc" = 0 ] || error_exit "privileged port not found" )
10229 run_test 100 "check local port using privileged port ==========="
10231 function get_named_value()
10235 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
10238 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
10239 awk '/^max_cached_mb/ { print $2 }')
10242 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
10247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10252 local cache_limit=32
10254 $LCTL set_param -n osc.*-osc*.rpc_stats=0
10255 trap cleanup_101a EXIT
10256 $LCTL set_param -n llite.*.read_ahead_stats=0
10257 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
10260 # randomly read 10000 of 64K chunks from file 3x 32MB in size
10262 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
10263 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
10266 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
10267 get_named_value 'read.but.discarded'); do
10268 discard=$(($discard + $s))
10272 $LCTL get_param osc.*-osc*.rpc_stats
10273 $LCTL get_param llite.*.read_ahead_stats
10275 # Discard is generally zero, but sometimes a few random reads line up
10276 # and trigger larger readahead, which is wasted & leads to discards.
10277 if [[ $(($discard)) -gt $nreads ]]; then
10278 error "too many ($discard) discarded pages"
10280 rm -f $DIR/$tfile || true
10282 run_test 101a "check read-ahead for random reads"
10284 setup_test101bc() {
10285 test_mkdir $DIR/$tdir
10287 local FILE_LENGTH=$2
10290 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
10292 local list=$(comma_list $(osts_nodes))
10293 set_osd_param $list '' read_cache_enable 0
10294 set_osd_param $list '' writethrough_cache_enable 0
10296 trap cleanup_test101bc EXIT
10297 # prepare the read-ahead file
10298 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
10300 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
10301 count=$FILE_SIZE_MB 2> /dev/null
10305 cleanup_test101bc() {
10310 local list=$(comma_list $(osts_nodes))
10311 set_osd_param $list '' read_cache_enable 1
10312 set_osd_param $list '' writethrough_cache_enable 1
10316 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
10321 local STRIPE_SIZE=$2
10322 local FILE_LENGTH=$3
10323 local RA_INC=1048576
10324 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
10325 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
10326 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
10327 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
10328 get_named_value 'read.but.discarded' | calc_total)
10329 if [[ $DISCARD -gt $discard_limit ]]; then
10330 $LCTL get_param llite.*.read_ahead_stats
10331 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
10333 echo "Read-ahead success for size ${READ_SIZE}"
10338 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10339 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10341 local STRIPE_SIZE=1048576
10342 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
10344 if [ $SLOW == "yes" ]; then
10345 local FILE_LENGTH=$((STRIDE_SIZE * 64))
10347 local FILE_LENGTH=$((STRIDE_SIZE * 8))
10350 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
10352 # prepare the read-ahead file
10353 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10354 cancel_lru_locks osc
10355 for BIDX in 2 4 8 16 32 64 128 256
10357 local BSIZE=$((BIDX*4096))
10358 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
10359 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
10360 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
10361 $LCTL set_param -n llite.*.read_ahead_stats=0
10362 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
10363 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
10364 cancel_lru_locks osc
10365 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
10370 run_test 101b "check stride-io mode read-ahead ================="
10373 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10375 local STRIPE_SIZE=1048576
10376 local FILE_LENGTH=$((STRIPE_SIZE*100))
10379 local osc_rpc_stats
10381 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10383 cancel_lru_locks osc
10384 $LCTL set_param osc.*.rpc_stats=0
10385 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
10386 $LCTL get_param osc.*.rpc_stats
10387 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
10388 local stats=$($LCTL get_param -n $osc_rpc_stats)
10389 local lines=$(echo "$stats" | awk 'END {print NR;}')
10392 if [ $lines -le 20 ]; then
10393 echo "continue debug"
10396 for size in 1 2 4 8; do
10397 local rpc=$(echo "$stats" |
10398 awk '($1 == "'$size':") {print $2; exit; }')
10399 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
10400 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
10402 echo "$osc_rpc_stats check passed!"
10407 run_test 101c "check stripe_size aligned read-ahead"
10410 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10412 local file=$DIR/$tfile
10413 local sz_MB=${FILESIZE_101d:-80}
10414 local ra_MB=${READAHEAD_MB:-40}
10416 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
10417 [ $free_MB -lt $sz_MB ] &&
10418 skip "Need free space ${sz_MB}M, have ${free_MB}M"
10420 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
10421 $LFS setstripe -c -1 $file || error "setstripe failed"
10423 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
10424 echo Cancel LRU locks on lustre client to flush the client cache
10425 cancel_lru_locks osc
10427 echo Disable read-ahead
10428 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10429 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10430 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
10431 $LCTL get_param -n llite.*.max_read_ahead_mb
10433 echo "Reading the test file $file with read-ahead disabled"
10434 local sz_KB=$((sz_MB * 1024 / 4))
10435 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
10436 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
10437 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10438 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10440 echo "Cancel LRU locks on lustre client to flush the client cache"
10441 cancel_lru_locks osc
10442 echo Enable read-ahead with ${ra_MB}MB
10443 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
10445 echo "Reading the test file $file with read-ahead enabled"
10446 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10447 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10449 echo "read-ahead disabled time read $raOFF"
10450 echo "read-ahead enabled time read $raON"
10453 wait_delete_completed
10455 # use awk for this check instead of bash because it handles decimals
10456 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
10457 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
10459 run_test 101d "file read with and without read-ahead enabled"
10462 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10464 local file=$DIR/$tfile
10465 local size_KB=500 #KB
10469 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
10470 local need_KB=$((count * size_KB))
10471 [[ $free_KB -le $need_KB ]] &&
10472 skip_env "Need free space $need_KB, have $free_KB"
10474 echo "Creating $count ${size_KB}K test files"
10475 for ((i = 0; i < $count; i++)); do
10476 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
10479 echo "Cancel LRU locks on lustre client to flush the client cache"
10480 cancel_lru_locks $OSC
10482 echo "Reset readahead stats"
10483 $LCTL set_param -n llite.*.read_ahead_stats=0
10485 for ((i = 0; i < $count; i++)); do
10486 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
10489 $LCTL get_param llite.*.max_cached_mb
10490 $LCTL get_param llite.*.read_ahead_stats
10491 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10492 get_named_value 'misses' | calc_total)
10494 for ((i = 0; i < $count; i++)); do
10495 rm -rf $file.$i 2>/dev/null
10498 #10000 means 20% reads are missing in readahead
10499 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
10501 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
10504 which iozone || skip_env "no iozone installed"
10506 local old_debug=$($LCTL get_param debug)
10507 old_debug=${old_debug#*=}
10508 $LCTL set_param debug="reada mmap"
10510 # create a test file
10511 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
10513 echo Cancel LRU locks on lustre client to flush the client cache
10514 cancel_lru_locks osc
10516 echo Reset readahead stats
10517 $LCTL set_param -n llite.*.read_ahead_stats=0
10519 echo mmap read the file with small block size
10520 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
10523 echo checking missing pages
10524 $LCTL get_param llite.*.read_ahead_stats
10525 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10526 get_named_value 'misses' | calc_total)
10528 $LCTL set_param debug="$old_debug"
10529 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
10532 run_test 101f "check mmap read performance"
10534 test_101g_brw_size_test() {
10536 local pages=$((mb * 1048576 / PAGE_SIZE))
10537 local file=$DIR/$tfile
10539 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
10540 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
10541 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
10542 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
10546 stack_trap "rm -f $file" EXIT
10547 $LCTL set_param -n osc.*.rpc_stats=0
10549 # 10 RPCs should be enough for the test
10551 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
10552 { error "dd write ${mb} MB blocks failed"; return 3; }
10553 cancel_lru_locks osc
10554 dd of=/dev/null if=$file bs=${mb}M count=$count ||
10555 { error "dd write ${mb} MB blocks failed"; return 4; }
10557 # calculate number of full-sized read and write RPCs
10558 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
10559 sed -n '/pages per rpc/,/^$/p' |
10560 awk '/'$pages':/ { reads += $2; writes += $6 }; \
10561 END { print reads,writes }'))
10562 # allow one extra full-sized read RPC for async readahead
10563 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
10564 { error "${rpcs[0]} != $count read RPCs"; return 5; }
10565 [[ ${rpcs[1]} == $count ]] ||
10566 { error "${rpcs[1]} != $count write RPCs"; return 6; }
10570 remote_ost_nodsh && skip "remote OST with nodsh"
10573 local osts=$(get_facets OST)
10574 local list=$(comma_list $(osts_nodes))
10575 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10576 local brw_size="obdfilter.*.brw_size"
10578 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10580 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
10582 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
10583 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
10584 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
10585 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
10586 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
10587 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
10589 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
10592 if [[ $orig_mb -lt 16 ]]; then
10593 save_lustre_params $osts "$brw_size" > $p
10594 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
10595 error "set 16MB RPC size failed"
10597 echo "remount client to enable new RPC size"
10598 remount_client $MOUNT || error "remount_client failed"
10601 test_101g_brw_size_test 16 || error "16MB RPC test failed"
10602 # should be able to set brw_size=12, but no rpc_stats for that
10603 test_101g_brw_size_test 8 || error "8MB RPC test failed"
10606 test_101g_brw_size_test 4 || error "4MB RPC test failed"
10608 if [[ $orig_mb -lt 16 ]]; then
10609 restore_lustre_params < $p
10610 remount_client $MOUNT || error "remount_client restore failed"
10613 rm -f $p $DIR/$tfile
10615 run_test 101g "Big bulk(4/16 MiB) readahead"
10618 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10620 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
10621 error "dd 70M file failed"
10622 echo Cancel LRU locks on lustre client to flush the client cache
10623 cancel_lru_locks osc
10625 echo "Reset readahead stats"
10626 $LCTL set_param -n llite.*.read_ahead_stats 0
10628 echo "Read 10M of data but cross 64M bundary"
10629 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
10630 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10631 get_named_value 'misses' | calc_total)
10632 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
10633 rm -f $p $DIR/$tfile
10635 run_test 101h "Readahead should cover current read window"
10638 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
10639 error "dd 10M file failed"
10641 local max_per_file_mb=$($LCTL get_param -n \
10642 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
10643 cancel_lru_locks osc
10644 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
10645 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
10646 error "set max_read_ahead_per_file_mb to 1 failed"
10648 echo "Reset readahead stats"
10649 $LCTL set_param llite.*.read_ahead_stats=0
10651 dd if=$DIR/$tfile of=/dev/null bs=2M
10653 $LCTL get_param llite.*.read_ahead_stats
10654 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10655 awk '/misses/ { print $2 }')
10656 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
10659 run_test 101i "allow current readahead to exceed reservation"
10662 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
10663 error "setstripe $DIR/$tfile failed"
10664 local file_size=$((1048576 * 16))
10665 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10666 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
10668 echo Disable read-ahead
10669 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10671 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
10672 for blk in $PAGE_SIZE 1048576 $file_size; do
10673 cancel_lru_locks osc
10674 echo "Reset readahead stats"
10675 $LCTL set_param -n llite.*.read_ahead_stats=0
10676 local count=$(($file_size / $blk))
10677 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
10678 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10679 get_named_value 'failed.to.fast.read' | calc_total)
10680 $LCTL get_param -n llite.*.read_ahead_stats
10681 [ $miss -eq $count ] || error "expected $count got $miss"
10684 rm -f $p $DIR/$tfile
10686 run_test 101j "A complete read block should be submitted when no RA"
10689 test_mkdir $DIR/$tdir
10690 chown $RUNAS_ID $DIR/$tdir
10693 STRIPE_COUNT=$OSTCOUNT
10694 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
10696 trap cleanup_test102 EXIT
10698 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
10700 for num in 1 2 3 4; do
10701 for count in $(seq 1 $STRIPE_COUNT); do
10702 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
10703 local size=`expr $STRIPE_SIZE \* $num`
10704 local file=file"$num-$idx-$count"
10705 $1 $LFS setstripe -S $size -i $idx -c $count $file
10711 $1 tar cf $TMP/f102.tar $tdir --xattrs
10714 cleanup_test102() {
10716 rm -f $TMP/f102.tar
10717 rm -rf $DIR/d0.sanity/d102
10721 [ "$UID" != 0 ] && skip "must run as root"
10722 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
10723 skip_env "must have user_xattr"
10725 [ -z "$(which setfattr 2>/dev/null)" ] &&
10726 skip_env "could not find setfattr"
10728 local testfile=$DIR/$tfile
10731 echo "set/get xattr..."
10732 setfattr -n trusted.name1 -v value1 $testfile ||
10733 error "setfattr -n trusted.name1=value1 $testfile failed"
10734 getfattr -n trusted.name1 $testfile 2> /dev/null |
10735 grep "trusted.name1=.value1" ||
10736 error "$testfile missing trusted.name1=value1"
10738 setfattr -n user.author1 -v author1 $testfile ||
10739 error "setfattr -n user.author1=author1 $testfile failed"
10740 getfattr -n user.author1 $testfile 2> /dev/null |
10741 grep "user.author1=.author1" ||
10742 error "$testfile missing trusted.author1=author1"
10744 echo "listxattr..."
10745 setfattr -n trusted.name2 -v value2 $testfile ||
10746 error "$testfile unable to set trusted.name2"
10747 setfattr -n trusted.name3 -v value3 $testfile ||
10748 error "$testfile unable to set trusted.name3"
10749 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
10750 grep "trusted.name" | wc -l) -eq 3 ] ||
10751 error "$testfile missing 3 trusted.name xattrs"
10753 setfattr -n user.author2 -v author2 $testfile ||
10754 error "$testfile unable to set user.author2"
10755 setfattr -n user.author3 -v author3 $testfile ||
10756 error "$testfile unable to set user.author3"
10757 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
10758 grep "user.author" | wc -l) -eq 3 ] ||
10759 error "$testfile missing 3 user.author xattrs"
10761 echo "remove xattr..."
10762 setfattr -x trusted.name1 $testfile ||
10763 error "$testfile error deleting trusted.name1"
10764 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
10765 error "$testfile did not delete trusted.name1 xattr"
10767 setfattr -x user.author1 $testfile ||
10768 error "$testfile error deleting user.author1"
10769 echo "set lustre special xattr ..."
10770 $LFS setstripe -c1 $testfile
10771 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
10772 awk -F "=" '/trusted.lov/ { print $2 }' )
10773 setfattr -n "trusted.lov" -v $lovea $testfile ||
10774 error "$testfile doesn't ignore setting trusted.lov again"
10775 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
10776 error "$testfile allow setting invalid trusted.lov"
10779 run_test 102a "user xattr test =================================="
10781 check_102b_layout() {
10783 local testfile=$DIR/$tfile
10785 echo "test layout '$layout'"
10786 $LFS setstripe $layout $testfile || error "setstripe failed"
10787 $LFS getstripe -y $testfile
10789 echo "get/set/list trusted.lov xattr ..." # b=10930
10790 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
10791 [[ "$value" =~ "trusted.lov" ]] ||
10792 error "can't get trusted.lov from $testfile"
10793 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
10794 error "getstripe failed"
10796 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
10798 value=$(cut -d= -f2 <<<$value)
10799 # LU-13168: truncated xattr should fail if short lov_user_md header
10800 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
10801 lens="${#value}" || lens="$(seq 4 2 ${#value})"
10802 for len in $lens; do
10803 echo "setfattr $len $testfile.2"
10804 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
10805 [ $len -lt 66 ] && error "short xattr len=$len worked"
10807 local stripe_size=$($LFS getstripe -S $testfile.2)
10808 local stripe_count=$($LFS getstripe -c $testfile.2)
10809 [[ $stripe_size -eq 65536 ]] ||
10810 error "stripe size $stripe_size != 65536"
10811 [[ $stripe_count -eq $stripe_count_orig ]] ||
10812 error "stripe count $stripe_count != $stripe_count_orig"
10813 rm $testfile $testfile.2
10817 [ -z "$(which setfattr 2>/dev/null)" ] &&
10818 skip_env "could not find setfattr"
10819 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10821 # check plain layout
10822 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
10824 # and also check composite layout
10825 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
10828 run_test 102b "getfattr/setfattr for trusted.lov EAs"
10831 [ -z "$(which setfattr 2>/dev/null)" ] &&
10832 skip_env "could not find setfattr"
10833 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10835 # b10930: get/set/list lustre.lov xattr
10836 echo "get/set/list lustre.lov xattr ..."
10837 test_mkdir $DIR/$tdir
10838 chown $RUNAS_ID $DIR/$tdir
10839 local testfile=$DIR/$tdir/$tfile
10840 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
10841 error "setstripe failed"
10842 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
10843 error "getstripe failed"
10844 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
10845 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
10847 local testfile2=${testfile}2
10848 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
10849 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
10851 $RUNAS $MCREATE $testfile2
10852 $RUNAS setfattr -n lustre.lov -v $value $testfile2
10853 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
10854 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
10855 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
10856 [ $stripe_count -eq $STRIPECOUNT ] ||
10857 error "stripe count $stripe_count != $STRIPECOUNT"
10859 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
10861 compare_stripe_info1() {
10862 local stripe_index_all_zero=true
10864 for num in 1 2 3 4; do
10865 for count in $(seq 1 $STRIPE_COUNT); do
10866 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
10867 local size=$((STRIPE_SIZE * num))
10868 local file=file"$num-$offset-$count"
10869 stripe_size=$($LFS getstripe -S $PWD/$file)
10870 [[ $stripe_size -ne $size ]] &&
10871 error "$file: size $stripe_size != $size"
10872 stripe_count=$($LFS getstripe -c $PWD/$file)
10873 # allow fewer stripes to be created, ORI-601
10874 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
10875 error "$file: count $stripe_count != $count"
10876 stripe_index=$($LFS getstripe -i $PWD/$file)
10877 [[ $stripe_index -ne 0 ]] &&
10878 stripe_index_all_zero=false
10882 $stripe_index_all_zero &&
10883 error "all files are being extracted starting from OST index 0"
10887 have_xattrs_include() {
10888 tar --help | grep -q xattrs-include &&
10889 echo --xattrs-include="lustre.*"
10893 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10894 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10896 XINC=$(have_xattrs_include)
10898 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
10899 cd $DIR/$tdir/$tdir
10900 compare_stripe_info1
10902 run_test 102d "tar restore stripe info from tarfile,not keep osts"
10905 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10906 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10908 XINC=$(have_xattrs_include)
10910 test_mkdir $DIR/$tdir.restore
10912 tar cf - --xattrs $tdir | tar xf - \
10913 -C $DIR/$tdir.restore --xattrs $XINC
10914 cd $DIR/$tdir.restore/$tdir
10915 compare_stripe_info1
10917 run_test 102f "tar copy files, not keep osts"
10920 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
10921 skip "must have user_xattr"
10922 [ -z "$(which setfattr 2>/dev/null)" ] &&
10923 skip_env "could not find setfattr"
10924 [ -z "$(which getfattr 2>/dev/null)" ] &&
10925 skip_env "could not find getfattr"
10927 local xsize=${1:-1024} # in bytes
10928 local file=$DIR/$tfile
10929 local value="$(generate_string $xsize)"
10930 local xbig=trusted.big
10934 log "save $xbig on $file"
10935 if [ -z "$toobig" ]
10937 setfattr -n $xbig -v $value $file ||
10938 error "saving $xbig on $file failed"
10940 setfattr -n $xbig -v $value $file &&
10941 error "saving $xbig on $file succeeded"
10945 local orig=$(get_xattr_value $xbig $file)
10946 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
10948 local xsml=trusted.sml
10949 log "save $xsml on $file"
10950 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
10952 local new=$(get_xattr_value $xbig $file)
10953 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
10955 log "grow $xsml on $file"
10956 setfattr -n $xsml -v "$value" $file ||
10957 error "growing $xsml on $file failed"
10959 new=$(get_xattr_value $xbig $file)
10960 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
10961 log "$xbig still valid after growing $xsml"
10966 test_102h() { # bug 15777
10969 run_test 102h "grow xattr from inside inode to external block"
10972 large_xattr_enabled || skip_env "ea_inode feature disabled"
10974 echo "setting xattr of max xattr size: $(max_xattr_size)"
10975 grow_xattr $(max_xattr_size)
10977 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
10978 echo "This should fail:"
10979 grow_xattr $(($(max_xattr_size) + 10)) 1
10981 run_test 102ha "grow xattr from inside inode to external inode"
10983 test_102i() { # bug 17038
10984 [ -z "$(which getfattr 2>/dev/null)" ] &&
10985 skip "could not find getfattr"
10988 ln -s $DIR/$tfile $DIR/${tfile}link
10989 getfattr -n trusted.lov $DIR/$tfile ||
10990 error "lgetxattr on $DIR/$tfile failed"
10991 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
10992 grep -i "no such attr" ||
10993 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
10994 rm -f $DIR/$tfile $DIR/${tfile}link
10996 run_test 102i "lgetxattr test on symbolic link ============"
10999 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11000 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11002 XINC=$(have_xattrs_include)
11003 setup_test102 "$RUNAS"
11004 chown $RUNAS_ID $DIR/$tdir
11005 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11006 cd $DIR/$tdir/$tdir
11007 compare_stripe_info1 "$RUNAS"
11009 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
11012 [ -z "$(which setfattr 2>/dev/null)" ] &&
11013 skip "could not find setfattr"
11016 # b22187 just check that does not crash for regular file.
11017 setfattr -n trusted.lov $DIR/$tfile
11018 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
11019 local test_kdir=$DIR/$tdir
11020 test_mkdir $test_kdir
11021 local default_size=$($LFS getstripe -S $test_kdir)
11022 local default_count=$($LFS getstripe -c $test_kdir)
11023 local default_offset=$($LFS getstripe -i $test_kdir)
11024 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
11025 error 'dir setstripe failed'
11026 setfattr -n trusted.lov $test_kdir
11027 local stripe_size=$($LFS getstripe -S $test_kdir)
11028 local stripe_count=$($LFS getstripe -c $test_kdir)
11029 local stripe_offset=$($LFS getstripe -i $test_kdir)
11030 [ $stripe_size -eq $default_size ] ||
11031 error "stripe size $stripe_size != $default_size"
11032 [ $stripe_count -eq $default_count ] ||
11033 error "stripe count $stripe_count != $default_count"
11034 [ $stripe_offset -eq $default_offset ] ||
11035 error "stripe offset $stripe_offset != $default_offset"
11036 rm -rf $DIR/$tfile $test_kdir
11038 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
11041 [ -z "$(which getfattr 2>/dev/null)" ] &&
11042 skip "could not find getfattr"
11044 # LU-532 trusted. xattr is invisible to non-root
11045 local testfile=$DIR/$tfile
11049 echo "listxattr as user..."
11050 chown $RUNAS_ID $testfile
11051 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
11052 grep -q "trusted" &&
11053 error "$testfile trusted xattrs are user visible"
11057 run_test 102l "listxattr size test =================================="
11059 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
11060 local path=$DIR/$tfile
11063 listxattr_size_check $path || error "listattr_size_check $path failed"
11065 run_test 102m "Ensure listxattr fails on small bufffer ========"
11069 getxattr() { # getxattr path name
11070 # Return the base64 encoding of the value of xattr name on path.
11074 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
11076 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11078 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11080 getfattr --absolute-names --encoding=base64 --name=$name $path |
11081 awk -F= -v name=$name '$1 == name {
11082 print substr($0, index($0, "=") + 1);
11086 test_102n() { # LU-4101 mdt: protect internal xattrs
11087 [ -z "$(which setfattr 2>/dev/null)" ] &&
11088 skip "could not find setfattr"
11089 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
11091 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
11094 local file0=$DIR/$tfile.0
11095 local file1=$DIR/$tfile.1
11096 local xattr0=$TMP/$tfile.0
11097 local xattr1=$TMP/$tfile.1
11098 local namelist="lov lma lmv link fid version som hsm"
11102 rm -rf $file0 $file1 $xattr0 $xattr1
11103 touch $file0 $file1
11105 # Get 'before' xattrs of $file1.
11106 getfattr --absolute-names --dump --match=- $file1 > $xattr0
11108 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
11109 namelist+=" lfsck_namespace"
11110 for name in $namelist; do
11111 # Try to copy xattr from $file0 to $file1.
11112 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11114 setfattr --name=trusted.$name --value="$value" $file1 ||
11115 error "setxattr 'trusted.$name' failed"
11117 # Try to set a garbage xattr.
11118 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11120 if [[ x$name == "xlov" ]]; then
11121 setfattr --name=trusted.lov --value="$value" $file1 &&
11122 error "setxattr invalid 'trusted.lov' success"
11124 setfattr --name=trusted.$name --value="$value" $file1 ||
11125 error "setxattr invalid 'trusted.$name' failed"
11128 # Try to remove the xattr from $file1. We don't care if this
11129 # appears to succeed or fail, we just don't want there to be
11130 # any changes or crashes.
11131 setfattr --remove=$trusted.$name $file1 2> /dev/null
11134 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
11137 # Try to copy xattr from $file0 to $file1.
11138 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11140 setfattr --name=trusted.$name --value="$value" $file1 ||
11141 error "setxattr 'trusted.$name' failed"
11143 # Try to set a garbage xattr.
11144 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11146 setfattr --name=trusted.$name --value="$value" $file1 ||
11147 error "setxattr 'trusted.$name' failed"
11149 # Try to remove the xattr from $file1. We don't care if this
11150 # appears to succeed or fail, we just don't want there to be
11151 # any changes or crashes.
11152 setfattr --remove=$trusted.$name $file1 2> /dev/null
11155 # Get 'after' xattrs of file1.
11156 getfattr --absolute-names --dump --match=- $file1 > $xattr1
11158 if ! diff $xattr0 $xattr1; then
11159 error "before and after xattrs of '$file1' differ"
11162 rm -rf $file0 $file1 $xattr0 $xattr1
11166 run_test 102n "silently ignore setxattr on internal trusted xattrs"
11168 test_102p() { # LU-4703 setxattr did not check ownership
11169 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
11170 skip "MDS needs to be at least 2.5.56"
11172 local testfile=$DIR/$tfile
11176 echo "setfacl as user..."
11177 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
11178 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
11180 echo "setfattr as user..."
11181 setfacl -m "u:$RUNAS_ID:---" $testfile
11182 $RUNAS setfattr -x system.posix_acl_access $testfile
11183 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
11185 run_test 102p "check setxattr(2) correctly fails without permission"
11188 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
11189 skip "MDS needs to be at least 2.6.92"
11191 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
11193 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
11196 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
11197 skip "MDS needs to be at least 2.6.93"
11199 touch $DIR/$tfile || error "touch"
11200 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
11201 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
11202 rm $DIR/$tfile || error "rm"
11205 mkdir -p $DIR/$tdir || error "mkdir"
11206 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11207 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11208 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11209 error "$testfile error deleting user.author1"
11210 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11211 grep "user.$(basename $tdir)" &&
11212 error "$tdir did not delete user.$(basename $tdir)"
11213 rmdir $DIR/$tdir || error "rmdir"
11216 test_mkdir $DIR/$tdir
11217 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11218 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11219 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11220 error "$testfile error deleting user.author1"
11221 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11222 grep "user.$(basename $tdir)" &&
11223 error "$tdir did not delete user.$(basename $tdir)"
11224 rmdir $DIR/$tdir || error "rm striped dir"
11226 run_test 102r "set EAs with empty values"
11229 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11230 skip "MDS needs to be at least 2.11.52"
11232 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11234 save_lustre_params client "llite.*.xattr_cache" > $save
11236 for cache in 0 1; do
11237 lctl set_param llite.*.xattr_cache=$cache
11240 touch $DIR/$tfile || error "touch"
11241 for prefix in lustre security system trusted user; do
11242 # Note getxattr() may fail with 'Operation not
11243 # supported' or 'No such attribute' depending
11244 # on prefix and cache.
11245 getfattr -n $prefix.n102s $DIR/$tfile &&
11246 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
11250 restore_lustre_params < $save
11252 run_test 102s "getting nonexistent xattrs should fail"
11255 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11256 skip "MDS needs to be at least 2.11.52"
11258 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11260 save_lustre_params client "llite.*.xattr_cache" > $save
11262 for cache in 0 1; do
11263 lctl set_param llite.*.xattr_cache=$cache
11265 for buf_size in 0 256; do
11267 touch $DIR/$tfile || error "touch"
11268 setfattr -n user.multiop $DIR/$tfile
11269 $MULTIOP $DIR/$tfile oa$buf_size ||
11270 error "cannot get zero length xattr value (buf_size = $buf_size)"
11274 restore_lustre_params < $save
11276 run_test 102t "zero length xattr values handled correctly"
11280 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
11285 [ "$UID" != 0 ] && skip "must run as root"
11286 $GSS && skip_env "could not run under gss"
11287 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
11288 skip_env "must have acl enabled"
11289 [ -z "$(which setfacl 2>/dev/null)" ] &&
11290 skip_env "could not find setfacl"
11291 remote_mds_nodsh && skip "remote MDS with nodsh"
11293 gpasswd -a daemon bin # LU-5641
11294 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
11296 declare -a identity_old
11298 for num in $(seq $MDSCOUNT); do
11299 switch_identity $num true || identity_old[$num]=$?
11302 SAVE_UMASK=$(umask)
11304 mkdir -p $DIR/$tdir
11307 echo "performing cp ..."
11308 run_acl_subtest cp || error "run_acl_subtest cp failed"
11309 echo "performing getfacl-noacl..."
11310 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
11311 echo "performing misc..."
11312 run_acl_subtest misc || error "misc test failed"
11313 echo "performing permissions..."
11314 run_acl_subtest permissions || error "permissions failed"
11315 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
11316 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
11317 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
11318 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
11320 echo "performing permissions xattr..."
11321 run_acl_subtest permissions_xattr ||
11322 error "permissions_xattr failed"
11324 echo "performing setfacl..."
11325 run_acl_subtest setfacl || error "setfacl test failed"
11327 # inheritance test got from HP
11328 echo "performing inheritance..."
11329 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
11330 chmod +x make-tree || error "chmod +x failed"
11331 run_acl_subtest inheritance || error "inheritance test failed"
11334 echo "LU-974 ignore umask when acl is enabled..."
11335 run_acl_subtest 974 || error "LU-974 umask test failed"
11336 if [ $MDSCOUNT -ge 2 ]; then
11337 run_acl_subtest 974_remote ||
11338 error "LU-974 umask test failed under remote dir"
11341 echo "LU-2561 newly created file is same size as directory..."
11342 if [ "$mds1_FSTYPE" != "zfs" ]; then
11343 run_acl_subtest 2561 || error "LU-2561 test failed"
11345 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
11348 run_acl_subtest 4924 || error "LU-4924 test failed"
11353 for num in $(seq $MDSCOUNT); do
11354 if [ "${identity_old[$num]}" = 1 ]; then
11355 switch_identity $num false || identity_old[$num]=$?
11359 run_test 103a "acl test"
11365 for U in {0..511}; do
11367 local O=$(printf "%04o" $U)
11369 umask $(printf "%04o" $((511 ^ $O)))
11370 $LFS setstripe -c 1 $DIR/$tfile.s$O
11371 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
11373 (( $S == ($O & 0666) )) ||
11374 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
11376 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
11377 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
11378 (( $S == ($O & 0666) )) ||
11379 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
11381 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
11382 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
11383 (( $S == ($O & 0666) )) ||
11384 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
11385 rm -f $DIR/$tfile.[smp]$0
11389 # limit the concurrently running threads to 64. LU-11878
11390 local idx=$((U % 64))
11391 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
11396 run_test 103b "umask lfs setstripe"
11399 mkdir -p $DIR/$tdir
11400 cp -rp $DIR/$tdir $DIR/$tdir.bak
11402 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
11403 error "$DIR/$tdir shouldn't contain default ACL"
11404 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
11405 error "$DIR/$tdir.bak shouldn't contain default ACL"
11408 run_test 103c "'cp -rp' won't set empty acl"
11413 local saved_debug=$($LCTL get_param -n debug)
11415 (( $MDS1_VERSION >= $(version_code 2.14.0) )) ||
11416 skip "MDS needs to be at least 2.14.0"
11418 large_xattr_enabled || skip_env "ea_inode feature disabled"
11420 mkdir -p $DIR/$tdir
11421 # add big LOV EA to cause reply buffer overflow earlier
11422 $LFS setstripe -C 1000 $DIR/$tdir
11423 lctl set_param mdc.*-mdc*.stats=clear
11425 $LCTL set_param debug=0
11426 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
11427 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
11429 # add a large number of default ACLs (expect 8000+ for 2.13+)
11430 for U in {2..7000}; do
11431 setfacl -d -m user:$U:rwx $DIR/$tdir ||
11432 error "Able to add just $U default ACLs"
11434 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
11435 echo "$numacl default ACLs created"
11437 stat $DIR/$tdir || error "Cannot stat directory"
11438 # check file creation
11439 touch $DIR/$tdir/$tfile ||
11440 error "failed to create $tfile with $numacl default ACLs"
11441 stat $DIR/$tdir/$tfile || error "Cannot stat file"
11442 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11443 echo "$fileacl ACLs were inherited"
11444 (( $fileacl == $numacl )) ||
11445 error "Not all default ACLs were inherited: $numacl != $fileacl"
11446 # check that new ACLs creation adds new ACLs to inherited ACLs
11447 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
11448 error "Cannot set new ACL"
11449 numacl=$((numacl + 1))
11450 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11451 (( $fileacl == $numacl )) ||
11452 error "failed to add new ACL: $fileacl != $numacl as expected"
11453 # adds more ACLs to a file to reach their maximum at 8000+
11455 for U in {20000..25000}; do
11456 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
11457 numacl=$((numacl + 1))
11459 echo "Added $numacl more ACLs to the file"
11460 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11461 echo "Total $fileacl ACLs in file"
11462 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
11463 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
11464 rmdir $DIR/$tdir || error "Cannot remove directory"
11466 run_test 103e "inheritance of big amount of default ACLs"
11469 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
11470 skip "MDS needs to be at least 2.14.51"
11472 large_xattr_enabled || skip_env "ea_inode feature disabled"
11474 # enable changelog to consume more internal MDD buffers
11477 mkdir -p $DIR/$tdir
11479 $LFS setstripe -C 1000 $DIR/$tdir
11480 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
11481 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
11482 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
11483 rmdir $DIR/$tdir || error "Cannot remove directory"
11485 run_test 103f "changelog doesn't interfere with default ACLs buffers"
11488 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11491 lfs df || error "lfs df failed"
11492 lfs df -ih || error "lfs df -ih failed"
11493 lfs df -h $DIR || error "lfs df -h $DIR failed"
11494 lfs df -i $DIR || error "lfs df -i $DIR failed"
11495 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
11496 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
11498 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
11499 lctl --device %$OSC deactivate
11500 lfs df || error "lfs df with deactivated OSC failed"
11501 lctl --device %$OSC activate
11502 # wait the osc back to normal
11503 wait_osc_import_ready client ost
11505 lfs df || error "lfs df with reactivated OSC failed"
11508 run_test 104a "lfs df [-ih] [path] test ========================="
11511 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11512 [ $RUNAS_ID -eq $UID ] &&
11513 skip_env "RUNAS_ID = UID = $UID -- skipping"
11515 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
11516 grep "Permission denied" | wc -l)))
11517 if [ $denied_cnt -ne 0 ]; then
11518 error "lfs check servers test failed"
11521 run_test 104b "$RUNAS lfs check servers test ===================="
11524 # Verify $1 is within range of $2.
11525 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
11526 # $1 is <= 2% of $2. Else Fail.
11529 # Strip all units (M, G, T)
11530 actual=$(echo $1 | tr -d A-Z)
11531 expect=$(echo $2 | tr -d A-Z)
11533 expect_lo=$(($expect * 98 / 100)) # 2% below
11534 expect_hi=$(($expect * 102 / 100)) # 2% above
11536 # permit 2% drift above and below
11537 (( $actual >= $expect_lo && $actual <= $expect_hi ))
11541 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11542 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
11544 local ost_param="osd-zfs.$FSNAME-OST0000."
11545 local mdt_param="osd-zfs.$FSNAME-MDT0000."
11546 local ofacets=$(get_facets OST)
11547 local mfacets=$(get_facets MDS)
11548 local saved_ost_blocks=
11549 local saved_mdt_blocks=
11551 echo "Before recordsize change"
11552 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
11553 df=($(df -h | grep "/mnt/lustre"$))
11556 echo "lfs output : ${lfs_df[*]}"
11557 echo "df output : ${df[*]}"
11559 for facet in ${ofacets//,/ }; do
11560 if [ -z $saved_ost_blocks ]; then
11561 saved_ost_blocks=$(do_facet $facet \
11562 lctl get_param -n $ost_param.blocksize)
11563 echo "OST Blocksize: $saved_ost_blocks"
11565 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11566 do_facet $facet zfs set recordsize=32768 $ost
11569 # BS too small. Sufficient for functional testing.
11570 for facet in ${mfacets//,/ }; do
11571 if [ -z $saved_mdt_blocks ]; then
11572 saved_mdt_blocks=$(do_facet $facet \
11573 lctl get_param -n $mdt_param.blocksize)
11574 echo "MDT Blocksize: $saved_mdt_blocks"
11576 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11577 do_facet $facet zfs set recordsize=32768 $mdt
11580 # Give new values chance to reflect change
11583 echo "After recordsize change"
11584 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
11585 df_after=($(df -h | grep "/mnt/lustre"$))
11588 echo "lfs output : ${lfs_df_after[*]}"
11589 echo "df output : ${df_after[*]}"
11592 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
11593 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
11594 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
11595 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
11596 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
11597 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
11600 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
11601 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
11602 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
11603 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
11604 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
11605 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
11607 # Restore MDT recordize back to original
11608 for facet in ${mfacets//,/ }; do
11609 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11610 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
11613 # Restore OST recordize back to original
11614 for facet in ${ofacets//,/ }; do
11615 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11616 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
11621 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
11624 # doesn't work on 2.4 kernels
11626 if $(flock_is_enabled); then
11627 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
11629 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
11633 run_test 105a "flock when mounted without -o flock test ========"
11637 if $(flock_is_enabled); then
11638 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
11640 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
11644 run_test 105b "fcntl when mounted without -o flock test ========"
11648 if $(flock_is_enabled); then
11649 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
11651 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
11655 run_test 105c "lockf when mounted without -o flock test"
11657 test_105d() { # bug 15924
11658 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11660 test_mkdir $DIR/$tdir
11661 flock_is_enabled || skip_env "mount w/o flock enabled"
11662 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
11663 $LCTL set_param fail_loc=0x80000315
11664 flocks_test 2 $DIR/$tdir
11666 run_test 105d "flock race (should not freeze) ========"
11668 test_105e() { # bug 22660 && 22040
11669 flock_is_enabled || skip_env "mount w/o flock enabled"
11672 flocks_test 3 $DIR/$tfile
11674 run_test 105e "Two conflicting flocks from same process"
11676 test_106() { #bug 10921
11677 test_mkdir $DIR/$tdir
11678 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
11679 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
11681 run_test 106 "attempt exec of dir followed by chown of that dir"
11684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11692 local save_pattern=$(sysctl -n kernel.core_pattern)
11693 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
11694 sysctl -w kernel.core_pattern=$file
11695 sysctl -w kernel.core_uses_pid=0
11697 ulimit -c unlimited
11703 kill -s 11 $SLEEPPID
11705 if [ -e $file ]; then
11706 size=`stat -c%s $file`
11707 [ $size -eq 0 ] && error "Fail to create core file $file"
11709 error "Fail to create core file $file"
11712 sysctl -w kernel.core_pattern=$save_pattern
11713 sysctl -w kernel.core_uses_pid=$save_uses_pid
11716 run_test 107 "Coredump on SIG"
11719 test_mkdir $DIR/$tdir
11720 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
11721 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
11722 error "mkdir with 256 char should fail, but did not"
11723 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
11724 error "create with 255 char failed"
11725 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
11726 error "create with 256 char should fail, but did not"
11731 run_test 110 "filename length checking"
11734 # Purpose: To verify dynamic thread (OSS) creation.
11737 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11738 remote_ost_nodsh && skip "remote OST with nodsh"
11740 # Lustre does not stop service threads once they are started.
11741 # Reset number of running threads to default.
11746 local save_params="$TMP/sanity-$TESTNAME.parameters"
11748 # Get ll_ost_io count before I/O
11749 OSTIO_pre=$(do_facet ost1 \
11750 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
11751 # Exit if lustre is not running (ll_ost_io not running).
11752 [ -z "$OSTIO_pre" ] && error "no OSS threads"
11754 echo "Starting with $OSTIO_pre threads"
11755 local thread_max=$((OSTIO_pre * 2))
11756 local rpc_in_flight=$((thread_max * 2))
11757 # Number of I/O Process proposed to be started.
11759 local facets=$(get_facets OST)
11761 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
11762 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
11764 # Set in_flight to $rpc_in_flight
11765 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
11766 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
11767 nfiles=${rpc_in_flight}
11768 # Set ost thread_max to $thread_max
11769 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
11771 # 5 Minutes should be sufficient for max number of OSS
11772 # threads(thread_max) to be created.
11776 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
11777 test_mkdir $DIR/$tdir
11778 for i in $(seq $nfiles); do
11779 local file=$DIR/$tdir/${tfile}-$i
11780 $LFS setstripe -c -1 -i 0 $file
11781 ($WTL $file $timeout)&
11784 # I/O Started - Wait for thread_started to reach thread_max or report
11785 # error if thread_started is more than thread_max.
11786 echo "Waiting for thread_started to reach thread_max"
11787 local thread_started=0
11788 local end_time=$((SECONDS + timeout))
11790 while [ $SECONDS -le $end_time ] ; do
11792 # Get ost i/o thread_started count.
11793 thread_started=$(do_facet ost1 \
11795 ost.OSS.ost_io.threads_started | cut -d= -f2")
11796 # Break out if thread_started is equal/greater than thread_max
11797 if [[ $thread_started -ge $thread_max ]]; then
11798 echo ll_ost_io thread_started $thread_started, \
11799 equal/greater than thread_max $thread_max
11805 # Cleanup - We have the numbers, Kill i/o jobs if running.
11806 jobcount=($(jobs -p))
11807 for i in $(seq 0 $((${#jobcount[@]}-1)))
11809 kill -9 ${jobcount[$i]}
11810 if [ $? -ne 0 ] ; then
11812 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
11816 # Cleanup files left by WTL binary.
11817 for i in $(seq $nfiles); do
11818 local file=$DIR/$tdir/${tfile}-$i
11820 if [ $? -ne 0 ] ; then
11821 echo "Warning: Failed to delete file $file"
11825 restore_lustre_params <$save_params
11826 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
11828 # Error out if no new thread has started or Thread started is greater
11830 if [[ $thread_started -le $OSTIO_pre ||
11831 $thread_started -gt $thread_max ]]; then
11832 error "ll_ost_io: thread_started $thread_started" \
11833 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
11834 "No new thread started or thread started greater " \
11838 run_test 115 "verify dynamic thread creation===================="
11841 wait_delete_completed
11842 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
11843 echo "OST kbytes available: ${AVAIL[@]}"
11848 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
11849 #echo OST $i: ${AVAIL[i]}kb
11850 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
11854 if [[ ${AVAIL[i]} -lt $MINV ]]; then
11859 echo "Min free space: OST $MINI: $MINV"
11860 echo "Max free space: OST $MAXI: $MAXV"
11863 test_116a() { # was previously test_116()
11864 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11865 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11866 remote_mds_nodsh && skip "remote MDS with nodsh"
11868 echo -n "Free space priority "
11869 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
11874 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
11875 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
11876 trap simple_cleanup_common EXIT
11878 # Check if we need to generate uneven OSTs
11879 test_mkdir -p $DIR/$tdir/OST${MINI}
11880 local FILL=$((MINV / 4))
11881 local DIFF=$((MAXV - MINV))
11882 local DIFF2=$((DIFF * 100 / MINV))
11884 local threshold=$(do_facet $SINGLEMDS \
11885 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
11886 threshold=${threshold%%%}
11887 echo -n "Check for uneven OSTs: "
11888 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
11890 if [[ $DIFF2 -gt $threshold ]]; then
11892 echo "Don't need to fill OST$MINI"
11894 # generate uneven OSTs. Write 2% over the QOS threshold value
11896 DIFF=$((threshold - DIFF2 + 2))
11897 DIFF2=$((MINV * DIFF / 100))
11898 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
11899 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
11900 error "setstripe failed"
11901 DIFF=$((DIFF2 / 2048))
11903 while [ $i -lt $DIFF ]; do
11905 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
11906 bs=2M count=1 2>/dev/null
11915 DIFF=$((MAXV - MINV))
11916 DIFF2=$((DIFF * 100 / MINV))
11917 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
11918 if [ $DIFF2 -gt $threshold ]; then
11921 echo "failed - QOS mode won't be used"
11922 simple_cleanup_common
11923 skip "QOS imbalance criteria not met"
11931 # now fill using QOS
11932 $LFS setstripe -c 1 $DIR/$tdir
11933 FILL=$((FILL / 200))
11934 if [ $FILL -gt 600 ]; then
11937 echo "writing $FILL files to QOS-assigned OSTs"
11939 while [ $i -lt $FILL ]; do
11941 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
11942 count=1 2>/dev/null
11945 echo "wrote $i 200k files"
11949 echo "Note: free space may not be updated, so measurements might be off"
11951 DIFF2=$((MAXV - MINV))
11952 echo "free space delta: orig $DIFF final $DIFF2"
11953 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
11954 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
11955 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
11956 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
11957 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
11958 if [[ $DIFF -gt 0 ]]; then
11959 FILL=$((DIFF2 * 100 / DIFF - 100))
11960 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
11963 # Figure out which files were written where
11964 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
11965 awk '/'$MINI1': / {print $2; exit}')
11967 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
11968 echo "$MINC files created on smaller OST $MINI1"
11969 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
11970 awk '/'$MAXI1': / {print $2; exit}')
11972 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
11973 echo "$MAXC files created on larger OST $MAXI1"
11974 if [[ $MINC -gt 0 ]]; then
11975 FILL=$((MAXC * 100 / MINC - 100))
11976 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
11978 [[ $MAXC -gt $MINC ]] ||
11979 error_ignore LU-9 "stripe QOS didn't balance free space"
11980 simple_cleanup_common
11982 run_test 116a "stripe QOS: free space balance ==================="
11984 test_116b() { # LU-2093
11985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11986 remote_mds_nodsh && skip "remote MDS with nodsh"
11988 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
11989 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
11990 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
11991 [ -z "$old_rr" ] && skip "no QOS"
11992 do_facet $SINGLEMDS lctl set_param \
11993 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
11994 mkdir -p $DIR/$tdir
11995 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
11996 createmany -o $DIR/$tdir/f- 20 || error "can't create"
11997 do_facet $SINGLEMDS lctl set_param fail_loc=0
11999 do_facet $SINGLEMDS lctl set_param \
12000 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
12002 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
12004 test_117() # bug 10891
12006 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12008 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
12009 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
12010 lctl set_param fail_loc=0x21e
12011 > $DIR/$tfile || error "truncate failed"
12012 lctl set_param fail_loc=0
12013 echo "Truncate succeeded."
12016 run_test 117 "verify osd extend =========="
12018 NO_SLOW_RESENDCOUNT=4
12019 export OLD_RESENDCOUNT=""
12020 set_resend_count () {
12021 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
12022 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
12023 lctl set_param -n $PROC_RESENDCOUNT $1
12024 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
12027 # for reduce test_118* time (b=14842)
12028 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12030 # Reset async IO behavior after error case
12032 FILE=$DIR/reset_async
12034 # Ensure all OSCs are cleared
12035 $LFS setstripe -c -1 $FILE
12036 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
12041 test_118a() #bug 11710
12043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12047 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12048 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12049 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12051 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12052 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12057 run_test 118a "verify O_SYNC works =========="
12061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12062 remote_ost_nodsh && skip "remote OST with nodsh"
12066 #define OBD_FAIL_SRV_ENOENT 0x217
12067 set_nodes_failloc "$(osts_nodes)" 0x217
12068 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12070 set_nodes_failloc "$(osts_nodes)" 0
12071 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12072 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12075 if [[ $RC -eq 0 ]]; then
12076 error "Must return error due to dropped pages, rc=$RC"
12080 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12081 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12085 echo "Dirty pages not leaked on ENOENT"
12087 # Due to the above error the OSC will issue all RPCs syncronously
12088 # until a subsequent RPC completes successfully without error.
12089 $MULTIOP $DIR/$tfile Ow4096yc
12094 run_test 118b "Reclaim dirty pages on fatal error =========="
12098 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12100 # for 118c, restore the original resend count, LU-1940
12101 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
12102 set_resend_count $OLD_RESENDCOUNT
12103 remote_ost_nodsh && skip "remote OST with nodsh"
12107 #define OBD_FAIL_OST_EROFS 0x216
12108 set_nodes_failloc "$(osts_nodes)" 0x216
12110 # multiop should block due to fsync until pages are written
12111 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12115 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12116 error "Multiop failed to block on fsync, pid=$MULTIPID"
12119 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12121 if [[ $WRITEBACK -eq 0 ]]; then
12122 error "No page in writeback, writeback=$WRITEBACK"
12125 set_nodes_failloc "$(osts_nodes)" 0
12128 if [[ $RC -ne 0 ]]; then
12129 error "Multiop fsync failed, rc=$RC"
12132 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12133 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12135 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12136 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12140 echo "Dirty pages flushed via fsync on EROFS"
12143 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
12145 # continue to use small resend count to reduce test_118* time (b=14842)
12146 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12150 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12151 remote_ost_nodsh && skip "remote OST with nodsh"
12155 #define OBD_FAIL_OST_BRW_PAUSE_BULK
12156 set_nodes_failloc "$(osts_nodes)" 0x214
12157 # multiop should block due to fsync until pages are written
12158 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12162 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12163 error "Multiop failed to block on fsync, pid=$MULTIPID"
12166 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12168 if [[ $WRITEBACK -eq 0 ]]; then
12169 error "No page in writeback, writeback=$WRITEBACK"
12172 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
12173 set_nodes_failloc "$(osts_nodes)" 0
12175 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12176 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12178 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12179 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12183 echo "Dirty pages gaurenteed flushed via fsync"
12186 run_test 118d "Fsync validation inject a delay of the bulk =========="
12189 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12193 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
12194 lctl set_param fail_loc=0x8000040a
12196 # Should simulate EINVAL error which is fatal
12197 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12199 if [[ $RC -eq 0 ]]; then
12200 error "Must return error due to dropped pages, rc=$RC"
12203 lctl set_param fail_loc=0x0
12205 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12206 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12207 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12209 if [[ $LOCKED -ne 0 ]]; then
12210 error "Locked pages remain in cache, locked=$LOCKED"
12213 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12214 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12218 echo "No pages locked after fsync"
12223 run_test 118f "Simulate unrecoverable OSC side error =========="
12226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12230 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
12231 lctl set_param fail_loc=0x406
12233 # simulate local -ENOMEM
12234 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12237 lctl set_param fail_loc=0
12238 if [[ $RC -eq 0 ]]; then
12239 error "Must return error due to dropped pages, rc=$RC"
12242 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12243 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12244 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12246 if [[ $LOCKED -ne 0 ]]; then
12247 error "Locked pages remain in cache, locked=$LOCKED"
12250 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12251 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12255 echo "No pages locked after fsync"
12260 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
12263 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12264 remote_ost_nodsh && skip "remote OST with nodsh"
12268 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12269 set_nodes_failloc "$(osts_nodes)" 0x20e
12270 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12271 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12274 set_nodes_failloc "$(osts_nodes)" 0
12275 if [[ $RC -eq 0 ]]; then
12276 error "Must return error due to dropped pages, rc=$RC"
12279 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12280 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12281 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12283 if [[ $LOCKED -ne 0 ]]; then
12284 error "Locked pages remain in cache, locked=$LOCKED"
12287 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12288 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12292 echo "No pages locked after fsync"
12296 run_test 118h "Verify timeout in handling recoverables errors =========="
12298 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12302 remote_ost_nodsh && skip "remote OST with nodsh"
12306 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12307 set_nodes_failloc "$(osts_nodes)" 0x20e
12309 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12310 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12313 set_nodes_failloc "$(osts_nodes)" 0
12317 if [[ $RC -ne 0 ]]; then
12318 error "got error, but should be not, rc=$RC"
12321 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12322 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12323 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12324 if [[ $LOCKED -ne 0 ]]; then
12325 error "Locked pages remain in cache, locked=$LOCKED"
12328 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12329 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12333 echo "No pages locked after fsync"
12337 run_test 118i "Fix error before timeout in recoverable error =========="
12339 [ "$SLOW" = "no" ] && set_resend_count 4
12342 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12343 remote_ost_nodsh && skip "remote OST with nodsh"
12347 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
12348 set_nodes_failloc "$(osts_nodes)" 0x220
12350 # return -EIO from OST
12351 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12353 set_nodes_failloc "$(osts_nodes)" 0x0
12354 if [[ $RC -eq 0 ]]; then
12355 error "Must return error due to dropped pages, rc=$RC"
12358 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12359 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12360 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12361 if [[ $LOCKED -ne 0 ]]; then
12362 error "Locked pages remain in cache, locked=$LOCKED"
12365 # in recoverable error on OST we want resend and stay until it finished
12366 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12367 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12371 echo "No pages locked after fsync"
12375 run_test 118j "Simulate unrecoverable OST side error =========="
12379 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12380 remote_ost_nodsh && skip "remote OSTs with nodsh"
12382 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12383 set_nodes_failloc "$(osts_nodes)" 0x20e
12384 test_mkdir $DIR/$tdir
12386 for ((i=0;i<10;i++)); do
12387 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
12388 error "dd to $DIR/$tdir/$tfile-$i failed" )&
12395 set_nodes_failloc "$(osts_nodes)" 0
12398 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
12400 test_118l() # LU-646
12402 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12404 test_mkdir $DIR/$tdir
12405 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
12408 run_test 118l "fsync dir"
12410 test_118m() # LU-3066
12412 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12414 test_mkdir $DIR/$tdir
12415 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
12418 run_test 118m "fdatasync dir ========="
12420 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12427 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12428 remote_ost_nodsh && skip "remote OSTs with nodsh"
12430 # Sleep to avoid a cached response.
12431 #define OBD_STATFS_CACHE_SECONDS 1
12434 # Inject a 10 second delay in the OST_STATFS handler.
12435 #define OBD_FAIL_OST_STATFS_DELAY 0x242
12436 set_nodes_failloc "$(osts_nodes)" 0x242
12439 stat --file-system $MOUNT > /dev/null
12442 set_nodes_failloc "$(osts_nodes)" 0
12444 if ((end - begin > 20)); then
12445 error "statfs took $((end - begin)) seconds, expected 10"
12448 run_test 118n "statfs() sends OST_STATFS requests in parallel"
12450 test_119a() # bug 11737
12452 BSIZE=$((512 * 1024))
12453 directio write $DIR/$tfile 0 1 $BSIZE
12454 # We ask to read two blocks, which is more than a file size.
12455 # directio will indicate an error when requested and actual
12456 # sizes aren't equeal (a normal situation in this case) and
12457 # print actual read amount.
12458 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
12459 if [ "$NOB" != "$BSIZE" ]; then
12460 error "read $NOB bytes instead of $BSIZE"
12464 run_test 119a "Short directIO read must return actual read amount"
12466 test_119b() # bug 11737
12468 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12470 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
12471 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
12473 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
12474 error "direct read failed"
12477 run_test 119b "Sparse directIO read must return actual read amount"
12479 test_119c() # bug 13099
12482 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
12483 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
12486 run_test 119c "Testing for direct read hitting hole"
12488 test_119d() # bug 15950
12490 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12492 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
12493 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
12495 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
12496 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
12497 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
12498 lctl set_param fail_loc=0x40d
12499 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
12502 cat $DIR/$tfile > /dev/null &
12503 lctl set_param fail_loc=0
12506 log "the DIO writes have completed, now wait for the reads (should not block very long)"
12508 [ -n "`ps h -p $pid_reads -o comm`" ] && \
12509 error "the read rpcs have not completed in 2s"
12511 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
12513 run_test 119d "The DIO path should try to send a new rpc once one is completed"
12516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12517 remote_mds_nodsh && skip "remote MDS with nodsh"
12518 test_mkdir -i0 -c1 $DIR/$tdir
12519 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12520 skip_env "no early lock cancel on server"
12522 lru_resize_disable mdc
12523 lru_resize_disable osc
12524 cancel_lru_locks mdc
12525 # asynchronous object destroy at MDT could cause bl ast to client
12526 cancel_lru_locks osc
12528 stat $DIR/$tdir > /dev/null
12529 can1=$(do_facet mds1 \
12530 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12531 awk '/ldlm_cancel/ {print $2}')
12532 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12533 awk '/ldlm_bl_callback/ {print $2}')
12534 test_mkdir -i0 -c1 $DIR/$tdir/d1
12535 can2=$(do_facet mds1 \
12536 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12537 awk '/ldlm_cancel/ {print $2}')
12538 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12539 awk '/ldlm_bl_callback/ {print $2}')
12540 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12541 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12542 lru_resize_enable mdc
12543 lru_resize_enable osc
12545 run_test 120a "Early Lock Cancel: mkdir test"
12548 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12549 remote_mds_nodsh && skip "remote MDS with nodsh"
12550 test_mkdir $DIR/$tdir
12551 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12552 skip_env "no early lock cancel on server"
12554 lru_resize_disable mdc
12555 lru_resize_disable osc
12556 cancel_lru_locks mdc
12557 stat $DIR/$tdir > /dev/null
12558 can1=$(do_facet $SINGLEMDS \
12559 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12560 awk '/ldlm_cancel/ {print $2}')
12561 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12562 awk '/ldlm_bl_callback/ {print $2}')
12563 touch $DIR/$tdir/f1
12564 can2=$(do_facet $SINGLEMDS \
12565 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12566 awk '/ldlm_cancel/ {print $2}')
12567 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12568 awk '/ldlm_bl_callback/ {print $2}')
12569 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12570 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12571 lru_resize_enable mdc
12572 lru_resize_enable osc
12574 run_test 120b "Early Lock Cancel: create test"
12577 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12578 remote_mds_nodsh && skip "remote MDS with nodsh"
12579 test_mkdir -i0 -c1 $DIR/$tdir
12580 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12581 skip "no early lock cancel on server"
12583 lru_resize_disable mdc
12584 lru_resize_disable osc
12585 test_mkdir -i0 -c1 $DIR/$tdir/d1
12586 test_mkdir -i0 -c1 $DIR/$tdir/d2
12587 touch $DIR/$tdir/d1/f1
12588 cancel_lru_locks mdc
12589 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
12590 can1=$(do_facet mds1 \
12591 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12592 awk '/ldlm_cancel/ {print $2}')
12593 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12594 awk '/ldlm_bl_callback/ {print $2}')
12595 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
12596 can2=$(do_facet mds1 \
12597 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12598 awk '/ldlm_cancel/ {print $2}')
12599 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12600 awk '/ldlm_bl_callback/ {print $2}')
12601 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12602 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12603 lru_resize_enable mdc
12604 lru_resize_enable osc
12606 run_test 120c "Early Lock Cancel: link test"
12609 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12610 remote_mds_nodsh && skip "remote MDS with nodsh"
12611 test_mkdir -i0 -c1 $DIR/$tdir
12612 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12613 skip_env "no early lock cancel on server"
12615 lru_resize_disable mdc
12616 lru_resize_disable osc
12618 cancel_lru_locks mdc
12619 stat $DIR/$tdir > /dev/null
12620 can1=$(do_facet mds1 \
12621 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12622 awk '/ldlm_cancel/ {print $2}')
12623 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12624 awk '/ldlm_bl_callback/ {print $2}')
12625 chmod a+x $DIR/$tdir
12626 can2=$(do_facet mds1 \
12627 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12628 awk '/ldlm_cancel/ {print $2}')
12629 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12630 awk '/ldlm_bl_callback/ {print $2}')
12631 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12632 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12633 lru_resize_enable mdc
12634 lru_resize_enable osc
12636 run_test 120d "Early Lock Cancel: setattr test"
12639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12640 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12641 skip_env "no early lock cancel on server"
12642 remote_mds_nodsh && skip "remote MDS with nodsh"
12644 local dlmtrace_set=false
12646 test_mkdir -i0 -c1 $DIR/$tdir
12647 lru_resize_disable mdc
12648 lru_resize_disable osc
12649 ! $LCTL get_param debug | grep -q dlmtrace &&
12650 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
12651 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
12652 cancel_lru_locks mdc
12653 cancel_lru_locks osc
12654 dd if=$DIR/$tdir/f1 of=/dev/null
12655 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
12656 # XXX client can not do early lock cancel of OST lock
12657 # during unlink (LU-4206), so cancel osc lock now.
12659 cancel_lru_locks osc
12660 can1=$(do_facet mds1 \
12661 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12662 awk '/ldlm_cancel/ {print $2}')
12663 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12664 awk '/ldlm_bl_callback/ {print $2}')
12665 unlink $DIR/$tdir/f1
12667 can2=$(do_facet mds1 \
12668 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12669 awk '/ldlm_cancel/ {print $2}')
12670 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12671 awk '/ldlm_bl_callback/ {print $2}')
12672 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
12673 $LCTL dk $TMP/cancel.debug.txt
12674 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
12675 $LCTL dk $TMP/blocking.debug.txt
12676 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
12677 lru_resize_enable mdc
12678 lru_resize_enable osc
12680 run_test 120e "Early Lock Cancel: unlink test"
12683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12684 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12685 skip_env "no early lock cancel on server"
12686 remote_mds_nodsh && skip "remote MDS with nodsh"
12688 test_mkdir -i0 -c1 $DIR/$tdir
12689 lru_resize_disable mdc
12690 lru_resize_disable osc
12691 test_mkdir -i0 -c1 $DIR/$tdir/d1
12692 test_mkdir -i0 -c1 $DIR/$tdir/d2
12693 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
12694 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
12695 cancel_lru_locks mdc
12696 cancel_lru_locks osc
12697 dd if=$DIR/$tdir/d1/f1 of=/dev/null
12698 dd if=$DIR/$tdir/d2/f2 of=/dev/null
12699 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
12700 # XXX client can not do early lock cancel of OST lock
12701 # during rename (LU-4206), so cancel osc lock now.
12703 cancel_lru_locks osc
12704 can1=$(do_facet mds1 \
12705 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12706 awk '/ldlm_cancel/ {print $2}')
12707 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12708 awk '/ldlm_bl_callback/ {print $2}')
12709 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
12711 can2=$(do_facet mds1 \
12712 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12713 awk '/ldlm_cancel/ {print $2}')
12714 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12715 awk '/ldlm_bl_callback/ {print $2}')
12716 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12717 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12718 lru_resize_enable mdc
12719 lru_resize_enable osc
12721 run_test 120f "Early Lock Cancel: rename test"
12724 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12725 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12726 skip_env "no early lock cancel on server"
12727 remote_mds_nodsh && skip "remote MDS with nodsh"
12729 lru_resize_disable mdc
12730 lru_resize_disable osc
12732 echo create $count files
12733 test_mkdir $DIR/$tdir
12734 cancel_lru_locks mdc
12735 cancel_lru_locks osc
12738 can0=$(do_facet $SINGLEMDS \
12739 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12740 awk '/ldlm_cancel/ {print $2}')
12741 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12742 awk '/ldlm_bl_callback/ {print $2}')
12743 createmany -o $DIR/$tdir/f $count
12745 can1=$(do_facet $SINGLEMDS \
12746 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12747 awk '/ldlm_cancel/ {print $2}')
12748 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12749 awk '/ldlm_bl_callback/ {print $2}')
12751 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
12752 echo rm $count files
12755 can2=$(do_facet $SINGLEMDS \
12756 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12757 awk '/ldlm_cancel/ {print $2}')
12758 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12759 awk '/ldlm_bl_callback/ {print $2}')
12761 echo total: $count removes in $((t2-t1))
12762 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
12764 # wait for commitment of removal
12765 lru_resize_enable mdc
12766 lru_resize_enable osc
12768 run_test 120g "Early Lock Cancel: performance test"
12770 test_121() { #bug #10589
12771 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12774 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
12775 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
12776 lctl set_param fail_loc=0x310
12777 cancel_lru_locks osc > /dev/null
12778 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
12779 lctl set_param fail_loc=0
12780 [[ $reads -eq $writes ]] ||
12781 error "read $reads blocks, must be $writes blocks"
12783 run_test 121 "read cancel race ========="
12785 test_123a_base() { # was test 123, statahead(bug 11401)
12789 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
12790 log "testing UP system. Performance may be lower than expected."
12795 test_mkdir $DIR/$tdir
12796 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
12797 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
12799 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
12800 createmany -o $DIR/$tdir/$tfile $j $((i - j))
12802 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
12803 lctl set_param -n llite.*.statahead_max 0
12804 lctl get_param llite.*.statahead_max
12805 cancel_lru_locks mdc
12806 cancel_lru_locks osc
12808 time $lsx $DIR/$tdir | wc -l
12810 delta=$((etime - stime))
12811 log "$lsx $i files without statahead: $delta sec"
12812 lctl set_param llite.*.statahead_max=$max
12814 swrong=$(lctl get_param -n llite.*.statahead_stats |
12815 grep "statahead wrong:" | awk '{print $3}')
12816 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
12817 cancel_lru_locks mdc
12818 cancel_lru_locks osc
12820 time $lsx $DIR/$tdir | wc -l
12822 delta_sa=$((etime - stime))
12823 log "$lsx $i files with statahead: $delta_sa sec"
12824 lctl get_param -n llite.*.statahead_stats
12825 ewrong=$(lctl get_param -n llite.*.statahead_stats |
12826 grep "statahead wrong:" | awk '{print $3}')
12828 [[ $swrong -lt $ewrong ]] &&
12829 log "statahead was stopped, maybe too many locks held!"
12830 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
12832 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
12833 max=$(lctl get_param -n llite.*.statahead_max |
12835 lctl set_param -n llite.*.statahead_max 0
12836 lctl get_param llite.*.statahead_max
12837 cancel_lru_locks mdc
12838 cancel_lru_locks osc
12840 time $lsx $DIR/$tdir | wc -l
12842 delta=$((etime - stime))
12843 log "$lsx $i files again without statahead: $delta sec"
12844 lctl set_param llite.*.statahead_max=$max
12845 if [ $((delta_sa * 100 > delta * 105 && delta_sa > delta + 2)) ]; then
12846 if [ $SLOWOK -eq 0 ]; then
12847 error "$lsx $i files is slower with statahead!"
12849 log "$lsx $i files is slower with statahead!"
12855 [ $delta -gt 20 ] && break
12856 [ $delta -gt 8 ] && MULT=$((50 / delta))
12857 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
12865 delta=$((etime - stime))
12866 log "rm -r $DIR/$tdir/: $delta seconds"
12868 lctl get_param -n llite.*.statahead_stats
12872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12874 test_123a_base "ls -l"
12876 run_test 123aa "verify statahead work"
12879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12881 statx_supported || skip_env "Test must be statx() syscall supported"
12883 test_123a_base "$STATX -l"
12885 run_test 123ab "verify statahead work by using statx"
12888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12890 statx_supported || skip_env "Test must be statx() syscall supported"
12897 cancel_lru_locks $OSC
12898 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
12899 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
12900 awk '/agl.total:/ {print $3}')
12901 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
12902 test_123a_base "$STATX --cached=always -D"
12903 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
12904 awk '/agl.total:/ {print $3}')
12905 [ $agl_before -eq $agl_after ] ||
12906 error "Should not trigger AGL thread - $agl_before:$agl_after"
12907 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
12908 [ $rpcs_after -eq $rpcs_before ] ||
12909 error "$STATX should not send glimpse RPCs to $OSC"
12911 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
12913 test_123b () { # statahead(bug 15027)
12914 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12916 test_mkdir $DIR/$tdir
12917 createmany -o $DIR/$tdir/$tfile-%d 1000
12919 cancel_lru_locks mdc
12920 cancel_lru_locks osc
12922 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
12923 lctl set_param fail_loc=0x80000803
12924 ls -lR $DIR/$tdir > /dev/null
12926 lctl set_param fail_loc=0x0
12927 lctl get_param -n llite.*.statahead_stats
12932 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
12935 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
12937 test_mkdir -i 0 -c 1 $DIR/$tdir.0
12938 test_mkdir -i 1 -c 1 $DIR/$tdir.1
12939 touch $DIR/$tdir.1/{1..3}
12940 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
12942 remount_client $MOUNT
12944 $MULTIOP $DIR/$tdir.0 Q
12946 # let statahead to complete
12947 ls -l $DIR/$tdir.0 > /dev/null
12949 testid=$(echo $TESTNAME | tr '_' ' ')
12950 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
12951 error "statahead warning" || true
12953 run_test 123c "Can not initialize inode warning on DNE statahead"
12956 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12957 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
12958 skip_env "no lru resize on server"
12962 test_mkdir $DIR/$tdir
12964 log "create $NR files at $DIR/$tdir"
12965 createmany -o $DIR/$tdir/f $NR ||
12966 error "failed to create $NR files in $DIR/$tdir"
12968 cancel_lru_locks mdc
12969 ls -l $DIR/$tdir > /dev/null
12973 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
12974 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
12975 LRU_SIZE=$($LCTL get_param -n $PARAM)
12976 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
12977 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
12979 log "NS=$(basename $NSDIR)"
12984 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
12985 skip "Not enough cached locks created!"
12987 log "LRU=$LRU_SIZE"
12991 # We know that lru resize allows one client to hold $LIMIT locks
12992 # for 10h. After that locks begin to be killed by client.
12994 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
12996 if [ $LIMIT -lt $LRU_SIZE ]; then
12997 skip "Limit is too small $LIMIT"
13000 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
13001 # killing locks. Some time was spent for creating locks. This means
13002 # that up to the moment of sleep finish we must have killed some of
13003 # them (10-100 locks). This depends on how fast ther were created.
13004 # Many of them were touched in almost the same moment and thus will
13005 # be killed in groups.
13006 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
13008 # Use $LRU_SIZE_B here to take into account real number of locks
13009 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
13010 local LRU_SIZE_B=$LRU_SIZE
13012 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
13013 log "OLD_LVF=$OLD_LVF"
13014 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
13016 # Let's make sure that we really have some margin. Client checks
13017 # cached locks every 10 sec.
13018 SLEEP=$((SLEEP+20))
13019 log "Sleep ${SLEEP} sec"
13021 while ((SEC<$SLEEP)); do
13025 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
13026 echo -n "$LRU_SIZE"
13029 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
13030 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
13032 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
13033 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
13034 unlinkmany $DIR/$tdir/f $NR
13038 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
13039 log "unlink $NR files at $DIR/$tdir"
13040 unlinkmany $DIR/$tdir/f $NR
13042 run_test 124a "lru resize ======================================="
13044 get_max_pool_limit()
13046 local limit=$($LCTL get_param \
13047 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
13049 for l in $limit; do
13050 if [[ $l -gt $max ]]; then
13058 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13059 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13060 skip_env "no lru resize on server"
13062 LIMIT=$(get_max_pool_limit)
13064 NR=$(($(default_lru_size)*20))
13065 if [[ $NR -gt $LIMIT ]]; then
13066 log "Limit lock number by $LIMIT locks"
13070 IFree=$(mdsrate_inodes_available)
13071 if [ $IFree -lt $NR ]; then
13072 log "Limit lock number by $IFree inodes"
13076 lru_resize_disable mdc
13077 test_mkdir -p $DIR/$tdir/disable_lru_resize
13079 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
13080 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
13081 cancel_lru_locks mdc
13084 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13087 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13090 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13094 nolruresize_delta=$((etime-stime))
13095 log "ls -la time: $nolruresize_delta seconds"
13096 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13097 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
13099 lru_resize_enable mdc
13100 test_mkdir -p $DIR/$tdir/enable_lru_resize
13102 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
13103 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
13104 cancel_lru_locks mdc
13107 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13110 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13113 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13117 lruresize_delta=$((etime-stime))
13118 log "ls -la time: $lruresize_delta seconds"
13119 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13121 if [ $lruresize_delta -gt $nolruresize_delta ]; then
13122 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
13123 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
13124 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
13126 log "lru resize performs the same with no lru resize"
13128 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
13130 run_test 124b "lru resize (performance test) ======================="
13133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13134 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13135 skip_env "no lru resize on server"
13137 # cache ununsed locks on client
13139 cancel_lru_locks mdc
13140 test_mkdir $DIR/$tdir
13141 createmany -o $DIR/$tdir/f $nr ||
13142 error "failed to create $nr files in $DIR/$tdir"
13143 ls -l $DIR/$tdir > /dev/null
13145 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13146 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13147 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13148 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13149 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13151 # set lru_max_age to 1 sec
13152 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13153 echo "sleep $((recalc_p * 2)) seconds..."
13154 sleep $((recalc_p * 2))
13156 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13157 # restore lru_max_age
13158 $LCTL set_param -n $nsdir.lru_max_age $max_age
13159 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13160 unlinkmany $DIR/$tdir/f $nr
13162 run_test 124c "LRUR cancel very aged locks"
13165 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13166 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13167 skip_env "no lru resize on server"
13169 # cache ununsed locks on client
13172 lru_resize_disable mdc
13173 stack_trap "lru_resize_enable mdc" EXIT
13175 cancel_lru_locks mdc
13177 # asynchronous object destroy at MDT could cause bl ast to client
13178 test_mkdir $DIR/$tdir
13179 createmany -o $DIR/$tdir/f $nr ||
13180 error "failed to create $nr files in $DIR/$tdir"
13181 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
13183 ls -l $DIR/$tdir > /dev/null
13185 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13186 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13187 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13188 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13190 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13192 # set lru_max_age to 1 sec
13193 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13194 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
13196 echo "sleep $((recalc_p * 2)) seconds..."
13197 sleep $((recalc_p * 2))
13199 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13201 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13203 run_test 124d "cancel very aged locks if lru-resize diasbaled"
13205 test_125() { # 13358
13206 $LCTL get_param -n llite.*.client_type | grep -q local ||
13207 skip "must run as local client"
13208 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
13209 skip_env "must have acl enabled"
13210 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13212 test_mkdir $DIR/$tdir
13213 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
13214 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
13215 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
13217 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
13219 test_126() { # bug 12829/13455
13220 $GSS && skip_env "must run as gss disabled"
13221 $LCTL get_param -n llite.*.client_type | grep -q local ||
13222 skip "must run as local client"
13223 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
13225 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
13226 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
13228 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
13230 run_test 126 "check that the fsgid provided by the client is taken into account"
13232 test_127a() { # bug 15521
13233 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13234 local name count samp unit min max sum sumsq
13236 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
13237 echo "stats before reset"
13238 $LCTL get_param osc.*.stats
13239 $LCTL set_param osc.*.stats=0
13240 local fsize=$((2048 * 1024))
13242 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
13243 cancel_lru_locks osc
13244 dd if=$DIR/$tfile of=/dev/null bs=$fsize
13246 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
13247 stack_trap "rm -f $TMP/$tfile.tmp"
13248 while read name count samp unit min max sum sumsq; do
13249 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13250 [ ! $min ] && error "Missing min value for $name proc entry"
13251 eval $name=$count || error "Wrong proc format"
13254 read_bytes|write_bytes)
13255 [[ "$unit" =~ "bytes" ]] ||
13256 error "unit is not 'bytes': $unit"
13257 (( $min >= 4096 )) || error "min is too small: $min"
13258 (( $min <= $fsize )) || error "min is too big: $min"
13259 (( $max >= 4096 )) || error "max is too small: $max"
13260 (( $max <= $fsize )) || error "max is too big: $max"
13261 (( $sum == $fsize )) || error "sum is wrong: $sum"
13262 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
13263 error "sumsquare is too small: $sumsq"
13264 (( $sumsq <= $fsize * $fsize )) ||
13265 error "sumsquare is too big: $sumsq"
13267 ost_read|ost_write)
13268 [[ "$unit" =~ "usec" ]] ||
13269 error "unit is not 'usec': $unit"
13273 done < $DIR/$tfile.tmp
13275 #check that we actually got some stats
13276 [ "$read_bytes" ] || error "Missing read_bytes stats"
13277 [ "$write_bytes" ] || error "Missing write_bytes stats"
13278 [ "$read_bytes" != 0 ] || error "no read done"
13279 [ "$write_bytes" != 0 ] || error "no write done"
13281 run_test 127a "verify the client stats are sane"
13283 test_127b() { # bug LU-333
13284 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13285 local name count samp unit min max sum sumsq
13287 echo "stats before reset"
13288 $LCTL get_param llite.*.stats
13289 $LCTL set_param llite.*.stats=0
13291 # perform 2 reads and writes so MAX is different from SUM.
13292 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13293 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13294 cancel_lru_locks osc
13295 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13296 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13298 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
13299 stack_trap "rm -f $TMP/$tfile.tmp"
13300 while read name count samp unit min max sum sumsq; do
13301 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13302 eval $name=$count || error "Wrong proc format"
13305 read_bytes|write_bytes)
13306 [[ "$unit" =~ "bytes" ]] ||
13307 error "unit is not 'bytes': $unit"
13308 (( $count == 2 )) || error "count is not 2: $count"
13309 (( $min == $PAGE_SIZE )) ||
13310 error "min is not $PAGE_SIZE: $min"
13311 (( $max == $PAGE_SIZE )) ||
13312 error "max is not $PAGE_SIZE: $max"
13313 (( $sum == $PAGE_SIZE * 2 )) ||
13314 error "sum is not $((PAGE_SIZE * 2)): $sum"
13317 [[ "$unit" =~ "usec" ]] ||
13318 error "unit is not 'usec': $unit"
13322 done < $TMP/$tfile.tmp
13324 #check that we actually got some stats
13325 [ "$read_bytes" ] || error "Missing read_bytes stats"
13326 [ "$write_bytes" ] || error "Missing write_bytes stats"
13327 [ "$read_bytes" != 0 ] || error "no read done"
13328 [ "$write_bytes" != 0 ] || error "no write done"
13330 run_test 127b "verify the llite client stats are sane"
13332 test_127c() { # LU-12394
13333 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13340 $LCTL set_param llite.*.extents_stats=1
13341 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
13343 # Use two stripes so there is enough space in default config
13344 $LFS setstripe -c 2 $DIR/$tfile
13346 # Extent stats start at 0-4K and go in power of two buckets
13347 # LL_HIST_START = 12 --> 2^12 = 4K
13348 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
13349 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
13351 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
13353 # Write and read, 2x each, second time at a non-zero offset
13354 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
13355 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
13356 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
13357 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
13361 $LCTL get_param llite.*.extents_stats
13364 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
13366 local bucket=$($LCTL get_param -n llite.*.extents_stats |
13368 reads=$(echo $bucket | awk '{print $5}')
13369 writes=$(echo $bucket | awk '{print $9}')
13370 [ "$reads" -eq $count ] ||
13371 error "$reads reads in < $bsize bucket, expect $count"
13372 [ "$writes" -eq $count ] ||
13373 error "$writes writes in < $bsize bucket, expect $count"
13376 # Test mmap write and read
13377 $LCTL set_param llite.*.extents_stats=c
13379 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
13380 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
13381 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
13383 $LCTL get_param llite.*.extents_stats
13385 count=$(((size*1024) / PAGE_SIZE))
13387 bsize=$((2 * PAGE_SIZE / 1024))K
13389 bucket=$($LCTL get_param -n llite.*.extents_stats |
13391 reads=$(echo $bucket | awk '{print $5}')
13392 writes=$(echo $bucket | awk '{print $9}')
13393 # mmap writes fault in the page first, creating an additonal read
13394 [ "$reads" -eq $((2 * count)) ] ||
13395 error "$reads reads in < $bsize bucket, expect $count"
13396 [ "$writes" -eq $count ] ||
13397 error "$writes writes in < $bsize bucket, expect $count"
13399 run_test 127c "test llite extent stats with regular & mmap i/o"
13401 test_128() { # bug 15212
13403 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
13408 result=$(grep error $TMP/$tfile.log)
13409 rm -f $DIR/$tfile $TMP/$tfile.log
13410 [ -z "$result" ] ||
13411 error "consecutive find's under interactive lfs failed"
13413 run_test 128 "interactive lfs for 2 consecutive find's"
13415 set_dir_limits () {
13420 local ldproc=/proc/fs/ldiskfs
13421 local facets=$(get_facets MDS)
13423 for facet in ${facets//,/ }; do
13424 canondev=$(ldiskfs_canon \
13425 *.$(convert_facet2label $facet).mntdev $facet)
13426 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
13427 ldproc=/sys/fs/ldiskfs
13428 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
13429 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
13433 check_mds_dmesg() {
13434 local facets=$(get_facets MDS)
13435 for facet in ${facets//,/ }; do
13436 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
13442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13443 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
13444 skip "Need MDS version with at least 2.5.56"
13445 if [ "$mds1_FSTYPE" != ldiskfs ]; then
13446 skip_env "ldiskfs only test"
13448 remote_mds_nodsh && skip "remote MDS with nodsh"
13451 local has_warning=false
13454 mkdir -p $DIR/$tdir
13456 # block size of mds1
13457 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
13458 set_dir_limits $maxsize $((maxsize * 6 / 8))
13459 stack_trap "set_dir_limits 0 0"
13460 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
13461 local dirsize=$(stat -c%s "$DIR/$tdir")
13463 while (( $dirsize <= $maxsize )); do
13464 $MCREATE $DIR/$tdir/file_base_$nfiles
13466 # check two errors:
13467 # ENOSPC for ext4 max_dir_size, which has been used since
13468 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
13469 if (( rc == ENOSPC )); then
13471 echo "rc=$rc returned as expected after $nfiles files"
13473 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
13474 error "create failed w/o dir size limit"
13476 # messages may be rate limited if test is run repeatedly
13477 check_mds_dmesg '"is approaching max"' ||
13478 echo "warning message should be output"
13479 check_mds_dmesg '"has reached max"' ||
13480 echo "reached message should be output"
13482 dirsize=$(stat -c%s "$DIR/$tdir")
13484 [[ $dirsize -ge $maxsize ]] && return 0
13485 error "dirsize $dirsize < $maxsize after $nfiles files"
13486 elif (( rc != 0 )); then
13489 nfiles=$((nfiles + 1))
13490 dirsize=$(stat -c%s "$DIR/$tdir")
13493 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
13495 run_test 129 "test directory size limit ========================"
13504 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13505 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13507 trap cleanup_130 EXIT RETURN
13509 local fm_file=$DIR/$tfile
13510 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
13511 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
13512 error "dd failed for $fm_file"
13514 # LU-1795: test filefrag/FIEMAP once, even if unsupported
13515 filefrag -ves $fm_file
13517 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13518 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13519 [ $RC != 0 ] && error "filefrag $fm_file failed"
13521 filefrag_op=$(filefrag -ve -k $fm_file |
13522 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13523 lun=$($LFS getstripe -i $fm_file)
13525 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
13528 for line in $filefrag_op
13530 frag_lun=`echo $line | cut -d: -f5`
13531 ext_len=`echo $line | cut -d: -f4`
13532 if (( $frag_lun != $lun )); then
13534 error "FIEMAP on 1-stripe file($fm_file) failed"
13537 (( tot_len += ext_len ))
13540 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
13542 error "FIEMAP on 1-stripe file($fm_file) failed;"
13548 echo "FIEMAP on single striped file succeeded"
13550 run_test 130a "FIEMAP (1-stripe file)"
13553 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13555 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13556 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13558 trap cleanup_130 EXIT RETURN
13560 local fm_file=$DIR/$tfile
13561 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13562 error "setstripe on $fm_file"
13563 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13564 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13566 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
13567 error "dd failed on $fm_file"
13569 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13570 filefrag_op=$(filefrag -ve -k $fm_file |
13571 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13573 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13574 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13579 for line in $filefrag_op
13581 frag_lun=$(echo $line | cut -d: -f5 |
13582 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13583 ext_len=$(echo $line | cut -d: -f4)
13584 if (( $frag_lun != $last_lun )); then
13585 if (( tot_len != 1024 )); then
13587 error "FIEMAP on $fm_file failed; returned " \
13588 "len $tot_len for OST $last_lun instead of 1024"
13591 (( num_luns += 1 ))
13595 (( tot_len += ext_len ))
13598 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
13600 error "FIEMAP on $fm_file failed; returned wrong number of " \
13601 "luns or wrong len for OST $last_lun"
13607 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
13609 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
13612 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13614 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13615 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13617 trap cleanup_130 EXIT RETURN
13619 local fm_file=$DIR/$tfile
13620 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
13621 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13622 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13624 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
13625 error "dd failed on $fm_file"
13627 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13628 filefrag_op=$(filefrag -ve -k $fm_file |
13629 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13631 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13632 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13637 for line in $filefrag_op
13639 frag_lun=$(echo $line | cut -d: -f5 |
13640 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13641 ext_len=$(echo $line | cut -d: -f4)
13642 if (( $frag_lun != $last_lun )); then
13643 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
13644 if (( logical != 512 )); then
13646 error "FIEMAP on $fm_file failed; returned " \
13647 "logical start for lun $logical instead of 512"
13650 if (( tot_len != 512 )); then
13652 error "FIEMAP on $fm_file failed; returned " \
13653 "len $tot_len for OST $last_lun instead of 1024"
13656 (( num_luns += 1 ))
13660 (( tot_len += ext_len ))
13663 if (( num_luns != 2 || tot_len != 512 )); then
13665 error "FIEMAP on $fm_file failed; returned wrong number of " \
13666 "luns or wrong len for OST $last_lun"
13672 echo "FIEMAP on 2-stripe file with hole succeeded"
13674 run_test 130c "FIEMAP (2-stripe file with hole)"
13677 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
13679 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13680 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13682 trap cleanup_130 EXIT RETURN
13684 local fm_file=$DIR/$tfile
13685 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13686 error "setstripe on $fm_file"
13687 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13688 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13690 local actual_stripe_count=$($LFS getstripe -c $fm_file)
13691 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
13692 error "dd failed on $fm_file"
13694 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13695 filefrag_op=$(filefrag -ve -k $fm_file |
13696 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13698 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13699 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13704 for line in $filefrag_op
13706 frag_lun=$(echo $line | cut -d: -f5 |
13707 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13708 ext_len=$(echo $line | cut -d: -f4)
13709 if (( $frag_lun != $last_lun )); then
13710 if (( tot_len != 1024 )); then
13712 error "FIEMAP on $fm_file failed; returned " \
13713 "len $tot_len for OST $last_lun instead of 1024"
13716 (( num_luns += 1 ))
13720 (( tot_len += ext_len ))
13723 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
13725 error "FIEMAP on $fm_file failed; returned wrong number of " \
13726 "luns or wrong len for OST $last_lun"
13732 echo "FIEMAP on N-stripe file succeeded"
13734 run_test 130d "FIEMAP (N-stripe file)"
13737 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13739 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13740 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13742 trap cleanup_130 EXIT RETURN
13744 local fm_file=$DIR/$tfile
13745 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
13748 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
13749 for ((i = 0; i < $NUM_BLKS; i++)); do
13750 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
13751 conv=notrunc > /dev/null 2>&1
13754 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13755 filefrag_op=$(filefrag -ve -k $fm_file |
13756 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13758 last_lun=$(echo $filefrag_op | cut -d: -f5)
13763 for line in $filefrag_op; do
13764 frag_lun=$(echo $line | cut -d: -f5)
13765 ext_len=$(echo $line | cut -d: -f4)
13766 if [[ "$frag_lun" != "$last_lun" ]]; then
13767 if (( tot_len != $EXPECTED_LEN )); then
13769 error "OST$last_lun $tot_len != $EXPECTED_LEN"
13771 (( num_luns += 1 ))
13775 (( tot_len += ext_len ))
13778 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
13780 error "OST$last_lun $num_luns != 2, $tot_len != $EXPECTED_LEN"
13783 echo "FIEMAP with continuation calls succeeded"
13785 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
13788 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13789 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13791 local fm_file=$DIR/$tfile
13792 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
13793 error "multiop create with lov_delay_create on $fm_file"
13795 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13796 filefrag_extents=$(filefrag -vek $fm_file |
13797 awk '/extents? found/ { print $2 }')
13798 if [[ "$filefrag_extents" != "0" ]]; then
13799 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
13804 run_test 130f "FIEMAP (unstriped file)"
13807 local file=$DIR/$tfile
13808 local nr=$((OSTCOUNT * 100))
13810 $LFS setstripe -C $nr $file ||
13811 error "failed to setstripe -C $nr $file"
13813 dd if=/dev/zero of=$file count=$nr bs=1M
13815 nr=$($LFS getstripe -c $file)
13817 local extents=$(filefrag -v $file |
13818 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
13820 echo "filefrag list $extents extents in file with stripecount $nr"
13821 if (( extents < nr )); then
13822 $LFS getstripe $file
13824 error "filefrag printed $extents < $nr extents"
13829 run_test 130g "FIEMAP (overstripe file)"
13831 # Test for writev/readv
13833 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
13834 error "writev test failed"
13835 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
13836 error "readv failed"
13839 run_test 131a "test iov's crossing stripe boundary for writev/readv"
13842 local fsize=$((524288 + 1048576 + 1572864))
13843 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
13844 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
13845 error "append writev test failed"
13847 ((fsize += 1572864 + 1048576))
13848 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
13849 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
13850 error "append writev test failed"
13853 run_test 131b "test append writev"
13856 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
13859 run_test 131c "test read/write on file w/o objects"
13862 rwv -f $DIR/$tfile -w -n 1 1572864
13863 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
13864 if [ "$NOB" != 1572864 ]; then
13865 error "Short read filed: read $NOB bytes instead of 1572864"
13869 run_test 131d "test short read"
13872 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
13873 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
13874 error "read hitting hole failed"
13877 run_test 131e "test read hitting hole"
13886 mds*) res=$(do_facet $facet \
13887 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
13889 ost*) res=$(do_facet $facet \
13890 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
13892 *) error "Wrong facet '$facet'" ;;
13894 [ "$res" ] || error "The counter for $op on $facet was not incremented"
13895 # if the argument $3 is zero, it means any stat increment is ok.
13896 if [[ $want -gt 0 ]]; then
13897 local count=$(echo $res | awk '{ print $2 }')
13898 [[ $count -ne $want ]] &&
13899 error "The $op counter on $facet is $count, not $want"
13904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13905 remote_ost_nodsh && skip "remote OST with nodsh"
13906 remote_mds_nodsh && skip "remote MDS with nodsh"
13907 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
13908 skip_env "MDS doesn't support rename stats"
13910 local testdir=$DIR/${tdir}/stats_testdir
13912 mkdir -p $DIR/${tdir}
13915 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13916 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
13918 # verify mdt stats first.
13919 mkdir ${testdir} || error "mkdir failed"
13920 check_stats $SINGLEMDS "mkdir" 1
13921 touch ${testdir}/${tfile} || error "touch failed"
13922 check_stats $SINGLEMDS "open" 1
13923 check_stats $SINGLEMDS "close" 1
13924 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
13925 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
13926 check_stats $SINGLEMDS "mknod" 2
13928 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
13929 check_stats $SINGLEMDS "unlink" 1
13930 rm -f ${testdir}/${tfile} || error "file remove failed"
13931 check_stats $SINGLEMDS "unlink" 2
13933 # remove working dir and check mdt stats again.
13934 rmdir ${testdir} || error "rmdir failed"
13935 check_stats $SINGLEMDS "rmdir" 1
13937 local testdir1=$DIR/${tdir}/stats_testdir1
13938 mkdir -p ${testdir}
13939 mkdir -p ${testdir1}
13940 touch ${testdir1}/test1
13941 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
13942 check_stats $SINGLEMDS "crossdir_rename" 1
13944 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
13945 check_stats $SINGLEMDS "samedir_rename" 1
13947 rm -rf $DIR/${tdir}
13949 run_test 133a "Verifying MDT stats ========================================"
13954 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13955 remote_ost_nodsh && skip "remote OST with nodsh"
13956 remote_mds_nodsh && skip "remote MDS with nodsh"
13958 local testdir=$DIR/${tdir}/stats_testdir
13960 mkdir -p ${testdir} || error "mkdir failed"
13961 touch ${testdir}/${tfile} || error "touch failed"
13962 cancel_lru_locks mdc
13965 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13966 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
13968 # extra mdt stats verification.
13969 chmod 444 ${testdir}/${tfile} || error "chmod failed"
13970 check_stats $SINGLEMDS "setattr" 1
13971 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13972 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
13974 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
13975 check_stats $SINGLEMDS "getattr" 1
13977 rm -rf $DIR/${tdir}
13979 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
13980 # so the check below is not reliable
13981 [ $MDSCOUNT -eq 1 ] || return 0
13983 # Sleep to avoid a cached response.
13984 #define OBD_STATFS_CACHE_SECONDS 1
13986 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13987 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
13988 $LFS df || error "lfs failed"
13989 check_stats $SINGLEMDS "statfs" 1
13991 # check aggregated statfs (LU-10018)
13992 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
13994 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
13997 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13998 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14000 check_stats $SINGLEMDS "statfs" 1
14002 # We want to check that the client didn't send OST_STATFS to
14003 # ost1 but the MDT also uses OST_STATFS for precreate. So some
14004 # extra care is needed here.
14005 if remote_mds; then
14006 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
14007 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
14009 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
14010 [ "$res" ] && error "OST got STATFS"
14015 run_test 133b "Verifying extra MDT stats =================================="
14018 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14019 remote_ost_nodsh && skip "remote OST with nodsh"
14020 remote_mds_nodsh && skip "remote MDS with nodsh"
14022 local testdir=$DIR/$tdir/stats_testdir
14024 test_mkdir -p $testdir
14026 # verify obdfilter stats.
14027 $LFS setstripe -c 1 -i 0 $testdir/$tfile
14029 cancel_lru_locks osc
14030 wait_delete_completed
14033 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14034 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14036 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
14039 cancel_lru_locks osc
14040 check_stats ost1 "write" 1
14042 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
14043 check_stats ost1 "read" 1
14045 > $testdir/$tfile || error "truncate failed"
14046 check_stats ost1 "punch" 1
14048 rm -f $testdir/$tfile || error "file remove failed"
14049 wait_delete_completed
14050 check_stats ost1 "destroy" 1
14054 run_test 133c "Verifying OST stats ========================================"
14061 while [ $value -ge 2 ]; do
14066 if [ $orig -gt $order ]; then
14074 local size=('K' 'M' 'G' 'T');
14076 local size_string=$value
14078 while [ $value -ge 1024 ]; do
14079 if [ $i -gt 3 ]; then
14080 #T is the biggest unit we get here, if that is bigger,
14082 size_string=${value}T
14085 value=$((value >> 10))
14086 if [ $value -lt 1024 ]; then
14087 size_string=${value}${size[$i]}
14096 get_rename_size() {
14098 local context=${2:-.}
14099 local sample=$(do_facet $SINGLEMDS $LCTL \
14100 get_param mdt.$FSNAME-MDT0000.rename_stats |
14101 grep -A1 $context |
14102 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
14107 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14108 remote_ost_nodsh && skip "remote OST with nodsh"
14109 remote_mds_nodsh && skip "remote MDS with nodsh"
14110 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14111 skip_env "MDS doesn't support rename stats"
14113 local testdir1=$DIR/${tdir}/stats_testdir1
14114 local testdir2=$DIR/${tdir}/stats_testdir2
14115 mkdir -p $DIR/${tdir}
14117 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14119 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
14120 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
14122 createmany -o $testdir1/test 512 || error "createmany failed"
14124 # check samedir rename size
14125 mv ${testdir1}/test0 ${testdir1}/test_0
14127 local testdir1_size=$(ls -l $DIR/${tdir} |
14128 awk '/stats_testdir1/ {print $5}')
14129 local testdir2_size=$(ls -l $DIR/${tdir} |
14130 awk '/stats_testdir2/ {print $5}')
14132 testdir1_size=$(order_2 $testdir1_size)
14133 testdir2_size=$(order_2 $testdir2_size)
14135 testdir1_size=$(size_in_KMGT $testdir1_size)
14136 testdir2_size=$(size_in_KMGT $testdir2_size)
14138 echo "source rename dir size: ${testdir1_size}"
14139 echo "target rename dir size: ${testdir2_size}"
14141 local cmd="do_facet $SINGLEMDS $LCTL "
14142 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
14144 eval $cmd || error "$cmd failed"
14145 local samedir=$($cmd | grep 'same_dir')
14146 local same_sample=$(get_rename_size $testdir1_size)
14147 [ -z "$samedir" ] && error "samedir_rename_size count error"
14148 [[ $same_sample -eq 1 ]] ||
14149 error "samedir_rename_size error $same_sample"
14150 echo "Check same dir rename stats success"
14152 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14154 # check crossdir rename size
14155 mv ${testdir1}/test_0 ${testdir2}/test_0
14157 testdir1_size=$(ls -l $DIR/${tdir} |
14158 awk '/stats_testdir1/ {print $5}')
14159 testdir2_size=$(ls -l $DIR/${tdir} |
14160 awk '/stats_testdir2/ {print $5}')
14162 testdir1_size=$(order_2 $testdir1_size)
14163 testdir2_size=$(order_2 $testdir2_size)
14165 testdir1_size=$(size_in_KMGT $testdir1_size)
14166 testdir2_size=$(size_in_KMGT $testdir2_size)
14168 echo "source rename dir size: ${testdir1_size}"
14169 echo "target rename dir size: ${testdir2_size}"
14171 eval $cmd || error "$cmd failed"
14172 local crossdir=$($cmd | grep 'crossdir')
14173 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
14174 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
14175 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
14176 [[ $src_sample -eq 1 ]] ||
14177 error "crossdir_rename_size error $src_sample"
14178 [[ $tgt_sample -eq 1 ]] ||
14179 error "crossdir_rename_size error $tgt_sample"
14180 echo "Check cross dir rename stats success"
14181 rm -rf $DIR/${tdir}
14183 run_test 133d "Verifying rename_stats ========================================"
14186 remote_mds_nodsh && skip "remote MDS with nodsh"
14187 remote_ost_nodsh && skip "remote OST with nodsh"
14188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14190 local testdir=$DIR/${tdir}/stats_testdir
14191 local ctr f0 f1 bs=32768 count=42 sum
14193 mkdir -p ${testdir} || error "mkdir failed"
14195 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
14197 for ctr in {write,read}_bytes; do
14199 cancel_lru_locks osc
14201 do_facet ost1 $LCTL set_param -n \
14202 "obdfilter.*.exports.clear=clear"
14204 if [ $ctr = write_bytes ]; then
14206 f1=${testdir}/${tfile}
14208 f0=${testdir}/${tfile}
14212 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
14215 cancel_lru_locks osc
14217 sum=$(do_facet ost1 $LCTL get_param \
14218 "obdfilter.*.exports.*.stats" |
14219 awk -v ctr=$ctr 'BEGIN { sum = 0 }
14220 $1 == ctr { sum += $7 }
14221 END { printf("%0.0f", sum) }')
14223 if ((sum != bs * count)); then
14224 error "Bad $ctr sum, expected $((bs * count)), got $sum"
14228 rm -rf $DIR/${tdir}
14230 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
14233 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
14234 skip "too old lustre for get_param -R ($facet_ver)"
14236 # verifying readability.
14237 $LCTL get_param -R '*' &> /dev/null
14239 # Verifing writability with badarea_io.
14240 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14241 local skipped_params='force_lbug|changelog_mask|daemon_file'
14242 $LCTL list_param -FR '*' | grep '=' | tr -d = |
14243 egrep -v "$skipped_params" |
14244 xargs -n 1 find $proc_dirs -name |
14245 xargs -n 1 badarea_io ||
14246 error "client badarea_io failed"
14248 # remount the FS in case writes/reads /proc break the FS
14249 cleanup || error "failed to unmount"
14250 setup || error "failed to setup"
14252 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
14255 remote_mds_nodsh && skip "remote MDS with nodsh"
14256 remote_ost_nodsh && skip "remote OST with nodsh"
14258 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14259 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
14261 for facet in mds1 ost1; do
14262 local facet_ver=$(lustre_version_code $facet)
14263 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
14264 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
14266 log "$facet: too old lustre for get_param -R"
14268 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
14269 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
14270 tr -d = | egrep -v $skipped_params |
14271 xargs -n 1 find $proc_dirs -name |
14272 xargs -n 1 badarea_io" ||
14273 error "$facet badarea_io failed"
14275 skip_noexit "$facet: too old lustre for get_param -R"
14279 # remount the FS in case writes/reads /proc break the FS
14280 cleanup || error "failed to unmount"
14281 setup || error "failed to setup"
14283 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
14286 remote_mds_nodsh && skip "remote MDS with nodsh"
14287 remote_ost_nodsh && skip "remote OST with nodsh"
14288 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
14289 skip "Need MDS version at least 2.9.54"
14292 for facet in client mds1 ost1; do
14293 # Get the list of files that are missing the terminating newline
14294 local plist=$(do_facet $facet
14295 $LCTL list_param -FR '*' | grep '=' | tr -d =)
14297 for ent in $plist; do
14298 local missing=$(do_facet $facet $LCTL get_param $ent \|\
14299 awk -v FS='\v' -v RS='\v\v' \
14300 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
14301 print FILENAME}'" 2>/dev/null)
14302 [ -z $missing ] || {
14303 do_facet $facet $LCTL get_param $ent | od -An -tx1
14304 error "file does not end with newline: $facet-$ent"
14309 run_test 133h "Proc files should end with newlines"
14312 remote_mds_nodsh && skip "remote MDS with nodsh"
14313 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14314 skip "Need MDS version at least 2.7.54"
14316 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14317 cancel_lru_locks mdc
14319 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14320 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14321 [ $unused -eq 0 ] || error "$unused locks are not cleared"
14324 createmany -o $DIR/$tdir/f $nr ||
14325 error "failed to create $nr files in $DIR/$tdir"
14326 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14328 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
14329 do_facet mds1 $LCTL set_param fail_loc=0x327
14330 do_facet mds1 $LCTL set_param fail_val=500
14333 echo "sleep 10 seconds ..."
14335 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
14337 do_facet mds1 $LCTL set_param fail_loc=0
14338 do_facet mds1 $LCTL set_param fail_val=0
14339 [ $lck_cnt -lt $unused ] ||
14340 error "No locks reclaimed, before:$unused, after:$lck_cnt"
14343 unlinkmany $DIR/$tdir/f $nr
14345 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
14348 remote_mds_nodsh && skip "remote MDS with nodsh"
14349 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14350 skip "Need MDS version at least 2.7.54"
14352 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14353 cancel_lru_locks mdc
14355 local low_wm=$(do_facet mds1 $LCTL get_param -n \
14356 ldlm.lock_reclaim_threshold_mb)
14357 # disable reclaim temporarily
14358 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
14360 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
14361 do_facet mds1 $LCTL set_param fail_loc=0x328
14362 do_facet mds1 $LCTL set_param fail_val=500
14364 $LCTL set_param debug=+trace
14367 createmany -o $DIR/$tdir/f $nr &
14368 local create_pid=$!
14370 echo "Sleep $TIMEOUT seconds ..."
14372 if ! ps -p $create_pid > /dev/null 2>&1; then
14373 do_facet mds1 $LCTL set_param fail_loc=0
14374 do_facet mds1 $LCTL set_param fail_val=0
14375 do_facet mds1 $LCTL set_param \
14376 ldlm.lock_reclaim_threshold_mb=${low_wm}m
14377 error "createmany finished incorrectly!"
14379 do_facet mds1 $LCTL set_param fail_loc=0
14380 do_facet mds1 $LCTL set_param fail_val=0
14381 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
14382 wait $create_pid || return 1
14384 unlinkmany $DIR/$tdir/f $nr
14386 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
14389 remote_mds_nodsh && skip "remote MDS with nodsh"
14390 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14391 skip "Need MDS version at least 2.13.50"
14394 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14396 #define OBD_FAIL_PLAIN_RECORDS 0x1319
14397 #set only one record at plain llog
14398 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
14400 #fill already existed plain llog each 64767
14401 #wrapping whole catalog
14402 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14404 createmany -o $DIR/$tdir/$tfile_ 64700
14405 for (( i = 0; i < 64700; i = i + 2 ))
14407 rm $DIR/$tdir/$tfile_$i &
14408 rm $DIR/$tdir/$tfile_$((i + 1)) &
14413 #waiting osp synchronization
14414 wait_delete_completed
14416 run_test 135 "Race catalog processing"
14419 remote_mds_nodsh && skip "remote MDS with nodsh"
14420 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14421 skip "Need MDS version at least 2.13.50"
14424 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14425 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
14426 #set only one record at plain llog
14427 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
14428 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
14430 #fill already existed 2 plain llogs each 64767
14431 #wrapping whole catalog
14432 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14433 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
14434 wait_delete_completed
14436 createmany -o $DIR/$tdir/$tfile_ 10
14439 do_facet $SINGLEMDS $LCTL set_param fail_val=3
14440 for (( i = 0; i < 10; i = i + 3 ))
14442 rm $DIR/$tdir/$tfile_$i &
14443 rm $DIR/$tdir/$tfile_$((i + 1)) &
14447 rm $DIR/$tdir/$tfile_$((i + 2)) &
14450 #waiting osp synchronization
14451 wait_delete_completed
14453 run_test 136 "Race catalog processing 2"
14455 test_140() { #bug-17379
14456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14458 test_mkdir $DIR/$tdir
14459 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
14460 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
14462 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
14463 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
14465 while i=$((i + 1)); do
14467 cd $i || error "Changing to $i"
14468 ln -s ../stat stat || error "Creating stat symlink"
14469 # Read the symlink until ELOOP present,
14470 # not LBUGing the system is considered success,
14471 # we didn't overrun the stack.
14472 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
14473 if [ $ret -ne 0 ]; then
14474 if [ $ret -eq 40 ]; then
14477 error "Open stat symlink"
14483 echo "The symlink depth = $i"
14484 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
14485 error "Invalid symlink depth"
14487 # Test recursive symlink
14488 ln -s symlink_self symlink_self
14489 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
14490 echo "open symlink_self returns $ret"
14491 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
14493 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
14496 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14498 local TF="$TMP/$tfile"
14500 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14501 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
14503 cancel_lru_locks $OSC
14504 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
14505 remount_client $MOUNT
14507 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
14510 $TRUNCATE $DIR/$tfile 6000
14511 cancel_lru_locks $OSC
14512 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
14515 echo "12345" >>$DIR/$tfile
14516 cancel_lru_locks $OSC
14517 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
14520 echo "12345" >>$DIR/$tfile
14521 cancel_lru_locks $OSC
14522 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
14524 run_test 150a "truncate/append tests"
14527 check_set_fallocate_or_skip
14530 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14531 check_fallocate $DIR/$tfile || error "fallocate failed"
14533 run_test 150b "Verify fallocate (prealloc) functionality"
14536 check_set_fallocate_or_skip
14539 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14540 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
14542 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14543 # precomputed md5sum for 20MB of zeroes
14544 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
14545 local sum=($(md5sum $DIR/$tfile))
14547 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
14549 check_set_fallocate 1
14552 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14553 sum=($(md5sum $DIR/$tfile))
14555 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
14557 run_test 150bb "Verify fallocate modes both zero space"
14560 check_set_fallocate_or_skip
14561 local striping="-c2"
14563 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14564 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
14565 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
14566 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14567 local want=$((OSTCOUNT * 1048576))
14569 # Must allocate all requested space, not more than 5% extra
14570 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14571 error "bytes $bytes is not $want"
14575 echo "verify fallocate on PFL file"
14577 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14579 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
14580 error "Create $DIR/$tfile failed"
14581 fallocate -l $((1048576 * 512)) $DIR/$tfile ||
14582 error "fallocate failed"
14583 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14584 want=$((512 * 1048576))
14586 # Must allocate all requested space, not more than 5% extra
14587 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14588 error "bytes $bytes is not $want"
14590 run_test 150c "Verify fallocate Size and Blocks"
14593 check_set_fallocate_or_skip
14594 local striping="-c2"
14596 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14598 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14599 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
14600 error "setstripe failed"
14601 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
14602 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
14603 local want=$((OSTCOUNT * 1048576))
14605 # Must allocate all requested space, not more than 5% extra
14606 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14607 error "bytes $bytes is not $want"
14609 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
14612 check_set_fallocate_or_skip
14616 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14617 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
14618 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
14620 # Find OST with Minimum Size
14621 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
14622 sort -un | head -1)
14624 # Get 100MB per OST of the available space to reduce run time
14625 # else 60% of the available space if we are running SLOW tests
14626 if [ $SLOW == "no" ]; then
14627 local space=$((1024 * 100 * OSTCOUNT))
14629 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
14632 fallocate -l${space}k $DIR/$tfile ||
14633 error "fallocate ${space}k $DIR/$tfile failed"
14634 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
14636 # get size immediately after fallocate. This should be correctly
14638 local size=$(stat -c '%s' $DIR/$tfile)
14639 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
14641 # Sleep for a while for statfs to get updated. And not pull from cache.
14644 echo "df after fallocate:"
14647 (( size / 1024 == space )) || error "size $size != requested $space"
14648 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
14649 error "used $used < space $space"
14651 rm $DIR/$tfile || error "rm failed"
14653 wait_delete_completed
14655 echo "df after unlink:"
14658 run_test 150e "Verify 60% of available OST space consumed by fallocate"
14663 local want_size_before=20480 # in bytes
14664 local want_blocks_before=40 # 512 sized blocks
14665 local want_blocks_after=24 # 512 sized blocks
14666 local length=$(((want_blocks_before - want_blocks_after) * 512))
14668 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
14669 skip "need at least 2.14.0 for fallocate punch"
14671 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
14672 skip "LU-14160: punch mode is not implemented on OSD ZFS"
14675 check_set_fallocate_or_skip
14676 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14678 [[ "x$DOM" == "xyes" ]] &&
14679 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
14681 echo "Verify fallocate punch: Range within the file range"
14682 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
14683 error "dd failed for bs 4096 and count 5"
14685 # Call fallocate with punch range which is within the file range
14686 fallocate -p --offset 4096 -l $length $DIR/$tfile ||
14687 error "fallocate failed: offset 4096 and length $length"
14688 # client must see changes immediately after fallocate
14689 size=$(stat -c '%s' $DIR/$tfile)
14690 blocks=$(stat -c '%b' $DIR/$tfile)
14692 # Verify punch worked.
14693 (( blocks == want_blocks_after )) ||
14694 error "punch failed: blocks $blocks != $want_blocks_after"
14696 (( size == want_size_before )) ||
14697 error "punch failed: size $size != $want_size_before"
14699 # Verify there is hole in file
14700 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
14701 # precomputed md5sum
14702 local expect="4a9a834a2db02452929c0a348273b4aa"
14704 cksum=($(md5sum $DIR/$tfile))
14705 [[ "${cksum[0]}" == "$expect" ]] ||
14706 error "unexpected MD5SUM after punch: ${cksum[0]}"
14708 # Start second sub-case for fallocate punch.
14709 echo "Verify fallocate punch: Range overlapping and less than blocksize"
14710 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
14711 error "dd failed for bs 4096 and count 5"
14713 # Punch range less than block size will have no change in block count
14714 want_blocks_after=40 # 512 sized blocks
14716 # Punch overlaps two blocks and less than blocksize
14717 fallocate -p --offset 4000 -l 3000 $DIR/$tfile ||
14718 error "fallocate failed: offset 4000 length 3000"
14719 size=$(stat -c '%s' $DIR/$tfile)
14720 blocks=$(stat -c '%b' $DIR/$tfile)
14722 # Verify punch worked.
14723 (( blocks == want_blocks_after )) ||
14724 error "punch failed: blocks $blocks != $want_blocks_after"
14726 (( size == want_size_before )) ||
14727 error "punch failed: size $size != $want_size_before"
14729 # Verify if range is really zero'ed out. We expect Zeros.
14730 # precomputed md5sum
14731 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
14732 cksum=($(md5sum $DIR/$tfile))
14733 [[ "${cksum[0]}" == "$expect" ]] ||
14734 error "unexpected MD5SUM after punch: ${cksum[0]}"
14736 run_test 150f "Verify fallocate punch functionality"
14744 local BS=4096 # Block size in bytes
14746 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
14747 skip "need at least 2.14.0 for fallocate punch"
14749 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
14750 skip "LU-14160: punch mode is not implemented on OSD ZFS"
14753 check_set_fallocate_or_skip
14754 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14756 if [[ "x$DOM" == "xyes" ]]; then
14757 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
14758 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
14760 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
14761 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
14764 # Get 100MB per OST of the available space to reduce run time
14765 # else 60% of the available space if we are running SLOW tests
14766 if [ $SLOW == "no" ]; then
14767 space=$((1024 * 100 * OSTCOUNT))
14769 # Find OST with Minimum Size
14770 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
14771 sort -un | head -1)
14772 echo "min size OST: $space"
14773 space=$(((space * 60)/100 * OSTCOUNT))
14775 # space in 1k units, round to 4k blocks
14776 local blkcount=$((space * 1024 / $BS))
14778 echo "Verify fallocate punch: Very large Range"
14779 fallocate -l${space}k $DIR/$tfile ||
14780 error "fallocate ${space}k $DIR/$tfile failed"
14781 # write 1M at the end, start and in the middle
14782 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
14783 error "dd failed: bs $BS count 256"
14784 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
14785 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
14786 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
14787 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
14790 size=$(stat -c '%s' $DIR/$tfile)
14792 # gather punch length.
14793 local punch_size=$((size - (BS * 2)))
14795 echo "punch_size = $punch_size"
14796 echo "size - punch_size: $((size - punch_size))"
14797 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
14799 # Call fallocate to punch all except 2 blocks. We leave the
14800 # first and the last block
14801 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
14802 fallocate -p --offset $BS -l $punch_size $DIR/$tfile ||
14803 error "fallocate failed: offset $BS length $punch_size"
14805 size_after=$(stat -c '%s' $DIR/$tfile)
14806 blocks_after=$(stat -c '%b' $DIR/$tfile)
14808 # Verify punch worked.
14809 # Size should be kept
14810 (( size == size_after )) ||
14811 error "punch failed: size $size != $size_after"
14813 # two 4k data blocks to remain plus possible 1 extra extent block
14814 (( blocks_after <= ((BS / 512) * 3) )) ||
14815 error "too many blocks remains: $blocks_after"
14817 # Verify that file has hole between the first and the last blocks
14818 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
14819 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
14821 echo "Hole at [$hole_start, $hole_end)"
14822 (( hole_start == BS )) ||
14823 error "no hole at offset $BS after punch"
14825 (( hole_end == BS + punch_size )) ||
14826 error "data at offset $hole_end < $((BS + punch_size))"
14828 run_test 150g "Verify fallocate punch on large range"
14830 #LU-2902 roc_hit was not able to read all values from lproc
14831 function roc_hit_init() {
14832 local list=$(comma_list $(osts_nodes))
14833 local dir=$DIR/$tdir-check
14834 local file=$dir/$tfile
14840 #use setstripe to do a write to every ost
14841 for i in $(seq 0 $((OSTCOUNT-1))); do
14842 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
14843 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
14844 idx=$(printf %04x $i)
14845 BEFORE=$(get_osd_param $list *OST*$idx stats |
14846 awk '$1 == "cache_access" {sum += $7}
14847 END { printf("%0.0f", sum) }')
14849 cancel_lru_locks osc
14850 cat $file >/dev/null
14852 AFTER=$(get_osd_param $list *OST*$idx stats |
14853 awk '$1 == "cache_access" {sum += $7}
14854 END { printf("%0.0f", sum) }')
14856 echo BEFORE:$BEFORE AFTER:$AFTER
14857 if ! let "AFTER - BEFORE == 4"; then
14859 error "roc_hit is not safe to use"
14867 function roc_hit() {
14868 local list=$(comma_list $(osts_nodes))
14869 echo $(get_osd_param $list '' stats |
14870 awk '$1 == "cache_hit" {sum += $7}
14871 END { printf("%0.0f", sum) }')
14874 function set_cache() {
14877 if [ "$2" == "off" ]; then
14880 local list=$(comma_list $(osts_nodes))
14881 set_osd_param $list '' $1_cache_enable $on
14883 cancel_lru_locks osc
14887 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14888 remote_ost_nodsh && skip "remote OST with nodsh"
14891 local list=$(comma_list $(osts_nodes))
14893 # check whether obdfilter is cache capable at all
14894 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
14895 skip "not cache-capable obdfilter"
14898 # check cache is enabled on all obdfilters
14899 if get_osd_param $list '' read_cache_enable | grep 0; then
14900 skip "oss cache is disabled"
14903 set_osd_param $list '' writethrough_cache_enable 1
14905 # check write cache is enabled on all obdfilters
14906 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
14907 skip "oss write cache is NOT enabled"
14912 #define OBD_FAIL_OBD_NO_LRU 0x609
14913 do_nodes $list $LCTL set_param fail_loc=0x609
14915 # pages should be in the case right after write
14916 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
14919 local BEFORE=$(roc_hit)
14920 cancel_lru_locks osc
14921 cat $DIR/$tfile >/dev/null
14922 local AFTER=$(roc_hit)
14924 do_nodes $list $LCTL set_param fail_loc=0
14926 if ! let "AFTER - BEFORE == CPAGES"; then
14927 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
14930 cancel_lru_locks osc
14931 # invalidates OST cache
14932 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
14933 set_osd_param $list '' read_cache_enable 0
14934 cat $DIR/$tfile >/dev/null
14936 # now data shouldn't be found in the cache
14938 cancel_lru_locks osc
14939 cat $DIR/$tfile >/dev/null
14941 if let "AFTER - BEFORE != 0"; then
14942 error "IN CACHE: before: $BEFORE, after: $AFTER"
14945 set_osd_param $list '' read_cache_enable 1
14948 run_test 151 "test cache on oss and controls ==============================="
14951 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14953 local TF="$TMP/$tfile"
14955 # simulate ENOMEM during write
14956 #define OBD_FAIL_OST_NOMEM 0x226
14957 lctl set_param fail_loc=0x80000226
14958 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
14960 sync || error "sync failed"
14961 lctl set_param fail_loc=0
14963 # discard client's cache
14964 cancel_lru_locks osc
14966 # simulate ENOMEM during read
14967 lctl set_param fail_loc=0x80000226
14968 cmp $TF $DIR/$tfile || error "cmp failed"
14969 lctl set_param fail_loc=0
14973 run_test 152 "test read/write with enomem ============================"
14976 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
14978 run_test 153 "test if fdatasync does not crash ======================="
14980 dot_lustre_fid_permission_check() {
14982 local ffid=$MOUNT/.lustre/fid/$fid
14985 echo "stat fid $fid"
14986 stat $ffid > /dev/null || error "stat $ffid failed."
14987 echo "touch fid $fid"
14988 touch $ffid || error "touch $ffid failed."
14989 echo "write to fid $fid"
14990 cat /etc/hosts > $ffid || error "write $ffid failed."
14991 echo "read fid $fid"
14992 diff /etc/hosts $ffid || error "read $ffid failed."
14993 echo "append write to fid $fid"
14994 cat /etc/hosts >> $ffid || error "append write $ffid failed."
14995 echo "rename fid $fid"
14996 mv $ffid $test_dir/$tfile.1 &&
14997 error "rename $ffid to $tfile.1 should fail."
14998 touch $test_dir/$tfile.1
14999 mv $test_dir/$tfile.1 $ffid &&
15000 error "rename $tfile.1 to $ffid should fail."
15001 rm -f $test_dir/$tfile.1
15002 echo "truncate fid $fid"
15003 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
15004 echo "link fid $fid"
15005 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
15006 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
15007 echo "setfacl fid $fid"
15008 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
15009 echo "getfacl fid $fid"
15010 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
15012 echo "unlink fid $fid"
15013 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
15014 echo "mknod fid $fid"
15015 mknod $ffid c 1 3 && error "mknod $ffid should fail."
15017 fid=[0xf00000400:0x1:0x0]
15018 ffid=$MOUNT/.lustre/fid/$fid
15020 echo "stat non-exist fid $fid"
15021 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
15022 echo "write to non-exist fid $fid"
15023 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
15024 echo "link new fid $fid"
15025 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
15027 mkdir -p $test_dir/$tdir
15028 touch $test_dir/$tdir/$tfile
15029 fid=$($LFS path2fid $test_dir/$tdir)
15032 error "error: could not get fid for $test_dir/$dir/$tfile."
15034 ffid=$MOUNT/.lustre/fid/$fid
15037 ls $ffid > /dev/null || error "ls $ffid failed."
15038 echo "touch $fid/$tfile.1"
15039 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
15041 echo "touch $MOUNT/.lustre/fid/$tfile"
15042 touch $MOUNT/.lustre/fid/$tfile && \
15043 error "touch $MOUNT/.lustre/fid/$tfile should fail."
15045 echo "setxattr to $MOUNT/.lustre/fid"
15046 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
15048 echo "listxattr for $MOUNT/.lustre/fid"
15049 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
15051 echo "delxattr from $MOUNT/.lustre/fid"
15052 setfattr -x trusted.name1 $MOUNT/.lustre/fid
15054 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
15055 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
15056 error "touch invalid fid should fail."
15058 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
15059 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
15060 error "touch non-normal fid should fail."
15062 echo "rename $tdir to $MOUNT/.lustre/fid"
15063 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
15064 error "rename to $MOUNT/.lustre/fid should fail."
15066 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
15068 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
15069 local new_obf_mode=777
15071 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
15072 chmod $new_obf_mode $DIR/.lustre/fid ||
15073 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
15075 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
15076 [ $obf_mode -eq $new_obf_mode ] ||
15077 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
15079 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
15080 chmod $old_obf_mode $DIR/.lustre/fid ||
15081 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
15084 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
15085 fid=$($LFS path2fid $test_dir/$tfile-2)
15087 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
15089 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
15090 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
15091 error "create lov data thru .lustre failed"
15093 echo "cp /etc/passwd $test_dir/$tfile-2"
15094 cp /etc/passwd $test_dir/$tfile-2 ||
15095 error "copy to $test_dir/$tfile-2 failed."
15096 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
15097 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
15098 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
15100 rm -rf $test_dir/tfile.lnk
15101 rm -rf $test_dir/$tfile-2
15105 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15106 skip "Need MDS version at least 2.4.1"
15108 local tf=$DIR/$tfile
15111 local fid=$($LFS path2fid $tf)
15112 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
15114 # check that we get the same pathname back
15117 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
15118 echo "$rootpath $fid"
15119 found=$($LFS fid2path $rootpath "$fid")
15120 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
15121 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
15124 # check wrong root path format
15125 rootpath=$MOUNT"_wrong"
15126 found=$($LFS fid2path $rootpath "$fid")
15127 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
15129 run_test 154A "lfs path2fid and fid2path basic checks"
15132 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15133 skip "Need MDS version at least 2.4.1"
15135 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
15136 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
15137 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
15138 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
15140 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
15141 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
15143 # check that we get the same pathname
15144 echo "PFID: $PFID, name: $name"
15145 local FOUND=$($LFS fid2path $MOUNT "$PFID")
15146 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
15147 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
15148 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
15150 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
15152 run_test 154B "verify the ll_decode_linkea tool"
15155 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15156 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15157 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
15158 skip "Need MDS version at least 2.2.51"
15159 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
15161 cp /etc/hosts $DIR/$tfile
15163 fid=$($LFS path2fid $DIR/$tfile)
15165 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
15167 dot_lustre_fid_permission_check "$fid" $DIR ||
15168 error "dot lustre permission check $fid failed"
15170 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
15172 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
15174 touch $MOUNT/.lustre/file &&
15175 error "creation is not allowed under .lustre"
15177 mkdir $MOUNT/.lustre/dir &&
15178 error "mkdir is not allowed under .lustre"
15182 run_test 154a "Open-by-FID"
15185 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15186 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15187 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15188 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
15189 skip "Need MDS version at least 2.2.51"
15191 local remote_dir=$DIR/$tdir/remote_dir
15195 mkdir -p $DIR/$tdir
15196 $LFS mkdir -i $MDTIDX $remote_dir ||
15197 error "create remote directory failed"
15199 cp /etc/hosts $remote_dir/$tfile
15201 fid=$($LFS path2fid $remote_dir/$tfile)
15203 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
15205 dot_lustre_fid_permission_check "$fid" $remote_dir ||
15206 error "dot lustre permission check $fid failed"
15209 run_test 154b "Open-by-FID for remote directory"
15212 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15213 skip "Need MDS version at least 2.4.1"
15215 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
15216 local FID1=$($LFS path2fid $DIR/$tfile.1)
15217 local FID2=$($LFS path2fid $DIR/$tfile.2)
15218 local FID3=$($LFS path2fid $DIR/$tfile.3)
15221 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
15222 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
15223 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
15225 [ "$FID" = "${!want}" ] ||
15226 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
15230 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
15232 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
15233 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
15237 run_test 154c "lfs path2fid and fid2path multiple arguments"
15240 remote_mds_nodsh && skip "remote MDS with nodsh"
15241 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
15242 skip "Need MDS version at least 2.5.53"
15244 if remote_mds; then
15245 nid=$($LCTL list_nids | sed "s/\./\\\./g")
15249 local proc_ofile="mdt.*.exports.'$nid'.open_files"
15256 local fid=$($LFS path2fid $DIR/$tfile)
15259 cmd="exec $fd<$DIR/$tfile"
15261 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
15262 echo "$fid_list" | grep "$fid"
15265 cmd="exec $fd>/dev/null"
15267 if [ $rc -ne 0 ]; then
15268 error "FID $fid not found in open files list $fid_list"
15271 run_test 154d "Verify open file fid"
15275 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
15276 skip "Need MDS version at least 2.6.50"
15278 if ls -a $MOUNT | grep -q '^\.lustre$'; then
15279 error ".lustre returned by readdir"
15282 run_test 154e ".lustre is not returned by readdir"
15285 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15287 # create parent directory on a single MDT to avoid cross-MDT hardlinks
15288 mkdir_on_mdt0 $DIR/$tdir
15289 # test dirs inherit from its stripe
15290 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
15291 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
15292 cp /etc/hosts $DIR/$tdir/foo1/$tfile
15293 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
15296 # get fid of parents
15297 local FID0=$($LFS path2fid $DIR/$tdir)
15298 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
15299 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
15300 local FID3=$($LFS path2fid $DIR)
15302 # check that path2fid --parents returns expected <parent_fid>/name
15303 # 1) test for a directory (single parent)
15304 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
15305 [ "$parent" == "$FID0/foo1" ] ||
15306 error "expected parent: $FID0/foo1, got: $parent"
15308 # 2) test for a file with nlink > 1 (multiple parents)
15309 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
15310 echo "$parent" | grep -F "$FID1/$tfile" ||
15311 error "$FID1/$tfile not returned in parent list"
15312 echo "$parent" | grep -F "$FID2/link" ||
15313 error "$FID2/link not returned in parent list"
15315 # 3) get parent by fid
15316 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
15317 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15318 echo "$parent" | grep -F "$FID1/$tfile" ||
15319 error "$FID1/$tfile not returned in parent list (by fid)"
15320 echo "$parent" | grep -F "$FID2/link" ||
15321 error "$FID2/link not returned in parent list (by fid)"
15323 # 4) test for entry in root directory
15324 parent=$($LFS path2fid --parents $DIR/f)
15325 echo "$parent" | grep -F "$FID3/f" ||
15326 error "$FID3/f not returned in parent list"
15328 # 5) test it on root directory
15329 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
15330 error "$MOUNT should not have parents"
15332 # enable xattr caching and check that linkea is correctly updated
15333 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
15334 save_lustre_params client "llite.*.xattr_cache" > $save
15335 lctl set_param llite.*.xattr_cache 1
15337 # 6.1) linkea update on rename
15338 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
15340 # get parents by fid
15341 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15342 # foo1 should no longer be returned in parent list
15343 echo "$parent" | grep -F "$FID1" &&
15344 error "$FID1 should no longer be in parent list"
15345 # the new path should appear
15346 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
15347 error "$FID2/$tfile.moved is not in parent list"
15349 # 6.2) linkea update on unlink
15350 rm -f $DIR/$tdir/foo2/link
15351 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15352 # foo2/link should no longer be returned in parent list
15353 echo "$parent" | grep -F "$FID2/link" &&
15354 error "$FID2/link should no longer be in parent list"
15358 restore_lustre_params < $save
15361 run_test 154f "get parent fids by reading link ea"
15365 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15366 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
15367 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
15368 skip "Need MDS version at least 2.6.92"
15370 mkdir_on_mdt0 $DIR/$tdir
15371 llapi_fid_test -d $DIR/$tdir
15373 run_test 154g "various llapi FID tests"
15375 test_155_small_load() {
15376 local temp=$TMP/$tfile
15377 local file=$DIR/$tfile
15379 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
15380 error "dd of=$temp bs=6096 count=1 failed"
15382 cancel_lru_locks $OSC
15383 cmp $temp $file || error "$temp $file differ"
15385 $TRUNCATE $temp 6000
15386 $TRUNCATE $file 6000
15387 cmp $temp $file || error "$temp $file differ (truncate1)"
15389 echo "12345" >>$temp
15390 echo "12345" >>$file
15391 cmp $temp $file || error "$temp $file differ (append1)"
15393 echo "12345" >>$temp
15394 echo "12345" >>$file
15395 cmp $temp $file || error "$temp $file differ (append2)"
15401 test_155_big_load() {
15402 remote_ost_nodsh && skip "remote OST with nodsh"
15404 local temp=$TMP/$tfile
15405 local file=$DIR/$tfile
15408 local cache_size=$(do_facet ost$((MAXI+1)) \
15409 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
15410 local large_file_size=$((cache_size * 2))
15412 echo "OSS cache size: $cache_size KB"
15413 echo "Large file size: $large_file_size KB"
15415 [ $MAXV -le $large_file_size ] &&
15416 skip_env "max available OST size needs > $large_file_size KB"
15418 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
15420 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
15421 error "dd of=$temp bs=$large_file_size count=1k failed"
15424 cancel_lru_locks osc
15425 cmp $temp $file || error "$temp $file differ"
15431 save_writethrough() {
15432 local facets=$(get_facets OST)
15434 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
15438 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15440 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15442 save_writethrough $p
15445 set_cache writethrough on
15446 test_155_small_load
15447 restore_lustre_params < $p
15450 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
15453 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15455 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15457 save_writethrough $p
15460 set_cache writethrough off
15461 test_155_small_load
15462 restore_lustre_params < $p
15465 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
15468 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15470 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15472 save_writethrough $p
15475 set_cache writethrough on
15476 test_155_small_load
15477 restore_lustre_params < $p
15480 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
15483 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15485 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15487 save_writethrough $p
15490 set_cache writethrough off
15491 test_155_small_load
15492 restore_lustre_params < $p
15495 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
15498 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15500 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15502 save_writethrough $p
15505 set_cache writethrough on
15507 restore_lustre_params < $p
15510 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
15513 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15515 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15517 save_writethrough $p
15520 set_cache writethrough off
15522 restore_lustre_params < $p
15525 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
15528 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15530 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15532 save_writethrough $p
15535 set_cache writethrough on
15537 restore_lustre_params < $p
15540 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
15543 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15545 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15547 save_writethrough $p
15550 set_cache writethrough off
15552 restore_lustre_params < $p
15555 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
15558 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15559 remote_ost_nodsh && skip "remote OST with nodsh"
15560 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
15561 skip "stats not implemented on old servers"
15562 [ "$ost1_FSTYPE" = "zfs" ] &&
15563 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
15568 local file="$DIR/$tfile"
15569 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15571 save_writethrough $p
15574 log "Turn on read and write cache"
15576 set_cache writethrough on
15578 log "Write data and read it back."
15579 log "Read should be satisfied from the cache."
15580 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15582 cancel_lru_locks osc
15583 cat $file >/dev/null
15585 if ! let "AFTER - BEFORE == CPAGES"; then
15586 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
15588 log "cache hits: before: $BEFORE, after: $AFTER"
15591 log "Read again; it should be satisfied from the cache."
15593 cancel_lru_locks osc
15594 cat $file >/dev/null
15596 if ! let "AFTER - BEFORE == CPAGES"; then
15597 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
15599 log "cache hits:: before: $BEFORE, after: $AFTER"
15602 log "Turn off the read cache and turn on the write cache"
15604 set_cache writethrough on
15606 log "Read again; it should be satisfied from the cache."
15608 cancel_lru_locks osc
15609 cat $file >/dev/null
15611 if ! let "AFTER - BEFORE == CPAGES"; then
15612 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
15614 log "cache hits:: before: $BEFORE, after: $AFTER"
15617 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
15618 # > 2.12.56 uses pagecache if cached
15619 log "Read again; it should not be satisfied from the cache."
15621 cancel_lru_locks osc
15622 cat $file >/dev/null
15624 if ! let "AFTER - BEFORE == 0"; then
15625 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
15627 log "cache hits:: before: $BEFORE, after: $AFTER"
15631 log "Write data and read it back."
15632 log "Read should be satisfied from the cache."
15633 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15635 cancel_lru_locks osc
15636 cat $file >/dev/null
15638 if ! let "AFTER - BEFORE == CPAGES"; then
15639 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
15641 log "cache hits:: before: $BEFORE, after: $AFTER"
15644 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
15645 # > 2.12.56 uses pagecache if cached
15646 log "Read again; it should not be satisfied from the cache."
15648 cancel_lru_locks osc
15649 cat $file >/dev/null
15651 if ! let "AFTER - BEFORE == 0"; then
15652 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
15654 log "cache hits:: before: $BEFORE, after: $AFTER"
15658 log "Turn off read and write cache"
15660 set_cache writethrough off
15662 log "Write data and read it back"
15663 log "It should not be satisfied from the cache."
15665 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15666 cancel_lru_locks osc
15668 cat $file >/dev/null
15670 if ! let "AFTER - BEFORE == 0"; then
15671 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
15673 log "cache hits:: before: $BEFORE, after: $AFTER"
15676 log "Turn on the read cache and turn off the write cache"
15678 set_cache writethrough off
15680 log "Write data and read it back"
15681 log "It should not be satisfied from the cache."
15683 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15685 cancel_lru_locks osc
15686 cat $file >/dev/null
15688 if ! let "AFTER - BEFORE == 0"; then
15689 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
15691 log "cache hits:: before: $BEFORE, after: $AFTER"
15694 log "Read again; it should be satisfied from the cache."
15696 cancel_lru_locks osc
15697 cat $file >/dev/null
15699 if ! let "AFTER - BEFORE == CPAGES"; then
15700 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
15702 log "cache hits:: before: $BEFORE, after: $AFTER"
15705 restore_lustre_params < $p
15708 run_test 156 "Verification of tunables"
15711 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15712 remote_mds_nodsh && skip "remote MDS with nodsh"
15713 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
15714 skip "Need MDS version at least 2.2.0"
15716 changelog_register || error "changelog_register failed"
15717 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
15718 changelog_users $SINGLEMDS | grep -q $cl_user ||
15719 error "User $cl_user not found in changelog_users"
15721 mkdir_on_mdt0 $DIR/$tdir
15724 test_mkdir -p $DIR/$tdir/pics/2008/zachy
15725 changelog_clear 0 || error "changelog_clear failed"
15726 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
15727 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
15728 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
15729 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
15730 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
15731 rm $DIR/$tdir/pics/desktop.jpg
15733 echo "verifying changelog mask"
15734 changelog_chmask "-MKDIR"
15735 changelog_chmask "-CLOSE"
15737 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
15738 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
15740 changelog_chmask "+MKDIR"
15741 changelog_chmask "+CLOSE"
15743 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
15744 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
15746 MKDIRS=$(changelog_dump | grep -c "MKDIR")
15747 CLOSES=$(changelog_dump | grep -c "CLOSE")
15748 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
15749 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
15752 echo "verifying target fid"
15753 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
15754 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
15755 [ "$fidc" == "$fidf" ] ||
15756 error "changelog '$tfile' fid $fidc != file fid $fidf"
15757 echo "verifying parent fid"
15758 # The FID returned from the Changelog may be the directory shard on
15759 # a different MDT, and not the FID returned by path2fid on the parent.
15760 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
15761 # since this is what will matter when recreating this file in the tree.
15762 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
15763 local pathp=$($LFS fid2path $MOUNT "$fidp")
15764 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
15765 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
15767 echo "getting records for $cl_user"
15768 changelog_users $SINGLEMDS
15769 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
15771 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
15772 error "changelog_clear failed"
15773 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
15774 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
15775 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
15776 error "user index expect $user_rec1 + $nclr != $user_rec2"
15778 local min0_rec=$(changelog_users $SINGLEMDS |
15779 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
15780 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
15781 awk '{ print $1; exit; }')
15783 changelog_dump | tail -n 5
15784 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
15785 [ $first_rec == $((min0_rec + 1)) ] ||
15786 error "first index should be $min0_rec + 1 not $first_rec"
15788 # LU-3446 changelog index reset on MDT restart
15789 local cur_rec1=$(changelog_users $SINGLEMDS |
15790 awk '/^current.index:/ { print $NF }')
15791 changelog_clear 0 ||
15792 error "clear all changelog records for $cl_user failed"
15793 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
15794 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
15795 error "Fail to start $SINGLEMDS"
15796 local cur_rec2=$(changelog_users $SINGLEMDS |
15797 awk '/^current.index:/ { print $NF }')
15798 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
15799 [ $cur_rec1 == $cur_rec2 ] ||
15800 error "current index should be $cur_rec1 not $cur_rec2"
15802 echo "verifying users from this test are deregistered"
15803 changelog_deregister || error "changelog_deregister failed"
15804 changelog_users $SINGLEMDS | grep -q $cl_user &&
15805 error "User '$cl_user' still in changelog_users"
15807 # lctl get_param -n mdd.*.changelog_users
15808 # current_index: 144
15809 # ID index (idle seconds)
15810 # cl3 144 (2) mask=<list>
15811 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
15812 # this is the normal case where all users were deregistered
15813 # make sure no new records are added when no users are present
15814 local last_rec1=$(changelog_users $SINGLEMDS |
15815 awk '/^current.index:/ { print $NF }')
15816 touch $DIR/$tdir/chloe
15817 local last_rec2=$(changelog_users $SINGLEMDS |
15818 awk '/^current.index:/ { print $NF }')
15819 echo "verify changelogs are off: $last_rec1 == $last_rec2"
15820 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
15822 # any changelog users must be leftovers from a previous test
15823 changelog_users $SINGLEMDS
15824 echo "other changelog users; can't verify off"
15827 run_test 160a "changelog sanity"
15829 test_160b() { # LU-3587
15830 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15831 remote_mds_nodsh && skip "remote MDS with nodsh"
15832 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
15833 skip "Need MDS version at least 2.2.0"
15835 changelog_register || error "changelog_register failed"
15836 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
15837 changelog_users $SINGLEMDS | grep -q $cl_user ||
15838 error "User '$cl_user' not found in changelog_users"
15840 local longname1=$(str_repeat a 255)
15841 local longname2=$(str_repeat b 255)
15844 echo "creating very long named file"
15845 touch $longname1 || error "create of '$longname1' failed"
15846 echo "renaming very long named file"
15847 mv $longname1 $longname2
15849 changelog_dump | grep RENME | tail -n 5
15852 run_test 160b "Verify that very long rename doesn't crash in changelog"
15855 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15856 remote_mds_nodsh && skip "remote MDS with nodsh"
15858 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
15859 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
15860 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
15861 skip "Need MDS version at least 2.5.58 or 2.5.2+"
15865 # Registration step
15866 changelog_register || error "changelog_register failed"
15869 mkdir -p $DIR/$tdir
15870 $MCREATE $DIR/$tdir/foo_160c
15871 changelog_chmask "-TRUNC"
15872 $TRUNCATE $DIR/$tdir/foo_160c 200
15873 changelog_chmask "+TRUNC"
15874 $TRUNCATE $DIR/$tdir/foo_160c 199
15875 changelog_dump | tail -n 5
15876 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
15877 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
15879 run_test 160c "verify that changelog log catch the truncate event"
15882 remote_mds_nodsh && skip "remote MDS with nodsh"
15883 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15884 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15885 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
15886 skip "Need MDS version at least 2.7.60"
15888 # Registration step
15889 changelog_register || error "changelog_register failed"
15891 mkdir -p $DIR/$tdir/migrate_dir
15892 changelog_clear 0 || error "changelog_clear failed"
15894 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
15895 changelog_dump | tail -n 5
15896 local migrates=$(changelog_dump | grep -c "MIGRT")
15897 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
15899 run_test 160d "verify that changelog log catch the migrate event"
15902 remote_mds_nodsh && skip "remote MDS with nodsh"
15905 changelog_register || error "changelog_register failed"
15907 local MDT0=$(facet_svc $SINGLEMDS)
15910 # No user (expect fail)
15911 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
15913 if [ $rc -eq 0 ]; then
15914 error "Should fail without user"
15915 elif [ $rc -ne 4 ]; then
15916 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
15919 # Delete a future user (expect fail)
15920 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
15922 if [ $rc -eq 0 ]; then
15923 error "Deleted non-existant user cl77"
15924 elif [ $rc -ne 2 ]; then
15925 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
15928 # Clear to a bad index (1 billion should be safe)
15929 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
15932 if [ $rc -eq 0 ]; then
15933 error "Successfully cleared to invalid CL index"
15934 elif [ $rc -ne 22 ]; then
15935 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
15938 run_test 160e "changelog negative testing (should return errors)"
15941 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15942 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
15943 skip "Need MDS version at least 2.10.56"
15945 local mdts=$(comma_list $(mdts_nodes))
15948 changelog_register || error "first changelog_register failed"
15949 changelog_register || error "second changelog_register failed"
15951 declare -A cl_user1
15952 declare -A cl_user2
15957 # generate some changelog records to accumulate on each MDT
15958 # use all_char because created files should be evenly distributed
15959 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
15960 error "test_mkdir $tdir failed"
15961 log "$(date +%s): creating first files"
15962 for ((i = 0; i < MDSCOUNT * 2; i++)); do
15963 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
15964 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
15967 # check changelogs have been generated
15968 local start=$SECONDS
15969 local idle_time=$((MDSCOUNT * 5 + 5))
15970 local nbcl=$(changelog_dump | wc -l)
15971 [[ $nbcl -eq 0 ]] && error "no changelogs found"
15973 for param in "changelog_max_idle_time=$idle_time" \
15975 "changelog_min_gc_interval=2" \
15976 "changelog_min_free_cat_entries=3"; do
15977 local MDT0=$(facet_svc $SINGLEMDS)
15978 local var="${param%=*}"
15979 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
15981 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
15982 do_nodes $mdts $LCTL set_param mdd.*.$param
15985 # force cl_user2 to be idle (1st part), but also cancel the
15986 # cl_user1 records so that it is not evicted later in the test.
15987 local sleep1=$((idle_time / 2))
15988 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
15991 # simulate changelog catalog almost full
15992 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
15993 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
15995 for i in $(seq $MDSCOUNT); do
15996 cl_users=(${CL_USERS[mds$i]})
15997 cl_user1[mds$i]="${cl_users[0]}"
15998 cl_user2[mds$i]="${cl_users[1]}"
16000 [ -n "${cl_user1[mds$i]}" ] ||
16001 error "mds$i: no user registered"
16002 [ -n "${cl_user2[mds$i]}" ] ||
16003 error "mds$i: only ${cl_user2[mds$i]} is registered"
16005 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16006 [ -n "$user_rec1" ] ||
16007 error "mds$i: User ${cl_user1[mds$i]} not registered"
16008 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16009 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16010 [ -n "$user_rec2" ] ||
16011 error "mds$i: User ${cl_user1[mds$i]} not registered"
16012 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16013 "$user_rec1 + 2 == $user_rec2"
16014 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16015 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16016 "$user_rec1 + 2, but is $user_rec2"
16017 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16018 [ -n "$user_rec2" ] ||
16019 error "mds$i: User ${cl_user2[mds$i]} not registered"
16020 [ $user_rec1 == $user_rec2 ] ||
16021 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16022 "$user_rec1, but is $user_rec2"
16025 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
16026 local sleep2=$((idle_time - (SECONDS - start) + 1))
16027 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
16030 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16031 # cl_user1 should be OK because it recently processed records.
16032 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
16033 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16034 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
16035 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
16038 # ensure gc thread is done
16039 for i in $(mdts_nodes); do
16040 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16041 error "$i: GC-thread not done"
16045 for (( i = 1; i <= MDSCOUNT; i++ )); do
16046 # check cl_user1 still registered
16047 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16048 error "mds$i: User ${cl_user1[mds$i]} not registered"
16049 # check cl_user2 unregistered
16050 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16051 error "mds$i: User ${cl_user2[mds$i]} still registered"
16053 # check changelogs are present and starting at $user_rec1 + 1
16054 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16055 [ -n "$user_rec1" ] ||
16056 error "mds$i: User ${cl_user1[mds$i]} not registered"
16057 first_rec=$($LFS changelog $(facet_svc mds$i) |
16058 awk '{ print $1; exit; }')
16060 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16061 [ $((user_rec1 + 1)) == $first_rec ] ||
16062 error "mds$i: rec $first_rec != $user_rec1 + 1"
16065 run_test 160f "changelog garbage collect (timestamped users)"
16068 remote_mds_nodsh && skip "remote MDS with nodsh"
16069 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16070 skip "Need MDS version at least 2.10.56"
16072 local mdts=$(comma_list $(mdts_nodes))
16074 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
16075 do_nodes $mdts $LCTL set_param fail_loc=0x1314
16078 changelog_register || error "first changelog_register failed"
16079 changelog_register || error "second changelog_register failed"
16081 declare -A cl_user1
16082 declare -A cl_user2
16087 # generate some changelog records to accumulate on each MDT
16088 # use all_char because created files should be evenly distributed
16089 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16090 error "test_mkdir $tdir failed"
16091 for ((i = 0; i < MDSCOUNT; i++)); do
16092 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16093 error "create $DIR/$tdir/d$i.1 failed"
16096 # check changelogs have been generated
16097 local nbcl=$(changelog_dump | wc -l)
16098 (( $nbcl > 0 )) || error "no changelogs found"
16100 # reduce the max_idle_indexes value to make sure we exceed it
16101 for param in "changelog_max_idle_indexes=1" \
16103 "changelog_min_gc_interval=2" \
16104 "changelog_min_free_cat_entries=3"; do
16105 local MDT0=$(facet_svc $SINGLEMDS)
16106 local var="${param%=*}"
16107 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16109 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16110 do_nodes $mdts $LCTL set_param mdd.*.$param ||
16111 error "unable to set mdd.*.$param"
16114 # simulate changelog catalog almost full
16115 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
16116 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
16118 local start=$SECONDS
16119 for i in $(seq $MDSCOUNT); do
16120 cl_users=(${CL_USERS[mds$i]})
16121 cl_user1[mds$i]="${cl_users[0]}"
16122 cl_user2[mds$i]="${cl_users[1]}"
16124 [ -n "${cl_user1[mds$i]}" ] ||
16125 error "mds$i: no user registered"
16126 [ -n "${cl_user2[mds$i]}" ] ||
16127 error "mds$i: only ${cl_user1[mds$i]} is registered"
16129 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16130 [ -n "$user_rec1" ] ||
16131 error "mds$i: User ${cl_user1[mds$i]} not registered"
16132 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16133 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16134 [ -n "$user_rec2" ] ||
16135 error "mds$i: User ${cl_user1[mds$i]} not registered"
16136 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16137 "$user_rec1 + 2 == $user_rec2"
16138 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16139 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16140 "$user_rec1 + 2, but is $user_rec2"
16141 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16142 [ -n "$user_rec2" ] ||
16143 error "mds$i: User ${cl_user2[mds$i]} not registered"
16144 [ $user_rec1 == $user_rec2 ] ||
16145 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16146 "$user_rec1, but is $user_rec2"
16149 # ensure we are past the previous changelog_min_gc_interval set above
16150 local sleep2=$((start + 2 - SECONDS))
16151 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
16153 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16154 # cl_user1 should be OK because it recently processed records.
16155 for ((i = 0; i < MDSCOUNT; i++)); do
16156 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
16157 error "create $DIR/$tdir/d$i.3 failed"
16160 # ensure gc thread is done
16161 for i in $(mdts_nodes); do
16162 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16163 error "$i: GC-thread not done"
16167 for (( i = 1; i <= MDSCOUNT; i++ )); do
16168 # check cl_user1 still registered
16169 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16170 error "mds$i: User ${cl_user1[mds$i]} not registered"
16171 # check cl_user2 unregistered
16172 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16173 error "mds$i: User ${cl_user2[mds$i]} still registered"
16175 # check changelogs are present and starting at $user_rec1 + 1
16176 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16177 [ -n "$user_rec1" ] ||
16178 error "mds$i: User ${cl_user1[mds$i]} not registered"
16179 first_rec=$($LFS changelog $(facet_svc mds$i) |
16180 awk '{ print $1; exit; }')
16182 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16183 [ $((user_rec1 + 1)) == $first_rec ] ||
16184 error "mds$i: rec $first_rec != $user_rec1 + 1"
16187 run_test 160g "changelog garbage collect (old users)"
16190 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16191 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16192 skip "Need MDS version at least 2.10.56"
16194 local mdts=$(comma_list $(mdts_nodes))
16197 changelog_register || error "first changelog_register failed"
16198 changelog_register || error "second changelog_register failed"
16200 declare -A cl_user1
16201 declare -A cl_user2
16206 # generate some changelog records to accumulate on each MDT
16207 # use all_char because created files should be evenly distributed
16208 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16209 error "test_mkdir $tdir failed"
16210 for ((i = 0; i < MDSCOUNT; i++)); do
16211 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16212 error "create $DIR/$tdir/d$i.1 failed"
16215 # check changelogs have been generated
16216 local nbcl=$(changelog_dump | wc -l)
16217 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16219 for param in "changelog_max_idle_time=10" \
16221 "changelog_min_gc_interval=2"; do
16222 local MDT0=$(facet_svc $SINGLEMDS)
16223 local var="${param%=*}"
16224 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16226 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16227 do_nodes $mdts $LCTL set_param mdd.*.$param
16230 # force cl_user2 to be idle (1st part)
16233 for i in $(seq $MDSCOUNT); do
16234 cl_users=(${CL_USERS[mds$i]})
16235 cl_user1[mds$i]="${cl_users[0]}"
16236 cl_user2[mds$i]="${cl_users[1]}"
16238 [ -n "${cl_user1[mds$i]}" ] ||
16239 error "mds$i: no user registered"
16240 [ -n "${cl_user2[mds$i]}" ] ||
16241 error "mds$i: only ${cl_user2[mds$i]} is registered"
16243 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16244 [ -n "$user_rec1" ] ||
16245 error "mds$i: User ${cl_user1[mds$i]} not registered"
16246 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16247 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16248 [ -n "$user_rec2" ] ||
16249 error "mds$i: User ${cl_user1[mds$i]} not registered"
16250 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16251 "$user_rec1 + 2 == $user_rec2"
16252 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16253 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16254 "$user_rec1 + 2, but is $user_rec2"
16255 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16256 [ -n "$user_rec2" ] ||
16257 error "mds$i: User ${cl_user2[mds$i]} not registered"
16258 [ $user_rec1 == $user_rec2 ] ||
16259 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16260 "$user_rec1, but is $user_rec2"
16263 # force cl_user2 to be idle (2nd part) and to reach
16264 # changelog_max_idle_time
16267 # force each GC-thread start and block then
16268 # one per MDT/MDD, set fail_val accordingly
16269 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
16270 do_nodes $mdts $LCTL set_param fail_loc=0x1316
16272 # generate more changelogs to trigger fail_loc
16273 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16274 error "create $DIR/$tdir/${tfile}bis failed"
16276 # stop MDT to stop GC-thread, should be done in back-ground as it will
16277 # block waiting for the thread to be released and exit
16278 declare -A stop_pids
16279 for i in $(seq $MDSCOUNT); do
16281 stop_pids[mds$i]=$!
16284 for i in $(mdts_nodes); do
16287 local facets=$(facets_up_on_host $i)
16289 for facet in ${facets//,/ }; do
16290 if [[ $facet == mds* ]]; then
16294 # ensure each MDS's gc threads are still present and all in "R"
16295 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
16296 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
16297 error "$i: expected $nb GC-thread"
16299 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
16301 error "$i: GC-thread not found in R-state"
16302 # check umounts of each MDT on MDS have reached kthread_stop()
16303 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
16304 error "$i: expected $nb umount"
16306 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
16307 error "$i: umount not found in D-state"
16310 # release all GC-threads
16311 do_nodes $mdts $LCTL set_param fail_loc=0
16313 # wait for MDT stop to complete
16314 for i in $(seq $MDSCOUNT); do
16315 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
16319 # may try to check if any orphan changelog records are present
16320 # via ldiskfs/zfs and llog_reader...
16322 # re-start/mount MDTs
16323 for i in $(seq $MDSCOUNT); do
16324 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
16325 error "Fail to start mds$i"
16329 for i in $(seq $MDSCOUNT); do
16330 # check cl_user1 still registered
16331 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16332 error "mds$i: User ${cl_user1[mds$i]} not registered"
16333 # check cl_user2 unregistered
16334 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16335 error "mds$i: User ${cl_user2[mds$i]} still registered"
16337 # check changelogs are present and starting at $user_rec1 + 1
16338 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16339 [ -n "$user_rec1" ] ||
16340 error "mds$i: User ${cl_user1[mds$i]} not registered"
16341 first_rec=$($LFS changelog $(facet_svc mds$i) |
16342 awk '{ print $1; exit; }')
16344 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
16345 [ $((user_rec1 + 1)) == $first_rec ] ||
16346 error "mds$i: first index should be $user_rec1 + 1, " \
16347 "but is $first_rec"
16350 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
16355 local mdts=$(comma_list $(mdts_nodes))
16357 changelog_register || error "first changelog_register failed"
16359 # generate some changelog records to accumulate on each MDT
16360 # use all_char because created files should be evenly distributed
16361 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16362 error "test_mkdir $tdir failed"
16363 for ((i = 0; i < MDSCOUNT; i++)); do
16364 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16365 error "create $DIR/$tdir/d$i.1 failed"
16368 # check changelogs have been generated
16369 local nbcl=$(changelog_dump | wc -l)
16370 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16372 # simulate race between register and unregister
16373 # XXX as fail_loc is set per-MDS, with DNE configs the race
16374 # simulation will only occur for one MDT per MDS and for the
16375 # others the normal race scenario will take place
16376 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
16377 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
16378 do_nodes $mdts $LCTL set_param fail_val=1
16380 # unregister 1st user
16381 changelog_deregister &
16383 # wait some time for deregister work to reach race rdv
16385 # register 2nd user
16386 changelog_register || error "2nd user register failed"
16388 wait $pid1 || error "1st user deregister failed"
16392 declare -A LAST_REC
16393 for i in $(seq $MDSCOUNT); do
16394 if changelog_users mds$i | grep "^cl"; then
16395 # make sure new records are added with one user present
16396 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
16397 awk '/^current.index:/ { print $NF }')
16399 error "mds$i has no user registered"
16403 # generate more changelog records to accumulate on each MDT
16404 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16405 error "create $DIR/$tdir/${tfile}bis failed"
16407 for i in $(seq $MDSCOUNT); do
16408 last_rec=$(changelog_users $SINGLEMDS |
16409 awk '/^current.index:/ { print $NF }')
16410 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
16411 [ $last_rec != ${LAST_REC[mds$i]} ] ||
16412 error "changelogs are off on mds$i"
16415 run_test 160i "changelog user register/unregister race"
16418 remote_mds_nodsh && skip "remote MDS with nodsh"
16419 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
16420 skip "Need MDS version at least 2.12.56"
16422 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
16423 stack_trap "umount $MOUNT2" EXIT
16425 changelog_register || error "first changelog_register failed"
16426 stack_trap "changelog_deregister" EXIT
16428 # generate some changelog
16429 # use all_char because created files should be evenly distributed
16430 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16431 error "mkdir $tdir failed"
16432 for ((i = 0; i < MDSCOUNT; i++)); do
16433 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16434 error "create $DIR/$tdir/d$i.1 failed"
16437 # open the changelog device
16438 exec 3>/dev/changelog-$FSNAME-MDT0000
16439 stack_trap "exec 3>&-" EXIT
16440 exec 4</dev/changelog-$FSNAME-MDT0000
16441 stack_trap "exec 4<&-" EXIT
16443 # umount the first lustre mount
16445 stack_trap "mount_client $MOUNT" EXIT
16447 # read changelog, which may or may not fail, but should not crash
16451 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16452 changelog_users $SINGLEMDS | grep -q $cl_user ||
16453 error "User $cl_user not found in changelog_users"
16455 printf 'clear:'$cl_user':0' >&3
16457 run_test 160j "client can be umounted while its chanangelog is being used"
16460 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16461 remote_mds_nodsh && skip "remote MDS with nodsh"
16463 mkdir -p $DIR/$tdir/1/1
16465 changelog_register || error "changelog_register failed"
16466 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16468 changelog_users $SINGLEMDS | grep -q $cl_user ||
16469 error "User '$cl_user' not found in changelog_users"
16470 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
16471 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
16472 rmdir $DIR/$tdir/1/1 & sleep 1
16474 touch $DIR/$tdir/2/2
16475 rm -rf $DIR/$tdir/2
16480 changelog_dump | grep rmdir || error "rmdir not recorded"
16482 run_test 160k "Verify that changelog records are not lost"
16484 # Verifies that a file passed as a parameter has recently had an operation
16485 # performed on it that has generated an MTIME changelog which contains the
16486 # correct parent FID. As files might reside on a different MDT from the
16487 # parent directory in DNE configurations, the FIDs are translated to paths
16488 # before being compared, which should be identical
16489 compare_mtime_changelog() {
16497 mdtidx=$($LFS getstripe --mdt-index $file)
16498 mdtidx=$(printf "%04x" $mdtidx)
16500 # Obtain the parent FID from the MTIME changelog
16501 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
16502 [ -z "$mtime" ] && error "MTIME changelog not recorded"
16504 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
16505 [ -z "$cl_fid" ] && error "parent FID not present"
16507 # Verify that the path for the parent FID is the same as the path for
16508 # the test directory
16509 pdir=$($LFS fid2path $MOUNT "$cl_fid")
16513 [[ "${pdir%/}" == "$dir" ]] ||
16514 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
16518 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16520 remote_mds_nodsh && skip "remote MDS with nodsh"
16521 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
16522 skip "Need MDS version at least 2.13.55"
16526 changelog_register || error "changelog_register failed"
16527 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16529 changelog_users $SINGLEMDS | grep -q $cl_user ||
16530 error "User '$cl_user' not found in changelog_users"
16532 # Clear some types so that MTIME changelogs are generated
16533 changelog_chmask "-CREAT"
16534 changelog_chmask "-CLOSE"
16536 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
16538 # Test CL_MTIME during setattr
16539 touch $DIR/$tdir/$tfile
16540 compare_mtime_changelog $DIR/$tdir/$tfile
16542 # Test CL_MTIME during close
16543 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
16544 compare_mtime_changelog $DIR/$tdir/${tfile}_2
16546 run_test 160l "Verify that MTIME changelog records contain the parent FID"
16549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16550 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16551 skip "Need MDS version at least 2.14.51"
16558 changelog_register || error "first changelog_register failed"
16559 changelog_register || error "second changelog_register failed"
16561 cl_users=(${CL_USERS[mds1]})
16562 cl_user1="${cl_users[0]}"
16563 cl_user2="${cl_users[1]}"
16564 # generate some changelog records to accumulate on MDT0
16565 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16566 createmany -m $DIR/$tdir/$tfile 50 ||
16567 error "create $DIR/$tdir/$tfile failed"
16568 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16571 # check changelogs have been generated
16572 local nbcl=$(changelog_dump | wc -l)
16573 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16575 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
16576 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
16578 __changelog_clear mds1 $cl_user1 +10
16579 __changelog_clear mds1 $cl_user2 0 &
16582 __changelog_clear mds1 $cl_user1 0 ||
16583 error "fail to cancel record for $cl_user1"
16585 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
16587 run_test 160m "Changelog clear race"
16590 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16591 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16592 skip "Need MDS version at least 2.14.51"
16601 changelog_register || error "first changelog_register failed"
16603 cl_users=(${CL_USERS[mds1]})
16604 cl_user1="${cl_users[0]}"
16606 # generate some changelog records to accumulate on MDT0
16607 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16608 first_rec=$(changelog_users $SINGLEMDS |
16609 awk '/^current.index:/ { print $NF }')
16610 while (( last_rec < (( first_rec + 65000)) )); do
16611 createmany -m $DIR/$tdir/$tfile 10000 ||
16612 error "create $DIR/$tdir/$tfile failed"
16614 for i in $(seq 0 10000); do
16615 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
16619 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
16620 error "unlinkmany failed unlink"
16621 last_rec=$(changelog_users $SINGLEMDS |
16622 awk '/^current.index:/ { print $NF }')
16623 echo last record $last_rec
16624 (( last_rec == 0 )) && error "no changelog found"
16627 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
16628 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
16630 __changelog_clear mds1 $cl_user1 0 &
16633 __changelog_clear mds1 $cl_user1 0 ||
16634 error "fail to cancel record for $cl_user1"
16636 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
16638 run_test 160n "Changelog destroy race"
16641 local mdt="$(facet_svc $SINGLEMDS)"
16643 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
16644 remote_mds_nodsh && skip "remote MDS with nodsh"
16645 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
16646 skip "Need MDS version at least 2.14.52"
16648 changelog_register --user test_160o -m unlnk+close+open ||
16649 error "changelog_register failed"
16651 do_facet $SINGLEMDS $LCTL --device $mdt \
16652 changelog_register -u "Tt3_-#" &&
16653 error "bad symbols in name should fail"
16655 do_facet $SINGLEMDS $LCTL --device $mdt \
16656 changelog_register -u test_160o &&
16657 error "the same name registration should fail"
16659 do_facet $SINGLEMDS $LCTL --device $mdt \
16660 changelog_register -u test_160toolongname &&
16661 error "too long name registration should fail"
16663 changelog_chmask "MARK+HSM"
16664 lctl get_param mdd.*.changelog*mask
16665 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16666 changelog_users $SINGLEMDS | grep -q $cl_user ||
16667 error "User $cl_user not found in changelog_users"
16669 echo $cl_user | grep -q test_160o ||
16670 error "User $cl_user has no specific name 'test160o'"
16673 changelog_clear 0 || error "changelog_clear failed"
16674 # generate some changelog records to accumulate on MDT0
16675 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16676 touch $DIR/$tdir/$tfile # open 1
16678 OPENS=$(changelog_dump | grep -c "OPEN")
16679 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
16681 # must be no MKDIR it wasn't set as user mask
16682 MKDIR=$(changelog_dump | grep -c "MKDIR")
16683 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
16685 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
16686 mdd.$mdt.changelog_current_mask -n)
16687 # register maskless user
16688 changelog_register || error "changelog_register failed"
16689 # effective mask should be not changed because it is not minimal
16690 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16691 mdd.$mdt.changelog_current_mask -n)
16692 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
16693 # set server mask to minimal value
16694 changelog_chmask "MARK"
16695 # check effective mask again, should be treated as DEFMASK now
16696 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16697 mdd.$mdt.changelog_current_mask -n)
16698 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
16700 do_facet $SINGLEMDS $LCTL --device $mdt \
16701 changelog_deregister -u test_160o ||
16702 error "cannot deregister by name"
16704 run_test 160o "changelog user name and mask"
16707 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16708 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16709 skip "Need MDS version at least 2.14.51"
16710 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
16716 changelog_register || error "first changelog_register failed"
16718 cl_users=(${CL_USERS[mds1]})
16719 cl_user1="${cl_users[0]}"
16721 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16722 createmany -m $DIR/$tdir/$tfile 50 ||
16723 error "create $DIR/$tdir/$tfile failed"
16724 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16727 # check changelogs have been generated
16728 entry_count=$(changelog_dump | wc -l)
16729 ((entry_count != 0)) || error "no changelog entries found"
16731 # remove changelog_users and check that orphan entries are removed
16733 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $(mdsdevname 1)"
16734 start mds1 || error "cannot start mdt"
16735 entry_count=$(changelog_dump | wc -l)
16736 ((entry_count == 0)) ||
16737 error "found $entry_count changelog entries, expected none"
16739 run_test 160p "Changelog orphan cleanup with no users"
16742 local mdt="$(facet_svc $SINGLEMDS)"
16745 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
16746 remote_mds_nodsh && skip "remote MDS with nodsh"
16747 [ $MDS1_VERSION -ge $(version_code 2.14.54) ] ||
16748 skip "Need MDS version at least 2.14.54"
16750 # set server mask to minimal value like server init does
16751 changelog_chmask "MARK"
16752 clu=$(do_facet $SINGLEMDS $LCTL --device $mdt changelog_register -n) ||
16753 error "changelog_register failed"
16754 # check effective mask again, should be treated as DEFMASK now
16755 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16756 mdd.$mdt.changelog_current_mask -n)
16757 do_facet $SINGLEMDS $LCTL --device $mdt changelog_deregister $clu ||
16758 error "changelog_deregister failed"
16759 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
16761 run_test 160q "changelog effective mask is DEFMASK if not set"
16764 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16766 test_mkdir -c1 $DIR/$tdir
16767 cp /etc/hosts $DIR/$tdir/$tfile
16768 test_mkdir -c1 $DIR/$tdir/foo1
16769 test_mkdir -c1 $DIR/$tdir/foo2
16770 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
16771 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
16772 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
16773 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
16774 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
16775 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
16776 $LFS fid2path $DIR $FID
16777 error "bad link ea"
16780 rm $DIR/$tdir/foo2/zachary
16782 rm $DIR/$tdir/foo2/thor
16784 rm $DIR/$tdir/$tfile
16786 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
16787 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
16788 { $LFS fid2path $DIR $FID; error "bad link rename"; }
16789 rm $DIR/$tdir/foo2/maggie
16792 local longname=$tfile.avg_len_is_thirty_two_
16793 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
16794 error_noexit 'failed to unlink many hardlinks'" EXIT
16795 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
16796 error "failed to hardlink many files"
16797 links=$($LFS fid2path $DIR $FID | wc -l)
16798 echo -n "${links}/1000 links in link EA"
16799 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
16801 run_test 161a "link ea sanity"
16804 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16805 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
16808 local remote_dir=$DIR/$tdir/remote_dir
16810 mkdir -p $DIR/$tdir
16811 $LFS mkdir -i $MDTIDX $remote_dir ||
16812 error "create remote directory failed"
16814 cp /etc/hosts $remote_dir/$tfile
16815 mkdir -p $remote_dir/foo1
16816 mkdir -p $remote_dir/foo2
16817 ln $remote_dir/$tfile $remote_dir/foo1/sofia
16818 ln $remote_dir/$tfile $remote_dir/foo2/zachary
16819 ln $remote_dir/$tfile $remote_dir/foo1/luna
16820 ln $remote_dir/$tfile $remote_dir/foo2/thor
16822 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
16824 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
16825 $LFS fid2path $DIR $FID
16826 error "bad link ea"
16829 rm $remote_dir/foo2/zachary
16831 rm $remote_dir/foo2/thor
16833 rm $remote_dir/$tfile
16835 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
16836 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
16837 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
16838 $LFS fid2path $DIR $FID
16839 error "bad link rename"
16841 rm $remote_dir/foo2/maggie
16844 local longname=filename_avg_len_is_thirty_two_
16845 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
16846 error "failed to hardlink many files"
16847 links=$($LFS fid2path $DIR $FID | wc -l)
16848 echo -n "${links}/1000 links in link EA"
16849 [[ ${links} -gt 60 ]] ||
16850 error "expected at least 60 links in link EA"
16851 unlinkmany $remote_dir/foo2/$longname 1000 ||
16852 error "failed to unlink many hardlinks"
16854 run_test 161b "link ea sanity under remote directory"
16857 remote_mds_nodsh && skip "remote MDS with nodsh"
16858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16859 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
16860 skip "Need MDS version at least 2.1.5"
16862 # define CLF_RENAME_LAST 0x0001
16863 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
16864 changelog_register || error "changelog_register failed"
16867 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
16868 touch $DIR/$tdir/foo_161c
16869 touch $DIR/$tdir/bar_161c
16870 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
16871 changelog_dump | grep RENME | tail -n 5
16872 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
16873 changelog_clear 0 || error "changelog_clear failed"
16874 if [ x$flags != "x0x1" ]; then
16875 error "flag $flags is not 0x1"
16878 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
16879 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
16880 touch $DIR/$tdir/foo_161c
16881 touch $DIR/$tdir/bar_161c
16882 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
16883 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
16884 changelog_dump | grep RENME | tail -n 5
16885 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
16886 changelog_clear 0 || error "changelog_clear failed"
16887 if [ x$flags != "x0x0" ]; then
16888 error "flag $flags is not 0x0"
16890 echo "rename overwrite a target having nlink > 1," \
16891 "changelog record has flags of $flags"
16893 # rename doesn't overwrite a target (changelog flag 0x0)
16894 touch $DIR/$tdir/foo_161c
16895 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
16896 changelog_dump | grep RENME | tail -n 5
16897 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
16898 changelog_clear 0 || error "changelog_clear failed"
16899 if [ x$flags != "x0x0" ]; then
16900 error "flag $flags is not 0x0"
16902 echo "rename doesn't overwrite a target," \
16903 "changelog record has flags of $flags"
16905 # define CLF_UNLINK_LAST 0x0001
16906 # unlink a file having nlink = 1 (changelog flag 0x1)
16907 rm -f $DIR/$tdir/foo2_161c
16908 changelog_dump | grep UNLNK | tail -n 5
16909 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
16910 changelog_clear 0 || error "changelog_clear failed"
16911 if [ x$flags != "x0x1" ]; then
16912 error "flag $flags is not 0x1"
16914 echo "unlink a file having nlink = 1," \
16915 "changelog record has flags of $flags"
16917 # unlink a file having nlink > 1 (changelog flag 0x0)
16918 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
16919 rm -f $DIR/$tdir/foobar_161c
16920 changelog_dump | grep UNLNK | tail -n 5
16921 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
16922 changelog_clear 0 || error "changelog_clear failed"
16923 if [ x$flags != "x0x0" ]; then
16924 error "flag $flags is not 0x0"
16926 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
16928 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
16931 remote_mds_nodsh && skip "remote MDS with nodsh"
16932 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
16937 changelog_register || error "changelog_register failed"
16939 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
16940 # interfer with $MOUNT/.lustre/fid/ access
16942 [[ $? -eq 0 ]] || error "mkdir failed"
16944 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
16945 $LCTL set_param fail_loc=0x8000140c
16947 $LCTL set_param fail_val=5
16950 echo foofoo > $DIR/$tdir/$tfile &
16953 # wait for create to be delayed
16957 [[ $? -eq 0 ]] || error "create should be blocked"
16959 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
16960 stack_trap "rm -f $tempfile"
16961 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
16962 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
16963 # some delay may occur during ChangeLog publishing and file read just
16964 # above, that could allow file write to happen finally
16965 [[ -s $tempfile ]] && echo "file should be empty"
16967 $LCTL set_param fail_loc=0
16970 [[ $? -eq 0 ]] || error "create failed"
16972 run_test 161d "create with concurrent .lustre/fid access"
16975 local expected="$1"
16980 path=$($LFS fid2path "$@")
16983 if [ $rc -ne 0 ]; then
16984 error "path looked up of '$expected' failed: rc=$rc"
16985 elif [ "$path" != "$expected" ]; then
16986 error "path looked up '$path' instead of '$expected'"
16988 echo "FID '$fid' resolves to path '$path' as expected"
16992 test_162a() { # was test_162
16993 test_mkdir -p -c1 $DIR/$tdir/d2
16994 touch $DIR/$tdir/d2/$tfile
16995 touch $DIR/$tdir/d2/x1
16996 touch $DIR/$tdir/d2/x2
16997 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
16998 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
17000 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
17001 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
17004 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
17005 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
17006 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
17008 # softlink to wrong file
17009 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
17010 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
17011 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
17014 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
17015 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
17016 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
17017 # fid2path dir/fsname should both work
17018 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
17019 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
17021 # hardlink count: check that there are 2 links
17022 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
17023 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
17025 # hardlink indexing: remove the first link
17026 rm $DIR/$tdir/d2/p/q/r/hlink
17027 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
17029 run_test 162a "path lookup sanity"
17032 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17033 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17036 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17037 error "create striped dir failed"
17039 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
17040 tail -n 1 | awk '{print $2}')
17041 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
17043 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
17044 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
17047 for ((i=0;i<5;i++)); do
17048 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
17049 error "get fid for f$i failed"
17050 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
17052 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
17053 error "get fid for d$i failed"
17054 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
17059 run_test 162b "striped directory path lookup sanity"
17061 # LU-4239: Verify fid2path works with paths 100 or more directories deep
17063 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
17064 skip "Need MDS version at least 2.7.51"
17066 local lpath=$tdir.local
17067 local rpath=$tdir.remote
17069 test_mkdir $DIR/$lpath
17070 test_mkdir $DIR/$rpath
17072 for ((i = 0; i <= 101; i++)); do
17075 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
17076 error "get fid for local directory $DIR/$lpath failed"
17077 check_path "$DIR/$lpath" $MOUNT $FID --link 0
17080 test_mkdir $DIR/$rpath
17081 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
17082 error "get fid for remote directory $DIR/$rpath failed"
17083 check_path "$DIR/$rpath" $MOUNT $FID --link 0
17088 run_test 162c "fid2path works with paths 100 or more directories deep"
17090 oalr_event_count() {
17094 awk -v name="${FSNAME}-OST0000" \
17095 -v event="${event}" \
17096 '$1 == "TRACE" && $2 == event && $3 == name' \
17101 oalr_expect_event_count() {
17104 local expect="${3}"
17107 count=$(oalr_event_count "${event}" "${trace}")
17108 if ((count == expect)); then
17112 error_noexit "${event} event count was '${count}', expected ${expect}"
17118 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
17120 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
17124 sync # Flush previous IOs so we can count log entries.
17125 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
17126 stack_trap cleanup_165 EXIT
17130 local trace="/tmp/${tfile}.trace"
17134 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17135 skip "OFD access log unsupported"
17138 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17141 do_facet ost1 ofd_access_log_reader --list
17144 do_facet ost1 killall -TERM ofd_access_log_reader
17148 if ((rc != 0)); then
17149 error "ofd_access_log_reader exited with rc = '${rc}'"
17152 # Parse trace file for discovery events:
17153 oalr_expect_event_count alr_log_add "${trace}" 1
17154 oalr_expect_event_count alr_log_eof "${trace}" 1
17155 oalr_expect_event_count alr_log_free "${trace}" 1
17157 run_test 165a "ofd access log discovery"
17160 local trace="/tmp/${tfile}.trace"
17161 local file="${DIR}/${tfile}"
17170 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17171 skip "OFD access log unsupported"
17174 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17177 do_facet ost1 ofd_access_log_reader --list
17179 lfs setstripe -c 1 -i 0 "${file}"
17180 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17181 error "cannot create '${file}'"
17184 do_facet ost1 killall -TERM ofd_access_log_reader
17188 if ((rc != 0)); then
17189 error "ofd_access_log_reader exited with rc = '${rc}'"
17192 oalr_expect_event_count alr_log_entry "${trace}" 1
17194 pfid1=$($LFS path2fid "${file}")
17196 # 1 2 3 4 5 6 7 8 9 10
17197 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
17198 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17200 echo "entry = '${entry[*]}'" >&2
17203 if [[ "${pfid1}" != "${pfid2}" ]]; then
17204 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17208 if ((size != 1048576)); then
17209 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
17213 if [[ "${flags}" != "w" ]]; then
17214 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
17217 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17220 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
17221 error "cannot read '${file}'"
17224 do_facet ost1 killall -TERM ofd_access_log_reader
17228 if ((rc != 0)); then
17229 error "ofd_access_log_reader exited with rc = '${rc}'"
17232 oalr_expect_event_count alr_log_entry "${trace}" 1
17234 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17235 echo "entry = '${entry[*]}'" >&2
17238 if [[ "${pfid1}" != "${pfid2}" ]]; then
17239 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17243 if ((size != 524288)); then
17244 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
17248 if [[ "${flags}" != "r" ]]; then
17249 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
17252 run_test 165b "ofd access log entries are produced and consumed"
17255 local trace="/tmp/${tfile}.trace"
17256 local file="${DIR}/${tdir}/${tfile}"
17258 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17259 skip "OFD access log unsupported"
17261 test_mkdir "${DIR}/${tdir}"
17264 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17267 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
17269 # 4096 / 64 = 64. Create twice as many entries.
17270 for ((i = 0; i < 128; i++)); do
17271 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
17272 error "cannot create file"
17277 do_facet ost1 killall -TERM ofd_access_log_reader
17280 if ((rc != 0)); then
17281 error "ofd_access_log_reader exited with rc = '${rc}'"
17284 unlinkmany "${file}-%d" 128
17286 run_test 165c "full ofd access logs do not block IOs"
17288 oal_get_read_count() {
17291 # STATS lustre-OST0001 alr_read_count 1
17293 do_facet ost1 cat "${stats}" |
17294 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
17295 END { print count; }'
17298 oal_expect_read_count() {
17303 # Ask ofd_access_log_reader to write stats.
17304 do_facet ost1 killall -USR1 ofd_access_log_reader
17306 # Allow some time for things to happen.
17309 count=$(oal_get_read_count "${stats}")
17310 if ((count == expect)); then
17314 error_noexit "bad read count, got ${count}, expected ${expect}"
17315 do_facet ost1 cat "${stats}" >&2
17320 local stats="/tmp/${tfile}.stats"
17321 local file="${DIR}/${tdir}/${tfile}"
17322 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
17324 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17325 skip "OFD access log unsupported"
17327 test_mkdir "${DIR}/${tdir}"
17330 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
17333 lfs setstripe -c 1 -i 0 "${file}"
17335 do_facet ost1 lctl set_param "${param}=rw"
17336 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17337 error "cannot create '${file}'"
17338 oal_expect_read_count "${stats}" 1
17340 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17341 error "cannot read '${file}'"
17342 oal_expect_read_count "${stats}" 2
17344 do_facet ost1 lctl set_param "${param}=r"
17345 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17346 error "cannot create '${file}'"
17347 oal_expect_read_count "${stats}" 2
17349 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17350 error "cannot read '${file}'"
17351 oal_expect_read_count "${stats}" 3
17353 do_facet ost1 lctl set_param "${param}=w"
17354 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17355 error "cannot create '${file}'"
17356 oal_expect_read_count "${stats}" 4
17358 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17359 error "cannot read '${file}'"
17360 oal_expect_read_count "${stats}" 4
17362 do_facet ost1 lctl set_param "${param}=0"
17363 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17364 error "cannot create '${file}'"
17365 oal_expect_read_count "${stats}" 4
17367 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17368 error "cannot read '${file}'"
17369 oal_expect_read_count "${stats}" 4
17371 do_facet ost1 killall -TERM ofd_access_log_reader
17374 if ((rc != 0)); then
17375 error "ofd_access_log_reader exited with rc = '${rc}'"
17378 run_test 165d "ofd_access_log mask works"
17381 local stats="/tmp/${tfile}.stats"
17382 local file0="${DIR}/${tdir}-0/${tfile}"
17383 local file1="${DIR}/${tdir}-1/${tfile}"
17385 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17386 skip "OFD access log unsupported"
17388 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
17390 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
17391 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
17393 lfs setstripe -c 1 -i 0 "${file0}"
17394 lfs setstripe -c 1 -i 0 "${file1}"
17397 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
17400 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
17401 error "cannot create '${file0}'"
17403 oal_expect_read_count "${stats}" 0
17405 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
17406 error "cannot create '${file1}'"
17408 oal_expect_read_count "${stats}" 1
17410 do_facet ost1 killall -TERM ofd_access_log_reader
17413 if ((rc != 0)); then
17414 error "ofd_access_log_reader exited with rc = '${rc}'"
17417 run_test 165e "ofd_access_log MDT index filter works"
17420 local trace="/tmp/${tfile}.trace"
17425 do_facet ost1 timeout 60 ofd_access_log_reader \
17426 --exit-on-close --debug=- --trace=- > "${trace}" &
17433 if ((rc != 0)); then
17434 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
17439 run_test 165f "ofd_access_log_reader --exit-on-close works"
17442 # do directio so as not to populate the page cache
17443 log "creating a 10 Mb file"
17444 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
17445 error "multiop failed while creating a file"
17446 log "starting reads"
17447 dd if=$DIR/$tfile of=/dev/null bs=4096 &
17448 log "truncating the file"
17449 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
17450 error "multiop failed while truncating the file"
17452 kill %+ || true # reads might have finished
17453 echo "wait until dd is finished"
17455 log "removing the temporary file"
17456 rm -rf $DIR/$tfile || error "tmp file removal failed"
17458 run_test 169 "parallel read and truncate should not deadlock"
17461 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17463 $LCTL clear # bug 18514
17464 $LCTL debug_daemon start $TMP/${tfile}_log_good
17466 $LCTL debug_daemon stop
17467 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
17468 error "sed failed to read log_good"
17470 $LCTL debug_daemon start $TMP/${tfile}_log_good
17472 $LCTL debug_daemon stop
17474 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
17475 error "lctl df log_bad failed"
17477 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
17478 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
17480 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
17481 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
17483 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
17484 error "bad_line good_line1 good_line2 are empty"
17486 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
17487 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
17488 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
17490 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
17491 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
17492 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
17494 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
17495 error "bad_line_new good_line_new are empty"
17497 local expected_good=$((good_line1 + good_line2*2))
17499 rm -f $TMP/${tfile}*
17500 # LU-231, short malformed line may not be counted into bad lines
17501 if [ $bad_line -ne $bad_line_new ] &&
17502 [ $bad_line -ne $((bad_line_new - 1)) ]; then
17503 error "expected $bad_line bad lines, but got $bad_line_new"
17507 if [ $expected_good -ne $good_line_new ]; then
17508 error "expected $expected_good good lines, but got $good_line_new"
17513 run_test 170 "test lctl df to handle corrupted log ====================="
17515 test_171() { # bug20592
17516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17518 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
17519 $LCTL set_param fail_loc=0x50e
17520 $LCTL set_param fail_val=3000
17521 multiop_bg_pause $DIR/$tfile O_s || true
17523 kill -USR1 $MULTIPID
17527 if dmesg | grep "recursive fault"; then
17528 error "caught a recursive fault"
17530 $LCTL set_param fail_loc=0
17533 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
17535 # it would be good to share it with obdfilter-survey/iokit-libecho code
17536 setup_obdecho_osc () {
17539 local obdfilter_name=$2
17540 echo "Creating new osc for $obdfilter_name on $ost_nid"
17541 # make sure we can find loopback nid
17542 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
17544 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
17545 ${obdfilter_name}_osc_UUID || rc=2; }
17546 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
17547 ${obdfilter_name}_UUID $ost_nid || rc=3; }
17551 cleanup_obdecho_osc () {
17552 local obdfilter_name=$1
17553 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
17554 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
17561 local pages=${3:-64}
17566 local obd_size=$(get_obd_size $node $OBD)
17567 local page_size=$(get_page_size $node)
17568 if [[ -n "$obd_size" ]]; then
17569 local new_count=$((obd_size / (pages * page_size / 1024)))
17570 [[ $new_count -ge $count ]] || count=$new_count
17573 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
17574 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
17576 if [ $rc -eq 0 ]; then
17577 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
17578 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
17580 echo "New object id is $id"
17581 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
17583 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
17584 "test_brw $count w v $pages $id" || rc=4; }
17585 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
17587 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
17588 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
17589 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
17590 { do_facet $node "$LCTL --device ec detach" || rc=6; }
17591 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
17596 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17598 if ! [ -d /sys/fs/lustre/echo_client ] &&
17599 ! module_loaded obdecho; then
17600 load_module obdecho/obdecho &&
17601 stack_trap "rmmod obdecho" EXIT ||
17602 error "unable to load obdecho on client"
17605 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
17606 local host=$($LCTL get_param -n osc.$osc.import |
17607 awk '/current_connection:/ { print $2 }' )
17608 local target=$($LCTL get_param -n osc.$osc.import |
17609 awk '/target:/ { print $2 }' )
17610 target=${target%_UUID}
17612 if [ -n "$target" ]; then
17613 setup_obdecho_osc $host $target &&
17614 stack_trap "cleanup_obdecho_osc $target" EXIT ||
17615 { error "obdecho setup failed with $?"; return; }
17617 obdecho_test ${target}_osc client ||
17618 error "obdecho_test failed on ${target}_osc"
17620 $LCTL get_param osc.$osc.import
17621 error "there is no osc.$osc.import target"
17624 run_test 180a "test obdecho on osc"
17627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17628 remote_ost_nodsh && skip "remote OST with nodsh"
17630 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
17631 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
17632 error "failed to load module obdecho"
17634 local target=$(do_facet ost1 $LCTL dl |
17635 awk '/obdfilter/ { print $4; exit; }')
17637 if [ -n "$target" ]; then
17638 obdecho_test $target ost1 || error "obdecho_test failed with $?"
17640 do_facet ost1 $LCTL dl
17641 error "there is no obdfilter target on ost1"
17644 run_test 180b "test obdecho directly on obdfilter"
17646 test_180c() { # LU-2598
17647 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17648 remote_ost_nodsh && skip "remote OST with nodsh"
17649 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
17650 skip "Need MDS version at least 2.4.0"
17652 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
17653 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
17654 error "failed to load module obdecho"
17656 local target=$(do_facet ost1 $LCTL dl |
17657 awk '/obdfilter/ { print $4; exit; }')
17659 if [ -n "$target" ]; then
17660 local pages=16384 # 64MB bulk I/O RPC size
17662 obdecho_test "$target" ost1 "$pages" ||
17663 error "obdecho_test with pages=$pages failed with $?"
17665 do_facet ost1 $LCTL dl
17666 error "there is no obdfilter target on ost1"
17669 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
17671 test_181() { # bug 22177
17672 test_mkdir $DIR/$tdir
17673 # create enough files to index the directory
17674 createmany -o $DIR/$tdir/foobar 4000
17675 # print attributes for debug purpose
17678 multiop_bg_pause $DIR/$tdir D_Sc || return 1
17680 # remove the files & current working dir
17681 unlinkmany $DIR/$tdir/foobar 4000
17683 kill -USR1 $MULTIPID
17685 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
17688 run_test 181 "Test open-unlinked dir ========================"
17694 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
17696 $LCTL set_param mdc.*.rpc_stats=clear
17698 for (( i = 0; i < $tcount; i++ )) ; do
17699 mkdir $DIR/$tdir/$i
17702 for (( i = 0; i < $tcount; i++ )) ; do
17703 createmany -o $DIR/$tdir/$i/f- $fcount &
17707 for (( i = 0; i < $tcount; i++ )) ; do
17708 unlinkmany $DIR/$tdir/$i/f- $fcount &
17712 $LCTL get_param mdc.*.rpc_stats
17716 run_test 182 "Test parallel modify metadata operations ================"
17718 test_183() { # LU-2275
17719 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17720 remote_mds_nodsh && skip "remote MDS with nodsh"
17721 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
17722 skip "Need MDS version at least 2.3.56"
17724 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
17725 echo aaa > $DIR/$tdir/$tfile
17727 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
17728 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
17730 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
17731 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
17733 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17735 # Flush negative dentry cache
17736 touch $DIR/$tdir/$tfile
17738 # We are not checking for any leaked references here, they'll
17739 # become evident next time we do cleanup with module unload.
17742 run_test 183 "No crash or request leak in case of strange dispositions ========"
17744 # test suite 184 is for LU-2016, LU-2017
17746 check_swap_layouts_support
17748 dir0=$DIR/$tdir/$testnum
17749 test_mkdir -p -c1 $dir0
17754 $LFS setstripe -c1 $file1
17756 $LFS setstripe -c2 $file2
17758 gen1=$($LFS getstripe -g $file1)
17759 gen2=$($LFS getstripe -g $file2)
17761 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
17762 gen=$($LFS getstripe -g $file1)
17763 [[ $gen1 != $gen ]] ||
17764 "Layout generation on $file1 does not change"
17765 gen=$($LFS getstripe -g $file2)
17766 [[ $gen2 != $gen ]] ||
17767 "Layout generation on $file2 does not change"
17769 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
17770 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
17772 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
17774 run_test 184a "Basic layout swap"
17777 check_swap_layouts_support
17779 dir0=$DIR/$tdir/$testnum
17780 mkdir -p $dir0 || error "creating dir $dir0"
17787 $LFS setstripe -c1 $file1
17788 $LFS setstripe -c2 $file2
17789 $LFS setstripe -c1 $file3
17790 chown $RUNAS_ID $file3
17791 gen1=$($LFS getstripe -g $file1)
17792 gen2=$($LFS getstripe -g $file2)
17794 $LFS swap_layouts $dir1 $dir2 &&
17795 error "swap of directories layouts should fail"
17796 $LFS swap_layouts $dir1 $file1 &&
17797 error "swap of directory and file layouts should fail"
17798 $RUNAS $LFS swap_layouts $file1 $file2 &&
17799 error "swap of file we cannot write should fail"
17800 $LFS swap_layouts $file1 $file3 &&
17801 error "swap of file with different owner should fail"
17802 /bin/true # to clear error code
17804 run_test 184b "Forbidden layout swap (will generate errors)"
17807 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
17808 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
17809 check_swap_layouts_support
17810 check_swap_layout_no_dom $DIR
17812 local dir0=$DIR/$tdir/$testnum
17813 mkdir -p $dir0 || error "creating dir $dir0"
17815 local ref1=$dir0/ref1
17816 local ref2=$dir0/ref2
17817 local file1=$dir0/file1
17818 local file2=$dir0/file2
17819 # create a file large enough for the concurrent test
17820 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
17821 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
17822 echo "ref file size: ref1($(stat -c %s $ref1))," \
17823 "ref2($(stat -c %s $ref2))"
17826 dd if=$ref1 of=$file1 bs=16k &
17829 # Make sure dd starts to copy file, but wait at most 5 seconds
17831 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
17833 $LFS swap_layouts $file1 $file2
17836 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
17837 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
17839 # how many bytes copied before swapping layout
17840 local copied=$(stat -c %s $file2)
17841 local remaining=$(stat -c %s $ref1)
17842 remaining=$((remaining - copied))
17843 echo "Copied $copied bytes before swapping layout..."
17845 cmp -n $copied $file1 $ref2 | grep differ &&
17846 error "Content mismatch [0, $copied) of ref2 and file1"
17847 cmp -n $copied $file2 $ref1 ||
17848 error "Content mismatch [0, $copied) of ref1 and file2"
17849 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
17850 error "Content mismatch [$copied, EOF) of ref1 and file1"
17853 rm -f $ref1 $ref2 $file1 $file2
17855 run_test 184c "Concurrent write and layout swap"
17858 check_swap_layouts_support
17859 check_swap_layout_no_dom $DIR
17860 [ -z "$(which getfattr 2>/dev/null)" ] &&
17861 skip_env "no getfattr command"
17863 local file1=$DIR/$tdir/$tfile-1
17864 local file2=$DIR/$tdir/$tfile-2
17865 local file3=$DIR/$tdir/$tfile-3
17869 mkdir -p $DIR/$tdir
17870 touch $file1 || error "create $file1 failed"
17871 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
17872 error "create $file2 failed"
17873 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
17874 error "create $file3 failed"
17875 lovea1=$(get_layout_param $file1)
17877 $LFS swap_layouts $file2 $file3 ||
17878 error "swap $file2 $file3 layouts failed"
17879 $LFS swap_layouts $file1 $file2 ||
17880 error "swap $file1 $file2 layouts failed"
17882 lovea2=$(get_layout_param $file2)
17885 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
17887 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
17888 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
17890 run_test 184d "allow stripeless layouts swap"
17893 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
17894 skip "Need MDS version at least 2.6.94"
17895 check_swap_layouts_support
17896 check_swap_layout_no_dom $DIR
17897 [ -z "$(which getfattr 2>/dev/null)" ] &&
17898 skip_env "no getfattr command"
17900 local file1=$DIR/$tdir/$tfile-1
17901 local file2=$DIR/$tdir/$tfile-2
17902 local file3=$DIR/$tdir/$tfile-3
17905 mkdir -p $DIR/$tdir
17906 touch $file1 || error "create $file1 failed"
17907 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
17908 error "create $file2 failed"
17909 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
17910 error "create $file3 failed"
17912 $LFS swap_layouts $file1 $file2 ||
17913 error "swap $file1 $file2 layouts failed"
17915 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
17916 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
17918 echo 123 > $file1 || error "Should be able to write into $file1"
17920 $LFS swap_layouts $file1 $file3 ||
17921 error "swap $file1 $file3 layouts failed"
17923 echo 123 > $file1 || error "Should be able to write into $file1"
17925 rm -rf $file1 $file2 $file3
17927 run_test 184e "Recreate layout after stripeless layout swaps"
17930 # Create a file with name longer than sizeof(struct stat) ==
17931 # 144 to see if we can get chars from the file name to appear
17932 # in the returned striping. Note that 'f' == 0x66.
17933 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
17935 mkdir -p $DIR/$tdir
17936 mcreate $DIR/$tdir/$file
17937 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
17938 error "IOC_MDC_GETFILEINFO returned garbage striping"
17941 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
17943 test_185() { # LU-2441
17944 # LU-3553 - no volatile file support in old servers
17945 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
17946 skip "Need MDS version at least 2.3.60"
17948 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
17949 touch $DIR/$tdir/spoo
17950 local mtime1=$(stat -c "%Y" $DIR/$tdir)
17951 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
17952 error "cannot create/write a volatile file"
17953 [ "$FILESET" == "" ] &&
17954 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
17955 error "FID is still valid after close"
17957 multiop_bg_pause $DIR/$tdir vVw4096_c
17964 # assume that the next FID for this client is sequential, since stdout
17965 # is unfortunately eaten by multiop_bg_pause
17966 local n=$((${fidv[1]} + 1))
17967 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
17968 if [ "$FILESET" == "" ]; then
17969 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
17970 error "FID is missing before close"
17972 kill -USR1 $multi_pid
17973 # 1 second delay, so if mtime change we will see it
17975 local mtime2=$(stat -c "%Y" $DIR/$tdir)
17976 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
17978 run_test 185 "Volatile file support"
17980 function create_check_volatile() {
17984 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
17987 local FID=$(cat /tmp/${tfile}.fid)
17988 [ "$FID" == "" ] && error "can't get FID for volatile"
17989 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
17990 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
17991 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
17995 cancel_lru_locks mdc # flush opencache
17996 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
18001 # LU-12516 - volatile creation via .lustre
18002 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
18003 skip "Need MDS version at least 2.3.55"
18005 create_check_volatile 0
18006 [ $MDSCOUNT -lt 2 ] && return 0
18009 create_check_volatile 1
18013 run_test 185a "Volatile file creation in .lustre/fid/"
18016 remote_mds_nodsh && skip "remote MDS with nodsh"
18017 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18018 skip "Need MDS version at least 2.3.0"
18020 local dir0=$DIR/$tdir/$testnum
18021 mkdir -p $dir0 || error "creating dir $dir0"
18023 local file=$dir0/file1
18024 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
18025 local dv1=$($LFS data_version $file)
18026 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
18027 local dv2=$($LFS data_version $file)
18028 [[ $dv1 != $dv2 ]] ||
18029 error "data version did not change on write $dv1 == $dv2"
18034 run_test 187a "Test data version change"
18037 remote_mds_nodsh && skip "remote MDS with nodsh"
18038 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18039 skip "Need MDS version at least 2.3.0"
18041 local dir0=$DIR/$tdir/$testnum
18042 mkdir -p $dir0 || error "creating dir $dir0"
18044 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
18045 [[ ${DV[0]} != ${DV[1]} ]] ||
18046 error "data version did not change on write"\
18047 " ${DV[0]} == ${DV[1]}"
18052 run_test 187b "Test data version change on volatile file"
18055 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18056 remote_mgs_nodsh && skip "remote MGS with nodsh"
18057 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
18059 local POOL=${POOL:-cea1}
18060 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
18061 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
18064 local last_ost=$(($OSTCOUNT - 1))
18066 local ost_list=$(seq $first_ost $ost_step $last_ost)
18067 local ost_range="$first_ost $last_ost $ost_step"
18068 local test_path=$POOL_ROOT/$POOL_DIR_NAME
18069 local file_dir=$POOL_ROOT/file_tst
18070 local subdir=$test_path/subdir
18074 # former test_200a test_200b
18075 pool_add $POOL || { rc=$? ; break; }
18076 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
18077 # former test_200c test_200d
18078 mkdir -p $test_path
18079 pool_set_dir $POOL $test_path || { rc=$? ; break; }
18080 pool_check_dir $POOL $test_path || { rc=$? ; break; }
18082 pool_check_dir $POOL $subdir || { rc=$? ; break; }
18083 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
18084 || { rc=$? ; break; }
18085 # former test_200e test_200f
18086 local files=$((OSTCOUNT*3))
18087 pool_alloc_files $POOL $test_path $files "$ost_list" \
18088 || { rc=$? ; break; }
18089 pool_create_files $POOL $file_dir $files "$ost_list" \
18090 || { rc=$? ; break; }
18091 # former test_200g test_200h
18092 pool_lfs_df $POOL || { rc=$? ; break; }
18093 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
18095 # former test_201a test_201b test_201c
18096 pool_remove_first_target $POOL || { rc=$? ; break; }
18098 local f=$test_path/$tfile
18099 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
18100 pool_remove $POOL $f || { rc=$? ; break; }
18108 run_test 200 "OST pools"
18110 # usage: default_attr <count | size | offset>
18112 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
18115 # usage: check_default_stripe_attr
18116 check_default_stripe_attr() {
18117 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
18120 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
18122 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
18126 error "unknown getstripe attr '$1'"
18129 [ $ACTUAL == $EXPECTED ] ||
18130 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
18134 test_mkdir $DIR/$tdir
18135 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
18137 check_default_stripe_attr --stripe-count
18138 check_default_stripe_attr --stripe-size
18139 check_default_stripe_attr --stripe-index
18141 run_test 204a "Print default stripe attributes"
18144 test_mkdir $DIR/$tdir
18145 $LFS setstripe --stripe-count 1 $DIR/$tdir
18147 check_default_stripe_attr --stripe-size
18148 check_default_stripe_attr --stripe-index
18150 run_test 204b "Print default stripe size and offset"
18153 test_mkdir $DIR/$tdir
18154 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18156 check_default_stripe_attr --stripe-count
18157 check_default_stripe_attr --stripe-index
18159 run_test 204c "Print default stripe count and offset"
18162 test_mkdir $DIR/$tdir
18163 $LFS setstripe --stripe-index 0 $DIR/$tdir
18165 check_default_stripe_attr --stripe-count
18166 check_default_stripe_attr --stripe-size
18168 run_test 204d "Print default stripe count and size"
18171 test_mkdir $DIR/$tdir
18172 $LFS setstripe -d $DIR/$tdir
18174 check_default_stripe_attr --stripe-count --raw
18175 check_default_stripe_attr --stripe-size --raw
18176 check_default_stripe_attr --stripe-index --raw
18178 run_test 204e "Print raw stripe attributes"
18181 test_mkdir $DIR/$tdir
18182 $LFS setstripe --stripe-count 1 $DIR/$tdir
18184 check_default_stripe_attr --stripe-size --raw
18185 check_default_stripe_attr --stripe-index --raw
18187 run_test 204f "Print raw stripe size and offset"
18190 test_mkdir $DIR/$tdir
18191 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18193 check_default_stripe_attr --stripe-count --raw
18194 check_default_stripe_attr --stripe-index --raw
18196 run_test 204g "Print raw stripe count and offset"
18199 test_mkdir $DIR/$tdir
18200 $LFS setstripe --stripe-index 0 $DIR/$tdir
18202 check_default_stripe_attr --stripe-count --raw
18203 check_default_stripe_attr --stripe-size --raw
18205 run_test 204h "Print raw stripe count and size"
18207 # Figure out which job scheduler is being used, if any,
18208 # or use a fake one
18209 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
18210 JOBENV=SLURM_JOB_ID
18211 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
18213 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
18215 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
18216 JOBENV=LOADL_STEP_ID
18217 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
18220 $LCTL list_param jobid_name > /dev/null 2>&1
18221 if [ $? -eq 0 ]; then
18227 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
18229 verify_jobstats() {
18234 # we don't really need to clear the stats for this test to work, since each
18235 # command has a unique jobid, but it makes debugging easier if needed.
18236 # for facet in $facets; do
18237 # local dev=$(convert_facet2label $facet)
18238 # # clear old jobstats
18239 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
18242 # use a new JobID for each test, or we might see an old one
18243 [ "$JOBENV" = "FAKE_JOBID" ] &&
18244 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
18246 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
18248 [ "$JOBENV" = "nodelocal" ] && {
18249 FAKE_JOBID=id.$testnum.%e.$RANDOM
18250 $LCTL set_param jobid_name=$FAKE_JOBID
18251 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
18254 log "Test: ${cmd[*]}"
18255 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
18257 if [ $JOBENV = "FAKE_JOBID" ]; then
18258 FAKE_JOBID=$JOBVAL ${cmd[*]}
18263 # all files are created on OST0000
18264 for facet in $facets; do
18265 local stats="*.$(convert_facet2label $facet).job_stats"
18267 # strip out libtool wrappers for in-tree executables
18268 if [ $(do_facet $facet lctl get_param $stats |
18269 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
18270 do_facet $facet lctl get_param $stats
18271 error "No jobstats for $JOBVAL found on $facet::$stats"
18277 local new_jobenv=$1
18279 set_persistent_param_and_check client "jobid_var" \
18280 "$FSNAME.sys.jobid_var" $new_jobenv
18283 test_205a() { # Job stats
18284 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18285 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
18286 skip "Need MDS version with at least 2.7.1"
18287 remote_mgs_nodsh && skip "remote MGS with nodsh"
18288 remote_mds_nodsh && skip "remote MDS with nodsh"
18289 remote_ost_nodsh && skip "remote OST with nodsh"
18290 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
18291 skip "Server doesn't support jobstats"
18292 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
18294 local old_jobenv=$($LCTL get_param -n jobid_var)
18295 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
18297 if [[ $PERM_CMD == *"set_param -P"* ]]; then
18298 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
18300 stack_trap "do_facet mgs $PERM_CMD \
18301 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
18305 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
18306 mdt.*.job_cleanup_interval | head -n 1)
18307 local new_interval=5
18308 do_facet $SINGLEMDS \
18309 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
18310 stack_trap "do_facet $SINGLEMDS \
18311 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
18312 local start=$SECONDS
18316 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
18317 verify_jobstats "$cmd" "$SINGLEMDS"
18319 cmd="rmdir $DIR/$tdir"
18320 verify_jobstats "$cmd" "$SINGLEMDS"
18321 # mkdir on secondary MDT
18322 if [ $MDSCOUNT -gt 1 ]; then
18323 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
18324 verify_jobstats "$cmd" "mds2"
18327 cmd="mknod $DIR/$tfile c 1 3"
18328 verify_jobstats "$cmd" "$SINGLEMDS"
18330 cmd="rm -f $DIR/$tfile"
18331 verify_jobstats "$cmd" "$SINGLEMDS"
18332 # create all files on OST0000 so verify_jobstats can find OST stats
18334 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
18335 verify_jobstats "$cmd" "$SINGLEMDS"
18337 cmd="touch $DIR/$tfile"
18338 verify_jobstats "$cmd" "$SINGLEMDS ost1"
18340 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
18341 verify_jobstats "$cmd" "ost1"
18343 cancel_lru_locks osc
18344 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
18345 verify_jobstats "$cmd" "ost1"
18347 cmd="$TRUNCATE $DIR/$tfile 0"
18348 verify_jobstats "$cmd" "$SINGLEMDS ost1"
18350 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
18351 verify_jobstats "$cmd" "$SINGLEMDS"
18352 # jobstats expiry - sleep until old stats should be expired
18353 local left=$((new_interval + 5 - (SECONDS - start)))
18354 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
18355 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
18357 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
18358 verify_jobstats "$cmd" "$SINGLEMDS"
18359 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
18360 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
18362 # Ensure that jobid are present in changelog (if supported by MDS)
18363 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
18364 changelog_dump | tail -10
18365 jobids=$(changelog_dump | tail -9 | grep -c "j=")
18366 [ $jobids -eq 9 ] ||
18367 error "Wrong changelog jobid count $jobids != 9"
18371 jobstats_set $JOBENV
18373 changelog_dump | grep $tfile
18374 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
18375 [ $jobids -eq 0 ] ||
18376 error "Unexpected jobids when jobid_var=$JOBENV"
18379 # test '%j' access to environment variable - if supported
18380 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
18381 JOBENV="JOBCOMPLEX"
18382 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
18384 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18387 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
18388 JOBENV="JOBCOMPLEX"
18389 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
18391 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18394 # test '%j' access to per-session jobid - if supported
18395 if lctl list_param jobid_this_session > /dev/null 2>&1
18397 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
18398 lctl set_param jobid_this_session=$USER
18400 JOBENV="JOBCOMPLEX"
18401 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
18403 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18406 run_test 205a "Verify job stats"
18408 # LU-13117, LU-13597
18410 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
18411 skip "Need MDS version at least 2.13.54.91"
18413 job_stats="mdt.*.job_stats"
18414 $LCTL set_param $job_stats=clear
18415 # Setting jobid_var to USER might not be supported
18416 $LCTL set_param jobid_var=USER || true
18417 $LCTL set_param jobid_name="%e.%u"
18418 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
18419 do_facet $SINGLEMDS $LCTL get_param $job_stats |
18420 grep "job_id:.*foolish" &&
18421 error "Unexpected jobid found"
18422 do_facet $SINGLEMDS $LCTL get_param $job_stats |
18423 grep "open:.*min.*max.*sum" ||
18424 error "wrong job_stats format found"
18426 run_test 205b "Verify job stats jobid and output format"
18430 $LCTL set_param llite.*.stats=0
18431 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
18432 $LCTL get_param llite.*.stats
18433 $LCTL get_param llite.*.stats | grep \
18434 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
18435 error "wrong client stats format found"
18437 run_test 205c "Verify client stats format"
18439 # LU-1480, LU-1773 and LU-1657
18441 mkdir -p $DIR/$tdir
18442 $LFS setstripe -c -1 $DIR/$tdir
18443 #define OBD_FAIL_LOV_INIT 0x1403
18444 $LCTL set_param fail_loc=0xa0001403
18445 $LCTL set_param fail_val=1
18446 touch $DIR/$tdir/$tfile || true
18448 run_test 206 "fail lov_init_raid0() doesn't lbug"
18451 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
18452 local fsz=`stat -c %s $DIR/$tfile`
18453 cancel_lru_locks mdc
18455 # do not return layout in getattr intent
18456 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
18457 $LCTL set_param fail_loc=0x170
18458 local sz=`stat -c %s $DIR/$tfile`
18460 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
18464 run_test 207a "can refresh layout at glimpse"
18467 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
18468 local cksum=`md5sum $DIR/$tfile`
18469 local fsz=`stat -c %s $DIR/$tfile`
18470 cancel_lru_locks mdc
18471 cancel_lru_locks osc
18473 # do not return layout in getattr intent
18474 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
18475 $LCTL set_param fail_loc=0x171
18477 # it will refresh layout after the file is opened but before read issues
18478 echo checksum is "$cksum"
18479 echo "$cksum" |md5sum -c --quiet || error "file differs"
18483 run_test 207b "can refresh layout at open"
18486 # FIXME: in this test suite, only RD lease is used. This is okay
18487 # for now as only exclusive open is supported. After generic lease
18488 # is done, this test suite should be revised. - Jinshan
18490 remote_mds_nodsh && skip "remote MDS with nodsh"
18491 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
18492 skip "Need MDS version at least 2.4.52"
18494 echo "==== test 1: verify get lease work"
18495 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
18497 echo "==== test 2: verify lease can be broken by upcoming open"
18498 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
18502 $MULTIOP $DIR/$tfile oO_RDWR:c
18503 kill -USR1 $PID && wait $PID || error "break lease error"
18505 echo "==== test 3: verify lease can't be granted if an open already exists"
18506 $MULTIOP $DIR/$tfile oO_RDWR:_c &
18510 $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
18511 kill -USR1 $PID && wait $PID || error "open file error"
18513 echo "==== test 4: lease can sustain over recovery"
18514 $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
18520 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
18522 echo "==== test 5: lease broken can't be regained by replay"
18523 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
18527 # open file to break lease and then recovery
18528 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
18531 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
18535 run_test 208 "Exclusive open"
18538 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
18539 skip_env "must have disp_stripe"
18542 sync; sleep 5; sync;
18544 echo 3 > /proc/sys/vm/drop_caches
18545 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
18546 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
18547 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
18549 # open/close 500 times
18550 for i in $(seq 500); do
18554 echo 3 > /proc/sys/vm/drop_caches
18555 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
18556 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
18557 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
18559 echo "before: $req_before, after: $req_after"
18560 [ $((req_after - req_before)) -ge 300 ] &&
18561 error "open/close requests are not freed"
18564 run_test 209 "read-only open/close requests should be freed promptly"
18569 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
18573 $LFS getstripe $DIR/$tfile
18575 wait $pid || error "multiop failed"
18577 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
18581 $LFS getstripe $DIR/$tfile
18583 wait $pid || error "multiop failed"
18585 run_test 210 "lfs getstripe does not break leases"
18589 size=$((size % 8192 + 1))
18590 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
18591 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
18592 rm -f $DIR/f212 $DIR/f212.xyz
18594 run_test 212 "Sendfile test ============================================"
18597 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
18598 cancel_lru_locks osc
18599 lctl set_param fail_loc=0x8000040f
18600 # generate a read lock
18601 cat $DIR/$tfile > /dev/null
18602 # write to the file, it will try to cancel the above read lock.
18603 cat /etc/hosts >> $DIR/$tfile
18605 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
18607 test_214() { # for bug 20133
18608 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
18609 for (( i=0; i < 340; i++ )) ; do
18610 touch $DIR/$tdir/d214c/a$i
18613 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
18614 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
18615 ls $DIR/d214c || error "ls $DIR/d214c failed"
18616 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
18617 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
18619 run_test 214 "hash-indexed directory test - bug 20133"
18621 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
18622 create_lnet_proc_files() {
18623 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
18626 # counterpart of create_lnet_proc_files
18627 remove_lnet_proc_files() {
18628 rm -f $TMP/lnet_$1.sys
18631 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
18632 # 3rd arg as regexp for body
18633 check_lnet_proc_stats() {
18634 local l=$(cat "$TMP/lnet_$1" |wc -l)
18635 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
18637 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
18640 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
18641 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
18642 # optional and can be regexp for 2nd line (lnet.routes case)
18643 check_lnet_proc_entry() {
18644 local blp=2 # blp stands for 'position of 1st line of body'
18645 [ -z "$5" ] || blp=3 # lnet.routes case
18647 local l=$(cat "$TMP/lnet_$1" |wc -l)
18648 # subtracting one from $blp because the body can be empty
18649 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
18651 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
18652 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
18654 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
18655 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
18657 # bail out if any unexpected line happened
18658 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
18659 [ "$?" != 0 ] || error "$2 misformatted"
18662 test_215() { # for bugs 18102, 21079, 21517
18663 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18665 local N='(0|[1-9][0-9]*)' # non-negative numeric
18666 local P='[1-9][0-9]*' # positive numeric
18667 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
18668 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
18669 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
18670 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
18672 local L1 # regexp for 1st line
18673 local L2 # regexp for 2nd line (optional)
18674 local BR # regexp for the rest (body)
18676 # lnet.stats should look as 11 space-separated non-negative numerics
18677 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
18678 create_lnet_proc_files "stats"
18679 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
18680 remove_lnet_proc_files "stats"
18682 # lnet.routes should look like this:
18683 # Routing disabled/enabled
18684 # net hops priority state router
18685 # where net is a string like tcp0, hops > 0, priority >= 0,
18686 # state is up/down,
18687 # router is a string like 192.168.1.1@tcp2
18688 L1="^Routing (disabled|enabled)$"
18689 L2="^net +hops +priority +state +router$"
18690 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
18691 create_lnet_proc_files "routes"
18692 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
18693 remove_lnet_proc_files "routes"
18695 # lnet.routers should look like this:
18696 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
18697 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
18698 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
18699 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
18700 L1="^ref +rtr_ref +alive +router$"
18701 BR="^$P +$P +(up|down) +$NID$"
18702 create_lnet_proc_files "routers"
18703 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
18704 remove_lnet_proc_files "routers"
18706 # lnet.peers should look like this:
18707 # nid refs state last max rtr min tx min queue
18708 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
18709 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
18710 # numeric (0 or >0 or <0), queue >= 0.
18711 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
18712 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
18713 create_lnet_proc_files "peers"
18714 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
18715 remove_lnet_proc_files "peers"
18717 # lnet.buffers should look like this:
18718 # pages count credits min
18719 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
18720 L1="^pages +count +credits +min$"
18721 BR="^ +$N +$N +$I +$I$"
18722 create_lnet_proc_files "buffers"
18723 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
18724 remove_lnet_proc_files "buffers"
18726 # lnet.nis should look like this:
18727 # nid status alive refs peer rtr max tx min
18728 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
18729 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
18730 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
18731 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
18732 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
18733 create_lnet_proc_files "nis"
18734 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
18735 remove_lnet_proc_files "nis"
18737 # can we successfully write to lnet.stats?
18738 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
18740 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
18742 test_216() { # bug 20317
18743 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18744 remote_ost_nodsh && skip "remote OST with nodsh"
18747 local facets=$(get_facets OST)
18748 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
18750 save_lustre_params client "osc.*.contention_seconds" > $p
18751 save_lustre_params $facets \
18752 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
18753 save_lustre_params $facets \
18754 "ldlm.namespaces.filter-*.contended_locks" >> $p
18755 save_lustre_params $facets \
18756 "ldlm.namespaces.filter-*.contention_seconds" >> $p
18757 clear_stats osc.*.osc_stats
18759 # agressive lockless i/o settings
18760 do_nodes $(comma_list $(osts_nodes)) \
18761 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
18762 ldlm.namespaces.filter-*.contended_locks=0 \
18763 ldlm.namespaces.filter-*.contention_seconds=60"
18764 lctl set_param -n osc.*.contention_seconds=60
18766 $DIRECTIO write $DIR/$tfile 0 10 4096
18767 $CHECKSTAT -s 40960 $DIR/$tfile
18769 # disable lockless i/o
18770 do_nodes $(comma_list $(osts_nodes)) \
18771 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
18772 ldlm.namespaces.filter-*.contended_locks=32 \
18773 ldlm.namespaces.filter-*.contention_seconds=0"
18774 lctl set_param -n osc.*.contention_seconds=0
18775 clear_stats osc.*.osc_stats
18777 dd if=/dev/zero of=$DIR/$tfile count=0
18778 $CHECKSTAT -s 0 $DIR/$tfile
18780 restore_lustre_params <$p
18784 run_test 216 "check lockless direct write updates file size and kms correctly"
18786 test_217() { # bug 22430
18787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18792 for node in $(nodes_list); do
18793 nid=$(host_nids_address $node $NETTYPE)
18794 if [[ $nid = *-* ]] ; then
18795 echo "lctl ping $(h2nettype $nid)"
18796 lctl ping $(h2nettype $nid)
18798 echo "skipping $node (no hyphen detected)"
18802 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
18805 # do directio so as not to populate the page cache
18806 log "creating a 10 Mb file"
18807 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
18808 log "starting reads"
18809 dd if=$DIR/$tfile of=/dev/null bs=4096 &
18810 log "truncating the file"
18811 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
18813 kill %+ || true # reads might have finished
18814 echo "wait until dd is finished"
18816 log "removing the temporary file"
18817 rm -rf $DIR/$tfile || error "tmp file removal failed"
18819 run_test 218 "parallel read and truncate should not deadlock"
18822 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18824 # write one partial page
18825 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
18826 # set no grant so vvp_io_commit_write will do sync write
18827 $LCTL set_param fail_loc=0x411
18828 # write a full page at the end of file
18829 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
18831 $LCTL set_param fail_loc=0
18832 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
18833 $LCTL set_param fail_loc=0x411
18834 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
18837 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
18838 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
18840 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
18842 test_220() { #LU-325
18843 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18844 remote_ost_nodsh && skip "remote OST with nodsh"
18845 remote_mds_nodsh && skip "remote MDS with nodsh"
18846 remote_mgs_nodsh && skip "remote MGS with nodsh"
18850 # create on MDT0000 so the last_id and next_id are correct
18851 mkdir_on_mdt0 $DIR/$tdir
18852 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
18856 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
18857 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
18858 osp.$mdtosc_proc1.prealloc_last_id)
18859 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
18860 osp.$mdtosc_proc1.prealloc_next_id)
18864 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
18865 #define OBD_FAIL_OST_ENOINO 0x229
18866 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
18867 create_pool $FSNAME.$TESTNAME || return 1
18868 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
18870 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
18872 MDSOBJS=$((last_id - next_id))
18873 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
18875 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
18876 echo "OST still has $count kbytes free"
18878 echo "create $MDSOBJS files @next_id..."
18879 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
18881 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
18882 osp.$mdtosc_proc1.prealloc_last_id)
18883 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
18884 osp.$mdtosc_proc1.prealloc_next_id)
18886 echo "after creation, last_id=$last_id2, next_id=$next_id2"
18891 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
18892 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
18894 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
18895 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
18896 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
18897 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
18898 echo "unlink $MDSOBJS files @$next_id..."
18899 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
18901 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
18904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18906 dd if=`which date` of=$MOUNT/date oflag=sync
18907 chmod +x $MOUNT/date
18909 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
18910 $LCTL set_param fail_loc=0x80001401
18912 $MOUNT/date > /dev/null
18915 run_test 221 "make sure fault and truncate race to not cause OOM"
18918 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18921 test_mkdir $DIR/$tdir
18922 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18923 createmany -o $DIR/$tdir/$tfile 10
18924 cancel_lru_locks mdc
18925 cancel_lru_locks osc
18926 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
18927 $LCTL set_param fail_loc=0x31a
18928 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
18929 $LCTL set_param fail_loc=0
18932 run_test 222a "AGL for ls should not trigger CLIO lock failure"
18935 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18938 test_mkdir $DIR/$tdir
18939 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18940 createmany -o $DIR/$tdir/$tfile 10
18941 cancel_lru_locks mdc
18942 cancel_lru_locks osc
18943 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
18944 $LCTL set_param fail_loc=0x31a
18945 rm -r $DIR/$tdir || error "AGL for rmdir failed"
18946 $LCTL set_param fail_loc=0
18948 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
18951 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18954 test_mkdir $DIR/$tdir
18955 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18956 createmany -o $DIR/$tdir/$tfile 10
18957 cancel_lru_locks mdc
18958 cancel_lru_locks osc
18959 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
18960 $LCTL set_param fail_loc=0x31b
18961 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
18962 $LCTL set_param fail_loc=0
18965 run_test 223 "osc reenqueue if without AGL lock granted ======================="
18967 test_224a() { # LU-1039, MRP-303
18968 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18969 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
18970 $LCTL set_param fail_loc=0x508
18971 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fsync
18972 $LCTL set_param fail_loc=0
18975 run_test 224a "Don't panic on bulk IO failure"
18977 test_224bd_sub() { # LU-1039, MRP-303
18978 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18982 dd if=/dev/urandom of=$TMP/$tfile bs=1M count=1
18984 $LFS setstripe -c 1 -i 0 $DIR/$tfile
18986 dd if=$TMP/$tfile of=$DIR/$tfile bs=1M count=1
18987 cancel_lru_locks osc
18989 stack_trap "set_checksums $ORIG_CSUM" EXIT
18990 local at_max_saved=0
18992 # adaptive timeouts may prevent seeing the issue
18993 if at_is_enabled; then
18994 at_max_saved=$(at_max_get mds)
18995 at_max_set 0 mds client
18996 stack_trap "at_max_set $at_max_saved mds client" EXIT
18999 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
19000 do_facet ost1 $LCTL set_param fail_val=$timeout fail_loc=0x80000515
19001 dd of=$TMP/$tfile.new if=$DIR/$tfile bs=1M count=1 || "$@"
19003 do_facet ost1 $LCTL set_param fail_loc=0
19004 cmp $TMP/$tfile $TMP/$tfile.new || error "file contents wrong"
19009 test_224bd_sub 3 error "dd failed"
19011 run_test 224b "Don't panic on bulk IO failure"
19013 test_224c() { # LU-6441
19014 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19015 remote_mds_nodsh && skip "remote MDS with nodsh"
19017 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19018 save_writethrough $p
19019 set_cache writethrough on
19021 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
19022 local at_max=$($LCTL get_param -n at_max)
19023 local timeout=$($LCTL get_param -n timeout)
19024 local test_at="at_max"
19025 local param_at="$FSNAME.sys.at_max"
19026 local test_timeout="timeout"
19027 local param_timeout="$FSNAME.sys.timeout"
19029 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
19031 set_persistent_param_and_check client "$test_at" "$param_at" 0
19032 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
19034 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
19035 do_facet ost1 "$LCTL set_param fail_loc=0x520"
19036 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19037 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
19039 do_facet ost1 "$LCTL set_param fail_loc=0"
19041 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
19042 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
19045 $LCTL set_param -n $pages_per_rpc
19046 restore_lustre_params < $p
19049 run_test 224c "Don't hang if one of md lost during large bulk RPC"
19051 test_224d() { # LU-11169
19052 test_224bd_sub $((TIMEOUT + 2)) error "dd failed"
19054 run_test 224d "Don't corrupt data on bulk IO timeout"
19056 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
19058 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19059 if [ -z ${MDSSURVEY} ]; then
19060 skip_env "mds-survey not found"
19062 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19063 skip "Need MDS version at least 2.2.51"
19065 local mds=$(facet_host $SINGLEMDS)
19066 local target=$(do_nodes $mds 'lctl dl' |
19067 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19069 local cmd1="file_count=1000 thrhi=4"
19070 local cmd2="dir_count=2 layer=mdd stripe_count=0"
19071 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19072 local cmd="$cmd1 $cmd2 $cmd3"
19074 rm -f ${TMP}/mds_survey*
19076 eval $cmd || error "mds-survey with zero-stripe failed"
19077 cat ${TMP}/mds_survey*
19078 rm -f ${TMP}/mds_survey*
19080 run_test 225a "Metadata survey sanity with zero-stripe"
19083 if [ -z ${MDSSURVEY} ]; then
19084 skip_env "mds-survey not found"
19086 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19087 skip "Need MDS version at least 2.2.51"
19088 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19089 remote_mds_nodsh && skip "remote MDS with nodsh"
19090 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
19091 skip_env "Need to mount OST to test"
19094 local mds=$(facet_host $SINGLEMDS)
19095 local target=$(do_nodes $mds 'lctl dl' |
19096 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19098 local cmd1="file_count=1000 thrhi=4"
19099 local cmd2="dir_count=2 layer=mdd stripe_count=1"
19100 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19101 local cmd="$cmd1 $cmd2 $cmd3"
19103 rm -f ${TMP}/mds_survey*
19105 eval $cmd || error "mds-survey with stripe_count failed"
19106 cat ${TMP}/mds_survey*
19107 rm -f ${TMP}/mds_survey*
19109 run_test 225b "Metadata survey sanity with stripe_count = 1"
19111 mcreate_path2fid () {
19117 local path=$DIR/$tdir/$name
19122 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
19123 error "cannot create $desc"
19125 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
19127 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
19129 fid_path=$($LFS fid2path $MOUNT $fid)
19131 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
19133 [ "$path" == "$fid_path" ] ||
19134 error "fid2path returned $fid_path, expected $path"
19136 echo "pass with $path and $fid"
19141 mkdir -p $DIR/$tdir
19143 mcreate_path2fid 0010666 0 0 fifo "FIFO"
19144 mcreate_path2fid 0020666 1 3 null "character special file (null)"
19145 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
19146 mcreate_path2fid 0040666 0 0 dir "directory"
19147 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
19148 mcreate_path2fid 0100666 0 0 file "regular file"
19149 mcreate_path2fid 0120666 0 0 link "symbolic link"
19150 mcreate_path2fid 0140666 0 0 sock "socket"
19152 run_test 226a "call path2fid and fid2path on files of all type"
19155 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19160 mkdir -p $DIR/$tdir
19161 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
19162 error "create remote directory failed"
19163 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
19164 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
19165 "character special file (null)"
19166 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
19167 "character special file (no device)"
19168 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
19169 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
19170 "block special file (loop)"
19171 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
19172 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
19173 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
19175 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
19178 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19179 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
19180 skip "Need MDS version at least 2.13.55"
19182 local submnt=/mnt/submnt
19183 local srcfile=/etc/passwd
19184 local dstfile=$submnt/passwd
19190 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
19191 error "create remote directory failed"
19192 mkdir -p $submnt || error "create $submnt failed"
19193 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
19194 error "mount $submnt failed"
19195 stack_trap "umount $submnt" EXIT
19197 cp $srcfile $dstfile
19198 fid=$($LFS path2fid $dstfile)
19199 path=$($LFS fid2path $submnt "$fid")
19200 [ "$path" = "$dstfile" ] ||
19201 error "fid2path $submnt $fid failed ($path != $dstfile)"
19203 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
19205 # LU-1299 Executing or running ldd on a truncated executable does not
19206 # cause an out-of-memory condition.
19208 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19209 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
19211 dd if=$(which date) of=$MOUNT/date bs=1k count=1
19212 chmod +x $MOUNT/date
19214 $MOUNT/date > /dev/null
19215 ldd $MOUNT/date > /dev/null
19218 run_test 227 "running truncated executable does not cause OOM"
19220 # LU-1512 try to reuse idle OI blocks
19222 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19223 remote_mds_nodsh && skip "remote MDS with nodsh"
19224 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19226 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19227 local myDIR=$DIR/$tdir
19230 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19231 $LCTL set_param fail_loc=0x80001002
19232 createmany -o $myDIR/t- 10000
19233 $LCTL set_param fail_loc=0
19234 # The guard is current the largest FID holder
19236 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19238 local IDX=$(($SEQ % 64))
19240 do_facet $SINGLEMDS sync
19241 # Make sure journal flushed.
19243 local blk1=$(do_facet $SINGLEMDS \
19244 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19245 grep Blockcount | awk '{print $4}')
19247 # Remove old files, some OI blocks will become idle.
19248 unlinkmany $myDIR/t- 10000
19249 # Create new files, idle OI blocks should be reused.
19250 createmany -o $myDIR/t- 2000
19251 do_facet $SINGLEMDS sync
19252 # Make sure journal flushed.
19254 local blk2=$(do_facet $SINGLEMDS \
19255 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19256 grep Blockcount | awk '{print $4}')
19258 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19260 run_test 228a "try to reuse idle OI blocks"
19263 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19264 remote_mds_nodsh && skip "remote MDS with nodsh"
19265 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19267 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19268 local myDIR=$DIR/$tdir
19271 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19272 $LCTL set_param fail_loc=0x80001002
19273 createmany -o $myDIR/t- 10000
19274 $LCTL set_param fail_loc=0
19275 # The guard is current the largest FID holder
19277 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19279 local IDX=$(($SEQ % 64))
19281 do_facet $SINGLEMDS sync
19282 # Make sure journal flushed.
19284 local blk1=$(do_facet $SINGLEMDS \
19285 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19286 grep Blockcount | awk '{print $4}')
19288 # Remove old files, some OI blocks will become idle.
19289 unlinkmany $myDIR/t- 10000
19292 stop $SINGLEMDS || error "Fail to stop MDT."
19294 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
19296 df $MOUNT || error "Fail to df."
19297 # Create new files, idle OI blocks should be reused.
19298 createmany -o $myDIR/t- 2000
19299 do_facet $SINGLEMDS sync
19300 # Make sure journal flushed.
19302 local blk2=$(do_facet $SINGLEMDS \
19303 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19304 grep Blockcount | awk '{print $4}')
19306 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19308 run_test 228b "idle OI blocks can be reused after MDT restart"
19312 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19313 remote_mds_nodsh && skip "remote MDS with nodsh"
19314 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19316 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19317 local myDIR=$DIR/$tdir
19320 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19321 $LCTL set_param fail_loc=0x80001002
19322 # 20000 files can guarantee there are index nodes in the OI file
19323 createmany -o $myDIR/t- 20000
19324 $LCTL set_param fail_loc=0
19325 # The guard is current the largest FID holder
19327 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19329 local IDX=$(($SEQ % 64))
19331 do_facet $SINGLEMDS sync
19332 # Make sure journal flushed.
19334 local blk1=$(do_facet $SINGLEMDS \
19335 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19336 grep Blockcount | awk '{print $4}')
19338 # Remove old files, some OI blocks will become idle.
19339 unlinkmany $myDIR/t- 20000
19341 # The OI file should become empty now
19343 # Create new files, idle OI blocks should be reused.
19344 createmany -o $myDIR/t- 2000
19345 do_facet $SINGLEMDS sync
19346 # Make sure journal flushed.
19348 local blk2=$(do_facet $SINGLEMDS \
19349 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19350 grep Blockcount | awk '{print $4}')
19352 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19354 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
19356 test_229() { # LU-2482, LU-3448
19357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19358 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
19359 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
19360 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
19364 # Create a file with a released layout and stripe count 2.
19365 $MULTIOP $DIR/$tfile H2c ||
19366 error "failed to create file with released layout"
19368 $LFS getstripe -v $DIR/$tfile
19370 local pattern=$($LFS getstripe -L $DIR/$tfile)
19371 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
19373 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
19375 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
19376 stat $DIR/$tfile || error "failed to stat released file"
19378 chown $RUNAS_ID $DIR/$tfile ||
19379 error "chown $RUNAS_ID $DIR/$tfile failed"
19381 chgrp $RUNAS_ID $DIR/$tfile ||
19382 error "chgrp $RUNAS_ID $DIR/$tfile failed"
19384 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
19385 rm $DIR/$tfile || error "failed to remove released file"
19387 run_test 229 "getstripe/stat/rm/attr changes work on released files"
19390 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19391 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19392 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19393 skip "Need MDS version at least 2.11.52"
19397 test_mkdir $DIR/$tdir
19398 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
19399 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
19400 [ $mdt_idx -ne 0 ] &&
19401 error "create local directory on wrong MDT $mdt_idx"
19403 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
19404 error "create remote directory failed"
19405 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
19406 [ $mdt_idx -ne $MDTIDX ] &&
19407 error "create remote directory on wrong MDT $mdt_idx"
19409 createmany -o $DIR/$tdir/test_230/t- 10 ||
19410 error "create files on remote directory failed"
19411 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
19412 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
19413 rm -r $DIR/$tdir || error "unlink remote directory failed"
19415 run_test 230a "Create remote directory and files under the remote directory"
19418 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19419 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19420 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19421 skip "Need MDS version at least 2.11.52"
19429 local migrate_dir=$DIR/$tdir/migrate_dir
19430 local other_dir=$DIR/$tdir/other_dir
19432 test_mkdir $DIR/$tdir
19433 test_mkdir -i0 -c1 $migrate_dir
19434 test_mkdir -i0 -c1 $other_dir
19435 for ((i=0; i<10; i++)); do
19436 mkdir -p $migrate_dir/dir_${i}
19437 createmany -o $migrate_dir/dir_${i}/f 10 ||
19438 error "create files under remote dir failed $i"
19441 cp /etc/passwd $migrate_dir/$tfile
19442 cp /etc/passwd $other_dir/$tfile
19443 chattr +SAD $migrate_dir
19444 chattr +SAD $migrate_dir/$tfile
19446 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19447 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19448 local old_dir_mode=$(stat -c%f $migrate_dir)
19449 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
19451 mkdir -p $migrate_dir/dir_default_stripe2
19452 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
19453 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
19455 mkdir -p $other_dir
19456 ln $migrate_dir/$tfile $other_dir/luna
19457 ln $migrate_dir/$tfile $migrate_dir/sofia
19458 ln $other_dir/$tfile $migrate_dir/david
19459 ln -s $migrate_dir/$tfile $other_dir/zachary
19460 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
19461 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
19467 for len in 58 59 60; do
19468 lnktgt=$(str_repeat 'l' $len)
19469 touch $migrate_dir/$lnktgt
19470 ln -s $lnktgt $migrate_dir/${len}char_ln
19474 for len in 4094 4095; do
19475 lnktgt=$(str_repeat 'l' $len)
19476 ln -s $lnktgt $migrate_dir/${len}char_ln
19480 for len in 254 255; do
19481 touch $migrate_dir/$(str_repeat 'l' $len)
19484 $LFS migrate -m $MDTIDX $migrate_dir ||
19485 error "fails on migrating remote dir to MDT1"
19487 echo "migratate to MDT1, then checking.."
19488 for ((i = 0; i < 10; i++)); do
19489 for file in $(find $migrate_dir/dir_${i}); do
19490 mdt_index=$($LFS getstripe -m $file)
19491 # broken symlink getstripe will fail
19492 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
19493 error "$file is not on MDT${MDTIDX}"
19497 # the multiple link file should still in MDT0
19498 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
19499 [ $mdt_index == 0 ] ||
19500 error "$file is not on MDT${MDTIDX}"
19502 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19503 [ "$old_dir_flag" = "$new_dir_flag" ] ||
19504 error " expect $old_dir_flag get $new_dir_flag"
19506 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19507 [ "$old_file_flag" = "$new_file_flag" ] ||
19508 error " expect $old_file_flag get $new_file_flag"
19510 local new_dir_mode=$(stat -c%f $migrate_dir)
19511 [ "$old_dir_mode" = "$new_dir_mode" ] ||
19512 error "expect mode $old_dir_mode get $new_dir_mode"
19514 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
19515 [ "$old_file_mode" = "$new_file_mode" ] ||
19516 error "expect mode $old_file_mode get $new_file_mode"
19518 diff /etc/passwd $migrate_dir/$tfile ||
19519 error "$tfile different after migration"
19521 diff /etc/passwd $other_dir/luna ||
19522 error "luna different after migration"
19524 diff /etc/passwd $migrate_dir/sofia ||
19525 error "sofia different after migration"
19527 diff /etc/passwd $migrate_dir/david ||
19528 error "david different after migration"
19530 diff /etc/passwd $other_dir/zachary ||
19531 error "zachary different after migration"
19533 diff /etc/passwd $migrate_dir/${tfile}_ln ||
19534 error "${tfile}_ln different after migration"
19536 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
19537 error "${tfile}_ln_other different after migration"
19539 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
19540 [ $stripe_count = 2 ] ||
19541 error "dir strpe_count $d != 2 after migration."
19543 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
19544 [ $stripe_count = 2 ] ||
19545 error "file strpe_count $d != 2 after migration."
19547 #migrate back to MDT0
19550 $LFS migrate -m $MDTIDX $migrate_dir ||
19551 error "fails on migrating remote dir to MDT0"
19553 echo "migrate back to MDT0, checking.."
19554 for file in $(find $migrate_dir); do
19555 mdt_index=$($LFS getstripe -m $file)
19556 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
19557 error "$file is not on MDT${MDTIDX}"
19560 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19561 [ "$old_dir_flag" = "$new_dir_flag" ] ||
19562 error " expect $old_dir_flag get $new_dir_flag"
19564 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19565 [ "$old_file_flag" = "$new_file_flag" ] ||
19566 error " expect $old_file_flag get $new_file_flag"
19568 local new_dir_mode=$(stat -c%f $migrate_dir)
19569 [ "$old_dir_mode" = "$new_dir_mode" ] ||
19570 error "expect mode $old_dir_mode get $new_dir_mode"
19572 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
19573 [ "$old_file_mode" = "$new_file_mode" ] ||
19574 error "expect mode $old_file_mode get $new_file_mode"
19576 diff /etc/passwd ${migrate_dir}/$tfile ||
19577 error "$tfile different after migration"
19579 diff /etc/passwd ${other_dir}/luna ||
19580 error "luna different after migration"
19582 diff /etc/passwd ${migrate_dir}/sofia ||
19583 error "sofia different after migration"
19585 diff /etc/passwd ${other_dir}/zachary ||
19586 error "zachary different after migration"
19588 diff /etc/passwd $migrate_dir/${tfile}_ln ||
19589 error "${tfile}_ln different after migration"
19591 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
19592 error "${tfile}_ln_other different after migration"
19594 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
19595 [ $stripe_count = 2 ] ||
19596 error "dir strpe_count $d != 2 after migration."
19598 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
19599 [ $stripe_count = 2 ] ||
19600 error "file strpe_count $d != 2 after migration."
19602 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19604 run_test 230b "migrate directory"
19607 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19608 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19609 remote_mds_nodsh && skip "remote MDS with nodsh"
19610 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19611 skip "Need MDS version at least 2.11.52"
19617 local migrate_dir=$DIR/$tdir/migrate_dir
19619 #If migrating directory fails in the middle, all entries of
19620 #the directory is still accessiable.
19621 test_mkdir $DIR/$tdir
19622 test_mkdir -i0 -c1 $migrate_dir
19623 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
19625 createmany -o $migrate_dir/f $total ||
19626 error "create files under ${migrate_dir} failed"
19628 # fail after migrating top dir, and this will fail only once, so the
19629 # first sub file migration will fail (currently f3), others succeed.
19630 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
19631 do_facet mds1 lctl set_param fail_loc=0x1801
19632 local t=$(ls $migrate_dir | wc -l)
19633 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
19634 error "migrate should fail"
19635 local u=$(ls $migrate_dir | wc -l)
19636 [ "$u" == "$t" ] || error "$u != $t during migration"
19638 # add new dir/file should succeed
19639 mkdir $migrate_dir/dir ||
19640 error "mkdir failed under migrating directory"
19641 touch $migrate_dir/file ||
19642 error "create file failed under migrating directory"
19644 # add file with existing name should fail
19645 for file in $migrate_dir/f*; do
19646 stat $file > /dev/null || error "stat $file failed"
19647 $OPENFILE -f O_CREAT:O_EXCL $file &&
19648 error "open(O_CREAT|O_EXCL) $file should fail"
19649 $MULTIOP $file m && error "create $file should fail"
19650 touch $DIR/$tdir/remote_dir/$tfile ||
19651 error "touch $tfile failed"
19652 ln $DIR/$tdir/remote_dir/$tfile $file &&
19653 error "link $file should fail"
19654 mdt_index=$($LFS getstripe -m $file)
19655 if [ $mdt_index == 0 ]; then
19656 # file failed to migrate is not allowed to rename to
19657 mv $DIR/$tdir/remote_dir/$tfile $file &&
19658 error "rename to $file should fail"
19660 mv $DIR/$tdir/remote_dir/$tfile $file ||
19661 error "rename to $file failed"
19663 echo hello >> $file || error "write $file failed"
19666 # resume migration with different options should fail
19667 $LFS migrate -m 0 $migrate_dir &&
19668 error "migrate -m 0 $migrate_dir should fail"
19670 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
19671 error "migrate -c 2 $migrate_dir should fail"
19673 # resume migration should succeed
19674 $LFS migrate -m $MDTIDX $migrate_dir ||
19675 error "migrate $migrate_dir failed"
19677 echo "Finish migration, then checking.."
19678 for file in $(find $migrate_dir); do
19679 mdt_index=$($LFS getstripe -m $file)
19680 [ $mdt_index == $MDTIDX ] ||
19681 error "$file is not on MDT${MDTIDX}"
19684 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19686 run_test 230c "check directory accessiblity if migration failed"
19689 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19690 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19691 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19692 skip "Need MDS version at least 2.11.52"
19694 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
19696 local migrate_dir=$DIR/$tdir/migrate_dir
19706 old_index=$((RANDOM % MDSCOUNT))
19707 old_count=$((MDSCOUNT - old_index))
19708 new_index=$((RANDOM % MDSCOUNT))
19709 new_count=$((MDSCOUNT - new_index))
19710 new_hash=1 # for all_char
19712 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
19713 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
19715 test_mkdir $DIR/$tdir
19716 test_mkdir -i $old_index -c $old_count $migrate_dir
19718 for ((i=0; i<100; i++)); do
19719 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
19720 createmany -o $migrate_dir/dir_${i}/f 100 ||
19721 error "create files under remote dir failed $i"
19724 echo -n "Migrate from MDT$old_index "
19725 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
19726 echo -n "to MDT$new_index"
19727 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
19730 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
19731 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
19732 error "migrate remote dir error"
19734 echo "Finish migration, then checking.."
19735 for file in $(find $migrate_dir -maxdepth 1); do
19736 mdt_index=$($LFS getstripe -m $file)
19737 if [ $mdt_index -lt $new_index ] ||
19738 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
19739 error "$file is on MDT$mdt_index"
19743 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19745 run_test 230d "check migrate big directory"
19748 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19749 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19750 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19751 skip "Need MDS version at least 2.11.52"
19758 mkdir_on_mdt0 $DIR/$tdir
19759 mkdir $DIR/$tdir/migrate_dir
19760 mkdir $DIR/$tdir/other_dir
19761 touch $DIR/$tdir/migrate_dir/a
19762 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
19763 ls $DIR/$tdir/other_dir
19765 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
19766 error "migrate dir fails"
19768 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
19769 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
19771 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19772 [ $mdt_index == 0 ] || error "a is not on MDT0"
19774 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
19775 error "migrate dir fails"
19777 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
19778 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
19780 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19781 [ $mdt_index == 1 ] || error "a is not on MDT1"
19783 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
19784 [ $mdt_index == 1 ] || error "b is not on MDT1"
19786 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
19787 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
19789 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
19791 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19793 run_test 230e "migrate mulitple local link files"
19796 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19797 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19798 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19799 skip "Need MDS version at least 2.11.52"
19804 mkdir -p $DIR/$tdir
19805 mkdir $DIR/$tdir/migrate_dir
19806 $LFS mkdir -i1 $DIR/$tdir/other_dir
19807 touch $DIR/$tdir/migrate_dir/a
19808 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
19809 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
19810 ls $DIR/$tdir/other_dir
19812 # a should be migrated to MDT1, since no other links on MDT0
19813 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
19814 error "#1 migrate dir fails"
19815 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
19816 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
19817 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19818 [ $mdt_index == 1 ] || error "a is not on MDT1"
19820 # a should stay on MDT1, because it is a mulitple link file
19821 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
19822 error "#2 migrate dir fails"
19823 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19824 [ $mdt_index == 1 ] || error "a is not on MDT1"
19826 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
19827 error "#3 migrate dir fails"
19829 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
19830 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
19831 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
19833 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
19834 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
19836 # a should be migrated to MDT0, since no other links on MDT1
19837 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
19838 error "#4 migrate dir fails"
19839 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19840 [ $mdt_index == 0 ] || error "a is not on MDT0"
19842 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19844 run_test 230f "migrate mulitple remote link files"
19847 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19848 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19849 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19850 skip "Need MDS version at least 2.11.52"
19852 mkdir -p $DIR/$tdir/migrate_dir
19854 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
19855 error "migrating dir to non-exist MDT succeeds"
19858 run_test 230g "migrate dir to non-exist MDT"
19861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19862 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19863 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19864 skip "Need MDS version at least 2.11.52"
19868 mkdir -p $DIR/$tdir/migrate_dir
19870 $LFS migrate -m1 $DIR &&
19871 error "migrating mountpoint1 should fail"
19873 $LFS migrate -m1 $DIR/$tdir/.. &&
19874 error "migrating mountpoint2 should fail"
19877 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
19878 error "migrating $tdir/migrate_dir/.. should fail"
19882 run_test 230h "migrate .. and root"
19885 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19886 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19887 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19888 skip "Need MDS version at least 2.11.52"
19890 mkdir -p $DIR/$tdir/migrate_dir
19892 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
19893 error "migration fails with a tailing slash"
19895 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
19896 error "migration fails with two tailing slashes"
19898 run_test 230i "lfs migrate -m tolerates trailing slashes"
19901 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19902 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
19903 skip "Need MDS version at least 2.11.52"
19905 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
19906 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
19907 error "create $tfile failed"
19908 cat /etc/passwd > $DIR/$tdir/$tfile
19910 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
19912 cmp /etc/passwd $DIR/$tdir/$tfile ||
19913 error "DoM file mismatch after migration"
19915 run_test 230j "DoM file data not changed after dir migration"
19918 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
19919 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
19920 skip "Need MDS version at least 2.11.56"
19923 local files_on_starting_mdt=0
19925 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
19926 $LFS getdirstripe $DIR/$tdir
19927 for i in $(seq $total); do
19928 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
19929 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
19930 files_on_starting_mdt=$((files_on_starting_mdt + 1))
19933 echo "$files_on_starting_mdt files on MDT0"
19935 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
19936 $LFS getdirstripe $DIR/$tdir
19938 files_on_starting_mdt=0
19939 for i in $(seq $total); do
19940 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
19941 error "file $tfile.$i mismatch after migration"
19942 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
19943 files_on_starting_mdt=$((files_on_starting_mdt + 1))
19946 echo "$files_on_starting_mdt files on MDT1 after migration"
19947 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
19949 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
19950 $LFS getdirstripe $DIR/$tdir
19952 files_on_starting_mdt=0
19953 for i in $(seq $total); do
19954 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
19955 error "file $tfile.$i mismatch after 2nd migration"
19956 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
19957 files_on_starting_mdt=$((files_on_starting_mdt + 1))
19960 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
19961 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
19965 run_test 230k "file data not changed after dir migration"
19968 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19969 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
19970 skip "Need MDS version at least 2.11.56"
19972 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
19973 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
19974 error "create files under remote dir failed $i"
19975 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
19977 run_test 230l "readdir between MDTs won't crash"
19980 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19981 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
19982 skip "Need MDS version at least 2.11.56"
19985 local mig_dir=$DIR/$tdir/migrate_dir
19986 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
19990 echo "Creating files and dirs with xattrs"
19991 test_mkdir $DIR/$tdir
19992 test_mkdir -i0 -c1 $mig_dir
19994 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
19995 error "cannot set xattr attr1 on dir"
19996 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
19997 error "cannot set xattr attr2 on dir"
19998 touch $mig_dir/dir/f0
19999 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
20000 error "cannot set xattr attr1 on file"
20001 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
20002 error "cannot set xattr attr2 on file"
20003 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20004 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20005 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
20006 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20007 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
20008 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20009 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
20010 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20011 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
20013 echo "Migrating to MDT1"
20014 $LFS migrate -m $MDTIDX $mig_dir ||
20015 error "fails on migrating dir to MDT1"
20017 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20018 echo "Checking xattrs"
20019 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20020 [ "$val" = $longstr ] ||
20021 error "expecting xattr1 $longstr on dir, found $val"
20022 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20023 [ "$val" = $shortstr ] ||
20024 error "expecting xattr2 $shortstr on dir, found $val"
20025 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20026 [ "$val" = $longstr ] ||
20027 error "expecting xattr1 $longstr on file, found $val"
20028 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20029 [ "$val" = $shortstr ] ||
20030 error "expecting xattr2 $shortstr on file, found $val"
20032 run_test 230m "xattrs not changed after dir migration"
20035 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20036 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
20037 skip "Need MDS version at least 2.13.53"
20039 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
20040 cat /etc/hosts > $DIR/$tdir/$tfile
20041 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
20042 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
20044 cmp /etc/hosts $DIR/$tdir/$tfile ||
20045 error "File data mismatch after migration"
20047 run_test 230n "Dir migration with mirrored file"
20050 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
20051 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
20052 skip "Need MDS version at least 2.13.52"
20054 local mdts=$(comma_list $(mdts_nodes))
20056 local restripe_status
20060 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20062 # in case "crush" hash type is not set
20063 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20065 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20066 mdt.*MDT0000.enable_dir_restripe)
20067 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20068 stack_trap "do_nodes $mdts $LCTL set_param \
20069 mdt.*.enable_dir_restripe=$restripe_status"
20072 createmany -m $DIR/$tdir/f 100 ||
20073 error "create files under remote dir failed $i"
20074 createmany -d $DIR/$tdir/d 100 ||
20075 error "create dirs under remote dir failed $i"
20077 for i in $(seq 2 $MDSCOUNT); do
20078 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20079 $LFS setdirstripe -c $i $DIR/$tdir ||
20080 error "split -c $i $tdir failed"
20081 wait_update $HOSTNAME \
20082 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
20083 error "dir split not finished"
20084 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20085 awk '/migrate/ {sum += $2} END { print sum }')
20086 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
20087 # delta is around total_files/stripe_count
20088 (( $delta < 200 / (i - 1) + 4 )) ||
20089 error "$delta files migrated >= $((200 / (i - 1) + 4))"
20092 run_test 230o "dir split"
20095 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
20096 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20097 skip "Need MDS version at least 2.13.52"
20099 local mdts=$(comma_list $(mdts_nodes))
20101 local restripe_status
20105 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20107 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20109 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20110 mdt.*MDT0000.enable_dir_restripe)
20111 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20112 stack_trap "do_nodes $mdts $LCTL set_param \
20113 mdt.*.enable_dir_restripe=$restripe_status"
20115 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
20116 createmany -m $DIR/$tdir/f 100 ||
20117 error "create files under remote dir failed"
20118 createmany -d $DIR/$tdir/d 100 ||
20119 error "create dirs under remote dir failed"
20121 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
20122 local mdt_hash="crush"
20124 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20125 $LFS setdirstripe -c $c $DIR/$tdir ||
20126 error "split -c $c $tdir failed"
20127 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
20128 mdt_hash="$mdt_hash,fixed"
20129 elif [ $c -eq 1 ]; then
20132 wait_update $HOSTNAME \
20133 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
20134 error "dir merge not finished"
20135 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20136 awk '/migrate/ {sum += $2} END { print sum }')
20137 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
20138 # delta is around total_files/stripe_count
20139 (( delta < 200 / c + 4 )) ||
20140 error "$delta files migrated >= $((200 / c + 4))"
20143 run_test 230p "dir merge"
20146 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
20147 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20148 skip "Need MDS version at least 2.13.52"
20150 local mdts=$(comma_list $(mdts_nodes))
20151 local saved_threshold=$(do_facet mds1 \
20152 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
20153 local saved_delta=$(do_facet mds1 \
20154 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
20155 local threshold=100
20158 local stripe_count=0
20163 # test with fewer files on ZFS
20164 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
20166 stack_trap "do_nodes $mdts $LCTL set_param \
20167 mdt.*.dir_split_count=$saved_threshold"
20168 stack_trap "do_nodes $mdts $LCTL set_param \
20169 mdt.*.dir_split_delta=$saved_delta"
20170 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
20171 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
20172 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
20173 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
20174 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
20175 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20177 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20178 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20180 create=$((threshold * 3 / 2))
20181 while [ $stripe_count -lt $MDSCOUNT ]; do
20182 createmany -m $DIR/$tdir/f $total $create ||
20183 error "create sub files failed"
20184 stat $DIR/$tdir > /dev/null
20185 total=$((total + create))
20186 stripe_count=$((stripe_count + delta))
20187 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
20189 wait_update $HOSTNAME \
20190 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
20191 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
20193 wait_update $HOSTNAME \
20194 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
20195 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
20197 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
20198 echo "$nr_files/$total files on MDT$stripe_index after split"
20199 # allow 10% margin of imbalance with crush hash
20200 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
20201 error "$nr_files files on MDT$stripe_index after split"
20203 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
20204 [ $nr_files -eq $total ] ||
20205 error "total sub files $nr_files != $total"
20208 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
20210 echo "fixed layout directory won't auto split"
20211 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
20212 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
20213 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
20214 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
20215 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
20217 run_test 230q "dir auto split"
20220 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
20221 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20222 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
20223 skip "Need MDS version at least 2.13.54"
20225 # maximum amount of local locks:
20226 # parent striped dir - 2 locks
20227 # new stripe in parent to migrate to - 1 lock
20228 # source and target - 2 locks
20229 # Total 5 locks for regular file
20230 mkdir -p $DIR/$tdir
20231 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
20232 touch $DIR/$tdir/dir1/eee
20234 # create 4 hardlink for 4 more locks
20235 # Total: 9 locks > RS_MAX_LOCKS (8)
20236 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
20237 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
20238 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
20239 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
20240 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
20241 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
20242 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
20243 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
20245 cancel_lru_locks mdc
20247 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
20248 error "migrate dir fails"
20250 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20252 run_test 230r "migrate with too many local locks"
20255 [ $MDS1_VERSION -ge $(version_code 2.13.57) ] ||
20256 skip "Need MDS version at least 2.13.57"
20258 local mdts=$(comma_list $(mdts_nodes))
20259 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
20260 mdt.*MDT0000.enable_dir_restripe)
20262 stack_trap "do_nodes $mdts $LCTL set_param \
20263 mdt.*.enable_dir_restripe=$restripe_status"
20267 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
20268 test_mkdir $DIR/$tdir
20269 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
20270 error "$LFS mkdir doesn't return -EEXIST if target exists"
20274 run_test 230s "lfs mkdir should return -EEXIST if target exists"
20278 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20279 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
20280 skip "Need MDS version at least 2.14.50"
20282 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
20283 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
20284 $LFS project -p 1 -s $DIR/$tdir ||
20285 error "set $tdir project id failed"
20286 $LFS project -p 2 -s $DIR/$tdir/subdir ||
20287 error "set subdir project id failed"
20288 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
20290 run_test 230t "migrate directory with project ID set"
20294 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
20295 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20296 skip "Need MDS version at least 2.14.53"
20300 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
20301 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
20302 $LFS migrate -m -1 $DIR/$tdir/sub{0..99} || error "migrate sub failed"
20303 for i in $(seq 0 $((MDSCOUNT - 1))); do
20304 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
20305 echo "$count dirs migrated to MDT$i"
20307 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
20308 (( count >= MDSCOUNT - 1 )) || error "dirs migrated to $count MDTs"
20310 run_test 230u "migrate directory by QOS"
20314 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
20315 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20316 skip "Need MDS version at least 2.14.53"
20320 mkdir $DIR/$tdir || error "mkdir $tdir failed"
20321 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
20322 $LFS migrate -m 0,2,1 $DIR/$tdir || error "migrate $tdir failed"
20323 for i in $(seq 0 $((MDSCOUNT - 1))); do
20324 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
20325 echo "$count subdirs migrated to MDT$i"
20326 (( i == 3 )) && (( count > 0 )) &&
20327 error "subdir shouldn't be migrated to MDT3"
20329 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
20330 (( count == 3 )) || error "dirs migrated to $count MDTs"
20332 run_test 230v "subdir migrated to the MDT where its parent is located"
20336 # For simplicity this test assumes that max_pages_per_rpc
20337 # is the same across all OSCs
20338 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
20339 local bulk_size=$((max_pages * PAGE_SIZE))
20340 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
20343 mkdir -p $DIR/$tdir
20344 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
20345 error "failed to set stripe with -S ${brw_size}M option"
20347 # clear the OSC stats
20348 $LCTL set_param osc.*.stats=0 &>/dev/null
20351 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
20352 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
20353 oflag=direct &>/dev/null || error "dd failed"
20355 sync; sleep 1; sync # just to be safe
20356 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
20357 if [ x$nrpcs != "x1" ]; then
20358 $LCTL get_param osc.*.stats
20359 error "found $nrpcs ost_write RPCs, not 1 as expected"
20363 # Drop the OSC cache, otherwise we will read from it
20364 cancel_lru_locks osc
20366 # clear the OSC stats
20367 $LCTL set_param osc.*.stats=0 &>/dev/null
20369 # Client reads $bulk_size.
20370 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
20371 iflag=direct &>/dev/null || error "dd failed"
20373 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
20374 if [ x$nrpcs != "x1" ]; then
20375 $LCTL get_param osc.*.stats
20376 error "found $nrpcs ost_read RPCs, not 1 as expected"
20379 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
20382 mkdir -p $DIR/$tdir
20384 for i in {0..1023}; do
20385 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
20386 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
20387 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
20391 run_test 231b "must not assert on fully utilized OST request buffer"
20394 mkdir -p $DIR/$tdir
20395 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
20397 #define OBD_FAIL_LDLM_OST_LVB 0x31c
20398 do_facet ost1 $LCTL set_param fail_loc=0x31c
20400 # ignore dd failure
20401 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
20403 do_facet ost1 $LCTL set_param fail_loc=0
20404 umount_client $MOUNT || error "umount failed"
20405 mount_client $MOUNT || error "mount failed"
20406 stop ost1 || error "cannot stop ost1"
20407 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
20409 run_test 232a "failed lock should not block umount"
20412 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
20413 skip "Need MDS version at least 2.10.58"
20415 mkdir -p $DIR/$tdir
20416 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
20417 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
20419 cancel_lru_locks osc
20421 #define OBD_FAIL_LDLM_OST_LVB 0x31c
20422 do_facet ost1 $LCTL set_param fail_loc=0x31c
20425 $LFS data_version $DIR/$tdir/$tfile || true
20427 do_facet ost1 $LCTL set_param fail_loc=0
20428 umount_client $MOUNT || error "umount failed"
20429 mount_client $MOUNT || error "mount failed"
20430 stop ost1 || error "cannot stop ost1"
20431 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
20433 run_test 232b "failed data version lock should not block umount"
20436 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
20437 skip "Need MDS version at least 2.3.64"
20438 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
20440 local fid=$($LFS path2fid $MOUNT)
20442 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20443 error "cannot access $MOUNT using its FID '$fid'"
20445 run_test 233a "checking that OBF of the FS root succeeds"
20448 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
20449 skip "Need MDS version at least 2.5.90"
20450 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
20452 local fid=$($LFS path2fid $MOUNT/.lustre)
20454 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20455 error "cannot access $MOUNT/.lustre using its FID '$fid'"
20457 fid=$($LFS path2fid $MOUNT/.lustre/fid)
20458 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20459 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
20461 run_test 233b "checking that OBF of the FS .lustre succeeds"
20464 local p="$TMP/sanityN-$TESTNAME.parameters"
20465 save_lustre_params client "llite.*.xattr_cache" > $p
20466 lctl set_param llite.*.xattr_cache 1 ||
20467 skip_env "xattr cache is not supported"
20469 mkdir -p $DIR/$tdir || error "mkdir failed"
20470 touch $DIR/$tdir/$tfile || error "touch failed"
20471 # OBD_FAIL_LLITE_XATTR_ENOMEM
20472 $LCTL set_param fail_loc=0x1405
20473 getfattr -n user.attr $DIR/$tdir/$tfile &&
20474 error "getfattr should have failed with ENOMEM"
20475 $LCTL set_param fail_loc=0x0
20478 restore_lustre_params < $p
20481 run_test 234 "xattr cache should not crash on ENOMEM"
20484 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
20485 skip "Need MDS version at least 2.4.52"
20487 flock_deadlock $DIR/$tfile
20492 124) error "process hangs on a deadlock"
20494 *) error "error executing flock_deadlock $DIR/$tfile"
20498 run_test 235 "LU-1715: flock deadlock detection does not work properly"
20502 check_swap_layouts_support
20504 local ref1=/etc/passwd
20505 local ref2=/etc/group
20506 local file1=$DIR/$tdir/f1
20507 local file2=$DIR/$tdir/f2
20509 test_mkdir -c1 $DIR/$tdir
20510 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
20511 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
20512 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
20513 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
20514 local fd=$(free_fd)
20515 local cmd="exec $fd<>$file2"
20518 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
20519 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
20522 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
20527 run_test 236 "Layout swap on open unlinked file"
20529 # LU-4659 linkea consistency
20531 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
20532 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
20533 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
20534 skip "Need MDS version at least 2.5.58 or 2.5.2+"
20537 ln $DIR/$tfile $DIR/$tfile.lnk
20538 touch $DIR/$tfile.new
20539 mv $DIR/$tfile.new $DIR/$tfile
20540 local fid1=$($LFS path2fid $DIR/$tfile)
20541 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
20542 local path1=$($LFS fid2path $FSNAME "$fid1")
20543 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
20544 local path2=$($LFS fid2path $FSNAME "$fid2")
20545 [ $tfile.lnk == $path2 ] ||
20546 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
20549 run_test 238 "Verify linkea consistency"
20551 test_239A() { # was test_239
20552 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
20553 skip "Need MDS version at least 2.5.60"
20555 local list=$(comma_list $(mdts_nodes))
20557 mkdir -p $DIR/$tdir
20558 createmany -o $DIR/$tdir/f- 5000
20559 unlinkmany $DIR/$tdir/f- 5000
20560 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
20561 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
20562 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
20563 osp.*MDT*.sync_in_flight" | calc_sum)
20564 [ "$changes" -eq 0 ] || error "$changes not synced"
20566 run_test 239A "osp_sync test"
20568 test_239a() { #LU-5297
20569 remote_mds_nodsh && skip "remote MDS with nodsh"
20572 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
20573 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
20574 chgrp $RUNAS_GID $DIR/$tfile
20575 wait_delete_completed
20577 run_test 239a "process invalid osp sync record correctly"
20579 test_239b() { #LU-5297
20580 remote_mds_nodsh && skip "remote MDS with nodsh"
20583 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
20584 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
20585 chgrp $RUNAS_GID $DIR/$tfile1
20586 wait_delete_completed
20587 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
20589 chgrp $RUNAS_GID $DIR/$tfile2
20590 wait_delete_completed
20592 run_test 239b "process osp sync record with ENOMEM error correctly"
20595 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20596 remote_mds_nodsh && skip "remote MDS with nodsh"
20598 mkdir -p $DIR/$tdir
20600 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
20601 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
20602 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
20603 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
20605 umount_client $MOUNT || error "umount failed"
20606 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
20607 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
20608 mount_client $MOUNT || error "failed to mount client"
20610 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
20611 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
20613 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
20619 for LOOP in $(seq $count); do
20620 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
20621 cancel_lru_locks $OSC || true
20629 for LOOP in $(seq $1); do
20630 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
20635 test_241a() { # was test_241
20636 local bsize=$PAGE_SIZE
20638 (( bsize < 40960 )) && bsize=40960
20639 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
20641 cancel_lru_locks $OSC
20642 test_241_bio 1000 $bsize &
20644 test_241_dio 1000 $bsize
20647 run_test 241a "bio vs dio"
20650 local bsize=$PAGE_SIZE
20652 (( bsize < 40960 )) && bsize=40960
20653 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
20655 test_241_dio 1000 $bsize &
20657 test_241_dio 1000 $bsize
20660 run_test 241b "dio vs dio"
20663 remote_mds_nodsh && skip "remote MDS with nodsh"
20665 mkdir_on_mdt0 $DIR/$tdir
20666 touch $DIR/$tdir/$tfile
20668 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
20669 do_facet mds1 lctl set_param fail_loc=0x105
20670 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
20672 do_facet mds1 lctl set_param fail_loc=0
20673 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
20675 run_test 242 "mdt_readpage failure should not cause directory unreadable"
20679 test_mkdir $DIR/$tdir
20680 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
20682 run_test 243 "various group lock tests"
20686 test_mkdir $DIR/$tdir
20687 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
20688 sendfile_grouplock $DIR/$tdir/$tfile || \
20689 error "sendfile+grouplock failed"
20692 run_test 244a "sendfile with group lock tests"
20696 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
20699 local size=$((1024*1024))
20701 test_mkdir $DIR/$tdir
20702 for i in $(seq 1 $threads); do
20703 local file=$DIR/$tdir/file_$((i / 10))
20704 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
20707 for i in $(seq 1 $threads); do
20711 run_test 244b "multi-threaded write with group lock"
20714 local flagname="multi_mod_rpcs"
20715 local connect_data_name="max_mod_rpcs"
20718 # check if multiple modify RPCs flag is set
20719 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
20720 grep "connect_flags:")
20723 echo "$out" | grep -qw $flagname
20724 if [ $? -ne 0 ]; then
20725 echo "connect flag $flagname is not set"
20729 # check if multiple modify RPCs data is set
20730 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
20733 echo "$out" | grep -qw $connect_data_name ||
20734 error "import should have connect data $connect_data_name"
20736 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
20742 umount_client $submount
20747 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
20749 skip_env "Fileset feature is not supported"
20751 local submount=${MOUNT}_$tdir
20754 mkdir -p $submount || error "mkdir $submount failed"
20755 FILESET="$FILESET/$tdir" mount_client $submount ||
20756 error "mount $submount failed"
20757 trap "cleanup_247 $submount" EXIT
20758 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
20759 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
20760 error "read $MOUNT/$tdir/$tfile failed"
20761 cleanup_247 $submount
20763 run_test 247a "mount subdir as fileset"
20766 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
20767 skip_env "Fileset feature is not supported"
20769 local submount=${MOUNT}_$tdir
20771 rm -rf $MOUNT/$tdir
20772 mkdir -p $submount || error "mkdir $submount failed"
20774 FILESET="$FILESET/$tdir" mount_client $submount &&
20775 error "mount $submount should fail"
20778 run_test 247b "mount subdir that dose not exist"
20781 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
20782 skip_env "Fileset feature is not supported"
20784 local submount=${MOUNT}_$tdir
20786 mkdir -p $MOUNT/$tdir/dir1
20787 mkdir -p $submount || error "mkdir $submount failed"
20788 trap "cleanup_247 $submount" EXIT
20789 FILESET="$FILESET/$tdir" mount_client $submount ||
20790 error "mount $submount failed"
20791 local fid=$($LFS path2fid $MOUNT/)
20792 $LFS fid2path $submount $fid && error "fid2path should fail"
20793 cleanup_247 $submount
20795 run_test 247c "running fid2path outside subdirectory root"
20798 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
20799 skip "Fileset feature is not supported"
20801 local submount=${MOUNT}_$tdir
20803 mkdir -p $MOUNT/$tdir/dir1
20804 mkdir -p $submount || error "mkdir $submount failed"
20805 FILESET="$FILESET/$tdir" mount_client $submount ||
20806 error "mount $submount failed"
20807 trap "cleanup_247 $submount" EXIT
20809 local td=$submount/dir1
20810 local fid=$($LFS path2fid $td)
20811 [ -z "$fid" ] && error "path2fid unable to get $td FID"
20813 # check that we get the same pathname back
20816 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
20817 echo "$rootpath $fid"
20818 found=$($LFS fid2path $rootpath "$fid")
20819 [ -n "found" ] || error "fid2path should succeed"
20820 [ "$found" == "$td" ] || error "fid2path $found != $td"
20822 # check wrong root path format
20823 rootpath=$submount"_wrong"
20824 found=$($LFS fid2path $rootpath "$fid")
20825 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
20827 cleanup_247 $submount
20829 run_test 247d "running fid2path inside subdirectory root"
20833 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
20835 skip "Fileset feature is not supported"
20837 local submount=${MOUNT}_$tdir
20840 mkdir -p $submount || error "mkdir $submount failed"
20841 FILESET="$FILESET/.." mount_client $submount &&
20842 error "mount $submount should fail"
20845 run_test 247e "mount .. as fileset"
20848 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20849 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
20850 skip "Need at least version 2.13.52"
20851 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
20852 skip "Need at least version 2.14.50"
20853 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
20855 skip "Fileset feature is not supported"
20857 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
20858 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
20859 error "mkdir remote failed"
20860 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
20861 error "mkdir remote/subdir failed"
20862 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
20863 error "mkdir striped failed"
20864 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
20866 local submount=${MOUNT}_$tdir
20868 mkdir -p $submount || error "mkdir $submount failed"
20869 stack_trap "rmdir $submount"
20873 local fileset=$FILESET
20874 local mdts=$(comma_list $(mdts_nodes))
20876 stat=$(do_facet mds1 $LCTL get_param -n \
20877 mdt.*MDT0000.enable_remote_subdir_mount)
20878 stack_trap "do_nodes $mdts $LCTL set_param \
20879 mdt.*.enable_remote_subdir_mount=$stat"
20881 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
20882 stack_trap "umount_client $submount"
20883 FILESET="$fileset/$tdir/remote" mount_client $submount &&
20884 error "mount remote dir $dir should fail"
20886 for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
20887 $tdir/striped/. ; do
20888 FILESET="$fileset/$dir" mount_client $submount ||
20889 error "mount $dir failed"
20890 umount_client $submount
20893 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
20894 FILESET="$fileset/$tdir/remote" mount_client $submount ||
20895 error "mount $tdir/remote failed"
20897 run_test 247f "mount striped or remote directory as fileset"
20900 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
20901 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
20902 skip "Need at least version 2.14.50"
20904 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
20905 error "mkdir $tdir failed"
20906 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
20908 local submount=${MOUNT}_$tdir
20910 mkdir -p $submount || error "mkdir $submount failed"
20911 stack_trap "rmdir $submount"
20913 FILESET="$fileset/$tdir" mount_client $submount ||
20914 error "mount $dir failed"
20915 stack_trap "umount $submount"
20917 local mdts=$(comma_list $(mdts_nodes))
20921 stat $submount > /dev/null
20922 cancel_lru_locks $MDC
20923 stat $submount > /dev/null
20924 stat $submount/$tfile > /dev/null
20925 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
20926 stat $submount/$tfile > /dev/null
20927 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
20928 awk '/getattr/ {sum += $2} END {print sum}')
20930 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
20932 run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
20935 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
20936 [ -z "$fast_read_sav" ] && skip "no fast read support"
20938 # create a large file for fast read verification
20939 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
20941 # make sure the file is created correctly
20942 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
20943 { rm -f $DIR/$tfile; skip "file creation error"; }
20945 echo "Test 1: verify that fast read is 4 times faster on cache read"
20947 # small read with fast read enabled
20948 $LCTL set_param -n llite.*.fast_read=1
20949 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
20950 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20951 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20952 # small read with fast read disabled
20953 $LCTL set_param -n llite.*.fast_read=0
20954 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
20955 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20956 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20958 # verify that fast read is 4 times faster for cache read
20959 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
20960 error_not_in_vm "fast read was not 4 times faster: " \
20961 "$t_fast vs $t_slow"
20963 echo "Test 2: verify the performance between big and small read"
20964 $LCTL set_param -n llite.*.fast_read=1
20966 # 1k non-cache read
20967 cancel_lru_locks osc
20968 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
20969 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20970 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20972 # 1M non-cache read
20973 cancel_lru_locks osc
20974 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
20975 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
20976 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
20978 # verify that big IO is not 4 times faster than small IO
20979 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
20980 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
20982 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
20985 run_test 248a "fast read verification"
20988 # Default short_io_bytes=16384, try both smaller and larger sizes.
20989 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
20990 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
20991 echo "bs=53248 count=113 normal buffered write"
20992 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
20993 error "dd of initial data file failed"
20994 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
20996 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
20997 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
20998 error "dd with sync normal writes failed"
20999 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
21001 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
21002 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
21003 error "dd with sync small writes failed"
21004 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
21006 cancel_lru_locks osc
21008 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
21009 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
21010 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
21011 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
21012 iflag=direct || error "dd with O_DIRECT small read failed"
21013 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
21014 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
21015 error "compare $TMP/$tfile.1 failed"
21017 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
21018 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
21020 # just to see what the maximum tunable value is, and test parsing
21021 echo "test invalid parameter 2MB"
21022 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
21023 error "too-large short_io_bytes allowed"
21024 echo "test maximum parameter 512KB"
21025 # if we can set a larger short_io_bytes, run test regardless of version
21026 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
21027 # older clients may not allow setting it this large, that's OK
21028 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
21029 skip "Need at least client version 2.13.50"
21030 error "medium short_io_bytes failed"
21032 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21033 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
21035 echo "test large parameter 64KB"
21036 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
21037 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21039 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
21040 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
21041 error "dd with sync large writes failed"
21042 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
21044 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
21045 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
21046 num=$((113 * 4096 / PAGE_SIZE))
21047 echo "bs=$size count=$num oflag=direct large write $tfile.3"
21048 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
21049 error "dd with O_DIRECT large writes failed"
21050 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
21051 error "compare $DIR/$tfile.3 failed"
21053 cancel_lru_locks osc
21055 echo "bs=$size count=$num iflag=direct large read $tfile.2"
21056 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
21057 error "dd with O_DIRECT large read failed"
21058 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
21059 error "compare $TMP/$tfile.2 failed"
21061 echo "bs=$size count=$num iflag=direct large read $tfile.3"
21062 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
21063 error "dd with O_DIRECT large read failed"
21064 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
21065 error "compare $TMP/$tfile.3 failed"
21067 run_test 248b "test short_io read and write for both small and large sizes"
21069 test_249() { # LU-7890
21070 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
21071 skip "Need at least version 2.8.54"
21074 $LFS setstripe -c 1 $DIR/$tfile
21075 # Offset 2T == 4k * 512M
21076 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
21077 error "dd to 2T offset failed"
21079 run_test 249 "Write above 2T file size"
21082 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
21083 && skip "no 16TB file size limit on ZFS"
21085 $LFS setstripe -c 1 $DIR/$tfile
21086 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
21087 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
21088 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
21089 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
21090 conv=notrunc,fsync && error "append succeeded"
21093 run_test 250 "Write above 16T limit"
21096 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
21098 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
21099 #Skip once - writing the first stripe will succeed
21100 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21101 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
21102 error "short write happened"
21104 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21105 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
21106 error "short read happened"
21110 run_test 251 "Handling short read and write correctly"
21113 remote_mds_nodsh && skip "remote MDS with nodsh"
21114 remote_ost_nodsh && skip "remote OST with nodsh"
21115 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
21116 skip_env "ldiskfs only test"
21126 # check lr_reader on OST0000
21128 dev=$(facet_device $tgt)
21129 out=$(do_facet $tgt $LR_READER $dev)
21130 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21132 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
21133 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
21134 error "Invalid uuid returned by $LR_READER on target $tgt"
21135 echo -e "uuid returned by $LR_READER is '$uuid'\n"
21137 # check lr_reader -c on MDT0000
21139 dev=$(facet_device $tgt)
21140 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
21141 skip "$LR_READER does not support additional options"
21143 out=$(do_facet $tgt $LR_READER -c $dev)
21144 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21146 num=$(echo "$out" | grep -c "mdtlov")
21147 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
21148 error "Invalid number of mdtlov clients returned by $LR_READER"
21149 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
21151 # check lr_reader -cr on MDT0000
21152 out=$(do_facet $tgt $LR_READER -cr $dev)
21153 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21155 echo "$out" | grep -q "^reply_data:$" ||
21156 error "$LR_READER should have returned 'reply_data' section"
21157 num=$(echo "$out" | grep -c "client_generation")
21158 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
21160 run_test 252 "check lr_reader tool"
21163 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21164 remote_mds_nodsh && skip "remote MDS with nodsh"
21165 remote_mgs_nodsh && skip "remote MGS with nodsh"
21169 local ost_name=$(ostname_from_index $ostidx)
21172 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
21173 do_facet $SINGLEMDS $LCTL get_param -n \
21174 osp.$mdtosc_proc1.reserved_mb_high ||
21175 skip "remote MDS does not support reserved_mb_high"
21179 wait_delete_completed
21182 pool_add $TESTNAME || error "Pool creation failed"
21183 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
21185 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
21186 error "Setstripe failed"
21188 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
21190 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
21192 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
21194 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
21195 osp.$mdtosc_proc1.prealloc_status)
21196 echo "prealloc_status $oa_status"
21198 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
21199 error "File creation should fail"
21201 #object allocation was stopped, but we still able to append files
21202 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
21203 oflag=append || error "Append failed"
21205 rm -f $DIR/$tdir/$tfile.0
21207 # For this test, we want to delete the files we created to go out of
21208 # space but leave the watermark, so we remain nearly out of space
21209 ost_watermarks_enospc_delete_files $tfile $ostidx
21211 wait_delete_completed
21215 for i in $(seq 10 12); do
21216 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
21217 2>/dev/null || error "File creation failed after rm"
21220 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
21221 osp.$mdtosc_proc1.prealloc_status)
21222 echo "prealloc_status $oa_status"
21224 if (( oa_status != 0 )); then
21225 error "Object allocation still disable after rm"
21228 run_test 253 "Check object allocation limit"
21231 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21232 remote_mds_nodsh && skip "remote MDS with nodsh"
21234 local mdt=$(facet_svc $SINGLEMDS)
21236 do_facet $SINGLEMDS $LCTL get_param -n mdd.$mdt.changelog_size ||
21237 skip "MDS does not support changelog_size"
21241 changelog_register || error "changelog_register failed"
21243 changelog_clear 0 || error "changelog_clear failed"
21245 local size1=$(do_facet $SINGLEMDS \
21246 $LCTL get_param -n mdd.$mdt.changelog_size)
21247 echo "Changelog size $size1"
21250 $LFS mkdir -i 0 $DIR/$tdir
21252 mkdir -p $DIR/$tdir/pics/2008/zachy
21253 touch $DIR/$tdir/pics/2008/zachy/timestamp
21254 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
21255 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
21256 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
21257 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
21258 rm $DIR/$tdir/pics/desktop.jpg
21260 local size2=$(do_facet $SINGLEMDS \
21261 $LCTL get_param -n mdd.$mdt.changelog_size)
21262 echo "Changelog size after work $size2"
21264 (( $size2 > $size1 )) ||
21265 error "new Changelog size=$size2 less than old size=$size1"
21267 run_test 254 "Check changelog size"
21274 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
21275 awk -F: '{print $2}' | grep $type > /dev/null
21276 if [ $? -ne 0 ]; then
21286 lfs ladvise -a willread $file > /dev/null 2>&1
21287 if [ $? -eq 0 ]; then
21291 lfs ladvise -a willread $file 2>&1 |
21292 grep "Inappropriate ioctl for device" > /dev/null
21293 if [ $? -eq 0 ]; then
21300 bc <<<"scale=2; ($1 - $2) * 100 / $2"
21303 # run a random read IO workload
21304 # usage: random_read_iops <filename> <filesize> <iosize>
21305 random_read_iops() {
21308 local iosize=${3:-4096}
21310 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
21311 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
21314 drop_file_oss_cache() {
21318 $LFS ladvise -a dontneed $file 2>/dev/null ||
21319 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
21322 ladvise_willread_performance()
21325 local average_origin=0
21326 local average_cache=0
21327 local average_ladvise=0
21329 for ((i = 1; i <= $repeat; i++)); do
21330 echo "Iter $i/$repeat: reading without willread hint"
21331 cancel_lru_locks osc
21332 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
21333 local speed_origin=$(random_read_iops $DIR/$tfile $size)
21334 echo "Iter $i/$repeat: uncached speed: $speed_origin"
21335 average_origin=$(bc <<<"$average_origin + $speed_origin")
21337 cancel_lru_locks osc
21338 local speed_cache=$(random_read_iops $DIR/$tfile $size)
21339 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
21340 average_cache=$(bc <<<"$average_cache + $speed_cache")
21342 cancel_lru_locks osc
21343 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
21344 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
21345 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
21346 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
21347 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
21349 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
21350 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
21351 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
21353 speedup_cache=$(percent $average_cache $average_origin)
21354 speedup_ladvise=$(percent $average_ladvise $average_origin)
21356 echo "Average uncached read: $average_origin"
21357 echo "Average speedup with OSS cached read: " \
21358 "$average_cache = +$speedup_cache%"
21359 echo "Average speedup with ladvise willread: " \
21360 "$average_ladvise = +$speedup_ladvise%"
21362 local lowest_speedup=20
21363 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
21364 echo "Speedup with OSS cached read less than $lowest_speedup%," \
21365 "got $average_cache%. Skipping ladvise willread check."
21369 # the test won't work on ZFS until it supports 'ladvise dontneed', but
21370 # it is still good to run until then to exercise 'ladvise willread'
21371 ! $LFS ladvise -a dontneed $DIR/$tfile &&
21372 [ "$ost1_FSTYPE" = "zfs" ] &&
21373 echo "osd-zfs does not support dontneed or drop_caches" &&
21376 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
21377 [[ ${average_ladvise%.*} > $lowest_speedup ]] ||
21378 error_not_in_vm "Speedup with willread is less than " \
21379 "$lowest_speedup%, got $average_ladvise%"
21383 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
21384 skip "lustre < 2.8.54 does not support ladvise "
21385 remote_ost_nodsh && skip "remote OST with nodsh"
21387 stack_trap "rm -f $DIR/$tfile"
21388 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
21390 ladvise_no_type willread $DIR/$tfile &&
21391 skip "willread ladvise is not supported"
21393 ladvise_no_ioctl $DIR/$tfile &&
21394 skip "ladvise ioctl is not supported"
21397 local size=$((size_mb * 1048576))
21398 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
21399 error "dd to $DIR/$tfile failed"
21401 lfs ladvise -a willread $DIR/$tfile ||
21402 error "Ladvise failed with no range argument"
21404 lfs ladvise -a willread -s 0 $DIR/$tfile ||
21405 error "Ladvise failed with no -l or -e argument"
21407 lfs ladvise -a willread -e 1 $DIR/$tfile ||
21408 error "Ladvise failed with only -e argument"
21410 lfs ladvise -a willread -l 1 $DIR/$tfile ||
21411 error "Ladvise failed with only -l argument"
21413 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
21414 error "End offset should not be smaller than start offset"
21416 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
21417 error "End offset should not be equal to start offset"
21419 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
21420 error "Ladvise failed with overflowing -s argument"
21422 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
21423 error "Ladvise failed with overflowing -e argument"
21425 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
21426 error "Ladvise failed with overflowing -l argument"
21428 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
21429 error "Ladvise succeeded with conflicting -l and -e arguments"
21431 echo "Synchronous ladvise should wait"
21433 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
21434 do_nodes $(comma_list $(osts_nodes)) \
21435 $LCTL set_param fail_val=$delay fail_loc=0x237
21437 local start_ts=$SECONDS
21438 lfs ladvise -a willread $DIR/$tfile ||
21439 error "Ladvise failed with no range argument"
21440 local end_ts=$SECONDS
21441 local inteval_ts=$((end_ts - start_ts))
21443 if [ $inteval_ts -lt $(($delay - 1)) ]; then
21444 error "Synchronous advice didn't wait reply"
21447 echo "Asynchronous ladvise shouldn't wait"
21448 local start_ts=$SECONDS
21449 lfs ladvise -a willread -b $DIR/$tfile ||
21450 error "Ladvise failed with no range argument"
21451 local end_ts=$SECONDS
21452 local inteval_ts=$((end_ts - start_ts))
21454 if [ $inteval_ts -gt $(($delay / 2)) ]; then
21455 error "Asynchronous advice blocked"
21458 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
21459 ladvise_willread_performance
21461 run_test 255a "check 'lfs ladvise -a willread'"
21467 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
21471 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
21472 skip "lustre < 2.8.54 does not support ladvise "
21473 remote_ost_nodsh && skip "remote OST with nodsh"
21475 stack_trap "rm -f $DIR/$tfile"
21476 lfs setstripe -c 1 -i 0 $DIR/$tfile
21478 ladvise_no_type dontneed $DIR/$tfile &&
21479 skip "dontneed ladvise is not supported"
21481 ladvise_no_ioctl $DIR/$tfile &&
21482 skip "ladvise ioctl is not supported"
21484 ! $LFS ladvise -a dontneed $DIR/$tfile &&
21485 [ "$ost1_FSTYPE" = "zfs" ] &&
21486 skip "zfs-osd does not support 'ladvise dontneed'"
21489 local size=$((size_mb * 1048576))
21490 # In order to prevent disturbance of other processes, only check 3/4
21491 # of the memory usage
21492 local kibibytes=$((size_mb * 1024 * 3 / 4))
21494 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
21495 error "dd to $DIR/$tfile failed"
21497 #force write to complete before dropping OST cache & checking memory
21500 local total=$(facet_meminfo ost1 MemTotal)
21501 echo "Total memory: $total KiB"
21503 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
21504 local before_read=$(facet_meminfo ost1 Cached)
21505 echo "Cache used before read: $before_read KiB"
21507 lfs ladvise -a willread $DIR/$tfile ||
21508 error "Ladvise willread failed"
21509 local after_read=$(facet_meminfo ost1 Cached)
21510 echo "Cache used after read: $after_read KiB"
21512 lfs ladvise -a dontneed $DIR/$tfile ||
21513 error "Ladvise dontneed again failed"
21514 local no_read=$(facet_meminfo ost1 Cached)
21515 echo "Cache used after dontneed ladvise: $no_read KiB"
21517 if [ $total -lt $((before_read + kibibytes)) ]; then
21518 echo "Memory is too small, abort checking"
21522 if [ $((before_read + kibibytes)) -gt $after_read ]; then
21523 error "Ladvise willread should use more memory" \
21524 "than $kibibytes KiB"
21527 if [ $((no_read + kibibytes)) -gt $after_read ]; then
21528 error "Ladvise dontneed should release more memory" \
21529 "than $kibibytes KiB"
21532 run_test 255b "check 'lfs ladvise -a dontneed'"
21535 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
21536 skip "lustre < 2.10.50 does not support lockahead"
21538 local ost1_imp=$(get_osc_import_name client ost1)
21539 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
21547 test_mkdir -p $DIR/$tdir
21548 $LFS setstripe -i 0 -c 1 $DIR/$tdir
21550 #test 10 returns only success/failure
21552 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21554 if [ $rc -eq 255 ]; then
21555 error "Ladvise test${i} failed, ${rc}"
21558 #test 11 counts lock enqueue requests, all others count new locks
21560 count=$(do_facet ost1 \
21561 $LCTL get_param -n ost.OSS.ost.stats)
21562 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
21564 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21566 if [ $rc -eq 255 ]; then
21567 error "Ladvise test${i} failed, ${rc}"
21570 new_count=$(do_facet ost1 \
21571 $LCTL get_param -n ost.OSS.ost.stats)
21572 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
21573 awk '{ print $2 }')
21575 difference="$((new_count - count))"
21576 if [ $difference -ne $rc ]; then
21577 error "Ladvise test${i}, bad enqueue count, returned " \
21578 "${rc}, actual ${difference}"
21581 for i in $(seq 12 21); do
21582 # If we do not do this, we run the risk of having too many
21583 # locks and starting lock cancellation while we are checking
21585 cancel_lru_locks osc
21587 count=$($LCTL get_param -n \
21588 ldlm.namespaces.$imp_name.lock_unused_count)
21590 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21592 if [ $rc -eq 255 ]; then
21593 error "Ladvise test ${i} failed, ${rc}"
21596 new_count=$($LCTL get_param -n \
21597 ldlm.namespaces.$imp_name.lock_unused_count)
21598 difference="$((new_count - count))"
21600 # Test 15 output is divided by 100 to map down to valid return
21601 if [ $i -eq 15 ]; then
21605 if [ $difference -ne $rc ]; then
21606 error "Ladvise test ${i}, bad lock count, returned " \
21607 "${rc}, actual ${difference}"
21611 #test 22 returns only success/failure
21613 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21615 if [ $rc -eq 255 ]; then
21616 error "Ladvise test${i} failed, ${rc}"
21619 run_test 255c "suite of ladvise lockahead tests"
21622 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21623 remote_mds_nodsh && skip "remote MDS with nodsh"
21624 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
21625 changelog_users $SINGLEMDS | grep "^cl" &&
21626 skip "active changelog user"
21632 mdt_dev=$(mdsdevname 1)
21635 changelog_register || error "changelog_register failed"
21638 mkdir_on_mdt0 $DIR/$tdir
21640 changelog_clear 0 || error "changelog_clear failed"
21643 touch $DIR/$tdir/{1..10}
21646 stop $SINGLEMDS || error "Fail to stop MDT"
21650 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
21652 #after mount new plainllog is used
21653 touch $DIR/$tdir/{11..19}
21654 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
21655 stack_trap "rm -f $tmpfile"
21656 cat_sl=$(do_facet $SINGLEMDS "sync; \
21657 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
21658 llog_reader $tmpfile | grep -c type=1064553b")
21659 do_facet $SINGLEMDS llog_reader $tmpfile
21661 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
21663 changelog_clear 0 || error "changelog_clear failed"
21665 cat_sl=$(do_facet $SINGLEMDS "sync; \
21666 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
21667 llog_reader $tmpfile | grep -c type=1064553b")
21669 if (( cat_sl == 2 )); then
21670 error "Empty plain llog was not deleted from changelog catalog"
21671 elif (( cat_sl != 1 )); then
21672 error "Active plain llog shouldn't be deleted from catalog"
21675 run_test 256 "Check llog delete for empty and not full state"
21678 remote_mds_nodsh && skip "remote MDS with nodsh"
21679 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
21680 skip "Need MDS version at least 2.8.55"
21682 test_mkdir $DIR/$tdir
21684 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
21685 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
21688 #define OBD_FAIL_MDS_XATTR_REP 0x161
21689 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
21690 local facet=mds$((mdtidx + 1))
21691 set_nodes_failloc $(facet_active_host $facet) 0x80000161
21692 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
21694 stop $facet || error "stop MDS failed"
21695 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
21696 error "start MDS fail"
21697 wait_recovery_complete $facet
21699 run_test 257 "xattr locks are not lost"
21701 # Verify we take the i_mutex when security requires it
21703 #define OBD_FAIL_IMUTEX_SEC 0x141c
21704 $LCTL set_param fail_loc=0x141c
21706 chmod u+s $DIR/$tfile
21707 chmod a+rwx $DIR/$tfile
21708 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
21710 if [ $RC -ne 0 ]; then
21711 error "error, failed to take i_mutex, rc=$?"
21715 run_test 258a "verify i_mutex security behavior when suid attributes is set"
21717 # Verify we do NOT take the i_mutex in the normal case
21719 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
21720 $LCTL set_param fail_loc=0x141d
21723 chmod a+rw $DIR/$tfile
21724 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
21726 if [ $RC -ne 0 ]; then
21727 error "error, took i_mutex unnecessarily, rc=$?"
21732 run_test 258b "verify i_mutex security behavior"
21735 local file=$DIR/$tfile
21739 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
21741 stack_trap "rm -f $file" EXIT
21743 wait_delete_completed
21744 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21745 echo "before: $before"
21747 $LFS setstripe -i 0 -c 1 $file
21748 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
21750 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21751 echo "after write: $after"
21753 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
21754 do_facet ost1 $LCTL set_param fail_loc=0x2301
21756 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21757 echo "after truncate: $after"
21760 do_facet ost1 $LCTL set_param fail_loc=0
21761 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21763 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
21764 echo "after restart: $after"
21765 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
21766 error "missing truncate?"
21770 run_test 259 "crash at delayed truncate"
21773 #define OBD_FAIL_MDC_CLOSE 0x806
21774 $LCTL set_param fail_loc=0x80000806
21778 run_test 260 "Check mdc_close fail"
21780 ### Data-on-MDT sanity tests ###
21782 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21783 skip "Need MDS version at least 2.10.55 for DoM"
21786 local dom=$DIR/$tdir/dom_file
21787 local tmp=$DIR/$tdir/tmp_file
21789 mkdir_on_mdt0 $DIR/$tdir
21791 # basic checks for DoM component creation
21792 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
21793 error "Can set MDT layout to non-first entry"
21795 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
21796 error "Can define multiple entries as MDT layout"
21798 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
21800 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
21801 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
21802 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
21804 local mdtidx=$($LFS getstripe -m $dom)
21805 local mdtname=MDT$(printf %04x $mdtidx)
21806 local facet=mds$((mdtidx + 1))
21807 local space_check=1
21809 # Skip free space checks with ZFS
21810 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
21814 local size_tmp=$((65536 * 3))
21815 local mdtfree1=$(do_facet $facet \
21816 lctl get_param -n osd*.*$mdtname.kbytesfree)
21818 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
21819 # check also direct IO along write
21820 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
21821 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
21823 cmp $tmp $dom || error "file data is different"
21824 [ $(stat -c%s $dom) == $size_tmp ] ||
21825 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
21826 if [ $space_check == 1 ]; then
21827 local mdtfree2=$(do_facet $facet \
21828 lctl get_param -n osd*.*$mdtname.kbytesfree)
21830 # increase in usage from by $size_tmp
21831 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
21832 error "MDT free space wrong after write: " \
21833 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
21837 local size_dom=10000
21839 $TRUNCATE $dom $size_dom
21840 [ $(stat -c%s $dom) == $size_dom ] ||
21841 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
21842 if [ $space_check == 1 ]; then
21843 mdtfree1=$(do_facet $facet \
21844 lctl get_param -n osd*.*$mdtname.kbytesfree)
21845 # decrease in usage from $size_tmp to new $size_dom
21846 [ $(($mdtfree1 - $mdtfree2)) -ge \
21847 $(((size_tmp - size_dom) / 1024)) ] ||
21848 error "MDT free space is wrong after truncate: " \
21849 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
21855 size_dom=$((size_dom + size_tmp))
21856 [ $(stat -c%s $dom) == $size_dom ] ||
21857 error "bad size after append: $(stat -c%s $dom) != $size_dom"
21858 if [ $space_check == 1 ]; then
21859 mdtfree2=$(do_facet $facet \
21860 lctl get_param -n osd*.*$mdtname.kbytesfree)
21861 # increase in usage by $size_tmp from previous
21862 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
21863 error "MDT free space is wrong after append: " \
21864 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
21869 if [ $space_check == 1 ]; then
21870 mdtfree1=$(do_facet $facet \
21871 lctl get_param -n osd*.*$mdtname.kbytesfree)
21872 # decrease in usage by $size_dom from previous
21873 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
21874 error "MDT free space is wrong after removal: " \
21875 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
21878 # combined striping
21879 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
21880 error "Can't create DoM + OST striping"
21882 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
21883 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
21884 # check also direct IO along write
21885 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
21887 cmp $tmp $dom || error "file data is different"
21888 [ $(stat -c%s $dom) == $size_tmp ] ||
21889 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
21894 run_test 270a "DoM: basic functionality tests"
21897 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21898 skip "Need MDS version at least 2.10.55"
21900 local dom=$DIR/$tdir/dom_file
21901 local max_size=1048576
21903 mkdir -p $DIR/$tdir
21904 $LFS setstripe -E $max_size -L mdt $dom
21906 # truncate over the limit
21907 $TRUNCATE $dom $(($max_size + 1)) &&
21908 error "successful truncate over the maximum size"
21909 # write over the limit
21910 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
21911 error "successful write over the maximum size"
21912 # append over the limit
21913 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
21914 echo "12345" >> $dom && error "successful append over the maximum size"
21919 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
21922 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21923 skip "Need MDS version at least 2.10.55"
21925 mkdir -p $DIR/$tdir
21926 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21928 # check files inherit DoM EA
21929 touch $DIR/$tdir/first
21930 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
21931 error "bad pattern"
21932 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
21933 error "bad stripe count"
21934 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
21935 error "bad stripe size"
21937 # check directory inherits DoM EA and uses it as default
21938 mkdir $DIR/$tdir/subdir
21939 touch $DIR/$tdir/subdir/second
21940 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
21941 error "bad pattern in sub-directory"
21942 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
21943 error "bad stripe count in sub-directory"
21944 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
21945 error "bad stripe size in sub-directory"
21948 run_test 270c "DoM: DoM EA inheritance tests"
21951 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21952 skip "Need MDS version at least 2.10.55"
21954 mkdir -p $DIR/$tdir
21955 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
21957 # inherit default DoM striping
21958 mkdir $DIR/$tdir/subdir
21959 touch $DIR/$tdir/subdir/f1
21961 # change default directory striping
21962 $LFS setstripe -c 1 $DIR/$tdir/subdir
21963 touch $DIR/$tdir/subdir/f2
21964 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
21965 error "wrong default striping in file 2"
21966 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
21967 error "bad pattern in file 2"
21970 run_test 270d "DoM: change striping from DoM to RAID0"
21973 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
21974 skip "Need MDS version at least 2.10.55"
21976 mkdir -p $DIR/$tdir/dom
21977 mkdir -p $DIR/$tdir/norm
21980 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
21981 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
21983 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
21984 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
21986 # find DoM files by layout
21987 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
21988 [ $NUM -eq $DOMFILES ] ||
21989 error "lfs find -L: found $NUM, expected $DOMFILES"
21990 echo "Test 1: lfs find 20 DOM files by layout: OK"
21992 # there should be 1 dir with default DOM striping
21993 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
21995 error "lfs find -L: found $NUM, expected 1 dir"
21996 echo "Test 2: lfs find 1 DOM dir by layout: OK"
21998 # find DoM files by stripe size
21999 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
22000 [ $NUM -eq $DOMFILES ] ||
22001 error "lfs find -S: found $NUM, expected $DOMFILES"
22002 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
22004 # find files by stripe offset except DoM files
22005 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
22006 [ $NUM -eq $NORMFILES ] ||
22007 error "lfs find -i: found $NUM, expected $NORMFILES"
22008 echo "Test 5: lfs find no DOM files by stripe index: OK"
22011 run_test 270e "DoM: lfs find with DoM files test"
22014 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22015 skip "Need MDS version at least 2.10.55"
22017 local mdtname=${FSNAME}-MDT0000-mdtlov
22018 local dom=$DIR/$tdir/dom_file
22019 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
22020 lod.$mdtname.dom_stripesize)
22021 local dom_limit=131072
22023 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
22024 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22025 lod.$mdtname.dom_stripesize)
22026 [ ${dom_limit} -eq ${dom_current} ] ||
22027 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
22029 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22030 $LFS setstripe -d $DIR/$tdir
22031 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
22032 error "Can't set directory default striping"
22034 # exceed maximum stripe size
22035 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22036 error "Can't create file with $((dom_limit * 2)) DoM stripe"
22037 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
22038 error "Able to create DoM component size more than LOD limit"
22040 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22041 dom_current=$(do_facet mds1 $LCTL get_param -n \
22042 lod.$mdtname.dom_stripesize)
22043 [ 0 -eq ${dom_current} ] ||
22044 error "Can't set zero DoM stripe limit"
22047 # attempt to create DoM file on server with disabled DoM should
22048 # remove DoM entry from layout and be succeed
22049 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
22050 error "Can't create DoM file (DoM is disabled)"
22051 [ $($LFS getstripe -L $dom) == "mdt" ] &&
22052 error "File has DoM component while DoM is disabled"
22055 # attempt to create DoM file with only DoM stripe should return error
22056 $LFS setstripe -E $dom_limit -L mdt $dom &&
22057 error "Able to create DoM-only file while DoM is disabled"
22059 # too low values to be aligned with smallest stripe size 64K
22060 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
22061 dom_current=$(do_facet mds1 $LCTL get_param -n \
22062 lod.$mdtname.dom_stripesize)
22063 [ 30000 -eq ${dom_current} ] &&
22064 error "Can set too small DoM stripe limit"
22066 # 64K is a minimal stripe size in Lustre, expect limit of that size
22067 [ 65536 -eq ${dom_current} ] ||
22068 error "Limit is not set to 64K but ${dom_current}"
22070 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
22071 dom_current=$(do_facet mds1 $LCTL get_param -n \
22072 lod.$mdtname.dom_stripesize)
22074 [ 2147483648 -eq ${dom_current} ] &&
22075 error "Can set too large DoM stripe limit"
22077 do_facet mds1 $LCTL set_param -n \
22078 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
22079 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22080 error "Can't create DoM component size after limit change"
22081 do_facet mds1 $LCTL set_param -n \
22082 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
22083 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
22084 error "Can't create DoM file after limit decrease"
22085 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
22086 error "Can create big DoM component after limit decrease"
22087 touch ${dom}_def ||
22088 error "Can't create file with old default layout"
22090 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
22093 run_test 270f "DoM: maximum DoM stripe size checks"
22096 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
22097 skip "Need MDS version at least 2.13.52"
22098 local dom=$DIR/$tdir/$tfile
22100 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22101 local lodname=${FSNAME}-MDT0000-mdtlov
22103 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22104 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
22105 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
22106 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22108 local dom_limit=1024
22109 local dom_threshold="50%"
22111 $LFS setstripe -d $DIR/$tdir
22112 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
22113 error "Can't set directory default striping"
22115 do_facet mds1 $LCTL set_param -n \
22116 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
22117 # set 0 threshold and create DOM file to change tunable stripesize
22118 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
22119 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22120 error "Failed to create $dom file"
22121 # now tunable dom_cur_stripesize should reach maximum
22122 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22123 lod.${lodname}.dom_stripesize_cur_kb)
22124 [[ $dom_current == $dom_limit ]] ||
22125 error "Current DOM stripesize is not maximum"
22128 # set threshold for further tests
22129 do_facet mds1 $LCTL set_param -n \
22130 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
22131 echo "DOM threshold is $dom_threshold free space"
22134 # Spoof bfree to exceed threshold
22135 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
22136 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
22137 for spfree in 40 20 0 15 30 55; do
22138 do_facet mds1 $LCTL set_param -n fail_val=$spfree
22139 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22140 error "Failed to create $dom file"
22141 dom_def=$(do_facet mds1 $LCTL get_param -n \
22142 lod.${lodname}.dom_stripesize_cur_kb)
22143 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
22144 [[ $dom_def != $dom_current ]] ||
22145 error "Default stripe size was not changed"
22146 if [[ $spfree > 0 ]] ; then
22147 dom_set=$($LFS getstripe -S $dom)
22148 [[ $dom_set == $((dom_def * 1024)) ]] ||
22149 error "DOM component size is still old"
22151 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22152 error "DoM component is set with no free space"
22155 dom_current=$dom_def
22158 run_test 270g "DoM: default DoM stripe size depends on free space"
22161 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
22162 skip "Need MDS version at least 2.13.53"
22164 local mdtname=${FSNAME}-MDT0000-mdtlov
22165 local dom=$DIR/$tdir/$tfile
22166 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22168 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
22169 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22171 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22172 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
22173 error "can't create OST file"
22174 # mirrored file with DOM entry in the second mirror
22175 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
22176 error "can't create mirror with DoM component"
22178 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22180 # DOM component in the middle and has other enries in the same mirror,
22181 # should succeed but lost DoM component
22182 $LFS setstripe --copy=${dom}_1 $dom ||
22183 error "Can't create file from OST|DOM mirror layout"
22184 # check new file has no DoM layout after all
22185 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22186 error "File has DoM component while DoM is disabled"
22188 run_test 270h "DoM: DoM stripe removal when disabled on server"
22191 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
22192 skip "Need MDS version at least 2.14.54"
22195 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir &&
22196 error "setstripe should fail" || true
22198 run_test 270i "DoM: setting invalid DoM striping should fail"
22201 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22202 skip "Need MDS version at least 2.10.55"
22204 local dom=$DIR/$tdir/dom
22206 mkdir -p $DIR/$tdir
22208 $LFS setstripe -E 1024K -L mdt $dom
22210 lctl set_param -n mdc.*.stats=clear
22211 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
22212 cat $dom > /dev/null
22213 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
22214 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
22218 run_test 271a "DoM: data is cached for read after write"
22221 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22222 skip "Need MDS version at least 2.10.55"
22224 local dom=$DIR/$tdir/dom
22226 mkdir -p $DIR/$tdir
22228 $LFS setstripe -E 1024K -L mdt -E EOF $dom
22230 lctl set_param -n mdc.*.stats=clear
22231 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
22232 cancel_lru_locks mdc
22233 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
22234 # second stat to check size is cached on client
22235 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
22236 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
22237 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
22240 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
22243 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22244 skip "Need MDS version at least 2.10.55"
22246 local dom=$DIR/$tdir/dom
22248 mkdir -p $DIR/$tdir
22250 $LFS setstripe -E 1024K -L mdt -E EOF $dom
22252 lctl set_param -n mdc.*.stats=clear
22253 lctl set_param -n osc.*.stats=clear
22254 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
22255 cancel_lru_locks mdc
22256 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
22257 # second stat to check size is cached on client
22258 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
22259 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
22260 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
22261 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
22262 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
22265 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
22271 local mdt=MDT$(printf %04x $mdtidx)
22273 if [ -z $param ]; then
22274 lctl get_param -n mdc.*$mdt*.stats
22276 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
22281 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22282 skip "Need MDS version at least 2.10.55"
22284 local dom=$DIR/$tdir/dom
22286 mkdir -p $DIR/$tdir
22288 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22290 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
22291 local facet=mds$((mdtidx + 1))
22293 cancel_lru_locks mdc
22294 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
22295 createmany -o $dom 1000
22296 lctl set_param -n mdc.*.stats=clear
22297 smalliomany -w $dom 1000 200
22298 get_mdc_stats $mdtidx
22299 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
22300 # Each file has 1 open, 1 IO enqueues, total 2000
22301 # but now we have also +1 getxattr for security.capability, total 3000
22302 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
22303 unlinkmany $dom 1000
22305 cancel_lru_locks mdc
22306 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
22307 createmany -o $dom 1000
22308 lctl set_param -n mdc.*.stats=clear
22309 smalliomany -w $dom 1000 200
22310 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
22311 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
22312 # for OPEN and IO lock.
22313 [ $((enq - enq_2)) -ge 1000 ] ||
22314 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
22315 unlinkmany $dom 1000
22318 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
22320 cleanup_271def_tests() {
22326 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
22327 skip "Need MDS version at least 2.10.57"
22329 local dom=$DIR/$tdir/dom
22330 local tmp=$TMP/$tfile
22331 trap "cleanup_271def_tests $tmp" EXIT
22333 mkdir -p $DIR/$tdir
22335 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22337 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
22339 cancel_lru_locks mdc
22340 dd if=/dev/urandom of=$tmp bs=1000 count=1
22341 dd if=$tmp of=$dom bs=1000 count=1
22342 cancel_lru_locks mdc
22344 cat /etc/hosts >> $tmp
22345 lctl set_param -n mdc.*.stats=clear
22347 # append data to the same file it should update local page
22348 echo "Append to the same page"
22349 cat /etc/hosts >> $dom
22350 local num=$(get_mdc_stats $mdtidx ost_read)
22351 local ra=$(get_mdc_stats $mdtidx req_active)
22352 local rw=$(get_mdc_stats $mdtidx req_waittime)
22354 [ -z $num ] || error "$num READ RPC occured"
22355 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22359 cmp $tmp $dom || error "file miscompare"
22361 cancel_lru_locks mdc
22362 lctl set_param -n mdc.*.stats=clear
22364 echo "Open and read file"
22365 cat $dom > /dev/null
22366 local num=$(get_mdc_stats $mdtidx ost_read)
22367 local ra=$(get_mdc_stats $mdtidx req_active)
22368 local rw=$(get_mdc_stats $mdtidx req_waittime)
22370 [ -z $num ] || error "$num READ RPC occured"
22371 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22375 cmp $tmp $dom || error "file miscompare"
22379 run_test 271d "DoM: read on open (1K file in reply buffer)"
22382 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
22383 skip "Need MDS version at least 2.10.57"
22385 local dom=$DIR/$tdir/dom
22386 local tmp=$TMP/$tfile
22387 trap "cleanup_271def_tests $tmp" EXIT
22389 mkdir -p $DIR/$tdir
22391 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22393 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
22395 cancel_lru_locks mdc
22396 dd if=/dev/urandom of=$tmp bs=265000 count=1
22397 dd if=$tmp of=$dom bs=265000 count=1
22398 cancel_lru_locks mdc
22399 cat /etc/hosts >> $tmp
22400 lctl set_param -n mdc.*.stats=clear
22402 echo "Append to the same page"
22403 cat /etc/hosts >> $dom
22404 local num=$(get_mdc_stats $mdtidx ost_read)
22405 local ra=$(get_mdc_stats $mdtidx req_active)
22406 local rw=$(get_mdc_stats $mdtidx req_waittime)
22408 [ -z $num ] || error "$num READ RPC occured"
22409 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22413 cmp $tmp $dom || error "file miscompare"
22415 cancel_lru_locks mdc
22416 lctl set_param -n mdc.*.stats=clear
22418 echo "Open and read file"
22419 cat $dom > /dev/null
22420 local num=$(get_mdc_stats $mdtidx ost_read)
22421 local ra=$(get_mdc_stats $mdtidx req_active)
22422 local rw=$(get_mdc_stats $mdtidx req_waittime)
22424 [ -z $num ] && num=0
22425 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
22426 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22430 cmp $tmp $dom || error "file miscompare"
22434 run_test 271f "DoM: read on open (200K file and read tail)"
22437 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
22438 skip "Skipping due to old client or server version"
22440 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
22442 $CHECKSTAT -t file $DIR1/$tfile
22444 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
22447 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
22448 $LCTL set_param fail_loc=0x80000314
22449 rm $DIR1/$tfile || error "Unlink fails"
22451 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
22452 [ $RC -eq 0 ] || error "Failed write to stale object"
22454 run_test 271g "Discard DoM data vs client flush race"
22457 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22458 skip "Need MDS version at least 2.11.50"
22460 local dom=$DIR/$tdir/dom
22461 mkdir -p $DIR/$tdir
22463 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
22464 dd if=/dev/urandom of=$dom bs=512K count=1 ||
22465 error "failed to write data into $dom"
22466 local old_md5=$(md5sum $dom)
22468 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
22469 error "failed to migrate to the same DoM component"
22471 local new_md5=$(md5sum $dom)
22473 [ "$old_md5" == "$new_md5" ] ||
22474 error "md5sum differ: $old_md5, $new_md5"
22476 [ $($LFS getstripe -c $dom) -eq 2 ] ||
22477 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
22479 run_test 272a "DoM migration: new layout with the same DOM component"
22482 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22483 skip "Need MDS version at least 2.11.50"
22485 local dom=$DIR/$tdir/dom
22486 mkdir -p $DIR/$tdir
22487 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22489 local mdtidx=$($LFS getstripe -m $dom)
22490 local mdtname=MDT$(printf %04x $mdtidx)
22491 local facet=mds$((mdtidx + 1))
22493 local mdtfree1=$(do_facet $facet \
22494 lctl get_param -n osd*.*$mdtname.kbytesfree)
22495 dd if=/dev/urandom of=$dom bs=2M count=1 ||
22496 error "failed to write data into $dom"
22497 local old_md5=$(md5sum $dom)
22498 cancel_lru_locks mdc
22499 local mdtfree1=$(do_facet $facet \
22500 lctl get_param -n osd*.*$mdtname.kbytesfree)
22502 $LFS migrate -c2 $dom ||
22503 error "failed to migrate to the new composite layout"
22504 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22505 error "MDT stripe was not removed"
22507 cancel_lru_locks mdc
22508 local new_md5=$(md5sum $dom)
22509 [ "$old_md5" == "$new_md5" ] ||
22510 error "$old_md5 != $new_md5"
22512 # Skip free space checks with ZFS
22513 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22514 local mdtfree2=$(do_facet $facet \
22515 lctl get_param -n osd*.*$mdtname.kbytesfree)
22516 [ $mdtfree2 -gt $mdtfree1 ] ||
22517 error "MDT space is not freed after migration"
22521 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
22524 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22525 skip "Need MDS version at least 2.11.50"
22527 local dom=$DIR/$tdir/$tfile
22528 mkdir -p $DIR/$tdir
22529 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22531 local mdtidx=$($LFS getstripe -m $dom)
22532 local mdtname=MDT$(printf %04x $mdtidx)
22533 local facet=mds$((mdtidx + 1))
22535 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
22536 error "failed to write data into $dom"
22537 local old_md5=$(md5sum $dom)
22538 cancel_lru_locks mdc
22539 local mdtfree1=$(do_facet $facet \
22540 lctl get_param -n osd*.*$mdtname.kbytesfree)
22542 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
22543 error "failed to migrate to the new composite layout"
22544 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
22545 error "MDT stripe was not removed"
22547 cancel_lru_locks mdc
22548 local new_md5=$(md5sum $dom)
22549 [ "$old_md5" == "$new_md5" ] ||
22550 error "$old_md5 != $new_md5"
22552 # Skip free space checks with ZFS
22553 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22554 local mdtfree2=$(do_facet $facet \
22555 lctl get_param -n osd*.*$mdtname.kbytesfree)
22556 [ $mdtfree2 -gt $mdtfree1 ] ||
22557 error "MDS space is not freed after migration"
22561 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
22564 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22565 skip "Need MDS version at least 2.12.55"
22567 local dom=$DIR/$tdir/$tfile
22568 mkdir -p $DIR/$tdir
22569 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22571 local mdtidx=$($LFS getstripe -m $dom)
22572 local mdtname=MDT$(printf %04x $mdtidx)
22573 local facet=mds$((mdtidx + 1))
22575 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
22576 error "failed to write data into $dom"
22577 local old_md5=$(md5sum $dom)
22578 cancel_lru_locks mdc
22579 local mdtfree1=$(do_facet $facet \
22580 lctl get_param -n osd*.*$mdtname.kbytesfree)
22582 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
22583 error "failed mirroring to the new composite layout"
22584 $LFS mirror resync $dom ||
22585 error "failed mirror resync"
22586 $LFS mirror split --mirror-id 1 -d $dom ||
22587 error "failed mirror split"
22589 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22590 error "MDT stripe was not removed"
22592 cancel_lru_locks mdc
22593 local new_md5=$(md5sum $dom)
22594 [ "$old_md5" == "$new_md5" ] ||
22595 error "$old_md5 != $new_md5"
22597 # Skip free space checks with ZFS
22598 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22599 local mdtfree2=$(do_facet $facet \
22600 lctl get_param -n osd*.*$mdtname.kbytesfree)
22601 [ $mdtfree2 -gt $mdtfree1 ] ||
22602 error "MDS space is not freed after DOM mirror deletion"
22606 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
22609 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22610 skip "Need MDS version at least 2.12.55"
22612 local dom=$DIR/$tdir/$tfile
22613 mkdir -p $DIR/$tdir
22614 $LFS setstripe -c 2 $dom
22616 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
22617 error "failed to write data into $dom"
22618 local old_md5=$(md5sum $dom)
22619 cancel_lru_locks mdc
22621 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
22622 error "failed mirroring to the DOM layout"
22623 $LFS mirror resync $dom ||
22624 error "failed mirror resync"
22625 $LFS mirror split --mirror-id 1 -d $dom ||
22626 error "failed mirror split"
22628 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22629 error "MDT stripe was not removed"
22631 cancel_lru_locks mdc
22632 local new_md5=$(md5sum $dom)
22633 [ "$old_md5" == "$new_md5" ] ||
22634 error "$old_md5 != $new_md5"
22638 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
22641 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22642 skip "Need MDS version at least 2.12.55"
22644 local dom=$DIR/$tdir/$tfile
22645 mkdir -p $DIR/$tdir
22646 $LFS setstripe -c 2 $dom
22648 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
22649 error "failed to write data into $dom"
22650 local old_md5=$(md5sum $dom)
22651 cancel_lru_locks mdc
22653 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
22654 error "failed migrating to the DOM file"
22656 cancel_lru_locks mdc
22657 local new_md5=$(md5sum $dom)
22658 [ "$old_md5" != "$new_md5" ] &&
22659 error "$old_md5 != $new_md5"
22663 run_test 272f "DoM migration: OST-striped file to DOM file"
22666 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22667 skip "Need MDS version at least 2.11.50"
22669 # Layout swap cannot be done if either file has DOM component,
22670 # this will never be supported, migration should be used instead
22672 local dom=$DIR/$tdir/$tfile
22673 mkdir -p $DIR/$tdir
22675 $LFS setstripe -c2 ${dom}_plain
22676 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
22677 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
22678 error "can swap layout with DoM component"
22679 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
22680 error "can swap layout with DoM component"
22682 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
22683 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
22684 error "can swap layout with DoM component"
22685 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
22686 error "can swap layout with DoM component"
22689 run_test 273a "DoM: layout swapping should fail with DOM"
22692 mkdir -p $DIR/$tdir
22693 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
22695 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
22696 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
22698 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
22700 run_test 273b "DoM: race writeback and object destroy"
22703 remote_ost_nodsh && skip "remote OST with nodsh"
22704 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
22705 skip "Need OST version >= 2.10.57"
22707 local file=$DIR/$tfile
22710 oss=$(comma_list $(osts_nodes))
22712 dd if=/dev/urandom of=$file bs=1M count=2 ||
22713 error "failed to create a file"
22714 cancel_lru_locks osc
22717 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
22718 error "failed to read a file"
22720 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
22721 $LCTL set_param fail_loc=0x8000031f
22723 cancel_lru_locks osc &
22726 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
22727 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
22728 #IO takes another lock, but matches the PENDING one
22729 #and places it to the IO RPC
22730 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
22731 error "failed to read a file with PENDING lock"
22733 run_test 275 "Read on a canceled duplicate lock"
22736 remote_ost_nodsh && skip "remote OST with nodsh"
22739 do_facet ost1 "(while true; do \
22740 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
22741 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
22744 for LOOP in $(seq 20); do
22746 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
22749 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
22750 rm $TMP/sanity_276_pid"
22752 run_test 276 "Race between mount and obd_statfs"
22755 $LCTL set_param ldlm.namespaces.*.lru_size=0
22756 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
22757 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
22758 grep ^used_mb | awk '{print $2}')
22759 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
22760 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
22761 oflag=direct conv=notrunc
22762 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
22763 grep ^used_mb | awk '{print $2}')
22764 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
22766 run_test 277 "Direct IO shall drop page cache"
22769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
22770 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
22771 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
22772 skip "needs the same host for mdt1 mdt2" && return
22777 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
22778 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
22784 echo "Starting MDTs"
22785 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
22787 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
22789 do_facet mds2 $LCTL set_param fail_loc=0
22791 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
22792 wait_recovery_complete mds2
22794 run_test 278 "Race starting MDS between MDTs stop/start"
22797 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
22798 skip "Need MGS version at least 2.13.52"
22799 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22800 combined_mgs_mds || skip "needs combined MGS/MDT"
22802 umount_client $MOUNT
22803 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
22804 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
22806 mount_client $MOUNT &
22808 stop mgs || error "stop mgs failed"
22809 #for a race mgs would crash
22810 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
22811 # make sure we unmount client before remounting
22813 umount_client $MOUNT
22814 mount_client $MOUNT || error "mount client failed"
22816 run_test 280 "Race between MGS umount and client llog processing"
22818 cleanup_test_300() {
22822 test_striped_dir() {
22827 mkdir -p $DIR/$tdir
22829 SAVE_UMASK=$(umask)
22830 trap cleanup_test_300 RETURN EXIT
22832 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
22833 $DIR/$tdir/striped_dir ||
22834 error "set striped dir error"
22836 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
22837 [ "$mode" = "755" ] || error "expect 755 got $mode"
22839 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
22840 error "getdirstripe failed"
22841 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
22842 if [ "$stripe_count" != "2" ]; then
22843 error "1:stripe_count is $stripe_count, expect 2"
22845 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
22846 if [ "$stripe_count" != "2" ]; then
22847 error "2:stripe_count is $stripe_count, expect 2"
22850 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
22851 if [ "$stripe_index" != "$mdt_index" ]; then
22852 error "stripe_index is $stripe_index, expect $mdt_index"
22855 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
22856 error "nlink error after create striped dir"
22858 mkdir $DIR/$tdir/striped_dir/a
22859 mkdir $DIR/$tdir/striped_dir/b
22861 stat $DIR/$tdir/striped_dir/a ||
22862 error "create dir under striped dir failed"
22863 stat $DIR/$tdir/striped_dir/b ||
22864 error "create dir under striped dir failed"
22866 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
22867 error "nlink error after mkdir"
22869 rmdir $DIR/$tdir/striped_dir/a
22870 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
22871 error "nlink error after rmdir"
22873 rmdir $DIR/$tdir/striped_dir/b
22874 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
22875 error "nlink error after rmdir"
22877 chattr +i $DIR/$tdir/striped_dir
22878 createmany -o $DIR/$tdir/striped_dir/f 10 &&
22879 error "immutable flags not working under striped dir!"
22880 chattr -i $DIR/$tdir/striped_dir
22882 rmdir $DIR/$tdir/striped_dir ||
22883 error "rmdir striped dir error"
22891 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22892 skip "skipped for lustre < 2.7.0"
22893 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22894 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22896 test_striped_dir 0 || error "failed on striped dir on MDT0"
22897 test_striped_dir 1 || error "failed on striped dir on MDT0"
22899 run_test 300a "basic striped dir sanity test"
22902 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22903 skip "skipped for lustre < 2.7.0"
22904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22905 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22912 test_mkdir $DIR/$tdir || error "mkdir fail"
22913 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
22914 error "set striped dir error"
22915 for i in {0..9}; do
22916 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
22918 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
22919 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
22920 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
22922 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
22923 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
22924 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
22928 run_test 300b "check ctime/mtime for striped dir"
22931 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22932 skip "skipped for lustre < 2.7.0"
22933 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22934 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22938 mkdir_on_mdt0 $DIR/$tdir
22939 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
22940 error "set striped dir error"
22942 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
22943 error "chown striped dir failed"
22945 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
22946 error "create 5k files failed"
22948 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
22950 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
22954 run_test 300c "chown && check ls under striped directory"
22957 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
22958 skip "skipped for lustre < 2.7.0"
22959 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22960 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22965 mkdir -p $DIR/$tdir
22966 $LFS setstripe -c 2 $DIR/$tdir
22968 #local striped directory
22969 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
22970 error "set striped dir error"
22971 #look at the directories for debug purposes
22973 $LFS getdirstripe $DIR/$tdir
22974 ls -l $DIR/$tdir/striped_dir
22975 $LFS getdirstripe $DIR/$tdir/striped_dir
22976 createmany -o $DIR/$tdir/striped_dir/f 10 ||
22977 error "create 10 files failed"
22979 #remote striped directory
22980 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
22981 error "set striped dir error"
22982 #look at the directories for debug purposes
22984 $LFS getdirstripe $DIR/$tdir
22985 ls -l $DIR/$tdir/remote_striped_dir
22986 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
22987 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
22988 error "create 10 files failed"
22990 for file in $(find $DIR/$tdir); do
22991 stripe_count=$($LFS getstripe -c $file)
22992 [ $stripe_count -eq 2 ] ||
22993 error "wrong stripe $stripe_count for $file"
22998 run_test 300d "check default stripe under striped directory"
23001 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23002 skip "Need MDS version at least 2.7.55"
23003 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23004 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23009 mkdir -p $DIR/$tdir
23011 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23012 error "set striped dir error"
23014 touch $DIR/$tdir/striped_dir/a
23015 touch $DIR/$tdir/striped_dir/b
23016 touch $DIR/$tdir/striped_dir/c
23018 mkdir $DIR/$tdir/striped_dir/dir_a
23019 mkdir $DIR/$tdir/striped_dir/dir_b
23020 mkdir $DIR/$tdir/striped_dir/dir_c
23022 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
23023 error "set striped adir under striped dir error"
23025 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
23026 error "set striped bdir under striped dir error"
23028 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
23029 error "set striped cdir under striped dir error"
23031 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
23032 error "rename dir under striped dir fails"
23034 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
23035 error "rename dir under different stripes fails"
23037 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
23038 error "rename file under striped dir should succeed"
23040 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
23041 error "rename dir under striped dir should succeed"
23045 run_test 300e "check rename under striped directory"
23048 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23049 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23050 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23051 skip "Need MDS version at least 2.7.55"
23057 mkdir -p $DIR/$tdir
23059 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23060 error "set striped dir error"
23062 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
23063 error "set striped dir error"
23065 touch $DIR/$tdir/striped_dir/a
23066 mkdir $DIR/$tdir/striped_dir/dir_a
23067 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
23068 error "create striped dir under striped dir fails"
23070 touch $DIR/$tdir/striped_dir1/b
23071 mkdir $DIR/$tdir/striped_dir1/dir_b
23072 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
23073 error "create striped dir under striped dir fails"
23075 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
23076 error "rename dir under different striped dir should fail"
23078 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
23079 error "rename striped dir under diff striped dir should fail"
23081 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
23082 error "rename file under diff striped dirs fails"
23086 run_test 300f "check rename cross striped directory"
23088 test_300_check_default_striped_dir()
23091 local default_count=$2
23092 local default_index=$3
23095 local dir_stripe_index
23098 echo "checking $dirname $default_count $default_index"
23099 $LFS setdirstripe -D -c $default_count -i $default_index \
23100 -H all_char $DIR/$tdir/$dirname ||
23101 error "set default stripe on striped dir error"
23102 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
23103 [ $stripe_count -eq $default_count ] ||
23104 error "expect $default_count get $stripe_count for $dirname"
23106 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
23107 [ $stripe_index -eq $default_index ] ||
23108 error "expect $default_index get $stripe_index for $dirname"
23110 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
23111 error "create dirs failed"
23113 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
23114 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
23115 for dir in $(find $DIR/$tdir/$dirname/*); do
23116 stripe_count=$($LFS getdirstripe -c $dir)
23117 (( $stripe_count == $default_count )) ||
23118 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
23119 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
23120 error "stripe count $default_count != $stripe_count for $dir"
23122 stripe_index=$($LFS getdirstripe -i $dir)
23123 [ $default_index -eq -1 ] ||
23124 [ $stripe_index -eq $default_index ] ||
23125 error "$stripe_index != $default_index for $dir"
23127 #check default stripe
23128 stripe_count=$($LFS getdirstripe -D -c $dir)
23129 [ $stripe_count -eq $default_count ] ||
23130 error "default count $default_count != $stripe_count for $dir"
23132 stripe_index=$($LFS getdirstripe -D -i $dir)
23133 [ $stripe_index -eq $default_index ] ||
23134 error "default index $default_index != $stripe_index for $dir"
23136 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
23140 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23141 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23142 skip "Need MDS version at least 2.7.55"
23148 mkdir_on_mdt0 $DIR/$tdir
23149 mkdir $DIR/$tdir/normal_dir
23151 #Checking when client cache stripe index
23152 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
23153 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
23154 error "create striped_dir failed"
23156 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
23157 error "create dir0 fails"
23158 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
23159 [ $stripe_index -eq 0 ] ||
23160 error "dir0 expect index 0 got $stripe_index"
23162 mkdir $DIR/$tdir/striped_dir/dir1 ||
23163 error "create dir1 fails"
23164 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
23165 [ $stripe_index -eq 1 ] ||
23166 error "dir1 expect index 1 got $stripe_index"
23168 #check default stripe count/stripe index
23169 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
23170 test_300_check_default_striped_dir normal_dir 1 0
23171 test_300_check_default_striped_dir normal_dir -1 1
23172 test_300_check_default_striped_dir normal_dir 2 -1
23174 #delete default stripe information
23175 echo "delete default stripeEA"
23176 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
23177 error "set default stripe on striped dir error"
23179 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
23180 for dir in $(find $DIR/$tdir/normal_dir/*); do
23181 stripe_count=$($LFS getdirstripe -c $dir)
23182 [ $stripe_count -eq 0 ] ||
23183 error "expect 1 get $stripe_count for $dir"
23186 run_test 300g "check default striped directory for normal directory"
23189 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23190 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23191 skip "Need MDS version at least 2.7.55"
23197 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23198 error "set striped dir error"
23200 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
23201 test_300_check_default_striped_dir striped_dir 1 0
23202 test_300_check_default_striped_dir striped_dir -1 1
23203 test_300_check_default_striped_dir striped_dir 2 -1
23205 #delete default stripe information
23206 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
23207 error "set default stripe on striped dir error"
23209 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
23210 for dir in $(find $DIR/$tdir/striped_dir/*); do
23211 stripe_count=$($LFS getdirstripe -c $dir)
23212 [ $stripe_count -eq 0 ] ||
23213 error "expect 1 get $stripe_count for $dir"
23216 run_test 300h "check default striped directory for striped directory"
23219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23220 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23221 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23222 skip "Need MDS version at least 2.7.55"
23229 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23230 error "set striped dir error"
23232 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
23233 error "create files under striped dir failed"
23235 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
23236 error "set striped hashdir error"
23238 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
23239 error "create dir0 under hash dir failed"
23240 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
23241 error "create dir1 under hash dir failed"
23242 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
23243 error "create dir2 under hash dir failed"
23245 # unfortunately, we need to umount to clear dir layout cache for now
23246 # once we fully implement dir layout, we can drop this
23247 umount_client $MOUNT || error "umount failed"
23248 mount_client $MOUNT || error "mount failed"
23250 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
23251 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
23252 [ $dircnt -eq 2 ] || error "lfs find striped dir got:$dircnt,except:1"
23254 #set the stripe to be unknown hash type
23255 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
23256 $LCTL set_param fail_loc=0x1901
23257 for ((i = 0; i < 10; i++)); do
23258 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
23259 error "stat f-$i failed"
23260 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
23263 touch $DIR/$tdir/striped_dir/f0 &&
23264 error "create under striped dir with unknown hash should fail"
23266 $LCTL set_param fail_loc=0
23268 umount_client $MOUNT || error "umount failed"
23269 mount_client $MOUNT || error "mount failed"
23273 run_test 300i "client handle unknown hash type striped directory"
23276 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23277 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23278 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23279 skip "Need MDS version at least 2.7.55"
23286 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
23287 $LCTL set_param fail_loc=0x1702
23288 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23289 error "set striped dir error"
23291 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
23292 error "create files under striped dir failed"
23294 $LCTL set_param fail_loc=0
23296 rm -rf $DIR/$tdir || error "unlink striped dir fails"
23300 run_test 300j "test large update record"
23303 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23304 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23305 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23306 skip "Need MDS version at least 2.7.55"
23308 # this test needs a huge transaction
23310 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
23311 osd*.$FSNAME-MDT0000.kbytestotal")
23312 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
23319 #define OBD_FAIL_LARGE_STRIPE 0x1703
23320 $LCTL set_param fail_loc=0x1703
23321 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
23322 error "set striped dir error"
23323 $LCTL set_param fail_loc=0
23325 $LFS getdirstripe $DIR/$tdir/striped_dir ||
23326 error "getstripeddir fails"
23327 rm -rf $DIR/$tdir/striped_dir ||
23328 error "unlink striped dir fails"
23332 run_test 300k "test large striped directory"
23335 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23336 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23337 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23338 skip "Need MDS version at least 2.7.55"
23342 test_mkdir -p $DIR/$tdir/striped_dir
23343 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
23344 error "chown $RUNAS_ID failed"
23345 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
23346 error "set default striped dir failed"
23348 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
23349 $LCTL set_param fail_loc=0x80000158
23350 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
23352 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
23353 [ $stripe_index -eq 1 ] ||
23354 error "expect 1 get $stripe_index for $dir"
23356 run_test 300l "non-root user to create dir under striped dir with stale layout"
23359 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23360 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
23361 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23362 skip "Need MDS version at least 2.7.55"
23364 mkdir -p $DIR/$tdir/striped_dir
23365 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
23366 error "set default stripes dir error"
23368 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
23370 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
23371 [ $stripe_count -eq 0 ] ||
23372 error "expect 0 get $stripe_count for a"
23374 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
23375 error "set default stripes dir error"
23377 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
23379 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
23380 [ $stripe_count -eq 0 ] ||
23381 error "expect 0 get $stripe_count for b"
23383 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
23384 error "set default stripes dir error"
23386 mkdir $DIR/$tdir/striped_dir/c &&
23387 error "default stripe_index is invalid, mkdir c should fails"
23389 rm -rf $DIR/$tdir || error "rmdir fails"
23391 run_test 300m "setstriped directory on single MDT FS"
23394 local list=$(comma_list $(mdts_nodes))
23397 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
23401 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23402 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23403 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23404 skip "Need MDS version at least 2.7.55"
23405 remote_mds_nodsh && skip "remote MDS with nodsh"
23408 local list=$(comma_list $(mdts_nodes))
23410 trap cleanup_300n RETURN EXIT
23411 mkdir -p $DIR/$tdir
23412 chmod 777 $DIR/$tdir
23413 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
23414 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
23415 error "create striped dir succeeds with gid=0"
23417 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
23418 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
23419 error "create striped dir fails with gid=-1"
23421 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
23422 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
23423 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
23424 error "set default striped dir succeeds with gid=0"
23427 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
23428 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
23429 error "set default striped dir fails with gid=-1"
23432 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
23433 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
23434 error "create test_dir fails"
23435 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
23436 error "create test_dir1 fails"
23437 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
23438 error "create test_dir2 fails"
23441 run_test 300n "non-root user to create dir under striped dir with default EA"
23444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23445 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23446 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23447 skip "Need MDS version at least 2.7.55"
23452 mkdir -p $DIR/$tdir
23454 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
23455 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
23456 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
23457 skip "not enough free inodes $numfree1 $numfree2"
23460 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
23461 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
23462 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
23463 skip "not enough free space $numfree1 $numfree2"
23466 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
23467 error "setdirstripe fails"
23469 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
23470 error "create dirs fails"
23472 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
23473 ls $DIR/$tdir/striped_dir > /dev/null ||
23474 error "ls striped dir fails"
23475 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
23476 error "unlink big striped dir fails"
23478 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
23481 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23482 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23483 remote_mds_nodsh && skip "remote MDS with nodsh"
23485 mkdir_on_mdt0 $DIR/$tdir
23487 #define OBD_FAIL_OUT_ENOSPC 0x1704
23488 do_facet mds2 lctl set_param fail_loc=0x80001704
23489 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
23490 && error "create striped directory should fail"
23492 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
23494 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
23497 run_test 300p "create striped directory without space"
23500 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23501 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23503 local fd=$(free_fd)
23504 local cmd="exec $fd<$tdir"
23506 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
23509 trap "eval $cmd" EXIT
23510 cd $tdir || error "cd $tdir fails"
23511 rmdir ../$tdir || error "rmdir $tdir fails"
23512 mkdir local_dir && error "create dir succeeds"
23513 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
23517 run_test 300q "create remote directory under orphan directory"
23520 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23521 skip "Need MDS version at least 2.7.55" && return
23522 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23526 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
23527 error "set striped dir error"
23529 $LFS getdirstripe $DIR/$tdir/striped_dir ||
23530 error "getstripeddir fails"
23533 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
23534 awk '/lmv_stripe_count:/ { print $2 }')
23536 [ $MDSCOUNT -ne $stripe_count ] &&
23537 error "wrong stripe count $stripe_count expected $MDSCOUNT"
23539 rm -rf $DIR/$tdir/striped_dir ||
23540 error "unlink striped dir fails"
23542 run_test 300r "test -1 striped directory"
23544 test_300s_helper() {
23547 local stripe_dir=$DIR/$tdir/striped_dir.$count
23549 $LFS mkdir -c $count $stripe_dir ||
23550 error "lfs mkdir -c error"
23552 $LFS getdirstripe $stripe_dir ||
23553 error "lfs getdirstripe fails"
23556 stripe_count=$($LFS getdirstripe $stripe_dir |
23557 awk '/lmv_stripe_count:/ { print $2 }')
23559 [ $count -ne $stripe_count ] &&
23560 error_noexit "bad stripe count $stripe_count expected $count"
23563 dupe_stripes=$($LFS getdirstripe $stripe_dir |
23564 awk '/0x/ {count[$1] += 1}; END {
23565 for (idx in count) {
23566 if (count[idx]>1) {
23567 print "index " idx " count " count[idx]
23572 if [[ -n "$dupe_stripes" ]] ; then
23573 lfs getdirstripe $stripe_dir
23574 error_noexit "Dupe MDT above: $dupe_stripes "
23577 rm -rf $stripe_dir ||
23578 error_noexit "unlink $stripe_dir fails"
23582 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23583 skip "Need MDS version at least 2.7.55" && return
23584 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23587 for count in $(seq 2 $MDSCOUNT); do
23588 test_300s_helper $count
23591 run_test 300s "test lfs mkdir -c without -i"
23594 prepare_remote_file() {
23595 mkdir $DIR/$tdir/src_dir ||
23596 error "create remote source failed"
23598 cp /etc/hosts $DIR/$tdir/src_dir/a ||
23599 error "cp to remote source failed"
23600 touch $DIR/$tdir/src_dir/a
23602 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
23603 error "create remote target dir failed"
23605 touch $DIR/$tdir/tgt_dir/b
23607 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
23608 error "rename dir cross MDT failed!"
23610 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
23611 error "src_child still exists after rename"
23613 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
23614 error "missing file(a) after rename"
23616 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
23617 error "diff after rename"
23621 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
23622 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23624 local remote_file=$DIR/$tdir/tgt_dir/b
23626 mkdir -p $DIR/$tdir
23628 prepare_remote_file || error "prepare remote file failed"
23631 $OPENUNLINK $remote_file $remote_file ||
23632 error "openunlink $remote_file failed"
23633 $CHECKSTAT -a $remote_file || error "$remote_file exists"
23635 run_test 310a "open unlink remote file"
23638 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
23639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23641 local remote_file=$DIR/$tdir/tgt_dir/b
23643 mkdir -p $DIR/$tdir
23645 prepare_remote_file || error "prepare remote file failed"
23647 ln $remote_file $DIR/$tfile || error "link failed for remote file"
23648 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
23649 $CHECKSTAT -t file $remote_file || error "check file failed"
23651 run_test 310b "unlink remote file with multiple links while open"
23654 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23655 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
23657 local remote_file=$DIR/$tdir/tgt_dir/b
23659 mkdir -p $DIR/$tdir
23661 prepare_remote_file || error "prepare remote file failed"
23663 ln $remote_file $DIR/$tfile || error "link failed for remote file"
23664 multiop_bg_pause $remote_file O_uc ||
23665 error "mulitop failed for remote file"
23667 $MULTIOP $DIR/$tfile Ouc
23668 kill -USR1 $MULTIPID
23671 run_test 310c "open-unlink remote file with multiple links"
23675 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23676 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
23677 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
23678 skip "lustre < 2.8.54 does not contain LU-4825 fix"
23679 remote_mds_nodsh && skip "remote MDS with nodsh"
23681 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
23682 local mdts=$(comma_list $(mdts_nodes))
23684 mkdir -p $DIR/$tdir
23685 $LFS setstripe -i 0 -c 1 $DIR/$tdir
23686 createmany -o $DIR/$tdir/$tfile. 1000
23688 # statfs data is not real time, let's just calculate it
23689 old_iused=$((old_iused + 1000))
23691 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
23692 osp.*OST0000*MDT0000.create_count")
23693 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
23694 osp.*OST0000*MDT0000.max_create_count")
23695 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
23697 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
23698 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
23699 [ $index -ne 0 ] || error "$tfile stripe index is 0"
23701 unlinkmany $DIR/$tdir/$tfile. 1000
23703 do_nodes $mdts "$LCTL set_param -n \
23704 osp.*OST0000*.max_create_count=$max_count"
23705 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
23706 do_nodes $mdts "$LCTL set_param -n \
23707 osp.*OST0000*.create_count=$count"
23708 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
23709 grep "=0" && error "create_count is zero"
23712 for i in $(seq 120); do
23713 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
23714 # system may be too busy to destroy all objs in time, use
23715 # a somewhat small value to not fail autotest
23716 [ $((old_iused - new_iused)) -gt 400 ] && break
23720 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
23721 [ $((old_iused - new_iused)) -gt 400 ] ||
23722 error "objs not destroyed after unlink"
23724 run_test 311 "disable OSP precreate, and unlink should destroy objs"
23731 local vdevdir=$(dirname $(facet_vdevice $ost))
23732 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
23733 local zfs_zapid=$(do_facet $ost $cmd |
23734 grep -w "/O/0/d$((objid%32))" -C 5 |
23735 awk '/Object/{getline; print $1}')
23736 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
23737 awk "/$objid = /"'{printf $3}')
23742 zfs_object_blksz() {
23746 local vdevdir=$(dirname $(facet_vdevice $ost))
23747 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
23748 local blksz=$(do_facet $ost $cmd $objid |
23749 awk '/dblk/{getline; printf $4}')
23751 case "${blksz: -1}" in
23752 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
23753 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
23760 test_312() { # LU-4856
23761 remote_ost_nodsh && skip "remote OST with nodsh"
23762 [ "$ost1_FSTYPE" = "zfs" ] ||
23763 skip_env "the test only applies to zfs"
23765 local max_blksz=$(do_facet ost1 \
23766 $ZFS get -p recordsize $(facet_device ost1) |
23767 awk '!/VALUE/{print $3}')
23769 # to make life a little bit easier
23770 $LFS mkdir -c 1 -i 0 $DIR/$tdir
23771 $LFS setstripe -c 1 -i 0 $DIR/$tdir
23773 local tf=$DIR/$tdir/$tfile
23775 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
23777 # Get ZFS object id
23778 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
23779 # block size change by sequential overwrite
23782 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
23783 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
23785 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
23786 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
23790 # block size change by sequential append write
23791 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
23792 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
23793 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
23796 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
23797 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
23798 oflag=sync conv=notrunc
23800 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23801 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
23802 error "blksz error, actual $blksz, " \
23803 "expected: 2 * $count * $PAGE_SIZE"
23809 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
23810 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
23812 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
23813 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23814 [ $blksz -eq $PAGE_SIZE ] ||
23815 error "blksz error: $blksz, expected: $PAGE_SIZE"
23817 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
23818 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23819 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
23821 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
23822 blksz=$(zfs_object_blksz ost1 $zfs_objid)
23823 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
23825 run_test 312 "make sure ZFS adjusts its block size by write pattern"
23828 remote_ost_nodsh && skip "remote OST with nodsh"
23830 local file=$DIR/$tfile
23833 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
23835 # define OBD_FAIL_TGT_RCVD_EIO 0x720
23836 do_facet ost1 "$LCTL set_param fail_loc=0x720"
23837 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
23838 error "write should failed"
23839 do_facet ost1 "$LCTL set_param fail_loc=0"
23842 run_test 313 "io should fail after last_rcvd update fail"
23845 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
23847 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
23848 do_facet ost1 "$LCTL set_param fail_loc=0x720"
23850 wait_delete_completed
23851 do_facet ost1 "$LCTL set_param fail_loc=0"
23853 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
23855 test_315() { # LU-618
23856 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
23858 local file=$DIR/$tfile
23861 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
23862 error "multiop file write failed"
23863 $MULTIOP $file oO_RDONLY:r4063232_c &
23868 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
23871 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
23874 run_test 315 "read should be accounted"
23877 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
23878 large_xattr_enabled || skip_env "ea_inode feature disabled"
23880 rm -rf $DIR/$tdir/d
23881 mkdir -p $DIR/$tdir/d
23882 chown nobody $DIR/$tdir/d
23883 touch $DIR/$tdir/d/file
23885 $LFS mv -m1 $DIR/$tdir/d || error "lfs mv failed"
23887 run_test 316 "lfs mv"
23890 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
23891 skip "Need MDS version at least 2.11.53"
23892 if [ "$ost1_FSTYPE" == "zfs" ]; then
23893 skip "LU-10370: no implementation for ZFS"
23897 local grant_blk_size
23899 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
23900 awk '/grant_block_size:/ { print $2; exit; }')
23902 # Create File of size 5M. Truncate it to below size's and verify
23905 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
23906 error "Create file $DIR/$tfile failed"
23907 stack_trap "rm -f $DIR/$tfile" EXIT
23909 for trunc_sz in 2097152 4097 4000 509 0; do
23910 $TRUNCATE $DIR/$tfile $trunc_sz ||
23911 error "truncate $tfile to $trunc_sz failed"
23912 local sz=$(stat --format=%s $DIR/$tfile)
23913 local blk=$(stat --format=%b $DIR/$tfile)
23914 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
23915 grant_blk_size) * 8))
23917 if [[ $blk -ne $trunc_blk ]]; then
23918 $(which stat) $DIR/$tfile
23919 error "Expected Block $trunc_blk got $blk for $tfile"
23922 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
23923 error "Expected Size $trunc_sz got $sz for $tfile"
23928 # Create file with a hole and write actual 65536 bytes which aligned
23929 # with 4K and 64K PAGE_SIZE. Block count must be 128.
23932 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 seek=5 conv=fsync ||
23933 error "Create file : $DIR/$tfile"
23936 # Truncate to size $trunc_sz bytes. Strip tail blocks and leave only 8
23937 # blocks. The block count must drop to 8.
23939 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - \
23940 ((bs - grant_blk_size) + 1)))
23941 $TRUNCATE $DIR/$tfile $trunc_sz ||
23942 error "truncate $tfile to $trunc_sz failed"
23944 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
23945 sz=$(stat --format=%s $DIR/$tfile)
23946 blk=$(stat --format=%b $DIR/$tfile)
23948 if [[ $blk -ne $trunc_bsz ]]; then
23949 $(which stat) $DIR/$tfile
23950 error "Expected Block $trunc_bsz got $blk for $tfile"
23953 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
23954 error "Expected Size $trunc_sz got $sz for $tfile"
23956 run_test 317 "Verify blocks get correctly update after truncate"
23959 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
23960 local old_max_active=$($LCTL get_param -n \
23961 ${llite_name}.max_read_ahead_async_active \
23964 $LCTL set_param llite.*.max_read_ahead_async_active=256
23965 local max_active=$($LCTL get_param -n \
23966 ${llite_name}.max_read_ahead_async_active \
23968 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
23970 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
23971 error "set max_read_ahead_async_active should succeed"
23973 $LCTL set_param llite.*.max_read_ahead_async_active=512
23974 max_active=$($LCTL get_param -n \
23975 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
23976 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
23978 # restore @max_active
23979 [ $old_max_active -ne 0 ] && $LCTL set_param \
23980 llite.*.max_read_ahead_async_active=$old_max_active
23982 local old_threshold=$($LCTL get_param -n \
23983 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
23984 local max_per_file_mb=$($LCTL get_param -n \
23985 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
23987 local invalid=$(($max_per_file_mb + 1))
23989 llite.*.read_ahead_async_file_threshold_mb=$invalid\
23990 && error "set $invalid should fail"
23992 local valid=$(($invalid - 1))
23994 llite.*.read_ahead_async_file_threshold_mb=$valid ||
23995 error "set $valid should succeed"
23996 local threshold=$($LCTL get_param -n \
23997 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
23998 [ $threshold -eq $valid ] || error \
23999 "expect threshold $valid got $threshold"
24001 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
24003 run_test 318 "Verify async readahead tunables"
24006 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
24008 local before=$(date +%s)
24010 local mdir=$DIR/$tdir
24011 local file=$mdir/xxx
24013 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
24016 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
24017 $LCTL set_param fail_val=5 fail_loc=0x8000032c
24018 $LFS mv -m1 $file &
24021 dd if=$file of=/dev/null
24023 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
24024 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
24026 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
24028 run_test 319 "lost lease lock on migrate error"
24030 test_398a() { # LU-4198
24031 local ost1_imp=$(get_osc_import_name client ost1)
24032 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24035 $LFS setstripe -c 1 -i 0 $DIR/$tfile
24036 $LCTL set_param ldlm.namespaces.*.lru_size=clear
24038 # request a new lock on client
24039 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24041 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
24042 local lock_count=$($LCTL get_param -n \
24043 ldlm.namespaces.$imp_name.lru_size)
24044 [[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
24046 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
24048 # no lock cached, should use lockless IO and not enqueue new lock
24049 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
24050 lock_count=$($LCTL get_param -n \
24051 ldlm.namespaces.$imp_name.lru_size)
24052 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
24054 run_test 398a "direct IO should cancel lock otherwise lockless"
24056 test_398b() { # LU-4198
24057 which fio || skip_env "no fio installed"
24058 $LFS setstripe -c -1 $DIR/$tfile
24061 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
24064 echo "mix direct rw ${size}M to OST0 by fio with $njobs jobs..."
24065 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
24066 --numjobs=$njobs --fallocate=none \
24067 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24068 --filename=$DIR/$tfile &
24071 echo "mix buffer rw ${size}M to OST0 by fio with $njobs jobs..."
24072 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE \
24073 --numjobs=$njobs --fallocate=none \
24074 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24075 --filename=$DIR/$tfile || true
24080 run_test 398b "DIO and buffer IO race"
24082 test_398c() { # LU-4198
24083 local ost1_imp=$(get_osc_import_name client ost1)
24084 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24087 which fio || skip_env "no fio installed"
24089 saved_debug=$($LCTL get_param -n debug)
24090 $LCTL set_param debug=0
24092 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
24093 ((size /= 1024)) # by megabytes
24094 ((size /= 2)) # write half of the OST at most
24095 [ $size -gt 40 ] && size=40 #reduce test time anyway
24097 $LFS setstripe -c 1 $DIR/$tfile
24099 # it seems like ldiskfs reserves more space than necessary if the
24100 # writing blocks are not mapped, so it extends the file firstly
24101 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
24102 cancel_lru_locks osc
24104 # clear and verify rpc_stats later
24105 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
24108 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
24109 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
24110 --numjobs=$njobs --fallocate=none --ioengine=libaio \
24111 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24112 --filename=$DIR/$tfile
24113 [ $? -eq 0 ] || error "fio write error"
24115 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
24116 error "Locks were requested while doing AIO"
24118 # get the percentage of 1-page I/O
24119 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
24120 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
24122 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
24124 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
24125 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
24126 --numjobs=$njobs --fallocate=none --ioengine=libaio \
24127 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24128 --filename=$DIR/$tfile
24129 [ $? -eq 0 ] || error "fio mixed read write error"
24131 echo "AIO with large block size ${size}M"
24132 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
24133 --numjobs=1 --fallocate=none --ioengine=libaio \
24134 --iodepth=16 --allow_file_create=0 --size=${size}M \
24135 --filename=$DIR/$tfile
24136 [ $? -eq 0 ] || error "fio large block size failed"
24139 $LCTL set_param debug="$saved_debug"
24141 run_test 398c "run fio to test AIO"
24143 test_398d() { # LU-13846
24144 which aiocp || skip_env "no aiocp installed"
24145 local aio_file=$DIR/$tfile.aio
24147 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
24149 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
24150 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
24151 stack_trap "rm -f $DIR/$tfile $aio_file"
24153 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
24155 # make sure we don't crash and fail properly
24156 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
24157 error "aio not aligned with PAGE SIZE should fail"
24159 rm -f $DIR/$tfile $aio_file
24161 run_test 398d "run aiocp to verify block size > stripe size"
24164 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
24165 touch $DIR/$tfile.new
24166 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
24168 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
24170 test_398f() { # LU-14687
24171 which aiocp || skip_env "no aiocp installed"
24172 local aio_file=$DIR/$tfile.aio
24174 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
24176 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
24177 stack_trap "rm -f $DIR/$tfile $aio_file"
24179 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
24180 $LCTL set_param fail_loc=0x1418
24181 # make sure we don't crash and fail properly
24182 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
24183 error "aio with page allocation failure succeeded"
24184 $LCTL set_param fail_loc=0
24185 diff $DIR/$tfile $aio_file
24186 [[ $? != 0 ]] || error "no diff after failed aiocp"
24188 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
24190 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
24191 # stripe and i/o size must be > stripe size
24192 # Old style synchronous DIO waits after submitting each chunk, resulting in a
24193 # single RPC in flight. This test shows async DIO submission is working by
24194 # showing multiple RPCs in flight.
24195 test_398g() { # LU-13798
24196 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
24198 # We need to do some i/o first to acquire enough grant to put our RPCs
24199 # in flight; otherwise a new connection may not have enough grant
24201 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
24202 error "parallel dio failed"
24203 stack_trap "rm -f $DIR/$tfile"
24205 # Reduce RPC size to 1M to avoid combination in to larger RPCs
24206 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
24207 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
24208 stack_trap "$LCTL set_param -n $pages_per_rpc"
24210 # Recreate file so it's empty
24212 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
24213 #Pause rpc completion to guarantee we see multiple rpcs in flight
24214 #define OBD_FAIL_OST_BRW_PAUSE_BULK
24215 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
24216 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
24219 $LCTL set_param osc.*.rpc_stats=c
24221 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
24222 error "parallel dio failed"
24223 stack_trap "rm -f $DIR/$tfile"
24225 $LCTL get_param osc.*-OST0000-*.rpc_stats
24226 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
24227 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
24228 grep "8:" | awk '{print $8}')
24229 # We look at the "8 rpcs in flight" field, and verify A) it is present
24230 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
24231 # as expected for an 8M DIO to a file with 1M stripes.
24232 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
24234 # Verify turning off parallel dio works as expected
24236 $LCTL set_param osc.*.rpc_stats=c
24237 $LCTL set_param llite.*.parallel_dio=0
24238 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
24240 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
24241 error "dio with parallel dio disabled failed"
24243 # Ideally, we would see only one RPC in flight here, but there is an
24244 # unavoidable race between i/o completion and RPC in flight counting,
24245 # so while only 1 i/o is in flight at a time, the RPC in flight counter
24246 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
24247 # So instead we just verify it's always < 8.
24248 $LCTL get_param osc.*-OST0000-*.rpc_stats
24249 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
24250 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
24251 grep '^$' -B1 | grep . | awk '{print $1}')
24252 [ $ret != "8:" ] ||
24253 error "we should see fewer than 8 RPCs in flight (saw $ret)"
24255 run_test 398g "verify parallel dio async RPC submission"
24257 test_398h() { # LU-13798
24258 local dio_file=$DIR/$tfile.dio
24260 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
24262 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
24263 stack_trap "rm -f $DIR/$tfile $dio_file"
24265 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
24266 error "parallel dio failed"
24267 diff $DIR/$tfile $dio_file
24268 [[ $? == 0 ]] || error "file diff after aiocp"
24270 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
24272 test_398i() { # LU-13798
24273 local dio_file=$DIR/$tfile.dio
24275 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
24277 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
24278 stack_trap "rm -f $DIR/$tfile $dio_file"
24280 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
24281 $LCTL set_param fail_loc=0x1418
24282 # make sure we don't crash and fail properly
24283 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
24284 error "parallel dio page allocation failure succeeded"
24285 diff $DIR/$tfile $dio_file
24286 [[ $? != 0 ]] || error "no diff after failed aiocp"
24288 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
24290 test_398j() { # LU-13798
24291 # Stripe size > RPC size but less than i/o size tests split across
24292 # stripes and RPCs for individual i/o op
24293 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
24295 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
24296 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
24297 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
24298 stack_trap "$LCTL set_param -n $pages_per_rpc"
24300 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
24301 error "parallel dio write failed"
24302 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
24304 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
24305 error "parallel dio read failed"
24306 diff $DIR/$tfile $DIR/$tfile.2
24307 [[ $? == 0 ]] || error "file diff after parallel dio read"
24309 run_test 398j "test parallel dio where stripe size > rpc_size"
24311 test_398k() { # LU-13798
24312 wait_delete_completed
24315 # 4 stripe file; we will cause out of space on OST0
24316 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
24318 # Fill OST0 (if it's not too large)
24319 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
24321 if [[ $ORIGFREE -gt $MAXFREE ]]; then
24322 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
24324 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
24325 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
24326 error "dd should fill OST0"
24327 stack_trap "rm -f $DIR/$tfile.1"
24329 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
24333 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
24334 error "file is not 0 bytes in size"
24336 # dd above should not succeed, but don't error until here so we can
24337 # get debug info above
24339 error "parallel dio write with enospc succeeded"
24340 stack_trap "rm -f $DIR/$tfile"
24342 run_test 398k "test enospc on first stripe"
24344 test_398l() { # LU-13798
24345 wait_delete_completed
24348 # 4 stripe file; we will cause out of space on OST0
24349 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
24350 # happens on the second i/o chunk we issue
24351 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
24353 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
24354 stack_trap "rm -f $DIR/$tfile"
24356 # Fill OST0 (if it's not too large)
24357 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
24359 if [[ $ORIGFREE -gt $MAXFREE ]]; then
24360 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
24362 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
24363 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
24364 error "dd should fill OST0"
24365 stack_trap "rm -f $DIR/$tfile.1"
24367 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
24369 stack_trap "rm -f $DIR/$tfile.2"
24371 # Check that short write completed as expected
24372 ls -la $DIR/$tfile.2
24373 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
24374 error "file is not 1M in size"
24376 # dd above should not succeed, but don't error until here so we can
24377 # get debug info above
24379 error "parallel dio write with enospc succeeded"
24381 # Truncate source file to same length as output file and diff them
24382 $TRUNCATE $DIR/$tfile 1048576
24383 diff $DIR/$tfile $DIR/$tfile.2
24384 [[ $? == 0 ]] || error "data incorrect after short write"
24386 run_test 398l "test enospc on intermediate stripe/RPC"
24388 test_398m() { # LU-13798
24389 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
24391 # Set up failure on OST0, the first stripe:
24392 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
24393 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
24394 # So this fail_val specifies OST0
24395 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
24396 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
24398 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
24399 error "parallel dio write with failure on first stripe succeeded"
24400 stack_trap "rm -f $DIR/$tfile"
24401 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
24403 # Place data in file for read
24404 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
24405 error "parallel dio write failed"
24407 # Fail read on OST0, first stripe
24408 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
24409 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
24410 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
24411 error "parallel dio read with error on first stripe succeeded"
24412 rm -f $DIR/$tfile.2
24413 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
24415 # Switch to testing on OST1, second stripe
24416 # Clear file contents, maintain striping
24418 # Set up failure on OST1, second stripe:
24419 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=2
24420 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
24422 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
24423 error "parallel dio write with failure on first stripe succeeded"
24424 stack_trap "rm -f $DIR/$tfile"
24425 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
24427 # Place data in file for read
24428 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
24429 error "parallel dio write failed"
24431 # Fail read on OST1, second stripe
24432 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
24433 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
24434 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
24435 error "parallel dio read with error on first stripe succeeded"
24436 rm -f $DIR/$tfile.2
24437 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
24439 run_test 398m "test RPC failures with parallel dio"
24441 # Parallel submission of DIO should not cause problems for append, but it's
24442 # important to verify.
24443 test_398n() { # LU-13798
24444 $LFS setstripe -C 2 -S 1M $DIR/$tfile
24446 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
24447 error "dd to create source file failed"
24448 stack_trap "rm -f $DIR/$tfile"
24450 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
24451 error "parallel dio write with failure on second stripe succeeded"
24452 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
24453 diff $DIR/$tfile $DIR/$tfile.1
24454 [[ $? == 0 ]] || error "data incorrect after append"
24457 run_test 398n "test append with parallel DIO"
24460 local read_write=$1
24461 if [ "$read_write" = "write" ]; then
24462 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
24463 elif [ "$read_write" = "read" ]; then
24464 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
24466 error "argument error"
24469 # turn off debug for performance testing
24470 local saved_debug=$($LCTL get_param -n debug)
24471 $LCTL set_param debug=0
24473 $LFS setstripe -c 1 -i 0 $DIR/$tfile
24475 # get ost1 size - $FSNAME-OST0000
24476 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
24477 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
24478 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
24480 if [ "$read_write" = "read" ]; then
24481 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
24484 local start_time=$(date +%s.%N)
24485 $dd_cmd bs=1M count=$blocks oflag=sync ||
24486 error "real dd $read_write error"
24487 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
24489 if [ "$read_write" = "write" ]; then
24493 # define OBD_FAIL_OST_FAKE_RW 0x238
24494 do_facet ost1 $LCTL set_param fail_loc=0x238
24496 local start_time=$(date +%s.%N)
24497 $dd_cmd bs=1M count=$blocks oflag=sync ||
24498 error "fake dd $read_write error"
24499 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
24501 if [ "$read_write" = "write" ]; then
24503 cancel_lru_locks osc
24504 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
24505 error "$tfile size not $blocks MB"
24507 do_facet ost1 $LCTL set_param fail_loc=0
24509 echo "fake $read_write $duration_fake vs. normal $read_write" \
24510 "$duration in seconds"
24511 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
24512 error_not_in_vm "fake write is slower"
24514 $LCTL set_param -n debug="$saved_debug"
24517 test_399a() { # LU-7655 for OST fake write
24518 remote_ost_nodsh && skip "remote OST with nodsh"
24522 run_test 399a "fake write should not be slower than normal write"
24524 test_399b() { # LU-8726 for OST fake read
24525 remote_ost_nodsh && skip "remote OST with nodsh"
24526 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
24527 skip_env "ldiskfs only test"
24532 run_test 399b "fake read should not be slower than normal read"
24534 test_400a() { # LU-1606, was conf-sanity test_74
24535 if ! which $CC > /dev/null 2>&1; then
24536 skip_env "$CC is not installed"
24539 local extra_flags=''
24540 local out=$TMP/$tfile
24541 local prefix=/usr/include/lustre
24544 # Oleg removes c files in his test rig so test if any c files exist
24545 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
24546 skip_env "Needed c test files are missing"
24548 if ! [[ -d $prefix ]]; then
24549 # Assume we're running in tree and fixup the include path.
24550 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
24551 extra_flags+=" -L$LUSTRE/utils/.lib"
24554 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
24555 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
24556 error "client api broken"
24560 run_test 400a "Lustre client api program can compile and link"
24562 test_400b() { # LU-1606, LU-5011
24564 local out=$TMP/$tfile
24565 local prefix=/usr/include/linux/lustre
24567 # We use a hard coded prefix so that this test will not fail
24568 # when run in tree. There are headers in lustre/include/lustre/
24569 # that are not packaged (like lustre_idl.h) and have more
24570 # complicated include dependencies (like config.h and lnet/types.h).
24571 # Since this test about correct packaging we just skip them when
24572 # they don't exist (see below) rather than try to fixup cppflags.
24574 if ! which $CC > /dev/null 2>&1; then
24575 skip_env "$CC is not installed"
24578 for header in $prefix/*.h; do
24579 if ! [[ -f "$header" ]]; then
24583 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
24584 continue # lustre_ioctl.h is internal header
24587 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
24588 error "cannot compile '$header'"
24592 run_test 400b "packaged headers can be compiled"
24594 test_401a() { #LU-7437
24595 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
24596 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
24598 #count the number of parameters by "list_param -R"
24599 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
24600 #count the number of parameters by listing proc files
24601 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
24602 echo "proc_dirs='$proc_dirs'"
24603 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
24604 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
24607 [ $params -eq $procs ] ||
24608 error "found $params parameters vs. $procs proc files"
24610 # test the list_param -D option only returns directories
24611 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
24612 #count the number of parameters by listing proc directories
24613 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
24616 [ $params -eq $procs ] ||
24617 error "found $params parameters vs. $procs proc files"
24619 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
24622 # jobid_var may not allow arbitrary values, so use jobid_name
24624 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24625 local testname=jobid_name tmp='testing%p'
24627 local testname=jobid_var tmp=testing
24630 local save=$($LCTL get_param -n $testname)
24632 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
24633 error "no error returned when setting bad parameters"
24635 local jobid_new=$($LCTL get_param -n foe $testname baz)
24636 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
24638 $LCTL set_param -n fog=bam $testname=$save bat=fog
24639 local jobid_old=$($LCTL get_param -n foe $testname bag)
24640 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
24642 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
24645 # jobid_var may not allow arbitrary values, so use jobid_name
24647 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24648 local testname=jobid_name
24650 local testname=jobid_var
24653 local jobid_var_old=$($LCTL get_param -n $testname)
24654 local jobid_var_new
24656 $LCTL set_param $testname= &&
24657 error "no error returned for 'set_param a='"
24659 jobid_var_new=$($LCTL get_param -n $testname)
24660 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
24661 error "$testname was changed by setting without value"
24663 $LCTL set_param $testname &&
24664 error "no error returned for 'set_param a'"
24666 jobid_var_new=$($LCTL get_param -n $testname)
24667 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
24668 error "$testname was changed by setting without value"
24670 run_test 401c "Verify 'lctl set_param' without value fails in either format."
24673 # jobid_var may not allow arbitrary values, so use jobid_name
24675 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24676 local testname=jobid_name new_value='foo=bar%p'
24678 local testname=jobid_var new_valuie=foo=bar
24681 local jobid_var_old=$($LCTL get_param -n $testname)
24682 local jobid_var_new
24684 $LCTL set_param $testname=$new_value ||
24685 error "'set_param a=b' did not accept a value containing '='"
24687 jobid_var_new=$($LCTL get_param -n $testname)
24688 [[ "$jobid_var_new" == "$new_value" ]] ||
24689 error "'set_param a=b' failed on a value containing '='"
24691 # Reset the $testname to test the other format
24692 $LCTL set_param $testname=$jobid_var_old
24693 jobid_var_new=$($LCTL get_param -n $testname)
24694 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
24695 error "failed to reset $testname"
24697 $LCTL set_param $testname $new_value ||
24698 error "'set_param a b' did not accept a value containing '='"
24700 jobid_var_new=$($LCTL get_param -n $testname)
24701 [[ "$jobid_var_new" == "$new_value" ]] ||
24702 error "'set_param a b' failed on a value containing '='"
24704 $LCTL set_param $testname $jobid_var_old
24705 jobid_var_new=$($LCTL get_param -n $testname)
24706 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
24707 error "failed to reset $testname"
24709 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
24711 test_401e() { # LU-14779
24712 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
24713 error "lctl list_param MGC* failed"
24714 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
24715 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
24716 error "lctl get_param lru_size failed"
24718 run_test 401e "verify 'lctl get_param' works with NID in parameter"
24721 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
24722 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
24723 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
24724 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
24725 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
24726 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
24727 remote_mds_nodsh && skip "remote MDS with nodsh"
24729 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
24730 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
24731 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
24732 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
24733 echo "Touch failed - OK"
24735 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
24738 local file1=$DIR/$tfile.1
24739 local file2=$DIR/$tfile.2
24740 local tfile=$TMP/$tfile
24742 rm -f $file1 $file2 $tfile
24747 # 30 sec OBD_TIMEOUT in ll_getattr()
24748 # right before populating st_nlink
24749 $LCTL set_param fail_loc=0x80001409
24750 stat -c %h $file1 > $tfile &
24752 # create an alias, drop all locks and reclaim the dentry
24754 cancel_lru_locks mdc
24755 cancel_lru_locks osc
24756 sysctl -w vm.drop_caches=2
24760 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
24762 rm -f $tfile $file1 $file2
24764 run_test 403 "i_nlink should not drop to zero due to aliasing"
24766 test_404() { # LU-6601
24767 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
24768 skip "Need server version newer than 2.8.52"
24769 remote_mds_nodsh && skip "remote MDS with nodsh"
24771 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
24772 awk '/osp .*-osc-MDT/ { print $4}')
24775 for osp in $mosps; do
24776 echo "Deactivate: " $osp
24777 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
24778 local stat=$(do_facet $SINGLEMDS $LCTL dl |
24779 awk -vp=$osp '$4 == p { print $2 }')
24780 [ $stat = IN ] || {
24781 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
24782 error "deactivate error"
24784 echo "Activate: " $osp
24785 do_facet $SINGLEMDS $LCTL --device %$osp activate
24786 local stat=$(do_facet $SINGLEMDS $LCTL dl |
24787 awk -vp=$osp '$4 == p { print $2 }')
24788 [ $stat = UP ] || {
24789 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
24790 error "activate error"
24794 run_test 404 "validate manual {de}activated works properly for OSPs"
24797 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
24798 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
24799 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
24800 skip "Layout swap lock is not supported"
24802 check_swap_layouts_support
24803 check_swap_layout_no_dom $DIR
24805 test_mkdir $DIR/$tdir
24806 swap_lock_test -d $DIR/$tdir ||
24807 error "One layout swap locked test failed"
24809 run_test 405 "Various layout swap lock tests"
24812 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24813 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
24814 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
24815 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24816 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
24817 skip "Need MDS version at least 2.8.50"
24819 local def_stripe_size=$($LFS getstripe -S $MOUNT)
24820 local test_pool=$TESTNAME
24822 pool_add $test_pool || error "pool_add failed"
24823 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
24824 error "pool_add_targets failed"
24826 save_layout_restore_at_exit $MOUNT
24828 # parent set default stripe count only, child will stripe from both
24829 # parent and fs default
24830 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
24831 error "setstripe $MOUNT failed"
24832 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
24833 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
24834 for i in $(seq 10); do
24835 local f=$DIR/$tdir/$tfile.$i
24836 touch $f || error "touch failed"
24837 local count=$($LFS getstripe -c $f)
24838 [ $count -eq $OSTCOUNT ] ||
24839 error "$f stripe count $count != $OSTCOUNT"
24840 local offset=$($LFS getstripe -i $f)
24841 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
24842 local size=$($LFS getstripe -S $f)
24843 [ $size -eq $((def_stripe_size * 2)) ] ||
24844 error "$f stripe size $size != $((def_stripe_size * 2))"
24845 local pool=$($LFS getstripe -p $f)
24846 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
24849 # change fs default striping, delete parent default striping, now child
24850 # will stripe from new fs default striping only
24851 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
24852 error "change $MOUNT default stripe failed"
24853 $LFS setstripe -c 0 $DIR/$tdir ||
24854 error "delete $tdir default stripe failed"
24855 for i in $(seq 11 20); do
24856 local f=$DIR/$tdir/$tfile.$i
24857 touch $f || error "touch $f failed"
24858 local count=$($LFS getstripe -c $f)
24859 [ $count -eq 1 ] || error "$f stripe count $count != 1"
24860 local offset=$($LFS getstripe -i $f)
24861 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
24862 local size=$($LFS getstripe -S $f)
24863 [ $size -eq $def_stripe_size ] ||
24864 error "$f stripe size $size != $def_stripe_size"
24865 local pool=$($LFS getstripe -p $f)
24866 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
24869 unlinkmany $DIR/$tdir/$tfile. 1 20
24871 local f=$DIR/$tdir/$tfile
24872 pool_remove_all_targets $test_pool $f
24873 pool_remove $test_pool $f
24875 run_test 406 "DNE support fs default striping"
24878 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24879 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
24880 skip "Need MDS version at least 2.8.55"
24881 remote_mds_nodsh && skip "remote MDS with nodsh"
24883 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
24884 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
24885 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
24886 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
24887 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
24889 #define OBD_FAIL_DT_TXN_STOP 0x2019
24890 for idx in $(seq $MDSCOUNT); do
24891 do_facet mds$idx "lctl set_param fail_loc=0x2019"
24893 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
24894 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
24895 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
24898 run_test 407 "transaction fail should cause operation fail"
24901 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
24903 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
24904 lctl set_param fail_loc=0x8000040a
24905 # let ll_prepare_partial_page() fail
24906 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
24910 # create at least 100 unused inodes so that
24911 # shrink_icache_memory(0) should not return 0
24912 touch $DIR/$tfile-{0..100}
24913 rm -f $DIR/$tfile-{0..100}
24916 echo 2 > /proc/sys/vm/drop_caches
24918 run_test 408 "drop_caches should not hang due to page leaks"
24922 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
24924 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
24925 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
24926 touch $DIR/$tdir/guard || error "(2) Fail to create"
24928 local PREFIX=$(str_repeat 'A' 128)
24929 echo "Create 1K hard links start at $(date)"
24930 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
24931 error "(3) Fail to hard link"
24933 echo "Links count should be right although linkEA overflow"
24934 stat $DIR/$tdir/guard || error "(4) Fail to stat"
24935 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
24936 [ $linkcount -eq 1001 ] ||
24937 error "(5) Unexpected hard links count: $linkcount"
24939 echo "List all links start at $(date)"
24940 ls -l $DIR/$tdir/foo > /dev/null ||
24941 error "(6) Fail to list $DIR/$tdir/foo"
24943 echo "Unlink hard links start at $(date)"
24944 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
24945 error "(7) Fail to unlink"
24946 echo "Unlink hard links finished at $(date)"
24948 run_test 409 "Large amount of cross-MDTs hard links on the same file"
24952 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
24953 skip "Need client version at least 2.9.59"
24954 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
24955 skip "Need MODULES build"
24957 # Create a file, and stat it from the kernel
24958 local testfile=$DIR/$tfile
24961 local run_id=$RANDOM
24962 local my_ino=$(stat --format "%i" $testfile)
24964 # Try to insert the module. This will always fail as the
24965 # module is designed to not be inserted.
24966 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
24969 # Anything but success is a test failure
24971 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
24972 error "no inode match"
24974 run_test 410 "Test inode number returned from kernel thread"
24976 cleanup_test411_cgroup() {
24982 local cg_basedir=/sys/fs/cgroup/memory
24984 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
24985 skip "no setup for cgroup"
24987 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
24988 error "test file creation failed"
24989 cancel_lru_locks osc
24991 # Create a very small memory cgroup to force a slab allocation error
24992 local cgdir=$cg_basedir/osc_slab_alloc
24993 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
24994 trap "cleanup_test411_cgroup $cgdir" EXIT
24995 echo 2M > $cgdir/memory.kmem.limit_in_bytes
24996 echo 1M > $cgdir/memory.limit_in_bytes
24998 # Should not LBUG, just be killed by oom-killer
24999 # dd will return 0 even allocation failure in some environment.
25000 # So don't check return value
25001 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
25002 cleanup_test411_cgroup $cgdir
25006 run_test 411 "Slab allocation error with cgroup does not LBUG"
25009 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25010 if [ $MDS1_VERSION -lt $(version_code 2.10.55) ]; then
25011 skip "Need server version at least 2.10.55"
25014 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
25015 error "mkdir failed"
25016 $LFS getdirstripe $DIR/$tdir
25017 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
25018 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
25019 error "expect $((MDSCOUT - 1)) get $stripe_index"
25020 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
25021 [ $stripe_count -eq 2 ] ||
25022 error "expect 2 get $stripe_count"
25024 run_test 412 "mkdir on specific MDTs"
25026 generate_uneven_mdts() {
25028 local lmv_qos_maxage
25029 local lod_qos_maxage
25039 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
25040 $LCTL set_param lmv.*.qos_maxage=1
25041 stack_trap "$LCTL set_param \
25042 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
25043 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
25044 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
25045 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25046 lod.*.mdt_qos_maxage=1
25047 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25048 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
25051 echo "Check for uneven MDTs: "
25053 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25054 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25055 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25057 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25058 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25061 for ((i = 1; i < ${#ffree[@]}; i++)); do
25062 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25063 if [ $tmp -gt $max ]; then
25067 if [ $tmp -lt $min ]; then
25073 (( ${ffree[min_index]} > 0 )) ||
25074 skip "no free files in MDT$min_index"
25075 (( ${ffree[min_index]} < 10000000 )) ||
25076 skip "too many free files in MDT$min_index"
25078 # Check if we need to generate uneven MDTs
25079 local diff=$(((max - min) * 100 / min))
25080 local testdir=$DIR/$tdir-fillmdt
25086 while (( diff < threshold )); do
25087 # generate uneven MDTs, create till $threshold% diff
25088 echo -n "weight diff=$diff% must be > $threshold% ..."
25089 echo "Fill MDT$min_index with 1000 files: loop $i"
25090 testdir=$DIR/$tdir-fillmdt/$i
25091 [ -d $testdir ] || $LFS mkdir -i $min_index $testdir ||
25092 error "mkdir $testdir failed"
25093 $LFS setstripe -E 1M -L mdt $testdir ||
25094 error "setstripe $testdir failed"
25096 for F in f.{0..999}; do
25097 dd if=/dev/zero of=$testdir/$F bs=64K count=1 > \
25098 /dev/null 2>&1 || error "dd $F failed"
25101 # wait for QOS to update
25102 (( SECONDS < start + 1 )) && sleep $((start + 1 - SECONDS))
25104 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
25105 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
25106 max=$(((${ffree[max_index]} >> 8) * \
25107 (${bavail[max_index]} * bsize >> 16)))
25108 min=$(((${ffree[min_index]} >> 8) * \
25109 (${bavail[min_index]} * bsize >> 16)))
25110 diff=$(((max - min) * 100 / min))
25114 echo "MDT filesfree available: ${ffree[@]}"
25115 echo "MDT blocks available: ${bavail[@]}"
25116 echo "weight diff=$diff%"
25121 local stripe_count=$2
25122 local mdts=$(comma_list $(mdts_nodes))
25125 local lmv_qos_prio_free
25126 local lmv_qos_threshold_rr
25127 local lmv_qos_maxage
25128 local lod_qos_prio_free
25129 local lod_qos_threshold_rr
25130 local lod_qos_maxage
25134 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
25135 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
25136 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
25138 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
25139 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
25140 stack_trap "$LCTL set_param \
25141 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
25142 stack_trap "$LCTL set_param \
25143 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
25144 stack_trap "$LCTL set_param \
25145 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
25147 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
25148 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
25149 lod_qos_prio_free=${lod_qos_prio_free%%%}
25150 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
25151 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
25152 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
25153 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
25154 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
25155 stack_trap "do_nodes $mdts $LCTL set_param \
25156 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
25157 stack_trap "do_nodes $mdts $LCTL set_param \
25158 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
25159 stack_trap "do_nodes $mdts $LCTL set_param \
25160 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
25162 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
25163 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
25165 testdir=$DIR/$tdir-s$stripe_count/rr
25167 local stripe_index=$($LFS getstripe -m $testdir)
25168 local test_mkdir_rr=true
25170 getfattr -d -m dmv -e hex $testdir | grep dmv
25171 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
25172 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
25173 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
25174 test_mkdir_rr=false
25179 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
25180 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
25182 stack_trap "unlinkmany -d $testdir/subdir $((100 * MDSCOUNT))"
25183 for (( i = 0; i < 100 * MDSCOUNT; i++ )); do
25184 eval $mkdir_cmd $testdir/subdir$i ||
25185 error "$mkdir_cmd subdir$i failed"
25188 for (( i = 0; i < $MDSCOUNT; i++ )); do
25189 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
25190 echo "$count directories created on MDT$i"
25191 if $test_mkdir_rr; then
25192 (( $count == 100 )) ||
25193 error "subdirs are not evenly distributed"
25194 elif (( $i == $stripe_index )); then
25195 (( $count == 100 * MDSCOUNT )) ||
25196 error "$count subdirs created on MDT$i"
25198 (( $count == 0 )) ||
25199 error "$count subdirs created on MDT$i"
25202 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
25203 count=$($LFS getdirstripe $testdir/* |
25204 grep -c -P "^\s+$i\t")
25205 echo "$count stripes created on MDT$i"
25206 # deviation should < 5% of average
25207 (( $count >= 95 * stripe_count &&
25208 $count <= 105 * stripe_count)) ||
25209 error "stripes are not evenly distributed"
25214 echo "Check for uneven MDTs: "
25224 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25225 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25226 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25228 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25229 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25232 for ((i = 1; i < ${#ffree[@]}; i++)); do
25233 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25234 if [ $tmp -gt $max ]; then
25238 if [ $tmp -lt $min ]; then
25244 (( ${ffree[min_index]} > 0 )) ||
25245 skip "no free files in MDT$min_index"
25246 (( ${ffree[min_index]} < 10000000 )) ||
25247 skip "too many free files in MDT$min_index"
25249 echo "MDT filesfree available: ${ffree[@]}"
25250 echo "MDT blocks available: ${bavail[@]}"
25251 echo "weight diff=$(((max - min) * 100 / min))%"
25253 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
25255 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
25256 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
25257 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
25258 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
25259 # decrease statfs age, so that it can be updated in time
25260 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
25261 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
25265 testdir=$DIR/$tdir-s$stripe_count/qos
25268 stack_trap "unlinkmany -d $testdir/subdir $((num * MDSCOUNT))"
25269 for (( i = 0; i < num * MDSCOUNT; i++ )); do
25270 eval $mkdir_cmd $testdir/subdir$i ||
25271 error "$mkdir_cmd subdir$i failed"
25275 for (( i = 0; i < $MDSCOUNT; i++ )); do
25276 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
25277 (( count > max )) && max=$count
25278 echo "$count directories created on MDT$i"
25281 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
25283 # D-value should > 10% of averge
25284 (( max - min > num / 10 )) ||
25285 error "subdirs shouldn't be evenly distributed: $max - $min < $((num / 10))"
25287 # ditto for stripes
25288 if (( stripe_count > 1 )); then
25290 for (( i = 0; i < $MDSCOUNT; i++ )); do
25291 count=$($LFS getdirstripe $testdir/* |
25292 grep -c -P "^\s+$i\t")
25293 (( count > max )) && max=$count
25294 echo "$count stripes created on MDT$i"
25297 min=$($LFS getdirstripe $testdir/* |
25298 grep -c -P "^\s+$min_index\t")
25299 (( max - min > num * stripe_count / 10 )) ||
25300 error "stripes shouldn't be evenly distributed: $max - $min < $((num / 10)) * $stripe_count"
25312 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25313 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25314 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25316 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25318 for ((i = 1; i < ${#ffree[@]}; i++)); do
25319 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25320 (( tmp < min )) && min=$tmp && min_index=$i
25327 [ $MDSCOUNT -lt 2 ] &&
25328 skip "We need at least 2 MDTs for this test"
25330 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
25331 skip "Need server version at least 2.12.52"
25335 generate_uneven_mdts 100
25336 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
25337 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
25338 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
25339 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
25340 error "mkdir failed"
25341 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
25344 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
25347 [ $MDSCOUNT -lt 2 ] &&
25348 skip "We need at least 2 MDTs for this test"
25350 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
25351 skip "Need server version at least 2.12.52"
25356 generate_uneven_mdts 100
25357 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
25358 testdir=$DIR/$tdir-s$stripe_count
25359 mkdir $testdir || error "mkdir $testdir failed"
25360 mkdir $testdir/rr || error "mkdir rr failed"
25361 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
25362 error "mkdir qos failed"
25363 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
25364 $testdir/rr || error "setdirstripe rr failed"
25365 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
25366 error "setdirstripe failed"
25367 test_qos_mkdir "mkdir" $stripe_count
25370 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
25373 (( $MDSCOUNT >= 2 )) ||
25374 skip "We need at least 2 MDTs for this test"
25376 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
25377 skip "Need server version at least 2.14.51"
25383 testdir=$DIR/${tdir}-s1
25384 mkdir $testdir || error "mkdir $testdir failed"
25385 mkdir $testdir/rr || error "mkdir rr failed"
25386 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
25387 # default max_inherit is -1, default max_inherit_rr is 0
25388 $LFS setdirstripe -D -c 1 $testdir/rr ||
25389 error "setdirstripe rr failed"
25390 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
25391 error "setdirstripe qos failed"
25392 test_qos_mkdir "mkdir" 1
25394 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
25395 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
25396 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
25397 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
25398 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
25400 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
25401 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
25402 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
25403 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
25404 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
25405 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
25406 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
25407 error "level2 shouldn't have default LMV" || true
25409 run_test 413c "mkdir with default LMV max inherit rr"
25412 (( MDSCOUNT >= 2 )) ||
25413 skip "We need at least 2 MDTs for this test"
25415 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
25416 skip "Need server version at least 2.14.51"
25418 local lmv_qos_threshold_rr
25420 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
25422 stack_trap "$LCTL set_param \
25423 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
25425 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
25426 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
25427 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
25428 error "$tdir shouldn't have default LMV"
25429 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
25430 error "mkdir sub failed"
25432 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
25434 (( count == 100 )) || error "$count subdirs on MDT0"
25436 run_test 413d "inherit ROOT default LMV"
25443 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
25444 unlinkmany $subdir/f. 1000 &
25448 for pid in $pids; do
25452 run_test 413z "413 test cleanup"
25455 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
25456 $LCTL set_param fail_loc=0x80000521
25457 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
25460 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
25463 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25464 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
25465 skip "Need server version at least 2.11.52"
25475 # this test may be slow on ZFS
25476 [ "$mds1_FSTYPE" == "zfs" ] && total=100
25478 # though this test is designed for striped directory, let's test normal
25479 # directory too since lock is always saved as CoS lock.
25480 test_mkdir $DIR/$tdir || error "mkdir $tdir"
25481 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
25490 start_time=$(date +%s)
25491 for i in $(seq $total); do
25492 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
25495 end_time=$(date +%s)
25496 duration=$((end_time - start_time))
25498 kill -9 $setattr_pid
25500 echo "rename $total files took $duration sec"
25501 [ $duration -lt 100 ] || error "rename took $duration sec"
25503 run_test 415 "lock revoke is not missing"
25506 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
25507 skip "Need server version at least 2.11.55"
25509 # define OBD_FAIL_OSD_TXN_START 0x19a
25510 do_facet mds1 lctl set_param fail_loc=0x19a
25512 lfs mkdir -c $MDSCOUNT $DIR/$tdir
25516 run_test 416 "transaction start failure won't cause system hung"
25520 do_nodes $(comma_list $(mdts_nodes)) \
25521 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
25522 do_nodes $(comma_list $(mdts_nodes)) \
25523 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
25524 do_nodes $(comma_list $(mdts_nodes)) \
25525 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
25529 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25530 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
25531 skip "Need MDS version at least 2.11.56"
25533 trap cleanup_417 RETURN EXIT
25535 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
25536 do_nodes $(comma_list $(mdts_nodes)) \
25537 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
25538 $LFS migrate -m 0 $DIR/$tdir.1 &&
25539 error "migrate dir $tdir.1 should fail"
25541 do_nodes $(comma_list $(mdts_nodes)) \
25542 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
25543 $LFS mkdir -i 1 $DIR/$tdir.2 &&
25544 error "create remote dir $tdir.2 should fail"
25546 do_nodes $(comma_list $(mdts_nodes)) \
25547 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
25548 $LFS mkdir -c 2 $DIR/$tdir.3 &&
25549 error "create striped dir $tdir.3 should fail"
25552 run_test 417 "disable remote dir, striped dir and dir migration"
25554 # Checks that the outputs of df [-i] and lfs df [-i] match
25556 # usage: check_lfs_df <blocks | inodes> <mountpoint>
25566 [ "$1" == "blocks" ] && inodes= || inodes="-i"
25568 for count in {1..100}; do
25569 do_nodes "$CLIENTS" \
25570 $LCTL set_param ldlm.namespaces.*.lru_size=clear
25573 # read the lines of interest
25574 df_out=($(df -P $inodes $dir | tail -n +2)) ||
25575 error "df $inodes $dir | tail -n +2 failed"
25576 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
25577 error "lfs df $inodes $dir | grep summary: failed"
25579 # skip first substrings of each output as they are different
25580 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
25581 # compare the two outputs
25583 # skip "available" on MDT until LU-13997 is fixed.
25584 #for i in {1..5}; do
25585 for i in 1 2 4 5; do
25586 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
25594 lfs df $inodes $dir
25595 error "df and lfs df $1 output mismatch: " \
25596 "df ${inodes}: ${df_out[*]}, " \
25597 "lfs df ${inodes}: ${lfs_df_out[*]}"
25602 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25604 local dir=$DIR/$tdir
25605 local numfiles=$((RANDOM % 4096 + 2))
25606 local numblocks=$((RANDOM % 256 + 1))
25608 wait_delete_completed
25611 # check block output
25612 check_lfs_df blocks $dir
25613 # check inode output
25614 check_lfs_df inodes $dir
25616 # create a single file and retest
25617 echo "Creating a single file and testing"
25618 createmany -o $dir/$tfile- 1 &>/dev/null ||
25619 error "creating 1 file in $dir failed"
25620 check_lfs_df blocks $dir
25621 check_lfs_df inodes $dir
25623 # create a random number of files
25624 echo "Creating $((numfiles - 1)) files and testing"
25625 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
25626 error "creating $((numfiles - 1)) files in $dir failed"
25628 # write a random number of blocks to the first test file
25629 echo "Writing $numblocks 4K blocks and testing"
25630 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
25631 count=$numblocks &>/dev/null ||
25632 error "dd to $dir/${tfile}-0 failed"
25635 check_lfs_df blocks $dir
25636 check_lfs_df inodes $dir
25638 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
25639 error "unlinking $numfiles files in $dir failed"
25641 run_test 418 "df and lfs df outputs match"
25645 local dir=$DIR/$tdir
25650 cancel_lru_locks mdc
25652 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
25653 $LCTL set_param fail_loc=0x1410
25655 $LCTL set_param fail_loc=0
25658 run_test 419 "Verify open file by name doesn't crash kernel"
25662 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
25663 skip "Need MDS version at least 2.12.53"
25665 local SAVE_UMASK=$(umask)
25666 local dir=$DIR/$tdir
25667 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
25671 mkdir -m03777 $dir/testdir
25672 ls -dn $dir/testdir
25673 # Need to remove trailing '.' when SELinux is enabled
25674 local dirperms=$(ls -dn $dir/testdir |
25675 awk '{ sub(/\.$/, "", $1); print $1}')
25676 [ $dirperms == "drwxrwsrwt" ] ||
25677 error "incorrect perms on $dir/testdir"
25679 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
25680 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
25681 ls -n $dir/testdir/testfile
25682 local fileperms=$(ls -n $dir/testdir/testfile |
25683 awk '{ sub(/\.$/, "", $1); print $1}')
25684 [ $fileperms == "-rwxr-xr-x" ] ||
25685 error "incorrect perms on $dir/testdir/testfile"
25689 run_test 420 "clear SGID bit on non-directories for non-members"
25696 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25697 skip "Need MDS version at least 2.12.54"
25699 test_mkdir $DIR/$tdir
25700 createmany -o $DIR/$tdir/f 3
25701 cnt=$(ls -1 $DIR/$tdir | wc -l)
25702 [ $cnt != 3 ] && error "unexpected #files: $cnt"
25704 fid1=$(lfs path2fid $DIR/$tdir/f1)
25705 fid2=$(lfs path2fid $DIR/$tdir/f2)
25706 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
25708 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
25709 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
25711 cnt=$(ls -1 $DIR/$tdir | wc -l)
25712 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
25714 rm -f $DIR/$tdir/f3 || error "can't remove f3"
25715 createmany -o $DIR/$tdir/f 3
25716 cnt=$(ls -1 $DIR/$tdir | wc -l)
25717 [ $cnt != 3 ] && error "unexpected #files: $cnt"
25719 fid1=$(lfs path2fid $DIR/$tdir/f1)
25720 fid2=$(lfs path2fid $DIR/$tdir/f2)
25721 echo "remove using fsname $FSNAME"
25722 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
25724 cnt=$(ls -1 $DIR/$tdir | wc -l)
25725 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
25727 run_test 421a "simple rm by fid"
25734 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25735 skip "Need MDS version at least 2.12.54"
25737 test_mkdir $DIR/$tdir
25738 createmany -o $DIR/$tdir/f 3
25739 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
25742 FID1=$(lfs path2fid $DIR/$tdir/f1)
25743 FID2=$(lfs path2fid $DIR/$tdir/f2)
25744 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
25746 kill -USR1 $MULTIPID
25749 cnt=$(ls $DIR/$tdir | wc -l)
25750 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
25752 run_test 421b "rm by fid on open file"
25758 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25759 skip "Need MDS version at least 2.12.54"
25761 test_mkdir $DIR/$tdir
25762 createmany -o $DIR/$tdir/f 3
25763 touch $DIR/$tdir/$tfile
25764 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
25765 cnt=$(ls -1 $DIR/$tdir | wc -l)
25766 [ $cnt != 184 ] && error "unexpected #files: $cnt"
25768 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
25769 $LFS rmfid $DIR $FID1 || error "rmfid failed"
25771 cnt=$(ls $DIR/$tdir | wc -l)
25772 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
25774 run_test 421c "rm by fid against hardlinked files"
25780 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25781 skip "Need MDS version at least 2.12.54"
25783 test_mkdir $DIR/$tdir
25784 createmany -o $DIR/$tdir/f 4097
25785 cnt=$(ls -1 $DIR/$tdir | wc -l)
25786 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
25788 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
25789 $LFS rmfid $DIR $FIDS || error "rmfid failed"
25791 cnt=$(ls $DIR/$tdir | wc -l)
25793 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
25795 run_test 421d "rmfid en masse"
25801 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25802 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25803 skip "Need MDS version at least 2.12.54"
25805 mkdir -p $DIR/$tdir
25806 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
25807 createmany -o $DIR/$tdir/striped_dir/f 512
25808 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
25809 [ $cnt != 512 ] && error "unexpected #files: $cnt"
25811 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
25812 sed "s/[/][^:]*://g")
25813 $LFS rmfid $DIR $FIDS || error "rmfid failed"
25815 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
25817 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
25819 run_test 421e "rmfid in DNE"
25825 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25826 skip "Need MDS version at least 2.12.54"
25828 test_mkdir $DIR/$tdir
25830 cnt=$(ls -1 $DIR/$tdir | wc -l)
25831 [ $cnt != 1 ] && error "unexpected #files: $cnt"
25833 FID=$(lfs path2fid $DIR/$tdir/f)
25834 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
25835 # rmfid should fail
25836 cnt=$(ls -1 $DIR/$tdir | wc -l)
25837 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
25839 chmod a+rw $DIR/$tdir
25841 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
25842 # rmfid should fail
25843 cnt=$(ls -1 $DIR/$tdir | wc -l)
25844 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
25847 $RUNAS touch $DIR/$tdir/f
25848 FID=$(lfs path2fid $DIR/$tdir/f)
25849 echo "rmfid as root"
25850 $LFS rmfid $DIR $FID || error "rmfid as root failed"
25851 cnt=$(ls -1 $DIR/$tdir | wc -l)
25852 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
25855 $RUNAS touch $DIR/$tdir/f
25856 cnt=$(ls -1 $DIR/$tdir | wc -l)
25857 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
25858 FID=$(lfs path2fid $DIR/$tdir/f)
25859 # rmfid w/o user_fid2path mount option should fail
25860 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
25861 cnt=$(ls -1 $DIR/$tdir | wc -l)
25862 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
25864 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
25865 stack_trap "rmdir $tmpdir"
25866 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
25867 error "failed to mount client'"
25868 stack_trap "umount_client $tmpdir"
25870 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
25871 # rmfid should succeed
25872 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
25873 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
25875 # rmfid shouldn't allow to remove files due to dir's permission
25876 chmod a+rwx $tmpdir/$tdir
25877 touch $tmpdir/$tdir/f
25878 ls -la $tmpdir/$tdir
25879 FID=$(lfs path2fid $tmpdir/$tdir/f)
25880 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
25883 run_test 421f "rmfid checks permissions"
25889 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25890 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
25891 skip "Need MDS version at least 2.12.54"
25893 mkdir -p $DIR/$tdir
25894 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
25895 createmany -o $DIR/$tdir/striped_dir/f 512
25896 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
25897 [ $cnt != 512 ] && error "unexpected #files: $cnt"
25899 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
25900 sed "s/[/][^:]*://g")
25902 rm -f $DIR/$tdir/striped_dir/f1*
25903 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
25904 removed=$((512 - cnt))
25906 # few files have been just removed, so we expect
25907 # rmfid to fail on their fids
25908 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
25909 [ $removed != $errors ] && error "$errors != $removed"
25911 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
25913 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
25915 run_test 421g "rmfid to return errors properly"
25918 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
25919 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
25920 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
25921 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
25922 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
25924 local amc=$(at_max_get client)
25925 local amo=$(at_max_get mds1)
25926 local timeout=`lctl get_param -n timeout`
25928 at_max_set 0 client
25931 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
25932 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
25933 fail_val=$(((2*timeout + 10)*1000))
25934 touch $DIR/$tdir/d3/file &
25936 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
25937 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
25938 fail_val=$((2*timeout + 5))
25939 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
25943 sleep $((2 * timeout))
25947 touch $DIR/$tdir/d2/file3
25948 touch $DIR/$tdir/d2/file4
25949 touch $DIR/$tdir/d2/file5
25952 at_max_set $amc client
25953 at_max_set $amo mds1
25955 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
25956 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
25957 error "Watchdog is always throttled"
25959 run_test 422 "kill a process with RPC in progress"
25972 # ensure statfs cache is expired
25975 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
25976 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
25980 run_test 423 "statfs should return a right data"
25983 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
25984 $LCTL set_param fail_loc=0x80000522
25985 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
25988 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
25991 test_mkdir -c -1 $DIR/$tdir
25992 $LFS setstripe -c -1 $DIR/$tdir
25994 lru_resize_disable "" 100
25995 stack_trap "lru_resize_enable" EXIT
25999 for i in $(seq $((MDSCOUNT * 125))); do
26000 local t=$DIR/$tdir/$tfile_$i
26002 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
26003 error_noexit "Create file $t"
26005 stack_trap "rm -rf $DIR/$tdir" EXIT
26007 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
26008 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
26009 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
26011 [ $lock_count -le $lru_size ] ||
26012 error "osc lock count $lock_count > lru size $lru_size"
26015 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
26016 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
26017 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
26019 [ $lock_count -le $lru_size ] ||
26020 error "mdc lock count $lock_count > lru size $lru_size"
26023 run_test 425 "lock count should not exceed lru size"
26026 splice-test -r $DIR/$tfile
26027 splice-test -rd $DIR/$tfile
26028 splice-test $DIR/$tfile
26029 splice-test -d $DIR/$tfile
26031 run_test 426 "splice test on Lustre"
26034 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
26035 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
26036 skip "Need MDS version at least 2.12.4"
26042 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
26043 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
26045 $LFS getdirstripe $DIR/$tdir/1/dir
26047 #first setfattr for creating updatelog
26048 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
26050 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
26051 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
26052 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
26053 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
26057 wait_recovery_complete mds2 $((2*TIMEOUT))
26059 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
26060 echo $log | grep "get update log failed" &&
26061 error "update log corruption is detected" || true
26063 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
26066 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26067 local cache_limit=$CACHE_MAX
26069 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$cache_limit"
26070 $LCTL set_param -n llite.*.max_cached_mb=64
26073 $LFS setstripe -c 1 $DIR/$tdir
26074 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
26075 stack_trap "rm -f $DIR/$tdir/$tfile.*"
26077 for f in $(seq 4); do
26078 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
26082 cancel_lru_locks osc
26084 for f in $(seq 4); do
26085 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
26089 run_test 428 "large block size IO should not hang"
26091 test_429() { # LU-7915 / LU-10948
26092 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
26093 local testfile=$DIR/$tfile
26094 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
26100 $LCTL get_param $ll_opencache_threshold_count ||
26101 skip "client does not have opencache parameter"
26103 set_opencache $new_flag
26104 stack_trap "restore_opencache"
26105 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
26106 error "enable opencache failed"
26108 # drop MDC DLM locks
26109 cancel_lru_locks mdc
26110 # clear MDC RPC stats counters
26111 $LCTL set_param $mdc_rpcstats=clear
26113 # According to the current implementation, we need to run 3 times
26114 # open & close file to verify if opencache is enabled correctly.
26115 # 1st, RPCs are sent for lookup/open and open handle is released on
26117 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
26118 # so open handle won't be released thereafter.
26119 # 3rd, No RPC is sent out.
26120 $MULTIOP $testfile oc || error "multiop failed"
26121 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
26122 echo "1st: $first_rpc RPCs in flight"
26124 $MULTIOP $testfile oc || error "multiop failed"
26125 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
26126 echo "2nd: $second_rpc RPCs in flight"
26128 $MULTIOP $testfile oc || error "multiop failed"
26129 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
26130 echo "3rd: $third_rpc RPCs in flight"
26132 #verify no MDC RPC is sent
26133 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
26135 run_test 429 "verify if opencache flag on client side does work"
26141 # data at [200K, 400K)
26142 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
26143 error "256K->512K dd fails"
26145 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
26146 error "2M->3M dd fails"
26148 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
26149 error "4M->5M dd fails"
26150 echo "Data at 256K...512K, 2M...3M and 4M...5M"
26151 # start at first component hole #1
26152 printf "Seeking hole from 1000 ... "
26153 offset=$(lseek_test -l 1000 $file)
26155 [[ $offset == 1000 ]] || error "offset $offset != 1000"
26156 printf "Seeking data from 1000 ... "
26157 offset=$(lseek_test -d 1000 $file)
26159 [[ $offset == 262144 ]] || error "offset $offset != 262144"
26161 # start at first component data block
26162 printf "Seeking hole from 300000 ... "
26163 offset=$(lseek_test -l 300000 $file)
26165 [[ $offset == 524288 ]] || error "offset $offset != 524288"
26166 printf "Seeking data from 300000 ... "
26167 offset=$(lseek_test -d 300000 $file)
26169 [[ $offset == 300000 ]] || error "offset $offset != 300000"
26171 # start at the first component but beyond end of object size
26172 printf "Seeking hole from 1000000 ... "
26173 offset=$(lseek_test -l 1000000 $file)
26175 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
26176 printf "Seeking data from 1000000 ... "
26177 offset=$(lseek_test -d 1000000 $file)
26179 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
26181 # start at second component stripe 2 (empty file)
26182 printf "Seeking hole from 1500000 ... "
26183 offset=$(lseek_test -l 1500000 $file)
26185 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
26186 printf "Seeking data from 1500000 ... "
26187 offset=$(lseek_test -d 1500000 $file)
26189 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
26191 # start at second component stripe 1 (all data)
26192 printf "Seeking hole from 3000000 ... "
26193 offset=$(lseek_test -l 3000000 $file)
26195 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
26196 printf "Seeking data from 3000000 ... "
26197 offset=$(lseek_test -d 3000000 $file)
26199 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
26201 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
26202 error "2nd dd fails"
26203 echo "Add data block at 640K...1280K"
26205 # start at before new data block, in hole
26206 printf "Seeking hole from 600000 ... "
26207 offset=$(lseek_test -l 600000 $file)
26209 [[ $offset == 600000 ]] || error "offset $offset != 600000"
26210 printf "Seeking data from 600000 ... "
26211 offset=$(lseek_test -d 600000 $file)
26213 [[ $offset == 655360 ]] || error "offset $offset != 655360"
26215 # start at the first component new data block
26216 printf "Seeking hole from 1000000 ... "
26217 offset=$(lseek_test -l 1000000 $file)
26219 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
26220 printf "Seeking data from 1000000 ... "
26221 offset=$(lseek_test -d 1000000 $file)
26223 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
26225 # start at second component stripe 2, new data
26226 printf "Seeking hole from 1200000 ... "
26227 offset=$(lseek_test -l 1200000 $file)
26229 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
26230 printf "Seeking data from 1200000 ... "
26231 offset=$(lseek_test -d 1200000 $file)
26233 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
26235 # start beyond file end
26236 printf "Using offset > filesize ... "
26237 lseek_test -l 4000000 $file && error "lseek should fail"
26238 printf "Using offset > filesize ... "
26239 lseek_test -d 4000000 $file && error "lseek should fail"
26245 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
26246 skip "MDT does not support SEEK_HOLE"
26248 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
26249 skip "OST does not support SEEK_HOLE"
26251 local file=$DIR/$tdir/$tfile
26253 mkdir -p $DIR/$tdir
26255 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
26256 # OST stripe #1 will have continuous data at [1M, 3M)
26257 # OST stripe #2 is empty
26258 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
26259 lseek_test_430 $file
26261 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
26262 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
26263 lseek_test_430 $file
26265 $LFS setstripe -c2 -S 512K $file
26266 echo "Two stripes, stripe size 512K"
26267 lseek_test_430 $file
26269 # FLR with stale mirror
26270 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
26272 echo "Mirrored file:"
26273 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
26274 echo "Plain 2 stripes 1M"
26275 lseek_test_430 $file
26278 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
26281 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
26282 skip "OST does not support SEEK_HOLE"
26285 local file=$DIR/$tdir/$tfile
26287 mkdir -p $DIR/$tdir
26288 # Empty layout lseek should fail
26291 printf "Seeking hole from 0 ... "
26292 lseek_test -l 0 $file && error "lseek should fail"
26293 printf "Seeking data from 0 ... "
26294 lseek_test -d 0 $file && error "lseek should fail"
26298 $LFS setstripe -E 1M -c2 -E eof $file
26299 $TRUNCATE $file 1048576
26300 printf "Seeking hole from 1000000 ... "
26301 offset=$(lseek_test -l 1000000 $file)
26303 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
26304 printf "Seeking data from 1000000 ... "
26305 lseek_test -d 1000000 $file && error "lseek should fail"
26308 # full component followed by non-inited one
26309 $LFS setstripe -E 1M -c2 -E eof $file
26310 dd if=/dev/urandom of=$file bs=1M count=1
26311 printf "Seeking hole from 1000000 ... "
26312 offset=$(lseek_test -l 1000000 $file)
26314 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
26315 printf "Seeking hole from 1048576 ... "
26316 lseek_test -l 1048576 $file && error "lseek should fail"
26317 # init second component and truncate back
26318 echo "123" >> $file
26319 $TRUNCATE $file 1048576
26320 printf "Seeking hole from 1000000 ... "
26321 offset=$(lseek_test -l 1000000 $file)
26323 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
26324 printf "Seeking hole from 1048576 ... "
26325 lseek_test -l 1048576 $file && error "lseek should fail"
26326 # boundary checks for big values
26327 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
26328 offset=$(lseek_test -d 0 $file.10g)
26329 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
26330 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
26331 offset=$(lseek_test -d 0 $file.100g)
26332 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
26335 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
26338 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
26339 skip "OST does not support SEEK_HOLE"
26341 local file=$DIR/$tdir/$tfile
26344 mkdir -p $DIR/$tdir
26345 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M
26347 # cp version 8.33+ prefers lseek over fiemap
26348 if [[ $(cp --version | head -n1 | sed "s/[^0-9]//g") -ge 833 ]]; then
26350 time cp $file /dev/null
26351 (( SECONDS - start < 5 )) ||
26352 error "cp: too long runtime $((SECONDS - start))"
26355 # tar version 1.29+ supports SEEK_HOLE/DATA
26356 if [[ $(tar --version | head -n1 | sed "s/[^0-9]//g") -ge 129 ]]; then
26358 time tar cS $file - | cat > /dev/null
26359 (( SECONDS - start < 5 )) ||
26360 error "tar: too long runtime $((SECONDS - start))"
26363 run_test 430c "lseek: external tools check"
26365 test_431() { # LU-14187
26366 local file=$DIR/$tdir/$tfile
26368 mkdir -p $DIR/$tdir
26369 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
26370 dd if=/dev/urandom of=$file bs=4k count=1
26371 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
26372 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
26373 #define OBD_FAIL_OST_RESTART_IO 0x251
26374 do_facet ost1 "$LCTL set_param fail_loc=0x251"
26375 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
26379 echo 3 > /proc/sys/vm/drop_caches
26380 diff $file $file.0 || error "data diff"
26382 run_test 431 "Restart transaction for IO"
26384 cleanup_test_432() {
26385 do_facet mgs $LCTL nodemap_activate 0
26386 wait_nm_sync active
26390 local tmpdir=$TMP/dir432
26392 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
26393 skip "Need MDS version at least 2.14.52"
26395 stack_trap cleanup_test_432 EXIT
26399 do_facet mgs $LCTL nodemap_activate 1
26400 wait_nm_sync active
26401 do_facet mgs $LCTL nodemap_modify --name default \
26402 --property admin --value 1
26403 do_facet mgs $LCTL nodemap_modify --name default \
26404 --property trusted --value 1
26405 cancel_lru_locks mdc
26406 wait_nm_sync default admin_nodemap
26407 wait_nm_sync default trusted_nodemap
26409 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
26410 grep -ci "Operation not permitted") -ne 0 ]; then
26411 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
26414 run_test 432 "mv dir from outside Lustre"
26417 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
26418 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
26419 skip "Need server version at least 2.9.55"
26421 start_full_debug_logging
26425 stop_full_debug_logging
26429 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
26430 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
26431 awk '/The barrier for/ { print $7 }')
26434 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
26439 barrier_expired() {
26442 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
26443 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
26444 awk '/will be expired/ { print $7 }')
26446 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
26455 echo "Start barrier_freeze at: $(date)"
26456 #define OBD_FAIL_BARRIER_DELAY 0x2202
26457 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
26458 # Do not reduce barrier time - See LU-11873
26459 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
26462 local b_status=$(barrier_stat)
26463 echo "Got barrier status at: $(date)"
26464 [ "$b_status" = "'freezing_p1'" ] ||
26465 error "(1) unexpected barrier status $b_status"
26467 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
26469 b_status=$(barrier_stat)
26470 [ "$b_status" = "'frozen'" ] ||
26471 error "(2) unexpected barrier status $b_status"
26473 local expired=$(barrier_expired)
26474 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
26475 sleep $((expired + 3))
26477 b_status=$(barrier_stat)
26478 [ "$b_status" = "'expired'" ] ||
26479 error "(3) unexpected barrier status $b_status"
26481 # Do not reduce barrier time - See LU-11873
26482 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
26483 error "(4) fail to freeze barrier"
26485 b_status=$(barrier_stat)
26486 [ "$b_status" = "'frozen'" ] ||
26487 error "(5) unexpected barrier status $b_status"
26489 echo "Start barrier_thaw at: $(date)"
26490 #define OBD_FAIL_BARRIER_DELAY 0x2202
26491 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
26492 do_facet mgs $LCTL barrier_thaw $FSNAME &
26495 b_status=$(barrier_stat)
26496 echo "Got barrier status at: $(date)"
26497 [ "$b_status" = "'thawing'" ] ||
26498 error "(6) unexpected barrier status $b_status"
26500 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
26502 b_status=$(barrier_stat)
26503 [ "$b_status" = "'thawed'" ] ||
26504 error "(7) unexpected barrier status $b_status"
26506 #define OBD_FAIL_BARRIER_FAILURE 0x2203
26507 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
26508 do_facet mgs $LCTL barrier_freeze $FSNAME
26510 b_status=$(barrier_stat)
26511 [ "$b_status" = "'failed'" ] ||
26512 error "(8) unexpected barrier status $b_status"
26514 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
26515 do_facet mgs $LCTL barrier_thaw $FSNAME
26519 run_test 801a "write barrier user interfaces and stat machine"
26524 mkdir $DIR/$tdir || error "(1) fail to mkdir"
26525 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
26526 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
26527 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
26528 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
26530 cancel_lru_locks mdc
26532 # 180 seconds should be long enough
26533 do_facet mgs $LCTL barrier_freeze $FSNAME 180
26535 local b_status=$(barrier_stat)
26536 [ "$b_status" = "'frozen'" ] ||
26537 error "(6) unexpected barrier status $b_status"
26539 mkdir $DIR/$tdir/d0/d10 &
26542 touch $DIR/$tdir/d1/f13 &
26545 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
26548 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
26551 rm -f $DIR/$tdir/d4/f12 &
26554 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
26556 # To guarantee taht the 'stat' is not blocked
26557 b_status=$(barrier_stat)
26558 [ "$b_status" = "'frozen'" ] ||
26559 error "(8) unexpected barrier status $b_status"
26561 # let above commands to run at background
26564 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
26565 ps -p $touch_pid || error "(10) touch should be blocked"
26566 ps -p $ln_pid || error "(11) link should be blocked"
26567 ps -p $mv_pid || error "(12) rename should be blocked"
26568 ps -p $rm_pid || error "(13) unlink should be blocked"
26570 b_status=$(barrier_stat)
26571 [ "$b_status" = "'frozen'" ] ||
26572 error "(14) unexpected barrier status $b_status"
26574 do_facet mgs $LCTL barrier_thaw $FSNAME
26575 b_status=$(barrier_stat)
26576 [ "$b_status" = "'thawed'" ] ||
26577 error "(15) unexpected barrier status $b_status"
26579 wait $mkdir_pid || error "(16) mkdir should succeed"
26580 wait $touch_pid || error "(17) touch should succeed"
26581 wait $ln_pid || error "(18) link should succeed"
26582 wait $mv_pid || error "(19) rename should succeed"
26583 wait $rm_pid || error "(20) unlink should succeed"
26587 run_test 801b "modification will be blocked by write barrier"
26590 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26594 stop mds2 || error "(1) Fail to stop mds2"
26596 do_facet mgs $LCTL barrier_freeze $FSNAME 30
26598 local b_status=$(barrier_stat)
26599 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
26600 do_facet mgs $LCTL barrier_thaw $FSNAME
26601 error "(2) unexpected barrier status $b_status"
26604 do_facet mgs $LCTL barrier_rescan $FSNAME ||
26605 error "(3) Fail to rescan barrier bitmap"
26607 # Do not reduce barrier time - See LU-11873
26608 do_facet mgs $LCTL barrier_freeze $FSNAME 20
26610 b_status=$(barrier_stat)
26611 [ "$b_status" = "'frozen'" ] ||
26612 error "(4) unexpected barrier status $b_status"
26614 do_facet mgs $LCTL barrier_thaw $FSNAME
26615 b_status=$(barrier_stat)
26616 [ "$b_status" = "'thawed'" ] ||
26617 error "(5) unexpected barrier status $b_status"
26619 local devname=$(mdsdevname 2)
26621 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
26623 do_facet mgs $LCTL barrier_rescan $FSNAME ||
26624 error "(7) Fail to rescan barrier bitmap"
26628 run_test 801c "rescan barrier bitmap"
26630 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
26631 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
26632 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
26633 saved_MOUNT_OPTS=$MOUNT_OPTS
26639 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
26640 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
26641 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
26642 MOUNT_OPTS=$saved_MOUNT_OPTS
26647 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
26648 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
26649 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
26650 skip "Need server version at least 2.9.55"
26652 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
26654 mkdir $DIR/$tdir || error "(1) fail to mkdir"
26656 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
26657 error "(2) Fail to copy"
26659 trap cleanup_802a EXIT
26661 # sync by force before remount as readonly
26662 sync; sync_all_data; sleep 3; sync_all_data
26666 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
26667 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
26668 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
26670 echo "Mount the server as read only"
26671 setupall server_only || error "(3) Fail to start servers"
26673 echo "Mount client without ro should fail"
26674 mount_client $MOUNT &&
26675 error "(4) Mount client without 'ro' should fail"
26677 echo "Mount client with ro should succeed"
26678 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
26679 mount_client $MOUNT ||
26680 error "(5) Mount client with 'ro' should succeed"
26682 echo "Modify should be refused"
26683 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
26685 echo "Read should be allowed"
26686 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
26687 error "(7) Read should succeed under ro mode"
26691 run_test 802a "simulate readonly device"
26694 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26695 remote_mds_nodsh && skip "remote MDS with nodsh"
26697 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
26698 skip "readonly option not available"
26700 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
26702 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
26703 error "(2) Fail to copy"
26705 # write back all cached data before setting MDT to readonly
26709 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
26710 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
26712 echo "Modify should be refused"
26713 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
26715 echo "Read should be allowed"
26716 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
26717 error "(7) Read should succeed under ro mode"
26720 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
26722 run_test 802b "be able to set MDTs to readonly"
26725 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26726 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
26727 skip "MDS needs to be newer than 2.10.54"
26729 mkdir_on_mdt0 $DIR/$tdir
26730 # Create some objects on all MDTs to trigger related logs objects
26731 for idx in $(seq $MDSCOUNT); do
26732 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
26733 $DIR/$tdir/dir${idx} ||
26734 error "Fail to create $DIR/$tdir/dir${idx}"
26738 wait_delete_completed # ensure old test cleanups are finished
26739 echo "before create:"
26741 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
26743 for i in {1..10}; do
26744 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
26745 error "Fail to create $DIR/$tdir/foo$i"
26749 echo "after create:"
26751 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
26753 # allow for an llog to be cleaned up during the test
26754 [ $after_used -ge $((before_used + 10 - 1)) ] ||
26755 error "before ($before_used) + 10 > after ($after_used)"
26757 for i in {1..10}; do
26758 rm -rf $DIR/$tdir/foo$i ||
26759 error "Fail to remove $DIR/$tdir/foo$i"
26762 sleep 3 # avoid MDT return cached statfs
26763 wait_delete_completed
26764 echo "after unlink:"
26766 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
26768 # allow for an llog to be created during the test
26769 [ $after_used -le $((before_used + 1)) ] ||
26770 error "after ($after_used) > before ($before_used) + 1"
26772 run_test 803a "verify agent object for remote object"
26775 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26776 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
26777 skip "MDS needs to be newer than 2.13.56"
26778 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26780 for i in $(seq 0 $((MDSCOUNT - 1))); do
26781 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
26789 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
26790 for i in $(seq 0 $((MDSCOUNT - 1))); do
26791 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
26792 awk '/getattr/ { print $2 }')
26793 before=$((before + tmp))
26795 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
26796 for i in $(seq 0 $((MDSCOUNT - 1))); do
26797 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
26798 awk '/getattr/ { print $2 }')
26799 after=$((after + tmp))
26802 [ $before -eq $after ] || error "getattr count $before != $after"
26804 run_test 803b "remote object can getattr from cache"
26807 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
26808 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
26809 skip "MDS needs to be newer than 2.10.54"
26810 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
26812 mkdir -p $DIR/$tdir
26813 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
26814 error "Fail to create $DIR/$tdir/dir0"
26816 local fid=$($LFS path2fid $DIR/$tdir/dir0)
26817 local dev=$(mdsdevname 2)
26819 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26820 grep ${fid} || error "NOT found agent entry for dir0"
26822 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
26823 error "Fail to create $DIR/$tdir/dir1"
26825 touch $DIR/$tdir/dir1/foo0 ||
26826 error "Fail to create $DIR/$tdir/dir1/foo0"
26827 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
26830 for idx in $(seq $MDSCOUNT); do
26831 dev=$(mdsdevname $idx)
26832 do_facet mds${idx} \
26833 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26834 grep ${fid} && rc=$idx
26837 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
26838 error "Fail to rename foo0 to foo1"
26839 if [ $rc -eq 0 ]; then
26840 for idx in $(seq $MDSCOUNT); do
26841 dev=$(mdsdevname $idx)
26842 do_facet mds${idx} \
26843 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26844 grep ${fid} && rc=$idx
26848 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
26849 error "Fail to rename foo1 to foo2"
26850 if [ $rc -eq 0 ]; then
26851 for idx in $(seq $MDSCOUNT); do
26852 dev=$(mdsdevname $idx)
26853 do_facet mds${idx} \
26854 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
26855 grep ${fid} && rc=$idx
26859 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
26861 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
26862 error "Fail to link to $DIR/$tdir/dir1/foo2"
26863 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
26864 error "Fail to rename foo2 to foo0"
26865 unlink $DIR/$tdir/dir1/foo0 ||
26866 error "Fail to unlink $DIR/$tdir/dir1/foo0"
26867 rm -rf $DIR/$tdir/dir0 ||
26868 error "Fail to rm $DIR/$tdir/dir0"
26870 for idx in $(seq $MDSCOUNT); do
26871 dev=$(mdsdevname $idx)
26875 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
26877 start mds${idx} $dev $MDS_MOUNT_OPTS ||
26878 error "mount mds$idx failed"
26879 df $MOUNT > /dev/null 2>&1
26881 # e2fsck should not return error
26883 error "e2fsck detected error on MDT${idx}: rc=$rc"
26886 run_test 804 "verify agent entry for remote entry"
26889 do_facet $SINGLEMDS zfs set quota=$old $fsset
26890 unlinkmany $DIR/$tdir/f- 1000000
26895 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
26896 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
26897 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
26898 skip "netfree not implemented before 0.7"
26899 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
26900 skip "Need MDS version at least 2.10.57"
26907 local pref="osd-zfs.$FSNAME-MDT0000."
26909 # limit available space on MDS dataset to meet nospace issue
26910 # quickly. then ZFS 0.7.2 can use reserved space if asked
26911 # properly (using netfree flag in osd_declare_destroy()
26912 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
26913 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
26915 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
26916 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
26917 let "usedkb=usedkb-freekb"
26918 let "freekb=freekb/2"
26919 if let "freekb > 5000"; then
26922 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
26923 trap cleanup_805 EXIT
26924 mkdir_on_mdt0 $DIR/$tdir
26925 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
26926 error "Can't set PFL layout"
26927 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
26928 rm -rf $DIR/$tdir || error "not able to remove"
26929 do_facet $SINGLEMDS zfs set quota=$old $fsset
26932 run_test 805 "ZFS can remove from full fs"
26938 local expect=$(stat -c %s $file)
26940 check_lsom_size $1 $expect
26942 local blocks=$($LFS getsom -b $file)
26943 expect=$(stat -c %b $file)
26944 [[ $blocks == $expect ]] ||
26945 error "$file expected blocks: $expect, got: $blocks"
26953 cancel_lru_locks mdc
26955 size=$($LFS getsom -s $1)
26956 [[ $size == $expect ]] ||
26957 error "$file expected size: $expect, got: $size"
26961 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
26962 skip "Need MDS version at least 2.11.52"
26966 touch $DIR/$tfile || error "touch $tfile failed"
26968 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
26969 save_lustre_params client "llite.*.xattr_cache" > $save
26970 lctl set_param llite.*.xattr_cache=0
26971 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
26973 # single-threaded write
26974 echo "Test SOM for single-threaded write"
26975 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
26976 error "write $tfile failed"
26977 check_lsom_size $DIR/$tfile $bs
26980 local size=$(($num * $bs))
26984 echo "Test SOM for single client multi-threaded($num) write"
26985 $TRUNCATE $DIR/$tfile 0
26986 for ((i = 0; i < $num; i++)); do
26987 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
26989 offset=$((offset + $bs))
26991 for (( i=0; i < $num; i++ )); do
26994 check_lsom_size $DIR/$tfile $size
26996 $TRUNCATE $DIR/$tfile 0
26997 for ((i = 0; i < $num; i++)); do
26998 offset=$((offset - $bs))
26999 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27002 for (( i=0; i < $num; i++ )); do
27005 check_lsom_size $DIR/$tfile $size
27007 # multi-client writes
27008 num=$(get_node_count ${CLIENTS//,/ })
27009 size=$(($num * $bs))
27013 echo "Test SOM for multi-client ($num) writes"
27014 $TRUNCATE $DIR/$tfile 0
27015 for client in ${CLIENTS//,/ }; do
27016 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27019 offset=$((offset + $bs))
27021 for (( i=0; i < $num; i++ )); do
27024 check_lsom_size $DIR/$tfile $offset
27027 $TRUNCATE $DIR/$tfile 0
27028 for client in ${CLIENTS//,/ }; do
27029 offset=$((offset - $bs))
27030 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27034 for (( i=0; i < $num; i++ )); do
27037 check_lsom_size $DIR/$tfile $size
27040 echo "Test SOM for truncate"
27041 $TRUNCATE $DIR/$tfile 1048576
27042 check_lsom_size $DIR/$tfile 1048576
27043 $TRUNCATE $DIR/$tfile 1234
27044 check_lsom_size $DIR/$tfile 1234
27046 # verify SOM blocks count
27047 echo "Verify SOM block count"
27048 $TRUNCATE $DIR/$tfile 0
27049 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
27050 error "failed to write file $tfile"
27051 check_lsom_data $DIR/$tfile
27053 run_test 806 "Verify Lazy Size on MDS"
27056 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
27057 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
27058 skip "Need MDS version at least 2.11.52"
27060 # Registration step
27061 changelog_register || error "changelog_register failed"
27062 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
27063 changelog_users $SINGLEMDS | grep -q $cl_user ||
27064 error "User $cl_user not found in changelog_users"
27066 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
27067 save_lustre_params client "llite.*.xattr_cache" > $save
27068 lctl set_param llite.*.xattr_cache=0
27069 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
27071 rm -rf $DIR/$tdir || error "rm $tdir failed"
27072 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
27073 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
27074 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
27075 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
27076 error "truncate $tdir/trunc failed"
27079 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
27080 error "write $tfile failed"
27082 # multi-client wirtes
27083 local num=$(get_node_count ${CLIENTS//,/ })
27087 echo "Test SOM for multi-client ($num) writes"
27088 touch $DIR/$tfile || error "touch $tfile failed"
27089 $TRUNCATE $DIR/$tfile 0
27090 for client in ${CLIENTS//,/ }; do
27091 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27094 offset=$((offset + $bs))
27096 for (( i=0; i < $num; i++ )); do
27100 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
27101 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
27102 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
27103 check_lsom_data $DIR/$tdir/trunc
27104 check_lsom_data $DIR/$tdir/single_dd
27105 check_lsom_data $DIR/$tfile
27108 # Deregistration step
27109 changelog_deregister || error "changelog_deregister failed"
27111 run_test 807 "verify LSOM syncing tool"
27113 check_som_nologged()
27115 local lines=$($LFS changelog $FSNAME-MDT0000 |
27116 grep 'x=trusted.som' | wc -l)
27117 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
27121 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
27122 skip "Need MDS version at least 2.11.55"
27124 # Registration step
27125 changelog_register || error "changelog_register failed"
27127 touch $DIR/$tfile || error "touch $tfile failed"
27130 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
27131 error "write $tfile failed"
27134 $TRUNCATE $DIR/$tfile 1234
27137 $TRUNCATE $DIR/$tfile 1048576
27140 # Deregistration step
27141 changelog_deregister || error "changelog_deregister failed"
27143 run_test 808 "Check trusted.som xattr not logged in Changelogs"
27148 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
27152 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
27153 skip "Need MDS version at least 2.11.56"
27155 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
27156 error "failed to create DoM-only file $DIR/$tfile"
27157 touch $DIR/$tfile || error "touch $tfile failed"
27158 check_som_nodata $DIR/$tfile
27160 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
27161 error "write $tfile failed"
27162 check_som_nodata $DIR/$tfile
27164 $TRUNCATE $DIR/$tfile 1234
27165 check_som_nodata $DIR/$tfile
27167 $TRUNCATE $DIR/$tfile 4097
27168 check_som_nodata $DIR/$file
27170 run_test 809 "Verify no SOM xattr store for DoM-only files"
27173 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27174 $GSS && skip_env "could not run with gss"
27175 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
27176 skip "OST < 2.12.58 doesn't align checksum"
27179 stack_trap "set_checksums $ORIG_CSUM" EXIT
27180 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
27185 for csum in $CKSUM_TYPES; do
27186 #define OBD_FAIL_OSC_NO_GRANT 0x411
27187 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
27188 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
27190 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
27191 before=$(md5sum $DIR/$tfile)
27192 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
27193 after=$(md5sum $DIR/$tfile)
27194 [ "$before" == "$after" ] ||
27195 error "$csum: $before != $after bs=$1 seek=$2"
27199 run_test 810 "partial page writes on ZFS (LU-11663)"
27202 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
27203 skip "OST < 2.12.51 doesn't support this fail_loc"
27205 $LFS setstripe -c 1 -i 0 $DIR/$tfile
27206 # ensure ost1 is connected
27207 stat $DIR/$tfile >/dev/null || error "can't stat"
27208 wait_osc_import_state client ost1 FULL
27209 # no locks, no reqs to let the connection idle
27210 cancel_lru_locks osc
27212 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
27213 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
27214 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
27215 wait_osc_import_state client ost1 CONNECTING
27216 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
27218 stat $DIR/$tfile >/dev/null || error "can't stat file"
27220 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
27222 test_812b() { # LU-12378
27223 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
27224 skip "OST < 2.12.51 doesn't support this fail_loc"
27226 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
27227 # ensure ost1 is connected
27228 stat $DIR/$tfile >/dev/null || error "can't stat"
27229 wait_osc_import_state client ost1 FULL
27230 # no locks, no reqs to let the connection idle
27231 cancel_lru_locks osc
27233 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
27234 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
27235 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
27236 wait_osc_import_state client ost1 CONNECTING
27237 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
27239 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
27240 wait_osc_import_state client ost1 IDLE
27242 run_test 812b "do not drop no resend request for idle connect"
27247 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
27249 $LFS setstripe -c 1 -o 0 $DIR/$tfile
27250 $LFS getstripe $DIR/$tfile
27251 $LCTL set_param osc.*.idle_timeout=10
27252 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
27253 # ensure ost1 is connected
27254 stat $DIR/$tfile >/dev/null || error "can't stat"
27255 wait_osc_import_state client ost1 FULL
27256 # no locks, no reqs to let the connection idle
27257 cancel_lru_locks osc
27259 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
27260 $LCTL set_param fail_loc=0x80000533
27262 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
27264 run_test 812c "idle import vs lock enqueue race"
27267 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
27268 [ -z "$file_heat_sav" ] && skip "no file heat support"
27279 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
27280 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
27282 $LCTL set_param -n llite.*.file_heat=1
27283 echo "Turn on file heat"
27284 echo "Period second: $period_second, Decay percentage: $decay_pct"
27286 echo "QQQQ" > $DIR/$tfile
27287 echo "QQQQ" > $DIR/$tfile
27288 echo "QQQQ" > $DIR/$tfile
27289 cat $DIR/$tfile > /dev/null
27290 cat $DIR/$tfile > /dev/null
27291 cat $DIR/$tfile > /dev/null
27292 cat $DIR/$tfile > /dev/null
27294 local out=$($LFS heat_get $DIR/$tfile)
27296 $LFS heat_get $DIR/$tfile
27297 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27298 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27299 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27300 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27302 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
27303 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
27304 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
27305 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
27307 sleep $((period_second + 3))
27308 echo "Sleep $((period_second + 3)) seconds..."
27309 # The recursion formula to calculate the heat of the file f is as
27311 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
27312 # Where Hi is the heat value in the period between time points i*I and
27313 # (i+1)*I; Ci is the access count in the period; the symbol P refers
27314 # to the weight of Ci.
27315 out=$($LFS heat_get $DIR/$tfile)
27316 $LFS heat_get $DIR/$tfile
27317 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27318 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27319 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27320 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27322 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
27323 error "read sample ($readsample) is wrong"
27324 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
27325 error "write sample ($writesample) is wrong"
27326 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
27327 error "read bytes ($readbyte) is wrong"
27328 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
27329 error "write bytes ($writebyte) is wrong"
27331 echo "QQQQ" > $DIR/$tfile
27332 echo "QQQQ" > $DIR/$tfile
27333 echo "QQQQ" > $DIR/$tfile
27334 cat $DIR/$tfile > /dev/null
27335 cat $DIR/$tfile > /dev/null
27336 cat $DIR/$tfile > /dev/null
27337 cat $DIR/$tfile > /dev/null
27339 sleep $((period_second + 3))
27340 echo "Sleep $((period_second + 3)) seconds..."
27342 out=$($LFS heat_get $DIR/$tfile)
27343 $LFS heat_get $DIR/$tfile
27344 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27345 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27346 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27347 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27349 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
27350 4 * $decay_pct) / 100") -eq 1 ] ||
27351 error "read sample ($readsample1) is wrong"
27352 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
27353 3 * $decay_pct) / 100") -eq 1 ] ||
27354 error "write sample ($writesample1) is wrong"
27355 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
27356 20 * $decay_pct) / 100") -eq 1 ] ||
27357 error "read bytes ($readbyte1) is wrong"
27358 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
27359 15 * $decay_pct) / 100") -eq 1 ] ||
27360 error "write bytes ($writebyte1) is wrong"
27362 echo "Turn off file heat for the file $DIR/$tfile"
27363 $LFS heat_set -o $DIR/$tfile
27365 echo "QQQQ" > $DIR/$tfile
27366 echo "QQQQ" > $DIR/$tfile
27367 echo "QQQQ" > $DIR/$tfile
27368 cat $DIR/$tfile > /dev/null
27369 cat $DIR/$tfile > /dev/null
27370 cat $DIR/$tfile > /dev/null
27371 cat $DIR/$tfile > /dev/null
27373 out=$($LFS heat_get $DIR/$tfile)
27374 $LFS heat_get $DIR/$tfile
27375 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27376 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27377 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27378 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27380 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
27381 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
27382 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
27383 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
27385 echo "Trun on file heat for the file $DIR/$tfile"
27386 $LFS heat_set -O $DIR/$tfile
27388 echo "QQQQ" > $DIR/$tfile
27389 echo "QQQQ" > $DIR/$tfile
27390 echo "QQQQ" > $DIR/$tfile
27391 cat $DIR/$tfile > /dev/null
27392 cat $DIR/$tfile > /dev/null
27393 cat $DIR/$tfile > /dev/null
27394 cat $DIR/$tfile > /dev/null
27396 out=$($LFS heat_get $DIR/$tfile)
27397 $LFS heat_get $DIR/$tfile
27398 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27399 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27400 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27401 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27403 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
27404 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
27405 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
27406 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
27408 $LFS heat_set -c $DIR/$tfile
27409 $LCTL set_param -n llite.*.file_heat=0
27410 echo "Turn off file heat support for the Lustre filesystem"
27412 echo "QQQQ" > $DIR/$tfile
27413 echo "QQQQ" > $DIR/$tfile
27414 echo "QQQQ" > $DIR/$tfile
27415 cat $DIR/$tfile > /dev/null
27416 cat $DIR/$tfile > /dev/null
27417 cat $DIR/$tfile > /dev/null
27418 cat $DIR/$tfile > /dev/null
27420 out=$($LFS heat_get $DIR/$tfile)
27421 $LFS heat_get $DIR/$tfile
27422 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27423 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27424 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27425 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27427 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
27428 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
27429 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
27430 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
27432 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
27435 run_test 813 "File heat verfication"
27439 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
27440 echo -n y >> $DIR/$tfile
27441 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
27442 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
27444 run_test 814 "sparse cp works as expected (LU-12361)"
27448 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
27449 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
27451 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
27454 local ost1_imp=$(get_osc_import_name client ost1)
27455 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
27458 $LFS setstripe -c 1 -i 0 $DIR/$tfile
27459 # ensure ost1 is connected
27461 stat $DIR/$tfile >/dev/null || error "can't stat"
27462 wait_osc_import_state client ost1 FULL
27463 # no locks, no reqs to let the connection idle
27464 cancel_lru_locks osc
27465 lru_resize_disable osc
27468 before=$($LCTL get_param -n \
27469 ldlm.namespaces.$imp_name.lru_size)
27471 wait_osc_import_state client ost1 IDLE
27472 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
27473 now=$($LCTL get_param -n \
27474 ldlm.namespaces.$imp_name.lru_size)
27475 [ $before == $now ] || error "lru_size changed $before != $now"
27477 run_test 816 "do not reset lru_resize on idle reconnect"
27481 exportfs -u localhost:$DIR/nfsexp
27486 systemctl restart nfs-server.service || skip "failed to restart nfsd"
27488 mkdir -p $DIR/nfsexp
27489 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
27490 error "failed to export nfs"
27492 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
27493 stack_trap cleanup_817 EXIT
27495 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
27496 error "failed to mount nfs to $tmpdir"
27498 cp /bin/true $tmpdir
27499 $DIR/nfsexp/true || error "failed to execute 'true' command"
27501 run_test 817 "nfsd won't cache write lock for exec file"
27505 $LFS setstripe -c1 -i0 $DIR/$tfile
27506 $LFS setstripe -c1 -i1 $DIR/$tfile
27508 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
27509 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
27510 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
27511 error "start $SINGLEMDS failed"
27514 run_test 818 "unlink with failed llog"
27517 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
27518 cancel_lru_locks osc
27519 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
27520 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
27521 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
27524 run_test 819a "too big niobuf in read"
27527 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
27528 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
27529 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
27530 cancel_lru_locks osc
27534 run_test 819b "too big niobuf in write"
27537 function test_820_start_ost() {
27540 for num in $(seq $OSTCOUNT); do
27541 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
27546 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27549 umount_client $MOUNT || error "umount failed"
27550 for num in $(seq $OSTCOUNT); do
27554 # mount client with no active OSTs
27555 # so that the client can't initialize max LOV EA size
27556 # from OSC notifications
27557 mount_client $MOUNT || error "mount failed"
27558 # delay OST starting to keep this 0 max EA size for a while
27559 test_820_start_ost &
27561 # create a directory on MDS2
27562 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
27563 error "Failed to create directory"
27564 # open intent should update default EA size
27565 # see mdc_update_max_ea_from_body()
27566 # notice this is the very first RPC to MDS2
27567 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
27570 # With SSK, this situation can lead to -EPERM being returned.
27571 # In that case, simply retry.
27572 if [ $ret -ne 0 ] && $SHARED_KEY; then
27573 if echo "$out" | grep -q "not permitted"; then
27574 cp /etc/services $DIR/$tdir/mds2
27578 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
27580 run_test 820 "update max EA from open intent"
27583 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
27585 save_lustre_params mds1 \
27586 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
27587 do_facet $SINGLEMDS "$LCTL set_param -n \
27588 osp.$FSNAME-OST*MDT0000.max_create_count=0"
27589 do_facet $SINGLEMDS "$LCTL set_param -n \
27590 osp.$FSNAME-OST0000*MDT0000.max_create_count=20000"
27592 # wait for statfs update to clear OS_STATFS_NOPRECREATE
27593 local maxage=$(do_facet mds1 $LCTL get_param -n \
27594 osp.$FSNAME-OST0000*MDT0000.maxage)
27595 sleep $((maxage + 1))
27597 #define OBD_FAIL_NET_ERROR_RPC 0x532
27598 do_facet mds1 "$LCTL set_param fail_loc=0x80000532 fail_val=5"
27600 stack_trap "restore_lustre_params < $p; rm $p"
27602 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
27603 osp.$FSNAME-OST0000*MDT0000.create_count")
27604 for i in $(seq 1 $count); do
27605 touch $DIR/$tfile.${i} || error "touch failed"
27608 run_test 822 "test precreate failure"
27611 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
27612 local OST_MAX_PRECREATE=20000
27614 save_lustre_params mds1 \
27615 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
27616 do_facet $SINGLEMDS "$LCTL set_param -n \
27617 osp.$FSNAME-OST*MDT0000.max_create_count=0"
27618 do_facet $SINGLEMDS "$LCTL set_param -n \
27619 osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE"
27621 stack_trap "restore_lustre_params < $p; rm $p"
27623 do_facet $SINGLEMDS "$LCTL set_param -n \
27624 osp.$FSNAME-OST*-osc-MDT*.create_count=100200"
27626 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
27627 osp.$FSNAME-OST0000*MDT0000.create_count")
27628 local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \
27629 osp.$FSNAME-OST0000*MDT0000.max_create_count")
27630 local expect_count=$(((($max/2)/256) * 256))
27632 log "setting create_count to 100200:"
27633 log " -result- count: $count with max: $max, expecting: $expect_count"
27635 [[ $count -eq expect_count ]] ||
27636 error "Create count not set to max precreate."
27638 run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum"
27641 # tests that do cleanup/setup should be run at the end
27645 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27648 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
27649 $LCTL set_param fail_loc=0x903
27651 cancel_lru_locks MGC
27653 FAIL_ON_ERROR=true cleanup
27654 FAIL_ON_ERROR=true setup
27656 run_test 900 "umount should not race with any mgc requeue thread"
27658 # LUS-6253/LU-11185
27664 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27666 # some get_param have a bug to handle dot in param name
27667 cancel_lru_locks MGC
27668 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
27669 olds=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
27670 umount_client $MOUNT || error "umount failed"
27671 mount_client $MOUNT || error "mount failed"
27672 cancel_lru_locks MGC
27673 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
27674 news=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
27676 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
27677 [ $olds -lt $news ] && error "mgs lock leak ($olds != $news)"
27681 run_test 901 "don't leak a mgc lock on client umount"
27685 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
27686 skip "client does not have LU-13377 fix"
27687 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
27688 $LCTL set_param fail_loc=0x1415
27689 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
27690 cancel_lru_locks osc
27693 run_test 902 "test short write doesn't hang lustre"
27697 $LFS setstripe -i 0 -c 1 $DIR/$tfile $DIR/${tfile}-2
27698 echo "blah" > $DIR/${tfile}-2
27699 dd if=/dev/zero of=$DIR/$tfile bs=1M count=6 conv=fsync
27700 #define OBD_FAIL_OSC_SLOW_PAGE_EVICT 0x417
27701 $LCTL set_param fail_loc=0x417 fail_val=20
27703 mv $DIR/${tfile}-2 $DIR/$tfile # Destroys the big object
27704 sleep 1 # To start the destroy
27705 wait_destroy_complete 150 || error "Destroy taking too long"
27706 cat $DIR/$tfile > /dev/null || error "Evicted"
27708 run_test 903 "Test long page discard does not cause evictions"
27711 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
27712 check_and_cleanup_lustre
27713 if [ "$I_MOUNTED" != "yes" ]; then
27714 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true